warnings and TODOs

This commit is contained in:
Sébastien Loriot 2025-02-10 19:50:43 +01:00
parent 634df03161
commit 328230c40e
3 changed files with 18 additions and 23 deletions

View File

@ -97,8 +97,8 @@ public Q_SLOTS:
if (ui.IsotropicClustering->isChecked()) if (ui.IsotropicClustering->isChecked())
remeshed = PMP::acvd_isotropic_remeshing(*graph, ui.nb_clusters_spin_box->value()); remeshed = PMP::acvd_isotropic_remeshing(*graph, ui.nb_clusters_spin_box->value());
else if (ui.QEMClustering->isChecked()) else if (ui.QEMClustering->isChecked())
remeshed = PMP::acvd_isotropic_remeshing(*graph, ui.nb_clusters_spin_box->value(), CGAL::parameters::post_processing_qem(true)); // make it its own option once acvd_qem_remeshing works //remeshed = PMP::acvd_isotropic_remeshing(*graph, ui.nb_clusters_spin_box->value(), CGAL::parameters::post_processing_qem(true)); // make it its own option once acvd_qem_remeshing works
// remeshed = PMP::acvd_qem_remeshing(*graph, ui.nb_clusters_spin_box->value()); remeshed = PMP::acvd_qem_remeshing(*graph, ui.nb_clusters_spin_box->value());
else else
remeshed = PMP::acvd_isotropic_remeshing(*graph, ui.nb_clusters_spin_box->value(), CGAL::parameters::gradation_factor(0.8)); remeshed = PMP::acvd_isotropic_remeshing(*graph, ui.nb_clusters_spin_box->value(), CGAL::parameters::gradation_factor(0.8));

View File

@ -21,7 +21,7 @@ typedef boost::property_map<Surface_Mesh, CGAL::dynamic_vertex_property_t<CGAL::
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
Surface_Mesh smesh; Surface_Mesh smesh;
//CGAL::get_default_random() = CGAL::Random( 1739197120 ); //connexity constraint issue CGAL::get_default_random() = CGAL::Random( 1739197120 ); //connexity constraint issue
//CGAL::get_default_random() = CGAL::Random( 1739199762 ); //one small edge //CGAL::get_default_random() = CGAL::Random( 1739199762 ); //one small edge
std::cout << "Seed : " << CGAL::get_default_random().get_seed() << std::endl; std::cout << "Seed : " << CGAL::get_default_random().get_seed() << std::endl;
const std::string filename = (argc > 1) ? const std::string filename = (argc > 1) ?

View File

