]> Creatis software - cpMesh.git/blob - lib/cpm/DataStructures/QuadEdgeIterators.hxx
Read/Write image plugin integration
[cpMesh.git] / lib / cpm / DataStructures / QuadEdgeIterators.hxx
1 #ifndef __CPM__DATASTRUCTURES__QUADEDGEITERATORS__HXX__
2 #define __CPM__DATASTRUCTURES__QUADEDGEITERATORS__HXX__
3
4 // -------------------------------------------------------------------------
5 template< class E >
6 cpm::DataStructures::QuadEdgeBaseIterator< E >::
7 QuadEdgeBaseIterator( E* e, int op, bool start )
8   : m_StartEdge( e ),
9     m_Iterator( e ),
10     m_OpType( op ),
11     m_Start( start )
12 {
13 }
14
15 // -------------------------------------------------------------------------
16 template< class E >
17 cpm::DataStructures::QuadEdgeBaseIterator< E >::
18 ~QuadEdgeBaseIterator( )
19 {
20 }
21
22 // -------------------------------------------------------------------------
23 template< class E >
24 typename cpm::DataStructures::QuadEdgeBaseIterator< E >::
25 Self& cpm::DataStructures::QuadEdgeBaseIterator< E >::
26 operator=( const Self& r )
27 {
28   if( this != &r )
29   {
30     this->m_StartEdge = r.m_StartEdge;
31     this->m_Iterator = r.m_Iterator;
32     this->m_OpType = r.m_OpType;
33     this->m_Start = r.m_Start;
34
35   } // fi
36   return( *this );
37 }
38
39 // -------------------------------------------------------------------------
40 template< class E >
41 E* cpm::DataStructures::QuadEdgeBaseIterator< E >::
42 GetStartEdge( ) const
43 {
44   return( this->m_StartEdge );
45 }
46
47 // -------------------------------------------------------------------------
48 template< class E >
49 E* cpm::DataStructures::QuadEdgeBaseIterator< E >::
50 GetIterator( ) const
51 {
52   return( this->m_Iterator );
53 }
54
55 // -------------------------------------------------------------------------
56 template< class E >
57 int cpm::DataStructures::QuadEdgeBaseIterator< E >::
58 GetOpType( ) const
59 {
60   return( this->m_OpType );
61 }
62
63 // -------------------------------------------------------------------------
64 template< class E >
65 bool cpm::DataStructures::QuadEdgeBaseIterator< E >::
66 GetStart( ) const
67 {
68   return( this->m_Start );
69 }
70
71 // -------------------------------------------------------------------------
72 template< class E >
73 bool cpm::DataStructures::QuadEdgeBaseIterator< E >::
74 operator==( Self& r )
75 {
76   return(
77     ( this->m_StartEdge == r.m_StartEdge ) &&
78     ( this->m_Iterator  == r.m_Iterator ) &&
79     ( this->m_OpType    == r.m_OpType ) &&
80     ( this->m_Start     == r.m_Start )
81     );
82 }
83
84 // -------------------------------------------------------------------------
85 template< class E >
86 bool cpm::DataStructures::QuadEdgeBaseIterator< E >::
87 operator==( const Self& r ) const
88 {
89   return(
90     ( this->m_StartEdge == r.m_StartEdge ) &&
91     ( this->m_Iterator  == r.m_Iterator ) &&
92     ( this->m_OpType    == r.m_OpType ) &&
93     ( this->m_Start     == r.m_Start )
94     );
95 }
96
97 // -------------------------------------------------------------------------
98 template< class E >
99 bool cpm::DataStructures::QuadEdgeBaseIterator< E >::
100 operator!=( Self& r )
101 {
102   return( !( this->operator==( r ) ) );
103 }
104
105 // -------------------------------------------------------------------------
106 template< class E >
107 bool cpm::DataStructures::QuadEdgeBaseIterator< E >::
108 operator!=( const Self& r ) const
109 {
110   return( !( this->operator==( r ) ) );
111 }
112
113 // -------------------------------------------------------------------------
114 template< class E >
115 typename cpm::DataStructures::QuadEdgeBaseIterator< E >::
116 Self& cpm::DataStructures::QuadEdgeBaseIterator< E >::
117 operator++( )
118 {
119   if( this->m_Start )
120   {
121     this->_GoToNext( );
122     this->m_Start = !( this->m_Iterator == this->m_StartEdge );
123
124   } // fi
125   return( *this );
126 }
127
128 // -------------------------------------------------------------------------
129 template< class E >
130 typename cpm::DataStructures::QuadEdgeBaseIterator< E >::
131 Self& cpm::DataStructures::QuadEdgeBaseIterator< E >::
132 operator++( int )
133 {
134   if( this->m_Start )
135   {
136     this->_GoToNext( );
137     this->m_Start = !( this->m_Iterator == this->m_StartEdge );
138
139   } // fi
140   return( *this );
141 }
142
143 // -------------------------------------------------------------------------
144 template< class E >
145 void cpm::DataStructures::QuadEdgeBaseIterator< E >::
146 _GoToNext( )
147 {
148   switch( this->m_OpType )
149   {
150   case Self::OpOnext:
151     this->m_Iterator = this->m_Iterator->GetOnext( );
152     break;
153   case Self::OpLnext:
154     this->m_Iterator = this->m_Iterator->GetLnext( );
155     break;
156   case Self::OpRnext:
157     this->m_Iterator = this->m_Iterator->GetRnext( );
158     break;
159   case Self::OpDnext:
160     this->m_Iterator = this->m_Iterator->GetDnext( );
161     break;
162   case Self::OpOprev:
163     this->m_Iterator = this->m_Iterator->GetOprev( );
164     break;
165   case Self::OpLprev:
166     this->m_Iterator = this->m_Iterator->GetLprev( );
167     break;
168   case Self::OpRprev:
169     this->m_Iterator = this->m_Iterator->GetRprev( );
170     break;
171   case Self::OpDprev:
172     this->m_Iterator = this->m_Iterator->GetDprev( );
173     break;
174   default:
175     break;
176   } // hctiws
177 }
178
179 // -------------------------------------------------------------------------
180 template< class E >
181 cpm::DataStructures::QuadEdgeIterator< E >::
182 QuadEdgeIterator( E* e, int op, bool start )
183   : Superclass( e, op, start )
184 {
185 }
186
187 // -------------------------------------------------------------------------
188 template< class E >
189 cpm::DataStructures::QuadEdgeIterator< E >::
190 ~QuadEdgeIterator( )
191 {
192 }
193
194 // -------------------------------------------------------------------------
195 template< class E >
196 E* cpm::DataStructures::QuadEdgeIterator< E >::
197 operator*( )
198 {
199   return( this->m_Iterator );
200 }
201
202 // -------------------------------------------------------------------------
203 template< class E >
204 cpm::DataStructures::QuadEdgeConstIterator< E >::
205 QuadEdgeConstIterator( const E* e, int op, bool start )
206   : Superclass( e, op, start )
207 {
208 }
209
210 // -------------------------------------------------------------------------
211 template< class E >
212 cpm::DataStructures::QuadEdgeConstIterator< E >::
213 ~QuadEdgeConstIterator( )
214 {
215 }
216
217 // -------------------------------------------------------------------------
218 template< class E >
219 const E* cpm::DataStructures::QuadEdgeConstIterator< E >::
220 operator*( ) const
221 {
222   return( this->m_Iterator );
223 }
224
225 // -------------------------------------------------------------------------
226 template< class E >
227 cpm::DataStructures::QuadEdgePointIterator< E >::
228 QuadEdgePointIterator( const E* e, int op, bool start )
229   : Superclass( e, op, start )
230 {
231 }
232
233 // -------------------------------------------------------------------------
234 template< class E >
235 cpm::DataStructures::QuadEdgePointIterator< E >::
236 ~QuadEdgePointIterator( )
237 {
238 }
239
240 // -------------------------------------------------------------------------
241 template< class E >
242 typename E::TPrimalGeometry&
243 cpm::DataStructures::QuadEdgePointIterator< E >::
244 operator*( )
245 {
246   return( this->m_Iterator->GetOrigin( ) );
247 }
248
249 // -------------------------------------------------------------------------
250 template< class E >
251 cpm::DataStructures::QuadEdgePointConstIterator< E >::
252 QuadEdgePointConstIterator( const E* e, int op, bool start )
253   : Superclass( e, op, start )
254 {
255 }
256
257 // -------------------------------------------------------------------------
258 template< class E >
259 cpm::DataStructures::QuadEdgePointConstIterator< E >::
260 ~QuadEdgePointConstIterator( )
261 {
262 }
263
264 // -------------------------------------------------------------------------
265 template< class E >
266 const typename E::TPrimalGeometry&
267 cpm::DataStructures::QuadEdgePointConstIterator< E >::
268 operator*( ) const
269 {
270   return( this->m_Iterator->GetOrigin( ) );
271 }
272
273 #endif // __CPM__DATASTRUCTURES__QUADEDGEITERATORS__HXX__
274
275 // eof - $RCSfile$