Skip to content

Commit

Permalink
Replace UpdateSolid::add_shell with add_shells
Browse files Browse the repository at this point in the history
This is more flexible and follows the convention of other, similar
methods of the operations API.
  • Loading branch information
hannobraun committed Jun 19, 2023
1 parent 4232b5a commit 5d474c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/fj-core/src/operations/build/solid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub trait BuildSolid {
services: &mut Services,
) -> Tetrahedron {
let shell = Shell::tetrahedron(points, services).insert(services);
let solid = Solid::empty().add_shell(shell.shell.clone());
let solid = Solid::empty().add_shells([shell.shell.clone()]);

Tetrahedron { solid, shell }
}
Expand Down
12 changes: 9 additions & 3 deletions crates/fj-core/src/operations/update/solid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ use crate::{
/// Update a [`Solid`]
pub trait UpdateSolid {
/// Add a shell to the solid
fn add_shell(&self, shell: Handle<Shell>) -> Solid;
fn add_shells(
&self,
shells: impl IntoIterator<Item = Handle<Shell>>,
) -> Solid;
}

impl UpdateSolid for Solid {
fn add_shell(&self, shell: Handle<Shell>) -> Solid {
let shells = self.shells().cloned().chain([shell]);
fn add_shells(
&self,
shells: impl IntoIterator<Item = Handle<Shell>>,
) -> Solid {
let shells = self.shells().cloned().chain(shells);
Solid::new(shells)
}
}

0 comments on commit 5d474c4

Please sign in to comment.