move function to init index maps to BGL

This commit is contained in:
Sébastien Loriot 2017-01-18 16:30:51 +01:00
parent b3340608cc
commit 3fa4abe869
5 changed files with 130 additions and 126 deletions

View File

@ -30,9 +30,6 @@
#include <CGAL/boost/graph/helpers.h>
#include <CGAL/property_map.h>
#include <boost/unordered_map.hpp>
#include <boost/dynamic_bitset.hpp> /// \TODO not needed
#include <CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h> /// \TODO extract code from this file!
namespace CGAL {
@ -184,8 +181,8 @@ void copy_face_graph(const SourceMesh& sm, TargetMesh& tm,
// init halfedge index map
/// \TODO shall we keep that?
Corefinement::init_halfedge_indices(const_cast<SourceMesh&>(sm),
get(boost::halfedge_index, sm));
helpers::init_halfedge_indices(const_cast<SourceMesh&>(sm),
get(boost::halfedge_index, sm));
copy_face_graph_impl(sm, tm,
bind_property_maps(get(boost::halfedge_index, sm),

View File

@ -23,6 +23,7 @@
#include <CGAL/property_map.h>
#include <boost/graph/properties.hpp>
#include <boost/graph/graph_traits.hpp>
#include <CGAL/basic.h>
#include <string>
@ -105,4 +106,127 @@ using boost::face_external_index;
using boost::vertex_property_t;
} // CGAL
namespace CGAL{
namespace helpers {
// matches read-write property maps
template <class PolygonMesh, class FaceIndexMap, class Tag>
void init_face_indices(PolygonMesh& pm,
FaceIndexMap& fid,
boost::read_write_property_map_tag,
Tag)
{
typename boost::property_traits<FaceIndexMap>::value_type i = 0;
BOOST_FOREACH(typename boost::graph_traits<PolygonMesh>::face_descriptor fd,
faces(pm))
{
put(fid, fd, i);
++i;
}
}
template <class PolygonMesh, class VertexIndexMap, class Tag>
void init_vertex_indices(PolygonMesh& pm,
VertexIndexMap& vid,
boost::read_write_property_map_tag,
Tag)
{
typename boost::property_traits<VertexIndexMap>::value_type i = 0;
BOOST_FOREACH(typename boost::graph_traits<PolygonMesh>::vertex_descriptor vd,
vertices(pm))
{
put(vid, vd, i);
++i;
}
}
template <class PolygonMesh, class HalfedgeIndexMap, class Tag>
void init_halfedge_indices(PolygonMesh& pm,
HalfedgeIndexMap& hid,
boost::read_write_property_map_tag,
Tag)
{
typename boost::property_traits<HalfedgeIndexMap>::value_type i = 0;
BOOST_FOREACH(typename boost::graph_traits<PolygonMesh>::halfedge_descriptor hd,
halfedges(pm))
{
put(hid, hd, i);
++i;
}
}
// matches mutable Lvalue property maps
template <class PolygonMesh, class FaceIndexMap>
void init_face_indices(PolygonMesh& pm,
FaceIndexMap& fid,
boost::lvalue_property_map_tag,
boost::false_type)
{
init_face_indices(pm, fid,
boost::read_write_property_map_tag(), boost::false_type());
}
template <class PolygonMesh, class VertexIndexMap>
void init_vertex_indices(PolygonMesh& pm,
VertexIndexMap& vid,
boost::lvalue_property_map_tag,
boost::false_type)
{
init_vertex_indices(pm, vid,
boost::read_write_property_map_tag(), boost::false_type());
}
template <class PolygonMesh, class HalfedgeIndexMap>
void init_halfedge_indices(PolygonMesh& pm,
HalfedgeIndexMap& hid,
boost::lvalue_property_map_tag,
boost::false_type)
{
init_halfedge_indices(pm, hid,
boost::read_write_property_map_tag(), boost::false_type());
}
// matches all other types of property map
template <class PolygonMesh, class FaceIndexMap, class MapTag, class Tag>
void init_face_indices(PolygonMesh&, FaceIndexMap, MapTag, Tag)
{}
template <class PolygonMesh, class VertexIndexMap, class MapTag, class Tag>
void init_vertex_indices(PolygonMesh&, VertexIndexMap, MapTag, Tag)
{}
template <class PolygonMesh, class HalfedgeIndexMap, class MapTag, class Tag>
void init_halfedge_indices(PolygonMesh&, HalfedgeIndexMap, MapTag, Tag)
{}
template <class PolygonMesh, class FaceIndexMap>
void init_face_indices(PolygonMesh& pm, FaceIndexMap fid)
{
init_face_indices(pm, fid,
typename boost::property_traits<FaceIndexMap>::category(),
typename boost::is_const<
typename boost::remove_reference<
typename boost::property_traits<FaceIndexMap>::reference
>::type >::type() );
}
template <class PolygonMesh, class VertexIndexMap>
void init_vertex_indices(PolygonMesh& pm, VertexIndexMap vid)
{
init_vertex_indices(pm, vid,
typename boost::property_traits<VertexIndexMap>::category(),
typename boost::is_const<
typename boost::remove_reference<
typename boost::property_traits<VertexIndexMap>::reference
>::type >::type() );
}
template <class PolygonMesh, class HalfedgeIndexMap>
void init_halfedge_indices(PolygonMesh& pm, HalfedgeIndexMap hid)
{
init_halfedge_indices(pm, hid,
typename boost::property_traits<HalfedgeIndexMap>::category(),
typename boost::is_const<
typename boost::remove_reference<
typename boost::property_traits<HalfedgeIndexMap>::reference
>::type >::type() );
}
} } //end of namespace CGAL::helpers
#endif // CGAL_BOOST_GRAPH_BGL_PROPERTIES_H

View File

@ -394,8 +394,8 @@ public:
CGAL_assertion(intersection_edges1.size()==intersection_edges2.size());
// this will initialize face indices if the face index map is writable.
init_face_indices(tm1, fids1);
init_face_indices(tm2, fids2);
helpers::init_face_indices(tm1, fids1);
helpers::init_face_indices(tm2, fids2);
// bitset to identify coplanar faces
boost::dynamic_bitset<> tm1_coplanar_faces(num_faces(tm1), 0);

View File

@ -31,123 +31,6 @@
namespace CGAL {
namespace Corefinement {
// matches read-write property maps
template <class PolygonMesh, class FaceIndexMap, class Tag>
void init_face_indices(PolygonMesh& pm,
FaceIndexMap& fid,
boost::read_write_property_map_tag,
Tag)
{
typename boost::property_traits<FaceIndexMap>::value_type i = 0;
BOOST_FOREACH(typename boost::graph_traits<PolygonMesh>::face_descriptor fd,
faces(pm))
{
put(fid, fd, i);
++i;
}
}
template <class PolygonMesh, class VertexIndexMap, class Tag>
void init_vertex_indices(PolygonMesh& pm,
VertexIndexMap& vid,
boost::read_write_property_map_tag,
Tag)
{
typename boost::property_traits<VertexIndexMap>::value_type i = 0;
BOOST_FOREACH(typename boost::graph_traits<PolygonMesh>::vertex_descriptor vd,
vertices(pm))
{
put(vid, vd, i);
++i;
}
}
template <class PolygonMesh, class HalfedgeIndexMap, class Tag>
void init_halfedge_indices(PolygonMesh& pm,
HalfedgeIndexMap& hid,
boost::read_write_property_map_tag,
Tag)
{
typename boost::property_traits<HalfedgeIndexMap>::value_type i = 0;
BOOST_FOREACH(typename boost::graph_traits<PolygonMesh>::halfedge_descriptor hd,
halfedges(pm))
{
put(hid, hd, i);
++i;
}
}
// matches mutable Lvalue property maps
template <class PolygonMesh, class FaceIndexMap>
void init_face_indices(PolygonMesh& pm,
FaceIndexMap& fid,
boost::lvalue_property_map_tag,
boost::false_type)
{
init_face_indices(pm, fid,
boost::read_write_property_map_tag(), boost::false_type());
}
template <class PolygonMesh, class VertexIndexMap>
void init_vertex_indices(PolygonMesh& pm,
VertexIndexMap& vid,
boost::lvalue_property_map_tag,
boost::false_type)
{
init_vertex_indices(pm, vid,
boost::read_write_property_map_tag(), boost::false_type());
}
template <class PolygonMesh, class HalfedgeIndexMap>
void init_halfedge_indices(PolygonMesh& pm,
HalfedgeIndexMap& hid,
boost::lvalue_property_map_tag,
boost::false_type)
{
init_halfedge_indices(pm, hid,
boost::read_write_property_map_tag(), boost::false_type());
}
// matches all other types of property map
template <class PolygonMesh, class FaceIndexMap, class MapTag, class Tag>
void init_face_indices(PolygonMesh&, FaceIndexMap, MapTag, Tag)
{}
template <class PolygonMesh, class VertexIndexMap, class MapTag, class Tag>
void init_vertex_indices(PolygonMesh&, VertexIndexMap, MapTag, Tag)
{}
template <class PolygonMesh, class HalfedgeIndexMap, class MapTag, class Tag>
void init_halfedge_indices(PolygonMesh&, HalfedgeIndexMap, MapTag, Tag)
{}
template <class PolygonMesh, class FaceIndexMap>
void init_face_indices(PolygonMesh& pm, FaceIndexMap fid)
{
init_face_indices(pm, fid,
typename boost::property_traits<FaceIndexMap>::category(),
typename boost::is_const<
typename boost::remove_reference<
typename boost::property_traits<FaceIndexMap>::reference
>::type >::type() );
}
template <class PolygonMesh, class VertexIndexMap>
void init_vertex_indices(PolygonMesh& pm, VertexIndexMap vid)
{
init_vertex_indices(pm, vid,
typename boost::property_traits<VertexIndexMap>::category(),
typename boost::is_const<
typename boost::remove_reference<
typename boost::property_traits<VertexIndexMap>::reference
>::type >::type() );
}
template <class PolygonMesh, class HalfedgeIndexMap>
void init_halfedge_indices(PolygonMesh& pm, HalfedgeIndexMap hid)
{
init_halfedge_indices(pm, hid,
typename boost::property_traits<HalfedgeIndexMap>::category(),
typename boost::is_const<
typename boost::remove_reference<
typename boost::property_traits<HalfedgeIndexMap>::reference
>::type >::type() );
}
template <typename G>
struct No_mark
{

View File

@ -68,8 +68,8 @@ clip_open_impl( TriangleMesh& tm,
get_property_map(vertex_point, clipper));
// init indices if needed
Corefinement::init_face_indices(tm, fid_map);
Corefinement::init_vertex_indices(tm, vid_map);
helpers::init_face_indices(tm, fid_map);
helpers::init_vertex_indices(tm, vid_map);
// set the connected component id of each face
std::vector<std::size_t> face_cc(num_faces(tm), std::size_t(-1));