diff --git a/crates/fj-core/src/algorithms/approx/curve.rs b/crates/fj-core/src/algorithms/approx/curve.rs index a9ccfa50f..1870cf82d 100644 --- a/crates/fj-core/src/algorithms/approx/curve.rs +++ b/crates/fj-core/src/algorithms/approx/curve.rs @@ -48,7 +48,7 @@ fn approx_curve( boundary: CurveBoundary>, tolerance: impl Into, ) -> CurveApprox { - let SurfaceGeom::Basic { u, .. } = surface; + let SurfaceGeom { u, .. } = surface; let points = match (path, u) { (SurfacePath::Circle(_), GlobalPath::Circle(_)) => { approx_circle_on_curved_surface() @@ -116,7 +116,7 @@ fn approx_line_on_any_surface( .map(|point_curve| [line.point_from_line_coords(point_curve).u]), ); - let SurfaceGeom::Basic { u, .. } = surface; + let SurfaceGeom { u, .. } = surface; let approx_u = match u { GlobalPath::Circle(circle) => approx_circle(circle, range_u, tolerance), GlobalPath::Line(line) => approx_line(line), @@ -222,7 +222,7 @@ mod tests { #[test] fn approx_line_on_curved_surface_but_not_along_curve() { - let surface = SurfaceGeom::Basic { + let surface = SurfaceGeom { u: GlobalPath::circle_from_radius(1.), v: Vector::from([0., 0., 1.]), }; @@ -242,7 +242,7 @@ mod tests { let circle = Circle::from_center_and_radius(Point::origin(), 1.); let global_path = GlobalPath::Circle(circle); - let surface_geom = SurfaceGeom::Basic { + let surface_geom = SurfaceGeom { u: global_path, v: Vector::from([0., 0., 1.]), }; diff --git a/crates/fj-core/src/algorithms/bounding_volume/face.rs b/crates/fj-core/src/algorithms/bounding_volume/face.rs index 8520a87ba..98f24c5fd 100644 --- a/crates/fj-core/src/algorithms/bounding_volume/face.rs +++ b/crates/fj-core/src/algorithms/bounding_volume/face.rs @@ -15,7 +15,7 @@ impl super::BoundingVolume<3> for &Face { .map(|aabb2| { let surface = geometry.of_surface(self.surface()); - let SurfaceGeom::Basic { u, v } = surface; + let SurfaceGeom { u, v } = surface; match u { GlobalPath::Circle(circle) => { // This is not the most precise way to calculate the diff --git a/crates/fj-core/src/geometry/geometry.rs b/crates/fj-core/src/geometry/geometry.rs index 796ddb269..511734ce8 100644 --- a/crates/fj-core/src/geometry/geometry.rs +++ b/crates/fj-core/src/geometry/geometry.rs @@ -42,21 +42,21 @@ impl Geometry { self_.define_surface_inner( self_.xy_plane.clone(), - SurfaceGeom::Basic { + SurfaceGeom { u: GlobalPath::x_axis(), v: Vector::unit_y(), }, ); self_.define_surface_inner( self_.xz_plane.clone(), - SurfaceGeom::Basic { + SurfaceGeom { u: GlobalPath::x_axis(), v: Vector::unit_z(), }, ); self_.define_surface_inner( self_.yz_plane.clone(), - SurfaceGeom::Basic { + SurfaceGeom { u: GlobalPath::y_axis(), v: Vector::unit_z(), }, diff --git a/crates/fj-core/src/geometry/surface.rs b/crates/fj-core/src/geometry/surface.rs index 8a5348a6f..85b715fa7 100644 --- a/crates/fj-core/src/geometry/surface.rs +++ b/crates/fj-core/src/geometry/surface.rs @@ -8,29 +8,18 @@ use super::GlobalPath; /// The geometry that defines a surface #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] -pub enum SurfaceGeom { - /// # Basic definition of surface geometry - /// - /// ## Implementation Note - /// - /// At the time of writing, this is the sole variant of `SurfaceGeom`. - /// `SurfaceGeom` simply used to be a struct, identical to this variant. - /// - /// This was changed as part of a transition to a new, less basic and more - /// flexible, representation of surface geometry. - Basic { - /// The u-axis of the surface - u: GlobalPath, +pub struct SurfaceGeom { + /// The u-axis of the surface + pub u: GlobalPath, - /// The v-axis of the surface - v: Vector<3>, - }, + /// The v-axis of the surface + pub v: Vector<3>, } impl SurfaceGeom { /// # Access the origin of the surface pub fn origin(&self) -> Point<3> { - let Self::Basic { u, .. } = self; + let Self { u, .. } = self; match u { GlobalPath::Circle(circle) => circle.center(), GlobalPath::Line(line) => line.origin(), @@ -80,7 +69,7 @@ impl SurfaceGeom { ) -> (Triangle<3>, [Scalar; 3]) { let point_surface = point_surface.into(); - let Self::Basic { u, v } = self; + let Self { u, v } = self; match u { GlobalPath::Circle(circle) => { let params = PathApproxParams::for_circle(circle, tolerance); @@ -148,11 +137,11 @@ impl SurfaceGeom { /// Transform the surface geometry #[must_use] pub fn transform(self, transform: &Transform) -> Self { - let Self::Basic { u, v } = self; + let Self { u, v } = self; let u = u.transform(transform); let v = transform.transform_vector(&v); - Self::Basic { u, v } + Self { u, v } } } @@ -168,7 +157,7 @@ mod tests { #[test] fn point_from_surface_coords() { - let surface = SurfaceGeom::Basic { + let surface = SurfaceGeom { u: GlobalPath::Line(Line::from_origin_and_direction( Point::from([1., 1., 1.]), Vector::from([0., 2., 0.]), @@ -187,7 +176,7 @@ mod tests { #[test] fn vector_from_surface_coords() { - let surface = SurfaceGeom::Basic { + let surface = SurfaceGeom { u: GlobalPath::Line(Line::from_origin_and_direction( Point::from([1., 0., 0.]), Vector::from([0., 2., 0.]), diff --git a/crates/fj-core/src/operations/build/surface.rs b/crates/fj-core/src/operations/build/surface.rs index ef55d1e27..76e90495c 100644 --- a/crates/fj-core/src/operations/build/surface.rs +++ b/crates/fj-core/src/operations/build/surface.rs @@ -35,7 +35,7 @@ pub trait BuildSurface { core: &mut Core, ) -> Handle { Self::from_geometry( - SurfaceGeom::Basic { + SurfaceGeom { u: u.into(), v: v.into(), }, diff --git a/crates/fj-core/src/operations/sweep/path.rs b/crates/fj-core/src/operations/sweep/path.rs index f5bdc65f3..4770dc14b 100644 --- a/crates/fj-core/src/operations/sweep/path.rs +++ b/crates/fj-core/src/operations/sweep/path.rs @@ -39,7 +39,7 @@ impl SweepSurfacePath for SurfacePath { path: impl Into>, core: &mut Core, ) -> Handle { - let SurfaceGeom::Basic { u, .. } = surface; + let SurfaceGeom { u, .. } = surface; match u { GlobalPath::Circle(_) => { // Sweeping a `Curve` creates a `Surface`. The u-axis of that