mirror of https://github.com/CGAL/cgal
change the Id in the base class + update pmaps to handle also pairs
This commit is contained in:
parent
aa10bcc5b0
commit
eb8e5e5b35
|
|
@ -30,52 +30,9 @@
|
|||
#include <CGAL/AABB_primitive.h>
|
||||
#include <CGAL/boost/graph/property_maps.h>
|
||||
#include <CGAL/Default.h>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
namespace CGAL {
|
||||
namespace internal_primitive_id{
|
||||
//helper base class for creating the right Id: just a face_descriptor if OneFaceGraphPerTree
|
||||
// is true,else : a pair with the corresponding graph.
|
||||
template<class FaceGraph,
|
||||
class OneFaceGraphPerTree>
|
||||
class Primitive_wrapper;
|
||||
|
||||
template<class FaceGraph>
|
||||
class Primitive_wrapper<FaceGraph, Tag_true>
|
||||
{
|
||||
public:
|
||||
typedef typename boost::graph_traits<FaceGraph>::face_descriptor Id;
|
||||
|
||||
Primitive_wrapper(const FaceGraph*)
|
||||
{}
|
||||
|
||||
template<class T>
|
||||
Id from_id(const T& id)const
|
||||
{
|
||||
return Id(id);
|
||||
}
|
||||
};
|
||||
|
||||
template<class FaceGraph>
|
||||
class Primitive_wrapper<FaceGraph, Tag_false>
|
||||
{
|
||||
public:
|
||||
typedef std::pair<typename boost::graph_traits<FaceGraph>::face_descriptor,
|
||||
FaceGraph> Id;
|
||||
|
||||
Primitive_wrapper(const FaceGraph* graph)
|
||||
:this_graph(graph)
|
||||
{}
|
||||
|
||||
template<class T>
|
||||
Id from_id(const T& id)const
|
||||
{
|
||||
return std::make_pair(id, *this_graph);
|
||||
}
|
||||
|
||||
private:
|
||||
const FaceGraph* this_graph;
|
||||
};
|
||||
}//end internal
|
||||
|
||||
/*!
|
||||
* \ingroup PkgAABB_tree
|
||||
|
|
@ -109,7 +66,9 @@ template < class FaceGraph,
|
|||
class CacheDatum=Tag_false >
|
||||
class AABB_face_graph_triangle_primitive
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
: public AABB_primitive<typename boost::graph_traits<FaceGraph>::face_descriptor,
|
||||
: public AABB_primitive<typename boost::mpl::if_<OneFaceGraphPerTree,
|
||||
typename boost::graph_traits<FaceGraph>::face_descriptor,
|
||||
std::pair<typename boost::graph_traits<FaceGraph>::face_descriptor, const FaceGraph*> >::type,
|
||||
Triangle_from_face_descriptor_map<
|
||||
FaceGraph,
|
||||
typename Default::Get<VertexPointPMap,
|
||||
|
|
@ -121,12 +80,13 @@ class AABB_face_graph_triangle_primitive
|
|||
typename boost::property_map< FaceGraph,
|
||||
vertex_point_t>::type >::type>,
|
||||
OneFaceGraphPerTree,
|
||||
CacheDatum >,
|
||||
public internal_primitive_id::Primitive_wrapper<FaceGraph, OneFaceGraphPerTree>
|
||||
CacheDatum >
|
||||
#endif
|
||||
{
|
||||
typedef typename Default::Get<VertexPointPMap, typename boost::property_map< FaceGraph, vertex_point_t>::type >::type VertexPointPMap_;
|
||||
typedef typename boost::graph_traits<FaceGraph>::face_descriptor Id_;
|
||||
typedef typename boost::graph_traits<FaceGraph>::face_descriptor FD;
|
||||
typedef typename boost::mpl::if_<OneFaceGraphPerTree, FD, std::pair<FD, const FaceGraph*> >::type Id_;
|
||||
|
||||
typedef Triangle_from_face_descriptor_map<FaceGraph,VertexPointPMap_> Triangle_property_map;
|
||||
typedef One_point_from_face_descriptor_map<FaceGraph,VertexPointPMap_> Point_property_map;
|
||||
|
||||
|
|
@ -135,11 +95,17 @@ class AABB_face_graph_triangle_primitive
|
|||
Point_property_map,
|
||||
OneFaceGraphPerTree,
|
||||
CacheDatum > Base;
|
||||
|
||||
FD make_id(FD fd, const FaceGraph&, Tag_true)
|
||||
{
|
||||
return fd;
|
||||
}
|
||||
|
||||
std::pair<FD, const FaceGraph*> make_id(FD fd, const FaceGraph& fg, Tag_false)
|
||||
{
|
||||
return std::make_pair(fd, &fg);
|
||||
}
|
||||
|
||||
typedef internal_primitive_id::Primitive_wrapper<FaceGraph, OneFaceGraphPerTree> Base_2;
|
||||
|
||||
public:
|
||||
typedef typename Base_2::Id Id;
|
||||
public:
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
/// \name Types
|
||||
|
|
@ -154,10 +120,10 @@ public:
|
|||
typedef Kernel_traits<Point>::Kernel::Triangle_3 Datum;
|
||||
/*!
|
||||
Id type:
|
||||
- boost::graph_traits<FaceGraph>::face_descriptor Id if OneFaceGraphPerTree is `CGAL::Tag_true`
|
||||
- std::pair<boost::graph_traits<FaceGraph>::face_descriptor, FaceGraph> Id if OneFaceGraphPerTree is `CGAL::Tag_false`
|
||||
- `boost::graph_traits<FaceGraph>::face_descriptor` if `OneFaceGraphPerTree` is `CGAL::Tag_true`
|
||||
- `std::pair<boost::graph_traits<FaceGraph>::face_descriptor, FaceGraph>` if `OneFaceGraphPerTree` is `CGAL::Tag_false`
|
||||
*/
|
||||
Unspecified_type Id;
|
||||
unspecified_type Id;
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
@ -165,10 +131,11 @@ public:
|
|||
If `OneFaceGraphPerTree` is CGAL::Tag_true, constructs a `Shared_data` object from a reference to the polyhedon `graph`.
|
||||
*/
|
||||
static unspecified_type construct_shared_data( FaceGraph& graph );
|
||||
#else
|
||||
typedef typename Base::Id Id;
|
||||
#endif
|
||||
Id id() const {
|
||||
return Base_2::from_id(Base::id());
|
||||
}
|
||||
typedef typename boost::graph_traits<FaceGraph>::face_descriptor face_descriptor;
|
||||
|
||||
// constructors
|
||||
/*!
|
||||
\tparam Iterator an input iterator with `Id` as value type.
|
||||
|
|
@ -178,10 +145,9 @@ public:
|
|||
*/
|
||||
template <class Iterator>
|
||||
AABB_face_graph_triangle_primitive(Iterator it, const FaceGraph& graph, VertexPointPMap_ vppm)
|
||||
: Base( it,
|
||||
: Base( Id_(make_id(*it, graph, OneFaceGraphPerTree())),
|
||||
Triangle_property_map(const_cast<FaceGraph*>(&graph),vppm),
|
||||
Point_property_map(const_cast<FaceGraph*>(&graph),vppm) ),
|
||||
Base_2(&graph)
|
||||
Point_property_map(const_cast<FaceGraph*>(&graph),vppm) )
|
||||
{}
|
||||
|
||||
/*!
|
||||
|
|
@ -189,30 +155,24 @@ public:
|
|||
If `VertexPointPMap` is the default of the class, an additional constructor
|
||||
is available with `vppm` set to `get(vertex_point, graph)`.
|
||||
*/
|
||||
AABB_face_graph_triangle_primitive(
|
||||
typename boost::graph_traits<FaceGraph>::face_descriptor id, const FaceGraph& graph,
|
||||
VertexPointPMap_ vppm)
|
||||
: Base( Id_(id),
|
||||
AABB_face_graph_triangle_primitive(face_descriptor fd, const FaceGraph& graph, VertexPointPMap_ vppm)
|
||||
: Base( Id_(make_id(fd, graph, OneFaceGraphPerTree())),
|
||||
Triangle_property_map(const_cast<FaceGraph*>(&graph),vppm),
|
||||
Point_property_map(const_cast<FaceGraph*>(&graph),vppm) ),
|
||||
Base_2(&graph)
|
||||
Point_property_map(const_cast<FaceGraph*>(&graph),vppm) )
|
||||
{}
|
||||
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
template <class Iterator>
|
||||
AABB_face_graph_triangle_primitive(Iterator it, const FaceGraph& graph)
|
||||
: Base( Id_(*it),
|
||||
: Base( Id_(make_id(*it, graph, OneFaceGraphPerTree())),
|
||||
Triangle_property_map(const_cast<FaceGraph*>(&graph)),
|
||||
Point_property_map(const_cast<FaceGraph*>(&graph)) ),
|
||||
Base_2(&graph)
|
||||
Point_property_map(const_cast<FaceGraph*>(&graph)) )
|
||||
{}
|
||||
|
||||
AABB_face_graph_triangle_primitive(
|
||||
typename boost::graph_traits<FaceGraph>::face_descriptor id, const FaceGraph& graph)
|
||||
: Base( Id_(id),
|
||||
AABB_face_graph_triangle_primitive(face_descriptor fd, const FaceGraph& graph)
|
||||
: Base( Id_(make_id(fd, graph, OneFaceGraphPerTree())),
|
||||
Triangle_property_map(const_cast<FaceGraph*>(&graph)),
|
||||
Point_property_map(const_cast<FaceGraph*>(&graph)) ),
|
||||
Base_2(&graph)
|
||||
Point_property_map(const_cast<FaceGraph*>(&graph)) )
|
||||
{}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -35,54 +35,11 @@
|
|||
#include <CGAL/is_iterator.h>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
#include <CGAL/Default.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace internal_primitive_id{
|
||||
//helper base class for creating the right Id: just a face_descriptor if OneFaceGraphPerTree
|
||||
// is true,else : a pair with the corresponding graph.
|
||||
template<class Graph,
|
||||
class OneGraphPerTree>
|
||||
class EPrimitive_wrapper;
|
||||
|
||||
template<class Graph>
|
||||
class EPrimitive_wrapper<Graph, Tag_true>
|
||||
{
|
||||
public:
|
||||
typedef typename boost::graph_traits<Graph>::edge_descriptor Id;
|
||||
|
||||
EPrimitive_wrapper(const Graph*)
|
||||
{}
|
||||
|
||||
template<class T>
|
||||
Id from_id(const T& id)const
|
||||
{
|
||||
return Id(id);
|
||||
}
|
||||
};
|
||||
|
||||
template<class Graph>
|
||||
class EPrimitive_wrapper<Graph, Tag_false>
|
||||
{
|
||||
public:
|
||||
typedef std::pair<typename boost::graph_traits<Graph>::edge_descriptor,
|
||||
Graph> Id;
|
||||
|
||||
EPrimitive_wrapper(const Graph* graph)
|
||||
:this_graph(graph)
|
||||
{}
|
||||
|
||||
template<class T>
|
||||
Id from_id(const T& id)const
|
||||
{
|
||||
return std::make_pair(id, *this_graph);
|
||||
}
|
||||
|
||||
private:
|
||||
const Graph* this_graph;
|
||||
};
|
||||
}//end internal
|
||||
|
||||
|
||||
/*!
|
||||
|
|
@ -122,7 +79,9 @@ template < class HalfedgeGraph,
|
|||
class CacheDatum = Tag_false >
|
||||
class AABB_halfedge_graph_segment_primitive
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
: public AABB_primitive< typename boost::graph_traits<HalfedgeGraph>::edge_descriptor,
|
||||
: public AABB_primitive< typename boost::mpl::if_<OneHalfedgeGraphPerTree,
|
||||
typename boost::graph_traits<HalfedgeGraph>::edge_descriptor,
|
||||
std::pair<typename boost::graph_traits<HalfedgeGraph>::edge_descriptor, const HalfedgeGraph*> >::type,
|
||||
Segment_from_edge_descriptor_map<
|
||||
HalfedgeGraph,
|
||||
typename Default::Get<VertexPointPMap,
|
||||
|
|
@ -134,13 +93,13 @@ class AABB_halfedge_graph_segment_primitive
|
|||
typename boost::property_map< HalfedgeGraph,
|
||||
vertex_point_t>::type >::type >,
|
||||
OneHalfedgeGraphPerTree,
|
||||
CacheDatum >,
|
||||
public internal_primitive_id::EPrimitive_wrapper<HalfedgeGraph, OneHalfedgeGraphPerTree>
|
||||
CacheDatum >
|
||||
#endif
|
||||
{
|
||||
typedef typename Default::Get<VertexPointPMap,typename boost::property_map< HalfedgeGraph,vertex_point_t>::type >::type VertexPointPMap_;
|
||||
typedef typename boost::graph_traits<HalfedgeGraph>::edge_descriptor ED;
|
||||
typedef typename boost::mpl::if_<OneHalfedgeGraphPerTree, ED, std::pair<ED, const HalfedgeGraph*> >::type Id_;
|
||||
|
||||
typedef typename boost::graph_traits<HalfedgeGraph>::edge_descriptor Id_;
|
||||
typedef Segment_from_edge_descriptor_map<HalfedgeGraph,VertexPointPMap_> Segment_property_map;
|
||||
typedef Source_point_from_edge_descriptor_map<HalfedgeGraph,VertexPointPMap_> Point_property_map;
|
||||
|
||||
|
|
@ -149,13 +108,19 @@ class AABB_halfedge_graph_segment_primitive
|
|||
Point_property_map,
|
||||
OneHalfedgeGraphPerTree,
|
||||
CacheDatum > Base;
|
||||
|
||||
typedef internal_primitive_id::EPrimitive_wrapper<HalfedgeGraph, OneHalfedgeGraphPerTree> Base_2;
|
||||
|
||||
ED make_id(ED ed, const HalfedgeGraph&, Tag_true)
|
||||
{
|
||||
return ed;
|
||||
}
|
||||
|
||||
std::pair<ED, const HalfedgeGraph*> make_id(ED ed, const HalfedgeGraph& fg, Tag_false)
|
||||
{
|
||||
return std::make_pair(ed, &fg);
|
||||
}
|
||||
|
||||
public:
|
||||
typedef typename Base_2::Id Id;
|
||||
|
||||
public:
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
|
@ -169,20 +134,20 @@ public:
|
|||
typedef Kernel_traits<Point>::Kernel::Segment_3 Datum;
|
||||
/*!
|
||||
Id type:
|
||||
- boost::graph_traits<HalfegdeGraph>::edge_descriptor Id if OneHalfegdeGraphPerTree is `CGAL::Tag_true`
|
||||
- std::pair<boost::graph_traits<HalfegdeGraph>::edge_descriptor, HalfegdeGraph> Id if OneHalfegdeGraphPerTree is `CGAL::Tag_false`
|
||||
- `boost::graph_traits<HalfedgeGraph>::edge_descriptor if `OneHalfedgeGraphPerTree` is `Tag_true`
|
||||
- `std::pair<boost::graph_traits<HalfedgeGraph>::edge_descriptor`, HalfedgeGraph>` if `OneHalfedgeGraphPerTree` is `Tag_false`
|
||||
*/
|
||||
Unspecified_type Id;
|
||||
unspecified_type Id;
|
||||
/// @}
|
||||
|
||||
/*!
|
||||
If `OneHalfedgeGraphPerTreeGraphPerTree` is CGAL::Tag_true, constructs a `Shared_data` object from a reference to the halfedge graph.
|
||||
If `OneHalfedgeGraphPerTree` is CGAL::Tag_true, constructs a `Shared_data` object from a reference to the halfedge graph.
|
||||
*/
|
||||
static unspecified_type construct_shared_data( HalfedgeGraph& graph );
|
||||
#else
|
||||
typedef typename Base::Id Id;
|
||||
#endif
|
||||
Id id() const {
|
||||
return Base_2::from_id(Base::id());
|
||||
}
|
||||
typedef typename boost::graph_traits<HalfedgeGraph>::edge_descriptor edge_descriptor;
|
||||
|
||||
/*!
|
||||
Constructs a primitive.
|
||||
|
|
@ -194,10 +159,9 @@ public:
|
|||
*/
|
||||
template <class Iterator>
|
||||
AABB_halfedge_graph_segment_primitive(Iterator it, const HalfedgeGraph& graph, VertexPointPMap_ vppm)
|
||||
: Base( Id_(*it),
|
||||
: Base( Id_(make_id(*it, graph, OneHalfedgeGraphPerTree())),
|
||||
Segment_property_map(const_cast<HalfedgeGraph*>(&graph), vppm),
|
||||
Point_property_map(const_cast<HalfedgeGraph*>(&graph), vppm) ),
|
||||
Base_2(&graph)
|
||||
Point_property_map(const_cast<HalfedgeGraph*>(&graph), vppm) )
|
||||
{}
|
||||
|
||||
/*!
|
||||
|
|
@ -205,30 +169,23 @@ public:
|
|||
If `VertexPointPMap` is the default of the class, an additional constructor
|
||||
is available with `vppm` set to `boost::get(vertex_point, graph)`.
|
||||
*/
|
||||
AABB_halfedge_graph_segment_primitive(
|
||||
typename boost::graph_traits<HalfedgeGraph>::edge_descriptor id, const HalfedgeGraph& graph, VertexPointPMap_ vppm)
|
||||
: Base( Id_(id),
|
||||
AABB_halfedge_graph_segment_primitive(edge_descriptor ed, const HalfedgeGraph& graph, VertexPointPMap_ vppm)
|
||||
: Base( Id_(make_id(ed, graph, OneHalfedgeGraphPerTree())),
|
||||
Segment_property_map(const_cast<HalfedgeGraph*>(&graph), vppm),
|
||||
Point_property_map(const_cast<HalfedgeGraph*>(&graph), vppm) ),
|
||||
Base_2(&graph)
|
||||
Point_property_map(const_cast<HalfedgeGraph*>(&graph), vppm) )
|
||||
{}
|
||||
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
template <class Iterator>
|
||||
AABB_halfedge_graph_segment_primitive(Iterator it, const HalfedgeGraph& graph)
|
||||
: Base( Id_(*it),
|
||||
: Base( Id_(make_id(*it, graph, OneHalfedgeGraphPerTree())),
|
||||
Segment_property_map(const_cast<HalfedgeGraph*>(&graph)),
|
||||
Point_property_map(const_cast<HalfedgeGraph*>(&graph)) ),
|
||||
Base_2(&graph)
|
||||
{}
|
||||
Point_property_map(const_cast<HalfedgeGraph*>(&graph)) ){}
|
||||
|
||||
AABB_halfedge_graph_segment_primitive(
|
||||
typename boost::graph_traits<HalfedgeGraph>::edge_descriptor id, const HalfedgeGraph& graph)
|
||||
: Base( Id_(id),
|
||||
AABB_halfedge_graph_segment_primitive(edge_descriptor ed, const HalfedgeGraph& graph)
|
||||
: Base( Id_(make_id(ed, graph, OneHalfedgeGraphPerTree())),
|
||||
Segment_property_map(const_cast<HalfedgeGraph*>(&graph)),
|
||||
Point_property_map(const_cast<HalfedgeGraph*>(&graph)) ),
|
||||
Base_2(&graph)
|
||||
{}
|
||||
Point_property_map(const_cast<HalfedgeGraph*>(&graph)) ){}
|
||||
#endif
|
||||
|
||||
/// \internal
|
||||
|
|
|
|||
|
|
@ -73,6 +73,19 @@ struct Triangle_from_face_descriptor_map{
|
|||
get(pmap.m_vpm, target(next(halfedge(f,tm),tm),tm)),
|
||||
get(pmap.m_vpm, source(halfedge(f,tm),tm)) );
|
||||
}
|
||||
|
||||
inline friend
|
||||
reference
|
||||
get(const Triangle_from_face_descriptor_map<TriangleMesh,VertexPointMap>& pmap,
|
||||
const std::pair<key_type, const TriangleMesh*>& f)
|
||||
{
|
||||
typename boost::remove_const<TriangleMesh>::type & tm = *(pmap.m_tm);
|
||||
CGAL_precondition(halfedge(f.first,tm) == next(next(next(halfedge(f.first,tm),tm),tm),tm));
|
||||
|
||||
return value_type( get(pmap.m_vpm, target(halfedge(f.first,tm),tm)),
|
||||
get(pmap.m_vpm, target(next(halfedge(f.first,tm),tm),tm)),
|
||||
get(pmap.m_vpm, source(halfedge(f.first,tm),tm)) );
|
||||
}
|
||||
};
|
||||
|
||||
template < class PolygonMesh,
|
||||
|
|
@ -114,6 +127,15 @@ struct Segment_from_edge_descriptor_map{
|
|||
return value_type(get(pmap.m_vpm, source(h, *pmap.m_pm) ),
|
||||
get(pmap.m_vpm, target(h, *pmap.m_pm) ) );
|
||||
}
|
||||
|
||||
inline friend
|
||||
reference
|
||||
get(const Segment_from_edge_descriptor_map<PolygonMesh,VertexPointMap>& pmap,
|
||||
const std::pair<key_type, const PolygonMesh*>& h)
|
||||
{
|
||||
return value_type(get(pmap.m_vpm, source(h.first, *pmap.m_pm) ),
|
||||
get(pmap.m_vpm, target(h.first, *pmap.m_pm) ) );
|
||||
}
|
||||
};
|
||||
|
||||
//property map to access a point from a face_descriptor
|
||||
|
|
@ -151,6 +173,14 @@ struct One_point_from_face_descriptor_map{
|
|||
{
|
||||
return get(m.m_vpm, target(halfedge(f, *m.m_pm), *m.m_pm));
|
||||
}
|
||||
|
||||
inline friend
|
||||
reference
|
||||
get(const One_point_from_face_descriptor_map<PolygonMesh,VertexPointMap>& m,
|
||||
const std::pair<key_type, const PolygonMesh*>& f)
|
||||
{
|
||||
return get(m.m_vpm, target(halfedge(f.first, *m.m_pm), *m.m_pm));
|
||||
}
|
||||
};
|
||||
|
||||
//property map to access a point from an edge
|
||||
|
|
@ -187,6 +217,14 @@ struct Source_point_from_edge_descriptor_map{
|
|||
{
|
||||
return get(pmap.m_vpm, source(h, *pmap.m_pm) );
|
||||
}
|
||||
|
||||
inline friend
|
||||
reference
|
||||
get(const Source_point_from_edge_descriptor_map<PolygonMesh,VertexPointMap>& pmap,
|
||||
const std::pair<key_type, const PolygonMesh*>& h)
|
||||
{
|
||||
return get(pmap.m_vpm, source(h.first, *pmap.m_pm) );
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace CGAL
|
||||
|
|
|
|||
Loading…
Reference in New Issue