mirror of https://github.com/hannobraun/Fornjot
Change style of `update_as_line_from_points`
This commit is contained in:
parent
0e44127ebd
commit
686f635439
|
@ -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.;
|
||||
|
|
|
@ -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 = [
|
||||
|
|
|
@ -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.]]]);
|
||||
|
|
|
@ -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<Point<2>>; 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<Scalar>) -> Self {
|
||||
|
@ -43,12 +45,10 @@ impl CurveBuilder for PartialCurve {
|
|||
}
|
||||
|
||||
fn update_as_line_from_points(
|
||||
self,
|
||||
&mut self,
|
||||
points: [impl Into<Point<2>>; 2],
|
||||
) -> Self {
|
||||
Self {
|
||||
path: Some(SurfacePath::line_from_points(points)),
|
||||
..self
|
||||
}
|
||||
) -> &mut Self {
|
||||
self.path = Some(SurfacePath::line_from_points(points));
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,10 +64,11 @@ impl CycleBuilder for PartialCycle {
|
|||
|
||||
previous = Some(vertex_next.clone());
|
||||
|
||||
let curve = PartialCurve {
|
||||
let mut curve = PartialCurve {
|
||||
surface: Some(surface.clone()),
|
||||
..Default::default()
|
||||
}
|
||||
};
|
||||
curve
|
||||
.update_as_line_from_points([position_prev, position_next]);
|
||||
|
||||
let vertices = [(0., vertex_prev), (1., vertex_next)].map(
|
||||
|
|
|
@ -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)| {
|
||||
|
|
Loading…
Reference in New Issue