BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Polygon_2/Polygon_2_edge_circulator.h
Go to the documentation of this file.
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/Polygon/include/CGAL/Polygon_2/Polygon_2_edge_circulator.h $
00019 // $Id: Polygon_2_edge_circulator.h 45787 2008-09-25 19:15:00Z spion $
00020 // 
00021 //
00022 // Author(s)     : Wieger Wesselink <wieger@cs.ruu.nl>
00023 
00024 #ifndef CGAL_POLYGON_2_EDGE_CIRCULATOR_H
00025 #define CGAL_POLYGON_2_EDGE_CIRCULATOR_H
00026 
00027 #include <iterator>
00028 #include <CGAL/circulator.h>
00029 #include <CGAL/Polygon_2/Polygon_2_vertex_circulator.h>
00030 #include <CGAL/Polygon_2/polygon_assertions.h>
00031 
00032 CGAL_BEGIN_NAMESPACE
00033 
00034 template <class _Traits, class _Container> class Polygon_2;
00035 
00036 template <class _Traits, class _Container>
00037 class Polygon_2_const_edge_circulator {
00038   public:
00039     typedef _Traits Traits;
00040     typedef typename _Traits::Segment_2 Segment_2;
00041     typedef _Container Container;
00042 //    typedef Bidirectional_const_circulator_from_container<_Container>
00043     typedef Polygon_circulator<_Container>
00044             Vertex_const_circulator;
00045 
00046     typedef Segment_2                            value_type;
00047     typedef typename _Container::difference_type difference_type;
00048     typedef typename _Container::size_type       size_type;
00049     typedef Segment_2*                           pointer;
00050     typedef const Segment_2*                     const_pointer;
00051     typedef Segment_2&                           reference;
00052     typedef const Segment_2&                     const_reference;
00053     typedef Bidirectional_circulator_tag    iterator_category;
00054 
00055   private:
00056     Vertex_const_circulator first_vertex;
00057 
00058   public:
00059     Polygon_2_const_edge_circulator() {}
00060 
00061     Polygon_2_const_edge_circulator(Vertex_const_circulator f)
00062       : first_vertex(f) {}
00063 
00064     bool operator==( Nullptr_t p ) const {
00065       CGAL_polygon_assertion( p == 0);
00066       return (first_vertex == 0);
00067     }
00068 
00069     bool operator!=( Nullptr_t p ) const
00070     {
00071       return !(*this == p);
00072     }
00073 
00074     bool
00075     operator==(
00076       const Polygon_2_const_edge_circulator<_Traits, _Container>& x) const
00077     {
00078       return first_vertex == x.first_vertex;
00079     }
00080 
00081     bool
00082     operator!=(
00083       const Polygon_2_const_edge_circulator<_Traits, _Container>& x) const
00084     {
00085       return !(first_vertex == x.first_vertex);
00086     }
00087 
00088     Segment_2 operator*() const
00089     {
00090       Vertex_const_circulator second_vertex = first_vertex;
00091       ++second_vertex;
00092       typename Traits::Construct_segment_2 construct_segment_2 = 
00093             Traits().construct_segment_2_object();
00094       return construct_segment_2(*first_vertex, *second_vertex);
00095     }
00096 
00097     Polygon_2_const_edge_circulator<_Traits, _Container>& operator++()
00098     {
00099       ++first_vertex;
00100       return *this;
00101     }
00102 
00103     Polygon_2_const_edge_circulator<_Traits, _Container> operator++(int)
00104     {
00105       Polygon_2_const_edge_circulator<_Traits, _Container> tmp = *this;
00106       ++*this;
00107       return tmp;
00108     }
00109 
00110     Polygon_2_const_edge_circulator<_Traits, _Container>& operator--()
00111     {
00112       --first_vertex;
00113       return *this;
00114     }
00115 
00116     Polygon_2_const_edge_circulator<_Traits, _Container> operator--(int)
00117     {
00118       Polygon_2_const_edge_circulator<_Traits, _Container> tmp = *this;
00119       --*this;
00120       return tmp;
00121     }
00122 
00123 // random access iterator requirements
00124     Polygon_2_const_edge_circulator<_Traits, _Container>&
00125     operator+=(difference_type n)
00126     {
00127       first_vertex += n;
00128       return *this;
00129     }
00130 
00131     Polygon_2_const_edge_circulator<_Traits, _Container>
00132     operator+(difference_type n) const
00133     {
00134       return Polygon_2_const_edge_circulator<_Traits, _Container>(
00135         this->container, first_vertex + n);
00136     }
00137 
00138     Polygon_2_const_edge_circulator<_Traits, _Container>&
00139     operator-=(difference_type n)
00140     {
00141       return (*this) -= n;
00142     }
00143 
00144     Polygon_2_const_edge_circulator<_Traits, _Container>
00145     operator-(difference_type n) const
00146     {
00147       return Polygon_2_const_edge_circulator<_Traits, _Container>(
00148         this->container, first_vertex - n);
00149     }
00150 
00151     difference_type
00152     operator-(
00153       const Polygon_2_const_edge_circulator<_Traits, _Container>& a) const
00154     {
00155       return first_vertex - a.first_vertex;
00156     }
00157 
00158     Segment_2 operator[](int n) const
00159     {
00160       return *Polygon_2_const_edge_circulator<_Traits, _Container>(
00161         this->container, first_vertex+n);
00162     }
00163 
00164     bool operator<(
00165       const Polygon_2_const_edge_circulator<_Traits, _Container>& a) const
00166     {
00167       return first_vertex < a.first_vertex;
00168     }
00169 
00170     bool operator>(
00171       const Polygon_2_const_edge_circulator<_Traits, _Container>& a) const
00172     {
00173       return first_vertex > a.first_vertex;
00174     }
00175 
00176     bool operator<=(
00177       const Polygon_2_const_edge_circulator<_Traits, _Container>& a) const
00178     {
00179       return first_vertex <= a.first_vertex;
00180     }
00181 
00182     bool operator>=(
00183       const Polygon_2_const_edge_circulator<_Traits, _Container>& a) const
00184     {
00185       return first_vertex >= a.first_vertex;
00186     }
00187 
00188 };
00189 
00190 /*
00191 template <class _Traits, class _Container>
00192 typename _Container::difference_type
00193 distance_type(
00194   const Polygon_2_const_edge_circulator<_Traits,_Container>&)
00195 {
00196   return typename _Container::difference_type();
00197 }
00198 
00199 template <class _Traits, class _Container>
00200 typename _Traits::Segment_2*
00201 value_type(const Polygon_2_const_edge_circulator<_Traits,_Container>&)
00202 {
00203   return (typename _Traits::Segment_2*)(0);
00204 }
00205 */
00206 
00207 //-----------------------------------------------------------------------//
00208 //                          implementation
00209 //-----------------------------------------------------------------------//
00210 
00211 //--------------------------------------------------------------------//
00212 // I don't know how to implement the following function:
00213 //
00214 // template <class _Traits, class _Container>
00215 // inline
00216 // Polygon_2_const_edge_circulator<_Traits, _Container>
00217 // operator+(_Container::difference_type n,
00218 //           Polygon_2_const_edge_circulator<_Traits, _Container>& a)
00219 // { return a+n; }
00220 //--------------------------------------------------------------------//
00221 
00222 CGAL_END_NAMESPACE
00223 
00224 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines