BWAPI
|
00001 // Copyright (c) 2007 GeometryFactory (France). All rights reserved. 00002 // 00003 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or 00004 // modify it under the terms of the GNU Lesser General Public License as 00005 // published by the Free Software Foundation; version 2.1 of the License. 00006 // See the file LICENSE.LGPL distributed with CGAL. 00007 // 00008 // Licensees holding a valid commercial license may use this file in 00009 // accordance with the commercial license agreement provided with the software. 00010 // 00011 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 // 00014 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/BGL/include/CGAL/boost/graph/halfedge_graph_traits_Polyhedron_3.h $ 00015 // $Id: halfedge_graph_traits_Polyhedron_3.h 43252 2008-05-21 17:13:31Z fcacciola $ 00016 // 00017 // 00018 // Author(s) : Andreas Fabri, Fernando Cacciola 00019 00020 00021 #ifndef CGAL_BOOST_GRAPH_HALFEDGE_GRAPH_TRAITS_POLYHEDRON_3_H 00022 #define CGAL_BOOST_GRAPH_HALFEDGE_GRAPH_TRAITS_POLYHEDRON_3_H 00023 00024 #include <CGAL/HalfedgeDS_items_decorator.h> 00025 #include <CGAL/boost/graph/graph_traits_Polyhedron_3.h> 00026 #include <CGAL/boost/graph/halfedge_graph_traits.h> 00027 #include <CGAL/boost/graph/halfedge_graph_traits_HalfedgeDS.h> 00028 00029 #ifndef CGAL_CFG_NO_TMPL_IN_TMPL_PARAM 00030 # define CGAL_HDS_PARAM_ template < class Traits, class Items, class Alloc> class HDS 00031 #else 00032 # define CGAL_HDS_PARAM_ class HDS 00033 #endif 00034 00035 // 00036 // NOTE: The BGL algorithms are NOT const-correct: i.e., they take a "G const&" 00037 // but instantiate "graph_traits<G>" instead of "graph_traits<G const>" 00038 // This is known Boost bug which will eventually be fixed, but in the meantime we need 00039 // to coerce both const and non-const specializations. 00040 // That is, HDS_graph_traits<G const> is really the same as HDS_graph_traits<G> 00041 // so graph_traits<G> is also the same as graph_traits<G const>. 00042 // Therefore, while, for instance, "graph_traits<G const>::vertex_descriptor" 00043 // is conceptually const-correct, it actually corresponds to the non-const handle, 00044 // hence the const_cast<> used below in the functions implementation. 00045 // 00046 00047 CGAL_BEGIN_NAMESPACE 00048 00049 // 00050 // Const versions 00051 // 00052 template<class Gt, class I, CGAL_HDS_PARAM_, class A> 00053 struct halfedge_graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const > 00054 : CGAL::HDS_halfedge_graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> > // See NOTE above! 00055 { 00056 }; 00057 00058 template<class Gt, class I, CGAL_HDS_PARAM_, class A> 00059 inline std::pair<typename halfedge_graph_traits< Polyhedron_3<Gt,I,HDS,A> const>::undirected_edge_iterator 00060 ,typename halfedge_graph_traits< Polyhedron_3<Gt,I,HDS,A> const>::undirected_edge_iterator 00061 > 00062 undirected_edges( Polyhedron_3<Gt,I,HDS,A> const& p ) 00063 { 00064 typedef typename halfedge_graph_traits< Polyhedron_3<Gt,I,HDS,A> const>::undirected_edge_iterator Iter; 00065 CGAL::Polyhedron_3<Gt,I,HDS,A>& ncp = const_cast<CGAL::Polyhedron_3<Gt,I,HDS,A>&>(p); 00066 return std::make_pair( Iter(ncp.edges_begin()), Iter(ncp.edges_end()) ); 00067 } 00068 00069 template<class Gt, class I, CGAL_HDS_PARAM_, class A> 00070 typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> const>::edge_descriptor 00071 next_edge( typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> const>::edge_descriptor outedge 00072 , Polyhedron_3<Gt,I,HDS,A> const& 00073 ) 00074 { 00075 return outedge->next(); 00076 } 00077 00078 template<class Gt, class I, CGAL_HDS_PARAM_, class A> 00079 typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> const>::edge_descriptor 00080 prev_edge( typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> const>::edge_descriptor outedge 00081 , Polyhedron_3<Gt,I,HDS,A> const& 00082 ) 00083 { 00084 HalfedgeDS_items_decorator< Polyhedron_3<Gt,I,HDS,A> > D ; 00085 return D.get_prev(outedge); 00086 } 00087 00088 template<class Gt, class I, CGAL_HDS_PARAM_, class A> 00089 typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> const>::edge_descriptor 00090 opposite_edge( typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> const>::edge_descriptor e 00091 , Polyhedron_3<Gt,I,HDS,A> const& 00092 ) 00093 { 00094 return e->opposite(); 00095 } 00096 00097 template<class Gt, class I, CGAL_HDS_PARAM_, class A> 00098 typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> const>::edge_descriptor 00099 next_edge_ccw( typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> const>::edge_descriptor outedge 00100 , Polyhedron_3<Gt,I,HDS,A> const& 00101 ) 00102 { 00103 HalfedgeDS_items_decorator< Polyhedron_3<Gt,I,HDS,A> > D ; 00104 return D.get_prev(outedge)->opposite(); 00105 } 00106 00107 template<class Gt, class I, CGAL_HDS_PARAM_, class A> 00108 typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> const>::edge_descriptor 00109 next_edge_cw( typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> const>::edge_descriptor outedge 00110 , Polyhedron_3<Gt,I,HDS,A> const& 00111 ) 00112 { 00113 return outedge->opposite()->next(); 00114 } 00115 00116 00117 // 00118 // Non-const versions 00119 // 00120 00121 template<class Gt, class I, CGAL_HDS_PARAM_, class A> 00122 struct halfedge_graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> > 00123 : CGAL::HDS_halfedge_graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> > 00124 { 00125 }; 00126 00127 template<class Gt, class I, CGAL_HDS_PARAM_, class A> 00128 inline std::pair<typename halfedge_graph_traits< Polyhedron_3<Gt,I,HDS,A> >::undirected_edge_iterator 00129 ,typename halfedge_graph_traits< Polyhedron_3<Gt,I,HDS,A> >::undirected_edge_iterator 00130 > 00131 undirected_edges( Polyhedron_3<Gt,I,HDS,A>& p ) 00132 { 00133 typedef typename halfedge_graph_traits< Polyhedron_3<Gt,I,HDS,A> >::undirected_edge_iterator Iter; 00134 CGAL::Polyhedron_3<Gt,I,HDS,A>& ncp = const_cast<CGAL::Polyhedron_3<Gt,I,HDS,A>&>(p); 00135 return std::make_pair( Iter(ncp.edges_begin()), Iter(ncp.edges_end()) ); 00136 } 00137 00138 template<class Gt, class I, CGAL_HDS_PARAM_, class A> 00139 typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> >::edge_descriptor 00140 next_edge( typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> >::edge_descriptor outedge 00141 , Polyhedron_3<Gt,I,HDS,A>& 00142 ) 00143 { 00144 return outedge->next(); 00145 } 00146 00147 00148 template<class Gt, class I, CGAL_HDS_PARAM_, class A> 00149 typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> >::edge_descriptor 00150 prev_edge( typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> >::edge_descriptor outedge 00151 , Polyhedron_3<Gt,I,HDS,A>& 00152 ) 00153 { 00154 CGAL::HalfedgeDS_items_decorator< Polyhedron_3<Gt,I,HDS,A> > D ; 00155 return D.get_prev(outedge); 00156 } 00157 00158 00159 template<class Gt, class I, CGAL_HDS_PARAM_, class A> 00160 typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> >::edge_descriptor 00161 opposite_edge( typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> >::edge_descriptor e 00162 , Polyhedron_3<Gt,I,HDS,A>& 00163 ) 00164 { 00165 return e->opposite(); 00166 } 00167 00168 00169 template<class Gt, class I, CGAL_HDS_PARAM_, class A> 00170 typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> >::edge_descriptor 00171 next_edge_ccw( typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> >::edge_descriptor outedge 00172 , Polyhedron_3<Gt,I,HDS,A>& 00173 ) 00174 { 00175 HalfedgeDS_items_decorator< Polyhedron_3<Gt,I,HDS,A> > D ; 00176 return D.get_prev(outedge)->opposite(); 00177 } 00178 00179 00180 template<class Gt, class I, CGAL_HDS_PARAM_, class A> 00181 typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> >::edge_descriptor 00182 next_edge_cw( typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> >::edge_descriptor outedge 00183 , Polyhedron_3<Gt,I,HDS,A>& 00184 ) 00185 { 00186 return outedge->opposite()->next(); 00187 } 00188 00189 00190 CGAL_END_NAMESPACE 00191 00192 #undef CGAL_HDS_ 00193 00194 #endif // CGAL_BOOST_GRAPH_HALFEDGE_GRAPH_TRAITS_POLYHEDRON_3_H