Skip to content

Commit

Permalink
Merge pull request #1220 from hannobraun/duplication
Browse files Browse the repository at this point in the history
Fix more `SurfaceVertex` duplication issues
  • Loading branch information
hannobraun authored Oct 13, 2022
2 parents a6091e8 + 96cd9fb commit c4d866f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
43 changes: 34 additions & 9 deletions crates/fj-kernel/src/algorithms/sweep/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ mod tests {

use crate::{
algorithms::{reverse::Reverse, sweep::Sweep},
objects::{Cycle, Face, HalfEdge, Objects},
objects::{Cycle, Face, HalfEdge, Objects, SurfaceVertex, Vertex},
partial::HasPartial,
storage::Handle,
};

#[test]
Expand All @@ -203,22 +204,46 @@ mod tests {
.with_surface(Some(surface.clone()))
.as_line_segment_from_points([[0., 0.], [1., 0.]])
.build(&objects);
let side_up = HalfEdge::partial()
.with_surface(Some(surface.clone()))
.with_back_vertex(Some(Vertex::partial().with_surface_form(
Some(bottom.front().surface_form().clone()),
)))
.with_front_vertex(Some(
Vertex::partial().with_surface_form(Some(
Handle::<SurfaceVertex>::partial()
.with_position(Some([1., 1.])),
)),
))
.as_line_segment()
.build(&objects);
let top = HalfEdge::partial()
.with_surface(Some(surface.clone()))
.as_line_segment_from_points([[0., 1.], [1., 1.]])
.with_back_vertex(Some(
Vertex::partial().with_surface_form(Some(
Handle::<SurfaceVertex>::partial()
.with_position(Some([0., 1.])),
)),
))
.with_front_vertex(Some(Vertex::partial().with_surface_form(
Some(side_up.front().surface_form().clone()),
)))
.as_line_segment()
.build(&objects)
.reverse();
let left = HalfEdge::partial()
let side_down = HalfEdge::partial()
.with_surface(Some(surface.clone()))
.as_line_segment_from_points([[0., 0.], [0., 1.]])
.with_back_vertex(Some(Vertex::partial().with_surface_form(
Some(bottom.back().surface_form().clone()),
)))
.with_front_vertex(Some(Vertex::partial().with_surface_form(
Some(top.front().surface_form().clone()),
)))
.as_line_segment()
.build(&objects)
.reverse();
let right = HalfEdge::partial()
.with_surface(Some(surface.clone()))
.as_line_segment_from_points([[1., 0.], [1., 1.]])
.build(&objects);

let cycle = Cycle::new(surface, [bottom, right, top, left]);
let cycle = Cycle::new(surface, [bottom, side_up, top, side_down]);

Face::from_exterior(cycle)
};
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-kernel/src/objects/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ impl Cycle {
let [next, _] = b.vertices();

assert_eq!(
prev.surface_form(),
next.surface_form(),
prev.surface_form().id(),
next.surface_form().id(),
"Edges in cycle do not connect"
);
}
Expand Down

0 comments on commit c4d866f

Please sign in to comment.