// 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_GRAPH_TRAITS_POLYHEDRON_3_H #define CGAL_BOOST_GRAPH_GRAPH_TRAITS_POLYHEDRON_3_H #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 // // NOTE: The BGL algorithms are NOT const-correct: i.e., they take a "G const&" // but instantiate "graph_traits" instead of "graph_traits" // This is known Boost bug which will eventually be fixed, but in the meantime we need // to coerce both const and non-const specializations. // That is, HDS_graph_traits is really the same as HDS_graph_traits // so graph_traits is also the same as graph_traits. // Therefore, while, for instance, "graph_traits::vertex_descriptor" // is conceptually const-correct, it actually corresponds to the non-const handle, // hence the const_cast<> used below in the functions implementation. // namespace boost { template struct graph_traits< CGAL::Polyhedron_3 > : CGAL::HDS_graph_traits< CGAL::Polyhedron_3 > {}; template struct graph_traits< CGAL::Polyhedron_3 const > : CGAL::HDS_graph_traits< CGAL::Polyhedron_3 > // See NOTE above! {}; template typename graph_traits< CGAL::Polyhedron_3 const>::vertices_size_type num_vertices(const CGAL::Polyhedron_3& p) { return p.size_of_vertices(); } template typename graph_traits< CGAL::Polyhedron_3 const>::edges_size_type num_edges(const CGAL::Polyhedron_3& p) { return p.size_of_halfedges() ; } template typename graph_traits< CGAL::Polyhedron_3 const>::degree_size_type degree(typename graph_traits< CGAL::Polyhedron_3 const>::vertex_descriptor v, const CGAL::Polyhedron_3&) { return v->vertex_degree() * 2 ; } template typename graph_traits< CGAL::Polyhedron_3 const>::degree_size_type out_degree(typename graph_traits< CGAL::Polyhedron_3 const>::vertex_descriptor v, const CGAL::Polyhedron_3&) { return v->vertex_degree(); } template typename graph_traits< CGAL::Polyhedron_3 const>::degree_size_type in_degree(typename graph_traits< CGAL::Polyhedron_3 const>::vertex_descriptor v, const CGAL::Polyhedron_3&) { return v->vertex_degree(); } template typename graph_traits< CGAL::Polyhedron_3 const>::vertex_descriptor source(typename graph_traits< CGAL::Polyhedron_3 const>::edge_descriptor e, const CGAL::Polyhedron_3 & ) { return e->opposite()->vertex(); } template typename graph_traits< CGAL::Polyhedron_3 const>::vertex_descriptor target(typename graph_traits< CGAL::Polyhedron_3 const>::edge_descriptor e, const CGAL::Polyhedron_3 & ) { return e->vertex(); } template inline std::pair const>::vertex_iterator ,typename graph_traits< CGAL::Polyhedron_3 const>::vertex_iterator > vertices( const CGAL::Polyhedron_3& p) { typedef typename graph_traits< CGAL::Polyhedron_3 const>::vertex_iterator Iter; CGAL::Polyhedron_3& ncp = const_cast&>(p); return std::make_pair( Iter(ncp.vertices_begin()), Iter(ncp.vertices_end()) ); } template inline std::pair const>::edge_iterator ,typename graph_traits< CGAL::Polyhedron_3 const>::edge_iterator > edges( const CGAL::Polyhedron_3& p) { typedef typename graph_traits< CGAL::Polyhedron_3 const>::edge_iterator Iter; CGAL::Polyhedron_3& ncp = const_cast&>(p); return std::make_pair( Iter(ncp.halfedges_begin()), Iter(ncp.halfedges_end()) ); } template inline std::pair const>::in_edge_iterator ,typename graph_traits< CGAL::Polyhedron_3 const>::in_edge_iterator > in_edges( typename graph_traits< CGAL::Polyhedron_3 const>::vertex_descriptor u, const CGAL::Polyhedron_3& g) { typename CGAL::Polyhedron_3::Halfedge_around_vertex_circulator ec = u->vertex_begin(); typename graph_traits< CGAL::Polyhedron_3 const>::edges_size_type in_deg = in_degree(u,g); typedef typename graph_traits< CGAL::Polyhedron_3 const>::in_edge_iterator Iter; return std::make_pair( Iter(ec), Iter(ec,in_deg) ); } template inline std::pair const>::out_edge_iterator ,typename graph_traits< CGAL::Polyhedron_3 const>::out_edge_iterator > out_edges( typename graph_traits< CGAL::Polyhedron_3 const>::vertex_descriptor u, const CGAL::Polyhedron_3& g) { typename CGAL::Polyhedron_3::Halfedge_around_vertex_circulator ec = u->vertex_begin(); typename graph_traits< CGAL::Polyhedron_3 const>::edges_size_type out_deg = out_degree(u,g); typedef typename graph_traits< CGAL::Polyhedron_3 const>::out_edge_iterator Iter; return std::make_pair( Iter(ec), Iter(ec,out_deg) ); } } // namespace boost #undef CGAL_HDS_PARAM_ #endif // CGAL_BOOST_GRAPH_GRAPH_TRAITS_POLYHEDRON_3_H