diff --git a/experiments/2025-03-18/src/geometry/curve.rs b/experiments/2025-03-18/src/geometry/curve.rs index 52ef895b0..7a5f030f6 100644 --- a/experiments/2025-03-18/src/geometry/curve.rs +++ b/experiments/2025-03-18/src/geometry/curve.rs @@ -29,7 +29,9 @@ impl AnchoredCurve { ) -> Self { Self { origin, - floating: Box::new(curve), + floating: FloatingCurve { + inner: Box::new(curve), + }, } } @@ -50,17 +52,19 @@ impl AnchoredCurve { } pub fn point_from_local(&self, point: impl Into>) -> Point<3> { - self.origin + self.floating.vector_from_local_point(point.into()) + self.origin + self.floating.inner.vector_from_local_point(point.into()) } pub fn project_point(&self, point: Point<3>) -> Point<1> { - self.floating.project_vector(point - self.origin) + self.floating.inner.project_vector(point - self.origin) } pub fn translate(&self, offset: impl Into>) -> Self { Self { origin: self.origin + offset, - floating: self.floating.clone_curve_geometry(), + floating: FloatingCurve { + inner: self.floating.inner.clone_curve_geometry(), + }, } } @@ -69,7 +73,7 @@ impl AnchoredCurve { boundary: [Point<1>; 2], tolerance: Tolerance, ) -> Vec> { - self.floating.approximate(boundary, tolerance) + self.floating.inner.approximate(boundary, tolerance) } } @@ -77,12 +81,16 @@ impl Clone for AnchoredCurve { fn clone(&self) -> Self { Self { origin: self.origin, - floating: self.floating.clone_curve_geometry(), + floating: FloatingCurve { + inner: self.floating.inner.clone_curve_geometry(), + }, } } } -pub type FloatingCurve = Box; +pub struct FloatingCurve { + pub inner: Box, +} pub trait CurveGeometry { fn clone_curve_geometry(&self) -> Box; diff --git a/experiments/2025-03-18/src/geometry/swept_curve.rs b/experiments/2025-03-18/src/geometry/swept_curve.rs index 23d5ec543..c032344fa 100644 --- a/experiments/2025-03-18/src/geometry/swept_curve.rs +++ b/experiments/2025-03-18/src/geometry/swept_curve.rs @@ -17,7 +17,7 @@ impl SweptCurve { Self { u: AnchoredCurve::from_origin_and_curve(origin, u), - v: Box::new(v), + v: FloatingCurve { inner: Box::new(v) }, } } @@ -29,7 +29,7 @@ impl SweptCurve { pub fn point_from_local(&self, point: impl Into>) -> Point<3> { let [u, v] = point.into().coords.components; self.u.point_from_local([u]) - + self.v.vector_from_local_point(Point::from([v])) + + self.v.inner.vector_from_local_point(Point::from([v])) } pub fn project_point(&self, point: impl Into>) -> Point<2> { @@ -39,7 +39,9 @@ impl SweptCurve { let v = { let v = AnchoredCurve { origin: self.u.point_from_local(u), - floating: self.v.clone_curve_geometry(), + floating: FloatingCurve { + inner: self.v.inner.clone_curve_geometry(), + }, }; v.project_point(point) @@ -51,14 +53,18 @@ impl SweptCurve { pub fn flip(&self) -> Self { Self { u: self.u.clone(), - v: self.v.flip(), + v: FloatingCurve { + inner: self.v.inner.flip(), + }, } } pub fn translate(&self, offset: impl Into>) -> Self { Self { u: self.u.translate(offset), - v: self.v.clone_curve_geometry(), + v: FloatingCurve { + inner: self.v.inner.clone_curve_geometry(), + }, } } } diff --git a/experiments/2025-03-18/src/model.rs b/experiments/2025-03-18/src/model.rs index c433c48c3..dd6368e4a 100644 --- a/experiments/2025-03-18/src/model.rs +++ b/experiments/2025-03-18/src/model.rs @@ -3,7 +3,7 @@ use fj_math::Vector; use fj_viewer::Viewer; use crate::{ - geometry::{Line, Sketch, SweptCurve, ToTriMesh}, + geometry::{FloatingCurve, Line, Sketch, SweptCurve, ToTriMesh}, handle::Handle, operations::sweep::SweepExt, topology::surface::Surface, @@ -45,9 +45,11 @@ pub fn model(viewer: &Viewer) -> TriMesh { viewer.display(top.to_tri_mesh(tolerance)); let solid = top.sweep( - Box::new(Line { - direction: Vector::from([0., 0., -2.]), - }), + FloatingCurve { + inner: Box::new(Line { + direction: Vector::from([0., 0., -2.]), + }), + }, [1.], ); viewer.display(solid.to_tri_mesh(tolerance)); diff --git a/experiments/2025-03-18/src/operations/connect.rs b/experiments/2025-03-18/src/operations/connect.rs index 7b4356663..03e0ac698 100644 --- a/experiments/2025-03-18/src/operations/connect.rs +++ b/experiments/2025-03-18/src/operations/connect.rs @@ -88,7 +88,9 @@ fn build_connecting_faces( let curve = Curve { geometry: AnchoredCurve { origin: a.point, - floating: connecting_curve.clone_curve_geometry(), + floating: FloatingCurve { + inner: connecting_curve.inner.clone_curve_geometry(), + }, }, }; diff --git a/experiments/2025-03-18/src/operations/sweep.rs b/experiments/2025-03-18/src/operations/sweep.rs index 7808c386c..0e6538728 100644 --- a/experiments/2025-03-18/src/operations/sweep.rs +++ b/experiments/2025-03-18/src/operations/sweep.rs @@ -26,7 +26,7 @@ pub trait SweepExt { impl SweepExt for Handle { fn sweep(self, along: FloatingCurve, to: impl Into>) -> Solid { let [from, to] = [Point::from([0.]), to.into()] - .map(|point| along.vector_from_local_point(point)); + .map(|point| along.inner.vector_from_local_point(point)); let bottom = self; let top = {