*update AABB_primitive: the property maps must operate on Id!

*correct and complete implementation for HalfhedgeGraph models
This commit is contained in:
Sébastien Loriot 2012-05-10 15:51:45 +00:00
parent 388d53e0a3
commit be1de01b22
12 changed files with 198 additions and 106 deletions

1
.gitattributes vendored
View File

@ -34,6 +34,7 @@ AABB_tree/doc_tex/AABB_tree_ref/AABB_tree.tex -text
AABB_tree/doc_tex/AABB_tree_ref/introduction.tex -text AABB_tree/doc_tex/AABB_tree_ref/introduction.tex -text
AABB_tree/doc_tex/AABB_tree_ref/main.tex -text AABB_tree/doc_tex/AABB_tree_ref/main.tex -text
AABB_tree/dont_submit -text AABB_tree/dont_submit -text
AABB_tree/examples/AABB_tree/AABB_HalfedgeGraph_edge_example.cpp -text
AABB_tree/examples/AABB_tree/cleanup.bat -text AABB_tree/examples/AABB_tree/cleanup.bat -text
AABB_tree/include/CGAL/AABB_FaceGraph_triangle_primitive.h -text AABB_tree/include/CGAL/AABB_FaceGraph_triangle_primitive.h -text
AABB_tree/include/CGAL/AABB_HalfedgeGraph_segment_primitive.h -text AABB_tree/include/CGAL/AABB_HalfedgeGraph_segment_primitive.h -text

View File

@ -0,0 +1,63 @@
// Author(s) : Pierre Alliez
#include <iostream>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_HalfedgeGraph_segment_primitive.h>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/bind.hpp>
typedef CGAL::Simple_cartesian<double> K;
typedef K::FT FT;
typedef K::Point_3 Point;
typedef K::Triangle_3 Triangle;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_HalfedgeGraph_segment_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
template <class Kernel, class HalfedgeGraph>
void run(const HalfedgeGraph& graph){
typename Kernel::Point_3 p(1.0, 0.0, 0.0);
typename Kernel::Point_3 q(0.0, 1.0, 0.0);
typename Kernel::Point_3 r(0.0, 0.0, 1.0);
typedef typename boost::graph_traits<HalfedgeGraph>::edge_descriptor edge_descriptor;
// constructs the AABB tree and the internal search tree for
// efficient distance queries.
Tree tree(boost::make_transform_iterator(boost::edges(graph).first,
boost::bind(&std::make_pair<const HalfedgeGraph*, edge_descriptor>,
&graph, _1)),
boost::make_transform_iterator(boost::edges(graph).second,
boost::bind(&std::make_pair<const HalfedgeGraph*, edge_descriptor>,
&graph, _1)));
tree.accelerate_distance_queries();
// counts #intersections with a triangle query
Triangle triangle_query(p,q,r);
std::cout << tree.number_of_intersected_primitives(triangle_query)
<< " intersections(s) with triangle" << std::endl;
// computes the closest point from a query point
typename Kernel::Point_3 point_query(2.0, 2.0, 2.0);
typename Kernel::Point_3 closest = tree.closest_point(point_query);
std::cerr << "closest point is: " << closest << std::endl;
}
int main()
{
Point p(1.0, 0.0, 0.0);
Point q(0.0, 1.0, 0.0);
Point r(0.0, 0.0, 1.0);
Point s(0.0, 0.0, 0.0);
Polyhedron polyhedron;
polyhedron.make_tetrahedron(p, q, r, s);
run<K>(polyhedron);
return EXIT_SUCCESS;
}

View File

@ -17,7 +17,7 @@ typedef K::Segment_3 Segment;
typedef K::Triangle_3 Triangle; typedef K::Triangle_3 Triangle;
typedef std::list<Segment>::iterator Iterator; typedef std::list<Segment>::iterator Iterator;
typedef CGAL::AABB_segment_primitive<K,Iterator> Primitive; typedef CGAL::AABB_segment_primitive<Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits; typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree; typedef CGAL::AABB_tree<Traits> Tree;

View File

@ -17,7 +17,7 @@ typedef K::Point_3 Point;
typedef K::Triangle_3 Triangle; typedef K::Triangle_3 Triangle;
typedef std::list<Triangle>::iterator Iterator; typedef std::list<Triangle>::iterator Iterator;
typedef CGAL::AABB_triangle_primitive<K,Iterator> Primitive; typedef CGAL::AABB_triangle_primitive<Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> AABB_triangle_traits; typedef CGAL::AABB_traits<K, Primitive> AABB_triangle_traits;
typedef CGAL::AABB_tree<AABB_triangle_traits> Tree; typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;

