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 \ diff --git a/Orthtree/include/CGAL/Orthtree.h b/Orthtree/include/CGAL/Orthtree.h index 3ba95f14ee6..afc958b9754 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); 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 b9e1102f32d..9830ad06e6c 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 @@ -1068,15 +1068,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; @@ -1091,6 +1091,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 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 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..f74562e6e58 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,33 @@ 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" && + + //read a nrrd file + 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"); + delete image; + 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())) { QMessageBox qmb(QMessageBox::NoIcon, @@ -1100,13 +1129,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); 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 diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h index 97ba5aed47b..8e274941fc1 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 = 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); } } @@ -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 = 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); } }