From 6433d7d6b531f84388184e1ac35474a9f24a9763 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 13 Mar 2024 12:21:14 +0100 Subject: [PATCH 1/5] Add `ShellExtendedBySweep` --- crates/fj-core/src/operations/sweep/mod.rs | 2 +- .../fj-core/src/operations/sweep/shell_face.rs | 16 +++++++++++++--- models/split/src/lib.rs | 4 +++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/crates/fj-core/src/operations/sweep/mod.rs b/crates/fj-core/src/operations/sweep/mod.rs index 9ed29c1ff7..5d3a4552c2 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/shell_face.rs b/crates/fj-core/src/operations/sweep/shell_face.rs index 4a54bbbde5..9421997088 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() { @@ -76,6 +76,16 @@ impl SweepFaceOfShell for Shell { .all_faces() .collect::>(); - self.remove_face(&face).add_faces(faces, core) + let shell = self.remove_face(&face).add_faces(faces, core); + + ShellExtendedBySweep { shell } } } + +/// The result of sweeping a [`Face`] of a [`Shell`] +/// +/// See [`SweepFaceOfShell`]. +pub struct ShellExtendedBySweep { + /// The resulting shell after the sweep + pub shell: Shell, +} diff --git a/models/split/src/lib.rs b/models/split/src/lib.rs index 4d1ca96b38..1792c8e078 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, ) From 8eb0796cf9b9549e4dbe1a79cf10a31dad06d14a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 13 Mar 2024 12:22:14 +0100 Subject: [PATCH 2/5] Refactor to simplify --- crates/fj-core/src/operations/sweep/shell_face.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/fj-core/src/operations/sweep/shell_face.rs b/crates/fj-core/src/operations/sweep/shell_face.rs index 9421997088..5f9e693692 100644 --- a/crates/fj-core/src/operations/sweep/shell_face.rs +++ b/crates/fj-core/src/operations/sweep/shell_face.rs @@ -73,8 +73,7 @@ impl SweepFaceOfShell for Shell { &mut cache, core, ) - .all_faces() - .collect::>(); + .all_faces(); let shell = self.remove_face(&face).add_faces(faces, core); From b9b45ca9afbc8fadc89d244500cc2a37a18e2c36 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 13 Mar 2024 12:22:54 +0100 Subject: [PATCH 3/5] Refactor to prepare for follow-on change --- .../src/operations/sweep/shell_face.rs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/fj-core/src/operations/sweep/shell_face.rs b/crates/fj-core/src/operations/sweep/shell_face.rs index 5f9e693692..e8a5c8b58c 100644 --- a/crates/fj-core/src/operations/sweep/shell_face.rs +++ b/crates/fj-core/src/operations/sweep/shell_face.rs @@ -65,17 +65,17 @@ 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(); + 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(faces, core); + let shell = self + .remove_face(&face) + .add_faces(swept_region.all_faces(), core); ShellExtendedBySweep { shell } } From 7912e9920c43068fb13b2f4f870d6a7f6d589bcd Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 13 Mar 2024 12:26:38 +0100 Subject: [PATCH 4/5] Derive `Clone` for `SweptRegion` --- crates/fj-core/src/operations/sweep/region.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/fj-core/src/operations/sweep/region.rs b/crates/fj-core/src/operations/sweep/region.rs index a91255f24f..d8b632854f 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, From 127110816958cdca95987528d5ca773e80531643 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 13 Mar 2024 12:26:48 +0100 Subject: [PATCH 5/5] Add more information to `ShellExtendedBySweep` --- crates/fj-core/src/operations/sweep/shell_face.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/operations/sweep/shell_face.rs b/crates/fj-core/src/operations/sweep/shell_face.rs index e8a5c8b58c..3a03c0cf4f 100644 --- a/crates/fj-core/src/operations/sweep/shell_face.rs +++ b/crates/fj-core/src/operations/sweep/shell_face.rs @@ -75,9 +75,13 @@ impl SweepFaceOfShell for Shell { let shell = self .remove_face(&face) - .add_faces(swept_region.all_faces(), core); + .add_faces(swept_region.clone().all_faces(), core); - ShellExtendedBySweep { shell } + ShellExtendedBySweep { + shell, + side_faces: swept_region.side_faces, + top_face: swept_region.top_face, + } } } @@ -87,4 +91,10 @@ impl SweepFaceOfShell for Shell { 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, }