ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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 {
105 m_OpType = r.m_OpType;
106 m_Start = r.m_Start;
107 }
108 return *this;
109 }
110
111 [[nodiscard]] QuadEdgeType *
113 {
114 return m_StartEdge;
115 }
116 [[nodiscard]] QuadEdgeType *
118 {
119 return m_Iterator;
120 }
121 [[nodiscard]] int
122 GetOpType() const
123 {
124 return m_OpType;
125 }
126 [[nodiscard]] 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();
149 }
150
151 return *this;
152 }
153
154 Self &
156 {
157 if (m_Start)
158 {
159 this->GoToNext();
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 }
215
216protected:
219 int m_OpType{};
220 bool m_Start{};
221};
222
229template <typename TQuadEdge>
230class ITK_TEMPLATE_EXPORT QuadEdgeMeshIterator : public QuadEdgeMeshBaseIterator<TQuadEdge>
231{
232public:
236 using QuadEdgeType = TQuadEdge;
237
238public:
241 : Superclass(e, op, start)
242 {}
243
245
246 Self &
247 operator=(const Self &) = default;
248
249 ~QuadEdgeMeshIterator() override = default;
250
253 {
254 return this->m_Iterator;
255 }
256 [[nodiscard]] const QuadEdgeType *
257 Value() const
258 {
259 return this->m_Iterator;
260 }
261};
262
269template <typename TGeometricalQuadEdge>
270class ITK_TEMPLATE_EXPORT QuadEdgeMeshIteratorGeom : public QuadEdgeMeshIterator<TGeometricalQuadEdge>
271{
272public:
275 using QuadEdgeType = TGeometricalQuadEdge;
276
278 using OriginRefType = typename QuadEdgeType::OriginRefType;
279
280public:
281 QuadEdgeMeshIteratorGeom(QuadEdgeType * e = nullptr, int op = Superclass::OperatorOnext, bool start = true)
282 : Superclass(e, op, start)
283 {}
284
286
289
292 {
293 return this->m_Iterator->GetOrigin();
294 }
295};
296
303template <typename TQuadEdge>
304class ITK_TEMPLATE_EXPORT QuadEdgeMeshConstIterator : public QuadEdgeMeshBaseIterator<TQuadEdge>
305{
306public:
311 using QuadEdgeType = TQuadEdge;
312
313public:
317 bool start = true)
318 : Superclass(const_cast<QuadEdgeType *>(e), op, start)
319 {}
320
322
323 Self &
324 operator=(const Self &) = default;
325
326 ~QuadEdgeMeshConstIterator() override = default;
327
328 Self &
330 {
331 this->m_StartEdge = r.GetStartEdge();
332 this->m_Iterator = r.GetIterator();
333 this->m_OpType = r.GetOpType();
334 this->m_Start = r.GetStart();
335 return *this;
336 }
337
338 [[nodiscard]] const QuadEdgeType *
339 Value() const
340 {
341 return this->m_Iterator;
342 }
343};
344
351template <typename TGeometricalQuadEdge>
352class ITK_TEMPLATE_EXPORT QuadEdgeMeshConstIteratorGeom : public QuadEdgeMeshConstIterator<TGeometricalQuadEdge>
353{
354public:
359 using QuadEdgeType = TGeometricalQuadEdge;
360
363
364public:
367 bool start = true)
368 : Superclass(e, op, start)
369 {}
370
372
373 Self &
374 operator=(const Self &) = default;
375
376 ~QuadEdgeMeshConstIteratorGeom() override = default;
377
378 Self &
380 {
381 this->m_StartEdge = r.GetStartEdge();
382 this->m_Iterator = r.GetIterator();
383 this->m_OpType = r.GetOpType();
384 this->m_Start = r.GetStart();
385 return *this;
386 }
387
388 const OriginRefType
389 operator*() const
390 {
391 return this->m_Iterator->GetOrigin();
392 }
393};
394} // namespace itk
395
396#endif
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
Self & operator=(const Self &)=default
QuadEdgeMeshConstIterator(const QuadEdgeType *e=(QuadEdgeType *) 0, int op=Superclass::OperatorOnext, bool start=true)
~QuadEdgeMeshConstIterator() override=default
QuadEdgeMeshConstIterator(const QuadEdgeMeshConstIterator &)=default
Self & operator=(const Self &)=default
Non const geometrical iterator.
QuadEdgeMeshIteratorGeom & operator=(const QuadEdgeMeshIteratorGeom &)=default
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
Self & operator=(const Self &)=default
QuadEdgeMeshIterator(const QuadEdgeMeshIterator &)=default
QuadEdgeMeshBaseIterator< Self > Superclass
QuadEdgeMeshIterator(QuadEdgeType *e=(QuadEdgeType *) 0, int op=Superclass::OperatorOnext, bool start=true)
~QuadEdgeMeshIterator() override=default
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....