// Copyright (c) 2007 GeometryFactory (France). All rights reserved. // // This file is part of CGAL (www.cgal.org); you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; version 2.1 of the License. // See the file LICENSE.LGPL distributed with CGAL. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // // $URL$ // $Id$ // // // Author(s) : Andreas Fabri, Fernando Cacciola #ifndef CGAL_BOOST_GRAPH_PROPERTIES_POLYHEDRON_3_H #define CGAL_BOOST_GRAPH_PROPERTIES_POLYHEDRON_3_H #include #include #include #ifndef CGAL_CFG_NO_TMPL_IN_TMPL_PARAM # define CGAL_HDS_PARAM_ template < class Traits, class Items, class Alloc> class HDS #else # define CGAL_HDS_PARAM_ class HDS #endif CGAL_BEGIN_NAMESPACE template class Polyhedron_edge_weight_map : public boost::put_get_helper > { private: typedef CGAL::Polyhedron_3 Polyhedron ; public: typedef boost::readable_property_map_tag category; typedef double value_type; typedef double reference; typedef typename boost::graph_traits::edge_descriptor key_type; Polyhedron_edge_weight_map( Polyhedron const& ) {} reference operator[](key_type const& e) const { return CGAL::squared_distance(e->vertex()->point(), e->opposite()->vertex()->point()); } }; template class Polyhedron_edge_is_border_map : public boost::put_get_helper > { private: typedef CGAL::Polyhedron_3 Polyhedron ; public: typedef boost::readable_property_map_tag category; typedef bool value_type; typedef bool reference; typedef typename boost::graph_traits::edge_descriptor key_type; Polyhedron_edge_is_border_map( Polyhedron const& ) {} reference operator[](key_type const& e) const { return e->is_border(); } }; template class Polyhedron_edge_index_map_stored : public boost::put_get_helper > { private: typedef CGAL::Polyhedron_3 Polyhedron ; public: typedef boost::readable_property_map_tag category; typedef std::size_t value_type; typedef std::size_t reference; typedef typename boost::graph_traits::edge_descriptor key_type; Polyhedron_edge_index_map_stored( Polyhedron const& ) {} reference operator[](key_type const& e) const { return e->id(); } }; template class Polyhedron_edge_index_map_external : public boost::put_get_helper > { private: typedef CGAL::Polyhedron_3 Polyhedron ; public: typedef boost::readable_property_map_tag category; typedef std::size_t value_type; typedef std::size_t reference; typedef typename boost::graph_traits::edge_descriptor key_type; Polyhedron_edge_index_map_external( Polyhedron const& p) : map( remove_const(p).halfedges_begin() , remove_const(p).halfedges_end() , 0 , std::size_t(-1) , p.size_of_halfedges() ) {} reference operator[](key_type const& e) const { return map[e]; } private: static Polyhedron& remove_const ( Polyhedron const& p ) { return const_cast(p) ; } CGAL::Unique_hash_map map ; }; template class Polyhedron_vertex_point_map : public boost::put_get_helper< typename Gt::Point_3&, Polyhedron_vertex_point_map > { private: typedef CGAL::Polyhedron_3 Polyhedron ; public: typedef typename Gt::Point_3 Point_3 ; typedef boost::lvalue_property_map_tag category; typedef Point_3 value_type; typedef Point_3& reference; typedef typename boost::graph_traits::vertex_descriptor key_type; Polyhedron_vertex_point_map( Polyhedron& ) {} reference operator[](key_type const& v) const { return v->point(); } }; template class Polyhedron_vertex_point_const_map : public boost::put_get_helper< typename Gt::Point_3 const& , Polyhedron_vertex_point_const_map > { private: typedef CGAL::Polyhedron_3 Polyhedron ; public: typedef typename Gt::Point_3 Point_3 ; typedef boost::readable_property_map_tag category; typedef Point_3 value_type; typedef Point_3 const& reference; typedef typename boost::graph_traits::vertex_descriptor key_type; Polyhedron_vertex_point_const_map( Polyhedron const& ) {} reference operator[](key_type const& v) const { return v->point(); } }; template class Polyhedron_vertex_index_map_stored : public boost::put_get_helper > { private: typedef CGAL::Polyhedron_3 Polyhedron ; public: typedef boost::readable_property_map_tag category; typedef std::size_t value_type; typedef std::size_t reference; typedef typename boost::graph_traits::vertex_descriptor key_type; Polyhedron_vertex_index_map_stored( Polyhedron const& ) {} reference operator[](key_type const& v) const { return v->id(); } }; template class Polyhedron_vertex_index_map_external : public boost::put_get_helper > { private: typedef CGAL::Polyhedron_3 Polyhedron ; public: typedef boost::readable_property_map_tag category; typedef std::size_t value_type; typedef std::size_t reference; typedef typename boost::graph_traits::vertex_descriptor key_type; Polyhedron_vertex_index_map_external( Polyhedron const& p) : map( remove_const(p).vertices_begin() , remove_const(p).vertices_end() , 0 , std::size_t(-1) , p.size_of_vertices() ) {} reference operator[](key_type const& v) const { return map[v]; } private: static Polyhedron& remove_const ( Polyhedron const& p ) { return const_cast(p) ; } CGAL::Unique_hash_map map ; }; template struct Polyhedron_property_map {}; template <> struct Polyhedron_property_map { template struct bind_ { typedef Polyhedron_edge_weight_map type; typedef Polyhedron_edge_weight_map const_type; }; }; template <> struct Polyhedron_property_map { template struct bind_ { typedef Polyhedron_edge_index_map_stored type; typedef Polyhedron_edge_index_map_stored const_type; }; }; template <> struct Polyhedron_property_map { template struct bind_ { typedef Polyhedron_edge_index_map_external type; typedef Polyhedron_edge_index_map_external const_type; }; }; template <> struct Polyhedron_property_map { template struct bind_ { typedef Polyhedron_edge_is_border_map type; typedef Polyhedron_edge_is_border_map const_type; }; }; template <> struct Polyhedron_property_map { template struct bind_ { typedef Polyhedron_vertex_point_map type; typedef Polyhedron_vertex_point_const_map const_type; }; }; template <> struct Polyhedron_property_map { template struct bind_ { typedef Polyhedron_vertex_index_map_stored type; typedef Polyhedron_vertex_index_map_stored const_type; }; }; template <> struct Polyhedron_property_map { template struct bind_ { typedef Polyhedron_vertex_index_map_external type; typedef Polyhedron_vertex_index_map_external const_type; }; }; CGAL_END_NAMESPACE namespace boost { template inline CGAL::Polyhedron_edge_weight_map get( edge_weight_t, CGAL::Polyhedron_3 const& p) { CGAL::Polyhedron_edge_weight_map m(p); return m; } template inline CGAL::Polyhedron_edge_is_border_map get( CGAL::edge_is_border_t, CGAL::Polyhedron_3 const& p) { CGAL::Polyhedron_edge_is_border_map m(p); return m; } template inline CGAL::Polyhedron_edge_index_map_stored get( edge_index_t, CGAL::Polyhedron_3 const& p) { CGAL::Polyhedron_edge_index_map_stored m(p); return m; } template inline CGAL::Polyhedron_edge_index_map_external get( CGAL::edge_external_index_t, CGAL::Polyhedron_3 const& p) { CGAL::Polyhedron_edge_index_map_external m(p); return m; } template inline CGAL::Polyhedron_vertex_point_map get(CGAL::vertex_point_t, CGAL::Polyhedron_3& p) { CGAL::Polyhedron_vertex_point_map m(p); return m; } template inline CGAL::Polyhedron_vertex_point_const_map get(CGAL::vertex_point_t, CGAL::Polyhedron_3 const& p) { CGAL::Polyhedron_vertex_point_const_map m(p); return m; } template inline CGAL::Polyhedron_vertex_index_map_stored get(vertex_index_t, CGAL::Polyhedron_3 const& p) { CGAL::Polyhedron_vertex_index_map_stored m(p); return m; } template inline CGAL::Polyhedron_vertex_index_map_external get(CGAL::vertex_external_index_t, CGAL::Polyhedron_3 const& p) { CGAL::Polyhedron_vertex_index_map_external m(p); return m; } template struct property_map, Tag> { typedef typename CGAL::Polyhedron_property_map:: template bind_ map_gen; typedef typename map_gen::type type; typedef typename map_gen::const_type const_type; }; template inline typename property_traits,PropertyTag>::type>::reference get(PropertyTag p, CGAL::Polyhedron_3& g, const Key& key) { return get(get(p, g), key); } template inline typename property_traits,PropertyTag>::const_type>::reference get(PropertyTag p, CGAL::Polyhedron_3 const& g, const Key& key) { return get(get(p, g), key); } template inline void put(PropertyTag p, CGAL::Polyhedron_3& g, const Key& key, const Value& value) { typedef typename property_map, PropertyTag>::type Map; Map pmap = get(p, g); put(pmap, key, value); } // What are those needed for ??? template struct edge_property_type > { typedef edge_weight_t type; }; template struct vertex_property_type > { typedef CGAL::vertex_point_t type; }; } // namespace boost #undef CGAL_HDS_PARAM_ #endif // CGAL_BOOST_GRAPH_PROPERTIES_POLYHEDRON_3_H