Skip to content

Commit 2442084

Browse files
authored
Merge pull request #2137 from hannobraun/sweep
Add `SweptRegion`
2 parents c70d86b + a83b277 commit 2442084

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

crates/fj-core/src/operations/holes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl AddHole for Shell {
5050
&mut SweepCache::default(),
5151
services,
5252
)
53-
.into_iter()
53+
.all_faces()
5454
.map(|face| face.insert(services))
5555
.collect::<Vec<_>>();
5656

crates/fj-core/src/operations/sweep/face.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl SweepFace for Handle<Face> {
5454
let side_faces = bottom_face
5555
.region()
5656
.sweep_region(bottom_face.surface(), path, cache, services)
57-
.into_iter()
57+
.all_faces()
5858
.map(|side_face| side_face.insert(services));
5959
faces.extend(side_faces);
6060

crates/fj-core/src/operations/sweep/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub use self::{
1717
face::SweepFace,
1818
half_edge::SweepHalfEdge,
1919
path::SweepSurfacePath,
20-
region::SweepRegion,
20+
region::{SweepRegion, SweptRegion},
2121
shell_face::SweepFaceOfShell,
2222
sketch::SweepSketch,
2323
vertex::SweepVertex,

crates/fj-core/src/operations/sweep/region.rs

+24-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub trait SweepRegion {
3434
path: impl Into<Vector<3>>,
3535
cache: &mut SweepCache,
3636
services: &mut Services,
37-
) -> Vec<Face>;
37+
) -> SweptRegion;
3838
}
3939

4040
impl SweepRegion for Region {
@@ -44,7 +44,7 @@ impl SweepRegion for Region {
4444
path: impl Into<Vector<3>>,
4545
cache: &mut SweepCache,
4646
services: &mut Services,
47-
) -> Vec<Face> {
47+
) -> SweptRegion {
4848
let path = path.into();
4949

5050
let mut faces = Vec::new();
@@ -84,9 +84,11 @@ impl SweepRegion for Region {
8484

8585
Face::new(top_surface, top_region)
8686
};
87-
faces.push(top_face);
8887

89-
faces
88+
SweptRegion {
89+
top_face,
90+
side_faces: faces,
91+
}
9092
}
9193
}
9294

@@ -111,3 +113,21 @@ fn sweep_cycle(
111113

112114
swept_cycle.top_cycle.insert(services)
113115
}
116+
117+
/// The result of sweeping a [`Region`]
118+
///
119+
/// See [`SweepRegion`].
120+
pub struct SweptRegion {
121+
/// The side faces created by the sweep
122+
pub side_faces: Vec<Face>,
123+
124+
/// The top face created by the sweep
125+
pub top_face: Face,
126+
}
127+
128+
impl SweptRegion {
129+
/// Return an iterator over all of the faces
130+
pub fn all_faces(self) -> impl Iterator<Item = Face> {
131+
self.side_faces.into_iter().chain([self.top_face])
132+
}
133+
}

crates/fj-core/src/operations/sweep/shell_face.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl SweepFaceOfShell for Shell {
5757
let region = Region::new(exterior, [], face.region().color());
5858
let faces = region
5959
.sweep_region(face.surface(), path, &mut cache, services)
60-
.into_iter()
60+
.all_faces()
6161
.map(|face| face.insert(services));
6262

6363
self.remove_face(&face).add_faces(faces)

0 commit comments

Comments
 (0)