diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h index 7ffe2acffd9..87fe506d7e8 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h @@ -28,6 +28,7 @@ #include // needed for CGAL::exact(FT)/CGAL::exact(Lazy_exact_nt) +#include #include #include @@ -825,6 +826,7 @@ centroid(const TriangleMesh& tmesh) * \ingroup measure_grp * given two meshes, separates the faces that are only in one, the faces * that are only in the other one, and the faces that are common to both. + * The orientation of the faces is ignored during the comparison. * * @tparam PolygonMesh a model of `HalfedgeListGraph` and `FaceListGraph` * \tparam FaceRange a mutable range of `boost::graph_traits::%face_descriptor` @@ -835,9 +837,9 @@ centroid(const TriangleMesh& tmesh) * * @param m1 the first `PolygonMesh` * @param m2 the second `PolygonMesh` - * @param common the range containing the faces that are common to both meshes. - * @param m1_only the range containing the faces that are only in `m1` - * @param m2_only the range containing the faces that are only in `m2` + * @param common output range containing the faces that are common to both meshes. + * @param m1_only output range containing the faces that are only in `m1` + * @param m2_only output range containing the faces that are only in `m2` * @param np1 an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * @param np2 an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * @@ -845,9 +847,20 @@ centroid(const TriangleMesh& tmesh) * \cgalParamNBegin{vertex_point_map} * \cgalParamDescription{a property map associating points to the vertices of `m1` (`m2`)} * \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` - * as key type and `%Point_3` as value type} + * as key type and `%Point_3` as value type. `%Point_3` must be LessThanComparable.} * \cgalParamDefault{`boost::get(CGAL::vertex_point, m1 (m2))`} * \cgalParamNEnd + * + * \cgalParamNBegin{vertex_index_map} + * \cgalParamDescription{a property map associating to each vertex of `m1` (`m2`) a unique index between `0` and `num_vertices(m1 (m2)) - 1`} + * \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` + * as key type and `std::size_t` as value type} + * \cgalParamDefault{an automatically indexed internal map} + * \cgalParamExtra{If this parameter is not passed, internal machinery will create and initialize + * a face index property map, either using the internal property map if it exists + * or using an external map. The latter might result in - slightly - worsened performance + * in case of non-constant complexity for index access.} + * \cgalParamNEnd * \cgalNamedParamsEnd * */ @@ -860,8 +873,8 @@ void compare_meshes(const PolygonMesh& m1, const PolygonMesh& m2, using parameters::get_parameter; typedef typename GetVertexPointMap < PolygonMesh, NamedParameters1>::const_type VPMap1; typedef typename GetVertexPointMap < PolygonMesh, NamedParameters2>::const_type VPMap2; - typedef typename GetInitializedVertexIndexMap::type VIMap1; - typedef typename GetInitializedVertexIndexMap::type VIMap2; + typedef typename GetInitializedVertexIndexMap::const_type VIMap1; + typedef typename GetInitializedVertexIndexMap::const_type VIMap2; VPMap1 vpm1 = choose_parameter(get_parameter(np1, internal_np::vertex_point), get_const_property_map(vertex_point, m1)); VPMap2 vpm2 = choose_parameter(get_parameter(np2, internal_np::vertex_point), @@ -883,7 +896,7 @@ void compare_meshes(const PolygonMesh& m1, const PolygonMesh& m2, auto res = point_id_map.insert(std::make_pair(p, id)); if(res.second) id++; - m1_vertex_id[(std::size_t)get(vim1, v)]=res.first->second; + m1_vertex_id[static_cast(get(vim1, v))]=res.first->second; } for(auto v : vertices(m2)) { @@ -891,28 +904,28 @@ void compare_meshes(const PolygonMesh& m1, const PolygonMesh& m2, auto res = point_id_map.insert(std::make_pair(p, id)); if(res.second) id++; - m2_vertex_id[(std::size_t)get(vim2, v)]=res.first->second; + m2_vertex_id[static_cast(get(vim2, v))]=res.first->second; } //fill a set with the "faces point-ids" of m1 and then iterate faces of m2 to compare. - std::set > m1_faces; + std::set > m1_faces; for(auto f : faces(m1)) { - std::vector ids; + boost::container::small_vector ids; for(auto v : CGAL::vertices_around_face(halfedge(f, m1), m1)) { - ids.push_back(m1_vertex_id[(std::size_t)get(vim1, v)]); + ids.push_back(m1_vertex_id[static_cast(get(vim1, v))]); } std::sort(ids.begin(), ids.end()); m1_faces.insert(ids); } - std::map, face_descriptor> m2_faces_map; + std::map, face_descriptor> m2_faces_map; for(auto f : faces(m2)) { - std::vector ids; + boost::container::small_vector ids; for(auto v : CGAL::vertices_around_face(halfedge(f, m2), m2)) { - ids.push_back(m2_vertex_id[(std::size_t)get(vim2, v)]); + ids.push_back(m2_vertex_id[static_cast(get(vim2, v))]); } std::sort(ids.begin(), ids.end()); m2_faces_map.insert({ids, f}); @@ -923,10 +936,10 @@ void compare_meshes(const PolygonMesh& m1, const PolygonMesh& m2, for(auto f : faces(m1)) { - std::vector ids; + boost::container::small_vector ids; for(auto v : CGAL::vertices_around_face(halfedge(f, m1), m1)) { - ids.push_back(m1_vertex_id[(std::size_t)get(vim1, v)]); + ids.push_back(m1_vertex_id[static_cast(get(vim1, v))]); } std::sort(ids.begin(), ids.end()); auto m2_face_it = m2_faces_map.find(ids);