diff --git a/AABB_tree/include/CGAL/AABB_face_graph_triangle_primitive.h b/AABB_tree/include/CGAL/AABB_face_graph_triangle_primitive.h index 74d34ec46f3..20fa60d52f6 100644 --- a/AABB_tree/include/CGAL/AABB_face_graph_triangle_primitive.h +++ b/AABB_tree/include/CGAL/AABB_face_graph_triangle_primitive.h @@ -33,33 +33,47 @@ namespace CGAL { namespace internal_primitive_id{ -//helper struct for creating the right Id: just a face_descriptor if OneFaceGraphPerTree +//helper base class for creating the right Id: just a face_descriptor if OneFaceGraphPerTree // is true,else : a pair with the corresponding graph. template -struct Primitive_id; +class Primitive_wrapper; template -struct Primitive_id +class Primitive_wrapper { - typedef typename boost::graph_traits::face_descriptor Id_; + public: + typedef typename boost::graph_traits::face_descriptor Id; + + Primitive_wrapper(const FaceGraph*) + {} + template - static Id_ from_id(const T& id, const FaceGraph&) + Id from_id(const T& id)const { - return Id_(id); + return Id(id); } }; template -struct Primitive_id +class Primitive_wrapper { +public: typedef std::pair::face_descriptor, - FaceGraph> Id_; + FaceGraph> Id; + + Primitive_wrapper(const FaceGraph* graph) + :this_graph(graph) + {} + template - static Id_ from_id(const T& id, const FaceGraph& f) + Id from_id(const T& id)const { - return std::make_pair(id, f); + return std::make_pair(id, *this_graph); } + +private: + const FaceGraph* this_graph; }; }//end internal @@ -107,7 +121,8 @@ class AABB_face_graph_triangle_primitive typename boost::property_map< FaceGraph, vertex_point_t>::type >::type>, OneFaceGraphPerTree, - CacheDatum > + CacheDatum >, + public internal_primitive_id::Primitive_wrapper #endif { typedef typename Default::Get::type >::type VertexPointPMap_; @@ -120,10 +135,11 @@ class AABB_face_graph_triangle_primitive Point_property_map, OneFaceGraphPerTree, CacheDatum > Base; + + typedef internal_primitive_id::Primitive_wrapper Base_2; + public: - typedef typename internal_primitive_id::Primitive_id::Id_ Id; -protected: - const FaceGraph* this_graph; + typedef typename Base_2::Id Id; public: #ifdef DOXYGEN_RUNNING /// \name Types @@ -151,8 +167,7 @@ public: static unspecified_type construct_shared_data( FaceGraph& graph ); #endif Id id() const { - return internal_primitive_id::Primitive_id::from_id(Base::id(), - *this_graph); + return Base_2::from_id(Base::id()); } // constructors /*! @@ -166,7 +181,7 @@ public: : Base( it, Triangle_property_map(const_cast(&graph),vppm), Point_property_map(const_cast(&graph),vppm) ), - this_graph(&graph) + Base_2(&graph) {} /*! @@ -180,7 +195,7 @@ public: : Base( Id_(id), Triangle_property_map(const_cast(&graph),vppm), Point_property_map(const_cast(&graph),vppm) ), - this_graph(&graph) + Base_2(&graph) {} #ifndef DOXYGEN_RUNNING @@ -189,7 +204,7 @@ public: : Base( Id_(*it), Triangle_property_map(const_cast(&graph)), Point_property_map(const_cast(&graph)) ), - this_graph(&graph) + Base_2(&graph) {} AABB_face_graph_triangle_primitive( @@ -197,7 +212,7 @@ public: : Base( Id_(id), Triangle_property_map(const_cast(&graph)), Point_property_map(const_cast(&graph)) ), - this_graph(&graph) + Base_2(&graph) {} #endif diff --git a/AABB_tree/include/CGAL/AABB_halfedge_graph_segment_primitive.h b/AABB_tree/include/CGAL/AABB_halfedge_graph_segment_primitive.h index f72db800b61..7783b330b34 100644 --- a/AABB_tree/include/CGAL/AABB_halfedge_graph_segment_primitive.h +++ b/AABB_tree/include/CGAL/AABB_halfedge_graph_segment_primitive.h @@ -40,33 +40,47 @@ namespace CGAL { namespace internal_primitive_id{ -//helper struct for creating the right Id: just an edge_descriptor if OneHalfedgeGraphPerTree +//helper base class for creating the right Id: just a face_descriptor if OneFaceGraphPerTree // is true,else : a pair with the corresponding graph. -template -struct EPrimitive_id; +template +class EPrimitive_wrapper; -template -struct EPrimitive_id +template +class EPrimitive_wrapper { - typedef typename boost::graph_traits::edge_descriptor Id_; + public: + typedef typename boost::graph_traits::edge_descriptor Id; + + EPrimitive_wrapper(const Graph*) + {} + template - static Id_ from_id(const T& id, const HalfedgeGraph&) + Id from_id(const T& id)const { - return Id_(id); + return Id(id); } }; -template -struct EPrimitive_id +template +class EPrimitive_wrapper { - typedef std::pair::edge_descriptor, - HalfedgeGraph> Id_; +public: + typedef std::pair::edge_descriptor, + Graph> Id; + + EPrimitive_wrapper(const Graph* graph) + :this_graph(graph) + {} + template - static Id_ from_id(const T& id, const HalfedgeGraph& f) + Id from_id(const T& id)const { - return std::make_pair(id, f); + return std::make_pair(id, *this_graph); } + +private: + const Graph* this_graph; }; }//end internal @@ -120,7 +134,8 @@ class AABB_halfedge_graph_segment_primitive typename boost::property_map< HalfedgeGraph, vertex_point_t>::type >::type >, OneHalfedgeGraphPerTree, - CacheDatum > + CacheDatum >, + public internal_primitive_id::EPrimitive_wrapper #endif { typedef typename Default::Get::type >::type VertexPointPMap_; @@ -134,11 +149,12 @@ class AABB_halfedge_graph_segment_primitive Point_property_map, OneHalfedgeGraphPerTree, CacheDatum > Base; + + typedef internal_primitive_id::EPrimitive_wrapper Base_2; public: - typedef typename internal_primitive_id::EPrimitive_id::Id_ Id; -protected: - const HalfedgeGraph* this_graph; + typedef typename Base_2::Id Id; + public: #ifdef DOXYGEN_RUNNING /// \name Types @@ -165,9 +181,7 @@ public: static unspecified_type construct_shared_data( HalfedgeGraph& graph ); #endif Id id() const { - return internal_primitive_id::EPrimitive_id::from_id(Base::id(), - *this_graph); + return Base_2::from_id(Base::id()); } /*! @@ -183,7 +197,7 @@ public: : Base( Id_(*it), Segment_property_map(const_cast(&graph), vppm), Point_property_map(const_cast(&graph), vppm) ), - this_graph(&graph) + Base_2(&graph) {} /*! @@ -196,7 +210,7 @@ public: : Base( Id_(id), Segment_property_map(const_cast(&graph), vppm), Point_property_map(const_cast(&graph), vppm) ), - this_graph(&graph) + Base_2(&graph) {} #ifndef DOXYGEN_RUNNING @@ -205,7 +219,7 @@ public: : Base( Id_(*it), Segment_property_map(const_cast(&graph)), Point_property_map(const_cast(&graph)) ), - this_graph(&graph) + Base_2(&graph) {} AABB_halfedge_graph_segment_primitive( @@ -213,7 +227,7 @@ public: : Base( Id_(id), Segment_property_map(const_cast(&graph)), Point_property_map(const_cast(&graph)) ), - this_graph(&graph) + Base_2(&graph) {} #endif