From e369e3c9ff52338b0e128fa2d46ba3499ed6d2dd Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 9 Aug 2024 22:05:37 +0200 Subject: [PATCH 1/2] Add more information to validation error --- .../checks/coincident_half_edges_are_not_siblings.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/validation/checks/coincident_half_edges_are_not_siblings.rs b/crates/fj-core/src/validation/checks/coincident_half_edges_are_not_siblings.rs index 778c8de6a..2b95f30bf 100644 --- a/crates/fj-core/src/validation/checks/coincident_half_edges_are_not_siblings.rs +++ b/crates/fj-core/src/validation/checks/coincident_half_edges_are_not_siblings.rs @@ -31,6 +31,9 @@ pub struct CoincidentHalfEdgesAreNotSiblings { /// The second half-edge pub half_edge_b: Handle, + + /// The distances between the points on the half-edges that were checked + pub distances: Vec, } impl fmt::Display for CoincidentHalfEdgesAreNotSiblings { @@ -108,7 +111,7 @@ impl ValidationCheck for CoincidentHalfEdgesAreNotSiblings { continue; } - let Some(mut distances) = distances( + let Some(distances) = distances( half_edge_a.clone(), object .find_cycle_of_half_edge(half_edge_a) @@ -133,10 +136,11 @@ impl ValidationCheck for CoincidentHalfEdgesAreNotSiblings { // hence these half-edges can't be coincident. continue; }; + let distances = distances.collect::>(); // If all points on distinct curves are within // `distinct_min_distance`, that's a problem. - if distances.all(|d| d < config.distinct_min_distance) { + if distances.iter().all(|d| *d < config.distinct_min_distance) { let curves = [half_edge_a, half_edge_b] .map(|half_edge| half_edge.curve().clone()); let vertices = @@ -153,6 +157,7 @@ impl ValidationCheck for CoincidentHalfEdgesAreNotSiblings { vertices, half_edge_a: half_edge_a.clone(), half_edge_b: half_edge_b.clone(), + distances, }) } } From 311a54c69077dff25cd7492cbf684802f5dee278 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 9 Aug 2024 22:05:51 +0200 Subject: [PATCH 2/2] Update validation error message --- .../checks/coincident_half_edges_are_not_siblings.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/validation/checks/coincident_half_edges_are_not_siblings.rs b/crates/fj-core/src/validation/checks/coincident_half_edges_are_not_siblings.rs index 2b95f30bf..56f28fe16 100644 --- a/crates/fj-core/src/validation/checks/coincident_half_edges_are_not_siblings.rs +++ b/crates/fj-core/src/validation/checks/coincident_half_edges_are_not_siblings.rs @@ -75,8 +75,9 @@ impl fmt::Display for CoincidentHalfEdgesAreNotSiblings { write!( f, "Half-edge 1: {:#?}\n\ - Half-edge 2: {:#?}", - self.half_edge_a, self.half_edge_b, + Half-edge 2: {:#?}\n\ + Distances: {:#?}", + self.half_edge_a, self.half_edge_b, self.distances )?; Ok(())