From e96bb84077c65a273c1eff2a7572ec3409423848 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 7 Feb 2019 16:25:20 +0100 Subject: [PATCH 01/18] Update ramp when button Min/Max button is clicked. --- .../demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index 8e8cc92994c..9f1ddd3bd2a 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -387,6 +387,7 @@ public: QPalette palette(minColor); dock_widget->minColorButton->setPalette(palette); dock_widget->minColorButton->update(); + replaceRamp(); }); connect(dock_widget->maxColorButton, &QPushButton::pressed, this, [this]() @@ -401,6 +402,7 @@ public: dock_widget->maxColorButton->setPalette(palette); dock_widget->maxColorButton->update(); + replaceRamp(); }); connect(dock_widget->sourcePointsButton, SIGNAL(toggled(bool)), From 852283d38a6f43e76bb95623b459c72436cd4413 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 7 Feb 2019 16:47:41 +0100 Subject: [PATCH 02/18] Fix the way the items are selected for the statistics table. --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index ebb3182ed2a..ee2414849d6 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -2433,7 +2433,7 @@ QString MainWindow::get_item_stats() { //1st step : get all classnames of the selected items QList classnames; - Q_FOREACH(int id, getSelectedSceneItemIndices()) + Q_FOREACH(int id, scene->selectionIndices()) { QString classname = scene->item(id)->metaObject()->className(); if(!classnames.contains(classname)) @@ -2442,7 +2442,7 @@ QString MainWindow::get_item_stats() //2nd step : separate the selection in lists corresponding to their classname QVector< QList > items; items.resize(classnames.size()); - Q_FOREACH(int id, getSelectedSceneItemIndices()) + Q_FOREACH(int id, scene->selectionIndices()) { Scene_item* s_item = scene->item(id); for(int i=0; i Date: Fri, 8 Feb 2019 10:26:52 +0100 Subject: [PATCH 03/18] Allow resetColors also for vcolors. --- .../Polyhedron/Plugins/Display/Display_property_plugin.cpp | 2 -- Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index 9f1ddd3bd2a..38a770b2118 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -469,7 +469,6 @@ private Q_SLOTS: replaceRamp(); item->face_graph()->collect_garbage(); - item->face_graph()->collect_garbage(); switch(dock_widget->propertyBox->currentIndex()){ case 0: displayAngles(item); @@ -834,7 +833,6 @@ private Q_SLOTS: ); } - // AF: So far we only deal with adding sources BOOST_FOREACH(vertex_descriptor vd, vertices(mesh)){ if(is_source[vd]){ if(iDT){ diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp index bc44f100eff..b873f1e9c91 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp @@ -1429,18 +1429,18 @@ void Scene_surface_mesh_item::setItemIsMulticolor(bool b) void Scene_surface_mesh_item::show_feature_edges(bool b) { + d->has_feature_edges = b; if(b) { d->e_is_feature_map = d->smesh_->add_property_map::edge_descriptor,bool>("e:is_feature").first; invalidate(COLORS); itemChanged(); } - d->has_feature_edges = b; } bool Scene_surface_mesh_item::isItemMulticolor() { - return d->has_fcolors; + return d->has_fcolors || d->has_vcolors; } bool Scene_surface_mesh_item::hasPatchIds() From e3f615bc2a32d349aaa93654bca5af95de974d56 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 8 Feb 2019 11:48:18 +0100 Subject: [PATCH 04/18] Add an action specifically for the heat method. --- .../Plugins/Display/Display_property_plugin.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index 38a770b2118..1e4e728f832 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -338,6 +338,8 @@ public: this->current_item = NULL; QAction *actionDisplayAngles= new QAction(QString("Display Properties"), mw); + QAction *actionHeatMethod= new QAction(QString("Heat Method"), mw); + actionHeatMethod->setProperty("submenuName", "Color"); rm = 1.0; rM = 0.0; @@ -350,7 +352,16 @@ public: if(actionDisplayAngles) { connect(actionDisplayAngles, SIGNAL(triggered()), this, SLOT(openDialog())); + if(actionHeatMethod) + { + connect(actionHeatMethod, &QAction::triggered, + this, [this](){ + this->dock_widget->propertyBox->setCurrentIndex(2); + this->dock_widget->show(); + }); + } _actions << actionDisplayAngles; + _actions << actionHeatMethod; } dock_widget = new DockWidget("Property Displaying", mw); From 4a6dc5bfd63e920e53ebb260c31f6c99db146cf6 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 8 Feb 2019 12:03:32 +0100 Subject: [PATCH 05/18] Fix lasso for 0 facet --- .../Plugins/PMP/Scene_facegraph_item_k_ring_selection.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Scene_facegraph_item_k_ring_selection.h b/Polyhedron/demo/Polyhedron/Plugins/PMP/Scene_facegraph_item_k_ring_selection.h index 86747634b0f..36a50aa4cc6 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Scene_facegraph_item_k_ring_selection.h +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Scene_facegraph_item_k_ring_selection.h @@ -235,6 +235,7 @@ public Q_SLOTS: if(face_sel.empty()) { contour_2d.clear(); + qobject_cast(viewer)->set2DSelectionMode(false); return; } //get border edges of the selected patches From 13d673915b8dd8db39040fe0f5342ce848c642e1 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 8 Feb 2019 12:44:21 +0100 Subject: [PATCH 06/18] Don't count twice the extremity of a closed polyline. --- Polyhedron/demo/Polyhedron/Scene_polylines_item.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Scene_polylines_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polylines_item.cpp index fcc1e85634b..362254cf8b2 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polylines_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polylines_item.cpp @@ -116,11 +116,15 @@ Scene_polylines_item_private::computeElements() const it != item->polylines.end(); ++it) { - if(it->empty()) continue; + if(it->empty()) continue; + if(it->front() == it->back()) + nb_vertices += it->size() - 1; + else nb_vertices += it->size(); - for(size_t i = 0, end = it->size()-1; - i < end; ++i) - { + + for(size_t i = 0, end = it->size()-1; + i < end; ++i) + { const Point_3& a = (*it)[i]; const Point_3& b = (*it)[i+1]; if(a!=b) From c86362ac8613483ad12509429643b74503248627 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 8 Feb 2019 12:51:54 +0100 Subject: [PATCH 07/18] fix stats labels --- Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp index b873f1e9c91..3043d169ddd 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp @@ -1709,7 +1709,7 @@ CGAL::Three::Scene_item::Header_data Scene_surface_mesh_item::header() const data.titles.append(QString("#Border Edges")); data.titles.append(QString("Pure Triangle")); data.titles.append(QString("Pure Quad")); - data.titles.append(QString("#Degenerated Faces")); + data.titles.append(QString("#Degenerate Faces")); data.titles.append(QString("Connected Components of the Boundary")); data.titles.append(QString("Area")); data.titles.append(QString("Volume")); @@ -1729,7 +1729,7 @@ CGAL::Three::Scene_item::Header_data Scene_surface_mesh_item::header() const data.titles.append(QString("Maximum Length")); data.titles.append(QString("Median Length")); data.titles.append(QString("Mean Length")); - data.titles.append(QString("#Null Length")); + data.titles.append(QString("#Degenerate Edges")); data.titles.append(QString("Minimum")); data.titles.append(QString("Maximum")); data.titles.append(QString("Average")); From 82fc6cf6983a3c4c8e4bad1e53a97d8b098c0fba Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 8 Feb 2019 13:12:17 +0100 Subject: [PATCH 08/18] Offset_meshing produces outward oriented meshes. --- .../Plugins/Surface_mesh/Offset_meshing_plugin.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Offset_meshing_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Offset_meshing_plugin.cpp index 4c196105039..3b87f795b6d 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Offset_meshing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Offset_meshing_plugin.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -297,7 +298,13 @@ CGAL::Three::Scene_item* cgal_off_meshing(QWidget*, // add remesh as new polyhedron Result_mesh *pRemesh = new Result_mesh; CGAL::facets_in_complex_3_to_triangle_mesh(c3t3, *pRemesh); - return make_item(pRemesh); + if(CGAL::is_closed(*pRemesh) + && ! CGAL::Polygon_mesh_processing::is_outward_oriented(*pRemesh)) + { + CGAL::Polygon_mesh_processing::reverse_face_orientations(*pRemesh); + } + + return make_item(pRemesh); } else return 0; @@ -436,6 +443,7 @@ if(sm_item) .arg(offset_value)); new_item->setColor(Qt::magenta); new_item->setRenderingMode(item->renderingMode()); + scene->addItem(new_item); item->setVisible(false); scene->itemChanged(index); From aad63b61ff9c31b4b92020c1d7322a4b8aafca68 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 8 Feb 2019 13:14:36 +0100 Subject: [PATCH 09/18] Remove "as Surface_mesh" --- Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp | 2 +- Polyhedron/demo/Polyhedron/Plugins/PMP/Orient_soup_plugin.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp index ecf2f4bc889..1225b7d7475 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp @@ -672,7 +672,7 @@ treat_result(Scene_item& source_item, { Scene_surface_mesh_item* new_item = new Scene_surface_mesh_item; CGAL::facets_in_complex_3_to_triangle_mesh(result_item->c3t3(), *new_item->face_graph()); - new_item->setName(tr("%1 [Remeshed as Surface_mesh]").arg(source_item.name())); + new_item->setName(tr("%1 [Remeshed]").arg(source_item.name())); Q_FOREACH(int ind, scene->selectionIndices()) { scene->item(ind)->setVisible(false); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Orient_soup_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Orient_soup_plugin.cpp index 1ae9edc3f74..0ef8e67a5f3 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Orient_soup_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Orient_soup_plugin.cpp @@ -74,7 +74,7 @@ void Polyhedron_demo_orient_soup_plugin::init(QMainWindow* mainWindow, scene = scene_interface; mw = mainWindow; messages = m; - actionOrientSM = new QAction(tr("&Orient Polygon Soup (as a surface_mesh)"), mainWindow); + actionOrientSM = new QAction(tr("&Orient Polygon Soup"), mainWindow); actionOrientSM->setObjectName("actionOrientSM"); actionOrientSM->setProperty("subMenuName", "Polygon Mesh Processing"); connect(actionOrientSM, SIGNAL(triggered()), From f5f2ebfb519ea3ebe8a15b896111a0e48d426e43 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 8 Feb 2019 14:26:02 +0100 Subject: [PATCH 10/18] Force Fusion style for colored button so they are displayed on all platforms. --- .../Polyhedron/Plugins/Display/Display_property_plugin.cpp | 3 +++ Polyhedron/demo/Polyhedron/Viewer.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index 1e4e728f832..b3de546b031 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -369,10 +370,12 @@ public: addDockWidget(dock_widget); QPalette palette(Qt::red); dock_widget->minColorButton->setPalette(palette); + dock_widget->minColorButton->setStyle(QStyleFactory::create("Fusion")); dock_widget->minColorButton->update(); palette = QPalette(Qt::green); dock_widget->maxColorButton->setPalette(palette); + dock_widget->maxColorButton->setStyle(QStyleFactory::create("Fusion")); dock_widget->maxColorButton->update(); connect(dock_widget->colorizeButton, SIGNAL(clicked(bool)), this, SLOT(colorize())); diff --git a/Polyhedron/demo/Polyhedron/Viewer.cpp b/Polyhedron/demo/Polyhedron/Viewer.cpp index fcd28eb6819..819adc1aa7b 100644 --- a/Polyhedron/demo/Polyhedron/Viewer.cpp +++ b/Polyhedron/demo/Polyhedron/Viewer.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include "ui_LightingDialog.h" @@ -122,18 +123,21 @@ public: 255*d->ambient.z()); palette.setColor(QPalette::Button,ambient); ambientButton->setPalette(palette); + ambientButton->setStyle(QStyleFactory::create("Fusion")); diffuse=QColor(255*d->diffuse.x(), 255*d->diffuse.y(), 255*d->diffuse.z()); palette.setColor(QPalette::Button,diffuse); diffuseButton->setPalette(palette); + diffuseButton->setStyle(QStyleFactory::create("Fusion")); specular=QColor(255*d->specular.x(), 255*d->specular.y(), 255*d->specular.z()); palette.setColor(QPalette::Button,specular); specularButton->setPalette(palette); + specularButton->setStyle(QStyleFactory::create("Fusion")); spec_powrSlider->setValue(static_cast(d->spec_power)); connect(&ambient_dial, &QColorDialog::currentColorChanged, this, &LightingDialog::ambient_changed ); From e679c824af48669ace9afe4df59d087a3411226b Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 8 Feb 2019 16:32:03 +0100 Subject: [PATCH 11/18] Make the deletion of an item faster --- Polyhedron/demo/Polyhedron/Scene_item_rendering_helper.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Scene_item_rendering_helper.cpp b/Polyhedron/demo/Polyhedron/Scene_item_rendering_helper.cpp index 78ef1ecbf7b..d1570def5eb 100644 --- a/Polyhedron/demo/Polyhedron/Scene_item_rendering_helper.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_item_rendering_helper.cpp @@ -59,7 +59,8 @@ struct PRIV{ }; Scene_item_rendering_helper::Scene_item_rendering_helper() - :priv(new PRIV(this)){} + :Scene_item(0,0), + priv(new PRIV(this)){} Scene_item_rendering_helper::~Scene_item_rendering_helper() { From f146d099ac0d580d9cc6ce448621ce879a95c158 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 11 Feb 2019 10:14:29 +0100 Subject: [PATCH 12/18] Fix selection_files loading --- .../demo/Polyhedron/Scene_polyhedron_selection_item.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h index d43f0b6936e..bafac0bc5d1 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h @@ -384,21 +384,21 @@ public: std::string line; std::size_t id, id2; - if(!std::getline(in, line)) { return true; } + if(!std::getline(in, line)) { compute_normal_maps(); return true; } std::istringstream vertex_line(line); while(vertex_line >> id) { if(id >= all_vertices.size()) { return false; } selected_vertices.insert(all_vertices[id]); } - if(!std::getline(in, line)) { return true; } + if(!std::getline(in, line)) { compute_normal_maps(); return true; } std::istringstream facet_line(line); while(facet_line >> id) { if(id >= all_facets.size()) { return false; } selected_facets.insert(all_facets[id]); } - if(!std::getline(in, line)) { return true; } + if(!std::getline(in, line)) { compute_normal_maps(); return true; } std::istringstream edge_line(line); while(edge_line >> id >> id2) { if(id >= all_edges.size() || id2 >= all_edges.size()) { return false; } From c7a77e1a97de524810b38dedd146c9bc7465f1c3 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 11 Feb 2019 10:15:24 +0100 Subject: [PATCH 13/18] Fix typo --- Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp index dc80426098a..14e271ed64c 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp @@ -789,7 +789,7 @@ public Q_SLOTS: QMessageBox::warning(mw, tr("Degenerated Face_graph"), tr("Degenerated faces have been detected. Problems may occur " - "for operations other tha \"Move point\". ")); + "for operations other than \"Move point\". ")); } //remove lasso mode selection_item->set_lasso_mode(false); From fecc589b4c8fa1aeef0821c0da8fd2c94cce5459 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 11 Feb 2019 10:25:47 +0100 Subject: [PATCH 14/18] Move restoreoverridecursor() --- .../demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp index 2f7e9f7b8e1..33882b8d858 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp @@ -541,7 +541,6 @@ void Polyhedron_demo_affine_transform_plugin::start(Scene_points_with_normal_ite void Polyhedron_demo_affine_transform_plugin::end(){ - QApplication::restoreOverrideCursor(); double matrix[16]; transformMatrix(&matrix[0]); const CGAL::qglviewer::Vec offset = static_cast(CGAL::QGLViewer::QGLViewerPool().first())->offset(); @@ -600,6 +599,7 @@ void Polyhedron_demo_affine_transform_plugin::end(){ transform_points_item = NULL; } dock_widget->hide(); + QApplication::restoreOverrideCursor(); } void Polyhedron_demo_affine_transform_plugin::updateUiMatrix() From c650f26c2357f5c8072651746e12795d2a0e93d2 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 11 Feb 2019 12:45:27 +0100 Subject: [PATCH 15/18] Fix OFF reader to detect sooner the flux errors. --- Polyhedron_IO/include/CGAL/IO/OFF_reader.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Polyhedron_IO/include/CGAL/IO/OFF_reader.h b/Polyhedron_IO/include/CGAL/IO/OFF_reader.h index d1d5ddf502c..1bcce913894 100644 --- a/Polyhedron_IO/include/CGAL/IO/OFF_reader.h +++ b/Polyhedron_IO/include/CGAL/IO/OFF_reader.h @@ -98,14 +98,15 @@ namespace CGAL { } else scanner.skip_to_next_vertex(i); + if(!in) + return false; } - if(!in) - return false; bool has_fcolors = false; for (std::size_t i = 0; i < scanner.size_of_facets(); ++i) { std::size_t no; scanner.scan_facet( no, i); - + if(!in) + return false; IO::internal::resize(polygons[i], no); for(std::size_t j = 0; j < no; ++j) { std::size_t id; From b8e03cdf495cc46c602cf1e8e49367061f6a734c Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 13 Feb 2019 17:00:49 +0100 Subject: [PATCH 16/18] Use cgal dynamic_property_maps for source points --- .../Display/Display_property_plugin.cpp | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index b3de546b031..4d288029411 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -26,6 +26,7 @@ #include "triangulate_primitive.h" #include #include +#include #define ARBITRARY_DBL_MIN 1.0E-30 #define ARBITRARY_DBL_MAX 1.0E+30 @@ -34,6 +35,9 @@ //Item for heat values typedef CGAL::Three::Triangle_container Tri; typedef CGAL::Three::Viewer_interface VI; +typedef CGAL::dynamic_vertex_property_t Vertex_source_tag; +typedef typename boost::property_map::type Vertex_source_map; + class Scene_heat_item : public CGAL::Three::Scene_item_rendering_helper { @@ -568,12 +572,6 @@ private Q_SLOTS: { smesh.remove_property_map(angles); } - SMesh::Property_map is_source; - boost::tie(is_source, found) = smesh.property_map("v:heat_source"); - if(found) - { - smesh.remove_property_map(is_source); - } } void displayScaledJacobian(Scene_surface_mesh_item* item) @@ -792,10 +790,7 @@ private Q_SLOTS: bool displayHeatIntensity(Scene_surface_mesh_item* item, bool iDT = false) { SMesh& mesh = *item->face_graph(); - bool found = false; - SMesh::Property_map is_source ; - boost::tie(is_source, found)= - mesh.property_map("v:heat_source"); + bool found = is_source.find(item) != is_source.end(); if(!found || ! source_points || source_points->point_set()->is_empty()) @@ -848,7 +843,7 @@ private Q_SLOTS: } BOOST_FOREACH(vertex_descriptor vd, vertices(mesh)){ - if(is_source[vd]){ + if(get(is_source[item], vd)){ if(iDT){ hm_idt->add_source(vd); } else @@ -1112,13 +1107,20 @@ private Q_SLOTS: source_points=mesh_sources_map[current_item]; } connect(item, SIGNAL(selected_vertex(void*)), this, SLOT(on_vertex_selected(void*))); - bool non_init; - SMesh::Property_map is_source; - boost::tie(is_source, non_init) = current_item->face_graph()->add_property_map("v:heat_source", false); + bool non_init = is_source.find(item) == is_source.end(); if(non_init) { + Vertex_source_map map = get(Vertex_source_tag(), *item->face_graph()); + is_source.insert(std::make_pair(item, map)); connect(item, &Scene_surface_mesh_item::itemChanged, this, &DisplayPropertyPlugin::resetProperty); + connect(item, &Scene_surface_mesh_item::aboutToBeDestroyed, + [this, item](){ + if(is_source.find(item) != is_source.end()) + { + is_source.erase(item); + } + }); } } else @@ -1135,19 +1137,17 @@ private Q_SLOTS: typedef boost::graph_traits::vertices_size_type size_type; size_type h = static_cast(reinterpret_cast(void_ptr)); vertex_descriptor vd = static_cast(h) ; - bool found; - SMesh::Property_map is_source; - boost::tie(is_source, found) = current_item->face_graph()->property_map("v:heat_source"); + bool found = is_source.find(current_item) != is_source.end(); if(found) { - if(!is_source[vd]) + if(!get(is_source[current_item], vd)) { - is_source[vd]=true; + put(is_source[current_item], vd, true); source_points->point_set()->insert(current_item->face_graph()->point(vd)); } else { - is_source[vd]=false; + put(is_source[current_item], vd, false); Point_set::iterator it; for(it = source_points->point_set()->begin(); it != source_points->point_set()->end(); ++it) if(source_points->point_set()->point(*it) == current_item->face_graph()->point(vd)) @@ -1238,6 +1238,7 @@ private: boost::unordered_map > angles_min; boost::unordered_map > angles_max; + boost::unordered_map is_source; double minBox; From a52fccb99722a1990a0e365fd4ec3f9a667fa3a8 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 19 Feb 2019 12:18:16 +0100 Subject: [PATCH 17/18] Move typedefs to avoid error --- .../Polyhedron/Plugins/Display/Display_property_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index 4d288029411..d5f7ba37c8c 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -35,8 +35,6 @@ //Item for heat values typedef CGAL::Three::Triangle_container Tri; typedef CGAL::Three::Viewer_interface VI; -typedef CGAL::dynamic_vertex_property_t Vertex_source_tag; -typedef typename boost::property_map::type Vertex_source_map; class Scene_heat_item : public CGAL::Three::Scene_item_rendering_helper @@ -314,6 +312,8 @@ class DisplayPropertyPlugin : typedef SMesh::Property_map::vertex_descriptor, double> Vertex_distance_map; typedef CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3 Heat_method; typedef CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3 Heat_method_idt; + typedef CGAL::dynamic_vertex_property_t Vertex_source_tag; + typedef typename boost::property_map::type Vertex_source_map; public: From 893e2a055a4b33577025818482fd44e661e8bb36 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 20 Feb 2019 09:32:05 +0100 Subject: [PATCH 18/18] Remove useless typename --- .../demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index d5f7ba37c8c..21784dd06b7 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -313,7 +313,7 @@ class DisplayPropertyPlugin : typedef CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3 Heat_method; typedef CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3 Heat_method_idt; typedef CGAL::dynamic_vertex_property_t Vertex_source_tag; - typedef typename boost::property_map::type Vertex_source_map; + typedef boost::property_map::type Vertex_source_map; public: