From 9f0ebc705bdf0a5c17cae786ea6a2e978afa3bc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 15 May 2020 18:03:40 +0200 Subject: [PATCH 1/8] set the initial size of the internal vector when using vector_property_map --- BGL/examples/BGL_LCC/normals_lcc.cpp | 2 +- BGL/examples/BGL_polyhedron_3/normals.cpp | 2 +- .../Polygon_mesh_processing/connected_components.h | 14 +++++++------- .../include/CGAL/Polygon_mesh_processing/repair.h | 2 +- .../connected_component_polyhedron.cpp | 6 +++--- .../PMP/Join_and_split_polyhedra_plugin.cpp | 2 +- .../PMP/Scene_facegraph_item_k_ring_selection.h | 2 +- .../demo/Polyhedron/Scene_surface_mesh_item.cpp | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/BGL/examples/BGL_LCC/normals_lcc.cpp b/BGL/examples/BGL_LCC/normals_lcc.cpp index 4c9588546a6..6779fccb616 100644 --- a/BGL/examples/BGL_LCC/normals_lcc.cpp +++ b/BGL/examples/BGL_LCC/normals_lcc.cpp @@ -74,7 +74,7 @@ int main(int argc, char** argv) // http://www.boost.org/libs/property_map/doc/vector_property_map.html // for details. boost::vector_property_map - normals(get(CGAL::face_index, lcc)); + normals(num_faces(lcc), get(CGAL::face_index, lcc)); calculate_face_normals( lcc // Graph diff --git a/BGL/examples/BGL_polyhedron_3/normals.cpp b/BGL/examples/BGL_polyhedron_3/normals.cpp index 5de0ba63f70..dbdca040ef5 100644 --- a/BGL/examples/BGL_polyhedron_3/normals.cpp +++ b/BGL/examples/BGL_polyhedron_3/normals.cpp @@ -82,7 +82,7 @@ int main(int argc, char** argv) // http://www.boost.org/libs/property_map/doc/vector_property_map.html // for details. boost::vector_property_map - normals(get(CGAL::face_index, P)); + normals(num_faces(P), get(CGAL::face_index, P)); calculate_face_normals( P // Graph diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index b98a70c63c5..ef715e096d2 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -387,7 +387,7 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh, Output_iterator out = choose_parameter(get_parameter(np, internal_np::output_iterator)); // vector_property_map - boost::vector_property_map face_cc(fimap); + boost::vector_property_map face_cc(num_faces(pmesh), fimap); std::size_t num = connected_components(pmesh, face_cc, np); // Even if we do not want to keep anything we need to first @@ -518,7 +518,7 @@ std::size_t keep_large_connected_components(PolygonMesh& pmesh, Output_iterator out = choose_parameter(get_parameter(np, internal_np::output_iterator)); // vector_property_map - boost::vector_property_map face_cc(fim); + boost::vector_property_map face_cc(num_faces(pmesh), fim); std::size_t num = connected_components(pmesh, face_cc, np); std::vector component_size(num, 0); @@ -595,10 +595,10 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh for(std::size_t i : components_to_keep) cc_to_keep.insert(i); - boost::vector_property_map keep_vertex(vim); - for(vertex_descriptor v : vertices(pmesh)){ + boost::vector_property_map keep_vertex(num_vertices(pmesh), vim); + for(vertex_descriptor v : vertices(pmesh)) keep_vertex[v] = false; - } + for(face_descriptor f : faces(pmesh)){ if (cc_to_keep.find(get(fcm,f)) != cc_to_keep.end()) put(fcm, f, keep ? 1 : 0); @@ -821,7 +821,7 @@ void remove_connected_components(PolygonMesh& pmesh typedef typename CGAL::GetInitializedFaceIndexMap::type FaceIndexMap; FaceIndexMap fim = CGAL::get_initialized_face_index_map(pmesh, np); - boost::vector_property_map face_cc(fim); + boost::vector_property_map face_cc(num_faces(pmesh), fim); connected_components(pmesh, face_cc, np); std::vector cc_to_remove; @@ -871,7 +871,7 @@ void keep_connected_components(PolygonMesh& pmesh typedef typename CGAL::GetInitializedFaceIndexMap::type FaceIndexMap; FaceIndexMap fim = CGAL::get_initialized_face_index_map(pmesh, np); - boost::vector_property_map face_cc(fim); + boost::vector_property_map face_cc(num_faces(pmesh), fim); connected_components(pmesh, face_cc, np); std::vector cc_to_keep; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h index 127f6c1b31c..5bfa2a7a839 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h @@ -179,7 +179,7 @@ std::size_t remove_connected_components_of_negligible_size(TriangleMesh& tmesh, return 0; // Compute the connected components only once - boost::vector_property_map face_cc(fim); + boost::vector_property_map face_cc(num_faces(tmesh), fim); std::size_t num = connected_components(tmesh, face_cc, np); #ifdef CGAL_PMP_DEBUG_SMALL_CC_REMOVAL diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp index 9b5a81b4855..c4eaac08ec5 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp @@ -38,7 +38,7 @@ void mesh_with_id(const char* argv1, const bool save_output) boost::vector_property_map::type> - fccmap(get(CGAL::face_index,sm)); + fccmap(num_faces(sm), get(CGAL::face_index,sm)); std::size_t num = PMP::connected_components(sm, fccmap); if (strcmp(argv1, "data/blobby_3cc.off") == 0) @@ -92,7 +92,7 @@ void mesh_no_id(const char* argv1, const bool save_output) boost::vector_property_map::type> - fccmap(fim); + fccmap(num_faces(sm), fim); std::size_t num = PMP::connected_components(sm, fccmap); @@ -133,7 +133,7 @@ void test_border_cases() boost::vector_property_map::type> - fccmap(get(boost::face_index,sm)); + fccmap(num_faces(sm), get(boost::face_index,sm)); PMP::connected_components(sm, fccmap); std::size_t nb_faces=num_faces(sm); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Join_and_split_polyhedra_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Join_and_split_polyhedra_plugin.cpp index 1c1e7f3bd70..f64b7f2da36 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Join_and_split_polyhedra_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Join_and_split_polyhedra_plugin.cpp @@ -237,7 +237,7 @@ void Polyhedron_demo_join_and_split_polyhedra_plugin::on_actionColorConnectedCom = get(boost::face_index, pmesh); boost::vector_property_map::type> - fccmap(fim); + fccmap(num_faces(pmesh),fim); boost::property_map >::type pid = get(CGAL::face_patch_id_t(), pmesh); 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 3ec4c1871b7..6331d623a70 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 @@ -273,7 +273,7 @@ public Q_SLOTS: boost::vector_property_map::type> - fccmap; + fccmap(num_faces(poly)); //get connected componant from the picked face std::set final_sel; diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp index 19e7013495b..c904ac3ff38 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp @@ -1606,7 +1606,7 @@ QString Scene_surface_mesh_item::computeStats(int type) { boost::vector_property_map::type> - fccmap(get(boost::face_index, *(d->smesh_))); + fccmap(num_faces(*(d->smesh_)), get(boost::face_index, *(d->smesh_))); return QString::number(CGAL::Polygon_mesh_processing::connected_components(*(d->smesh_), fccmap)); } case NB_BORDER_EDGES: From 094bfe35a3ca96c5ec2b0134af54961d78082302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 15 May 2020 18:05:57 +0200 Subject: [PATCH 2/8] do not iterate on a container while removing elements --- .../connected_components.h | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index ef715e096d2..93d18817024 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -615,11 +615,9 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh } } - edge_iterator eb, ee; - for (boost::tie(eb, ee) = edges(pmesh); eb != ee;) + std::vector edges_to_remove; + for (edge_descriptor e : edges(pmesh)) { - edge_descriptor e = *eb; - ++eb; vertex_descriptor v = source(e, pmesh); vertex_descriptor w = target(e, pmesh); halfedge_descriptor h = halfedge(e, pmesh); @@ -627,7 +625,7 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh if (!keep_vertex[v] && !keep_vertex[w]){ // don't care about connectivity // As vertices are not kept the faces and vertices will be removed later - remove_edge(e, pmesh); + edges_to_remove.push_back(e); } else if (keep_vertex[v] && keep_vertex[w]){ face_descriptor fh = face(h, pmesh), ofh = face(oh, pmesh); @@ -660,7 +658,7 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh // shortcut the next pointers as e will be removed set_next(prev(h, pmesh), next(oh, pmesh), pmesh); set_next(prev(oh, pmesh), next(h, pmesh), pmesh); - remove_edge(e, pmesh); + edges_to_remove.push_back(e); } } else if (keep_vertex[v]){ @@ -668,7 +666,7 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh set_halfedge(v, prev(h, pmesh), pmesh); } set_next(prev(h, pmesh), next(oh, pmesh), pmesh); - remove_edge(e, pmesh); + edges_to_remove.push_back(e); } else { CGAL_assertion(keep_vertex[w]); @@ -676,26 +674,28 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh set_halfedge(w, prev(oh, pmesh), pmesh); } set_next(prev(oh, pmesh), next(h, pmesh), pmesh); - remove_edge(e, pmesh); + edges_to_remove.push_back(e); } } + for (edge_descriptor e : edges_to_remove) + remove_edge(e, pmesh); - face_iterator fb, fe; // We now can remove all vertices and faces not marked as kept - for (boost::tie(fb, fe) = faces(pmesh); fb != fe;){ - face_descriptor f = *fb; - ++fb; - if (get(fcm,f) != 1){ - remove_face(f, pmesh); - } - } - vertex_iterator b, e; - for (boost::tie(b, e) = vertices(pmesh); b != e;){ - vertex_descriptor v = *b; - ++b; - if (!keep_vertex[v]){ - remove_vertex(v, pmesh); - } + std::vector faces_to_remove; + for (face_descriptor f : faces(pmesh)) + if (get(fcm,f) != 1) + faces_to_remove.push_back(f); + for (face_descriptor f : faces_to_remove) + remove_face(f, pmesh); + + std::vector vertices_to_remove; + for(vertex_descriptor v: vertices(pmesh)) + if (!keep_vertex[v]) + vertices_to_remove.push_back(v); + + for (vertex_descriptor v : vertices_to_remove) + remove_vertex(v, pmesh); + } } From 2eab2f447297a4501411b46f5b0f663a1b75d4bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 15 May 2020 18:06:35 +0200 Subject: [PATCH 3/8] add a property map returning a const bool at compile time --- Property_map/include/CGAL/property_map.h | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Property_map/include/CGAL/property_map.h b/Property_map/include/CGAL/property_map.h index f58413b9755..c5c78786f5e 100644 --- a/Property_map/include/CGAL/property_map.h +++ b/Property_map/include/CGAL/property_map.h @@ -65,6 +65,31 @@ public: {} }; +/// Similar to Static_property_map but retricted to bool and the value is const at compile time +template +class Static_boolean_property_map +{ +public: + typedef Key key_type; + typedef bool value_type; + typedef bool reference; + typedef boost::read_write_property_map_tag category; + +public: + + inline friend + value_type + get(const Static_boolean_property_map&, const key_type&) + { + return default_value; + } + + inline friend + void + put(Static_boolean_property_map&, const key_type&, const value_type&) + {} +}; + template class OR_property_map { From 577ea4039407eb04e366cf375ab7f134b0be08ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 15 May 2020 18:07:30 +0200 Subject: [PATCH 4/8] add the possibility to not remove some vertices when removing connected components --- .../connected_components.h | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 93d18817024..b966d227d99 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -579,6 +579,7 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh { using parameters::choose_parameter; using parameters::get_parameter; + using parameters::is_default_parameter; typedef typename boost::graph_traits::face_descriptor face_descriptor; typedef typename boost::graph_traits::face_iterator face_iterator; @@ -692,10 +693,22 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh for(vertex_descriptor v: vertices(pmesh)) if (!keep_vertex[v]) vertices_to_remove.push_back(v); - - for (vertex_descriptor v : vertices_to_remove) - remove_vertex(v, pmesh); - + if ( is_default_parameter(get_parameter(np, internal_np::vertex_is_constrained)) ) + for (vertex_descriptor v : vertices_to_remove) + remove_vertex(v, pmesh); + else + { + typedef typename internal_np::Lookup_named_param_def // default (not used) + >::type Vertex_map; + Vertex_map is_cst = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained), + Static_boolean_property_map()); + for (vertex_descriptor v : vertices_to_remove) + if (!get(is_cst, v)) + remove_vertex(v, pmesh); + else + set_halfedge(v, boost::graph_traits::null_halfedge(), pmesh); } } From fbd962830796c216c9f5e3a6919e694eb171e9c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 15 May 2020 18:27:33 +0200 Subject: [PATCH 5/8] add a static bool map and use it when possible also remove Static_property_map that is a duplicate of Constant_property_map --- .../connected_components.h | 13 +++----- .../Isotropic_remeshing/remesh_impl.h | 2 +- .../Polygon_mesh_processing/manifoldness.h | 4 +-- .../Polygon_mesh_processing/orientation.h | 4 +-- .../random_perturbation.h | 4 +-- .../CGAL/Polygon_mesh_processing/remesh.h | 16 +++++----- .../repair_degeneracies.h | 8 ++--- .../Polygon_mesh_processing/smooth_mesh.h | 4 +-- .../Polygon_mesh_processing/smooth_shape.h | 4 +-- .../PMP/Isotropic_remeshing_plugin.cpp | 4 +-- .../graph/properties_Polyhedron_3_features.h | 4 +-- Property_map/include/CGAL/property_map.h | 32 +------------------ .../graph/properties_Surface_mesh_features.h | 4 +-- 13 files changed, 34 insertions(+), 69 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index b966d227d99..1ed128cb15b 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -936,13 +936,6 @@ void keep_connected_components(PolygonMesh& pmesh namespace internal { -template -struct No_mark -{ - friend bool get(No_mark, typename boost::graph_traits::edge_descriptor) { return false; } - friend void put(No_mark, typename boost::graph_traits::edge_descriptor, bool) { } -}; - template < class PolygonMesh, class PolygonMeshRange, class FIMap, class VIMap, class HIMap, class Ecm, class NamedParameters > @@ -1039,17 +1032,19 @@ void split_connected_components(const PolygonMesh& pm, PolygonMeshRange& cc_meshes, const NamedParameters& np) { + typedef Static_boolean_property_map< + typename boost::graph_traits::edge_descriptor, false> Default_ecm; typedef typename internal_np::Lookup_named_param_def < internal_np::edge_is_constrained_t, NamedParameters, - internal::No_mark//default + Default_ecm//default > ::type Ecm; using parameters::choose_parameter; using parameters::get_parameter; Ecm ecm = choose_parameter(get_parameter(np, internal_np::edge_is_constrained), - internal::No_mark()); + Default_ecm()); internal::split_connected_components_impl(CGAL::get_initialized_face_index_map(pm, np), CGAL::get_initialized_halfedge_index_map(pm, np), diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h index e64e707bbd8..aa74a72008e 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h @@ -1524,7 +1524,7 @@ private: // update status using constrained edge map if (!boost::is_same >::value) + Static_boolean_property_map >::value) { for(edge_descriptor e : edges(mesh_)) { diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/manifoldness.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/manifoldness.h index 5ffa00ffeda..9740d3cbb2a 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/manifoldness.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/manifoldness.h @@ -174,10 +174,10 @@ std::size_t make_umbrella_manifold(typename boost::graph_traits::ha typedef typename internal_np::Lookup_named_param_def // default (no constraint pmap) + Static_boolean_property_map // default (no constraint pmap) >::type VerticesMap; VerticesMap cmap = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained), - Constant_property_map(false)); + Static_boolean_property_map()); std::size_t nb_new_vertices = 0; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h index d9131e4a083..88b2536b5ad 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h @@ -1216,7 +1216,7 @@ bool does_bound_a_volume(const TriangleMesh& tm, const NamedParameters& np) CGAL_precondition(is_closed(tm)); CGAL_precondition(is_triangle_mesh(tm)); - Static_property_map vidmap(0); // dummy map not used + Constant_property_map vidmap(0); // dummy map not used std::size_t res = volume_connected_components(tm, vidmap, np.do_orientation_tests(true) .i_used_as_a_predicate(true)); @@ -1297,7 +1297,7 @@ void orient_to_bound_a_volume(TriangleMesh& tm, std::vector face_cc(num_faces(tm), std::size_t(-1)); std::vector nesting_levels; std::vector is_cc_outward_oriented; - Static_property_map vidmap(0); // dummy map not used + Constant_property_map vidmap(0); // dummy map not used volume_connected_components(tm, vidmap, parameters::vertex_point_map(vpm) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/random_perturbation.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/random_perturbation.h index aec54c22b7c..f2e09a9dec4 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/random_perturbation.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/random_perturbation.h @@ -163,10 +163,10 @@ void random_perturbation(VertexRange vertices typedef typename internal_np::Lookup_named_param_def < internal_np::vertex_is_constrained_t, NamedParameters, - Constant_property_map // default + Static_boolean_property_map // default > ::type VCMap; VCMap vcmap = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained), - Constant_property_map(false)); + Static_boolean_property_map()); unsigned int seed = choose_parameter(get_parameter(np, internal_np::random_seed), -1); bool do_project = choose_parameter(get_parameter(np, internal_np::do_project), true); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h index 1c8b004bdd6..ece8e7f1410 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h @@ -165,18 +165,18 @@ void isotropic_remeshing(const FaceRange& faces typedef typename internal_np::Lookup_named_param_def < internal_np::edge_is_constrained_t, NamedParameters, - Constant_property_map // default (no constraint pmap) + Static_boolean_property_map // default (no constraint pmap) > ::type ECMap; ECMap ecmap = choose_parameter(get_parameter(np, internal_np::edge_is_constrained), - Constant_property_map(false)); + Static_boolean_property_map()); typedef typename internal_np::Lookup_named_param_def < internal_np::vertex_is_constrained_t, NamedParameters, - Constant_property_map // default (no constraint pmap) + Static_boolean_property_map // default (no constraint pmap) > ::type VCMap; VCMap vcmap = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained), - Constant_property_map(false)); + Static_boolean_property_map()); bool protect = choose_parameter(get_parameter(np, internal_np::protect_constraints), false); typedef typename internal_np::Lookup_named_param_def < @@ -342,18 +342,18 @@ void split_long_edges(const EdgeRange& edges typedef typename internal_np::Lookup_named_param_def < internal_np::edge_is_constrained_t, NamedParameters, - Constant_property_map // default (no constraint pmap) + Static_boolean_property_map // default (no constraint pmap) > ::type ECMap; ECMap ecmap = choose_parameter(get_parameter(np, internal_np::edge_is_constrained), - Constant_property_map(false)); + Static_boolean_property_map()); typename internal::Incremental_remesher, // no constraint pmap + Static_boolean_property_map, // no constraint pmap internal::Connected_components_pmap, FIMap > remesher(pmesh, vpmap, gt, false/*protect constraints*/, ecmap, - Constant_property_map(false), + Static_boolean_property_map(), internal::Connected_components_pmap(faces(pmesh), pmesh, ecmap, fimap, false), fimap, false/*need aabb_tree*/); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_degeneracies.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_degeneracies.h index 5ef95e053f6..13e7130b742 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_degeneracies.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_degeneracies.h @@ -353,17 +353,17 @@ bool remove_almost_degenerate_faces(const FaceRange& face_range, typedef typename boost::graph_traits::edge_descriptor edge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef Constant_property_map Default_VCM; + typedef Static_boolean_property_map Default_VCM; typedef typename internal_np::Lookup_named_param_def::type VCM; - VCM vcm_np = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained), Default_VCM(false)); + VCM vcm_np = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained), Default_VCM()); - typedef Constant_property_map Default_ECM; + typedef Static_boolean_property_map Default_ECM; typedef typename internal_np::Lookup_named_param_def::type ECM; - ECM ecm = choose_parameter(get_parameter(np, internal_np::edge_is_constrained), Default_ECM(false)); + ECM ecm = choose_parameter(get_parameter(np, internal_np::edge_is_constrained), Default_ECM()); typedef typename GetVertexPointMap::const_type VPM; VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smooth_mesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smooth_mesh.h index 60cdbf355be..4e663b7ca35 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smooth_mesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smooth_mesh.h @@ -122,7 +122,7 @@ void smooth_mesh(const FaceRange& faces, typedef typename internal_np::Lookup_named_param_def // default + Static_boolean_property_map // default > ::type ECMap; typedef internal::Area_smoother Area_optimizer; @@ -182,7 +182,7 @@ void smooth_mesh(const FaceRange& faces, } ECMap ecmap = choose_parameter(get_parameter(np, internal_np::edge_is_constrained), - Constant_property_map(false)); + Static_boolean_property_map()); // a constrained edge has constrained extremities for(face_descriptor f : faces) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smooth_shape.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smooth_shape.h index 608758623a1..fa07beac286 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smooth_shape.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smooth_shape.h @@ -92,7 +92,7 @@ void smooth_shape(const FaceRange& faces, typedef typename internal_np::Lookup_named_param_def< internal_np::vertex_is_constrained_t, NamedParameters, - Constant_property_map >::type VCMap; + Static_boolean_property_map >::type VCMap; using parameters::choose_parameter; using parameters::get_parameter; @@ -101,7 +101,7 @@ void smooth_shape(const FaceRange& faces, VertexPointMap vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point), get_property_map(CGAL::vertex_point, tmesh)); VCMap vcmap = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained), - Constant_property_map(false)); + Static_boolean_property_map()); const unsigned int nb_iterations = choose_parameter(get_parameter(np, internal_np::number_of_iterations), 1); #if defined(CGAL_EIGEN3_ENABLED) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp index c00c1fee0d3..f86ef0983b0 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp @@ -378,7 +378,7 @@ public Q_SLOTS: *selection_item->polyhedron(), selection_item->constrained_edges_pmap(), get(CGAL::vertex_point, *selection_item->polyhedron()), - CGAL::Static_property_map(1), + CGAL::Constant_property_map(1), 4. / 3. * target_length)) { QApplication::restoreOverrideCursor(); @@ -578,7 +578,7 @@ public Q_SLOTS: pmesh, ecm, get(CGAL::vertex_point, pmesh), - CGAL::Static_property_map(1), + CGAL::Constant_property_map(1), 4. / 3. * target_length)) { QApplication::restoreOverrideCursor(); diff --git a/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_features.h b/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_features.h index dc2069dd7f9..b74fd55f97c 100644 --- a/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_features.h +++ b/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_features.h @@ -27,8 +27,8 @@ BOOST_MPL_HAS_XXX_TRAIT_DEF(Plane_3) template struct Get_static_property_map { typedef boost::graph_traits > Graph_traits; - typedef CGAL::Static_property_map > type; + typedef CGAL::Constant_property_map > type; }; } // end namespace internal diff --git a/Property_map/include/CGAL/property_map.h b/Property_map/include/CGAL/property_map.h index c5c78786f5e..6228d3ec392 100644 --- a/Property_map/include/CGAL/property_map.h +++ b/Property_map/include/CGAL/property_map.h @@ -35,37 +35,7 @@ namespace CGAL { /// \cond SKIP_DOXYGEN -/// This class is almost the same as boost::static_property_map -/// The difference is that it is writable, although put() does nothing -template -class Static_property_map -{ -public: - typedef K key_type; - typedef V value_type; - typedef const V& reference; - typedef boost::read_write_property_map_tag category; - -private: - V v; - -public: - Static_property_map(V pv) - :v(pv){} - inline friend - value_type - get(const Static_property_map& pm, const key_type&) - { - return pm.v; - } - - inline friend - void - put(Static_property_map&, const key_type&, const value_type&) - {} -}; - -/// Similar to Static_property_map but retricted to bool and the value is const at compile time +/// A boolean property map return a const value at compile time template class Static_boolean_property_map { diff --git a/Surface_mesh/include/CGAL/boost/graph/properties_Surface_mesh_features.h b/Surface_mesh/include/CGAL/boost/graph/properties_Surface_mesh_features.h index 8ba1a3c1bee..b3881cb789e 100644 --- a/Surface_mesh/include/CGAL/boost/graph/properties_Surface_mesh_features.h +++ b/Surface_mesh/include/CGAL/boost/graph/properties_Surface_mesh_features.h @@ -36,7 +36,7 @@ struct property_map, CGAL::face_patch_id_t > typedef typename boost::graph_traits >::face_descriptor face_descriptor; - typedef CGAL::Static_property_map >::face_descriptor,std::pair > type; + typedef CGAL::Constant_property_map >::face_descriptor,std::pair > type; typedef type const_type; }; @@ -111,7 +111,7 @@ template CGAL_PROPERTY_SURFACE_MESH_RETURN_TYPE(CGAL::face_patch_id_t) inline get(CGAL::face_patch_id_t, const Surface_mesh