@ -41,7 +41,9 @@
#include <unordered_set> #include <unordered_set>
#include <iostream> #include <iostream>
#define CGAL_CLUSTERS_TO_VERTICES_THRESHOLD 0.1 #define CGAL_CLUSTERS_TO_VERTICES_THRESHOLD 0.1 // TODO add as a parameter: subdivide input until #cluster*threshold < num_vertices --> should be 0.01
// TODO also call split_long_edges: max edge length shall not be larger than 3 * input mean edge length -l3
// cheese crashes
#define CGAL_TO_QEM_MODIFICATION_THRESHOLD 1e-3 #define CGAL_TO_QEM_MODIFICATION_THRESHOLD 1e-3
#define CGAL_WEIGHT_CLAMP_RATIO_THRESHOLD 10000 #define CGAL_WEIGHT_CLAMP_RATIO_THRESHOLD 10000
@ -183,17 +185,14 @@ struct QEMClusterData {
typename GT::Vector_3 representative_point; typename GT::Vector_3 representative_point;
typename GT::FT energy; typename GT::FT energy;
bool modified = true; bool modified = true;
int last_modification_iteration; int last_modification_iteration = 0;
size_t nb_vertices = 0;
size_t nb_vertices;
QEMClusterData() : QEMClusterData() :
site_sum(0, 0, 0), site_sum(0, 0, 0),
weight_sum(0), weight_sum(0),
representative_point(0, 0, 0), representative_point(0, 0, 0),
energy(0), energy(0)
nb_vertices(0),
last_modification_iteration(0)
{ {
quadric_sum.setZero(); quadric_sum.setZero();
} }
@ -481,13 +480,14 @@ std::pair<
} }
// randomly initialize clusters // randomly initialize clusters
//TODO: std::lower_bound with vertex_weight_pmap
for (int ci = 0; ci < nb_clusters; ci++) for (int ci = 0; ci < nb_clusters; ci++)
{ {
int vi; int vi;
Vertex_descriptor vd; Vertex_descriptor vd;
do { do {
vi = CGAL::get_default_random().get_int(0, num_vertices(pmesh)); vi = CGAL::get_default_random().get_int(0, num_vertices(pmesh));
vd = *(vertices(pmesh).begin() + vi); vd = *(vertices(pmesh).begin() + vi); // TODO: bad with Polyhedron
} while (get(vertex_cluster_pmap, vd) != -1); } while (get(vertex_cluster_pmap, vd) != -1);
put(vertex_cluster_pmap, vd, ci); put(vertex_cluster_pmap, vd, ci);
@ -1040,14 +1040,13 @@ std::pair<
// the energy minimization loop (clustering loop) // the energy minimization loop (clustering loop)
int nb_modifications = 0; int nb_modifications = 0;
int nb_disconnected = 0; int nb_disconnected = 0;
int nb_qem_iters = 0;
// Turned on once nb_modifications < nb_vertices * CGAL_TO_QEM_MODIFICATION_THRESHOLD // Turned on once nb_modifications < nb_vertices * CGAL_TO_QEM_MODIFICATION_THRESHOLD
bool qem_energy_minimization = false; bool qem_energy_minimization = false;
int nb_loops = 0; int nb_loops = 0;
QEMClusterData<GT> cluster1_v1_to_c2, cluster2_v1_to_c2, cluster1_v2_to_c1, cluster2_v2_to_c1; QEMClusterData<GT> cluster1_v1_to_c2, cluster2_v1_to_c2, cluster1_v2_to_c1, cluster2_v2_to_c1;
// bool just_switched_to_qem = false;
do do
{ {
@ -1125,7 +1124,8 @@ std::pair<
{ {
// topological test to avoid creating disconnected clusters // topological test to avoid creating disconnected clusters
auto is_topologically_valid_merge = [&](Halfedge_descriptor hv, int cluster_id) auto is_topologically_valid_merge = [&](Halfedge_descriptor hv, int cluster_id)
{return true; {
return true;
// TODO : solve bug, test seems to be too strict! // TODO : solve bug, test seems to be too strict!
CGAL_assertion(get(vertex_cluster_pmap,target(hv, pmesh))==cluster_id); CGAL_assertion(get(vertex_cluster_pmap,target(hv, pmesh))==cluster_id);
Halfedge_descriptor h=hv; Halfedge_descriptor h=hv;
@ -1146,6 +1146,7 @@ std::pair<
in_cluster=true; in_cluster=true;
if (++nb_cc_cluster>1) { if (++nb_cc_cluster>1) {
std::cout << "\n no for " << pmesh.point( target( hv, pmesh ) ) << std::endl; std::cout << "\n no for " << pmesh.point( target( hv, pmesh ) ) << std::endl;
// throw std::runtime_error("BOOM!\n");
return false; return false;
} }
} }
@ -1181,8 +1182,8 @@ std::pair<
cluster2_v1_to_c2.last_modification_iteration = nb_iterations; cluster2_v1_to_c2.last_modification_iteration = nb_iterations;
typename GT::FT e_no_change = clusters[c1].compute_energy() + clusters[c2].compute_energy(); typename GT::FT e_no_change = clusters[c1].compute_energy() + clusters[c2].compute_energy();
typename GT::FT e_v1_to_c2 = std::numeric_limits< double >::max(); typename GT::FT e_v1_to_c2 = (std::numeric_limits< double >::max)();
typename GT::FT e_v2_to_c1 = std::numeric_limits< double >::max(); typename GT::FT e_v2_to_c1 = (std::numeric_limits< double >::max)();
if ( ( clusters[ c1 ].nb_vertices > 1 ) && ( !qem_energy_minimization || is_topologically_valid_merge(opposite(hi, pmesh), c1) ) ){ if ( ( clusters[ c1 ].nb_vertices > 1 ) && ( !qem_energy_minimization || is_topologically_valid_merge(opposite(hi, pmesh), c1) ) ){
@ -1245,20 +1246,14 @@ std::pair<
} }
std::cout << "# Modifications: " << nb_modifications << "\n"; std::cout << "# Modifications: " << nb_modifications << "\n";
//if(qem_energy_minimization)
// just_switched_to_qem = false;
// if (nb_qem_iters == 10)
// break;
clusters_edges_active.swap(clusters_edges_new); clusters_edges_active.swap(clusters_edges_new);
if (nb_modifications < nb_vertices * CGAL_TO_QEM_MODIFICATION_THRESHOLD) if (nb_modifications < nb_vertices * CGAL_TO_QEM_MODIFICATION_THRESHOLD)
{ {
qem_energy_minimization = true; qem_energy_minimization = true;
// just_switched_to_qem = true;
break; break;
} }
} while (nb_modifications > 0 /*&& !just_switched_to_qem*/); } while (nb_modifications > 0);
// Disconnected clusters handling // Disconnected clusters handling
// the goal is to delete clusters with multiple connected components and only keep the largest connected component of each cluster // the goal is to delete clusters with multiple connected components and only keep the largest connected component of each cluster