ITK  6.0.0
Insight Toolkit
itkQuadEdgeMeshBaseIterator.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkQuadEdgeMeshBaseIterator_h
19#define itkQuadEdgeMeshBaseIterator_h
20
21#include "itkMacro.h"
22
23// -------------------------------------------------------------------------
24#define itkQEDefineIteratorMethodsMacro(Op) \
25 virtual Iterator Begin##Op() { return Iterator(this, Self::Iterator::Operator##Op, true); } \
26 \
27 virtual ConstIterator Begin##Op() const { return ConstIterator(this, Self::ConstIterator::Operator##Op, true); } \
28 \
29 virtual Iterator End##Op() { return Iterator(this, Self::Iterator::Operator##Op, false); } \
30 \
31 virtual ConstIterator End##Op() const { return ConstIterator(this, Self::ConstIterator::Operator##Op, false); } \
32 ITK_MACROEND_NOOP_STATEMENT
33
34// -------------------------------------------------------------------------
35#define itkQEDefineIteratorGeomMethodsMacro(Op) \
36 virtual IteratorGeom BeginGeom##Op() { return IteratorGeom(this, Self::IteratorGeom::Operator##Op, true); } \
37 \
38 virtual ConstIteratorGeom BeginGeom##Op() const \
39 { \
40 return ConstIteratorGeom(this, Self::ConstIteratorGeom::Operator##Op, true); \
41 } \
42 \
43 virtual IteratorGeom EndGeom##Op() { return IteratorGeom(this, Self::IteratorGeom::Operator##Op, false); } \
44 \
45 virtual ConstIteratorGeom EndGeom##Op() const \
46 { \
47 return ConstIteratorGeom(this, Self::ConstIteratorGeom::Operator##Op, false); \
48 } \
49 ITK_MACROEND_NOOP_STATEMENT
50
51namespace itk
52{
59template <typename TQuadEdge>
61{
62public:
63 // Hierarchy type alias & values.
65 using QuadEdgeType = TQuadEdge;
66
67 // Different types of iterators, one for each basic QE operation.
68 enum
69 {
83 };
84
85public:
86 // Object creation methods.
87 QuadEdgeMeshBaseIterator(QuadEdgeType * e, int op = OperatorOnext, bool start = true)
88 : m_StartEdge(e)
89 , m_Iterator(e)
90 , m_OpType(op)
91 , m_Start(start)
92 {}
93
95
96 virtual ~QuadEdgeMeshBaseIterator() = default;
97
98 Self &
99 operator=(const Self & r)
100 {
101 if (this != &r)
102 {
103 m_StartEdge = r.m_StartEdge;
104 m_Iterator = r.m_Iterator;
105 m_OpType = r.m_OpType;
106 m_Start = r.m_Start;
107 }
108 return (*this);
109 }
110
113 {
114 return (m_StartEdge);
115 }
118 {
119 return (m_Iterator);
120 }
121 int
122 GetOpType() const
123 {
124 return (m_OpType);
125 }
126 bool
127 GetStart() const
128 {
129 return (m_Start);
130 }
131
133 bool
134 operator==(const Self & r) const
135 {
136 return ((m_StartEdge == r.m_StartEdge) && (m_Iterator == r.m_Iterator) && (m_OpType == r.m_OpType) &&
137 (m_Start == r.m_Start));
138 }
139
141
142 Self &
144 {
145 if (m_Start)
146 {
147 this->GoToNext();
148 m_Start = !(m_Iterator == m_StartEdge);
149 }
150
151 return (*this);
152 }
153
154 Self &
156 {
157 if (m_Start)
158 {
159 this->GoToNext();
160 m_Start = !(m_Iterator == m_StartEdge);
161 }
162 return (*this);
163 }
164
165protected:
167 virtual void
169 {
170 switch (m_OpType)
171 {
172 case OperatorOnext:
173 m_Iterator = m_Iterator->GetOnext();
174 break;
175 case OperatorSym:
176 m_Iterator = m_Iterator->GetSym();
177 break;
178 case OperatorLnext:
179 m_Iterator = m_Iterator->GetLnext();
180 break;
181 case OperatorRnext:
182 m_Iterator = m_Iterator->GetRnext();
183 break;
184 case OperatorDnext:
185 m_Iterator = m_Iterator->GetDnext();
186 break;
187 case OperatorOprev:
188 m_Iterator = m_Iterator->GetOprev();
189 break;
190 case OperatorLprev:
191 m_Iterator = m_Iterator->GetLprev();
192 break;
193 case OperatorRprev:
194 m_Iterator = m_Iterator->GetRprev();
195 break;
196 case OperatorDprev:
197 m_Iterator = m_Iterator->GetDprev();
198 break;
199 case OperatorInvOnext:
200 m_Iterator = m_Iterator->GetInvOnext();
201 break;
202 case OperatorInvLnext:
203 m_Iterator = m_Iterator->GetInvLnext();
204 break;
205 case OperatorInvRnext:
206 m_Iterator = m_Iterator->GetInvRnext();
207 break;
208 case OperatorInvDnext:
209 m_Iterator = m_Iterator->GetInvDnext();
210 break;
211 default:
212 break;
213 }
214 }
217protected:
225};
226
233template <typename TQuadEdge>
234class ITK_TEMPLATE_EXPORT QuadEdgeMeshIterator : public QuadEdgeMeshBaseIterator<TQuadEdge>
235{
236public:
237
241 using QuadEdgeType = TQuadEdge;
242
243public:
245 QuadEdgeMeshIterator(QuadEdgeType * e = (QuadEdgeType *)0, int op = Superclass::OperatorOnext, bool start = true)
246 : Superclass(e, op, start)
247 {}
248
250
251 ~QuadEdgeMeshIterator() override = default;
252
255 {
256 return (this->m_Iterator);
257 }
258 const QuadEdgeType *
259 Value() const
260 {
261 return (this->m_Iterator);
262 }
263};
264
271template <typename TGeometricalQuadEdge>
272class ITK_TEMPLATE_EXPORT QuadEdgeMeshIteratorGeom : public QuadEdgeMeshIterator<TGeometricalQuadEdge>
273{
274public:
275
278 using QuadEdgeType = TGeometricalQuadEdge;
279
281 using OriginRefType = typename QuadEdgeType::OriginRefType;
282
283public:
284 QuadEdgeMeshIteratorGeom(QuadEdgeType * e = nullptr, int op = Superclass::OperatorOnext, bool start = true)
285 : Superclass(e, op, start)
286 {}
287
289
290 OriginRefType operator*() { return (this->m_Iterator->GetOrigin()); }
291};
292
299template <typename TQuadEdge>
300class ITK_TEMPLATE_EXPORT QuadEdgeMeshConstIterator : public QuadEdgeMeshBaseIterator<TQuadEdge>
301{
302public:
303
308 using QuadEdgeType = TQuadEdge;
309
310public:
313 int op = Superclass::OperatorOnext,
314 bool start = true)
315 : Superclass(const_cast<QuadEdgeType *>(e), op, start)
316 {}
317
319
320 ~QuadEdgeMeshConstIterator() override = default;
321
322 Self &
324 {
325 this->m_StartEdge = r.GetStartEdge();
326 this->m_Iterator = r.GetIterator();
327 this->m_OpType = r.GetOpType();
328 this->m_Start = r.GetStart();
329 return (*this);
330 }
331
332 const QuadEdgeType *
333 Value() const
334 {
335 return (this->m_Iterator);
336 }
337};
338
345template <typename TGeometricalQuadEdge>
346class ITK_TEMPLATE_EXPORT QuadEdgeMeshConstIteratorGeom : public QuadEdgeMeshConstIterator<TGeometricalQuadEdge>
347{
348public:
349
354 using QuadEdgeType = TGeometricalQuadEdge;
355
357 using OriginRefType = typename QuadEdgeType::OriginRefType;
358
359public:
361 int op = Superclass::OperatorOnext,
362 bool start = true)
363 : Superclass(e, op, start)
364 {}
365
367
368 ~QuadEdgeMeshConstIteratorGeom() override = default;
369
370 Self &
372 {
373 this->m_StartEdge = r.GetStartEdge();
374 this->m_Iterator = r.GetIterator();
375 this->m_OpType = r.GetOpType();
376 this->m_Start = r.GetStart();
377 return (*this);
378 }
379
380 const OriginRefType operator*() const { return (this->m_Iterator->GetOrigin()); }
381};
382} // namespace itk
383
384#endif
Pixel-wise addition of two images.
Base iterator class for QuadEdgeMesh.
virtual ~QuadEdgeMeshBaseIterator()=default
QuadEdgeMeshBaseIterator(const QuadEdgeMeshBaseIterator &)=default
QuadEdgeMeshBaseIterator(QuadEdgeType *e, int op=OperatorOnext, bool start=true)
QuadEdgeMeshConstIteratorGeom(const QuadEdgeMeshConstIteratorGeom &)=default
QuadEdgeMeshConstIteratorGeom(const QuadEdgeType *e=(QuadEdgeType *) 0, int op=Superclass::OperatorOnext, bool start=true)
typename QuadEdgeType::OriginRefType OriginRefType
~QuadEdgeMeshConstIteratorGeom() override=default
Const iterator for QuadEdgeMesh.
Self & operator=(const NoConstType &r)
QuadEdgeMeshConstIterator(const QuadEdgeType *e=(QuadEdgeType *) 0, int op=Superclass::OperatorOnext, bool start=true)
~QuadEdgeMeshConstIterator() override=default
QuadEdgeMeshConstIterator(const QuadEdgeMeshConstIterator &)=default
Non const geometrical iterator.
QuadEdgeMeshIteratorGeom(QuadEdgeType *e=nullptr, int op=Superclass::OperatorOnext, bool start=true)
QuadEdgeMeshIteratorGeom(const QuadEdgeMeshIteratorGeom &)=default
typename QuadEdgeType::OriginRefType OriginRefType
Non const iterator for QuadMesh.
const QuadEdgeType * Value() const
QuadEdgeMeshIterator(const QuadEdgeMeshIterator &)=default
QuadEdgeMeshIterator(QuadEdgeType *e=(QuadEdgeType *) 0, int op=Superclass::OperatorOnext, bool start=true)
~QuadEdgeMeshIterator() override=default
static constexpr double e
Definition: itkMath.h:56
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....