ITK  5.4.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 
51 namespace itk
52 {
59 template <typename TQuadEdge>
61 {
62 public:
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 
85 public:
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 
111  QuadEdgeType *
112  GetStartEdge() const
113  {
114  return (m_StartEdge);
115  }
116  QuadEdgeType *
117  GetIterator() const
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 
165 protected:
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  }
217 protected:
225 };
226 
233 template <typename TQuadEdge>
234 class ITK_TEMPLATE_EXPORT QuadEdgeMeshIterator : public QuadEdgeMeshBaseIterator<TQuadEdge>
235 {
236 public:
237 
241  using QuadEdgeType = TQuadEdge;
242 
243 public:
245  QuadEdgeMeshIterator(QuadEdgeType * e = (QuadEdgeType *)0, int op = Superclass::OperatorOnext, bool start = true)
246  : Superclass(e, op, start)
247  {}
248 
249  QuadEdgeMeshIterator(const QuadEdgeMeshIterator &) = default;
250 
251  ~QuadEdgeMeshIterator() override = default;
252 
253  QuadEdgeType *
255  {
256  return (this->m_Iterator);
257  }
258  const QuadEdgeType *
259  Value() const
260  {
261  return (this->m_Iterator);
262  }
263 };
264 
271 template <typename TGeometricalQuadEdge>
272 class ITK_TEMPLATE_EXPORT QuadEdgeMeshIteratorGeom : public QuadEdgeMeshIterator<TGeometricalQuadEdge>
273 {
274 public:
275 
278  using QuadEdgeType = TGeometricalQuadEdge;
279 
281  using OriginRefType = typename QuadEdgeType::OriginRefType;
282 
283 public:
285  int op = Superclass::OperatorOnext,
286  bool start = true)
287  : Superclass(e, op, start)
288  {}
289 
291 
292  OriginRefType operator*() { return (this->m_Iterator->GetOrigin()); }
293 };
294 
301 template <typename TQuadEdge>
302 class ITK_TEMPLATE_EXPORT QuadEdgeMeshConstIterator : public QuadEdgeMeshBaseIterator<TQuadEdge>
303 {
304 public:
305 
310  using QuadEdgeType = TQuadEdge;
311 
312 public:
315  int op = Superclass::OperatorOnext,
316  bool start = true)
317  : Superclass(const_cast<QuadEdgeType *>(e), op, start)
318  {}
319 
321 
322  ~QuadEdgeMeshConstIterator() override = default;
323 
324  Self &
326  {
327  this->m_StartEdge = r.GetStartEdge();
328  this->m_Iterator = r.GetIterator();
329  this->m_OpType = r.GetOpType();
330  this->m_Start = r.GetStart();
331  return (*this);
332  }
333 
334  const QuadEdgeType *
335  Value() const
336  {
337  return (this->m_Iterator);
338  }
339 };
340 
347 template <typename TGeometricalQuadEdge>
348 class ITK_TEMPLATE_EXPORT QuadEdgeMeshConstIteratorGeom : public QuadEdgeMeshConstIterator<TGeometricalQuadEdge>
349 {
350 public:
351 
356  using QuadEdgeType = TGeometricalQuadEdge;
357 
359  using OriginRefType = typename QuadEdgeType::OriginRefType;
360 
361 public:
363  int op = Superclass::OperatorOnext,
364  bool start = true)
365  : Superclass(e, op, start)
366  {}
367 
369 
370  ~QuadEdgeMeshConstIteratorGeom() override = default;
371 
372  Self &
374  {
375  this->m_StartEdge = r.GetStartEdge();
376  this->m_Iterator = r.GetIterator();
377  this->m_OpType = r.GetOpType();
378  this->m_Start = r.GetStart();
379  return (*this);
380  }
381 
382  const OriginRefType operator*() const { return (this->m_Iterator->GetOrigin()); }
383 };
384 } // namespace itk
385 
386 #endif
itk::QuadEdgeMeshBaseIterator::OperatorDprev
Definition: itkQuadEdgeMeshBaseIterator.h:78
itk::QuadEdgeMeshBaseIterator::operator==
bool operator==(const Self &r) const
Definition: itkQuadEdgeMeshBaseIterator.h:134
itk::QuadEdgeMeshBaseIterator::GetOpType
int GetOpType() const
Definition: itkQuadEdgeMeshBaseIterator.h:122
itk::QuadEdgeMeshBaseIterator
Base iterator class for QuadEdgeMesh.
Definition: itkQuadEdgeMeshBaseIterator.h:60
itk::QuadEdgeMeshBaseIterator::operator=
Self & operator=(const Self &r)
Definition: itkQuadEdgeMeshBaseIterator.h:99
itk::QuadEdgeMeshBaseIterator::OperatorInvDnext
Definition: itkQuadEdgeMeshBaseIterator.h:82
itk::QuadEdgeMeshIteratorGeom::OriginRefType
typename QuadEdgeType::OriginRefType OriginRefType
Definition: itkQuadEdgeMeshBaseIterator.h:281
itk::QuadEdgeMeshBaseIterator::GetStart
bool GetStart() const
Definition: itkQuadEdgeMeshBaseIterator.h:127
itk::QuadEdgeMeshConstIteratorGeom::OriginRefType
typename QuadEdgeType::OriginRefType OriginRefType
Definition: itkQuadEdgeMeshBaseIterator.h:359
itk::QuadEdgeMeshConstIterator
Const iterator for QuadEdgeMesh.
Definition: itkQuadEdgeMeshBaseIterator.h:302
itk::QuadEdgeMeshBaseIterator::OperatorInvLnext
Definition: itkQuadEdgeMeshBaseIterator.h:80
itk::QuadEdgeMeshIterator::Value
const QuadEdgeType * Value() const
Definition: itkQuadEdgeMeshBaseIterator.h:259
itk::QuadEdgeMeshBaseIterator::OperatorLnext
Definition: itkQuadEdgeMeshBaseIterator.h:72
itk::QuadEdgeMeshIteratorGeom::operator*
OriginRefType operator*()
Definition: itkQuadEdgeMeshBaseIterator.h:292
itk::QuadEdgeMeshBaseIterator::OperatorOnext
Definition: itkQuadEdgeMeshBaseIterator.h:70
itk::QuadEdgeMeshBaseIterator::OperatorOprev
Definition: itkQuadEdgeMeshBaseIterator.h:75
itk::QuadEdgeMeshConstIteratorGeom::QuadEdgeMeshConstIteratorGeom
QuadEdgeMeshConstIteratorGeom(const QuadEdgeType *e=(QuadEdgeType *) 0, int op=Superclass::OperatorOnext, bool start=true)
Definition: itkQuadEdgeMeshBaseIterator.h:362
itk::QuadEdgeMeshBaseIterator::~QuadEdgeMeshBaseIterator
virtual ~QuadEdgeMeshBaseIterator()=default
itk::QuadEdgeMeshBaseIterator::OperatorRprev
Definition: itkQuadEdgeMeshBaseIterator.h:77
itk::QuadEdgeMeshBaseIterator::OperatorLprev
Definition: itkQuadEdgeMeshBaseIterator.h:76
itk::QuadEdgeMeshBaseIterator::OperatorRnext
Definition: itkQuadEdgeMeshBaseIterator.h:73
itk::QuadEdgeMeshConstIterator::Value
const QuadEdgeType * Value() const
Definition: itkQuadEdgeMeshBaseIterator.h:335
itk::QuadEdgeMeshBaseIterator::OperatorDnext
Definition: itkQuadEdgeMeshBaseIterator.h:74
itk::QuadEdgeMeshBaseIterator::OperatorSym
Definition: itkQuadEdgeMeshBaseIterator.h:71
itk::QuadEdgeMeshIterator::Value
QuadEdgeType * Value()
Definition: itkQuadEdgeMeshBaseIterator.h:254
itkMacro.h
itk::QuadEdgeMeshConstIteratorGeom::QuadEdgeType
TGeometricalQuadEdge QuadEdgeType
Definition: itkQuadEdgeMeshBaseIterator.h:356
itk::QuadEdgeMeshBaseIterator::ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Self)
itk::QuadEdgeMeshBaseIterator::QuadEdgeMeshBaseIterator
QuadEdgeMeshBaseIterator(QuadEdgeType *e, int op=OperatorOnext, bool start=true)
Definition: itkQuadEdgeMeshBaseIterator.h:87
itk::QuadEdgeMeshConstIterator::QuadEdgeMeshConstIterator
QuadEdgeMeshConstIterator(const QuadEdgeType *e=(QuadEdgeType *) 0, int op=Superclass::OperatorOnext, bool start=true)
Definition: itkQuadEdgeMeshBaseIterator.h:314
itk::QuadEdgeMeshIteratorGeom
Non const geometrical iterator.
Definition: itkQuadEdgeMeshBaseIterator.h:272
itk::QuadEdgeMeshIterator::QuadEdgeMeshIterator
QuadEdgeMeshIterator(QuadEdgeType *e=(QuadEdgeType *) 0, int op=Superclass::OperatorOnext, bool start=true)
Definition: itkQuadEdgeMeshBaseIterator.h:245
itk::QuadEdgeMeshIteratorGeom::QuadEdgeType
TGeometricalQuadEdge QuadEdgeType
Definition: itkQuadEdgeMeshBaseIterator.h:278
itk::QuadEdgeMeshBaseIterator::operator++
Self & operator++()
Definition: itkQuadEdgeMeshBaseIterator.h:143
itk::QuadEdgeMeshBaseIterator::GetStartEdge
QuadEdgeType * GetStartEdge() const
Definition: itkQuadEdgeMeshBaseIterator.h:112
itk::QuadEdgeMeshBaseIterator::GetIterator
QuadEdgeType * GetIterator() const
Definition: itkQuadEdgeMeshBaseIterator.h:117
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::QuadEdgeMeshBaseIterator::operator++
Self & operator++(int)
Definition: itkQuadEdgeMeshBaseIterator.h:155
itk::QuadEdgeMeshConstIteratorGeom
Const geometrical iterator.
Definition: itkQuadEdgeMeshBaseIterator.h:348
itk::QuadEdgeMeshConstIteratorGeom::operator*
const OriginRefType operator*() const
Definition: itkQuadEdgeMeshBaseIterator.h:382
itk::QuadEdgeMeshConstIteratorGeom::operator=
Self & operator=(const NoConstType &r)
Definition: itkQuadEdgeMeshBaseIterator.h:373
itk::QuadEdgeMeshBaseIterator::OperatorInvOnext
Definition: itkQuadEdgeMeshBaseIterator.h:79
itk::Math::e
static constexpr double e
Definition: itkMath.h:54
itk::QuadEdgeMeshBaseIterator::GoToNext
virtual void GoToNext()
Definition: itkQuadEdgeMeshBaseIterator.h:168
AddImageFilter
Definition: itkAddImageFilter.h:80
itk::QuadEdgeMeshIterator
Non const iterator for QuadMesh.
Definition: itkQuadEdgeMeshBaseIterator.h:234
itk::QuadEdgeMeshBaseIterator::OperatorInvRnext
Definition: itkQuadEdgeMeshBaseIterator.h:81
itk::QuadEdgeMeshConstIterator::operator=
Self & operator=(const NoConstType &r)
Definition: itkQuadEdgeMeshBaseIterator.h:325
itk::QuadEdgeMeshBaseIterator< TGeometricalQuadEdge >::QuadEdgeType
TGeometricalQuadEdge QuadEdgeType
Definition: itkQuadEdgeMeshBaseIterator.h:65
itk::QuadEdgeMeshIteratorGeom::QuadEdgeMeshIteratorGeom
QuadEdgeMeshIteratorGeom(QuadEdgeType *e=(QuadEdgeType *) nullptr, int op=Superclass::OperatorOnext, bool start=true)
Definition: itkQuadEdgeMeshBaseIterator.h:284