Fix another bug in MeshBound
This commit is contained in:
parent
3e0f121240
commit
714e5793e6
21
src/main.rs
21
src/main.rs
@ -220,6 +220,7 @@ struct MeshBound<'a> {
|
|||||||
m: &'a Mesh,
|
m: &'a Mesh,
|
||||||
start: HalfEdgeID,
|
start: HalfEdgeID,
|
||||||
cur: HalfEdgeID,
|
cur: HalfEdgeID,
|
||||||
|
done: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> MeshBound<'a> {
|
impl<'a> MeshBound<'a> {
|
||||||
@ -230,6 +231,7 @@ impl<'a> MeshBound<'a> {
|
|||||||
m: m,
|
m: m,
|
||||||
start: halfedge_id,
|
start: halfedge_id,
|
||||||
cur: halfedge_id,
|
cur: halfedge_id,
|
||||||
|
done: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,22 +250,23 @@ impl<'a> Iterator for MeshBound<'a> {
|
|||||||
// Find the one that is a boundary.
|
// Find the one that is a boundary.
|
||||||
//
|
//
|
||||||
// Update 'cur' to this half-edge.
|
// Update 'cur' to this half-edge.
|
||||||
println!("DEBUG: start={} cur={}", self.start, self.cur);
|
|
||||||
|
if self.done {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
let (v1, v2) = self.m.edge_vertices(self.cur);
|
let (v1, v2) = self.m.edge_vertices(self.cur);
|
||||||
println!("DEBUG: v1={} v2={}", v1, v2);
|
|
||||||
// TODO: v1 or v2?
|
|
||||||
for halfedge_id in self.m.vertex_halfedge_iter(v1) {
|
for halfedge_id in self.m.vertex_halfedge_iter(v1) {
|
||||||
println!("DEBUG: try halfedge {}", halfedge_id);
|
let (v3, v4) = self.m.edge_vertices(halfedge_id);
|
||||||
|
if v3 == v2 || v4 == v2 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if self.m.is_edge_on_boundary(halfedge_id) {
|
if self.m.is_edge_on_boundary(halfedge_id) {
|
||||||
println!("DEBUG: is boundary");
|
|
||||||
if self.start == halfedge_id {
|
if self.start == halfedge_id {
|
||||||
println!("DEBUG: back to start");
|
|
||||||
// If we are walking the boundary and reach the
|
// If we are walking the boundary and reach the
|
||||||
// starting edge again, we're done:
|
// start edge again, this is the last iteration:
|
||||||
break;
|
self.done = true;
|
||||||
}
|
}
|
||||||
// Otherwise, yield the next edge:
|
|
||||||
self.cur = halfedge_id;
|
self.cur = halfedge_id;
|
||||||
return Some(halfedge_id);
|
return Some(halfedge_id);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user