diff --git a/crates/fj-core/src/operations/sweep/mod.rs b/crates/fj-core/src/operations/sweep/mod.rs index 9ed29c1ff..5d3a4552c 100644 --- a/crates/fj-core/src/operations/sweep/mod.rs +++ b/crates/fj-core/src/operations/sweep/mod.rs @@ -18,7 +18,7 @@ pub use self::{ half_edge::SweepHalfEdge, path::SweepSurfacePath, region::{SweepRegion, SweptRegion}, - shell_face::SweepFaceOfShell, + shell_face::{ShellExtendedBySweep, SweepFaceOfShell}, sketch::SweepSketch, vertex::SweepVertex, }; diff --git a/crates/fj-core/src/operations/sweep/region.rs b/crates/fj-core/src/operations/sweep/region.rs index a91255f24..d8b632854 100644 --- a/crates/fj-core/src/operations/sweep/region.rs +++ b/crates/fj-core/src/operations/sweep/region.rs @@ -119,6 +119,7 @@ fn sweep_cycle( /// The result of sweeping a [`Region`] /// /// See [`SweepRegion`]. +#[derive(Clone)] pub struct SweptRegion { /// The side faces created by the sweep pub side_faces: Vec, diff --git a/crates/fj-core/src/operations/sweep/shell_face.rs b/crates/fj-core/src/operations/sweep/shell_face.rs index 4a54bbbde..3a03c0cf4 100644 --- a/crates/fj-core/src/operations/sweep/shell_face.rs +++ b/crates/fj-core/src/operations/sweep/shell_face.rs @@ -37,7 +37,7 @@ pub trait SweepFaceOfShell { face: Handle, path: impl Into>, core: &mut Core, - ) -> Self; + ) -> ShellExtendedBySweep; } impl SweepFaceOfShell for Shell { @@ -46,7 +46,7 @@ impl SweepFaceOfShell for Shell { face: Handle, path: impl Into>, core: &mut Core, - ) -> Self { + ) -> ShellExtendedBySweep { let path = path.into(); if !face.region().interiors().is_empty() { @@ -65,17 +65,36 @@ impl SweepFaceOfShell for Shell { .insert(core) .derive_from(face.region().exterior(), core); let region = Region::new(exterior, []); - let faces = region - .sweep_region( - face.surface(), - face.region().get_color(core), - path, - &mut cache, - core, - ) - .all_faces() - .collect::>(); + let swept_region = region.sweep_region( + face.surface(), + face.region().get_color(core), + path, + &mut cache, + core, + ); + + let shell = self + .remove_face(&face) + .add_faces(swept_region.clone().all_faces(), core); - self.remove_face(&face).add_faces(faces, core) + ShellExtendedBySweep { + shell, + side_faces: swept_region.side_faces, + top_face: swept_region.top_face, + } } } + +/// The result of sweeping a [`Face`] of a [`Shell`] +/// +/// See [`SweepFaceOfShell`]. +pub struct ShellExtendedBySweep { + /// The resulting shell after the sweep + pub shell: Shell, + + /// The side faces created by the sweep + pub side_faces: Vec, + + /// The top face created by the sweep + pub top_face: Face, +} diff --git a/models/split/src/lib.rs b/models/split/src/lib.rs index 4d1ca96b3..1792c8e07 100644 --- a/models/split/src/lib.rs +++ b/models/split/src/lib.rs @@ -21,7 +21,9 @@ pub fn model(size: f64, split_pos: f64, core: &mut fj::core::Core) -> Solid { let (shell, [face, _]) = shell.split_face(face, line, core); - [shell.sweep_face_of_shell(face, [0., 0., -size / 2.], core)] + [shell + .sweep_face_of_shell(face, [0., 0., -size / 2.], core) + .shell] }, core, )