From 01ba108aa2cdcbcb64a7bdce0dbe6617177cf563 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 24 Mar 2023 14:15:33 +0100 Subject: [PATCH] Add `UpdateSolid` --- crates/fj-kernel/src/operations/mod.rs | 4 +++- crates/fj-kernel/src/operations/update/mod.rs | 3 ++- crates/fj-kernel/src/operations/update/solid.rs | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 crates/fj-kernel/src/operations/update/solid.rs diff --git a/crates/fj-kernel/src/operations/mod.rs b/crates/fj-kernel/src/operations/mod.rs index 5c65569c4..1f5913e9a 100644 --- a/crates/fj-kernel/src/operations/mod.rs +++ b/crates/fj-kernel/src/operations/mod.rs @@ -12,5 +12,7 @@ pub use self::{ }, insert::{Insert, IsInserted, IsInsertedNo, IsInsertedYes}, join::JoinCycle, - update::{UpdateCycle, UpdateFace, UpdateHalfEdge, UpdateShell}, + update::{ + UpdateCycle, UpdateFace, UpdateHalfEdge, UpdateShell, UpdateSolid, + }, }; diff --git a/crates/fj-kernel/src/operations/update/mod.rs b/crates/fj-kernel/src/operations/update/mod.rs index 73f5d0874..431b97368 100644 --- a/crates/fj-kernel/src/operations/update/mod.rs +++ b/crates/fj-kernel/src/operations/update/mod.rs @@ -2,8 +2,9 @@ mod cycle; mod edge; mod face; mod shell; +mod solid; pub use self::{ cycle::UpdateCycle, edge::UpdateHalfEdge, face::UpdateFace, - shell::UpdateShell, + shell::UpdateShell, solid::UpdateSolid, }; diff --git a/crates/fj-kernel/src/operations/update/solid.rs b/crates/fj-kernel/src/operations/update/solid.rs new file mode 100644 index 000000000..9c0e340f7 --- /dev/null +++ b/crates/fj-kernel/src/operations/update/solid.rs @@ -0,0 +1,17 @@ +use crate::{ + objects::{Shell, Solid}, + storage::Handle, +}; + +/// Update a [`Solid`] +pub trait UpdateSolid { + /// Add a shell to the solid + fn add_shell(&self, shell: Handle) -> Solid; +} + +impl UpdateSolid for Solid { + fn add_shell(&self, shell: Handle) -> Solid { + let shells = self.shells().cloned().chain([shell]); + Solid::new(shells) + } +}