mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-05 10:28:27 +00:00
Port part of validation check to new infra
This commit is contained in:
parent
fa4642ff8a
commit
aa9a44c60a
@ -3,9 +3,12 @@ use fj_math::Winding;
|
||||
use crate::{
|
||||
geometry::Geometry,
|
||||
storage::Handle,
|
||||
topology::{Cycle, Sketch},
|
||||
topology::{Cycle, HalfEdge, Sketch},
|
||||
validation::{
|
||||
checks::{AdjacentHalfEdgesNotConnected, ReferenceCounter},
|
||||
checks::{
|
||||
AdjacentHalfEdgesNotConnected, MultipleReferencesToObject,
|
||||
ReferenceCounter,
|
||||
},
|
||||
ValidationCheck,
|
||||
},
|
||||
};
|
||||
@ -23,6 +26,12 @@ impl Validate for Sketch {
|
||||
AdjacentHalfEdgesNotConnected::check(self, geometry, config)
|
||||
.map(Into::into),
|
||||
);
|
||||
errors.extend(
|
||||
MultipleReferencesToObject::<HalfEdge, Cycle>::check(
|
||||
self, geometry, config,
|
||||
)
|
||||
.map(Into::into),
|
||||
);
|
||||
SketchValidationError::check_object_references(self, config, errors);
|
||||
SketchValidationError::check_exterior_cycles(
|
||||
self, geometry, config, errors,
|
||||
@ -64,19 +73,14 @@ impl SketchValidationError {
|
||||
errors: &mut Vec<ValidationError>,
|
||||
) {
|
||||
let mut cycles = ReferenceCounter::new();
|
||||
let mut half_edges = ReferenceCounter::new();
|
||||
|
||||
sketch.regions().iter().for_each(|r| {
|
||||
r.all_cycles().for_each(|c| {
|
||||
cycles.count(c.clone(), r.clone());
|
||||
c.half_edges().into_iter().for_each(|e| {
|
||||
half_edges.count(e.clone(), c.clone());
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
errors.extend(cycles.multiples().map(Into::into));
|
||||
errors.extend(half_edges.multiples().map(Into::into));
|
||||
}
|
||||
|
||||
fn check_exterior_cycles(
|
||||
|
@ -1,6 +1,10 @@
|
||||
use std::{any::type_name_of_val, collections::HashMap, fmt};
|
||||
|
||||
use crate::storage::Handle;
|
||||
use crate::{
|
||||
storage::Handle,
|
||||
topology::{Cycle, HalfEdge, Sketch},
|
||||
validation::ValidationCheck,
|
||||
};
|
||||
|
||||
/// Object that should be exclusively owned by another, is not
|
||||
///
|
||||
@ -30,6 +34,26 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl ValidationCheck<Sketch> for MultipleReferencesToObject<HalfEdge, Cycle> {
|
||||
fn check<'r>(
|
||||
object: &'r Sketch,
|
||||
_: &'r crate::geometry::Geometry,
|
||||
_: &'r crate::validation::ValidationConfig,
|
||||
) -> impl Iterator<Item = Self> + 'r {
|
||||
let mut half_edges = ReferenceCounter::new();
|
||||
|
||||
for region in object.regions() {
|
||||
for cycle in region.all_cycles() {
|
||||
for half_edge in cycle.half_edges() {
|
||||
half_edges.count(half_edge.clone(), cycle.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
half_edges.multiples()
|
||||
}
|
||||
}
|
||||
|
||||
// Warnings are temporarily silenced, until this struct can be made private.
|
||||
// This can happen once this validation check has been fully ported from the old
|
||||
// infrastructure.
|
||||
|
Loading…
Reference in New Issue
Block a user