From 8a6fec8d67bad156908193af34aad24a540d6354 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 9 Jan 2023 18:43:49 +0100 Subject: [PATCH 1/8] Remove redundant `FaceBuilder` method --- .../src/algorithms/intersect/curve_face.rs | 6 ++++-- .../src/algorithms/intersect/face_face.rs | 6 +++--- .../src/algorithms/intersect/face_point.rs | 18 +++++++++--------- .../src/algorithms/intersect/ray_face.rs | 16 ++++++++-------- crates/fj-kernel/src/algorithms/sweep/face.rs | 16 +++++++++++----- .../src/algorithms/triangulate/mod.rs | 14 ++++++++++---- crates/fj-kernel/src/builder/face.rs | 13 ------------- crates/fj-kernel/src/builder/sketch.rs | 4 ++-- crates/fj-kernel/src/validate/face.rs | 4 ++-- 9 files changed, 49 insertions(+), 48 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index 76d839a07..60dfbd8a6 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -150,7 +150,7 @@ where #[cfg(test)] mod tests { use crate::{ - builder::{CurveBuilder, FaceBuilder}, + builder::{CurveBuilder, CycleBuilder, FaceBuilder}, partial::{Partial, PartialCurve, PartialFace, PartialObject}, services::Services, }; @@ -188,7 +188,9 @@ mod tests { let face = { let mut face = PartialFace::default(); face.exterior.write().surface = surface; - face.update_exterior_as_polygon_from_points(exterior); + face.exterior + .write() + .update_as_polygon_from_points(exterior); face.add_interior_polygon_from_points(interior); face.build(&mut services.objects) diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index a8ba4668a..499aa0719 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -69,7 +69,7 @@ mod tests { use crate::{ algorithms::intersect::CurveFaceIntersection, - builder::{CurveBuilder, FaceBuilder}, + builder::{CurveBuilder, CycleBuilder}, insert::Insert, partial::{Partial, PartialCurve, PartialFace, PartialObject}, services::Services, @@ -95,7 +95,7 @@ mod tests { .map(|surface| { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(surface); - face.update_exterior_as_polygon_from_points(points); + face.exterior.write().update_as_polygon_from_points(points); face.build(&mut services.objects) }); @@ -124,7 +124,7 @@ mod tests { let [a, b] = surfaces.clone().map(|surface| { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(surface); - face.update_exterior_as_polygon_from_points(points); + face.exterior.write().update_as_polygon_from_points(points); face.build(&mut services.objects) }); diff --git a/crates/fj-kernel/src/algorithms/intersect/face_point.rs b/crates/fj-kernel/src/algorithms/intersect/face_point.rs index 465f260b2..698999e6c 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_point.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_point.rs @@ -135,7 +135,7 @@ mod tests { use crate::{ algorithms::intersect::{face_point::FacePointIntersection, Intersect}, - builder::FaceBuilder, + builder::CycleBuilder, insert::Insert, partial::{Partial, PartialFace, PartialObject}, services::Services, @@ -148,7 +148,7 @@ mod tests { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(services.objects.surfaces.xy_plane()); - face.update_exterior_as_polygon_from_points([ + face.exterior.write().update_as_polygon_from_points([ [0., 0.], [1., 1.], [0., 2.], @@ -169,7 +169,7 @@ mod tests { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(services.objects.surfaces.xy_plane()); - face.update_exterior_as_polygon_from_points([ + face.exterior.write().update_as_polygon_from_points([ [0., 0.], [2., 1.], [0., 2.], @@ -193,7 +193,7 @@ mod tests { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(services.objects.surfaces.xy_plane()); - face.update_exterior_as_polygon_from_points([ + face.exterior.write().update_as_polygon_from_points([ [4., 2.], [0., 4.], [0., 0.], @@ -217,7 +217,7 @@ mod tests { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(services.objects.surfaces.xy_plane()); - face.update_exterior_as_polygon_from_points([ + face.exterior.write().update_as_polygon_from_points([ [0., 0.], [2., 1.], [3., 0.], @@ -242,7 +242,7 @@ mod tests { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(services.objects.surfaces.xy_plane()); - face.update_exterior_as_polygon_from_points([ + face.exterior.write().update_as_polygon_from_points([ [0., 0.], [2., 1.], [3., 1.], @@ -267,7 +267,7 @@ mod tests { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(services.objects.surfaces.xy_plane()); - face.update_exterior_as_polygon_from_points([ + face.exterior.write().update_as_polygon_from_points([ [0., 0.], [2., 1.], [3., 1.], @@ -293,7 +293,7 @@ mod tests { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(services.objects.surfaces.xy_plane()); - face.update_exterior_as_polygon_from_points([ + face.exterior.write().update_as_polygon_from_points([ [0., 0.], [2., 0.], [0., 1.], @@ -327,7 +327,7 @@ mod tests { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(services.objects.surfaces.xy_plane()); - face.update_exterior_as_polygon_from_points([ + face.exterior.write().update_as_polygon_from_points([ [0., 0.], [1., 0.], [0., 1.], diff --git a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs index 21cb23157..7565a50ef 100644 --- a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs @@ -151,7 +151,7 @@ mod tests { }, transform::TransformObject, }, - builder::FaceBuilder, + builder::CycleBuilder, insert::Insert, partial::{Partial, PartialFace, PartialObject}, services::Services, @@ -166,7 +166,7 @@ mod tests { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(services.objects.surfaces.yz_plane()); - face.update_exterior_as_polygon_from_points([ + face.exterior.write().update_as_polygon_from_points([ [-1., -1.], [1., -1.], [1., 1.], @@ -189,7 +189,7 @@ mod tests { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(services.objects.surfaces.yz_plane()); - face.update_exterior_as_polygon_from_points([ + face.exterior.write().update_as_polygon_from_points([ [-1., -1.], [1., -1.], [1., 1.], @@ -215,7 +215,7 @@ mod tests { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(services.objects.surfaces.yz_plane()); - face.update_exterior_as_polygon_from_points([ + face.exterior.write().update_as_polygon_from_points([ [-1., -1.], [1., -1.], [1., 1.], @@ -238,7 +238,7 @@ mod tests { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(services.objects.surfaces.yz_plane()); - face.update_exterior_as_polygon_from_points([ + face.exterior.write().update_as_polygon_from_points([ [-1., -1.], [1., -1.], [1., 1.], @@ -273,7 +273,7 @@ mod tests { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(services.objects.surfaces.yz_plane()); - face.update_exterior_as_polygon_from_points([ + face.exterior.write().update_as_polygon_from_points([ [-1., -1.], [1., -1.], [1., 1.], @@ -307,7 +307,7 @@ mod tests { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(services.objects.surfaces.xy_plane()); - face.update_exterior_as_polygon_from_points([ + face.exterior.write().update_as_polygon_from_points([ [-1., -1.], [1., -1.], [1., 1.], @@ -332,7 +332,7 @@ mod tests { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(services.objects.surfaces.xy_plane()); - face.update_exterior_as_polygon_from_points([ + face.exterior.write().update_as_polygon_from_points([ [-1., -1.], [1., -1.], [1., 1.], diff --git a/crates/fj-kernel/src/algorithms/sweep/face.rs b/crates/fj-kernel/src/algorithms/sweep/face.rs index 65d0f298f..7f54e4ff4 100644 --- a/crates/fj-kernel/src/algorithms/sweep/face.rs +++ b/crates/fj-kernel/src/algorithms/sweep/face.rs @@ -87,7 +87,7 @@ mod tests { use crate::{ algorithms::{reverse::Reverse, transform::TransformObject}, - builder::{FaceBuilder, HalfEdgeBuilder, SketchBuilder}, + builder::{CycleBuilder, HalfEdgeBuilder, SketchBuilder}, insert::Insert, partial::{ Partial, PartialFace, PartialHalfEdge, PartialObject, PartialSketch, @@ -116,7 +116,10 @@ mod tests { let mut bottom = PartialFace::default(); bottom.exterior.write().surface = Partial::from(surface.clone()); - bottom.update_exterior_as_polygon_from_points(TRIANGLE); + bottom + .exterior + .write() + .update_as_polygon_from_points(TRIANGLE); let bottom = bottom .build(&mut services.objects) .insert(&mut services.objects) @@ -124,7 +127,7 @@ mod tests { let mut top = PartialFace::default(); top.exterior.write().surface = Partial::from(surface.translate(UP, &mut services.objects)); - top.update_exterior_as_polygon_from_points(TRIANGLE); + top.exterior.write().update_as_polygon_from_points(TRIANGLE); let top = top .build(&mut services.objects) .insert(&mut services.objects); @@ -169,14 +172,17 @@ mod tests { bottom.exterior.write().surface = Partial::from( surface.clone().translate(DOWN, &mut services.objects), ); - bottom.update_exterior_as_polygon_from_points(TRIANGLE); + bottom + .exterior + .write() + .update_as_polygon_from_points(TRIANGLE); let bottom = bottom .build(&mut services.objects) .insert(&mut services.objects) .reverse(&mut services.objects); let mut top = PartialFace::default(); top.exterior.write().surface = Partial::from(surface); - top.update_exterior_as_polygon_from_points(TRIANGLE); + top.exterior.write().update_as_polygon_from_points(TRIANGLE); let top = top .build(&mut services.objects) .insert(&mut services.objects); diff --git a/crates/fj-kernel/src/algorithms/triangulate/mod.rs b/crates/fj-kernel/src/algorithms/triangulate/mod.rs index c252bb7fc..67182dd92 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/mod.rs @@ -77,7 +77,7 @@ mod tests { use crate::{ algorithms::approx::{Approx, Tolerance}, - builder::FaceBuilder, + builder::{CycleBuilder, FaceBuilder}, insert::Insert, objects::Face, partial::{Partial, PartialFace, PartialObject}, @@ -99,7 +99,9 @@ mod tests { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(services.objects.surfaces.xy_plane()); - face.update_exterior_as_polygon_from_points([a, b, c, d]); + face.exterior + .write() + .update_as_polygon_from_points([a, b, c, d]); let face = face .build(&mut services.objects) .insert(&mut services.objects); @@ -136,7 +138,9 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(surface.clone()); - face.update_exterior_as_polygon_from_points([a, b, c, d]); + face.exterior + .write() + .update_as_polygon_from_points([a, b, c, d]); face.add_interior_polygon_from_points([e, f, g, h]); let face = face .build(&mut services.objects) @@ -196,7 +200,9 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(surface.clone()); - face.update_exterior_as_polygon_from_points([a, b, c, d, e]); + face.exterior + .write() + .update_as_polygon_from_points([a, b, c, d, e]); let face = face .build(&mut services.objects) .insert(&mut services.objects); diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index fb5e74f61..08f3621dd 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -9,12 +9,6 @@ use super::CycleBuilder; /// Builder API for [`PartialFace`] pub trait FaceBuilder { - /// Update the face exterior as a polygon from the provided points - fn update_exterior_as_polygon_from_points( - &mut self, - points: impl IntoIterator>>, - ) -> Vec>; - /// Update the face exterior as a polygon fn update_exterior_as_polygon(&mut self); @@ -41,13 +35,6 @@ pub trait FaceBuilder { } impl FaceBuilder for PartialFace { - fn update_exterior_as_polygon_from_points( - &mut self, - points: impl IntoIterator>>, - ) -> Vec> { - self.exterior.write().update_as_polygon_from_points(points) - } - fn update_exterior_as_polygon(&mut self) { self.exterior.write().update_as_polygon() } diff --git a/crates/fj-kernel/src/builder/sketch.rs b/crates/fj-kernel/src/builder/sketch.rs index 57ca036fb..890804b2a 100644 --- a/crates/fj-kernel/src/builder/sketch.rs +++ b/crates/fj-kernel/src/builder/sketch.rs @@ -5,7 +5,7 @@ use crate::{ partial::{Partial, PartialFace, PartialSketch}, }; -use super::FaceBuilder; +use super::CycleBuilder; /// Builder API for [`PartialSketch`] pub trait SketchBuilder { @@ -25,7 +25,7 @@ impl SketchBuilder for PartialSketch { ) { let mut face = PartialFace::default(); face.exterior.write().surface = surface.into(); - face.update_exterior_as_polygon_from_points(points); + face.exterior.write().update_as_polygon_from_points(points); self.faces.extend([Partial::from_partial(face)]); } diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index d94bd4325..535509e2a 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -122,7 +122,7 @@ mod tests { let valid = { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(surface); - face.update_exterior_as_polygon_from_points([ + face.exterior.write().update_as_polygon_from_points([ [0., 0.], [3., 0.], [0., 3.], @@ -164,7 +164,7 @@ mod tests { let valid = { let mut face = PartialFace::default(); face.exterior.write().surface = Partial::from(surface); - face.update_exterior_as_polygon_from_points([ + face.exterior.write().update_as_polygon_from_points([ [0., 0.], [3., 0.], [0., 3.], From 4f5e5f23c5b61c8f45648fa6ee2a951080633fc7 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 9 Jan 2023 18:46:43 +0100 Subject: [PATCH 2/8] Remove unused method --- crates/fj-kernel/src/builder/face.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index 08f3621dd..ef3494cc2 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -9,9 +9,6 @@ use super::CycleBuilder; /// Builder API for [`PartialFace`] pub trait FaceBuilder { - /// Update the face exterior as a polygon - fn update_exterior_as_polygon(&mut self); - /// Update the face exterior as a triangle, from 3D points /// /// Uses the three points to infer a plane that is used as the surface. @@ -35,10 +32,6 @@ pub trait FaceBuilder { } impl FaceBuilder for PartialFace { - fn update_exterior_as_polygon(&mut self) { - self.exterior.write().update_as_polygon() - } - fn update_exterior_as_triangle_from_global_points( &mut self, points_global: [impl Into>; 3], From f250a74cfd3b8bd2c143e310644bac38be56a117 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 9 Jan 2023 18:47:09 +0100 Subject: [PATCH 3/8] Remove unused method --- crates/fj-kernel/src/builder/face.rs | 29 +--------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index ef3494cc2..fec8b41ae 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -1,29 +1,11 @@ use fj_math::Point; -use crate::{ - objects::HalfEdge, - partial::{Partial, PartialCycle, PartialFace}, -}; +use crate::partial::{Partial, PartialCycle, PartialFace}; use super::CycleBuilder; /// Builder API for [`PartialFace`] pub trait FaceBuilder { - /// Update the face exterior as a triangle, from 3D points - /// - /// Uses the three points to infer a plane that is used as the surface. - /// - /// # Implementation Note - /// - /// This method is probably just temporary, and will be generalized into a - /// "update as polygon from global points" method sooner or later. For now, - /// I didn't want to deal with the question of how to infer the surface, and - /// how to handle points that don't fit that surface. - fn update_exterior_as_triangle_from_global_points( - &mut self, - points: [impl Into>; 3], - ) -> [Partial; 3]; - /// Add an interior polygon, from the provided points fn add_interior_polygon_from_points( &mut self, @@ -32,15 +14,6 @@ pub trait FaceBuilder { } impl FaceBuilder for PartialFace { - fn update_exterior_as_triangle_from_global_points( - &mut self, - points_global: [impl Into>; 3], - ) -> [Partial; 3] { - self.exterior - .write() - .update_as_triangle_from_global_points(points_global) - } - fn add_interior_polygon_from_points( &mut self, points: impl IntoIterator>>, From f950d02c299f091c96de80b1eab32fa36717f59d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 9 Jan 2023 18:48:58 +0100 Subject: [PATCH 4/8] Refactor --- crates/fj-kernel/src/builder/face.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index fec8b41ae..d0275a233 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -24,6 +24,7 @@ impl FaceBuilder for PartialFace { }; cycle.update_as_polygon_from_points(points); - self.interiors.push(Partial::from_partial(cycle)); + let cycle = Partial::from_partial(cycle); + self.interiors.push(cycle); } } From 9470c84d2b90ff01e14dd424068ac24930969956 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 9 Jan 2023 18:49:35 +0100 Subject: [PATCH 5/8] Return created cycle from `FaceBuilder` method --- crates/fj-kernel/src/builder/face.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index d0275a233..1ea1c5504 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -1,6 +1,9 @@ use fj_math::Point; -use crate::partial::{Partial, PartialCycle, PartialFace}; +use crate::{ + objects::Cycle, + partial::{Partial, PartialCycle, PartialFace}, +}; use super::CycleBuilder; @@ -10,14 +13,14 @@ pub trait FaceBuilder { fn add_interior_polygon_from_points( &mut self, points: impl IntoIterator>>, - ); + ) -> Partial; } impl FaceBuilder for PartialFace { fn add_interior_polygon_from_points( &mut self, points: impl IntoIterator>>, - ) { + ) -> Partial { let mut cycle = PartialCycle { surface: self.exterior.read().surface.clone(), ..Default::default() @@ -25,6 +28,8 @@ impl FaceBuilder for PartialFace { cycle.update_as_polygon_from_points(points); let cycle = Partial::from_partial(cycle); - self.interiors.push(cycle); + self.interiors.push(cycle.clone()); + + cycle } } From 487b20c2833185e23530e1a5b324110a456d2906 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 9 Jan 2023 18:52:16 +0100 Subject: [PATCH 6/8] Simplify `FaceBuilder` method Its previous definition overlapped with a method of `CycleBuilder`. --- .../src/algorithms/intersect/curve_face.rs | 4 +++- .../fj-kernel/src/algorithms/triangulate/mod.rs | 4 +++- crates/fj-kernel/src/builder/face.rs | 17 +++-------------- crates/fj-kernel/src/validate/face.rs | 4 ++-- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index 60dfbd8a6..3724fb123 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -191,7 +191,9 @@ mod tests { face.exterior .write() .update_as_polygon_from_points(exterior); - face.add_interior_polygon_from_points(interior); + face.add_interior() + .write() + .update_as_polygon_from_points(interior); face.build(&mut services.objects) }; diff --git a/crates/fj-kernel/src/algorithms/triangulate/mod.rs b/crates/fj-kernel/src/algorithms/triangulate/mod.rs index 67182dd92..ec841dd1a 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/mod.rs @@ -141,7 +141,9 @@ mod tests { face.exterior .write() .update_as_polygon_from_points([a, b, c, d]); - face.add_interior_polygon_from_points([e, f, g, h]); + face.add_interior() + .write() + .update_as_polygon_from_points([e, f, g, h]); let face = face .build(&mut services.objects) .insert(&mut services.objects); diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index 1ea1c5504..e8cfdd2f0 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -1,31 +1,20 @@ -use fj_math::Point; - use crate::{ objects::Cycle, partial::{Partial, PartialCycle, PartialFace}, }; -use super::CycleBuilder; - /// Builder API for [`PartialFace`] pub trait FaceBuilder { /// Add an interior polygon, from the provided points - fn add_interior_polygon_from_points( - &mut self, - points: impl IntoIterator>>, - ) -> Partial; + fn add_interior(&mut self) -> Partial; } impl FaceBuilder for PartialFace { - fn add_interior_polygon_from_points( - &mut self, - points: impl IntoIterator>>, - ) -> Partial { - let mut cycle = PartialCycle { + fn add_interior(&mut self) -> Partial { + let cycle = PartialCycle { surface: self.exterior.read().surface.clone(), ..Default::default() }; - cycle.update_as_polygon_from_points(points); let cycle = Partial::from_partial(cycle); self.interiors.push(cycle.clone()); diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index 535509e2a..2aabcda3e 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -127,7 +127,7 @@ mod tests { [3., 0.], [0., 3.], ]); - face.add_interior_polygon_from_points([ + face.add_interior().write().update_as_polygon_from_points([ [1., 1.], [1., 2.], [2., 1.], @@ -169,7 +169,7 @@ mod tests { [3., 0.], [0., 3.], ]); - face.add_interior_polygon_from_points([ + face.add_interior().write().update_as_polygon_from_points([ [1., 1.], [1., 2.], [2., 1.], From 15a94bcdf81e6de941fe5a3c77354b6dd7f69f6d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 9 Jan 2023 18:53:04 +0100 Subject: [PATCH 7/8] Update doc comment --- crates/fj-kernel/src/builder/face.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index e8cfdd2f0..92d34ff95 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -5,7 +5,7 @@ use crate::{ /// Builder API for [`PartialFace`] pub trait FaceBuilder { - /// Add an interior polygon, from the provided points + /// Add an interior cycle fn add_interior(&mut self) -> Partial; } From ed00122796cd6a599a8046008d5a4b52298f6b6d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 9 Jan 2023 18:59:46 +0100 Subject: [PATCH 8/8] Refactor --- crates/fj-kernel/src/builder/face.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index 92d34ff95..33ec5f27d 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -11,14 +11,11 @@ pub trait FaceBuilder { impl FaceBuilder for PartialFace { fn add_interior(&mut self) -> Partial { - let cycle = PartialCycle { + let cycle = Partial::from_partial(PartialCycle { surface: self.exterior.read().surface.clone(), ..Default::default() - }; - - let cycle = Partial::from_partial(cycle); + }); self.interiors.push(cycle.clone()); - cycle } }