Skip to content

Commit

Permalink
Return top edge from half-edge sweep
Browse files Browse the repository at this point in the history
This is going to be required in the face sweep code, to make sure the
top of the solid is properly stitched up with the sides.
  • Loading branch information
hannobraun committed Feb 16, 2023
1 parent b04638e commit 819001e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
10 changes: 6 additions & 4 deletions crates/fj-kernel/src/algorithms/sweep/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
use super::{Sweep, SweepCache};

impl Sweep for (Handle<HalfEdge>, Color) {
type Swept = Handle<Face>;
type Swept = (Handle<Face>, Handle<HalfEdge>);

fn sweep_with_cache(
self,
Expand Down Expand Up @@ -137,7 +137,7 @@ impl Sweep for (Handle<HalfEdge>, Color) {
let cycle = {
let a = bottom_edge;
let [d, b] = side_edges;
let c = top_edge;
let c = top_edge.clone();

let mut edges = [a, b, c, d];

Expand Down Expand Up @@ -167,7 +167,9 @@ impl Sweep for (Handle<HalfEdge>, Color) {
color: Some(color),
..Default::default()
};
face.build(objects).insert(objects)
let face = face.build(objects).insert(objects);

(face, top_edge)
}
}

Expand Down Expand Up @@ -202,7 +204,7 @@ mod tests {
.insert(&mut services.objects)
};

let face = (half_edge, Color::default())
let (face, _) = (half_edge, Color::default())
.sweep([0., 0., 1.], &mut services.objects);

let expected_face = {
Expand Down
10 changes: 7 additions & 3 deletions crates/fj-kernel/src/algorithms/sweep/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Sweep for Handle<Face> {
let cycle = cycle.reverse(objects);

for half_edge in cycle.half_edges().cloned() {
let face = (half_edge, self.color())
let (face, _) = (half_edge, self.color())
.sweep_with_cache(path, cache, objects);

faces.push(face);
Expand Down Expand Up @@ -155,7 +155,9 @@ mod tests {
.build(&mut services.objects)
.insert(&mut services.objects)
};
(half_edge, Color::default()).sweep(UP, &mut services.objects)
let (face, _) =
(half_edge, Color::default()).sweep(UP, &mut services.objects);
face
});

assert!(side_faces
Expand Down Expand Up @@ -222,7 +224,9 @@ mod tests {
.insert(&mut services.objects)
.reverse(&mut services.objects)
};
(half_edge, Color::default()).sweep(DOWN, &mut services.objects)
let (face, _) = (half_edge, Color::default())
.sweep(DOWN, &mut services.objects);
face
});

assert!(side_faces
Expand Down

0 comments on commit 819001e

Please sign in to comment.