-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2121 from hannobraun/sweep
Add `SweepFaceOfShell`
- Loading branch information
Showing
3 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use fj_math::Vector; | ||
|
||
use crate::{ | ||
objects::{Face, Region, Shell}, | ||
operations::{ | ||
insert::Insert, | ||
reverse::Reverse, | ||
sweep::{SweepCache, SweepRegion}, | ||
update::UpdateShell, | ||
}, | ||
services::Services, | ||
storage::Handle, | ||
}; | ||
|
||
/// # Sweep a [`Face`] that is part of a [`Shell`] | ||
/// | ||
/// See [module documentation] for more information. | ||
/// | ||
/// [module documentation]: super | ||
pub trait SweepFaceOfShell { | ||
/// # Sweep the [`Face`] of the [`Shell`] | ||
/// | ||
/// Extends the shell, adding the new faces to it. | ||
/// | ||
/// # Panics | ||
/// | ||
/// Panics, if the face has interior cycles. This is not a fundamental | ||
/// limitation, but none the less not yet supported. | ||
fn sweep_face_of_shell( | ||
&self, | ||
face: Handle<Face>, | ||
path: impl Into<Vector<3>>, | ||
services: &mut Services, | ||
) -> Self; | ||
} | ||
|
||
impl SweepFaceOfShell for Shell { | ||
fn sweep_face_of_shell( | ||
&self, | ||
face: Handle<Face>, | ||
path: impl Into<Vector<3>>, | ||
services: &mut Services, | ||
) -> Self { | ||
let path = path.into(); | ||
|
||
if !face.region().interiors().is_empty() { | ||
todo!( | ||
"Sweeping shell faces with interior cycles is not yet \ | ||
supported." | ||
) | ||
} | ||
|
||
let mut cache = SweepCache::default(); | ||
|
||
let exterior = | ||
face.region().exterior().reverse(services).insert(services); | ||
let region = Region::new(exterior, [], face.region().color()); | ||
let faces = region | ||
.sweep_region(face.surface(), path, &mut cache, services) | ||
.into_iter() | ||
.map(|face| face.insert(services)); | ||
|
||
self.remove_face(&face).add_faces(faces) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters