move property map binders to property_map.h

This commit is contained in:
Sébastien Loriot 2017-01-18 16:12:34 +01:00
parent e50ae3c7bf
commit b3340608cc
6 changed files with 43 additions and 42 deletions

View File

@ -188,8 +188,8 @@ void copy_face_graph(const SourceMesh& sm, TargetMesh& tm,
get(boost::halfedge_index, sm));
copy_face_graph_impl(sm, tm,
Corefinement::bind_maps(get(boost::halfedge_index, sm),
make_property_map(hedges)),
bind_property_maps(get(boost::halfedge_index, sm),
make_property_map(hedges)),
v2v, h2h, f2f,
sm_vpm, tm_vpm);
}

View File

@ -171,7 +171,7 @@ bool does_bound_a_volume(const TriangleMesh& tm, const NamedParameters& np)
// set the connected component id of each face
std::size_t nb_cc = connected_components(tm,
Corefinement::bind_maps(fid_map,make_property_map(face_cc)),
bind_property_maps(fid_map,make_property_map(face_cc)),
parameters::face_index_map(fid_map));
if (nb_cc == 1)

View File

@ -497,7 +497,7 @@ public:
Border_edge_map<TriangleMesh> is_marked_1(intersection_edges1, tm1);
std::size_t nb_patches_tm1 =
PMP::connected_components(tm1,
bind_maps(fids1,make_property_map(&tm1_patch_ids[0])),
bind_property_maps(fids1,make_property_map(&tm1_patch_ids[0])),
params::edge_is_constrained_map(
is_marked_1)
.face_index_map(fids1));
@ -511,7 +511,7 @@ public:
Border_edge_map<TriangleMesh> is_marked_2(intersection_edges2, tm2);
std::size_t nb_patches_tm2 =
PMP::connected_components(tm2,
bind_maps(fids2,make_property_map(&tm2_patch_ids[0])),
bind_property_maps(fids2,make_property_map(&tm2_patch_ids[0])),
params::edge_is_constrained_map(
is_marked_2)
.face_index_map(fids2));

View File

@ -383,41 +383,6 @@ triangulate_a_face(
}
}
template <class KeyMap, class ValueMap>
struct Map_binder{
typedef typename boost::property_traits<KeyMap>::key_type key_type;
typedef typename boost::property_traits<ValueMap>::value_type value_type;
typedef typename boost::property_traits<ValueMap>::reference reference;
typedef boost::read_write_property_map_tag category;
KeyMap key_map;
ValueMap value_map;
Map_binder(const KeyMap& key_map, const ValueMap& value_map)
: key_map(key_map)
, value_map(value_map)
{}
friend
reference get(const Map_binder& map, key_type k)
{
return get(map.value_map, get(map.key_map,k));
}
friend
void put(const Map_binder& map, key_type k, const value_type& v)
{
put(map.value_map, get(map.key_map,k), v);
}
};
template <class KeyMap, class ValueMap>
Map_binder<KeyMap, ValueMap>
bind_maps(const KeyMap& src, const ValueMap& tgt)
{
return Map_binder<KeyMap, ValueMap>(src, tgt);
}
template <class PolygonMesh>
class Border_edge_map {
typedef std::size_t Node_id;

View File

@ -75,7 +75,7 @@ clip_open_impl( TriangleMesh& tm,
std::vector<std::size_t> face_cc(num_faces(tm), std::size_t(-1));
std::size_t nb_cc =
connected_components(tm,
Corefinement::bind_maps(fid_map, make_property_map(face_cc)),
bind_property_maps(fid_map, make_property_map(face_cc)),
parameters::face_index_map(fid_map).
edge_is_constrained_map(ecm));
@ -118,7 +118,7 @@ clip_open_impl( TriangleMesh& tm,
//now remove the cc
remove_connected_components(tm,
ccs_to_remove,
Corefinement::bind_maps(fid_map, make_property_map(face_cc)),
bind_property_maps(fid_map, make_property_map(face_cc)),
np_tm);
return true;

View File

@ -72,6 +72,42 @@ class OR_property_map {
};
// A property map that uses the result of a property map as key.
template <class KeyMap, class ValueMap>
struct Property_map_binder{
typedef typename boost::property_traits<KeyMap>::key_type key_type;
typedef typename boost::property_traits<ValueMap>::value_type value_type;
typedef typename boost::property_traits<ValueMap>::reference reference;
typedef boost::read_write_property_map_tag category;
KeyMap key_map;
ValueMap value_map;
Property_map_binder(const KeyMap& key_map, const ValueMap& value_map)
: key_map(key_map)
, value_map(value_map)
{}
friend
reference get(const Property_map_binder& map, key_type k)
{
return get(map.value_map, get(map.key_map,k));
}
friend
void put(const Property_map_binder& map, key_type k, const value_type& v)
{
put(map.value_map, get(map.key_map,k), v);
}
};
template <class KeyMap, class ValueMap>
Property_map_binder<KeyMap, ValueMap>
bind_property_maps(const KeyMap& src, const ValueMap& tgt)
{
return Property_map_binder<KeyMap, ValueMap>(src, tgt);
}
/// Property map that accesses a value from an iterator
///
/// \cgalModels `ReadablePropertyMap`