1st pass after review
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
|
||||
#include <CGAL/Lazy.h> // needed for CGAL::exact(FT)/CGAL::exact(Lazy_exact_nt<T>)
|
||||
|
||||
#include <boost/container/small_vector.hpp>
|
||||
#include <boost/unordered_set.hpp>
|
||||
#include <boost/graph/graph_traits.hpp>
|
||||
|
||||
@@ -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<PolygonMesh>::%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<PolygonMesh>::%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<Graph>::%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<PolygonMesh, NamedParameters1>::type VIMap1;
|
||||
typedef typename GetInitializedVertexIndexMap<PolygonMesh, NamedParameters2>::type VIMap2;
|
||||
typedef typename GetInitializedVertexIndexMap<PolygonMesh, NamedParameters1>::const_type VIMap1;
|
||||
typedef typename GetInitializedVertexIndexMap<PolygonMesh, NamedParameters2>::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<std::size_t>(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<std::size_t>(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<std::vector<std::size_t> > m1_faces;
|
||||
std::set<boost::container::small_vector<std::size_t, 4> > m1_faces;
|
||||
for(auto f : faces(m1))
|
||||
{
|
||||
std::vector<std::size_t> ids;
|
||||
boost::container::small_vector<std::size_t, 4> 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<std::size_t>(get(vim1, v))]);
|
||||
}
|
||||
std::sort(ids.begin(), ids.end());
|
||||
m1_faces.insert(ids);
|
||||
}
|
||||
std::map<std::vector<std::size_t>, face_descriptor> m2_faces_map;
|
||||
std::map<boost::container::small_vector<std::size_t, 4>, face_descriptor> m2_faces_map;
|
||||
for(auto f : faces(m2))
|
||||
{
|
||||
std::vector<std::size_t> ids;
|
||||
boost::container::small_vector<std::size_t, 4> 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<std::size_t>(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<std::size_t> ids;
|
||||
boost::container::small_vector<std::size_t, 4> 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<std::size_t>(get(vim1, v))]);
|
||||
}
|
||||
std::sort(ids.begin(), ids.end());
|
||||
auto m2_face_it = m2_faces_map.find(ids);
|
||||
|
||||
Reference in New Issue
Block a user