]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Extensions/DataStructures/QuadEdgeIterators.h
7ba20f075eeb62e1da5b62acae631ff392f06888
[cpPlugins.git] / lib / cpPlugins / Extensions / DataStructures / QuadEdgeIterators.h
1 #ifndef __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEITERATORS__H__
2 #define __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEITERATORS__H__
3
4 #include <cstdlib>
5
6 // -------------------------------------------------------------------------
7 #define cpPluginsQEIteratorsMacro( op, it, cit )        \
8   inline it Begin##op( )                                \
9   { return( it( this, it::Op##op, true ) ); }           \
10   inline it End##op( )                                  \
11   { return( it( this, it::Op##op, false ) ); }          \
12   inline cit Begin##op( ) const                         \
13   { return( cit( this, cit::Op##op, true ) ); }         \
14   inline cit End##op( ) const                           \
15   { return( cit( this, cit::Op##op, false ) ); }
16
17 // -------------------------------------------------------------------------
18 #define cpPluginsExtensionsQEPointIteratorsMacro( op, it, cit ) \
19   inline Point##it BeginPoint##op( )                            \
20   { return( Point##it( this, it::Op##op, true ) ); }            \
21   inline Point##it EndPoint##op( )                              \
22   { return( Point##it( this, it::Op##op, false ) ); }           \
23   inline Point##cit BeginPoint##op( ) const                     \
24   { return( Point##cit( this, cit::Op##op, true ) ); }          \
25   inline Point##cit EndPoint  ##op( ) const                     \
26   { return( Point##cit( this, cit::Op##op, false ) ); }
27
28 // -------------------------------------------------------------------------
29 #define cpPluginsExtensionsQEAllIteratorsMacro( op )                    \
30   cpPluginsQEIteratorsMacro( op, Iterator, ConstIterator );             \
31   cpPluginsExtensionsQEPointIteratorsMacro( op, Iterator, ConstIterator );
32
33 namespace cpPlugins
34 {
35   namespace Extensions
36   {
37     namespace DataStructures
38     {
39       /**
40        */
41       template< class E >
42       class QuadEdgeBaseIterator
43       {
44       public:
45         typedef QuadEdgeBaseIterator Self;
46         typedef E                    TQuadEdge;
47
48         // Different types of logical iterators
49         enum
50         {
51           OpOnext = 0,
52           OpLnext = 1,
53           OpRnext = 2,
54           OpDnext = 3,
55           OpOprev = 4,
56           OpLprev = 5,
57           OpRprev = 6,
58           OpDprev = 7
59         };
60
61       public:
62         QuadEdgeBaseIterator( E* e, int op = OpOnext, bool start = true );
63         virtual ~QuadEdgeBaseIterator( );
64         Self& operator=( const Self& r );
65
66         E*   GetStartEdge( ) const;
67         E*   GetIterator( ) const;
68         int  GetOpType( ) const;
69         bool GetStart( ) const;
70
71         bool  operator==( Self& r );
72         bool  operator==( const Self& r ) const;
73         bool  operator!=( Self& r );
74         bool  operator!=( const Self& r ) const;
75         Self& operator++( );
76         Self& operator++( int );
77
78       protected:
79         /// Method that should do all the iteration work
80       virtual void _GoToNext( );
81
82       protected:
83         E*   m_StartEdge; /**< Start edge */
84         E*   m_Iterator;  /**< Current iteration position */
85         int  m_OpType;    /**< Operation type */
86         bool m_Start;     /**< Indicates iteration has just started */
87       };
88
89       /**
90        */
91       template< class E >
92       class QuadEdgeIterator
93         : public QuadEdgeBaseIterator< E >
94       {
95       public:
96         typedef QuadEdgeIterator          Self;
97         typedef QuadEdgeBaseIterator< E > Superclass;
98         typedef E                         TQuadEdge;
99
100       public:
101         QuadEdgeIterator(
102           E* e = NULL, int op = Superclass::OpOnext, bool start = true
103           );
104         virtual ~QuadEdgeIterator( );
105         E* operator*( );
106       };
107
108       /**
109        */
110       template< class E >
111       class QuadEdgeConstIterator
112         : public QuadEdgeBaseIterator< const E >
113       {
114       public:
115         typedef QuadEdgeConstIterator           Self;
116         typedef QuadEdgeBaseIterator< const E > Superclass;
117         typedef E                               TQuadEdge;
118
119       public:
120         QuadEdgeConstIterator(
121           const E* e = NULL, int op = Superclass::OpOnext, bool start = true
122           );
123         virtual ~QuadEdgeConstIterator( );
124         const E* operator*( ) const;
125       };
126
127       /**
128        */
129       template< class E >
130       class QuadEdgePointIterator
131         : public QuadEdgeBaseIterator< const E >
132       {
133       public:
134         typedef QuadEdgePointIterator           Self;
135         typedef QuadEdgeBaseIterator< const E > Superclass;
136         typedef E                               TQuadEdge;
137
138       public:
139         QuadEdgePointIterator(
140           const E* e = NULL, int op = Superclass::OpOnext, bool start = true
141           );
142         virtual ~QuadEdgePointIterator( );
143         typename E::TPrimalGeometry& operator*( );
144       };
145
146       /**
147        */
148       template< class E >
149       class QuadEdgePointConstIterator
150         : public QuadEdgeBaseIterator< const E >
151       {
152       public:
153         typedef QuadEdgePointConstIterator      Self;
154         typedef QuadEdgeBaseIterator< const E > Superclass;
155         typedef E                               TQuadEdge;
156
157       public:
158         QuadEdgePointConstIterator(
159           const E* e = NULL, int op = Superclass::OpOnext, bool start = true
160           );
161         virtual ~QuadEdgePointConstIterator( );
162         const typename E::TPrimalGeometry& operator*( ) const;
163       };
164
165     } // ecapseman
166
167   } // ecapseman
168
169 } // ecapseman
170
171 #include <cpPlugins/Extensions/DataStructures/QuadEdgeIterators.hxx>
172
173 #endif // __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEITERATORS__H__
174
175 // eof - $RCSfile$