mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-05 02:18:28 +00:00
Port rest of validation check to new infra
This commit is contained in:
parent
aa9a44c60a
commit
e1902bbf3b
@ -3,12 +3,9 @@ use fj_math::Winding;
|
||||
use crate::{
|
||||
geometry::Geometry,
|
||||
storage::Handle,
|
||||
topology::{Cycle, HalfEdge, Sketch},
|
||||
topology::{Cycle, HalfEdge, Region, Sketch},
|
||||
validation::{
|
||||
checks::{
|
||||
AdjacentHalfEdgesNotConnected, MultipleReferencesToObject,
|
||||
ReferenceCounter,
|
||||
},
|
||||
checks::{AdjacentHalfEdgesNotConnected, MultipleReferencesToObject},
|
||||
ValidationCheck,
|
||||
},
|
||||
};
|
||||
@ -26,13 +23,18 @@ impl Validate for Sketch {
|
||||
AdjacentHalfEdgesNotConnected::check(self, geometry, config)
|
||||
.map(Into::into),
|
||||
);
|
||||
errors.extend(
|
||||
MultipleReferencesToObject::<Cycle, Region>::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,
|
||||
);
|
||||
@ -67,22 +69,6 @@ pub enum SketchValidationError {
|
||||
}
|
||||
|
||||
impl SketchValidationError {
|
||||
fn check_object_references(
|
||||
sketch: &Sketch,
|
||||
_config: &ValidationConfig,
|
||||
errors: &mut Vec<ValidationError>,
|
||||
) {
|
||||
let mut cycles = ReferenceCounter::new();
|
||||
|
||||
sketch.regions().iter().for_each(|r| {
|
||||
r.all_cycles().for_each(|c| {
|
||||
cycles.count(c.clone(), r.clone());
|
||||
})
|
||||
});
|
||||
|
||||
errors.extend(cycles.multiples().map(Into::into));
|
||||
}
|
||||
|
||||
fn check_exterior_cycles(
|
||||
sketch: &Sketch,
|
||||
geometry: &Geometry,
|
||||
|
@ -2,7 +2,7 @@ use std::{any::type_name_of_val, collections::HashMap, fmt};
|
||||
|
||||
use crate::{
|
||||
storage::Handle,
|
||||
topology::{Cycle, HalfEdge, Sketch},
|
||||
topology::{Cycle, HalfEdge, Region, Sketch},
|
||||
validation::ValidationCheck,
|
||||
};
|
||||
|
||||
@ -34,6 +34,24 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl ValidationCheck<Sketch> for MultipleReferencesToObject<Cycle, Region> {
|
||||
fn check<'r>(
|
||||
object: &'r Sketch,
|
||||
_: &'r crate::geometry::Geometry,
|
||||
_: &'r crate::validation::ValidationConfig,
|
||||
) -> impl Iterator<Item = Self> + 'r {
|
||||
let mut cycles = ReferenceCounter::new();
|
||||
|
||||
for region in object.regions() {
|
||||
for cycle in region.all_cycles() {
|
||||
cycles.count(cycle.clone(), region.clone());
|
||||
}
|
||||
}
|
||||
|
||||
cycles.multiples()
|
||||
}
|
||||
}
|
||||
|
||||
impl ValidationCheck<Sketch> for MultipleReferencesToObject<HalfEdge, Cycle> {
|
||||
fn check<'r>(
|
||||
object: &'r Sketch,
|
||||
|
Loading…
Reference in New Issue
Block a user