Skip to content

Commit

Permalink
Change style of update_as_circle_from_radius
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Nov 11, 2022
1 parent 686f635 commit ad87bd4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
9 changes: 4 additions & 5 deletions crates/fj-kernel/src/algorithms/approx/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,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_circle_from_radius(1.)
.build(&objects)?
.insert(&objects)?;
};
curve.update_as_circle_from_radius(1.);
let curve = curve.build(&objects)?.insert(&objects)?;

let range = RangeOnPath::from([[0.], [TAU]]);
let tolerance = 1.;
Expand Down
16 changes: 10 additions & 6 deletions crates/fj-kernel/src/builder/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ pub trait CurveBuilder {
fn update_as_v_axis(self) -> Self;

/// Update partial curve as a circle, from the provided radius
fn update_as_circle_from_radius(self, radius: impl Into<Scalar>) -> Self;
fn update_as_circle_from_radius(
&mut self,
radius: impl Into<Scalar>,
) -> &mut Self;

/// Update partial curve as a line, from the provided points
fn update_as_line_from_points(
Expand All @@ -37,11 +40,12 @@ impl CurveBuilder for PartialCurve {
self
}

fn update_as_circle_from_radius(self, radius: impl Into<Scalar>) -> Self {
Self {
path: Some(SurfacePath::circle_from_radius(radius)),
..self
}
fn update_as_circle_from_radius(
&mut self,
radius: impl Into<Scalar>,
) -> &mut Self {
self.path = Some(SurfacePath::circle_from_radius(radius));
self
}

fn update_as_line_from_points(
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/builder/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
) -> Result<Self, ValidationError> {
let mut curve = self.curve().into_partial();
curve.global_form = Some(self.extract_global_curve());
let curve = curve.update_as_circle_from_radius(radius);
curve.update_as_circle_from_radius(radius);

let path = curve.path.expect("Expected path that was just created");

Expand Down

0 comments on commit ad87bd4

Please sign in to comment.