diff --git a/crates/fj-core/src/algorithms/approx/curve/segment.rs b/crates/fj-core/src/algorithms/approx/curve/segment.rs index d3735ce36..631a8923d 100644 --- a/crates/fj-core/src/algorithms/approx/curve/segment.rs +++ b/crates/fj-core/src/algorithms/approx/curve/segment.rs @@ -79,10 +79,8 @@ impl CurveApproxSegment { ); self.boundary = self.boundary.subset(boundary); - - let [min, max] = self.boundary.inner; self.points - .retain(|point| point.local_form > min && point.local_form < max); + .retain(|point| self.boundary.contains(point.local_form)); } /// Merge the provided segment into this one @@ -112,7 +110,7 @@ impl CurveApproxSegment { self.points.retain(|point| { // Only retain points that don't overlap with the other segment, or // we might end up with duplicates. - point.local_form < other_min || point.local_form > other_max + !other.boundary.contains(point.local_form) }); self.points.extend(&other.points); self.points.sort(); diff --git a/crates/fj-core/src/geometry/boundary.rs b/crates/fj-core/src/geometry/boundary.rs index a7d2dea5b..d86a4eb84 100644 --- a/crates/fj-core/src/geometry/boundary.rs +++ b/crates/fj-core/src/geometry/boundary.rs @@ -65,6 +65,12 @@ impl CurveBoundary> { min >= max } + /// Indicate whether the boundary contains the given element + pub fn contains(&self, point: Point<1>) -> bool { + let [min, max] = self.inner; + point > min && point < max + } + /// Indicate whether the boundary overlaps another /// /// Boundaries that touch (i.e. their closest boundary elements are equal)