ITK  5.2.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  * http://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
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 
140  bool
141  operator==(const Self & r) const
142  {
143  return ((m_StartEdge == r.m_StartEdge) && (m_Iterator == r.m_Iterator) && (m_OpType == r.m_OpType) &&
144  (m_Start == r.m_Start));
145  }
146 
147  bool
149  {
150  return (!(this->operator==(r)));
151  }
152 
153  bool
154  operator!=(const Self & r) const
155  {
156  return (!(this->operator==(r)));
157  }
158 
159  Self &
161  {
162  if (m_Start)
163  {
164  this->GoToNext();
165  m_Start = !(m_Iterator == m_StartEdge);
166  }
167 
168  return (*this);
169  }
170 
171  Self &
173  {
174  if (m_Start)
175  {
176  this->GoToNext();
177  m_Start = !(m_Iterator == m_StartEdge);
178  }
179  return (*this);
180  }
181 
182 protected:
184  virtual void
186  {
187  switch (m_OpType)
188  {
189  case OperatorOnext:
190  m_Iterator = m_Iterator->GetOnext();
191  break;
192  case OperatorSym:
193  m_Iterator = m_Iterator->GetSym();
194  break;
195  case OperatorLnext:
196  m_Iterator = m_Iterator->GetLnext();
197  break;
198  case OperatorRnext:
199  m_Iterator = m_Iterator->GetRnext();
200  break;
201  case OperatorDnext:
202  m_Iterator = m_Iterator->GetDnext();
203  break;
204  case OperatorOprev:
205  m_Iterator = m_Iterator->GetOprev();
206  break;
207  case OperatorLprev:
208  m_Iterator = m_Iterator->GetLprev();
209  break;
210  case OperatorRprev:
211  m_Iterator = m_Iterator->GetRprev();
212  break;
213  case OperatorDprev:
214  m_Iterator = m_Iterator->GetDprev();
215  break;
216  case OperatorInvOnext:
217  m_Iterator = m_Iterator->GetInvOnext();
218  break;
219  case OperatorInvLnext:
220  m_Iterator = m_Iterator->GetInvLnext();
221  break;
222  case OperatorInvRnext:
223  m_Iterator = m_Iterator->GetInvRnext();
224  break;
225  case OperatorInvDnext:
226  m_Iterator = m_Iterator->GetInvDnext();
227  break;
228  default:
229  break;
230  }
231  }
233 
234 protected:
242 };
243 
250 template <typename TQuadEdge>
252 {
253 public:
254 
258  using QuadEdgeType = TQuadEdge;
259 
260 public:
263  : Superclass(e, op, start)
264  {}
265 
266  QuadEdgeMeshIterator(const QuadEdgeMeshIterator &) = default;
267 
268  ~QuadEdgeMeshIterator() override = default;
269 
270  QuadEdgeType *
272  {
273  return (this->m_Iterator);
274  }
275  const QuadEdgeType *
276  Value() const
277  {
278  return (this->m_Iterator);
279  }
280 };
281 
288 template <typename TGeometricalQuadEdge>
289 class QuadEdgeMeshIteratorGeom : public QuadEdgeMeshIterator<TGeometricalQuadEdge>
290 {
291 public:
292 
295  using QuadEdgeType = TGeometricalQuadEdge;
296 
298  using OriginRefType = typename QuadEdgeType::OriginRefType;
299 
300 public:
302  int op = Superclass::OperatorOnext,
303  bool start = true)
304  : Superclass(e, op, start)
305  {}
306 
308 
309  OriginRefType operator*() { return (this->m_Iterator->GetOrigin()); }
310 };
311 
318 template <typename TQuadEdge>
320 {
321 public:
322 
327  using QuadEdgeType = TQuadEdge;
328 
329 public:
332  int op = Superclass::OperatorOnext,
333  bool start = true)
334  : Superclass(const_cast<QuadEdgeType *>(e), op, start)
335  {}
336 
338 
339  ~QuadEdgeMeshConstIterator() override = default;
340 
341  Self &
343  {
344  this->m_StartEdge = r.GetStartEdge();
345  this->m_Iterator = r.GetIterator();
346  this->m_OpType = r.GetOpType();
347  this->m_Start = r.GetStart();
348  return (*this);
349  }
350 
351  const QuadEdgeType *
352  Value() const
353  {
354  return (this->m_Iterator);
355  }
356 };
357 
364 template <typename TGeometricalQuadEdge>
365 class QuadEdgeMeshConstIteratorGeom : public QuadEdgeMeshConstIterator<TGeometricalQuadEdge>
366 {
367 public:
368 
373  using QuadEdgeType = TGeometricalQuadEdge;
374 
376  using OriginRefType = typename QuadEdgeType::OriginRefType;
377 
378 public:
380  int op = Superclass::OperatorOnext,
381  bool start = true)
382  : Superclass(e, op, start)
383  {}
384 
386 
387  ~QuadEdgeMeshConstIteratorGeom() override = default;
388 
389  Self &
391  {
392  this->m_StartEdge = r.GetStartEdge();
393  this->m_Iterator = r.GetIterator();
394  this->m_OpType = r.GetOpType();
395  this->m_Start = r.GetStart();
396  return (*this);
397  }
398 
399  const OriginRefType operator*() const { return (this->m_Iterator->GetOrigin()); }
400 };
401 } // namespace itk
402 
403 #endif
itk::QuadEdgeMeshBaseIterator::operator!=
bool operator!=(Self &r)
Definition: itkQuadEdgeMeshBaseIterator.h:148
itk::QuadEdgeMeshConstIterator::Self
QuadEdgeMeshConstIterator Self
Definition: itkQuadEdgeMeshBaseIterator.h:324
itk::QuadEdgeMeshBaseIterator::OperatorDprev
Definition: itkQuadEdgeMeshBaseIterator.h:78
itk::QuadEdgeMeshIterator::~QuadEdgeMeshIterator
~QuadEdgeMeshIterator() override=default
itk::QuadEdgeMeshBaseIterator::operator==
bool operator==(const Self &r) const
Definition: itkQuadEdgeMeshBaseIterator.h:141
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:298
itk::QuadEdgeMeshBaseIterator::GetStart
bool GetStart() const
Definition: itkQuadEdgeMeshBaseIterator.h:127
itk::QuadEdgeMeshConstIteratorGeom::OriginRefType
typename QuadEdgeType::OriginRefType OriginRefType
Definition: itkQuadEdgeMeshBaseIterator.h:376
itk::QuadEdgeMeshConstIterator
Const iterator for QuadEdgeMesh.
Definition: itkQuadEdgeMeshBaseIterator.h:319
itk::QuadEdgeMeshBaseIterator::OperatorInvLnext
Definition: itkQuadEdgeMeshBaseIterator.h:80
itk::QuadEdgeMeshIterator::Value
const QuadEdgeType * Value() const
Definition: itkQuadEdgeMeshBaseIterator.h:276
itk::QuadEdgeMeshBaseIterator::OperatorLnext
Definition: itkQuadEdgeMeshBaseIterator.h:72
itk::QuadEdgeMeshIteratorGeom::operator*
OriginRefType operator*()
Definition: itkQuadEdgeMeshBaseIterator.h:309
itk::QuadEdgeMeshBaseIterator::OperatorOnext
Definition: itkQuadEdgeMeshBaseIterator.h:70
itk::QuadEdgeMeshBaseIterator::OperatorOprev
Definition: itkQuadEdgeMeshBaseIterator.h:75
itk::QuadEdgeMeshConstIteratorGeom::~QuadEdgeMeshConstIteratorGeom
~QuadEdgeMeshConstIteratorGeom() override=default
itk::QuadEdgeMeshConstIterator::~QuadEdgeMeshConstIterator
~QuadEdgeMeshConstIterator() override=default
itk::QuadEdgeMeshConstIteratorGeom::QuadEdgeMeshConstIteratorGeom
QuadEdgeMeshConstIteratorGeom(const QuadEdgeType *e=(QuadEdgeType *) 0, int op=Superclass::OperatorOnext, bool start=true)
Definition: itkQuadEdgeMeshBaseIterator.h:379
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:352
itk::QuadEdgeMeshBaseIterator::OperatorDnext
Definition: itkQuadEdgeMeshBaseIterator.h:74
itk::QuadEdgeMeshBaseIterator::OperatorSym
Definition: itkQuadEdgeMeshBaseIterator.h:71
itk::QuadEdgeMeshIterator::Value
QuadEdgeType * Value()
Definition: itkQuadEdgeMeshBaseIterator.h:271
itkMacro.h
itk::QuadEdgeMeshConstIteratorGeom::QuadEdgeType
TGeometricalQuadEdge QuadEdgeType
Definition: itkQuadEdgeMeshBaseIterator.h:373
itk::QuadEdgeMeshConstIteratorGeom::Self
QuadEdgeMeshConstIteratorGeom Self
Definition: itkQuadEdgeMeshBaseIterator.h:370
itk::QuadEdgeMeshBaseIterator::QuadEdgeMeshBaseIterator
QuadEdgeMeshBaseIterator(QuadEdgeType *e, int op=OperatorOnext, bool start=true)
Definition: itkQuadEdgeMeshBaseIterator.h:87
itk::QuadEdgeMeshBaseIterator::Self
QuadEdgeMeshBaseIterator Self
Definition: itkQuadEdgeMeshBaseIterator.h:64
itk::QuadEdgeMeshConstIterator::QuadEdgeMeshConstIterator
QuadEdgeMeshConstIterator(const QuadEdgeType *e=(QuadEdgeType *) 0, int op=Superclass::OperatorOnext, bool start=true)
Definition: itkQuadEdgeMeshBaseIterator.h:331
itk::QuadEdgeMeshBaseIterator::operator!=
bool operator!=(const Self &r) const
Definition: itkQuadEdgeMeshBaseIterator.h:154
itk::QuadEdgeMeshIteratorGeom
Non const geometrical iterator.
Definition: itkQuadEdgeMeshBaseIterator.h:289
itk::QuadEdgeMeshIterator::QuadEdgeMeshIterator
QuadEdgeMeshIterator(QuadEdgeType *e=(QuadEdgeType *) 0, int op=Superclass::OperatorOnext, bool start=true)
Definition: itkQuadEdgeMeshBaseIterator.h:262
itk::QuadEdgeMeshIterator::QuadEdgeType
TQuadEdge QuadEdgeType
Definition: itkQuadEdgeMeshBaseIterator.h:258
itk::QuadEdgeMeshBaseIterator::operator==
bool operator==(Self &r)
Definition: itkQuadEdgeMeshBaseIterator.h:134
itk::QuadEdgeMeshIteratorGeom::QuadEdgeType
TGeometricalQuadEdge QuadEdgeType
Definition: itkQuadEdgeMeshBaseIterator.h:295
itk::QuadEdgeMeshBaseIterator::operator++
Self & operator++()
Definition: itkQuadEdgeMeshBaseIterator.h:160
itk::QuadEdgeMeshBaseIterator::GetStartEdge
QuadEdgeType * GetStartEdge() const
Definition: itkQuadEdgeMeshBaseIterator.h:112
itk::QuadEdgeMeshConstIterator::QuadEdgeType
TQuadEdge QuadEdgeType
Definition: itkQuadEdgeMeshBaseIterator.h:327
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:172
itk::QuadEdgeMeshConstIteratorGeom
Const geometrical iterator.
Definition: itkQuadEdgeMeshBaseIterator.h:365
itk::QuadEdgeMeshConstIteratorGeom::operator*
const OriginRefType operator*() const
Definition: itkQuadEdgeMeshBaseIterator.h:399
itk::QuadEdgeMeshConstIteratorGeom::operator=
Self & operator=(const NoConstType &r)
Definition: itkQuadEdgeMeshBaseIterator.h:390
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:185
itk::QuadEdgeMeshIterator
Non const iterator for QuadMesh.
Definition: itkQuadEdgeMeshBaseIterator.h:251
itk::QuadEdgeMeshBaseIterator::OperatorInvRnext
Definition: itkQuadEdgeMeshBaseIterator.h:81
itk::QuadEdgeMeshConstIterator::operator=
Self & operator=(const NoConstType &r)
Definition: itkQuadEdgeMeshBaseIterator.h:342
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:301