mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-03 17:38:27 +00:00
Port part of validation test to new infrastructure
This commit is contained in:
parent
96617eeb1d
commit
e5d7a54a43
@ -3,7 +3,7 @@ use std::iter::repeat;
|
||||
use crate::{
|
||||
geometry::Geometry,
|
||||
storage::Handle,
|
||||
topology::{Cycle, HalfEdge, Region, Solid, Vertex},
|
||||
topology::{Cycle, Face, HalfEdge, Region, Solid, Vertex},
|
||||
validation::{
|
||||
checks::{MultipleReferencesToObject, ReferenceCounter},
|
||||
ValidationCheck,
|
||||
@ -20,6 +20,12 @@ impl Validate for Solid {
|
||||
errors: &mut Vec<ValidationError>,
|
||||
geometry: &Geometry,
|
||||
) {
|
||||
errors.extend(
|
||||
MultipleReferencesToObject::<Region, Face>::check(
|
||||
self, geometry, config,
|
||||
)
|
||||
.map(Into::into),
|
||||
);
|
||||
errors.extend(
|
||||
MultipleReferencesToObject::<Cycle, Region>::check(
|
||||
self, geometry, config,
|
||||
@ -156,17 +162,14 @@ impl SolidValidationError {
|
||||
errors: &mut Vec<ValidationError>,
|
||||
) {
|
||||
let mut faces = ReferenceCounter::new();
|
||||
let mut regions = ReferenceCounter::new();
|
||||
|
||||
solid.shells().iter().for_each(|s| {
|
||||
s.faces().into_iter().for_each(|f| {
|
||||
faces.count(f.clone(), s.clone());
|
||||
regions.count(f.region().clone(), f.clone());
|
||||
})
|
||||
});
|
||||
|
||||
errors.extend(faces.multiples().map(Into::into));
|
||||
errors.extend(regions.multiples().map(Into::into));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ use std::{any::type_name_of_val, collections::HashMap, fmt};
|
||||
use crate::{
|
||||
geometry::Geometry,
|
||||
storage::Handle,
|
||||
topology::{Cycle, HalfEdge, Region, Sketch, Solid},
|
||||
topology::{Cycle, Face, HalfEdge, Region, Sketch, Solid},
|
||||
validation::{ValidationCheck, ValidationConfig},
|
||||
};
|
||||
|
||||
@ -73,6 +73,24 @@ impl ValidationCheck<Sketch> for MultipleReferencesToObject<HalfEdge, Cycle> {
|
||||
}
|
||||
}
|
||||
|
||||
impl ValidationCheck<Solid> for MultipleReferencesToObject<Region, Face> {
|
||||
fn check<'r>(
|
||||
object: &'r Solid,
|
||||
_: &'r Geometry,
|
||||
_: &'r ValidationConfig,
|
||||
) -> impl Iterator<Item = Self> + 'r {
|
||||
let mut regions = ReferenceCounter::new();
|
||||
|
||||
for shell in object.shells() {
|
||||
for face in shell.faces() {
|
||||
regions.count(face.region().clone(), face.clone());
|
||||
}
|
||||
}
|
||||
|
||||
regions.multiples()
|
||||
}
|
||||
}
|
||||
|
||||
impl ValidationCheck<Solid> for MultipleReferencesToObject<Cycle, Region> {
|
||||
fn check<'r>(
|
||||
object: &'r Solid,
|
||||
|
Loading…
Reference in New Issue
Block a user