diff --git a/crates/fj-kernel/src/algorithms/approx/curve.rs b/crates/fj-kernel/src/algorithms/approx/curve.rs index 45b893d20..aa17fc9b7 100644 --- a/crates/fj-kernel/src/algorithms/approx/curve.rs +++ b/crates/fj-kernel/src/algorithms/approx/curve.rs @@ -213,13 +213,12 @@ mod tests { let surface = objects .surfaces .insert(Surface::new(GlobalPath::x_axis(), [0., 0., 1.]))?; - let curve = PartialCurve { + let mut curve = PartialCurve { surface: Some(surface), ..Default::default() - } - .update_as_line_from_points([[1., 1.], [2., 1.]]) - .build(&objects)? - .insert(&objects)?; + }; + curve.update_as_line_from_points([[1., 1.], [2., 1.]]); + let curve = curve.build(&objects)?.insert(&objects)?; let range = RangeOnPath::from([[0.], [1.]]); let approx = (&curve, range).approx(1.); @@ -237,13 +236,12 @@ mod tests { GlobalPath::circle_from_radius(1.), [0., 0., 1.], ))?; - let curve = PartialCurve { + let mut curve = PartialCurve { surface: Some(surface), ..Default::default() - } - .update_as_line_from_points([[1., 1.], [1., 2.]]) - .build(&objects)? - .insert(&objects)?; + }; + curve.update_as_line_from_points([[1., 1.], [1., 2.]]); + let curve = curve.build(&objects)?.insert(&objects)?; let range = RangeOnPath::from([[0.], [1.]]); let approx = (&curve, range).approx(1.); @@ -259,13 +257,12 @@ mod tests { let path = GlobalPath::circle_from_radius(1.); let surface = objects.surfaces.insert(Surface::new(path, [0., 0., 1.]))?; - let curve = PartialCurve { + let mut curve = PartialCurve { surface: Some(surface.clone()), ..Default::default() - } - .update_as_line_from_points([[0., 1.], [1., 1.]]) - .build(&objects)? - .insert(&objects)?; + }; + curve.update_as_line_from_points([[0., 1.], [1., 1.]]); + let curve = curve.build(&objects)?.insert(&objects)?; let range = RangeOnPath::from([[0.], [TAU]]); let tolerance = 1.; diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index c87c06d12..39a74cfa1 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -163,12 +163,12 @@ mod tests { let surface = objects.surfaces.xy_plane(); - let curve = PartialCurve { + let mut curve = PartialCurve { surface: Some(surface.clone()), ..Default::default() - } - .update_as_line_from_points([[-3., 0.], [-2., 0.]]) - .build(&objects)?; + }; + curve.update_as_line_from_points([[-3., 0.], [-2., 0.]]); + let curve = curve.build(&objects)?; #[rustfmt::skip] let exterior = [ diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index d197b5b81..26a992a51 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -129,13 +129,12 @@ mod tests { let expected_curves = surfaces.try_map_ext(|surface| -> Result<_, ValidationError> { - Ok(PartialCurve { + let mut curve = PartialCurve { surface: Some(surface), ..Default::default() - } - .update_as_line_from_points([[0., 0.], [1., 0.]]) - .build(&objects)? - .insert(&objects)?) + }; + curve.update_as_line_from_points([[0., 0.], [1., 0.]]); + Ok(curve.build(&objects)?.insert(&objects)?) })?; let expected_intervals = CurveFaceIntersection::from_intervals([[[-1.], [1.]]]); diff --git a/crates/fj-kernel/src/builder/curve.rs b/crates/fj-kernel/src/builder/curve.rs index b9e93097b..a16324b32 100644 --- a/crates/fj-kernel/src/builder/curve.rs +++ b/crates/fj-kernel/src/builder/curve.rs @@ -15,24 +15,26 @@ pub trait CurveBuilder { /// Update partial curve as a line, from the provided points fn update_as_line_from_points( - self, + &mut self, points: [impl Into>; 2], - ) -> Self; + ) -> &mut Self; } impl CurveBuilder for PartialCurve { - fn update_as_u_axis(self) -> Self { + fn update_as_u_axis(mut self) -> Self { let a = Point::origin(); let b = a + Vector::unit_u(); - self.update_as_line_from_points([a, b]) + self.update_as_line_from_points([a, b]); + self } - fn update_as_v_axis(self) -> Self { + fn update_as_v_axis(mut self) -> Self { let a = Point::origin(); let b = a + Vector::unit_v(); - self.update_as_line_from_points([a, b]) + self.update_as_line_from_points([a, b]); + self } fn update_as_circle_from_radius(self, radius: impl Into) -> Self { @@ -43,12 +45,10 @@ impl CurveBuilder for PartialCurve { } fn update_as_line_from_points( - self, + &mut self, points: [impl Into>; 2], - ) -> Self { - Self { - path: Some(SurfacePath::line_from_points(points)), - ..self - } + ) -> &mut Self { + self.path = Some(SurfacePath::line_from_points(points)); + self } } diff --git a/crates/fj-kernel/src/builder/cycle.rs b/crates/fj-kernel/src/builder/cycle.rs index a2499bbd2..64ba97be6 100644 --- a/crates/fj-kernel/src/builder/cycle.rs +++ b/crates/fj-kernel/src/builder/cycle.rs @@ -64,11 +64,12 @@ impl CycleBuilder for PartialCycle { previous = Some(vertex_next.clone()); - let curve = PartialCurve { + let mut curve = PartialCurve { surface: Some(surface.clone()), ..Default::default() - } - .update_as_line_from_points([position_prev, position_next]); + }; + curve + .update_as_line_from_points([position_prev, position_next]); let vertices = [(0., vertex_prev), (1., vertex_next)].map( |(position, surface_form)| { diff --git a/crates/fj-kernel/src/builder/edge.rs b/crates/fj-kernel/src/builder/edge.rs index 1c6abd920..c05c65120 100644 --- a/crates/fj-kernel/src/builder/edge.rs +++ b/crates/fj-kernel/src/builder/edge.rs @@ -139,12 +139,12 @@ impl HalfEdgeBuilder for PartialHalfEdge { .expect("Can't infer line segment without surface position") }); - let curve = PartialCurve { + let mut curve = PartialCurve { surface: Some(surface), global_form: Some(self.extract_global_curve()), ..Default::default() - } - .update_as_line_from_points(points); + }; + curve.update_as_line_from_points(points); let [back, front] = { let vertices = [(from, 0.), (to, 1.)].map(|(vertex, position)| {