From a0638f6e0a9c23f209ff9e5210c81ab12670d8ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 10 Jan 2024 11:18:50 +0100 Subject: [PATCH 1/4] Use file's completeBaseName for item names --- .../Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp | 4 ++-- .../demo/Polyhedron/Plugins/IO/Nef_io_plugin.cpp | 2 +- .../demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp | 2 +- .../Plugins/IO/OFF_to_nef_io_plugin.cpp | 2 +- .../Plugins/IO/Polylines_io_plugin.cpp | 2 +- .../demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp | 16 ++++++++-------- .../demo/Polyhedron/Plugins/IO/WKT_io_plugin.cpp | 2 +- .../Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp | 6 +++--- .../Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp | 2 +- .../Plugins/Mesh_3/Io_image_plugin.cpp | 8 ++++---- .../Polyhedron/Plugins/PMP/Selection_plugin.cpp | 2 +- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp index feeef33572e7..36233827a32a 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp @@ -85,7 +85,7 @@ Polyhedron_demo_gocad_plugin::load(QFileInfo fileinfo, bool& ok, bool add_to_sce t.stop(); std::cerr << "Reading took " << t.time() << " sec." << std::endl; if(name_and_color.first.size() == 0){ - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); } else { item->setName(name_and_color.first.c_str()); } @@ -121,7 +121,7 @@ save(QFileInfo fileinfo,QList& items) std::ofstream out(fileinfo.filePath().toUtf8()); out.precision (std::numeric_limits::digits10 + 2); SMesh* poly = const_cast(sm_item->polyhedron()); - CGAL::IO::write_GOCAD(out, qPrintable(fileinfo.baseName()), *poly); + CGAL::IO::write_GOCAD(out, qPrintable(fileinfo.completeBaseName()), *poly); items.pop_front(); return true; diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Nef_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Nef_io_plugin.cpp index ed9658065f70..25b5c1d7432b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Nef_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Nef_io_plugin.cpp @@ -57,7 +57,7 @@ load(QFileInfo fileinfo, bool& ok, bool add_to_scene) { // Try to read .nef3 in a polyhedron Scene_nef_polyhedron_item* item = new Scene_nef_polyhedron_item(); - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); if(fileinfo.size() == 0) { CGAL::Three::Three::warning( tr("The file you are trying to load is empty.")); diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp index e7de52da567b..c413104e883b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp @@ -215,7 +215,7 @@ Polyhedron_demo_off_plugin::load_obj(QFileInfo fileinfo) { return nullptr; } Scene_surface_mesh_item* item = new Scene_surface_mesh_item(); - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); if(item->load_obj(in)) return item; //if not polygonmesh load in soup diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp index 0f04fcd2dbf5..9e6cfd399ee4 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp @@ -50,7 +50,7 @@ load(QFileInfo fileinfo, bool& ok, bool add_to_scene){ return QList()<setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); ok = true; if(add_to_scene) CGAL::Three::Three::scene()->addItem(item); diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp index 3573ec548f3c..75503490a2a9 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp @@ -201,7 +201,7 @@ load(QFileInfo fileinfo, bool& ok, bool add_to_scene){ } Scene_polylines_item* item = new Scene_polylines_item; item->polylines = polylines; - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); item->setColor(Qt::black); item->setProperty("polylines metadata", polylines_metadata); std::cerr << "Number of polylines in item: " << item->polylines.size() << std::endl; diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp index bf3f4bf54e9f..ca824a3e9ee9 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp @@ -348,7 +348,7 @@ class Polyhedron_demo_vtk_plugin : || (is_polygon_mesh && is_polyline) || (is_c3t3 && is_polyline) ) { - group = new Scene_group_item(fileinfo.baseName()); + group = new Scene_group_item(fileinfo.completeBaseName()); } if(is_polygon_mesh) @@ -372,12 +372,12 @@ class Polyhedron_demo_vtk_plugin : if(poly_item) { if(group) { - poly_item->setName(QString("%1_faces").arg(fileinfo.baseName())); + poly_item->setName(QString("%1_faces").arg(fileinfo.completeBaseName())); CGAL::Three::Three::scene()->addItem(poly_item); CGAL::Three::Three::scene()->changeGroup(poly_item, group); } else{ - poly_item->setName(fileinfo.baseName()); + poly_item->setName(fileinfo.completeBaseName()); ok = true; if(add_to_scene) CGAL::Three::Three::scene()->addItem(poly_item); @@ -484,12 +484,12 @@ class Polyhedron_demo_vtk_plugin : c3t3_item->resetCutPlane(); if(group) { - c3t3_item->setName(QString("%1_tetrahedra").arg(fileinfo.baseName())); + c3t3_item->setName(QString("%1_tetrahedra").arg(fileinfo.completeBaseName())); CGAL::Three::Three::scene()->addItem(c3t3_item); CGAL::Three::Three::scene()->changeGroup(c3t3_item, group); } else{ - c3t3_item->setName(fileinfo.baseName()); + c3t3_item->setName(fileinfo.completeBaseName()); ok = true; if(add_to_scene) CGAL::Three::Three::scene()->addItem(c3t3_item); @@ -506,12 +506,12 @@ class Polyhedron_demo_vtk_plugin : polyline_item->polylines.push_back(segment); if(group) { - polyline_item->setName(QString("%1_lines").arg(fileinfo.baseName())); + polyline_item->setName(QString("%1_lines").arg(fileinfo.completeBaseName())); CGAL::Three::Three::scene()->addItem(polyline_item); CGAL::Three::Three::scene()->changeGroup(polyline_item, group); } else{ - polyline_item->setName(fileinfo.baseName()); + polyline_item->setName(fileinfo.completeBaseName()); ok = true; if(add_to_scene) CGAL::Three::Three::scene()->addItem(polyline_item); @@ -537,7 +537,7 @@ class Polyhedron_demo_vtk_plugin : double* p = data->GetPoint(i); point_item->point_set()->insert(Point_3(p[0], p[1], p[2])); } - point_item->setName(fileinfo.baseName()); + point_item->setName(fileinfo.completeBaseName()); ok = true; if(add_to_scene) CGAL::Three::Three::scene()->addItem(point_item); diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/WKT_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/WKT_io_plugin.cpp index 9dbd44d2abe3..8810d81942a4 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/WKT_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/WKT_io_plugin.cpp @@ -64,7 +64,7 @@ load(QFileInfo fileinfo, bool& ok, bool add_to_scene) { Scene_polylines_item* item = new Scene_polylines_item; item->polylines = polylines; - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); item->setColor(Qt::black); std::cerr << "Number of polylines in item: " << item->polylines.size() << std::endl; item->invalidateOpenGLBuffers(); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp index 4cadd392fd38..536545443d48 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp @@ -96,7 +96,7 @@ Polyhedron_demo_c3t3_binary_io_plugin::load( } if(fileinfo.suffix().toLower() == "cgal") { - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); if(item->load_binary(in)) { if(add_to_scene){ @@ -134,7 +134,7 @@ Polyhedron_demo_c3t3_binary_io_plugin::load( in.open(fileinfo.filePath().toUtf8(), std::ios_base::in);//not binary CGAL_assertion(!(!in)); - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); item->set_valid(false); if(CGAL::SMDS_3::build_triangulation_from_file(in, item->c3t3().triangulation(), @@ -165,7 +165,7 @@ Polyhedron_demo_c3t3_binary_io_plugin::load( CGAL_assertion(!(!in)); } - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); if (CGAL::IO::read_AVIZO_TETRA(in, item->c3t3().triangulation())) { diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp index 795f6a247f93..8fbe68dfc4ea 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp @@ -387,7 +387,7 @@ save(const Scene_c3t3_item& c3t3_item, const QFileInfo& fileInfo) rib_file.precision(8); // Header - QString basename = fileInfo.baseName(); + QString basename = fileInfo.completeBaseName(); write_header(qPrintable(basename), rib_file); // Lights diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp index fd99361c2902..317e15e7dc78 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp @@ -1356,7 +1356,7 @@ Io_image_plugin::load(QFileInfo fileinfo, bool& ok, bool add_to_scene) { //Create planes image_item = new Scene_image_item(image,0, true); - image_item->setName(fileinfo.baseName()); + image_item->setName(fileinfo.completeBaseName()); msgBox.setText("Planes created : 0/3"); msgBox.setStandardButtons(QMessageBox::NoButton); msgBox.show(); @@ -1367,7 +1367,7 @@ Io_image_plugin::load(QFileInfo fileinfo, bool& ok, bool add_to_scene) { image_item = new Scene_image_item(image,voxel_scale, false); } - image_item->setName(fileinfo.baseName()); + image_item->setName(fileinfo.completeBaseName()); if(add_to_scene) CGAL::Three::Three::scene()->addItem(image_item); @@ -1456,7 +1456,7 @@ bool Io_image_plugin::loadDirectory(const QString& dirname, { // Create planes image_item = new Scene_image_item(image,125, true); - image_item->setName(fileinfo.baseName()); + image_item->setName(fileinfo.completeBaseName()); msgBox.setText("Planes created : 0/3"); msgBox.setStandardButtons(QMessageBox::NoButton); msgBox.show(); @@ -1470,7 +1470,7 @@ bool Io_image_plugin::loadDirectory(const QString& dirname, int voxel_scale = ui.precisionList->currentIndex() + 1; image_item = new Scene_image_item(image,voxel_scale, false); - image_item->setName(fileinfo.baseName()); + image_item->setName(fileinfo.completeBaseName()); scene->addItem(image_item); } } diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp index b1ffae6e97bd..2c50e614ac01 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp @@ -111,7 +111,7 @@ class Polyhedron_demo_selection_plugin : ok = false; return QList(); } - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); ok = true; if(add_to_scene) CGAL::Three::Three::scene()->addItem(item); From 83fd1fe2b34bcbe6a69437e6d4748412f24889a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 10 Jan 2024 11:19:12 +0100 Subject: [PATCH 2/4] Disable the area smoothing box if Ceres is not available --- Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.cpp index 212f2cc60ef7..70747cdddc9f 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.cpp @@ -107,6 +107,10 @@ class Polyhedron_demo_smothing_plugin ui_widget.projection_checkBox->setChecked(true); ui_widget.area_smoothing_checkBox->setChecked(false); +#ifndef CGAL_PMP_USE_CERES_SOLVER + ui_widget.area_smoothing_checkBox->setDisabled(true); +#endif + ui_widget.flip_checkBox->setChecked(true); ui_widget.flip_checkBox->setDisabled(true); } From 53567bd20a3b3f0231f5841861b462b7644cd112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 10 Jan 2024 11:19:43 +0100 Subject: [PATCH 3/4] Handle non triangulated inputs in the repair plugin --- .../Plugins/PMP/Repair_polyhedron_plugin.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp index b0ac1f859965..6a6d43c08f2a 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp @@ -373,6 +373,11 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveDegenerateFaces_tr qobject_cast(scene->item(index)); if (poly_item) { + if(! CGAL::is_triangle_mesh(*poly_item->polyhedron())) { + CGAL::Three::Three::error(QString("The mesh must have triangle faces")); + return; + } + std::size_t nbv = faces(*poly_item->polyhedron()).size(); CGAL::Polygon_mesh_processing::remove_degenerate_faces( *poly_item->polyhedron()); @@ -399,6 +404,11 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveSelfIntersections_ qobject_cast(scene->item(index)); if (poly_item) { + if(! CGAL::is_triangle_mesh(*poly_item->polyhedron())) { + CGAL::Three::Three::error(QString("The mesh must have triangle faces")); + return; + } + bool solved = CGAL::Polygon_mesh_processing::experimental::remove_self_intersections( *poly_item->polyhedron(), CGAL::parameters::preserve_genus(false)); @@ -424,6 +434,7 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionAutorefine_triggered(Sce qobject_cast(scene->item(index)); if (poly_item) { + CGAL::Polygon_mesh_processing::triangulate_faces(*poly_item->polyhedron()); try{ CGAL::Polygon_mesh_processing::experimental::autorefine(*poly_item->polyhedron()); } @@ -523,6 +534,7 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionAutorefineAndRMSelfInter qobject_cast(scene->item(index)); if (poly_item) { + CGAL::Polygon_mesh_processing::triangulate_faces(*poly_item->polyhedron()); try{ bool solved = CGAL::Polygon_mesh_processing::experimental:: From af3608335b8e1f3f88b3150a0616fdac8ca0ba71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 10 Jan 2024 11:20:29 +0100 Subject: [PATCH 4/4] Misc indentation fixes --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 2 +- .../Plugins/PMP/Repair_polyhedron_plugin.cpp | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 1f92d97129fc..f85d0355570a 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -1102,7 +1102,7 @@ void MainWindow::open(QString filename) if ( dfs_it==default_plugin_selection.end() ) { // collect all io_plugins and offer them to load if the file extension match one name filter - // also collect all available plugin in case of a no extension match + // also collect all available plugins in case of a no extension match for(CGAL::Three::Polyhedron_demo_io_plugin_interface* io_plugin : io_plugins) { if ( file_matches_filter(io_plugin->loadNameFilters(), filename.toLower()) ) { diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp index 6a6d43c08f2a..5d87af53f59e 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp @@ -182,8 +182,7 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveIsolatedVertices_t if (poly_item) { std::size_t nbv = - CGAL::Polygon_mesh_processing::remove_isolated_vertices( - *poly_item->polyhedron()); + CGAL::Polygon_mesh_processing::remove_isolated_vertices(*poly_item->polyhedron()); CGAL::Three::Three::information(tr(" %1 isolated vertices have been removed.") .arg(nbv)); poly_item->setNbIsolatedvertices(0); @@ -369,8 +368,7 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionSnapBorders_triggered() template void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveDegenerateFaces_triggered(Scene_interface::Item_id index) { - Item* poly_item = - qobject_cast(scene->item(index)); + Item* poly_item = qobject_cast(scene->item(index)); if (poly_item) { if(! CGAL::is_triangle_mesh(*poly_item->polyhedron())) { @@ -379,8 +377,7 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveDegenerateFaces_tr } std::size_t nbv = faces(*poly_item->polyhedron()).size(); - CGAL::Polygon_mesh_processing::remove_degenerate_faces( - *poly_item->polyhedron()); + CGAL::Polygon_mesh_processing::remove_degenerate_faces(*poly_item->polyhedron()); nbv -= faces(*poly_item->polyhedron()).size(); poly_item->invalidateOpenGLBuffers(); Q_EMIT poly_item->itemChanged(); @@ -400,8 +397,7 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveDegenerateFaces_tr template void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveSelfIntersections_triggered(Scene_interface::Item_id index) { - Item* poly_item = - qobject_cast(scene->item(index)); + Item* poly_item = qobject_cast(scene->item(index)); if (poly_item) { if(! CGAL::is_triangle_mesh(*poly_item->polyhedron())) { @@ -430,8 +426,7 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveSelfIntersections_ template void Polyhedron_demo_repair_polyhedron_plugin::on_actionAutorefine_triggered(Scene_interface::Item_id index) { - Item* poly_item = - qobject_cast(scene->item(index)); + Item* poly_item = qobject_cast(scene->item(index)); if (poly_item) { CGAL::Polygon_mesh_processing::triangulate_faces(*poly_item->polyhedron()); @@ -530,8 +525,7 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionNewAutorefine_triggered( template void Polyhedron_demo_repair_polyhedron_plugin::on_actionAutorefineAndRMSelfIntersections_triggered(Scene_interface::Item_id index) { - Item* poly_item = - qobject_cast(scene->item(index)); + Item* poly_item = qobject_cast(scene->item(index)); if (poly_item) { CGAL::Polygon_mesh_processing::triangulate_faces(*poly_item->polyhedron());