mirror of
https://github.com/hannobraun/Fornjot
synced 2025-09-22 17:18:20 +00:00
Add FloatingCurve::new
This commit is contained in:
parent
2e5106fe12
commit
af589bde5e
@ -29,9 +29,7 @@ impl AnchoredCurve {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
origin,
|
origin,
|
||||||
floating: FloatingCurve {
|
floating: FloatingCurve::new(curve),
|
||||||
inner: Box::new(curve),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +89,13 @@ impl Clone for AnchoredCurve {
|
|||||||
pub struct FloatingCurve {
|
pub struct FloatingCurve {
|
||||||
pub inner: Box<dyn CurveGeometry>,
|
pub inner: Box<dyn CurveGeometry>,
|
||||||
}
|
}
|
||||||
|
impl FloatingCurve {
|
||||||
|
pub fn new(curve: impl CurveGeometry + 'static) -> Self {
|
||||||
|
Self {
|
||||||
|
inner: Box::new(curve),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub trait CurveGeometry {
|
pub trait CurveGeometry {
|
||||||
fn clone_curve_geometry(&self) -> Box<dyn CurveGeometry>;
|
fn clone_curve_geometry(&self) -> Box<dyn CurveGeometry>;
|
||||||
|
@ -17,7 +17,7 @@ impl SweptCurve {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
u: AnchoredCurve::from_origin_and_curve(origin, u),
|
u: AnchoredCurve::from_origin_and_curve(origin, u),
|
||||||
v: FloatingCurve { inner: Box::new(v) },
|
v: FloatingCurve::new(v),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,11 +45,9 @@ pub fn model(viewer: &Viewer) -> TriMesh {
|
|||||||
viewer.display(top.to_tri_mesh(tolerance));
|
viewer.display(top.to_tri_mesh(tolerance));
|
||||||
|
|
||||||
let solid = top.sweep(
|
let solid = top.sweep(
|
||||||
FloatingCurve {
|
FloatingCurve::new(Line {
|
||||||
inner: Box::new(Line {
|
|
||||||
direction: Vector::from([0., 0., -2.]),
|
direction: Vector::from([0., 0., -2.]),
|
||||||
}),
|
}),
|
||||||
},
|
|
||||||
[1.],
|
[1.],
|
||||||
);
|
);
|
||||||
viewer.display(solid.to_tri_mesh(tolerance));
|
viewer.display(solid.to_tri_mesh(tolerance));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user