&) { - typedef CGAL::Static_property_map >::face_descriptor,std::pair > Pmap; + typedef CGAL::Constant_property_map >::face_descriptor,std::pair > Pmap; return Pmap(std::make_pair(0,1)); } From 2169dd52aa3a2fc3d25920d0e27c00d9dea09461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 18 May 2020 08:49:14 +0200 Subject: [PATCH 6/8] warnings + compilation fixes --- .../CGAL/Polygon_mesh_processing/connected_components.h | 3 --- .../include/CGAL/Polygon_mesh_processing/remesh.h | 2 +- Property_map/include/CGAL/property_map.h | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 1ed128cb15b..15ebc54181f 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -582,12 +582,9 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh using parameters::is_default_parameter; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename boost::graph_traits::face_iterator face_iterator; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef typename boost::graph_traits::vertex_iterator vertex_iterator; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::edge_descriptor edge_descriptor; - typedef typename boost::graph_traits::edge_iterator edge_iterator; typedef typename GetInitializedVertexIndexMap::type VertexIndexMap; VertexIndexMap vim = get_initialized_vertex_index_map(pmesh, np); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h index ece8e7f1410..0f2e6397242 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h @@ -168,7 +168,7 @@ void isotropic_remeshing(const FaceRange& faces Static_boolean_property_map // default (no constraint pmap) > ::type ECMap; ECMap ecmap = choose_parameter(get_parameter(np, internal_np::edge_is_constrained), - Static_boolean_property_map()); + Static_boolean_property_map()); typedef typename internal_np::Lookup_named_param_def < internal_np::vertex_is_constrained_t, diff --git a/Property_map/include/CGAL/property_map.h b/Property_map/include/CGAL/property_map.h index 6228d3ec392..a4563a6ab60 100644 --- a/Property_map/include/CGAL/property_map.h +++ b/Property_map/include/CGAL/property_map.h @@ -49,14 +49,14 @@ public: inline friend value_type - get(const Static_boolean_property_map&, const key_type&) + get(Static_boolean_property_map, const key_type&) { return default_value; } inline friend void - put(Static_boolean_property_map&, const key_type&, const value_type&) + put(Static_boolean_property_map, const key_type&, const value_type&) {} }; From 6982b256015ad223f5e68c6b96f0d92a1e9d4458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 12 Aug 2020 15:43:39 +0200 Subject: [PATCH 7/8] try to avoid a conversion warning --- BGL/examples/BGL_polyhedron_3/normals.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BGL/examples/BGL_polyhedron_3/normals.cpp b/BGL/examples/BGL_polyhedron_3/normals.cpp index dbdca040ef5..b74b56183f1 100644 --- a/BGL/examples/BGL_polyhedron_3/normals.cpp +++ b/BGL/examples/BGL_polyhedron_3/normals.cpp @@ -82,7 +82,7 @@ int main(int argc, char** argv) // http://www.boost.org/libs/property_map/doc/vector_property_map.html // for details. boost::vector_property_map - normals(num_faces(P), get(CGAL::face_index, P)); + normals(static_cast(num_faces(P)), get(CGAL::face_index, P)); calculate_face_normals( P // Graph From 40f297e3e3faeae7f16d4f075e70f578611cd2e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 17 Aug 2020 17:07:17 +0200 Subject: [PATCH 8/8] more conversion warnings unsigned is hardcoded in boost --- BGL/examples/BGL_LCC/normals_lcc.cpp | 2 +- .../Polygon_mesh_processing/connected_components.h | 10 +++++----- .../include/CGAL/Polygon_mesh_processing/repair.h | 2 +- .../connected_component_polyhedron.cpp | 6 +++--- .../Plugins/PMP/Join_and_split_polyhedra_plugin.cpp | 2 +- .../PMP/Scene_facegraph_item_k_ring_selection.h | 2 +- Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/BGL/examples/BGL_LCC/normals_lcc.cpp b/BGL/examples/BGL_LCC/normals_lcc.cpp index 6779fccb616..1baa386b724 100644 --- a/BGL/examples/BGL_LCC/normals_lcc.cpp +++ b/BGL/examples/BGL_LCC/normals_lcc.cpp @@ -74,7 +74,7 @@ int main(int argc, char** argv) // http://www.boost.org/libs/property_map/doc/vector_property_map.html // for details. boost::vector_property_map - normals(num_faces(lcc), get(CGAL::face_index, lcc)); + normals(static_cast(num_faces(lcc)), get(CGAL::face_index, lcc)); calculate_face_normals( lcc // Graph diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 15ebc54181f..e51e9949cad 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -387,7 +387,7 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh, Output_iterator out = choose_parameter(get_parameter(np, internal_np::output_iterator)); // vector_property_map - boost::vector_property_map face_cc(num_faces(pmesh), fimap); + boost::vector_property_map face_cc(static_cast(num_faces(pmesh)), fimap); std::size_t num = connected_components(pmesh, face_cc, np); // Even if we do not want to keep anything we need to first @@ -518,7 +518,7 @@ std::size_t keep_large_connected_components(PolygonMesh& pmesh, Output_iterator out = choose_parameter(get_parameter(np, internal_np::output_iterator)); // vector_property_map - boost::vector_property_map face_cc(num_faces(pmesh), fim); + boost::vector_property_map face_cc(static_cast(num_faces(pmesh)), fim); std::size_t num = connected_components(pmesh, face_cc, np); std::vector component_size(num, 0); @@ -593,7 +593,7 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh for(std::size_t i : components_to_keep) cc_to_keep.insert(i); - boost::vector_property_map keep_vertex(num_vertices(pmesh), vim); + boost::vector_property_map keep_vertex(static_cast(num_vertices(pmesh)), vim); for(vertex_descriptor v : vertices(pmesh)) keep_vertex[v] = false; @@ -831,7 +831,7 @@ void remove_connected_components(PolygonMesh& pmesh typedef typename CGAL::GetInitializedFaceIndexMap::type FaceIndexMap; FaceIndexMap fim = CGAL::get_initialized_face_index_map(pmesh, np); - boost::vector_property_map face_cc(num_faces(pmesh), fim); + boost::vector_property_map face_cc(static_cast(num_faces(pmesh)), fim); connected_components(pmesh, face_cc, np); std::vector cc_to_remove; @@ -881,7 +881,7 @@ void keep_connected_components(PolygonMesh& pmesh typedef typename CGAL::GetInitializedFaceIndexMap::type FaceIndexMap; FaceIndexMap fim = CGAL::get_initialized_face_index_map(pmesh, np); - boost::vector_property_map face_cc(num_faces(pmesh), fim); + boost::vector_property_map face_cc(static_cast(num_faces(pmesh)), fim); connected_components(pmesh, face_cc, np); std::vector cc_to_keep; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h index 5bfa2a7a839..02826228eb1 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h @@ -179,7 +179,7 @@ std::size_t remove_connected_components_of_negligible_size(TriangleMesh& tmesh, return 0; // Compute the connected components only once - boost::vector_property_map face_cc(num_faces(tmesh), fim); + boost::vector_property_map face_cc(static_cast(num_faces(tmesh)), fim); std::size_t num = connected_components(tmesh, face_cc, np); #ifdef CGAL_PMP_DEBUG_SMALL_CC_REMOVAL diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp index c4eaac08ec5..45ad5168a05 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp @@ -38,7 +38,7 @@ void mesh_with_id(const char* argv1, const bool save_output) boost::vector_property_map::type> - fccmap(num_faces(sm), get(CGAL::face_index,sm)); + fccmap(static_cast(num_faces(sm)), get(CGAL::face_index,sm)); std::size_t num = PMP::connected_components(sm, fccmap); if (strcmp(argv1, "data/blobby_3cc.off") == 0) @@ -92,7 +92,7 @@ void mesh_no_id(const char* argv1, const bool save_output) boost::vector_property_map::type> - fccmap(num_faces(sm), fim); + fccmap(static_cast(num_faces(sm)), fim); std::size_t num = PMP::connected_components(sm, fccmap); @@ -133,7 +133,7 @@ void test_border_cases() boost::vector_property_map::type> - fccmap(num_faces(sm), get(boost::face_index,sm)); + fccmap(static_cast(num_faces(sm)), get(boost::face_index,sm)); PMP::connected_components(sm, fccmap); std::size_t nb_faces=num_faces(sm); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Join_and_split_polyhedra_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Join_and_split_polyhedra_plugin.cpp index f64b7f2da36..e2c4d3b576d 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Join_and_split_polyhedra_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Join_and_split_polyhedra_plugin.cpp @@ -237,7 +237,7 @@ void Polyhedron_demo_join_and_split_polyhedra_plugin::on_actionColorConnectedCom = get(boost::face_index, pmesh); boost::vector_property_map::type> - fccmap(num_faces(pmesh),fim); + fccmap(static_cast(num_faces(pmesh)),fim); boost::property_map >::type pid = get(CGAL::face_patch_id_t(), pmesh); 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 6331d623a70..e83fbd4637a 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 @@ -273,7 +273,7 @@ public Q_SLOTS: boost::vector_property_map::type> - fccmap(num_faces(poly)); + fccmap(static_cast(num_faces(poly))); //get connected componant from the picked face std::set final_sel; diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp index c904ac3ff38..24e43fde5b2 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp @@ -1606,7 +1606,7 @@ QString Scene_surface_mesh_item::computeStats(int type) { boost::vector_property_map::type> - fccmap(num_faces(*(d->smesh_)), get(boost::face_index, *(d->smesh_))); + fccmap(static_cast(num_faces(*(d->smesh_))), get(boost::face_index, *(d->smesh_))); return QString::number(CGAL::Polygon_mesh_processing::connected_components(*(d->smesh_), fccmap)); } case NB_BORDER_EDGES: