Skip to content

Commit

Permalink
Remove HalfEdgeBuilder::replace_surface
Browse files Browse the repository at this point in the history
Thanks to the recent simplifications, it was no longer carrying its
weight.
  • Loading branch information
hannobraun committed Feb 17, 2023
1 parent d8f6a69 commit c55abb0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 26 deletions.
18 changes: 12 additions & 6 deletions crates/fj-kernel/src/algorithms/sweep/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,10 @@ mod tests {
half_edge
};
let side_up = {
let mut side_up = PartialHalfEdge::default();
side_up.replace_surface(surface.clone());
let mut side_up = PartialHalfEdge {
surface: surface.clone(),
..Default::default()
};

{
let [back, front] = side_up
Expand All @@ -217,8 +219,10 @@ mod tests {
side_up
};
let top = {
let mut top = PartialHalfEdge::default();
top.replace_surface(surface.clone());
let mut top = PartialHalfEdge {
surface: surface.clone(),
..Default::default()
};

{
let [(back, back_surface), (front, front_surface)] =
Expand All @@ -243,8 +247,10 @@ mod tests {
.clone()
};
let side_down = {
let mut side_down = PartialHalfEdge::default();
side_down.replace_surface(surface);
let mut side_down = PartialHalfEdge {
surface,
..Default::default()
};

let [(back, back_surface), (front, front_surface)] =
side_down.vertices.each_mut_ext();
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/builder/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl CycleBuilder for PartialCycle {

let [_, vertex] = &mut new_half_edge.vertices;
vertex.1 = shared_surface_vertex;
new_half_edge.replace_surface(self.surface.clone());
new_half_edge.surface = self.surface.clone();
new_half_edge.infer_global_form();
}

Expand Down
18 changes: 1 addition & 17 deletions crates/fj-kernel/src/builder/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ use super::CurveBuilder;

/// Builder API for [`PartialHalfEdge`]
pub trait HalfEdgeBuilder {
/// Completely replace the surface in this half-edge's object graph
///
/// Please note that this operation will write to both vertices that the
/// half-edge references. If any of them were created from full objects,
/// this will break the connection to those, meaning that building the
/// partial objects won't result in those full objects again. This will be
/// the case, even if those full objects already referenced the provided
/// surface.
fn replace_surface(&mut self, surface: impl Into<Partial<Surface>>);

/// Update partial half-edge to be a circle, from the given radius
fn update_as_circle_from_radius(&mut self, radius: impl Into<Scalar>);

Expand Down Expand Up @@ -61,12 +51,6 @@ pub trait HalfEdgeBuilder {
}

impl HalfEdgeBuilder for PartialHalfEdge {
fn replace_surface(&mut self, surface: impl Into<Partial<Surface>>) {
let surface = surface.into();

self.surface = surface;
}

fn update_as_circle_from_radius(&mut self, radius: impl Into<Scalar>) {
let path = self.curve.write().update_as_circle_from_radius(radius);

Expand Down Expand Up @@ -130,7 +114,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
surface: impl Into<Partial<Surface>>,
points: [impl Into<Point<2>>; 2],
) {
self.replace_surface(surface.into());
self.surface = surface.into();

for (vertex, point) in self.vertices.each_mut_ext().zip_ext(points) {
let mut surface_form = vertex.1.write();
Expand Down
6 changes: 4 additions & 2 deletions crates/fj-operations/src/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ impl Shape for fj::Sketch {
let half_edge = {
let surface = Partial::from(surface);

let mut half_edge = PartialHalfEdge::default();
half_edge.replace_surface(surface);
let mut half_edge = PartialHalfEdge {
surface,
..Default::default()
};
half_edge.update_as_circle_from_radius(circle.radius());

Partial::from_partial(half_edge)
Expand Down

0 comments on commit c55abb0

Please sign in to comment.