diff --git a/crates/fj-core/src/geometry/boundary.rs b/crates/fj-core/src/geometry/boundary.rs index 8a6eef11a..85bb6fe0e 100644 --- a/crates/fj-core/src/geometry/boundary.rs +++ b/crates/fj-core/src/geometry/boundary.rs @@ -28,20 +28,26 @@ impl CurveBoundary { Self { inner: [b, a] } } + /// Indicate whether the boundary is normalized + /// + /// If the boundary is normalized, its bounding elements are in a defined + /// order, and calling `normalize` will return an identical instance. + pub fn is_normalized(&self) -> bool { + let [a, b] = &self.inner; + a <= b + } + /// Normalize the boundary /// /// Returns a new instance of this struct, which has the bounding elements - /// 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. + /// in a defined order. This can be used to compare boundaries while + /// disregarding their direction. #[must_use] - pub fn normalize(self) -> (Self, bool) { - let [a, b] = &self.inner; - if a > b { - (self.reverse(), true) + pub fn normalize(self) -> Self { + if self.is_normalized() { + self } else { - (self, false) + self.reverse() } } } diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index c87b92542..eb1f1f328 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -235,7 +235,6 @@ impl ShellValidationError { .bounding_vertices_of_edge(edge) .expect("Expected edge to be part of shell") .normalize() - .0 }; bounding_vertices_of(edge_a) @@ -315,8 +314,7 @@ impl ShellValidationError { .expect( "Cycle should provide bounds of its own half-edge", ) - .normalize() - .0; + .normalize(); let edge = (curve, bounding_vertices); @@ -396,8 +394,7 @@ impl ShellValidationError { .expect( "Just got edge from this cycle; must be part of it", ) - .normalize() - .0; + .normalize(); edges_by_coincidence .entry((curve, boundary))