Skip to content

Commit

Permalink
Merge pull request #7970 from MaelRL/CGAL-Demo_bugs-GF
Browse files Browse the repository at this point in the history
Fix some demo bugs
  • Loading branch information
lrineau committed Jan 24, 2024
2 parents 2ff279b + af36083 commit a70e920
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Polyhedron/demo/Polyhedron/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) )
{
Expand Down
4 changes: 2 additions & 2 deletions Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -121,7 +121,7 @@ save(QFileInfo fileinfo,QList<CGAL::Three::Scene_item*>& items)
std::ofstream out(fileinfo.filePath().toUtf8());
out.precision (std::numeric_limits<double>::digits10 + 2);
SMesh* poly = const_cast<SMesh*>(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;

Expand Down
2 changes: 1 addition & 1 deletion Polyhedron/demo/Polyhedron/Plugins/IO/Nef_io_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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."));
Expand Down
2 changes: 1 addition & 1 deletion Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ load(QFileInfo fileinfo, bool& ok, bool add_to_scene){
return QList<Scene_item*>()<<item;
}

item->setName(fileinfo.baseName());
item->setName(fileinfo.completeBaseName());
ok = true;
if(add_to_scene)
CGAL::Three::Three::scene()->addItem(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Polyhedron/demo/Polyhedron/Plugins/IO/WKT_io_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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()))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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);
}
}
Expand Down
30 changes: 18 additions & 12 deletions Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -369,13 +368,16 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionSnapBorders_triggered()
template <typename Item>
void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveDegenerateFaces_triggered(Scene_interface::Item_id index)
{
Item* poly_item =
qobject_cast<Item*>(scene->item(index));
Item* poly_item = qobject_cast<Item*>(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());
CGAL::Polygon_mesh_processing::remove_degenerate_faces(*poly_item->polyhedron());
nbv -= faces(*poly_item->polyhedron()).size();
poly_item->invalidateOpenGLBuffers();
Q_EMIT poly_item->itemChanged();
Expand All @@ -395,10 +397,14 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveDegenerateFaces_tr
template <typename Item>
void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveSelfIntersections_triggered(Scene_interface::Item_id index)
{
Item* poly_item =
qobject_cast<Item*>(scene->item(index));
Item* poly_item = qobject_cast<Item*>(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));
Expand All @@ -420,10 +426,10 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveSelfIntersections_
template <typename Item>
void Polyhedron_demo_repair_polyhedron_plugin::on_actionAutorefine_triggered(Scene_interface::Item_id index)
{
Item* poly_item =
qobject_cast<Item*>(scene->item(index));
Item* poly_item = qobject_cast<Item*>(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());
}
Expand Down Expand Up @@ -519,10 +525,10 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionNewAutorefine_triggered(
template <typename Item>
void Polyhedron_demo_repair_polyhedron_plugin::on_actionAutorefineAndRMSelfIntersections_triggered(Scene_interface::Item_id index)
{
Item* poly_item =
qobject_cast<Item*>(scene->item(index));
Item* poly_item = qobject_cast<Item*>(scene->item(index));
if (poly_item)
{
CGAL::Polygon_mesh_processing::triangulate_faces(*poly_item->polyhedron());
try{
bool solved =
CGAL::Polygon_mesh_processing::experimental::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Polyhedron_demo_selection_plugin :
ok = false;
return QList<Scene_item*>();
}
item->setName(fileinfo.baseName());
item->setName(fileinfo.completeBaseName());
ok = true;
if(add_to_scene)
CGAL::Three::Three::scene()->addItem(item);
Expand Down
4 changes: 4 additions & 0 deletions Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit a70e920

Please sign in to comment.