mirror of https://github.com/CGAL/cgal
Add property maps for simplex mapping.
Also adds an operator()(const T&){} to Emptyset_iterator so it can be used by boost::function_output_iterator().
This commit is contained in:
parent
6623d3633f
commit
cd6ffdc12a
|
|
@ -143,6 +143,36 @@ operation.\n
|
|||
<b>Default:</b> Emptyset_iterator
|
||||
\cgalNPEnd
|
||||
|
||||
\cgalNPBegin{vertex_to_vertex_map} \anchor BGL_vertex_to_vertex_map
|
||||
is a property map storing for each vertex of a source mesh the corresponding vertex of another mesh.\n
|
||||
A typical use case is mapping the vertices from a source mesh to its copy's after a `copy_face_graph()`
|
||||
operation.\n
|
||||
<b>Type:</b>a class model of `ReadWritePropertyMap` with
|
||||
`boost::graph_traits<PolygonMesh1>::%vertex_descriptor` as key type and
|
||||
`boost::graph_traits<PolygonMesh2>::%vertex_descriptor` as value type.\n
|
||||
<b>Default:</b> None.
|
||||
\cgalNPEnd
|
||||
|
||||
\cgalNPBegin{halfedge_to_halfedge_map} \anchor BGL_halfedge_to_halfedge_map
|
||||
is a property map storing for each halfedge of a source mesh the corresponding halfedge of another mesh.\n
|
||||
A typical use case is mapping the vertices from a source mesh to its copy's after a `copy_face_graph()`
|
||||
operation.\n
|
||||
<b>Type:</b>a class model of `ReadWritePropertyMap` with
|
||||
`boost::graph_traits<PolygonMesh1>::%halfedge_descriptor` as key type and
|
||||
`boost::graph_traits<PolygonMesh2>::%halfedge_descriptor` as value type.\n
|
||||
<b>Default:</b> None.
|
||||
\cgalNPEnd
|
||||
|
||||
\cgalNPBegin{face_to_face_map} \anchor BGL_face_to_face_map
|
||||
is a property map storing for each face of a source mesh the corresponding face of another mesh.\n
|
||||
A typical use case is mapping the vertices from a source mesh to its copy's after a `copy_face_graph()`
|
||||
operation.\n
|
||||
<b>Type:</b>a class model of `ReadWritePropertyMap` with
|
||||
`boost::graph_traits<PolygonMesh1>::%face_descriptor` as key type and
|
||||
`boost::graph_traits<PolygonMesh2>::%face_descriptor` as value type.\n
|
||||
<b>Default:</b> None.
|
||||
\cgalNPEnd
|
||||
|
||||
|
||||
|
||||
\cgalNPTableEnd
|
||||
|
|
|
|||
|
|
@ -67,16 +67,23 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
typedef boost::graph_traits<Target1>::vertex_descriptor source_vertex_descriptor;
|
||||
typedef boost::graph_traits<Target1>::halfedge_descriptor source_halfedge_descriptor;
|
||||
typedef boost::graph_traits<Target1>::face_descriptor source_face_descriptor;
|
||||
|
||||
typedef boost::graph_traits<Source>::vertex_descriptor tm_vertex_descriptor;
|
||||
typedef boost::graph_traits<Source>::halfedge_descriptor tm_halfedge_descriptor;
|
||||
typedef boost::graph_traits<Source>::face_descriptor tm_face_descriptor;
|
||||
|
||||
|
||||
boost::unordered_map<source_vertex_descriptor, tm_vertex_descriptor> v2v;
|
||||
boost::unordered_map<source_halfedge_descriptor, tm_halfedge_descriptor> h2h;
|
||||
|
||||
boost::unordered_map<source_face_descriptor, tm_face_descriptor> f2f;
|
||||
CGAL::copy_face_graph(T1, S, std::inserter(v2v, v2v.end()), std::inserter(h2h, h2h.end()));
|
||||
std::ofstream out("reverse.off");
|
||||
out << S;
|
||||
CGAL::copy_face_graph(T1, S, CGAL::parameters::vertex_to_vertex_map(boost::make_assoc_property_map(v2v))
|
||||
.halfedge_to_halfedge_output_iterator(std::inserter(h2h, h2h.end()))
|
||||
.face_to_face_map(boost::make_assoc_property_map(f2f)));
|
||||
CGAL::copy_face_graph(T1, S);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#include <CGAL/property_map.h>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/function_output_iterator.hpp>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
|
|
@ -211,6 +212,35 @@ void copy_face_graph(const SourceMesh& sm, TargetMesh& tm,
|
|||
sm_vpm, tm_vpm);
|
||||
}
|
||||
|
||||
template<typename PMAP>
|
||||
struct Output_iterator_functor
|
||||
{
|
||||
typedef typename boost::property_traits<PMAP>::key_type input_t;
|
||||
typedef typename boost::property_traits<PMAP>::value_type output_t;
|
||||
PMAP map;
|
||||
Output_iterator_functor(PMAP map)
|
||||
:map(map)
|
||||
{
|
||||
}
|
||||
void operator()(const typename std::pair<input_t, output_t>& pair)
|
||||
{
|
||||
put(map, pair.first, pair.second);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<typename PMAP>
|
||||
Output_iterator_functor<PMAP> make_functor(PMAP map)
|
||||
{
|
||||
return Output_iterator_functor<PMAP>(map);
|
||||
}
|
||||
|
||||
Emptyset_iterator make_functor(const boost::param_not_found&)
|
||||
{
|
||||
return Emptyset_iterator();
|
||||
}
|
||||
|
||||
|
||||
} // end of namespace internal
|
||||
|
||||
|
||||
|
|
@ -242,14 +272,26 @@ void copy_face_graph(const SourceMesh& sm, TargetMesh& tm,
|
|||
If this parameter is omitted, an internal property map for
|
||||
`CGAL::vertex_point_t` should be available in `SourceMesh` (`TargetMesh`)
|
||||
\cgalParamEnd
|
||||
\cgalParamBegin{vertex_to_vertex_output_iterator} an `OutputIterator`containing the
|
||||
pairs source-vertex, traget-vertex.
|
||||
\cgalParamBegin{vertex_to_vertex_output_iterator} an `OutputIterator` containing the
|
||||
pairs source-vertex, target-vertex. If this parameter is given, then
|
||||
`vertex_to_vertex_map` cannot be used.
|
||||
\cgalParamEnd
|
||||
\cgalParamBegin{halfedge_to_halfedge_output_iterator} an `OutputIterator`containing the
|
||||
pairs source-halfedge, traget-halfedge.
|
||||
\cgalParamBegin{halfedge_to_halfedge_output_iterator} an `OutputIterator` containing the
|
||||
pairs source-halfedge, target-halfedge. If this parameter is given, then
|
||||
`halfedge_to_halfedge_map` cannot be used.
|
||||
\cgalParamEnd
|
||||
\cgalParamBegin{face_to_face_output_iterator} an `OutputIterator`containing the
|
||||
pairs source-face, traget-face.
|
||||
\cgalParamBegin{face_to_face_output_iterator} an `OutputIterator` containing the
|
||||
pairs source-face, target-face. If this parameter is given, then
|
||||
`face_to_face_map` cannot be used.
|
||||
\cgalParamEnd
|
||||
\cgalParamBegin{vertex_to_vertex_map} a `ReadWritePropertyMap` containing the
|
||||
pairs source-vertex, target-vertex.
|
||||
\cgalParamEnd
|
||||
\cgalParamBegin{halfedge_to_halfedge_map} a `ReadWritePropertyMap` containing the
|
||||
pairs source-halfedge, target-halfedge.
|
||||
\cgalParamEnd
|
||||
\cgalParamBegin{face_to_face_map} a `ReadWritePropertyMap` containing the
|
||||
pairs source-face, target-face.
|
||||
\cgalParamEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
|
|
@ -289,6 +331,49 @@ void copy_face_graph(const SourceMesh& sm, TargetMesh& tm,
|
|||
)
|
||||
{
|
||||
using boost::choose_param;
|
||||
if (boost::is_default_param(get_param(np1, internal_np::vertex_to_vertex_output_iterator)))
|
||||
{
|
||||
if (boost::is_default_param(get_param(np1, internal_np::vertex_to_vertex_map))){
|
||||
copy_face_graph(sm, tm, CGAL::parameters::
|
||||
vertex_to_vertex_output_iterator(
|
||||
boost::make_function_output_iterator(internal::make_functor(get_param(np1, internal_np::vertex_to_vertex_map))))
|
||||
.halfedge_to_halfedge_output_iterator(get_param(np1, internal_np::halfedge_to_halfedge_output_iterator))
|
||||
.face_to_face_output_iterator(get_param(np1, internal_np::face_to_face_output_iterator))
|
||||
.halfedge_to_halfedge_map(get_param(np1, internal_np::halfedge_to_halfedge_map))
|
||||
.face_to_face_map(get_param(np1, internal_np::face_to_face_map))
|
||||
,np2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (!boost::is_default_param(get_param(np1, internal_np::halfedge_to_halfedge_output_iterator)))
|
||||
{
|
||||
if (!boost::is_default_param(get_param(np1, internal_np::halfedge_to_halfedge_map))){
|
||||
copy_face_graph(sm, tm, CGAL::parameters::
|
||||
vertex_to_vertex_output_iterator(get_param(np1, internal_np::vertex_to_vertex_output_iterator))
|
||||
.halfedge_to_halfedge_output_iterator(
|
||||
boost::make_function_output_iterator(internal::make_functor(get_param(np1, internal_np::halfedge_to_halfedge_map))))
|
||||
.face_to_face_output_iterator(get_param(np1, internal_np::face_to_face_output_iterator))
|
||||
.vertex_to_vertex_map(get_param(np1, internal_np::vertex_to_vertex_map))
|
||||
.face_to_face_map(get_param(np1, internal_np::face_to_face_map))
|
||||
,np2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (!boost::is_default_param(get_param(np1, internal_np::face_to_face_output_iterator)))
|
||||
{
|
||||
if (!boost::is_default_param(get_param(np1, internal_np::face_to_face_map)))
|
||||
{
|
||||
copy_face_graph(sm, tm, CGAL::parameters::
|
||||
vertex_to_vertex_output_iterator(get_param(np1, internal_np::vertex_to_vertex_output_iterator))
|
||||
.halfedge_to_halfedge_output_iterator(get_param(np1, internal_np::halfedge_to_halfedge_output_iterator))
|
||||
.face_to_face_output_iterator(
|
||||
boost::make_function_output_iterator(internal::make_functor(get_param(np1, internal_np::face_to_face_map))))
|
||||
.vertex_to_vertex_map(get_param(np1, internal_np::vertex_to_vertex_map))
|
||||
.halfedge_to_halfedge_map(get_param(np1, internal_np::halfedge_to_halfedge_map))
|
||||
,np2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
internal::copy_face_graph(sm, tm,
|
||||
CGAL::graph_has_property<SourceMesh,boost::halfedge_index_t>(),
|
||||
choose_param(get_param(np1, internal_np::vertex_to_vertex_output_iterator),
|
||||
|
|
@ -300,7 +385,7 @@ void copy_face_graph(const SourceMesh& sm, TargetMesh& tm,
|
|||
choose_param(get_param(np1, internal_np::vertex_point),
|
||||
get(vertex_point, sm)),
|
||||
choose_param(get_param(np2, internal_np::vertex_point),
|
||||
get(vertex_point, tm)));
|
||||
get(vertex_point, tm)));
|
||||
}
|
||||
|
||||
template <typename SourceMesh, typename TargetMesh>
|
||||
|
|
|
|||
|
|
@ -37,6 +37,10 @@ CGAL_add_named_parameter(vertex_to_vertex_output_iterator_t, vertex_to_vertex_ou
|
|||
CGAL_add_named_parameter(halfedge_to_halfedge_output_iterator_t, halfedge_to_halfedge_output_iterator, halfedge_to_halfedge_output_iterator)
|
||||
CGAL_add_named_parameter(face_to_face_output_iterator_t, face_to_face_output_iterator, face_to_face_output_iterator)
|
||||
|
||||
CGAL_add_named_parameter(vertex_to_vertex_map_t, vertex_to_vertex_map, vertex_to_vertex_map)
|
||||
CGAL_add_named_parameter(halfedge_to_halfedge_map_t, halfedge_to_halfedge_map, halfedge_to_halfedge_map)
|
||||
CGAL_add_named_parameter(face_to_face_map_t, face_to_face_map, face_to_face_map)
|
||||
|
||||
// List of named parameters that we use in the package 'Mesh_3'
|
||||
CGAL_add_named_parameter(vertex_feature_degree_t, vertex_feature_degree, vertex_feature_degree_map)
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,10 @@ void test(const NamedParameters& np)
|
|||
assert(get_param(np, CGAL::internal_np::halfedge_to_halfedge_output_iterator).v == 800000005);
|
||||
assert(get_param(np, CGAL::internal_np::face_to_face_output_iterator).v == 800000006);
|
||||
|
||||
assert(get_param(np, CGAL::internal_np::vertex_to_vertex_map).v == 800000007);
|
||||
assert(get_param(np, CGAL::internal_np::halfedge_to_halfedge_map).v == 800000008);
|
||||
assert(get_param(np, CGAL::internal_np::face_to_face_map).v == 800000009);
|
||||
|
||||
|
||||
// Named parameters that we use in the package 'Mesh_3'
|
||||
assert(get_param(np, CGAL::internal_np::vertex_feature_degree).v == 9);
|
||||
|
|
@ -115,6 +119,9 @@ void test(const NamedParameters& np)
|
|||
check_same_type<800000004>(get_param(np, CGAL::internal_np::vertex_to_vertex_output_iterator));
|
||||
check_same_type<800000005>(get_param(np, CGAL::internal_np::halfedge_to_halfedge_output_iterator));
|
||||
check_same_type<800000006>(get_param(np, CGAL::internal_np::face_to_face_output_iterator));
|
||||
check_same_type<800000007>(get_param(np, CGAL::internal_np::vertex_to_vertex_map));
|
||||
check_same_type<800000008>(get_param(np, CGAL::internal_np::halfedge_to_halfedge_map));
|
||||
check_same_type<800000009>(get_param(np, CGAL::internal_np::face_to_face_map));
|
||||
|
||||
// Named parameters that we use in the package 'Mesh_3'
|
||||
check_same_type<9>(get_param(np, CGAL::internal_np::vertex_feature_degree));
|
||||
|
|
@ -177,6 +184,9 @@ int main()
|
|||
.vertex_to_vertex_output_iterator(A<800000004>(800000004))
|
||||
.halfedge_to_halfedge_output_iterator(A<800000005>(800000005))
|
||||
.face_to_face_output_iterator(A<800000006>(800000006))
|
||||
.vertex_to_vertex_map(A<800000007>(800000007))
|
||||
.halfedge_to_halfedge_map(A<800000008>(800000008))
|
||||
.face_to_face_map(A<800000009>(800000009))
|
||||
.vertex_feature_degree_map(A<9>(9))
|
||||
.geom_traits(A<10>(10))
|
||||
.vertex_incident_patches_map(A<11>(11))
|
||||
|
|
|
|||
|
|
@ -113,6 +113,9 @@ struct iterator
|
|||
struct Emptyset_iterator
|
||||
: public CGAL::iterator< std::output_iterator_tag, void, void, void, void >
|
||||
{
|
||||
template<class T>
|
||||
void operator()(const T&) {}
|
||||
|
||||
template< class T >
|
||||
Emptyset_iterator& operator=(const T&) { return *this; }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue