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 
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:
284  QuadEdgeMeshIteratorGeom(QuadEdgeType * e = nullptr, int op = Superclass::OperatorOnext, bool start = true)
285  : Superclass(e, op, start)
286  {}
287 
289 
290  OriginRefType
292  {
293  return (this->m_Iterator->GetOrigin());
294  }
295 };
296 
303 template <typename TQuadEdge>
304 class ITK_TEMPLATE_EXPORT QuadEdgeMeshConstIterator : public QuadEdgeMeshBaseIterator<TQuadEdge>
305 {
306 public:
307 
312  using QuadEdgeType = TQuadEdge;
313 
314 public:
317  int op = Superclass::OperatorOnext,
318  bool start = true)
319  : Superclass(const_cast<QuadEdgeType *>(e), op, start)
320  {}
321 
323 
324  ~QuadEdgeMeshConstIterator() override = default;
325 
326  Self &
328  {
329  this->m_StartEdge = r.GetStartEdge();
330  this->m_Iterator = r.GetIterator();
331  this->m_OpType = r.GetOpType();
332  this->m_Start = r.GetStart();
333  return (*this);
334  }
335 
336  const QuadEdgeType *
337  Value() const
338  {
339  return (this->m_Iterator);
340  }
341 };
342 
349 template <typename TGeometricalQuadEdge>
350 class ITK_TEMPLATE_EXPORT QuadEdgeMeshConstIteratorGeom : public QuadEdgeMeshConstIterator<TGeometricalQuadEdge>
351 {
352 public:
353 
358  using QuadEdgeType = TGeometricalQuadEdge;
359 
361  using OriginRefType = typename QuadEdgeType::OriginRefType;
362 
363 public:
365  int op = Superclass::OperatorOnext,
366  bool start = true)
367  : Superclass(e, op, start)
368  {}
369 
371 
372  ~QuadEdgeMeshConstIteratorGeom() override = default;
373 
374  Self &
376  {
377  this->m_StartEdge = r.GetStartEdge();
378  this->m_Iterator = r.GetIterator();
379  this->m_OpType = r.GetOpType();
380  this->m_Start = r.GetStart();
381  return (*this);
382  }
383 
384  const OriginRefType
385  operator*() const
386  {
387  return (this->m_Iterator->GetOrigin());
388  }
389 };
390 } // namespace itk
391 
392 #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:361
itk::QuadEdgeMeshConstIterator
Const iterator for QuadEdgeMesh.
Definition: itkQuadEdgeMeshBaseIterator.h:304
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:291
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:364
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::QuadEdgeMeshIteratorGeom::QuadEdgeMeshIteratorGeom
QuadEdgeMeshIteratorGeom(QuadEdgeType *e=nullptr, int op=Superclass::OperatorOnext, bool start=true)
Definition: itkQuadEdgeMeshBaseIterator.h:284
itk::QuadEdgeMeshConstIterator::Value
const QuadEdgeType * Value() const
Definition: itkQuadEdgeMeshBaseIterator.h:337
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:358
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:316
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: itkAnatomicalOrientation.h:29
itk::QuadEdgeMeshBaseIterator::operator++
Self & operator++(int)
Definition: itkQuadEdgeMeshBaseIterator.h:155
itk::QuadEdgeMeshConstIteratorGeom
Const geometrical iterator.
Definition: itkQuadEdgeMeshBaseIterator.h:350
itk::QuadEdgeMeshConstIteratorGeom::operator*
const OriginRefType operator*() const
Definition: itkQuadEdgeMeshBaseIterator.h:385
itk::QuadEdgeMeshConstIteratorGeom::operator=
Self & operator=(const NoConstType &r)
Definition: itkQuadEdgeMeshBaseIterator.h:375
itk::QuadEdgeMeshBaseIterator::OperatorInvOnext
Definition: itkQuadEdgeMeshBaseIterator.h:79
itk::Math::e
static constexpr double e
Definition: itkMath.h:56
itk::QuadEdgeMeshBaseIterator::GoToNext
virtual void GoToNext()
Definition: itkQuadEdgeMeshBaseIterator.h:168
AddImageFilter
Definition: itkAddImageFilter.h:81
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:327
itk::QuadEdgeMeshBaseIterator< TGeometricalQuadEdge >::QuadEdgeType
TGeometricalQuadEdge QuadEdgeType
Definition: itkQuadEdgeMeshBaseIterator.h:65