From a640b925cdd97a84e52c01a3b24b63d0dda1222c Mon Sep 17 00:00:00 2001 From: Sebastien Valette Date: Wed, 12 Feb 2025 09:37:25 +0100 Subject: [PATCH] early stop condition : only consider vertices in non-frozen clusters to compute modification ratio --- .../include/CGAL/Polygon_mesh_processing/acvd/acvd.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/acvd/acvd.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/acvd/acvd.h index b07d4f1f1a6..d5a963589be 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/acvd/acvd.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/acvd/acvd.h @@ -610,6 +610,7 @@ std::pair< // Turned on once nb_modifications < nb_vertices * CGAL_TO_QEM_MODIFICATION_THRESHOLD bool qem_energy_minimization = false; int nb_loops = 0; + int nb_vertices_to_consider_for_early_stop = nb_vertices; QEMClusterData cluster1_v1_to_c2, cluster2_v1_to_c2, cluster1_v2_to_c1, cluster2_v2_to_c1; std::vector frozen_clusters(nb_clusters, false); @@ -803,7 +804,7 @@ std::pair< std::cout << "# Modifications: " << nb_modifications << "\n"; clusters_edges_active.swap(clusters_edges_new); - if (use_qem_metric && nb_modifications < nb_vertices * CGAL_TO_QEM_MODIFICATION_THRESHOLD && nb_loops<2) + if (use_qem_metric && nb_modifications <= nb_vertices_to_consider_for_early_stop * CGAL_TO_QEM_MODIFICATION_THRESHOLD && nb_loops<2) { qem_energy_minimization = true; break; @@ -1186,9 +1187,12 @@ dump_mesh_with_cluster_colors(pmesh, vertex_cluster_pmap, "/tmp/cluster_"+std::t } //~ if (kkk==0) + nb_vertices_to_consider_for_early_stop = 0; frozen_clusters = std::vector(nb_clusters, true); - for (std::size_t nmi : nm_clusters) + for (std::size_t nmi : nm_clusters) { frozen_clusters[nmi]=false; + nb_vertices_to_consider_for_early_stop += clusters[ nmi ].nb_vertices; + } for (std::size_t nmi : one_ring) frozen_clusters[nmi]=false;