Fix not purging to-be-border halfedges from edges-to-collapse sets

This commit is contained in:
Mael Rouxel-Labbé 2022-10-04 22:57:37 +02:00
parent 207a1e896b
commit 60d50a8b57
1 changed files with 14 additions and 2 deletions

View File

@ -710,9 +710,11 @@ bool remove_almost_degenerate_faces(const FaceRange& face_range,
edges_to_collapse.erase(h);
next_edges_to_collapse.erase(h);
halfedge_descriptor rm_h = prev(h, tmesh);
// By default, prev(h) is removed. If prev(h) is constrained, then next(h) is removed.
// Both cannot be constrained, otherwise we would not be collapsing `h`.
halfedge_descriptor rm_h = prev(h, tmesh), ot_h = next(h, tmesh);
if(get(ecm, edge(rm_h, tmesh)))
rm_h = next(h, tmesh);
std::swap(rm_h, ot_h);
edges_to_flip.erase(rm_h);
edges_to_collapse.erase(rm_h);
@ -722,6 +724,16 @@ bool remove_almost_degenerate_faces(const FaceRange& face_range,
edges_to_flip.erase(opp_rm_h);
edges_to_collapse.erase(opp_rm_h);
next_edges_to_collapse.erase(opp_rm_h);
// If the third (i.e., non-removed) halfedge of the face becomes a border halfedge
// with the collapse, then it also needs to be removed.
// Pre-collapse, the corresponding halfedge is `opp_rm_h`.
if(is_border(opp_rm_h, tmesh))
{
edges_to_flip.erase(ot_h);
edges_to_collapse.erase(ot_h);
next_edges_to_collapse.erase(ot_h);
}
}
h = opposite(h, tmesh);