diff --git a/crates/fj-core/src/operations/build/shell.rs b/crates/fj-core/src/operations/build/shell.rs index a40344324..2fdc55442 100644 --- a/crates/fj-core/src/operations/build/shell.rs +++ b/crates/fj-core/src/operations/build/shell.rs @@ -11,6 +11,11 @@ use crate::{ /// Build a [`Shell`] pub trait BuildShell { + /// Build an empty shell + fn empty() -> Shell { + Shell::new([]) + } + /// Build a tetrahedron from the provided points /// /// Accepts 4 points, naturally. For the purposes of the following diff --git a/crates/fj-core/src/operations/update/cycle.rs b/crates/fj-core/src/operations/update/cycle.rs index 5315ea684..c2b47f488 100644 --- a/crates/fj-core/src/operations/update/cycle.rs +++ b/crates/fj-core/src/operations/update/cycle.rs @@ -9,7 +9,7 @@ pub trait UpdateCycle { fn add_half_edges( &self, half_edges: impl IntoIterator>, - ) -> Cycle; + ) -> Self; /// Replace the provided half-edge /// @@ -20,7 +20,7 @@ pub trait UpdateCycle { &self, original: &Handle, replacement: Handle, - ) -> Cycle; + ) -> Self; /// Update the half-edge at the given index /// @@ -31,14 +31,14 @@ pub trait UpdateCycle { &self, index: usize, f: impl FnMut(&Handle) -> Handle, - ) -> Cycle; + ) -> Self; } impl UpdateCycle for Cycle { fn add_half_edges( &self, half_edges: impl IntoIterator>, - ) -> Cycle { + ) -> Self { let half_edges = self.half_edges().cloned().chain(half_edges); Cycle::new(half_edges) } @@ -47,7 +47,7 @@ impl UpdateCycle for Cycle { &self, original: &Handle, replacement: Handle, - ) -> Cycle { + ) -> Self { let mut num_replacements = 0; let half_edges = self.half_edges().map(|half_edge| { @@ -73,7 +73,7 @@ impl UpdateCycle for Cycle { &self, index: usize, mut f: impl FnMut(&Handle) -> Handle, - ) -> Cycle { + ) -> Self { let mut num_replacements = 0; let half_edges = self.half_edges().enumerate().map(|(i, half_edge)| { diff --git a/crates/fj-core/src/operations/update/edge.rs b/crates/fj-core/src/operations/update/edge.rs index 758fd0293..c1def62b4 100644 --- a/crates/fj-core/src/operations/update/edge.rs +++ b/crates/fj-core/src/operations/update/edge.rs @@ -6,14 +6,14 @@ use crate::{ /// Update a [`HalfEdge`] pub trait UpdateHalfEdge { /// Update the start vertex of the half-edge - fn replace_start_vertex(&self, start_vertex: Handle) -> HalfEdge; + fn replace_start_vertex(&self, start_vertex: Handle) -> Self; /// Update the global form of the half-edge - fn replace_global_form(&self, global_form: Handle) -> HalfEdge; + fn replace_global_form(&self, global_form: Handle) -> Self; } impl UpdateHalfEdge for HalfEdge { - fn replace_start_vertex(&self, start_vertex: Handle) -> HalfEdge { + fn replace_start_vertex(&self, start_vertex: Handle) -> Self { HalfEdge::new( self.curve(), self.boundary(), @@ -22,7 +22,7 @@ impl UpdateHalfEdge for HalfEdge { ) } - fn replace_global_form(&self, global_form: Handle) -> HalfEdge { + fn replace_global_form(&self, global_form: Handle) -> Self { HalfEdge::new( self.curve(), self.boundary(), diff --git a/crates/fj-core/src/operations/update/shell.rs b/crates/fj-core/src/operations/update/shell.rs index 3133b2d83..8d5291805 100644 --- a/crates/fj-core/src/operations/update/shell.rs +++ b/crates/fj-core/src/operations/update/shell.rs @@ -5,23 +5,31 @@ use crate::{ /// Update a [`Shell`] pub trait UpdateShell { + /// Add faces to the shell + fn add_faces(&self, faces: impl IntoIterator>) -> Self; + /// Update a face of the shell fn replace_face( &self, original: &Handle, replacement: Handle, - ) -> Shell; + ) -> Self; /// Remove a face from the shell - fn remove_face(&self, handle: &Handle) -> Shell; + fn remove_face(&self, handle: &Handle) -> Self; } impl UpdateShell for Shell { + fn add_faces(&self, faces: impl IntoIterator>) -> Self { + let faces = self.faces().into_iter().cloned().chain(faces); + Shell::new(faces) + } + fn replace_face( &self, original: &Handle, replacement: Handle, - ) -> Shell { + ) -> Self { let faces = self.faces().into_iter().map(|face| { if face.id() == original.id() { replacement.clone() @@ -33,7 +41,7 @@ impl UpdateShell for Shell { Shell::new(faces) } - fn remove_face(&self, handle: &Handle) -> Shell { + fn remove_face(&self, handle: &Handle) -> Self { let faces = self .faces() .into_iter() diff --git a/crates/fj-core/src/operations/update/solid.rs b/crates/fj-core/src/operations/update/solid.rs index a6135207e..db2979a91 100644 --- a/crates/fj-core/src/operations/update/solid.rs +++ b/crates/fj-core/src/operations/update/solid.rs @@ -9,14 +9,14 @@ pub trait UpdateSolid { fn add_shells( &self, shells: impl IntoIterator>, - ) -> Solid; + ) -> Self; } impl UpdateSolid for Solid { fn add_shells( &self, shells: impl IntoIterator>, - ) -> Solid { + ) -> Self { let shells = self.shells().cloned().chain(shells); Solid::new(shells) }