From 302a2707ea9b083993b06dd0e726780b76b2c736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 21 Mar 2022 07:11:41 +0100 Subject: [PATCH 1/5] use PMP functions (already dealing with Lazy calls) --- .../CGAL/Polygon_mesh_processing/repair.h | 34 ++++++------------- 1 file changed, 10 insertions(+), 24 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 46b3dbe9ae8..569b1a1fb6b 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -241,12 +242,7 @@ std::size_t remove_connected_components_of_negligible_size(TriangleMesh& tmesh, if(use_areas) { - for(face_descriptor f : faces(tmesh)) - { - const FT fa = face_area(f, tmesh, np); - component_areas[face_cc[f]] += fa; - total_area += fa; - } + total_area = area(tmesh); #ifdef CGAL_PMP_DEBUG_SMALL_CC_REMOVAL std::cout << "area threshold: " << area_threshold << std::endl; @@ -269,26 +265,16 @@ std::size_t remove_connected_components_of_negligible_size(TriangleMesh& tmesh, typename GT::Compute_volume_3 cv3 = traits.compute_volume_3_object(); Point_3 origin(0, 0, 0); - for(face_descriptor f : faces(tmesh)) - { - const std::size_t i = face_cc[f]; - if(!cc_closeness[i]) - continue; - - const FT fv = cv3(origin, - get(vpm, target(halfedge(f, tmesh), tmesh)), - get(vpm, target(next(halfedge(f, tmesh), tmesh), tmesh)), - get(vpm, target(prev(halfedge(f, tmesh), tmesh), tmesh))); - - component_volumes[i] += fv; - } - - // negative volume means the CC was oriented inward FT total_volume = 0; - for(std::size_t i=0; i fcc(tmesh); + for (std::size_t i=0; i Date: Mon, 21 Mar 2022 07:15:00 +0100 Subject: [PATCH 2/5] cc_volume should be positive --- .../include/CGAL/Polygon_mesh_processing/repair.h | 4 ++-- 1 file changed, 2 insertions(+), 2 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 569b1a1fb6b..40e51296aad 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h @@ -272,8 +272,8 @@ std::size_t remove_connected_components_of_negligible_size(TriangleMesh& tmesh, if (cc_closeness[i]) { fcc.set_selected_faces(i, face_cc); - component_volumes[i] = volume(fcc); - total_volume += CGAL::abs(component_volumes[i]); + component_volumes[i] = CGAL::abs(volume(fcc)); + total_volume += component_volumes[i]; } } From ff5ae14d8db54e4c08d1f86b8f77eb60b5b7b917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 21 Mar 2022 08:54:34 +0100 Subject: [PATCH 3/5] remove unused variables --- .../include/CGAL/Polygon_mesh_processing/repair.h | 3 --- 1 file changed, 3 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 40e51296aad..3b085644463 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h @@ -262,9 +262,6 @@ std::size_t remove_connected_components_of_negligible_size(TriangleMesh& tmesh, cc_closeness[face_cc[face(opposite(h, tmesh), tmesh)]] = false; } - typename GT::Compute_volume_3 cv3 = traits.compute_volume_3_object(); - Point_3 origin(0, 0, 0); - FT total_volume = 0; CGAL::Face_filtered_graph fcc(tmesh); for (std::size_t i=0; i Date: Mon, 21 Mar 2022 10:44:21 +0100 Subject: [PATCH 4/5] forgot about area per cc --- .../CGAL/Polygon_mesh_processing/repair.h | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 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 3b085644463..471fb50f901 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h @@ -236,24 +236,8 @@ std::size_t remove_connected_components_of_negligible_size(TriangleMesh& tmesh, if(!dry_run) CGAL::Polygon_mesh_processing::remove_isolated_vertices(tmesh); - // Compute CC-wide and total areas/volumes - FT total_area = 0; - std::vector component_areas(num, 0); - - if(use_areas) - { - total_area = area(tmesh); - -#ifdef CGAL_PMP_DEBUG_SMALL_CC_REMOVAL - std::cout << "area threshold: " << area_threshold << std::endl; - std::cout << "total area: " << total_area << std::endl; -#endif - } - // Volumes make no sense for CCs that are not closed std::vector cc_closeness(num, true); - std::vector component_volumes(num, FT(0)); - if(use_volumes) { for(halfedge_descriptor h : halfedges(tmesh)) @@ -261,24 +245,42 @@ std::size_t remove_connected_components_of_negligible_size(TriangleMesh& tmesh, if(is_border(h, tmesh)) cc_closeness[face_cc[face(opposite(h, tmesh), tmesh)]] = false; } + } - FT total_volume = 0; - CGAL::Face_filtered_graph fcc(tmesh); - for (std::size_t i=0; i component_areas(num, 0); + std::vector component_volumes(num, FT(0)); + + CGAL::Face_filtered_graph fcc(tmesh); + for (std::size_t i=0; i is_to_be_removed(num, false); From b56b36815fb818623fe549e27c7920e5ddca4c72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 21 Mar 2022 11:23:27 +0100 Subject: [PATCH 5/5] use initial version with additional calls to exact dealing with a custom mesh vpm in FFG is not simple + it is not optimal to traverse all the faces for each connected component --- .../CGAL/Polygon_mesh_processing/repair.h | 73 ++++++++++++------- 1 file changed, 46 insertions(+), 27 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 471fb50f901..641b368edb0 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h @@ -22,7 +22,6 @@ #include #include -#include #include #include @@ -236,8 +235,31 @@ std::size_t remove_connected_components_of_negligible_size(TriangleMesh& tmesh, if(!dry_run) CGAL::Polygon_mesh_processing::remove_isolated_vertices(tmesh); + // Compute CC-wide and total areas/volumes + FT total_area = 0; + std::vector component_areas(num, 0); + + if(use_areas) + { + for(face_descriptor f : faces(tmesh)) + { + const FT fa = face_area(f, tmesh, np); + component_areas[face_cc[f]] += fa; + exact(component_areas[face_cc[f]]); + total_area += fa; + exact(total_area); + } + +#ifdef CGAL_PMP_DEBUG_SMALL_CC_REMOVAL + std::cout << "area threshold: " << area_threshold << std::endl; + std::cout << "total area: " << total_area << std::endl; +#endif + } + // Volumes make no sense for CCs that are not closed std::vector cc_closeness(num, true); + std::vector component_volumes(num, FT(0)); + if(use_volumes) { for(halfedge_descriptor h : halfedges(tmesh)) @@ -245,42 +267,39 @@ std::size_t remove_connected_components_of_negligible_size(TriangleMesh& tmesh, if(is_border(h, tmesh)) cc_closeness[face_cc[face(opposite(h, tmesh), tmesh)]] = false; } - } - // Compute CC-wide and total areas/volumes - FT total_area = 0; - FT total_volume = 0; - std::vector component_areas(num, 0); - std::vector component_volumes(num, FT(0)); + typename GT::Compute_volume_3 cv3 = traits.compute_volume_3_object(); + Point_3 origin(0, 0, 0); - CGAL::Face_filtered_graph fcc(tmesh); - for (std::size_t i=0; i is_to_be_removed(num, false);