diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index 50c944d85..2018259de 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -208,61 +208,56 @@ mod tests { let face = (half_edge, Color::default()).sweep([0., 0., 1.], &objects)?; - let expected_face = { - let surface = objects.surfaces.xz_plane(); + let expected_face = + { + let surface = objects.surfaces.xz_plane(); - let bottom = HalfEdge::partial() - .update_as_line_segment_from_points( - surface.clone(), - [[0., 0.], [1., 0.]], - ) - .build(&objects)?; - let side_up = HalfEdge::partial() - .with_surface(Some(surface.clone())) - .with_back_vertex(Some( - Vertex::partial().with_surface_form( + let bottom = HalfEdge::partial() + .update_as_line_segment_from_points( + surface.clone(), + [[0., 0.], [1., 0.]], + ) + .build(&objects)?; + let side_up = HalfEdge::partial() + .with_surface(Some(surface.clone())) + .with_back_vertex(Vertex::partial().with_surface_form( bottom.front().surface_form().clone(), - ), - )) - .with_front_vertex(Vertex::partial().with_surface_form( - SurfaceVertex::partial().with_position(Some([1., 1.])), - )) - .update_as_line_segment() - .build(&objects)?; - let top = HalfEdge::partial() - .with_surface(Some(surface.clone())) - .with_back_vertex(Some(Vertex::partial().with_surface_form( - SurfaceVertex::partial().with_position(Some([0., 1.])), - ))) - .with_front_vertex( - Vertex::partial().with_surface_form( + )) + .with_front_vertex(Vertex::partial().with_surface_form( + SurfaceVertex::partial().with_position(Some([1., 1.])), + )) + .update_as_line_segment() + .build(&objects)?; + let top = HalfEdge::partial() + .with_surface(Some(surface.clone())) + .with_back_vertex(Vertex::partial().with_surface_form( + SurfaceVertex::partial().with_position(Some([0., 1.])), + )) + .with_front_vertex(Vertex::partial().with_surface_form( side_up.front().surface_form().clone(), - ), - ) - .update_as_line_segment() - .build(&objects)? - .reverse(&objects)?; - let side_down = HalfEdge::partial() - .with_surface(Some(surface)) - .with_back_vertex(Some( - Vertex::partial().with_surface_form( - bottom.back().surface_form().clone(), - ), - )) - .with_front_vertex( - Vertex::partial() - .with_surface_form(top.front().surface_form().clone()), - ) - .update_as_line_segment() - .build(&objects)? - .reverse(&objects)?; + )) + .update_as_line_segment() + .build(&objects)? + .reverse(&objects)?; + let side_down = + HalfEdge::partial() + .with_surface(Some(surface)) + .with_back_vertex(Vertex::partial().with_surface_form( + bottom.back().surface_form().clone(), + )) + .with_front_vertex(Vertex::partial().with_surface_form( + top.front().surface_form().clone(), + )) + .update_as_line_segment() + .build(&objects)? + .reverse(&objects)?; - let cycle = objects - .cycles - .insert(Cycle::new([bottom, side_up, top, side_down]))?; + let cycle = objects + .cycles + .insert(Cycle::new([bottom, side_up, top, side_down]))?; - Face::builder(&objects).with_exterior(cycle).build() - }; + Face::builder(&objects).with_exterior(cycle).build() + }; assert_eq!(face, expected_face); Ok(()) diff --git a/crates/fj-kernel/src/partial/objects/cycle.rs b/crates/fj-kernel/src/partial/objects/cycle.rs index aca41f414..8e3658b8e 100644 --- a/crates/fj-kernel/src/partial/objects/cycle.rs +++ b/crates/fj-kernel/src/partial/objects/cycle.rs @@ -118,7 +118,7 @@ impl PartialCycle { partial.with_surface_form(previous_vertex) }); - half_edge.with_back_vertex(Some(back)) + half_edge.with_back_vertex(back) }) .into_full(objects)?; diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index 9f1b01bc0..a3a5459ad 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -82,12 +82,11 @@ impl PartialHalfEdge { /// Update the partial half-edge with the given back vertex pub fn with_back_vertex( mut self, - vertex: Option>>, + vertex: impl Into>, ) -> Self { - if let Some(vertex) = vertex { - let [from, _] = &mut self.vertices; - *from = vertex.into(); - } + let [from, _] = &mut self.vertices; + *from = vertex.into(); + self }