diff --git a/crates/fj-core/src/geometry/boundary.rs b/crates/fj-core/src/geometry/boundary.rs index bb5ed9935..8a6eef11a 100644 --- a/crates/fj-core/src/geometry/boundary.rs +++ b/crates/fj-core/src/geometry/boundary.rs @@ -31,12 +31,18 @@ impl CurveBoundary { /// Normalize the boundary /// /// Returns a new instance of this struct, which has the bounding elements - /// in a defined order. This can be used to compare a boundary while - /// disregarding its direction. + /// in a defined order, alongside a boolean that indicates whether the new + /// instance is different from the original one. + /// + /// This can be used to compare a boundary while disregarding its direction. #[must_use] - pub fn normalize(mut self) -> Self { - self.inner.sort(); - self + pub fn normalize(self) -> (Self, bool) { + let [a, b] = &self.inner; + if a > b { + (self.reverse(), true) + } else { + (self, false) + } } } diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index eb1f1f328..c87b92542 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -235,6 +235,7 @@ impl ShellValidationError { .bounding_vertices_of_edge(edge) .expect("Expected edge to be part of shell") .normalize() + .0 }; bounding_vertices_of(edge_a) @@ -314,7 +315,8 @@ impl ShellValidationError { .expect( "Cycle should provide bounds of its own half-edge", ) - .normalize(); + .normalize() + .0; let edge = (curve, bounding_vertices); @@ -394,7 +396,8 @@ impl ShellValidationError { .expect( "Just got edge from this cycle; must be part of it", ) - .normalize(); + .normalize() + .0; edges_by_coincidence .entry((curve, boundary))