diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index b33643310..35ee1f673 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -189,8 +189,7 @@ mod tests { let face = Face::builder(&stores, surface) .with_exterior_polygon_from_points(exterior) .with_interior_polygon_from_points(interior) - .build() - .into_face(); + .build(); let expected = CurveFaceIntersection::from_intervals([[[1.], [2.]], [[4.], [5.]]]); diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index 9e5aad5eb..1e93b9151 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -86,7 +86,6 @@ mod tests { Face::builder(&stores, surface) .with_exterior_polygon_from_points(points) .build() - .into_face() }); let intersection = FaceFaceIntersection::compute([&a, &b], &stores); @@ -110,7 +109,6 @@ mod tests { Face::builder(&stores, surface) .with_exterior_polygon_from_points(points) .build() - .into_face() }); let intersection = FaceFaceIntersection::compute([&a, &b], &stores); diff --git a/crates/fj-kernel/src/algorithms/intersect/face_point.rs b/crates/fj-kernel/src/algorithms/intersect/face_point.rs index c27e18091..8b1a8dcea 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_point.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_point.rs @@ -144,8 +144,7 @@ mod tests { let face = Face::builder(&stores, Surface::xy_plane()) .with_exterior_polygon_from_points([[0., 0.], [1., 1.], [0., 2.]]) - .build() - .into_face(); + .build(); let point = Point::from([2., 1.]); let intersection = (&face, &point).intersect(); @@ -158,8 +157,7 @@ mod tests { let face = Face::builder(&stores, Surface::xy_plane()) .with_exterior_polygon_from_points([[0., 0.], [2., 1.], [0., 2.]]) - .build() - .into_face(); + .build(); let point = Point::from([1., 1.]); let intersection = (&face, &point).intersect(); @@ -175,8 +173,7 @@ mod tests { let face = Face::builder(&stores, Surface::xy_plane()) .with_exterior_polygon_from_points([[4., 2.], [0., 4.], [0., 0.]]) - .build() - .into_face(); + .build(); let point = Point::from([1., 2.]); let intersection = (&face, &point).intersect(); @@ -197,8 +194,7 @@ mod tests { [3., 0.], [3., 4.], ]) - .build() - .into_face(); + .build(); let point = Point::from([1., 1.]); let intersection = (&face, &point).intersect(); @@ -219,8 +215,7 @@ mod tests { [3., 1.], [0., 2.], ]) - .build() - .into_face(); + .build(); let point = Point::from([1., 1.]); let intersection = (&face, &point).intersect(); @@ -242,8 +237,7 @@ mod tests { [4., 0.], [4., 5.], ]) - .build() - .into_face(); + .build(); let point = Point::from([1., 1.]); let intersection = (&face, &point).intersect(); @@ -259,8 +253,7 @@ mod tests { let face = Face::builder(&stores, Surface::xy_plane()) .with_exterior_polygon_from_points([[0., 0.], [2., 0.], [0., 1.]]) - .build() - .into_face(); + .build(); let point = Point::from([1., 0.]); let intersection = (&face, &point).intersect(); @@ -285,8 +278,7 @@ mod tests { let face = Face::builder(&stores, Surface::xy_plane()) .with_exterior_polygon_from_points([[0., 0.], [1., 0.], [0., 1.]]) - .build() - .into_face(); + .build(); let point = Point::from([1., 0.]); let intersection = (&face, &point).intersect(); diff --git a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs index 7ce478fdc..30e9ee513 100644 --- a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs @@ -176,7 +176,6 @@ mod tests { [-1., 1.], ]) .build() - .into_face() .translate([-1., 0., 0.], &stores); assert_eq!((&ray, &face).intersect(), None); @@ -196,7 +195,6 @@ mod tests { [-1., 1.], ]) .build() - .into_face() .translate([1., 0., 0.], &stores); assert_eq!( @@ -219,7 +217,6 @@ mod tests { [-1., 1.], ]) .build() - .into_face() .translate([0., 0., 2.], &stores); assert_eq!((&ray, &face).intersect(), None); @@ -239,7 +236,6 @@ mod tests { [-1., 1.], ]) .build() - .into_face() .translate([1., 1., 0.], &stores); let edge = face @@ -270,7 +266,6 @@ mod tests { [-1., 1.], ]) .build() - .into_face() .translate([1., 1., 1.], &stores); let vertex = face @@ -298,8 +293,7 @@ mod tests { [1., 1.], [-1., 1.], ]) - .build() - .into_face(); + .build(); assert_eq!( (&ray, &face).intersect(), @@ -321,7 +315,6 @@ mod tests { [-1., 1.], ]) .build() - .into_face() .translate([0., 0., 1.], &stores); assert_eq!((&ray, &face).intersect(), None) diff --git a/crates/fj-kernel/src/algorithms/sweep/face.rs b/crates/fj-kernel/src/algorithms/sweep/face.rs index 535ede82e..36906cfbd 100644 --- a/crates/fj-kernel/src/algorithms/sweep/face.rs +++ b/crates/fj-kernel/src/algorithms/sweep/face.rs @@ -97,12 +97,10 @@ mod tests { let bottom = Face::builder(&stores, surface) .with_exterior_polygon_from_points(TRIANGLE) .build() - .into_face() .reverse(); let top = Face::builder(&stores, surface.translate(UP, &stores)) .with_exterior_polygon_from_points(TRIANGLE) - .build() - .into_face(); + .build(); assert!(solid.find_face(&bottom).is_some()); assert!(solid.find_face(&top).is_some()); @@ -134,12 +132,10 @@ mod tests { let bottom = Face::builder(&stores, surface.translate(DOWN, &stores)) .with_exterior_polygon_from_points(TRIANGLE) .build() - .into_face() .reverse(); let top = Face::builder(&stores, surface) .with_exterior_polygon_from_points(TRIANGLE) - .build() - .into_face(); + .build(); assert!(solid.find_face(&bottom).is_some()); assert!(solid.find_face(&top).is_some()); diff --git a/crates/fj-kernel/src/algorithms/triangulate/mod.rs b/crates/fj-kernel/src/algorithms/triangulate/mod.rs index 8c8ae8e57..5912fc12d 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/mod.rs @@ -102,8 +102,7 @@ mod tests { let surface = Surface::xy_plane(); let face = Face::builder(&stores, surface) .with_exterior_polygon_from_points([a, b, c, d]) - .build() - .into_face(); + .build(); let a = Point::from(a).to_xyz(); let b = Point::from(b).to_xyz(); @@ -138,8 +137,7 @@ mod tests { let face = Face::builder(&stores, surface) .with_exterior_polygon_from_points([a, b, c, d]) .with_interior_polygon_from_points([e, f, g, h]) - .build() - .into_face(); + .build(); let triangles = triangulate(face)?; @@ -191,8 +189,7 @@ mod tests { let surface = Surface::xy_plane(); let face = Face::builder(&stores, surface) .with_exterior_polygon_from_points([a, b, c, d, e]) - .build() - .into_face(); + .build(); let triangles = triangulate(face)?; diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index 4fc65c8d9..6dccad7b4 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -1,5 +1,3 @@ -use std::ops::Deref; - use fj_math::Point; use crate::{ @@ -53,58 +51,10 @@ impl<'a> FaceBuilder<'a> { } /// Construct a polygon from a list of points - pub fn build(self) -> FacePolygon<'a> { + pub fn build(self) -> Face { let exterior = self .exterior .expect("Can't build `Face` without exterior cycle"); - let face = - Face::new(self.surface, exterior).with_interiors(self.interiors); - - FacePolygon { - stores: self.stores, - face, - } - } -} - -/// A polygon -#[derive(Clone, Debug)] -pub struct FacePolygon<'a> { - stores: &'a Stores, - face: Face, -} - -impl FacePolygon<'_> { - /// Add a hole to the polygon - pub fn with_hole( - mut self, - points: impl IntoIterator>>, - ) -> Self { - let surface = *self.face.surface(); - self.face = - self.face - .with_interiors([Cycle::builder(self.stores, surface) - .build_polygon_from_points(points)]); - - self - } - - /// Consume the `Polygon` and return the [`Face`] it wraps - pub fn into_face(self) -> Face { - self.face - } -} - -impl From> for Face { - fn from(polygon: FacePolygon) -> Self { - polygon.into_face() - } -} - -impl Deref for FacePolygon<'_> { - type Target = Face; - - fn deref(&self) -> &Self::Target { - &self.face + Face::new(self.surface, exterior).with_interiors(self.interiors) } } diff --git a/crates/fj-kernel/src/builder/mod.rs b/crates/fj-kernel/src/builder/mod.rs index 9bc5b153a..0c73ef261 100644 --- a/crates/fj-kernel/src/builder/mod.rs +++ b/crates/fj-kernel/src/builder/mod.rs @@ -13,7 +13,7 @@ pub use self::{ curve::{CurveBuilder, GlobalCurveBuilder}, cycle::CycleBuilder, edge::HalfEdgeBuilder, - face::{FaceBuilder, FacePolygon}, + face::FaceBuilder, shell::ShellBuilder, sketch::SketchBuilder, solid::SolidBuilder, diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 705697e9e..95107d69f 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -40,7 +40,6 @@ impl<'a> ShellBuilder<'a> { Face::builder(self.stores, plane) .with_exterior_polygon_from_points(points) .build() - .into_face() }); Shell::new().with_faces(faces) diff --git a/crates/fj-kernel/src/builder/sketch.rs b/crates/fj-kernel/src/builder/sketch.rs index 2f993524f..7a25982fa 100644 --- a/crates/fj-kernel/src/builder/sketch.rs +++ b/crates/fj-kernel/src/builder/sketch.rs @@ -24,8 +24,7 @@ impl<'a> SketchBuilder<'a> { ) -> Sketch { let face = Face::builder(self.stores, self.surface) .with_exterior_polygon_from_points(points) - .build() - .into_face(); + .build(); Sketch::new().with_faces([face]) } } diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index a38a3a3e1..477344458 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -404,8 +404,7 @@ mod tests { let surface = Surface::xy_plane(); let object = Face::builder(&stores, surface) .with_exterior_polygon_from_points([[0., 0.], [1., 0.], [0., 1.]]) - .build() - .into_face(); + .build(); assert_eq!(3, object.curve_iter().count()); assert_eq!(1, object.cycle_iter().count()); @@ -502,8 +501,7 @@ mod tests { let surface = Surface::xy_plane(); let face = Face::builder(&stores, surface) .with_exterior_polygon_from_points([[0., 0.], [1., 0.], [0., 1.]]) - .build() - .into_face(); + .build(); let object = Sketch::new().with_faces([face]); assert_eq!(3, object.curve_iter().count()); diff --git a/crates/fj-operations/src/sketch.rs b/crates/fj-operations/src/sketch.rs index 2dc3e0d0f..a22893d8a 100644 --- a/crates/fj-operations/src/sketch.rs +++ b/crates/fj-operations/src/sketch.rs @@ -39,7 +39,6 @@ impl Shape for fj::Sketch { Face::builder(stores, surface) .with_exterior_polygon_from_points(points) .build() - .into_face() .with_color(Color(self.color())) } };