Skip to content

Commit

Permalink
Fix object duplication issue in PartialHalfEdge
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Oct 18, 2022
1 parent d9500cc commit cd8ebed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions crates/fj-kernel/src/partial/objects/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Scalar>) -> 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<Scalar>,
objects: &Objects,
) -> Self {
let curve = Handle::<Curve>::partial()
.with_global_form(self.extract_global_curve())
.with_surface(self.surface.clone())
Expand All @@ -124,7 +134,9 @@ impl PartialHalfEdge {
let path = curve.path.expect("Expected path that was just created");
let surface_form = Handle::<SurfaceVertex>::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()
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-operations/src/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down

0 comments on commit cd8ebed

Please sign in to comment.