Skip to content

Commit

Permalink
Merge pull request #2260 from hannobraun/sweep
Browse files Browse the repository at this point in the history
Return more information from shell-face sweep operation
  • Loading branch information
hannobraun authored Mar 13, 2024
2 parents 7d9f681 + 1271108 commit c9fa417
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 15 deletions.
2 changes: 1 addition & 1 deletion crates/fj-core/src/operations/sweep/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
1 change: 1 addition & 0 deletions crates/fj-core/src/operations/sweep/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Face>,
Expand Down
45 changes: 32 additions & 13 deletions crates/fj-core/src/operations/sweep/shell_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub trait SweepFaceOfShell {
face: Handle<Face>,
path: impl Into<Vector<3>>,
core: &mut Core,
) -> Self;
) -> ShellExtendedBySweep;
}

impl SweepFaceOfShell for Shell {
Expand All @@ -46,7 +46,7 @@ impl SweepFaceOfShell for Shell {
face: Handle<Face>,
path: impl Into<Vector<3>>,
core: &mut Core,
) -> Self {
) -> ShellExtendedBySweep {
let path = path.into();

if !face.region().interiors().is_empty() {
Expand All @@ -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::<Vec<_>>();
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<Face>,

/// The top face created by the sweep
pub top_face: Face,
}
4 changes: 3 additions & 1 deletion models/split/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down

0 comments on commit c9fa417

Please sign in to comment.