From b8e96fef84316d2be45a6efe1ab3c055de129688 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 7 Nov 2022 09:11:19 +0000 Subject: [PATCH 01/13] Surface_mesh: Deal with PLY files with vertex and face color which is float instead of unsigned char --- .../include/CGAL/Surface_mesh/IO/PLY.h | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h index 97ba5aed47b..0204a0ac701 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h @@ -289,10 +289,22 @@ public: if(m_vcolors == 3) { - unsigned char r, g, b; - element.assign(r, "red"); - element.assign(g, "green"); - element.assign(b, "blue"); + unsigned char r=0, g=0, b=0; + float rf=0, gf=0, bf=0; + if(element.has_property("red",r)) + { + element.assign(r, "red"); + element.assign(g, "green"); + element.assign(b, "blue"); + }else if(element.has_property("red", rf)) + { + element.assign(rf, "red"); + element.assign(gf, "green"); + element.assign(bf, "blue"); + r = std::floor(rf*255); + g = std::floor(gf*255); + b = std::floor(bf*255); + } m_vcolor_map[vi] = CGAL::IO::Color(r, g, b); } } @@ -331,10 +343,22 @@ public: if(m_fcolors == 3) { - unsigned char r, g, b; - element.assign(r, "red"); - element.assign(g, "green"); - element.assign(b, "blue"); + unsigned char r=0, g=0, b=0; + float rf=0, gf=0, bf=0; + if(element.has_property("red",r)) + { + element.assign(r, "red"); + element.assign(g, "green"); + element.assign(b, "blue"); + } else if(element.has_property("red", rf)) + { + element.assign(rf, "red"); + element.assign(gf, "green"); + element.assign(bf, "blue"); + r = std::floor(rf*255); + g = std::floor(gf*255); + b = std::floor(bf*255); + } m_fcolor_map[fi] = CGAL::IO::Color(r, g, b); } } From 3f9f7429b8f70eedc829b189339b2ad51cac43f2 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 7 Nov 2022 10:20:13 +0100 Subject: [PATCH 02/13] Update Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h Co-authored-by: Sebastien Loriot --- Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h index 0204a0ac701..ae1853a0a12 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h @@ -350,7 +350,7 @@ public: element.assign(r, "red"); element.assign(g, "green"); element.assign(b, "blue"); - } else if(element.has_property("red", rf)) + } else if(element.has_property("red", rf)) { element.assign(rf, "red"); element.assign(gf, "green"); From b609f5364b64740cb022102a18895360e42e2486 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 7 Nov 2022 12:19:16 +0100 Subject: [PATCH 03/13] remove duplicate include --- Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp index 999a81bc2cf..e35576fc98f 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp @@ -60,12 +60,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include From 57c6d59ddcef1fac903149ff3e3f5812191aca34 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 7 Nov 2022 12:20:14 +0100 Subject: [PATCH 04/13] add vtkNrrd reader to Io_image_plugin --- .../Plugins/Mesh_3/Io_image_plugin.cpp | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) 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 72ef02c7c4c..826c4867696 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp @@ -65,7 +65,9 @@ #include #include #include +#include #endif + #include // Covariant return types don't work for scalar types and we cannot @@ -978,7 +980,8 @@ private Q_SLOTS: QString Io_image_plugin::nameFilters() const { return QString("Inrimage files (*.inr *.inr.gz) ;; " "Analyze files (*.hdr *.img *img.gz) ;; " - "Stanford Exploration Project files (*.H *.HH)"); + "Stanford Exploration Project files (*.H *.HH) ;; " + "NRRD image files (*.nrrd)"); } @@ -1011,7 +1014,23 @@ Io_image_plugin::load(QFileInfo fileinfo, bool& ok, bool add_to_scene) ok = true; QApplication::restoreOverrideCursor(); Image* image = new Image; - if(fileinfo.suffix() != "H" && fileinfo.suffix() != "HH" && + if (fileinfo.suffix() == "nrrd") + { +#ifdef CGAL_USE_VTK + vtkNew reader; + reader->SetFileName(fileinfo.filePath().toUtf8()); + reader->Update(); + auto vtk_image = reader->GetOutput(); + vtk_image->Print(std::cerr); + *image = CGAL::IO::read_vtk_image_data(vtk_image); // copy the image data +#else + CGAL::Three::Three::warning("You need VTK to read a NRRD file"); + CGAL_USE(dirname); + delete image; + return QList(); +#endif + } + else if(fileinfo.suffix() != "H" && fileinfo.suffix() != "HH" && !image->read(fileinfo.filePath().toUtf8())) { QMessageBox qmb(QMessageBox::NoIcon, From 41f1acc4650b897568a1333700a0e367c9a633e6 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 7 Nov 2022 12:41:53 +0100 Subject: [PATCH 05/13] reorder if/else conditions --- .../Plugins/Mesh_3/Io_image_plugin.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) 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 826c4867696..7a3f29db756 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp @@ -1014,6 +1014,8 @@ Io_image_plugin::load(QFileInfo fileinfo, bool& ok, bool add_to_scene) ok = true; QApplication::restoreOverrideCursor(); Image* image = new Image; + + //read a nrrd file if (fileinfo.suffix() == "nrrd") { #ifdef CGAL_USE_VTK @@ -1030,6 +1032,15 @@ Io_image_plugin::load(QFileInfo fileinfo, bool& ok, bool add_to_scene) return QList(); #endif } + + //read a sep file + else if (fileinfo.suffix() == "H" || fileinfo.suffix() == "HH") + { + CGAL::SEP_to_ImageIO reader(fileinfo.filePath().toUtf8().data()); + *image = *reader.cgal_image(); + is_gray = true; + } + else if(fileinfo.suffix() != "H" && fileinfo.suffix() != "HH" && !image->read(fileinfo.filePath().toUtf8())) { @@ -1119,13 +1130,7 @@ Io_image_plugin::load(QFileInfo fileinfo, bool& ok, bool add_to_scene) return QList(); } } - //read a sep file - else if(fileinfo.suffix() == "H" || fileinfo.suffix() == "HH") - { - CGAL::SEP_to_ImageIO reader(fileinfo.filePath().toUtf8().data()); - *image = *reader.cgal_image(); - is_gray = true; - } + // Get display precision QDialog dialog; ui.setupUi(&dialog); From 26472284e4ee0ae551fbcf32bbfa663951242625 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 7 Nov 2022 12:47:35 +0100 Subject: [PATCH 06/13] the demo can now mesh images with any word type thanks to the new domain constructors that do not need to be defined explicitly a priori --- .../Plugins/Mesh_3/Mesh_3_plugin.cpp | 21 ------------------- 1 file changed, 21 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 6aa0571c8b9..ac61fa258e9 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp @@ -374,27 +374,6 @@ boost::optional Mesh_3_plugin::get_items_or_return_error_string() const auto& image_item = image_mesh_items->image_item; item = image_item; features_protection_available = true; - - bool fit_wrdtp = true; - std::size_t img_wdim = image_item->image()->image()->wdim; - WORD_KIND img_wordKind = image_item->image()->image()->wordKind; - // check if the word type fits the hardcoded values in the plugin - if (image_item->isGray()) { - if (img_wordKind != WK_FLOAT) - fit_wrdtp = false; - else if (img_wdim != 4) - fit_wrdtp = false; - } else { - if (img_wordKind != WK_FIXED) - fit_wrdtp = false; - else if (img_wdim != 1) - fit_wrdtp = false; - } - if (!fit_wrdtp) { - return tr( - "Selected object can't be meshed because the image's word type is " - "not supported by this plugin."); - } } # endif From f3f3af10bbe104ac5b49bd49700cc29d2ce91979 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 9 Nov 2022 08:18:22 +0000 Subject: [PATCH 07/13] Remove CGAL_USE(dirname) as not defined --- Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp | 1 - 1 file changed, 1 deletion(-) 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 7a3f29db756..f74562e6e58 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp @@ -1027,7 +1027,6 @@ Io_image_plugin::load(QFileInfo fileinfo, bool& ok, bool add_to_scene) *image = CGAL::IO::read_vtk_image_data(vtk_image); // copy the image data #else CGAL::Three::Three::warning("You need VTK to read a NRRD file"); - CGAL_USE(dirname); delete image; return QList(); #endif From fa6a2bddac4ec08f9f1d9f37269938573b1ee225 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 9 Nov 2022 08:32:59 +0000 Subject: [PATCH 08/13] static_cast to avoid warning --- Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h index ae1853a0a12..3f03e20badd 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h @@ -355,9 +355,9 @@ public: element.assign(rf, "red"); element.assign(gf, "green"); element.assign(bf, "blue"); - r = std::floor(rf*255); - g = std::floor(gf*255); - b = std::floor(bf*255); + r = static_cast(std::floor(rf*255)); + g = static_cast(std::floor(gf*255)); + b = static_cast(std::floor(bf*255)); } m_fcolor_map[fi] = CGAL::IO::Color(r, g, b); } From d1eca8310f955652616b3e1abdaa77f646ae004a Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 7 Nov 2022 17:34:54 +0000 Subject: [PATCH 09/13] typo --- Orthtree/include/CGAL/Orthtree/Node.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Orthtree/include/CGAL/Orthtree/Node.h b/Orthtree/include/CGAL/Orthtree/Node.h index 5a485adcae8..219959b81cc 100644 --- a/Orthtree/include/CGAL/Orthtree/Node.h +++ b/Orthtree/include/CGAL/Orthtree/Node.h @@ -345,7 +345,7 @@ public: } /*! - \brief returns the nth child fo this node. + \brief returns the nth child of this node. \pre `!is_null()` \pre `!is_leaf()` From 331ea2898a896b3a6b1c3cd4966f88c1b7221d41 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 8 Nov 2022 15:15:20 +0000 Subject: [PATCH 10/13] Orthtree: Fix memory leak --- Orthtree/include/CGAL/Orthtree.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Orthtree/include/CGAL/Orthtree.h b/Orthtree/include/CGAL/Orthtree.h index 5c8cc3ca021..8091001a32f 100644 --- a/Orthtree/include/CGAL/Orthtree.h +++ b/Orthtree/include/CGAL/Orthtree.h @@ -320,8 +320,21 @@ public: void refine(const Split_predicate& split_predicate) { // If the tree has already been refined, reset it - if (!m_root.is_leaf()) + if (!m_root.is_leaf()){ + std::queue nodes; + for (std::size_t i = 0; i < Degree::value; ++ i) + nodes.push (m_root[i]); + while (!nodes.empty()) + { + Node node = nodes.front(); + nodes.pop(); + if (!node.is_leaf()) + for (std::size_t i = 0; i < Degree::value; ++ i) + nodes.push (node[i]); + node.free(); + } m_root.unsplit(); + } // Reset the side length map, too m_side_per_depth.resize(1); From cd4de51a4035bf066e49abb9a2fa0d5ef96cba24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 9 Nov 2022 18:17:31 +0100 Subject: [PATCH 11/13] fix inconsistency check --- .../Corefinement/Face_graph_output_builder.h | 17 +++++++++---- .../data-coref/floating_squares.off | 16 +++++++++++++ .../data-coref/hexa.off | 24 +++++++++++++++++++ .../test_corefinement_bool_op.cmd | 1 + 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/floating_squares.off create mode 100644 Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/hexa.off diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h index bb52550f111..6709b3705eb 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h @@ -1069,15 +1069,15 @@ public: if (!used_to_clip_a_surface && !used_to_classify_patches && (!is_tm1_closed || !is_tm2_closed)) { //make sure there is no ambiguity in tm1 - if( (patch_status_was_not_already_set[0] && previous_bitvalue[0]!=is_patch_inside_tm2[patch_id_p1] ) || - (patch_status_was_not_already_set[1] && previous_bitvalue[1]!=is_patch_inside_tm2[patch_id_p2] ) ) + if( (!patch_status_was_not_already_set[0] && previous_bitvalue[0]!=is_patch_inside_tm2.test(patch_id_p1) ) || + (!patch_status_was_not_already_set[1] && previous_bitvalue[1]!=is_patch_inside_tm2.test(patch_id_p2) ) ) { impossible_operation.set(); return true; } //make sure there is no ambiguity in tm2 - if( (patch_status_was_not_already_set[2] && previous_bitvalue[2]!=is_patch_inside_tm2[patch_id_q1] ) || - (patch_status_was_not_already_set[3] && previous_bitvalue[3]!=is_patch_inside_tm2[patch_id_q2] ) ) + if( (!patch_status_was_not_already_set[2] && previous_bitvalue[2]!=is_patch_inside_tm1.test(patch_id_q1) ) || + (!patch_status_was_not_already_set[3] && previous_bitvalue[3]!=is_patch_inside_tm1.test(patch_id_q2) ) ) { impossible_operation.set(); return true; @@ -1092,6 +1092,15 @@ public: patch_status_not_set_tm2.reset(patch_id_q1); patch_status_not_set_tm2.reset(patch_id_q2); + // restore initial state, needed when checking in `inconsistent_classification()` + if (!is_tm1_closed || !is_tm2_closed) + { + is_patch_inside_tm2.reset(patch_id_p1); + is_patch_inside_tm2.reset(patch_id_p2); + is_patch_inside_tm1.reset(patch_id_q1); + is_patch_inside_tm1.reset(patch_id_q2); + } + #ifdef CGAL_COREFINEMENT_POLYHEDRA_DEBUG #warning: Factorize the orientation predicates. #endif //CGAL_COREFINEMENT_POLYHEDRA_DEBUG diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/floating_squares.off b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/floating_squares.off new file mode 100644 index 00000000000..86709d5e8ac --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/floating_squares.off @@ -0,0 +1,16 @@ +OFF +8 4 0 + +0 0 1 +1 0 1 +1 1 1 +0 1 1 +0 0 0 +1 0 0 +1 1 0 +0 1 0 +3 0 1 2 +3 2 3 0 +3 6 5 4 +3 4 7 6 + diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/hexa.off b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/hexa.off new file mode 100644 index 00000000000..4bbb30354ec --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/hexa.off @@ -0,0 +1,24 @@ +OFF +8 12 0 + +0.75 0.75 -1 +0.25 0.75 -1 +0.25 0.25 -1 +0.75 0.25 -1 +0.75 0.25 1 +0.75 0.75 1 +0.25 0.75 1 +0.25 0.25 1 +3 4 5 6 +3 0 3 2 +3 1 2 7 +3 0 1 6 +3 3 0 5 +3 2 3 4 +3 6 7 4 +3 2 1 0 +3 7 6 1 +3 6 5 0 +3 5 4 3 +3 4 7 2 + diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_bool_op.cmd b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_bool_op.cmd index 99d70e20728..c11009e6559 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_bool_op.cmd +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_bool_op.cmd @@ -1,2 +1,3 @@ ${CGAL_DATA_DIR}/meshes/elephant.off ${CGAL_DATA_DIR}/meshes/sphere.off ALL 1 1 1 1 ${CGAL_DATA_DIR}/meshes/open_cube.off data-coref/incompatible_with_open_cube.off ALL 0 0 0 0 +data-coref/floating_squares.off data-coref/hexa.off ALL 1 1 1 1 From 178bc9e905bf9221542fb23cfa0c144a183b06e7 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 10 Nov 2022 09:24:26 +0000 Subject: [PATCH 12/13] More static cast --- Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h index 3f03e20badd..8e274941fc1 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h @@ -301,9 +301,9 @@ public: element.assign(rf, "red"); element.assign(gf, "green"); element.assign(bf, "blue"); - r = std::floor(rf*255); - g = std::floor(gf*255); - b = std::floor(bf*255); + r = static_cast(std::floor(rf*255)); + g = static_cast(std::floor(gf*255)); + b = static_cast(std::floor(bf*255)); } m_vcolor_map[vi] = CGAL::IO::Color(r, g, b); } From 5f6f1e2e8d6543745ff73daa4b5b1df71eef87fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 14 Nov 2022 20:14:55 +0100 Subject: [PATCH 13/13] remove line that seems useless --- .github/install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/install.sh b/.github/install.sh index e06328da401..32b8552aa8f 100755 --- a/.github/install.sh +++ b/.github/install.sh @@ -1,5 +1,4 @@ #!/bin/bash -sudo add-apt-repository ppa:mikhailnov/pulseeffects -y sudo apt-get update sudo apt-get install -y libmpfr-dev \ libeigen3-dev qtbase5-dev libqt5sql5-sqlite libqt5opengl5-dev qtscript5-dev \