From 97ac5c1f759897badde8a3379fdb068a0e3b74aa Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 18 Mar 2024 13:46:05 +0100 Subject: [PATCH 1/3] Expect `&Geometry` in `ValidationCheck` method --- .../fj-core/src/validation/checks/half_edge_connection.rs | 5 ++++- crates/fj-core/src/validation/validation_check.rs | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/validation/checks/half_edge_connection.rs b/crates/fj-core/src/validation/checks/half_edge_connection.rs index 04f45b2e9..5a2dec955 100644 --- a/crates/fj-core/src/validation/checks/half_edge_connection.rs +++ b/crates/fj-core/src/validation/checks/half_edge_connection.rs @@ -87,7 +87,10 @@ mod tests { let mut core = Core::new(); let valid = Cycle::polygon([[0., 0.], [1., 0.], [1., 1.]], &mut core); - AdjacentHalfEdgesNotConnected::check_and_return_first_error(&valid)?; + AdjacentHalfEdgesNotConnected::check_and_return_first_error( + &valid, + &core.layers.geometry, + )?; let invalid = valid.update_half_edge( valid.half_edges().first(), diff --git a/crates/fj-core/src/validation/validation_check.rs b/crates/fj-core/src/validation/validation_check.rs index 9e75b1aef..7190343d4 100644 --- a/crates/fj-core/src/validation/validation_check.rs +++ b/crates/fj-core/src/validation/validation_check.rs @@ -1,5 +1,7 @@ use std::fmt::Display; +use crate::geometry::Geometry; + use super::ValidationConfig; /// Run a specific validation check on an object @@ -17,7 +19,10 @@ pub trait ValidationCheck: Sized { /// /// This method is designed for convenience over flexibility (it is intended /// for use in unit tests), and thus always uses the default configuration. - fn check_and_return_first_error(object: &T) -> Result<(), Self> { + fn check_and_return_first_error( + object: &T, + _: &Geometry, + ) -> Result<(), Self> { let config = ValidationConfig::default(); let mut errors = Self::check(object, &config); From 5e2a9776e5afb8adb6bdbfe6a9d26374960a77be Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 18 Mar 2024 13:47:34 +0100 Subject: [PATCH 2/3] Expect `&Geometry` in `ValidationCheck` method --- crates/fj-core/src/validation/checks/half_edge_connection.rs | 5 ++++- crates/fj-core/src/validation/validation_check.rs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/validation/checks/half_edge_connection.rs b/crates/fj-core/src/validation/checks/half_edge_connection.rs index 5a2dec955..a2ae617e6 100644 --- a/crates/fj-core/src/validation/checks/half_edge_connection.rs +++ b/crates/fj-core/src/validation/checks/half_edge_connection.rs @@ -99,7 +99,10 @@ mod tests { }, &mut core, ); - AdjacentHalfEdgesNotConnected::check_and_expect_one_error(&invalid); + AdjacentHalfEdgesNotConnected::check_and_expect_one_error( + &invalid, + &core.layers.geometry, + ); Ok(()) } diff --git a/crates/fj-core/src/validation/validation_check.rs b/crates/fj-core/src/validation/validation_check.rs index 7190343d4..cfe77fd6e 100644 --- a/crates/fj-core/src/validation/validation_check.rs +++ b/crates/fj-core/src/validation/validation_check.rs @@ -37,7 +37,7 @@ pub trait ValidationCheck: Sized { /// /// This method is designed for convenience over flexibility (it is intended /// for use in unit tests), and thus always uses the default configuration. - fn check_and_expect_one_error(object: &T) -> Self + fn check_and_expect_one_error(object: &T, _: &Geometry) -> Self where Self: Display, { From ec748fc720e82eb9c5143a2f5ce5ca4054484614 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 18 Mar 2024 13:53:42 +0100 Subject: [PATCH 3/3] Expect `&Geometry` in `ValidationCheck::check` --- crates/fj-core/src/validate/cycle.rs | 5 +++-- .../src/validation/checks/half_edge_connection.rs | 2 ++ crates/fj-core/src/validation/validation_check.rs | 9 +++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/fj-core/src/validate/cycle.rs b/crates/fj-core/src/validate/cycle.rs index 017694733..574aaf448 100644 --- a/crates/fj-core/src/validate/cycle.rs +++ b/crates/fj-core/src/validate/cycle.rs @@ -14,10 +14,11 @@ impl Validate for Cycle { &self, config: &ValidationConfig, errors: &mut Vec, - _: &Geometry, + geometry: &Geometry, ) { errors.extend( - AdjacentHalfEdgesNotConnected::check(self, config).map(Into::into), + AdjacentHalfEdgesNotConnected::check(self, geometry, config) + .map(Into::into), ); } } diff --git a/crates/fj-core/src/validation/checks/half_edge_connection.rs b/crates/fj-core/src/validation/checks/half_edge_connection.rs index a2ae617e6..2d65a92b9 100644 --- a/crates/fj-core/src/validation/checks/half_edge_connection.rs +++ b/crates/fj-core/src/validation/checks/half_edge_connection.rs @@ -1,6 +1,7 @@ use fj_math::{Point, Scalar}; use crate::{ + geometry::Geometry, objects::{Cycle, HalfEdge}, storage::Handle, validation::{validation_check::ValidationCheck, ValidationConfig}, @@ -40,6 +41,7 @@ pub struct AdjacentHalfEdgesNotConnected { impl ValidationCheck for AdjacentHalfEdgesNotConnected { fn check( object: &Cycle, + _: &Geometry, config: &ValidationConfig, ) -> impl Iterator { object.half_edges().pairs().filter_map(|(first, second)| { diff --git a/crates/fj-core/src/validation/validation_check.rs b/crates/fj-core/src/validation/validation_check.rs index cfe77fd6e..154536993 100644 --- a/crates/fj-core/src/validation/validation_check.rs +++ b/crates/fj-core/src/validation/validation_check.rs @@ -12,6 +12,7 @@ pub trait ValidationCheck: Sized { /// Run the validation check on the implementing object fn check( object: &T, + geometry: &Geometry, config: &ValidationConfig, ) -> impl Iterator; @@ -21,10 +22,10 @@ pub trait ValidationCheck: Sized { /// for use in unit tests), and thus always uses the default configuration. fn check_and_return_first_error( object: &T, - _: &Geometry, + geometry: &Geometry, ) -> Result<(), Self> { let config = ValidationConfig::default(); - let mut errors = Self::check(object, &config); + let mut errors = Self::check(object, geometry, &config); if let Some(err) = errors.next() { return Err(err); @@ -37,12 +38,12 @@ pub trait ValidationCheck: Sized { /// /// This method is designed for convenience over flexibility (it is intended /// for use in unit tests), and thus always uses the default configuration. - fn check_and_expect_one_error(object: &T, _: &Geometry) -> Self + fn check_and_expect_one_error(object: &T, geometry: &Geometry) -> Self where Self: Display, { let config = ValidationConfig::default(); - let mut errors = Self::check(object, &config).peekable(); + let mut errors = Self::check(object, geometry, &config).peekable(); let err = errors .next()