From 60d50a8b5726f70a79d1ce322b59c1baff2e8d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 4 Oct 2022 22:57:37 +0200 Subject: [PATCH] Fix not purging to-be-border halfedges from edges-to-collapse sets --- .../repair_degeneracies.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_degeneracies.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_degeneracies.h index e1fe165bc10..b238e5580cd 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_degeneracies.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_degeneracies.h @@ -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);