From 6a44f3227ef24bd9da5f57c5de5ec4ca1b77ce56 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 24 Nov 2022 15:39:17 +0100 Subject: [PATCH 1/6] Simplify `ShellBuilder` --- crates/fj-kernel/src/algorithms/sweep/face.rs | 2 +- .../src/algorithms/transform/shell.rs | 2 +- crates/fj-kernel/src/builder/shell.rs | 68 +++++++++---------- crates/fj-kernel/src/builder/solid.rs | 4 +- crates/fj-kernel/src/iter.rs | 4 +- crates/fj-kernel/src/objects/full/shell.rs | 3 +- 6 files changed, 39 insertions(+), 44 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/face.rs b/crates/fj-kernel/src/algorithms/sweep/face.rs index 930e19ccf..2b90bb540 100644 --- a/crates/fj-kernel/src/algorithms/sweep/face.rs +++ b/crates/fj-kernel/src/algorithms/sweep/face.rs @@ -74,7 +74,7 @@ impl Sweep for Handle { } } - Ok(Shell::builder(objects).with_faces(faces).build()) + Ok(Shell::builder(objects).with_faces(faces).build(objects)) } } diff --git a/crates/fj-kernel/src/algorithms/transform/shell.rs b/crates/fj-kernel/src/algorithms/transform/shell.rs index cb86a6e4d..f40992178 100644 --- a/crates/fj-kernel/src/algorithms/transform/shell.rs +++ b/crates/fj-kernel/src/algorithms/transform/shell.rs @@ -22,6 +22,6 @@ impl TransformObject for Handle { face.transform(transform, objects) }) .collect::, _>>()?; - Ok(Shell::builder(objects).with_faces(faces).build()) + Ok(Shell::builder(objects).with_faces(faces).build(objects)) } } diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index fe381beb9..b33ab9ddd 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -19,15 +19,12 @@ use crate::{ /// API for building a [`Shell`] /// /// Also see [`Shell::builder`]. -pub struct ShellBuilder<'a> { - /// The stores that the created objects are put in - pub objects: &'a Objects, - +pub struct ShellBuilder { /// The faces that make up the [`Shell`] pub faces: FaceSet, } -impl<'a> ShellBuilder<'a> { +impl ShellBuilder { /// Build the [`Shell`] with the provided faces pub fn with_faces( mut self, @@ -41,6 +38,7 @@ impl<'a> ShellBuilder<'a> { pub fn with_cube_from_edge_length( mut self, edge_length: impl Into, + objects: &Objects, ) -> Self { let edge_length = edge_length.into(); @@ -49,11 +47,10 @@ impl<'a> ShellBuilder<'a> { let h = edge_length / 2.; let bottom = { - let surface = self - .objects + let surface = objects .surfaces .xy_plane() - .translate([Z, Z, -h], self.objects) + .translate([Z, Z, -h], objects) .unwrap(); Face::partial() @@ -64,9 +61,9 @@ impl<'a> ShellBuilder<'a> { [h, h], [-h, h], ]) - .build(self.objects) + .build(objects) .unwrap() - .insert(self.objects) + .insert(objects) .unwrap() }; @@ -82,9 +79,9 @@ impl<'a> ShellBuilder<'a> { let c = a + [Z, Z, edge_length]; PartialSurface::plane_from_points([a, b, c]) - .build(self.objects) + .build(objects) .unwrap() - .insert(self.objects) + .insert(objects) .unwrap() }) .collect::>(); @@ -102,9 +99,9 @@ impl<'a> ShellBuilder<'a> { surface.clone(), [[Z, Z], [edge_length, Z]], ) - .build(self.objects) + .build(objects) .unwrap() - .insert(self.objects) + .insert(objects) .unwrap() }) .collect::>(); @@ -138,9 +135,9 @@ impl<'a> ShellBuilder<'a> { ..Default::default() } .update_as_line_segment() - .build(self.objects) + .build(objects) .unwrap() - .insert(self.objects) + .insert(objects) .unwrap() }) .collect::>(); @@ -190,9 +187,9 @@ impl<'a> ShellBuilder<'a> { ..Default::default() } .update_as_line_segment() - .build(self.objects) + .build(objects) .unwrap() - .insert(self.objects) + .insert(objects) .unwrap() }) .collect::>() @@ -223,9 +220,9 @@ impl<'a> ShellBuilder<'a> { ..Default::default() } .update_as_line_segment() - .build(self.objects) + .build(objects) .unwrap() - .insert(self.objects) + .insert(objects) .unwrap() }) .collect::>(); @@ -238,16 +235,16 @@ impl<'a> ShellBuilder<'a> { .map(|(((bottom, side_up), top), side_down)| { let cycle = Cycle::partial() .with_half_edges([bottom, side_up, top, side_down]) - .build(self.objects) + .build(objects) .unwrap() - .insert(self.objects) + .insert(objects) .unwrap(); Face::partial() .with_exterior(cycle) - .build(self.objects) + .build(objects) .unwrap() - .insert(self.objects) + .insert(objects) .unwrap() }); @@ -255,11 +252,10 @@ impl<'a> ShellBuilder<'a> { }; let top = { - let surface = self - .objects + let surface = objects .surfaces .xy_plane() - .translate([Z, Z, h], self.objects) + .translate([Z, Z, h], objects) .unwrap(); let mut top_edges = top_edges; @@ -283,9 +279,9 @@ impl<'a> ShellBuilder<'a> { surface: Some(surface.clone()), global_form: vertex.global_form().clone().into(), } - .build(self.objects) + .build(objects) .unwrap() - .insert(self.objects) + .insert(objects) .unwrap() }); @@ -317,18 +313,18 @@ impl<'a> ShellBuilder<'a> { ..Default::default() } .update_as_line_segment() - .build(self.objects) + .build(objects) .unwrap() - .insert(self.objects) + .insert(objects) .unwrap(), ); } Face::partial() - .with_exterior(Cycle::new(edges).insert(self.objects).unwrap()) - .build(self.objects) + .with_exterior(Cycle::new(edges).insert(objects).unwrap()) + .build(objects) .unwrap() - .insert(self.objects) + .insert(objects) .unwrap() }; @@ -340,7 +336,7 @@ impl<'a> ShellBuilder<'a> { } /// Build the [`Shell`] - pub fn build(self) -> Handle { - Shell::new(self.faces).insert(self.objects).unwrap() + pub fn build(self, objects: &Objects) -> Handle { + Shell::new(self.faces).insert(objects).unwrap() } } diff --git a/crates/fj-kernel/src/builder/solid.rs b/crates/fj-kernel/src/builder/solid.rs index d42c6480e..6a2ff4b0a 100644 --- a/crates/fj-kernel/src/builder/solid.rs +++ b/crates/fj-kernel/src/builder/solid.rs @@ -35,8 +35,8 @@ impl<'a> SolidBuilder<'a> { edge_length: impl Into, ) -> Self { let shell = Shell::builder(self.objects) - .with_cube_from_edge_length(edge_length) - .build(); + .with_cube_from_edge_length(edge_length, self.objects) + .build(self.objects); self.shells.insert(shell); self } diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index cfe8020b8..47ffc07e7 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -528,8 +528,8 @@ mod tests { let objects = Objects::new(); let object = Shell::builder(&objects) - .with_cube_from_edge_length(1.) - .build(); + .with_cube_from_edge_length(1., &objects) + .build(&objects); assert_eq!(24, object.curve_iter().count()); assert_eq!(6, object.cycle_iter().count()); diff --git a/crates/fj-kernel/src/objects/full/shell.rs b/crates/fj-kernel/src/objects/full/shell.rs index d1c1d6aac..1d0cf9386 100644 --- a/crates/fj-kernel/src/objects/full/shell.rs +++ b/crates/fj-kernel/src/objects/full/shell.rs @@ -17,9 +17,8 @@ pub struct Shell { impl Shell { /// Build a `Shell` using [`ShellBuilder`] - pub fn builder(objects: &Objects) -> ShellBuilder { + pub fn builder(_: &Objects) -> ShellBuilder { ShellBuilder { - objects, faces: FaceSet::new(), } } From cdbfc063fff21d8ecdc88f693c9f9b937f5b1aa0 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 24 Nov 2022 15:40:14 +0100 Subject: [PATCH 2/6] Remove unused argument --- crates/fj-kernel/src/algorithms/sweep/face.rs | 2 +- crates/fj-kernel/src/algorithms/transform/shell.rs | 2 +- crates/fj-kernel/src/builder/solid.rs | 2 +- crates/fj-kernel/src/iter.rs | 2 +- crates/fj-kernel/src/objects/full/shell.rs | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/face.rs b/crates/fj-kernel/src/algorithms/sweep/face.rs index 2b90bb540..c00491a05 100644 --- a/crates/fj-kernel/src/algorithms/sweep/face.rs +++ b/crates/fj-kernel/src/algorithms/sweep/face.rs @@ -74,7 +74,7 @@ impl Sweep for Handle { } } - Ok(Shell::builder(objects).with_faces(faces).build(objects)) + Ok(Shell::builder().with_faces(faces).build(objects)) } } diff --git a/crates/fj-kernel/src/algorithms/transform/shell.rs b/crates/fj-kernel/src/algorithms/transform/shell.rs index f40992178..167b06e3c 100644 --- a/crates/fj-kernel/src/algorithms/transform/shell.rs +++ b/crates/fj-kernel/src/algorithms/transform/shell.rs @@ -22,6 +22,6 @@ impl TransformObject for Handle { face.transform(transform, objects) }) .collect::, _>>()?; - Ok(Shell::builder(objects).with_faces(faces).build(objects)) + Ok(Shell::builder().with_faces(faces).build(objects)) } } diff --git a/crates/fj-kernel/src/builder/solid.rs b/crates/fj-kernel/src/builder/solid.rs index 6a2ff4b0a..63274e29f 100644 --- a/crates/fj-kernel/src/builder/solid.rs +++ b/crates/fj-kernel/src/builder/solid.rs @@ -34,7 +34,7 @@ impl<'a> SolidBuilder<'a> { mut self, edge_length: impl Into, ) -> Self { - let shell = Shell::builder(self.objects) + let shell = Shell::builder() .with_cube_from_edge_length(edge_length, self.objects) .build(self.objects); self.shells.insert(shell); diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index 47ffc07e7..9feb1ed68 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -527,7 +527,7 @@ mod tests { fn shell() { let objects = Objects::new(); - let object = Shell::builder(&objects) + let object = Shell::builder() .with_cube_from_edge_length(1., &objects) .build(&objects); diff --git a/crates/fj-kernel/src/objects/full/shell.rs b/crates/fj-kernel/src/objects/full/shell.rs index 1d0cf9386..31eb2de7a 100644 --- a/crates/fj-kernel/src/objects/full/shell.rs +++ b/crates/fj-kernel/src/objects/full/shell.rs @@ -1,6 +1,6 @@ use crate::{ builder::ShellBuilder, - objects::{Face, FaceSet, Objects}, + objects::{Face, FaceSet}, storage::Handle, }; @@ -17,7 +17,7 @@ pub struct Shell { impl Shell { /// Build a `Shell` using [`ShellBuilder`] - pub fn builder(_: &Objects) -> ShellBuilder { + pub fn builder() -> ShellBuilder { ShellBuilder { faces: FaceSet::new(), } From a6f3e36591c05e64976da13869d07466b8034ae0 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 24 Nov 2022 15:42:43 +0100 Subject: [PATCH 3/6] Simplify `SketchBuilder` --- crates/fj-kernel/src/algorithms/sweep/face.rs | 8 ++++---- .../fj-kernel/src/algorithms/transform/sketch.rs | 2 +- crates/fj-kernel/src/builder/sketch.rs | 16 +++++++--------- crates/fj-kernel/src/iter.rs | 3 ++- crates/fj-kernel/src/objects/full/sketch.rs | 3 +-- crates/fj-operations/src/difference_2d.rs | 3 ++- crates/fj-operations/src/sketch.rs | 2 +- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/face.rs b/crates/fj-kernel/src/algorithms/sweep/face.rs index c00491a05..95d5253bf 100644 --- a/crates/fj-kernel/src/algorithms/sweep/face.rs +++ b/crates/fj-kernel/src/algorithms/sweep/face.rs @@ -104,8 +104,8 @@ mod tests { let surface = objects.surfaces.xy_plane(); let solid = Sketch::builder(&objects) .with_surface(surface.clone()) - .with_polygon_from_points(TRIANGLE) - .build() + .with_polygon_from_points(TRIANGLE, &objects) + .build(&objects) .sweep(UP, &objects)?; let bottom = Face::partial() @@ -151,8 +151,8 @@ mod tests { let surface = objects.surfaces.xy_plane(); let solid = Sketch::builder(&objects) .with_surface(surface.clone()) - .with_polygon_from_points(TRIANGLE) - .build() + .with_polygon_from_points(TRIANGLE, &objects) + .build(&objects) .sweep(DOWN, &objects)?; let bottom = Face::partial() diff --git a/crates/fj-kernel/src/algorithms/transform/sketch.rs b/crates/fj-kernel/src/algorithms/transform/sketch.rs index ed327d45f..cfdab0f49 100644 --- a/crates/fj-kernel/src/algorithms/transform/sketch.rs +++ b/crates/fj-kernel/src/algorithms/transform/sketch.rs @@ -20,6 +20,6 @@ impl TransformObject for Handle { .cloned() .map(|face| face.transform(transform, objects)) .collect::, _>>()?; - Ok(Sketch::builder(objects).with_faces(faces).build()) + Ok(Sketch::builder(objects).with_faces(faces).build(objects)) } } diff --git a/crates/fj-kernel/src/builder/sketch.rs b/crates/fj-kernel/src/builder/sketch.rs index 85f2a3f26..0e475933e 100644 --- a/crates/fj-kernel/src/builder/sketch.rs +++ b/crates/fj-kernel/src/builder/sketch.rs @@ -12,10 +12,7 @@ use super::FaceBuilder; /// API for building a [`Sketch`] /// /// Also see [`Sketch::builder`]. -pub struct SketchBuilder<'a> { - /// The stores that the created objects are put in - pub objects: &'a Objects, - +pub struct SketchBuilder { /// The surface that the [`Sketch`] is defined in pub surface: Option>, @@ -23,7 +20,7 @@ pub struct SketchBuilder<'a> { pub faces: FaceSet, } -impl<'a> SketchBuilder<'a> { +impl SketchBuilder { /// Build the [`Sketch`] with the provided [`Surface`] pub fn with_surface(mut self, surface: Handle) -> Self { self.surface = Some(surface); @@ -43,6 +40,7 @@ impl<'a> SketchBuilder<'a> { pub fn with_polygon_from_points( mut self, points: impl IntoIterator>>, + objects: &Objects, ) -> Self { let surface = self .surface @@ -51,15 +49,15 @@ impl<'a> SketchBuilder<'a> { self.faces.extend([Face::partial() .with_surface(surface.clone()) .with_exterior_polygon_from_points(points) - .build(self.objects) + .build(objects) .unwrap() - .insert(self.objects) + .insert(objects) .unwrap()]); self } /// Build the [`Sketch`] - pub fn build(self) -> Handle { - Sketch::new(self.faces).insert(self.objects).unwrap() + pub fn build(self, objects: &Objects) -> Handle { + Sketch::new(self.faces).insert(objects).unwrap() } } diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index 9feb1ed68..639808dcd 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -554,7 +554,8 @@ mod tests { .with_exterior_polygon_from_points([[0., 0.], [1., 0.], [0., 1.]]) .build(&objects)? .insert(&objects)?; - let object = Sketch::builder(&objects).with_faces([face]).build(); + let object = + Sketch::builder(&objects).with_faces([face]).build(&objects); assert_eq!(3, object.curve_iter().count()); assert_eq!(1, object.cycle_iter().count()); diff --git a/crates/fj-kernel/src/objects/full/sketch.rs b/crates/fj-kernel/src/objects/full/sketch.rs index b3c314a91..ceebc9132 100644 --- a/crates/fj-kernel/src/objects/full/sketch.rs +++ b/crates/fj-kernel/src/objects/full/sketch.rs @@ -17,9 +17,8 @@ pub struct Sketch { impl Sketch { /// Build a `Sketch` using [`SketchBuilder`] - pub fn builder(objects: &Objects) -> SketchBuilder { + pub fn builder(_: &Objects) -> SketchBuilder { SketchBuilder { - objects, surface: None, faces: FaceSet::new(), } diff --git a/crates/fj-operations/src/difference_2d.rs b/crates/fj-operations/src/difference_2d.rs index 54b60414a..bd4609842 100644 --- a/crates/fj-operations/src/difference_2d.rs +++ b/crates/fj-operations/src/difference_2d.rs @@ -89,7 +89,8 @@ impl Shape for fj::Difference2d { ); } - let difference = Sketch::builder(objects).with_faces(faces).build(); + let difference = + Sketch::builder(objects).with_faces(faces).build(objects); Ok(difference.deref().clone()) } diff --git a/crates/fj-operations/src/sketch.rs b/crates/fj-operations/src/sketch.rs index a37ca92dd..eb13dfb68 100644 --- a/crates/fj-operations/src/sketch.rs +++ b/crates/fj-operations/src/sketch.rs @@ -59,7 +59,7 @@ impl Shape for fj::Sketch { } }; - let sketch = Sketch::builder(objects).with_faces([face]).build(); + let sketch = Sketch::builder(objects).with_faces([face]).build(objects); Ok(sketch.deref().clone()) } From 21d68aa8cb1d474da99262ddbf1e810a4b894572 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 24 Nov 2022 15:43:34 +0100 Subject: [PATCH 4/6] Remove unused argument --- crates/fj-kernel/src/algorithms/sweep/face.rs | 4 ++-- crates/fj-kernel/src/algorithms/transform/sketch.rs | 2 +- crates/fj-kernel/src/iter.rs | 3 +-- crates/fj-kernel/src/objects/full/sketch.rs | 4 ++-- crates/fj-operations/src/difference_2d.rs | 3 +-- crates/fj-operations/src/sketch.rs | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/face.rs b/crates/fj-kernel/src/algorithms/sweep/face.rs index 95d5253bf..35cc8344c 100644 --- a/crates/fj-kernel/src/algorithms/sweep/face.rs +++ b/crates/fj-kernel/src/algorithms/sweep/face.rs @@ -102,7 +102,7 @@ mod tests { let objects = Objects::new(); let surface = objects.surfaces.xy_plane(); - let solid = Sketch::builder(&objects) + let solid = Sketch::builder() .with_surface(surface.clone()) .with_polygon_from_points(TRIANGLE, &objects) .build(&objects) @@ -149,7 +149,7 @@ mod tests { let objects = Objects::new(); let surface = objects.surfaces.xy_plane(); - let solid = Sketch::builder(&objects) + let solid = Sketch::builder() .with_surface(surface.clone()) .with_polygon_from_points(TRIANGLE, &objects) .build(&objects) diff --git a/crates/fj-kernel/src/algorithms/transform/sketch.rs b/crates/fj-kernel/src/algorithms/transform/sketch.rs index cfdab0f49..2b8ee131c 100644 --- a/crates/fj-kernel/src/algorithms/transform/sketch.rs +++ b/crates/fj-kernel/src/algorithms/transform/sketch.rs @@ -20,6 +20,6 @@ impl TransformObject for Handle { .cloned() .map(|face| face.transform(transform, objects)) .collect::, _>>()?; - Ok(Sketch::builder(objects).with_faces(faces).build(objects)) + Ok(Sketch::builder().with_faces(faces).build(objects)) } } diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index 639808dcd..97b27699c 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -554,8 +554,7 @@ mod tests { .with_exterior_polygon_from_points([[0., 0.], [1., 0.], [0., 1.]]) .build(&objects)? .insert(&objects)?; - let object = - Sketch::builder(&objects).with_faces([face]).build(&objects); + let object = Sketch::builder().with_faces([face]).build(&objects); assert_eq!(3, object.curve_iter().count()); assert_eq!(1, object.cycle_iter().count()); diff --git a/crates/fj-kernel/src/objects/full/sketch.rs b/crates/fj-kernel/src/objects/full/sketch.rs index ceebc9132..ca58de263 100644 --- a/crates/fj-kernel/src/objects/full/sketch.rs +++ b/crates/fj-kernel/src/objects/full/sketch.rs @@ -1,6 +1,6 @@ use crate::{ builder::SketchBuilder, - objects::{Face, FaceSet, Objects}, + objects::{Face, FaceSet}, storage::Handle, }; @@ -17,7 +17,7 @@ pub struct Sketch { impl Sketch { /// Build a `Sketch` using [`SketchBuilder`] - pub fn builder(_: &Objects) -> SketchBuilder { + pub fn builder() -> SketchBuilder { SketchBuilder { surface: None, faces: FaceSet::new(), diff --git a/crates/fj-operations/src/difference_2d.rs b/crates/fj-operations/src/difference_2d.rs index bd4609842..d4518dc61 100644 --- a/crates/fj-operations/src/difference_2d.rs +++ b/crates/fj-operations/src/difference_2d.rs @@ -89,8 +89,7 @@ impl Shape for fj::Difference2d { ); } - let difference = - Sketch::builder(objects).with_faces(faces).build(objects); + let difference = Sketch::builder().with_faces(faces).build(objects); Ok(difference.deref().clone()) } diff --git a/crates/fj-operations/src/sketch.rs b/crates/fj-operations/src/sketch.rs index eb13dfb68..041fca4eb 100644 --- a/crates/fj-operations/src/sketch.rs +++ b/crates/fj-operations/src/sketch.rs @@ -59,7 +59,7 @@ impl Shape for fj::Sketch { } }; - let sketch = Sketch::builder(objects).with_faces([face]).build(objects); + let sketch = Sketch::builder().with_faces([face]).build(objects); Ok(sketch.deref().clone()) } From d8d7396667748b83df791bae31b81d463e0f10a3 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 24 Nov 2022 15:45:50 +0100 Subject: [PATCH 5/6] Simplify `SolidBuilder` --- crates/fj-kernel/src/algorithms/sweep/sketch.rs | 2 +- .../fj-kernel/src/algorithms/transform/solid.rs | 2 +- crates/fj-kernel/src/builder/solid.rs | 16 +++++++--------- crates/fj-kernel/src/iter.rs | 4 ++-- crates/fj-kernel/src/objects/full/solid.rs | 3 +-- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/sketch.rs b/crates/fj-kernel/src/algorithms/sweep/sketch.rs index fbd1a691f..cebc85a21 100644 --- a/crates/fj-kernel/src/algorithms/sweep/sketch.rs +++ b/crates/fj-kernel/src/algorithms/sweep/sketch.rs @@ -25,6 +25,6 @@ impl Sweep for Handle { shells.push(shell); } - Ok(Solid::builder(objects).with_shells(shells).build()) + Ok(Solid::builder(objects).with_shells(shells).build(objects)) } } diff --git a/crates/fj-kernel/src/algorithms/transform/solid.rs b/crates/fj-kernel/src/algorithms/transform/solid.rs index 684ce0b79..e68fc1abd 100644 --- a/crates/fj-kernel/src/algorithms/transform/solid.rs +++ b/crates/fj-kernel/src/algorithms/transform/solid.rs @@ -21,6 +21,6 @@ impl TransformObject for Handle { shell.transform(transform, objects) }) .collect::, _>>()?; - Ok(Solid::builder(objects).with_shells(faces).build()) + Ok(Solid::builder(objects).with_shells(faces).build(objects)) } } diff --git a/crates/fj-kernel/src/builder/solid.rs b/crates/fj-kernel/src/builder/solid.rs index 63274e29f..d8c3ecc40 100644 --- a/crates/fj-kernel/src/builder/solid.rs +++ b/crates/fj-kernel/src/builder/solid.rs @@ -11,15 +11,12 @@ use crate::{ /// API for building a [`Solid`] /// /// Also see [`Solid::builder`]. -pub struct SolidBuilder<'a> { - /// The stores that the created objects are put in - pub objects: &'a Objects, - +pub struct SolidBuilder { /// The shells that make up the [`Solid`] pub shells: BTreeSet>, } -impl<'a> SolidBuilder<'a> { +impl SolidBuilder { /// Build the [`Solid`] with the provided shells pub fn with_shells( mut self, @@ -33,16 +30,17 @@ impl<'a> SolidBuilder<'a> { pub fn with_cube_from_edge_length( mut self, edge_length: impl Into, + objects: &Objects, ) -> Self { let shell = Shell::builder() - .with_cube_from_edge_length(edge_length, self.objects) - .build(self.objects); + .with_cube_from_edge_length(edge_length, objects) + .build(objects); self.shells.insert(shell); self } /// Build the [`Solid`] - pub fn build(self) -> Handle { - Solid::new(self.shells).insert(self.objects).unwrap() + pub fn build(self, objects: &Objects) -> Handle { + Solid::new(self.shells).insert(objects).unwrap() } } diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index 97b27699c..30520b7ca 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -576,8 +576,8 @@ mod tests { let objects = Objects::new(); let object = Solid::builder(&objects) - .with_cube_from_edge_length(1.) - .build(); + .with_cube_from_edge_length(1., &objects) + .build(&objects); assert_eq!(24, object.curve_iter().count()); assert_eq!(6, object.cycle_iter().count()); diff --git a/crates/fj-kernel/src/objects/full/solid.rs b/crates/fj-kernel/src/objects/full/solid.rs index 8ff6aa00e..760beba4f 100644 --- a/crates/fj-kernel/src/objects/full/solid.rs +++ b/crates/fj-kernel/src/objects/full/solid.rs @@ -19,9 +19,8 @@ pub struct Solid { impl Solid { /// Build a `Solid` using [`SolidBuilder`] - pub fn builder(objects: &Objects) -> SolidBuilder { + pub fn builder(_: &Objects) -> SolidBuilder { SolidBuilder { - objects, shells: BTreeSet::new(), } } From d2f64436baeb2858e53c202b5144744002ff88ef Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 24 Nov 2022 15:46:31 +0100 Subject: [PATCH 6/6] Remove unused argument --- crates/fj-kernel/src/algorithms/sweep/sketch.rs | 2 +- crates/fj-kernel/src/algorithms/transform/solid.rs | 2 +- crates/fj-kernel/src/iter.rs | 2 +- crates/fj-kernel/src/objects/full/solid.rs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/sketch.rs b/crates/fj-kernel/src/algorithms/sweep/sketch.rs index cebc85a21..49d49bbfd 100644 --- a/crates/fj-kernel/src/algorithms/sweep/sketch.rs +++ b/crates/fj-kernel/src/algorithms/sweep/sketch.rs @@ -25,6 +25,6 @@ impl Sweep for Handle { shells.push(shell); } - Ok(Solid::builder(objects).with_shells(shells).build(objects)) + Ok(Solid::builder().with_shells(shells).build(objects)) } } diff --git a/crates/fj-kernel/src/algorithms/transform/solid.rs b/crates/fj-kernel/src/algorithms/transform/solid.rs index e68fc1abd..0230f8ddf 100644 --- a/crates/fj-kernel/src/algorithms/transform/solid.rs +++ b/crates/fj-kernel/src/algorithms/transform/solid.rs @@ -21,6 +21,6 @@ impl TransformObject for Handle { shell.transform(transform, objects) }) .collect::, _>>()?; - Ok(Solid::builder(objects).with_shells(faces).build(objects)) + Ok(Solid::builder().with_shells(faces).build(objects)) } } diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index 30520b7ca..2f7417597 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -575,7 +575,7 @@ mod tests { fn solid() { let objects = Objects::new(); - let object = Solid::builder(&objects) + let object = Solid::builder() .with_cube_from_edge_length(1., &objects) .build(&objects); diff --git a/crates/fj-kernel/src/objects/full/solid.rs b/crates/fj-kernel/src/objects/full/solid.rs index 760beba4f..7c0236a0f 100644 --- a/crates/fj-kernel/src/objects/full/solid.rs +++ b/crates/fj-kernel/src/objects/full/solid.rs @@ -2,7 +2,7 @@ use std::collections::BTreeSet; use crate::{ builder::SolidBuilder, - objects::{Face, Objects, Shell}, + objects::{Face, Shell}, storage::Handle, }; @@ -19,7 +19,7 @@ pub struct Solid { impl Solid { /// Build a `Solid` using [`SolidBuilder`] - pub fn builder(_: &Objects) -> SolidBuilder { + pub fn builder() -> SolidBuilder { SolidBuilder { shells: BTreeSet::new(), }