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
|
let surface = objects
|
||||||
.surfaces
|
.surfaces
|
||||||
.insert(Surface::new(GlobalPath::x_axis(), [0., 0., 1.]))?;
|
.insert(Surface::new(GlobalPath::x_axis(), [0., 0., 1.]))?;
|
||||||
let curve = PartialCurve {
|
let mut curve = PartialCurve {
|
||||||
surface: Some(surface),
|
surface: Some(surface),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
};
|
||||||
.update_as_line_from_points([[1., 1.], [2., 1.]])
|
curve.update_as_line_from_points([[1., 1.], [2., 1.]]);
|
||||||
.build(&objects)?
|
let curve = curve.build(&objects)?.insert(&objects)?;
|
||||||
.insert(&objects)?;
|
|
||||||
let range = RangeOnPath::from([[0.], [1.]]);
|
let range = RangeOnPath::from([[0.], [1.]]);
|
||||||
|
|
||||||
let approx = (&curve, range).approx(1.);
|
let approx = (&curve, range).approx(1.);
|
||||||
|
@ -237,13 +236,12 @@ mod tests {
|
||||||
GlobalPath::circle_from_radius(1.),
|
GlobalPath::circle_from_radius(1.),
|
||||||
[0., 0., 1.],
|
[0., 0., 1.],
|
||||||
))?;
|
))?;
|
||||||
let curve = PartialCurve {
|
let mut curve = PartialCurve {
|
||||||
surface: Some(surface),
|
surface: Some(surface),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
};
|
||||||
.update_as_line_from_points([[1., 1.], [1., 2.]])
|
curve.update_as_line_from_points([[1., 1.], [1., 2.]]);
|
||||||
.build(&objects)?
|
let curve = curve.build(&objects)?.insert(&objects)?;
|
||||||
.insert(&objects)?;
|
|
||||||
let range = RangeOnPath::from([[0.], [1.]]);
|
let range = RangeOnPath::from([[0.], [1.]]);
|
||||||
|
|
||||||
let approx = (&curve, range).approx(1.);
|
let approx = (&curve, range).approx(1.);
|
||||||
|
@ -259,13 +257,12 @@ mod tests {
|
||||||
let path = GlobalPath::circle_from_radius(1.);
|
let path = GlobalPath::circle_from_radius(1.);
|
||||||
let surface =
|
let surface =
|
||||||
objects.surfaces.insert(Surface::new(path, [0., 0., 1.]))?;
|
objects.surfaces.insert(Surface::new(path, [0., 0., 1.]))?;
|
||||||
let curve = PartialCurve {
|
let mut curve = PartialCurve {
|
||||||
surface: Some(surface.clone()),
|
surface: Some(surface.clone()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
};
|
||||||
.update_as_line_from_points([[0., 1.], [1., 1.]])
|
curve.update_as_line_from_points([[0., 1.], [1., 1.]]);
|
||||||
.build(&objects)?
|
let curve = curve.build(&objects)?.insert(&objects)?;
|
||||||
.insert(&objects)?;
|
|
||||||
|
|
||||||
let range = RangeOnPath::from([[0.], [TAU]]);
|
let range = RangeOnPath::from([[0.], [TAU]]);
|
||||||
let tolerance = 1.;
|
let tolerance = 1.;
|
||||||
|
|
|
@ -163,12 +163,12 @@ mod tests {
|
||||||
|
|
||||||
let surface = objects.surfaces.xy_plane();
|
let surface = objects.surfaces.xy_plane();
|
||||||
|
|
||||||
let curve = PartialCurve {
|
let mut curve = PartialCurve {
|
||||||
surface: Some(surface.clone()),
|
surface: Some(surface.clone()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
};
|
||||||
.update_as_line_from_points([[-3., 0.], [-2., 0.]])
|
curve.update_as_line_from_points([[-3., 0.], [-2., 0.]]);
|
||||||
.build(&objects)?;
|
let curve = curve.build(&objects)?;
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
let exterior = [
|
let exterior = [
|
||||||
|
|
|
@ -129,13 +129,12 @@ mod tests {
|
||||||
|
|
||||||
let expected_curves =
|
let expected_curves =
|
||||||
surfaces.try_map_ext(|surface| -> Result<_, ValidationError> {
|
surfaces.try_map_ext(|surface| -> Result<_, ValidationError> {
|
||||||
Ok(PartialCurve {
|
let mut curve = PartialCurve {
|
||||||
surface: Some(surface),
|
surface: Some(surface),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
};
|
||||||
.update_as_line_from_points([[0., 0.], [1., 0.]])
|
curve.update_as_line_from_points([[0., 0.], [1., 0.]]);
|
||||||
.build(&objects)?
|
Ok(curve.build(&objects)?.insert(&objects)?)
|
||||||
.insert(&objects)?)
|
|
||||||
})?;
|
})?;
|
||||||
let expected_intervals =
|
let expected_intervals =
|
||||||
CurveFaceIntersection::from_intervals([[[-1.], [1.]]]);
|
CurveFaceIntersection::from_intervals([[[-1.], [1.]]]);
|
||||||
|
|
|
@ -15,24 +15,26 @@ pub trait CurveBuilder {
|
||||||
|
|
||||||
/// Update partial curve as a line, from the provided points
|
/// Update partial curve as a line, from the provided points
|
||||||
fn update_as_line_from_points(
|
fn update_as_line_from_points(
|
||||||
self,
|
&mut self,
|
||||||
points: [impl Into<Point<2>>; 2],
|
points: [impl Into<Point<2>>; 2],
|
||||||
) -> Self;
|
) -> &mut Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CurveBuilder for PartialCurve {
|
impl CurveBuilder for PartialCurve {
|
||||||
fn update_as_u_axis(self) -> Self {
|
fn update_as_u_axis(mut self) -> Self {
|
||||||
let a = Point::origin();
|
let a = Point::origin();
|
||||||
let b = a + Vector::unit_u();
|
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 a = Point::origin();
|
||||||
let b = a + Vector::unit_v();
|
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 {
|
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(
|
fn update_as_line_from_points(
|
||||||
self,
|
&mut self,
|
||||||
points: [impl Into<Point<2>>; 2],
|
points: [impl Into<Point<2>>; 2],
|
||||||
) -> Self {
|
) -> &mut Self {
|
||||||
Self {
|
self.path = Some(SurfacePath::line_from_points(points));
|
||||||
path: Some(SurfacePath::line_from_points(points)),
|
self
|
||||||
..self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,10 +64,11 @@ impl CycleBuilder for PartialCycle {
|
||||||
|
|
||||||
previous = Some(vertex_next.clone());
|
previous = Some(vertex_next.clone());
|
||||||
|
|
||||||
let curve = PartialCurve {
|
let mut curve = PartialCurve {
|
||||||
surface: Some(surface.clone()),
|
surface: Some(surface.clone()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
};
|
||||||
|
curve
|
||||||
.update_as_line_from_points([position_prev, position_next]);
|
.update_as_line_from_points([position_prev, position_next]);
|
||||||
|
|
||||||
let vertices = [(0., vertex_prev), (1., vertex_next)].map(
|
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")
|
.expect("Can't infer line segment without surface position")
|
||||||
});
|
});
|
||||||
|
|
||||||
let curve = PartialCurve {
|
let mut curve = PartialCurve {
|
||||||
surface: Some(surface),
|
surface: Some(surface),
|
||||||
global_form: Some(self.extract_global_curve()),
|
global_form: Some(self.extract_global_curve()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
};
|
||||||
.update_as_line_from_points(points);
|
curve.update_as_line_from_points(points);
|
||||||
|
|
||||||
let [back, front] = {
|
let [back, front] = {
|
||||||
let vertices = [(from, 0.), (to, 1.)].map(|(vertex, position)| {
|
let vertices = [(from, 0.), (to, 1.)].map(|(vertex, position)| {
|
||||||
|
|
Loading…
Reference in New Issue