View File

@ -12,8 +12,8 @@
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// //
// $URL: svn+ssh://sloriot@scm.gforge.inria.fr/svn/cgal/branches/features/AABB_tree-one_primitive_per_object-sloriot/AABB_tree/include/CGAL/AABB_triangle_primitive.h $ // $URL$
// $Id: AABB_triangle_primitive.h 68959 2012-05-04 12:24:50Z sloriot $ // $Id$
// //
// //
// Author(s) : Sebastien Loriot // Author(s) : Sebastien Loriot
@ -39,12 +39,12 @@ template < class FaceGraph,
> >
class AABB_FaceGraph_triangle_primitive : public AABB_primitive< Id_, class AABB_FaceGraph_triangle_primitive : public AABB_primitive< Id_,
Triangle_from_facet_property_map<FaceGraph>, Triangle_from_facet_handle_property_map<FaceGraph>,
One_point_from_facet_property_map<FaceGraph>, One_point_from_facet_handle_property_map<FaceGraph>,
cache_primitive > cache_primitive >
{ {
typedef Triangle_from_facet_property_map<FaceGraph> Triangle_property_map; typedef Triangle_from_facet_handle_property_map<FaceGraph> Triangle_property_map;
typedef One_point_from_facet_property_map<FaceGraph> Point_property_map; typedef One_point_from_facet_handle_property_map<FaceGraph> Point_property_map;
typedef AABB_primitive< Id_, typedef AABB_primitive< Id_,
Triangle_property_map, Triangle_property_map,

View File

@ -12,8 +12,8 @@
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// //
// $URL: svn+ssh://sloriot@scm.gforge.inria.fr/svn/cgal/branches/features/AABB_tree-one_primitive_per_object-sloriot/AABB_tree/include/CGAL/AABB_triangle_primitive.h $ // $URL$
// $Id: AABB_triangle_primitive.h 68959 2012-05-04 12:24:50Z sloriot $ // $Id$
// //
// //
// Author(s) : Sebastien Loriot // Author(s) : Sebastien Loriot
@ -35,6 +35,7 @@
#include <CGAL/is_iterator.h> #include <CGAL/is_iterator.h>
#include <boost/type_traits/is_convertible.hpp> #include <boost/type_traits/is_convertible.hpp>
#include <boost/utility/enable_if.hpp> #include <boost/utility/enable_if.hpp>
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
namespace CGAL { namespace CGAL {
@ -52,15 +53,15 @@ namespace internal{
template < class HalfedgeGraph, template < class HalfedgeGraph,
class cache_primitive=Tag_false, class cache_primitive=Tag_false,
class Id_=typename HalfedgeGraph::Halfedge_handle //this one should be autodetected using edge_descriptor class Id_=typename boost::graph_traits<HalfedgeGraph>::edge_descriptor
> >
class AABB_HalfedgeGraph_segment_primitive : public AABB_primitive< Id_, class AABB_HalfedgeGraph_segment_primitive : public AABB_primitive< Id_,
Segment_from_halfedge_property_map<HalfedgeGraph>, Segment_from_edge_descriptor_property_map<HalfedgeGraph>,
One_point_from_halfedge_property_map<HalfedgeGraph>, Source_point_from_edge_descriptor<HalfedgeGraph>,
cache_primitive > cache_primitive >
{ {
typedef Segment_from_halfedge_property_map<HalfedgeGraph> Triangle_property_map; typedef Segment_from_edge_descriptor_property_map<HalfedgeGraph> Triangle_property_map;
typedef One_point_from_halfedge_property_map<HalfedgeGraph> Point_property_map; typedef Source_point_from_edge_descriptor<HalfedgeGraph> Point_property_map;
typedef AABB_primitive< Id_, typedef AABB_primitive< Id_,
Triangle_property_map, Triangle_property_map,

View File

@ -12,8 +12,8 @@
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// //
// $URL: svn+ssh://sloriot@scm.gforge.inria.fr/svn/cgal/branches/features/AABB_tree-one_primitive_per_object-sloriot/AABB_tree/include/CGAL/AABB_triangle_primitive.h $ // $URL$
// $Id: AABB_triangle_primitive.h 68970 2012-05-04 14:59:14Z sloriot $ // $Id$
// //
// //
// Author(s) : Sebastien Loriot // Author(s) : Sebastien Loriot
@ -53,10 +53,8 @@ public:
// constructors // constructors
AABB_primitive() {} AABB_primitive() {}
AABB_primitive(Id it,ObjectPropertyMap t_pmap=ObjectPropertyMap(), PointPropertyMap p_pmap=PointPropertyMap()) AABB_primitive(Id it,ObjectPropertyMap t_pmap=ObjectPropertyMap(), PointPropertyMap p_pmap=PointPropertyMap())
: m_ppmap(p_pmap), m_it(it) : Primitive_base(it,t_pmap),m_ppmap(p_pmap), m_it(it)
{ {}
this->set_primitive(it,t_pmap);
}
public: public:
Id& id() { return m_it; } Id& id() { return m_it; }
const Id& id() const { return m_it; } const Id& id() const { return m_it; }
@ -68,7 +66,7 @@ public:
/// Returns a point on the primitive /// Returns a point on the primitive
typename boost::property_traits< PointPropertyMap >::reference typename boost::property_traits< PointPropertyMap >::reference
reference_point() const { reference_point() const {
return get(m_ppmap,*m_it); return get(m_ppmap, m_it);
} }
}; };

View File

@ -27,42 +27,43 @@
#define CGAL_AABB_SEGMENT_PRIMITIVE_H_ #define CGAL_AABB_SEGMENT_PRIMITIVE_H_
#include <CGAL/AABB_primitive.h> #include <CGAL/AABB_primitive.h>
#include <CGAL/Kernel_traits.h>
#include <iterator>
namespace CGAL { namespace CGAL {
namespace internal { namespace internal {
template <class GeomTraits> template <class Iterator>
struct First_point_of_segment_3_property_map{ struct Source_of_segment_3_iterator_property_map{
//classical typedefs //classical typedefs
typedef const typename GeomTraits::Segment_3& key_type; typedef typename CGAL::Kernel_traits< typename std::iterator_traits<Iterator>::value_type >::Kernel GeomTraits;
typedef Iterator key_type;
typedef typename GeomTraits::Point_3 value_type; typedef typename GeomTraits::Point_3 value_type;
typedef const typename GeomTraits::Point_3& reference; typedef const typename GeomTraits::Point_3& reference;
typedef boost::readable_property_map_tag category; typedef boost::readable_property_map_tag category;
}; };
//get function for property map //get function for property map
template <class GeomTraits> template <class Iterator>
inline inline
const typename GeomTraits::Point_3& typename Source_of_segment_3_iterator_property_map<Iterator>::reference
get(First_point_of_segment_3_property_map<GeomTraits>, get(Source_of_segment_3_iterator_property_map<Iterator>, Iterator it)
const typename GeomTraits::Segment_3& s)
{ {
return s.source(); return it->source();
} }
}//namespace internal }//namespace internal
template <class GeomTraits, template < class Iterator,
class Iterator, class cache_primitive=Tag_false>
class cache_primitive=Tag_false>
class AABB_segment_primitive : public AABB_primitive< Iterator, class AABB_segment_primitive : public AABB_primitive< Iterator,
boost::typed_identity_property_map<typename GeomTraits::Segment_3>, Input_iterator_property_map<Iterator>,
internal::First_point_of_segment_3_property_map<GeomTraits>, internal::Source_of_segment_3_iterator_property_map<Iterator>,
cache_primitive > cache_primitive >
{ {
typedef AABB_primitive< Iterator, typedef AABB_primitive< Iterator,
boost::typed_identity_property_map<typename GeomTraits::Segment_3>, Input_iterator_property_map<Iterator>,
internal::First_point_of_segment_3_property_map<GeomTraits>, internal::Source_of_segment_3_iterator_property_map<Iterator>,
cache_primitive > Base; cache_primitive > Base;
public: public:
// constructors // constructors

View File

@ -27,42 +27,42 @@
#define CGAL_AABB_TRIANGLE_PRIMITIVE_H_ #define CGAL_AABB_TRIANGLE_PRIMITIVE_H_
#include <CGAL/AABB_primitive.h> #include <CGAL/AABB_primitive.h>
#include <CGAL/property_map.h>
namespace CGAL { namespace CGAL {
namespace internal { namespace internal {
template <class GeomTraits> template <class Iterator>
struct First_point_of_triangle_3_property_map{ struct Point_from_triangle_3_iterator_property_map{
//classical typedefs //classical typedefs
typedef const typename GeomTraits::Triangle_3& key_type; typedef typename CGAL::Kernel_traits< typename std::iterator_traits<Iterator>::value_type >::Kernel GeomTraits;
typedef Iterator key_type;
typedef typename GeomTraits::Point_3 value_type; typedef typename GeomTraits::Point_3 value_type;
typedef const typename GeomTraits::Point_3& reference; typedef const typename GeomTraits::Point_3& reference;
typedef boost::readable_property_map_tag category; typedef boost::readable_property_map_tag category;
}; };
//get function for property map //get function for property map
template <class GeomTraits> template <class Iterator>
inline inline
const typename GeomTraits::Point_3& typename Point_from_triangle_3_iterator_property_map<Iterator>::reference
get(First_point_of_triangle_3_property_map<GeomTraits>, get(Point_from_triangle_3_iterator_property_map<Iterator>,Iterator it)
const typename GeomTraits::Triangle_3& t)
{ {
return t.vertex(0); return it->vertex(0);
} }
}//namespace internal }//namespace internal
template <class GeomTraits, template < class Iterator,
class Iterator, class cache_primitive=Tag_false>
class cache_primitive=Tag_false>
class AABB_triangle_primitive : public AABB_primitive< Iterator, class AABB_triangle_primitive : public AABB_primitive< Iterator,
boost::typed_identity_property_map<typename GeomTraits::Triangle_3>, Input_iterator_property_map<Iterator>,
internal::First_point_of_triangle_3_property_map<GeomTraits>, internal::Point_from_triangle_3_iterator_property_map<Iterator>,
cache_primitive > cache_primitive >
{ {
typedef AABB_primitive< Iterator, typedef AABB_primitive< Iterator,
boost::typed_identity_property_map<typename GeomTraits::Triangle_3>, Input_iterator_property_map<Iterator>,
internal::First_point_of_triangle_3_property_map<GeomTraits>, internal::Point_from_triangle_3_iterator_property_map<Iterator>,
cache_primitive > Base; cache_primitive > Base;
public: public:
// constructors // constructors

View File

@ -43,7 +43,7 @@ namespace internal{
typedef const Primitive& result_type; typedef const Primitive& result_type;
Primitive datum; Primitive datum;
void set_primitive(Id id,PropertyMap pmap){datum=get(pmap,*id);} Primitive_caching(Id id,PropertyMap pmap) {datum=get(pmap,id);}
result_type get_primitive(Id) const{ result_type get_primitive(Id) const{
return datum; return datum;
} }
@ -55,9 +55,9 @@ namespace internal{
typedef typename boost::property_traits< PropertyMap >::reference result_type; typedef typename boost::property_traits< PropertyMap >::reference result_type;
PropertyMap pmap_; PropertyMap pmap_;
void set_primitive(Id,PropertyMap pmap){pmap_=pmap;} Primitive_caching(Id,PropertyMap pmap){pmap_=pmap;}
result_type get_primitive(Id id) const{ result_type get_primitive(Id id) const{
return get(pmap_,*id); return get(pmap_,id);
} }
}; };

View File

@ -195,6 +195,31 @@ make_nth_of_tuple_property_map(Iter)
return Nth_of_tuple_property_map<N, typename CGAL::value_type_traits<Iter>::type>(); return Nth_of_tuple_property_map<N, typename CGAL::value_type_traits<Iter>::type>();
} }
//=========================================================================
/// Property map that accesses a value from an iterator
///
/// @heading Is Model for the Concepts:
/// Model of boost::ReadablePropertyMap concept.
///
/// @heading Parameters:
/// @param InputIterator an input iterator
template<class InputIterator>
struct Input_iterator_property_map{
typedef InputIterator key_type;
typedef typename std::iterator_traits<InputIterator>::value_type value_type;
typedef typename std::iterator_traits<InputIterator>::reference reference;
typedef boost::readable_property_map_tag category;
};
/// Free function to use a get the value from an iterator using Input_iterator_property_map.
///
/// @relates Input_iterator_property_map
template <class InputIterator>
inline
typename std::iterator_traits<InputIterator>::reference
get(Input_iterator_property_map<InputIterator>,InputIterator it){ return *it; }
} // namespace CGAL } // namespace CGAL

View File

@ -24,18 +24,20 @@
#include <CGAL/property_map.h> #include <CGAL/property_map.h>
#include <boost/type_traits/is_const.hpp> #include <boost/type_traits/is_const.hpp>
#include <boost/mpl/if.hpp> #include <boost/mpl/if.hpp>
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
#include <CGAL/boost/graph/properties_Polyhedron_3.h>
namespace CGAL{ namespace CGAL{
//property map //property map
template <class Polyhedron> template <class Polyhedron>
struct Triangle_from_facet_property_map{ struct Triangle_from_facet_handle_property_map{
Triangle_from_facet_property_map(Polyhedron* = NULL){} Triangle_from_facet_handle_property_map(Polyhedron* = NULL){}
//classical typedefs //classical typedefs
typedef typename boost::mpl::if_< typedef typename boost::mpl::if_<
typename boost::is_const<Polyhedron>::type, typename boost::is_const<Polyhedron>::type,
const typename Polyhedron::Facet, typename Polyhedron::Facet_const_handle,
typename Polyhedron::Facet >::type key_type; typename Polyhedron::Facet_handle >::type key_type;
typedef typename Polyhedron::Traits::Kernel::Triangle_3 value_type; typedef typename Polyhedron::Traits::Kernel::Triangle_3 value_type;
typedef value_type reference; typedef value_type reference;
typedef boost::readable_property_map_tag category; typedef boost::readable_property_map_tag category;
@ -44,53 +46,55 @@ struct Triangle_from_facet_property_map{
template <class Polyhedron> template <class Polyhedron>
inline inline
typename Polyhedron::Traits::Kernel::Triangle_3 typename Polyhedron::Traits::Kernel::Triangle_3
get(const Triangle_from_facet_property_map<Polyhedron>&, get(Triangle_from_facet_handle_property_map<Polyhedron>,
typename Triangle_from_facet_property_map<Polyhedron>::key_type& f) typename Triangle_from_facet_handle_property_map<Polyhedron>::key_type f)
{ {
typedef typename Polyhedron::Traits::Kernel Kernel; typedef typename Polyhedron::Traits::Kernel Kernel;
CGAL_precondition(f.halfedge() == f.halfedge()->next()->next()->next()); CGAL_precondition(f->halfedge() == f->halfedge()->next()->next()->next());
const typename Kernel::Point_3& a = f.halfedge()->vertex()->point(); const typename Kernel::Point_3& a = f->halfedge()->vertex()->point();
const typename Kernel::Point_3& b = f.halfedge()->next()->vertex()->point(); const typename Kernel::Point_3& b = f->halfedge()->next()->vertex()->point();
const typename Kernel::Point_3& c = f.halfedge()->next()->next()->vertex()->point(); const typename Kernel::Point_3& c = f->halfedge()->next()->next()->vertex()->point();
return typename Kernel::Triangle_3(a,b,c); return typename Kernel::Triangle_3(a,b,c);
} }
template <class Polyhedron> template <class HalfedgeGraph>
struct Segment_from_halfedge_property_map{ struct Segment_from_edge_descriptor_property_map{
Segment_from_halfedge_property_map(Polyhedron* = NULL){} Segment_from_edge_descriptor_property_map(const HalfedgeGraph* g= NULL):m_graph( const_cast<HalfedgeGraph*>(g) ){}
//classical typedefs //classical typedefs
typedef typename boost::mpl::if_< typedef typename boost::property_traits< typename boost::property_map< HalfedgeGraph, vertex_point_t>::type >::value_type Point;
typename boost::is_const<Polyhedron>::type, typedef typename boost::graph_traits<HalfedgeGraph>::edge_descriptor key_type;
const typename Polyhedron::Halfedge, typedef typename Kernel_traits<Point>::Kernel::Segment_3 value_type;
typename Polyhedron::Halfedge >::type key_type;
typedef typename Polyhedron::Traits::Kernel::Segment_3 value_type;
typedef value_type reference; typedef value_type reference;
typedef boost::readable_property_map_tag category; typedef boost::readable_property_map_tag category;
//data
HalfedgeGraph* m_graph;
}; };
//get function for property map //get function for property map
template <class Polyhedron> template <class HalfedgeGraph>
inline inline
typename Polyhedron::Traits::Kernel::Segment_3 typename Segment_from_edge_descriptor_property_map<HalfedgeGraph>::value_type
get(const Segment_from_halfedge_property_map<Polyhedron>&, get(Segment_from_edge_descriptor_property_map<HalfedgeGraph> pmap,
typename Segment_from_halfedge_property_map<Polyhedron>::key_type& h) typename Segment_from_edge_descriptor_property_map<HalfedgeGraph>::key_type h)
{ {
typedef typename Polyhedron::Traits::Kernel Kernel; typedef typename boost::property_traits< typename boost::property_map< HalfedgeGraph, vertex_point_t>::type >::value_type Point;
const typename Kernel::Point_3& a = h.vertex()->point(); typedef typename Kernel_traits<Point>::Kernel Kernel;
const typename Kernel::Point_3& b = h.opposite()->vertex()->point(); const Point& a = boost::source(h,*pmap.m_graph)->point();
const Point& b = boost::target(h,*pmap.m_graph)->point();
return typename Kernel::Segment_3(a,b); return typename Kernel::Segment_3(a,b);
} }
//property map to access a point from a Facet //property map to access a point from a facet handle
template <class Polyhedron> template <class Polyhedron>
struct One_point_from_facet_property_map{ struct One_point_from_facet_handle_property_map{
One_point_from_facet_property_map(Polyhedron* = NULL){} One_point_from_facet_handle_property_map(Polyhedron* = NULL){}
//classical typedefs //classical typedefs
typedef typename boost::mpl::if_< typedef typename boost::mpl::if_<
typename boost::is_const<Polyhedron>::type, typename boost::is_const<Polyhedron>::type,
const typename Polyhedron::Facet, typename Polyhedron::Facet_const_handle,
typename Polyhedron::Facet >::type key_type; typename Polyhedron::Facet_handle >::type key_type;
typedef typename Polyhedron::Traits::Kernel::Point_3 value_type; typedef typename Polyhedron::Traits::Kernel::Point_3 value_type;
typedef const value_type& reference; typedef const value_type& reference;
typedef boost::lvalue_property_map_tag category; typedef boost::lvalue_property_map_tag category;
@ -98,34 +102,33 @@ struct One_point_from_facet_property_map{
//get function for property map //get function for property map
template <class Polyhedron> template <class Polyhedron>
inline inline
typename One_point_from_facet_property_map<Polyhedron>::reference typename One_point_from_facet_handle_property_map<Polyhedron>::reference
get(const One_point_from_facet_property_map<Polyhedron>&, get(One_point_from_facet_handle_property_map<Polyhedron>,
typename One_point_from_facet_property_map<Polyhedron>::key_type& f) typename One_point_from_facet_handle_property_map<Polyhedron>::key_type f)
{ {
return f.halfedge()->vertex()->point(); return f->halfedge()->vertex()->point();
} }
//property map to access a point from a Halfedge //property map to access a point from an edge
template <class Polyhedron> template <class HalfedgeGraph>
struct One_point_from_halfedge_property_map{ struct Source_point_from_edge_descriptor{
One_point_from_halfedge_property_map(Polyhedron* = NULL){} Source_point_from_edge_descriptor(const HalfedgeGraph* g= NULL):m_graph( const_cast<HalfedgeGraph*>(g) ){}
//classical typedefs //classical typedefs
typedef typename boost::mpl::if_< typedef typename boost::property_traits< typename boost::property_map< HalfedgeGraph, vertex_point_t>::type >::value_type value_type;
typename boost::is_const<Polyhedron>::type, typedef typename boost::property_traits< typename boost::property_map< HalfedgeGraph, vertex_point_t>::type >::reference reference;
const typename Polyhedron::Halfedge, typedef typename boost::graph_traits<HalfedgeGraph>::edge_descriptor key_type;
typename Polyhedron::Halfedge >::type key_type; typedef boost::readable_property_map_tag category;
typedef typename Polyhedron::Traits::Kernel::Point_3 value_type; //data
typedef const value_type& reference; HalfedgeGraph* m_graph;
typedef boost::lvalue_property_map_tag category;
}; };
//get function for property map //get function for property map
template <class Polyhedron> template <class HalfedgeGraph>
inline inline
typename One_point_from_halfedge_property_map<Polyhedron>::reference typename Source_point_from_edge_descriptor<HalfedgeGraph>::reference
get(const One_point_from_halfedge_property_map<Polyhedron>&, get(Source_point_from_edge_descriptor<HalfedgeGraph> pmap,
typename One_point_from_halfedge_property_map<Polyhedron>::key_type& h) typename boost::graph_traits<HalfedgeGraph>::edge_descriptor h)
{ {
return h.vertex()->point(); return boost::source(h,*pmap.m_graph)->point();
} }
} //namespace CGAL } //namespace CGAL