Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove reference to Surface from SurfaceVertex #1597

Merged
merged 12 commits into from
Feb 17, 2023
Prev Previous commit
Remove HalfEdgeBuilder::replace_surface
Thanks to the recent simplifications, it was no longer carrying its
weight.
hannobraun committed Feb 17, 2023
commit c55abb0f9c8458ebecf805a953e0a5a54d347560
18 changes: 12 additions & 6 deletions crates/fj-kernel/src/algorithms/sweep/edge.rs
Original file line number Diff line number Diff line change
@@ -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
@@ -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)] =
@@ -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();
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/builder/cycle.rs
Original file line number Diff line number Diff line change
@@ -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();
}

18 changes: 1 addition & 17 deletions crates/fj-kernel/src/builder/edge.rs
Original file line number Diff line number Diff line change
@@ -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>);

@@ -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);

@@ -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();
6 changes: 4 additions & 2 deletions crates/fj-operations/src/sketch.rs
Original file line number Diff line number Diff line change
@@ -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)