mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-07 03:18:30 +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::{
|
use crate::{
|
||||||
geometry::Geometry,
|
geometry::Geometry,
|
||||||
storage::Handle,
|
storage::Handle,
|
||||||
topology::{Cycle, HalfEdge, Sketch},
|
topology::{Cycle, HalfEdge, Region, Sketch},
|
||||||
validation::{
|
validation::{
|
||||||
checks::{
|
checks::{AdjacentHalfEdgesNotConnected, MultipleReferencesToObject},
|
||||||
AdjacentHalfEdgesNotConnected, MultipleReferencesToObject,
|
|
||||||
ReferenceCounter,
|
|
||||||
},
|
|
||||||
ValidationCheck,
|
ValidationCheck,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -26,13 +23,18 @@ impl Validate for Sketch {
|
|||||||
AdjacentHalfEdgesNotConnected::check(self, geometry, config)
|
AdjacentHalfEdgesNotConnected::check(self, geometry, config)
|
||||||
.map(Into::into),
|
.map(Into::into),
|
||||||
);
|
);
|
||||||
|
errors.extend(
|
||||||
|
MultipleReferencesToObject::<Cycle, Region>::check(
|
||||||
|
self, geometry, config,
|
||||||
|
)
|
||||||
|
.map(Into::into),
|
||||||
|
);
|
||||||
errors.extend(
|
errors.extend(
|
||||||
MultipleReferencesToObject::<HalfEdge, Cycle>::check(
|
MultipleReferencesToObject::<HalfEdge, Cycle>::check(
|
||||||
self, geometry, config,
|
self, geometry, config,
|
||||||
)
|
)
|
||||||
.map(Into::into),
|
.map(Into::into),
|
||||||
);
|
);
|
||||||
SketchValidationError::check_object_references(self, config, errors);
|
|
||||||
SketchValidationError::check_exterior_cycles(
|
SketchValidationError::check_exterior_cycles(
|
||||||
self, geometry, config, errors,
|
self, geometry, config, errors,
|
||||||
);
|
);
|
||||||
@ -67,22 +69,6 @@ pub enum SketchValidationError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl 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(
|
fn check_exterior_cycles(
|
||||||
sketch: &Sketch,
|
sketch: &Sketch,
|
||||||
geometry: &Geometry,
|
geometry: &Geometry,
|
||||||
|
@ -2,7 +2,7 @@ use std::{any::type_name_of_val, collections::HashMap, fmt};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
storage::Handle,
|
storage::Handle,
|
||||||
topology::{Cycle, HalfEdge, Sketch},
|
topology::{Cycle, HalfEdge, Region, Sketch},
|
||||||
validation::ValidationCheck,
|
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> {
|
impl ValidationCheck<Sketch> for MultipleReferencesToObject<HalfEdge, Cycle> {
|
||||||
fn check<'r>(
|
fn check<'r>(
|
||||||
object: &'r Sketch,
|
object: &'r Sketch,
|
||||||
|
Loading…
Reference in New Issue
Block a user