Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return more information from shell-face sweep operation #2260

Merged
merged 5 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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