Move reference infra to new validation infra

This commit is contained in:
Hanno Braun 2024-05-27 14:21:39 +02:00
parent 84de93d676
commit c4309bccd9
6 changed files with 20 additions and 16 deletions

View File

@ -65,7 +65,6 @@ mod curve;
mod cycle; mod cycle;
mod face; mod face;
mod half_edge; mod half_edge;
mod references;
mod region; mod region;
mod shell; mod shell;
mod sketch; mod sketch;
@ -78,10 +77,7 @@ use crate::{
validation::{ValidationConfig, ValidationError}, validation::{ValidationConfig, ValidationError},
}; };
pub use self::{ pub use self::{sketch::SketchValidationError, solid::SolidValidationError};
references::MultipleReferencesToObject, sketch::SketchValidationError,
solid::SolidValidationError,
};
/// Assert that some object has a validation error which matches a specific /// Assert that some object has a validation error which matches a specific
/// pattern. This is preferred to matching on [`Validate::validate_and_return_first_error`], since usually we don't care about the order. /// pattern. This is preferred to matching on [`Validate::validate_and_return_first_error`], since usually we don't care about the order.

View File

@ -4,12 +4,13 @@ use crate::{
geometry::Geometry, geometry::Geometry,
storage::Handle, storage::Handle,
topology::{Cycle, Sketch}, topology::{Cycle, Sketch},
validation::{checks::AdjacentHalfEdgesNotConnected, ValidationCheck}, validation::{
checks::{AdjacentHalfEdgesNotConnected, ReferenceCounter},
ValidationCheck,
},
}; };
use super::{ use super::{Validate, ValidationConfig, ValidationError};
references::ReferenceCounter, Validate, ValidationConfig, ValidationError,
};
impl Validate for Sketch { impl Validate for Sketch {
fn validate( fn validate(

View File

@ -4,12 +4,11 @@ use crate::{
geometry::Geometry, geometry::Geometry,
storage::Handle, storage::Handle,
topology::{Solid, Vertex}, topology::{Solid, Vertex},
validation::checks::ReferenceCounter,
}; };
use fj_math::Point; use fj_math::Point;
use super::{ use super::{Validate, ValidationConfig, ValidationError};
references::ReferenceCounter, Validate, ValidationConfig, ValidationError,
};
impl Validate for Solid { impl Validate for Solid {
fn validate( fn validate(

View File

@ -8,6 +8,7 @@ mod face_boundary;
mod face_winding; mod face_winding;
mod half_edge_connection; mod half_edge_connection;
mod half_edge_has_no_sibling; mod half_edge_has_no_sibling;
mod multiple_references;
pub use self::{ pub use self::{
coincident_half_edges_are_not_siblings::CoincidentHalfEdgesAreNotSiblings, coincident_half_edges_are_not_siblings::CoincidentHalfEdgesAreNotSiblings,
@ -16,4 +17,5 @@ pub use self::{
face_winding::InteriorCycleHasInvalidWinding, face_winding::InteriorCycleHasInvalidWinding,
half_edge_connection::AdjacentHalfEdgesNotConnected, half_edge_connection::AdjacentHalfEdgesNotConnected,
half_edge_has_no_sibling::HalfEdgeHasNoSibling, half_edge_has_no_sibling::HalfEdgeHasNoSibling,
multiple_references::{MultipleReferencesToObject, ReferenceCounter},
}; };

View File

@ -30,9 +30,17 @@ where
} }
} }
// 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.
#[allow(missing_docs)]
#[derive(Default)] #[derive(Default)]
pub struct ReferenceCounter<T, U>(HashMap<Handle<T>, Vec<Handle<U>>>); pub struct ReferenceCounter<T, U>(HashMap<Handle<T>, Vec<Handle<U>>>);
// 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.
#[allow(missing_docs)]
impl<T, U> ReferenceCounter<T, U> { impl<T, U> ReferenceCounter<T, U> {
pub fn new() -> Self { pub fn new() -> Self {
Self(HashMap::new()) Self(HashMap::new())

View File

@ -2,15 +2,13 @@ use std::{convert::Infallible, fmt};
use crate::{ use crate::{
topology::{Cycle, Face, HalfEdge, Region, Shell}, topology::{Cycle, Face, HalfEdge, Region, Shell},
validate::{ validate::{SketchValidationError, SolidValidationError},
MultipleReferencesToObject, SketchValidationError, SolidValidationError,
},
}; };
use super::checks::{ use super::checks::{
AdjacentHalfEdgesNotConnected, CoincidentHalfEdgesAreNotSiblings, AdjacentHalfEdgesNotConnected, CoincidentHalfEdgesAreNotSiblings,
CurveGeometryMismatch, FaceHasNoBoundary, HalfEdgeHasNoSibling, CurveGeometryMismatch, FaceHasNoBoundary, HalfEdgeHasNoSibling,
InteriorCycleHasInvalidWinding, InteriorCycleHasInvalidWinding, MultipleReferencesToObject,
}; };
/// An error that can occur during a validation /// An error that can occur during a validation