Add FloatingCurve::new

This commit is contained in:
Hanno Braun 2025-05-05 12:01:33 +02:00
parent 2e5106fe12
commit af589bde5e
3 changed files with 12 additions and 9 deletions

View File

@ -29,9 +29,7 @@ impl AnchoredCurve {
) -> Self {
Self {
origin,
floating: FloatingCurve {
inner: Box::new(curve),
},
floating: FloatingCurve::new(curve),
}
}
@ -91,6 +89,13 @@ impl Clone for AnchoredCurve {
pub struct FloatingCurve {
pub inner: Box<dyn CurveGeometry>,
}
impl FloatingCurve {
pub fn new(curve: impl CurveGeometry + 'static) -> Self {
Self {
inner: Box::new(curve),
}
}
}
pub trait CurveGeometry {
fn clone_curve_geometry(&self) -> Box<dyn CurveGeometry>;

View File

@ -17,7 +17,7 @@ impl SweptCurve {
Self {
u: AnchoredCurve::from_origin_and_curve(origin, u),
v: FloatingCurve { inner: Box::new(v) },
v: FloatingCurve::new(v),
}
}

View File

@ -45,11 +45,9 @@ pub fn model(viewer: &Viewer) -> TriMesh {
viewer.display(top.to_tri_mesh(tolerance));
let solid = top.sweep(
FloatingCurve {
inner: Box::new(Line {
direction: Vector::from([0., 0., -2.]),
}),
},
FloatingCurve::new(Line {
direction: Vector::from([0., 0., -2.]),
}),
[1.],
);
viewer.display(solid.to_tri_mesh(tolerance));