From cd8ebedae7568eb5905789151cf25cb61c8c0232 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 18 Oct 2022 16:51:42 +0200 Subject: [PATCH] Fix object duplication issue in `PartialHalfEdge` --- crates/fj-kernel/src/partial/objects/edge.rs | 16 ++++++++++++++-- crates/fj-operations/src/sketch.rs | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index 01456718c..b5c2793e0 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -108,7 +108,17 @@ impl PartialHalfEdge { } /// Update partial half-edge as a circle, from the given radius - pub fn as_circle_from_radius(mut self, radius: impl Into) -> Self { + /// + /// # Implementation Note + /// + /// In principle, only the `build` method should take a reference to + /// [`Objects`]. As of this writing, this method is the only one that + /// deviates from that. I couldn't think of a way to do it better. + pub fn as_circle_from_radius( + mut self, + radius: impl Into, + objects: &Objects, + ) -> Self { let curve = Handle::::partial() .with_global_form(self.extract_global_curve()) .with_surface(self.surface.clone()) @@ -124,7 +134,9 @@ impl PartialHalfEdge { let path = curve.path.expect("Expected path that was just created"); let surface_form = Handle::::partial() .with_position(Some(path.point_from_path_coords(a_curve))) - .with_global_form(Some(global_form)); + .with_surface(self.surface.clone()) + .with_global_form(Some(global_form)) + .build(objects); [a_curve, b_curve].map(|point_curve| { Vertex::partial() diff --git a/crates/fj-operations/src/sketch.rs b/crates/fj-operations/src/sketch.rs index 814f00952..d9d55f91e 100644 --- a/crates/fj-operations/src/sketch.rs +++ b/crates/fj-operations/src/sketch.rs @@ -28,7 +28,7 @@ impl Shape for fj::Sketch { let half_edge = HalfEdge::partial() .with_surface(Some(surface.clone())) - .as_circle_from_radius(circle.radius()) + .as_circle_from_radius(circle.radius(), objects) .build(objects); let cycle = Cycle::new(surface, [half_edge]);