BWAPI
|
00001 // Copyright (c) 1997 Utrecht University (The Netherlands), 00002 // ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany), 00003 // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg 00004 // (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria), 00005 // and Tel-Aviv University (Israel). All rights reserved. 00006 // 00007 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or 00008 // modify it under the terms of the GNU Lesser General Public License as 00009 // published by the Free Software Foundation; version 2.1 of the License. 00010 // See the file LICENSE.LGPL distributed with CGAL. 00011 // 00012 // Licensees holding a valid commercial license may use this file in 00013 // accordance with the commercial license agreement provided with the software. 00014 // 00015 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00017 // 00018 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/HalfedgeDS/include/CGAL/HalfedgeDS_iterator.h $ 00019 // $Id: HalfedgeDS_iterator.h 44130 2008-07-12 21:58:52Z spion $ 00020 // 00021 // 00022 // Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>) 00023 00024 #ifndef CGAL_HALFEDGEDS_ITERATOR_H 00025 #define CGAL_HALFEDGEDS_ITERATOR_H 1 00026 #include <CGAL/circulator.h> 00027 00028 CGAL_BEGIN_NAMESPACE 00029 00030 00031 00032 template < class It, class Ctg> 00033 class I_HalfedgeDS_facet_circ : public It { 00034 public: 00035 typedef It Iterator; 00036 typedef Ctg iterator_category; 00037 typedef I_HalfedgeDS_facet_circ<It,Ctg> Self; 00038 typedef std::iterator_traits<It> Traits; 00039 typedef typename Traits::value_type value_type; 00040 typedef typename Traits::difference_type difference_type; 00041 typedef std::size_t size_type; 00042 typedef typename Traits::reference reference; 00043 typedef typename Traits::pointer pointer; 00044 00045 // CREATION 00046 // -------- 00047 00048 I_HalfedgeDS_facet_circ() {} 00049 explicit I_HalfedgeDS_facet_circ( It i) : It(i) {} 00050 template <class It2, class Ctg2> 00051 I_HalfedgeDS_facet_circ( const I_HalfedgeDS_facet_circ<It2,Ctg2> &c) 00052 : It((const It2&)(c)) {} 00053 00054 // OPERATIONS Forward Category 00055 // --------------------------- 00056 00057 // pointer ptr() const { return & It::operator*();} 00058 00059 bool operator==( Nullptr_t CGAL_assertion_code(p)) const { 00060 CGAL_assertion( p == 0); 00061 return It::operator==( It()); 00062 } 00063 bool operator!=( Nullptr_t p) const { return !(*this == p); } 00064 bool operator==( const Self& i) const { return It::operator==(i); } 00065 bool operator!=( const Self& i) const { return !(*this == i); } 00066 00067 // operator* and operator-> are inherited. 00068 00069 Self& operator++() { 00070 *((Iterator*)this) = (*this)->next(); 00071 return *this; 00072 } 00073 Self operator++(int) { 00074 Self tmp = *this; 00075 ++*this; 00076 return tmp; 00077 } 00078 00079 // OPERATIONS Bidirectional Category 00080 // --------------------------------- 00081 00082 Self& operator--() { 00083 *((Iterator*)this) = (*this)->prev(); 00084 return *this; 00085 } 00086 Self operator--(int) { 00087 Self tmp = *this; 00088 --*this; 00089 return tmp; 00090 } 00091 }; 00092 template < class It, class Ctg> 00093 class I_HalfedgeDS_vertex_circ : public It { 00094 public: 00095 typedef It Iterator; 00096 typedef Ctg iterator_category; 00097 typedef I_HalfedgeDS_vertex_circ<It,Ctg> Self; 00098 typedef std::iterator_traits<It> Traits; 00099 typedef typename Traits::value_type value_type; 00100 typedef typename Traits::difference_type difference_type; 00101 typedef std::size_t size_type; 00102 typedef typename Traits::reference reference; 00103 typedef typename Traits::pointer pointer; 00104 00105 // CREATION 00106 // -------- 00107 00108 I_HalfedgeDS_vertex_circ() {} 00109 explicit I_HalfedgeDS_vertex_circ( It i) : It(i) {} 00110 template <class It2, class Ctg2> 00111 I_HalfedgeDS_vertex_circ( const I_HalfedgeDS_vertex_circ<It2,Ctg2> &c) 00112 : It((const It2&)(c)) {} 00113 00114 // OPERATIONS Forward Category 00115 // --------------------------- 00116 00117 // pointer ptr() const { return & It::operator*();} 00118 00119 bool operator==( Nullptr_t CGAL_assertion_code(p)) const { 00120 CGAL_assertion( p == 0); 00121 return It::operator==( It()); 00122 } 00123 bool operator!=( Nullptr_t p) const { return !(*this == p); } 00124 bool operator==( const Self& i) const { return It::operator==(i); } 00125 bool operator!=( const Self& i) const { return !(*this == i); } 00126 00127 // operator* and operator-> are inherited. 00128 00129 Self& operator++() { 00130 *((Iterator*)this) = (*this)->next()->opposite(); 00131 return *this; 00132 } 00133 Self operator++(int) { 00134 Self tmp = *this; 00135 ++*this; 00136 return tmp; 00137 } 00138 00139 // OPERATIONS Bidirectional Category 00140 // --------------------------------- 00141 00142 Self& operator--() { 00143 *((Iterator*)this) = (*this)->opposite()->prev(); 00144 return *this; 00145 } 00146 Self operator--(int) { 00147 Self tmp = *this; 00148 --*this; 00149 return tmp; 00150 } 00151 }; 00152 00153 // Determine the circulator category: If prev() is supported, 00154 // its bidirectional, otherwise its forward. 00155 00156 template < class T> struct HalfedgeDS_circulator_traits {}; 00157 00158 template <> 00159 struct HalfedgeDS_circulator_traits<Tag_true> { 00160 typedef Bidirectional_circulator_tag iterator_category; 00161 }; 00162 00163 template <> 00164 struct HalfedgeDS_circulator_traits<Tag_false> { 00165 typedef Forward_circulator_tag iterator_category; 00166 }; 00167 00168 // portability with other code using the old HalfedgeDS circulators 00169 00170 template < class Node, class It, class Ctg> 00171 class _HalfedgeDS_facet_circ : public It { 00172 // Ptr nt; // The internal node ptr inherited from It. 00173 public: 00174 typedef It Base; 00175 typedef _HalfedgeDS_facet_circ<Node,It,Ctg> Self; 00176 00177 typedef Ctg iterator_category; 00178 typedef Node value_type; 00179 typedef std::ptrdiff_t difference_type; 00180 typedef std::size_t size_type; 00181 typedef value_type& reference; 00182 typedef value_type* pointer; 00183 00184 00185 // CREATION 00186 // -------- 00187 00188 _HalfedgeDS_facet_circ() : It(0) {} 00189 //_HalfedgeDS_facet_circ( pointer p) : It(p) {} 00190 _HalfedgeDS_facet_circ( It i) : It(i) {} 00191 00192 // OPERATIONS Forward Category 00193 // --------------------------- 00194 00195 pointer ptr() const { return & It::operator*();} 00196 00197 bool operator==( Nullptr_t p) const { 00198 CGAL_assertion( p == NULL); 00199 return It::operator==( It(NULL)); 00200 } 00201 bool operator!=( Nullptr_t p) const { return !(*this == p); } 00202 bool operator==( const Self& i) const { return It::operator==(i); } 00203 bool operator!=( const Self& i) const { return !(*this == i); } 00204 00205 Self& operator++() { 00206 this->nt = (*this->nt).next(); 00207 return *this; 00208 } 00209 Self operator++(int) { 00210 Self tmp = *this; 00211 ++*this; 00212 return tmp; 00213 } 00214 00215 // OPERATIONS Bidirectional Category 00216 // --------------------------------- 00217 00218 Self& operator--() { 00219 this->nt = (*this->nt).prev(); 00220 return *this; 00221 } 00222 Self operator--(int) { 00223 Self tmp = *this; 00224 --*this; 00225 return tmp; 00226 } 00227 }; 00228 00229 00230 template < class Node, class It, class Ctg> 00231 class _HalfedgeDS_facet_const_circ : public It { 00232 // Ptr nt; // The internal node ptr inherited from It. 00233 public: 00234 typedef It Base; 00235 typedef _HalfedgeDS_facet_const_circ<Node,It,Ctg> Self; 00236 00237 typedef Ctg iterator_category; 00238 typedef Node value_type; 00239 typedef std::ptrdiff_t difference_type; 00240 typedef std::size_t size_type; 00241 typedef const value_type& reference; 00242 typedef const value_type* pointer; 00243 00244 // CREATION 00245 // -------- 00246 00247 _HalfedgeDS_facet_const_circ() : It(0) {} 00248 _HalfedgeDS_facet_const_circ( pointer p) : It(p) {} 00249 _HalfedgeDS_facet_const_circ( It i) : It(i) {} 00250 00251 template <class NN, class II, class CTG> 00252 _HalfedgeDS_facet_const_circ( const _HalfedgeDS_facet_circ<NN,II,CTG>& c) 00253 : It(c.ptr()) {} 00254 00255 // OPERATIONS Forward Category 00256 // --------------------------- 00257 00258 pointer ptr() const { return & It::operator*();} 00259 00260 bool operator==( Nullptr_t p) const { 00261 CGAL_assertion( p == NULL); 00262 return It::operator==( It(NULL)); 00263 } 00264 bool operator!=( Nullptr_t p) const { return !(*this == p); } 00265 bool operator==( const Self& i) const { return It::operator==(i); } 00266 bool operator!=( const Self& i) const { return !(*this == i); } 00267 00268 Self& operator++() { 00269 this->nt = (*this->nt).next(); 00270 return *this; 00271 } 00272 Self operator++(int) { 00273 Self tmp = *this; 00274 ++*this; 00275 return tmp; 00276 } 00277 00278 // OPERATIONS Bidirectional Category 00279 // --------------------------------- 00280 00281 Self& operator--() { 00282 this->nt = (*this->nt).prev(); 00283 return *this; 00284 } 00285 Self operator--(int) { 00286 Self tmp = *this; 00287 --*this; 00288 return tmp; 00289 } 00290 }; 00291 00292 template < class Node, class It, class Ctg> 00293 class _HalfedgeDS_vertex_circ : public It { 00294 // Ptr nt; // The internal node ptr inherited from It. 00295 public: 00296 typedef It Base; 00297 typedef _HalfedgeDS_vertex_circ<Node,It,Ctg> Self; 00298 00299 typedef Ctg iterator_category; 00300 typedef Node value_type; 00301 typedef std::ptrdiff_t difference_type; 00302 typedef std::size_t size_type; 00303 typedef value_type& reference; 00304 typedef value_type* pointer; 00305 00306 // CREATION 00307 // -------- 00308 00309 _HalfedgeDS_vertex_circ() : It(0) {} 00310 //_HalfedgeDS_vertex_circ( pointer p) : It(p) {} 00311 _HalfedgeDS_vertex_circ( It i) : It(i) {} 00312 00313 // OPERATIONS Forward Category 00314 // --------------------------- 00315 00316 pointer ptr() const { return & It::operator*();} 00317 00318 bool operator==( Nullptr_t p) const { 00319 CGAL_assertion( p == NULL); 00320 return It::operator==( It(NULL)); 00321 } 00322 bool operator!=( Nullptr_t p) const { return !(*this == p); } 00323 bool operator==( const Self& i) const { return It::operator==(i); } 00324 bool operator!=( const Self& i) const { return !(*this == i); } 00325 00326 Self& operator++() { 00327 this->nt = (*this->nt).next()->opposite(); 00328 return *this; 00329 } 00330 Self operator++(int) { 00331 Self tmp = *this; 00332 ++*this; 00333 return tmp; 00334 } 00335 00336 // OPERATIONS Bidirectional Category 00337 // --------------------------------- 00338 00339 Self& operator--() { 00340 this->nt = (*this->nt).opposite()->prev(); 00341 return *this; 00342 } 00343 Self operator--(int) { 00344 Self tmp = *this; 00345 --*this; 00346 return tmp; 00347 } 00348 }; 00349 00350 00351 template < class Node, class It, class Ctg> 00352 class _HalfedgeDS_vertex_const_circ : public It { 00353 // Ptr nt; // The internal node ptr inherited from It. 00354 public: 00355 typedef It Base; 00356 typedef _HalfedgeDS_vertex_const_circ<Node,It,Ctg> Self; 00357 00358 typedef Ctg iterator_category; 00359 typedef Node value_type; 00360 typedef std::ptrdiff_t difference_type; 00361 typedef std::size_t size_type; 00362 typedef const value_type& reference; 00363 typedef const value_type* pointer; 00364 00365 // CREATION 00366 // -------- 00367 00368 _HalfedgeDS_vertex_const_circ() : It(0) {} 00369 _HalfedgeDS_vertex_const_circ( pointer p) : It(p) {} 00370 _HalfedgeDS_vertex_const_circ( It i) : It(i) {} 00371 00372 template <class NN, class II, class CTG> 00373 _HalfedgeDS_vertex_const_circ( const _HalfedgeDS_vertex_circ<NN,II,CTG>& c) 00374 : It(c.ptr()) {} 00375 00376 // OPERATIONS Forward Category 00377 // --------------------------- 00378 00379 pointer ptr() const { return & It::operator*();} 00380 00381 bool operator==( Nullptr_t p) const { 00382 CGAL_assertion( p == NULL); 00383 return It::operator==( It(NULL)); 00384 } 00385 bool operator!=( Nullptr_t p) const { return !(*this == p); } 00386 bool operator==( const Self& i) const { return It::operator==(i); } 00387 bool operator!=( const Self& i) const { return !(*this == i); } 00388 00389 Self& operator++() { 00390 this->nt = (*this->nt).next()->opposite(); 00391 return *this; 00392 } 00393 Self operator++(int) { 00394 Self tmp = *this; 00395 ++*this; 00396 return tmp; 00397 } 00398 00399 // OPERATIONS Bidirectional Category 00400 // --------------------------------- 00401 00402 Self& operator--() { 00403 this->nt = (*this->nt).opposite()->prev(); 00404 return *this; 00405 } 00406 Self operator--(int) { 00407 Self tmp = *this; 00408 --*this; 00409 return tmp; 00410 } 00411 }; 00412 00413 CGAL_END_NAMESPACE 00414 #endif // CGAL_HALFEDGEDS_ITERATOR_H // 00415 // EOF //