From 5af7b56589c1cff41e287caccd8d706c3545d962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 14 Mar 2018 10:22:24 +0100 Subject: [PATCH] expand the selection only by CC (instead of globally) --- .../CGAL/Polygon_mesh_processing/repair.h | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h index 1a2e8c98df7..5916d7cc2a0 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h @@ -1354,6 +1354,10 @@ remove_self_intersections_one_step(TriangleMesh& tm, bool verbose, NamedParameters np) { + if (verbose) + std::cout << "DEBUG: running remove_self_intersections_one_step, step " << step + << " with " << faces_to_remove.size() << " intersecting faces\n"; + CGAL_assertion(tm.is_valid()); typedef boost::graph_traits graph_traits; @@ -1370,17 +1374,12 @@ remove_self_intersections_one_step(TriangleMesh& tm, bool topology_issue = false; if (verbose) { - std::cout << "DEBUG: is_valid in one_step(tm)? "; + std::cout << " DEBUG: is_valid in one_step(tm)? "; std::cout.flush(); std::cout << is_valid(tm) << "\n"; } if(!faces_to_remove.empty()){ - // expand the region to be filled - if (step > 0) - expand_face_selection(faces_to_remove, tm, step, - make_boolean_property_map(faces_to_remove), - Emptyset_iterator()); while(!faces_to_remove.empty()) { @@ -1412,6 +1411,13 @@ remove_self_intersections_one_step(TriangleMesh& tm, h = next(h, tm); } } + + // expand the region to be filled + if (step > 0) + expand_face_selection(cc_faces, tm, step, + make_boolean_property_map(cc_faces), + Emptyset_iterator()); + // remove faces from the set to process BOOST_FOREACH(face_descriptor f, cc_faces) faces_to_remove.erase(f); @@ -1472,7 +1478,7 @@ remove_self_intersections_one_step(TriangleMesh& tm, } while(true); - if (border_hedges_invalid) + if (border_hedges_invalid || step > 0) { cc_border_hedges.clear(); BOOST_FOREACH(face_descriptor fd, cc_faces) @@ -1531,14 +1537,14 @@ remove_self_intersections_one_step(TriangleMesh& tm, if(nb_cycles > (only_border_edges ? 1 : 0) ) { if(verbose) - std::cout << "DEBUG: CC not handled due to the presence of " + std::cout << " DEBUG: CC not handled due to the presence of " << nb_cycles << " of boundary edges\n"; topology_issue = true; } else { if(verbose) - std::cout << "DEBUG: CC not handled because it is not a topological disk\n"; + std::cout << " DEBUG: CC not handled because it is not a topological disk\n"; all_fixed = false; } continue; @@ -1586,7 +1592,7 @@ remove_self_intersections_one_step(TriangleMesh& tm, if (verbose) { - std::cout << "DEBUG: is_valid(tm) in one_step, before mesh changes? "; + std::cout << " DEBUG: is_valid(tm) in one_step, before mesh changes? "; std::cout << is_valid(tm) << std::endl; } @@ -1716,27 +1722,27 @@ bool remove_self_intersections(TriangleMesh& tm, const NamedParameters& np, typedef boost::graph_traits graph_traits; typedef typename graph_traits::face_descriptor face_descriptor; + if (verbose) + std::cout << "DEBUG: Starting remove_self_intersections, is_valid(tm)? " << is_valid(tm) << "\n"; + // first handle the removal of degenerate faces remove_degenerate_faces(tm, np); + + if (verbose) + std::cout << "DEBUG: After degenerate faces removal, is_valid(tm)? " << is_valid(tm) << "\n"; + // Look for self-intersections in the polyhedron and remove them int step=-1; bool all_fixed = true; // indicates if the filling of all created holes went fine bool topology_issue = false; // indicates if some boundary cycles of edges are blocking the fixing while( ++step Face_pair; std::vector self_inter; // TODO : possible optimization to reduce the range to check with the bbox // of the previous patches or something. self_intersections(tm, std::back_inserter(self_inter)); - if (verbose) - std::cout << "DEBUG: is_valid(tm) after self_intersections? " - << is_valid(tm) << "\n"; - std::set faces_to_remove; BOOST_FOREACH(Face_pair fp, self_inter) { @@ -1744,13 +1750,9 @@ bool remove_self_intersections(TriangleMesh& tm, const NamedParameters& np, faces_to_remove.insert(fp.second); } - if (verbose) - std::cout << "DEBUG: Iterative self-intersection removal step " << step - << " - is_valid(tm) = " << is_valid(tm) << std::endl; - if ( faces_to_remove.empty() && all_fixed){ if (verbose) - std::cout<<"DEBUG: There is no more faces to remove."<