ITK  6.0.0
Insight Toolkit
itkQuadEdgeMeshFrontIterator.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 itkQuadEdgeMeshFrontIterator_h
19 #define itkQuadEdgeMeshFrontIterator_h
20 
21 #include "itkMapContainer.h"
22 
23 // -------------------------------------------------------------------------
24 #define itkQEDefineFrontIteratorMethodsMacro(MeshTypeArg) \
25  /* Dual definition placed before others because of .NET that cannot */ \
26  /* cope with definition of FrontIterator (that further hides the */ \
27  /* definition of the template). */ \
28  using QEDualType = typename MeshTypeArg::QEDual; \
29  using QEPrimalType = typename MeshTypeArg::QEPrimal; \
30  using FrontDualIterator = QuadEdgeMeshFrontIterator<MeshTypeArg, QEDualType>; \
31  using ConstFrontDualIterator = QuadEdgeMeshConstFrontIterator<MeshTypeArg, QEDualType>; \
32  using FrontIterator = QuadEdgeMeshFrontIterator<MeshTypeArg, QEPrimalType>; \
33  using ConstFrontIterator = QuadEdgeMeshConstFrontIterator<MeshTypeArg, QEPrimalType>; \
34  \
35  virtual FrontIterator BeginFront(QEPrimalType * seed = nullptr) { return (FrontIterator(this, true, seed)); } \
36  \
37  virtual ConstFrontIterator BeginFront(QEPrimalType * seed) const { return (ConstFrontIterator(this, true, seed)); } \
38  \
39  virtual FrontIterator EndFront() { return (FrontIterator(this, false)); } \
40  \
41  virtual ConstFrontIterator EndFront() const { return (ConstFrontIterator(this, false)); } \
42  \
43  virtual FrontDualIterator BeginDualFront(QEDualType * seed = (QEDualType *)0) \
44  { \
45  return (FrontDualIterator(this, true, seed)); \
46  } \
47  \
48  virtual ConstFrontDualIterator BeginDualFront(QEDualType * seed) const \
49  { \
50  return (ConstFrontDualIterator(this, true, seed)); \
51  } \
52  \
53  virtual FrontDualIterator EndDualFront() { return (FrontDualIterator(this, false)); } \
54  \
55  virtual ConstFrontDualIterator EndDualFront() const { return (ConstFrontDualIterator(this, false)); } \
56  \
57  ITK_MACROEND_NOOP_STATEMENT
58 
59 namespace itk
60 {
74 template <typename TMesh, typename TQE>
75 class ITK_TEMPLATE_EXPORT QuadEdgeMeshFrontBaseIterator
76 {
77 public:
78  // Hierarchy type alias & values.
80 
81  // Template types
82  using MeshType = TMesh;
83  using QEType = TQE;
84 
85 protected:
86  // Mesh types
87  using CoordRepType = typename MeshType::CoordRepType;
88  // QE types
89  using QEOriginType = typename QEType::OriginRefType;
90 
100  class FrontAtom
101  {
102  public:
103  FrontAtom(QEType * e = (QEType *)0, const CoordRepType c = 0)
104  : m_Edge(e)
105  , m_Cost(c)
106  {}
107  virtual ~FrontAtom() = default;
108  FrontAtom &
109  operator=(const FrontAtom & r)
110  {
111  m_Edge = r.m_Edge;
112  m_Cost = r.m_Cost;
113  return *this;
114  }
115  bool
116  operator==(const FrontAtom & r) const
117  {
118  return (m_Edge == r.m_Edge);
119  }
122  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(FrontAtom);
123 
124  bool
125  operator<(const FrontAtom & r) const
126  {
127  return (m_Cost < r.m_Cost);
128  }
129 
130  public:
133  };
134 
138  using FrontType = std::list<FrontAtom>;
139  using FrontTypeIterator = typename FrontType::iterator;
141 
147 
148 public:
150  QuadEdgeMeshFrontBaseIterator(MeshType * mesh = nullptr, bool start = true, QEType * seed = nullptr);
154  Self &
155  operator=(const Self & r)
156  {
157  if (this != &r)
158  {
159  m_Mesh = r.m_Mesh;
160  m_Start = r.m_Start;
161  m_Seed = r.m_Seed;
162  m_Front = r.m_Front;
163  m_IsPointVisited = r.m_IsPointVisited;
164  m_CurrentEdge = r.m_CurrentEdge;
165  }
166  return (*this);
167  }
168 
169  // Iteration methods.
170  bool
171  operator==(const Self & r) const
172  {
173  return (m_Start == r.m_Start);
174  }
175 
176  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Self);
177 
178  Self &
179  operator++();
180 
181  Self &
183  {
184  return (this->operator++());
185  }
186 
187  MeshType *
188  GetMesh() const
189  {
190  return this->m_Mesh;
191  }
192 
193 protected:
197  QEType *
198  FindDefaultSeed();
199 
203  virtual CoordRepType
204  GetCost(QEType * itkNotUsed(edge))
205  {
206  return (1);
207  }
208 
209 protected:
211  MeshType * m_Mesh{};
212 
214  QEType * m_Seed{};
215 
217  bool m_Start{};
218 
220  FrontTypePointer m_Front{};
221 
223  IsVisitedPointerType m_IsPointVisited{};
224 
226  QEType * m_CurrentEdge{};
227 };
228 
235 template <typename TMesh, typename TQE>
236 class ITK_TEMPLATE_EXPORT QuadEdgeMeshFrontIterator : public QuadEdgeMeshFrontBaseIterator<TMesh, TQE>
237 {
238 public:
239 
243  using typename Superclass::MeshType;
244  using typename Superclass::QEType;
245 
246 public:
248  QuadEdgeMeshFrontIterator(MeshType * mesh = (MeshType *)0, bool start = true, QEType * seed = nullptr)
249  : Superclass(mesh, start, seed)
250  {}
251  ~QuadEdgeMeshFrontIterator() override = default;
252  QEType *
254  {
255  return (this->m_CurrentEdge);
256  }
257 };
266 template <typename TMesh, typename TQE = typename TMesh::QEType>
267 class ITK_TEMPLATE_EXPORT QuadEdgeMeshConstFrontIterator : public QuadEdgeMeshFrontBaseIterator<TMesh, TQE>
268 {
269 public:
270 
274  using typename Superclass::QEType;
275  using typename Superclass::MeshType;
277 
278 public:
280  QuadEdgeMeshConstFrontIterator(const MeshType * itkNotUsed(mesh) = (MeshType *)0,
281  bool itkNotUsed(start) = true,
282  QEType * itkNotUsed(seed) = (QEType *)nullptr)
283  {}
284 
286  ~QuadEdgeMeshConstFrontIterator() override = default;
287  Self &
289  {
290  this->m_Mesh = r.GetMesh();
291  return (*this);
292  }
295  const QEType *
296  Value() const
297  {
298  return (this->m_CurrentEdge);
299  }
300 };
301 } // namespace itk
302 
303 #include "itkQuadEdgeMeshFrontIterator.hxx"
304 
305 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::QuadEdgeMeshFrontBaseIterator::FrontTypePointer
FrontType * FrontTypePointer
Definition: itkQuadEdgeMeshFrontIterator.h:140
itk::QuadEdgeMeshFrontBaseIterator::operator==
bool operator==(const Self &r) const
Definition: itkQuadEdgeMeshFrontIterator.h:171
itk::QuadEdgeMeshFrontBaseIterator::m_IsPointVisited
IsVisitedPointerType m_IsPointVisited
Definition: itkQuadEdgeMeshFrontIterator.h:223
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom::operator==
bool operator==(const FrontAtom &r) const
Definition: itkQuadEdgeMeshFrontIterator.h:116
itk::operator<
bool operator<(const Index< VDimension > &one, const Index< VDimension > &two)
Definition: itkIndex.h:557
itk::QuadEdgeMeshFrontBaseIterator::m_Seed
QEType * m_Seed
Definition: itkQuadEdgeMeshFrontIterator.h:214
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom
Atomic information associated to each edge of the front.
Definition: itkQuadEdgeMeshFrontIterator.h:100
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom::m_Edge
QEType * m_Edge
Definition: itkQuadEdgeMeshFrontIterator.h:131
itk::QuadEdgeMeshConstFrontIterator::QuadEdgeMeshConstFrontIterator
QuadEdgeMeshConstFrontIterator(const MeshType *=(MeshType *) 0, bool=true, QEType *=(QEType *) nullptr)
Definition: itkQuadEdgeMeshFrontIterator.h:280
itk::QuadEdgeMeshFrontBaseIterator::MeshType
TMesh MeshType
Definition: itkQuadEdgeMeshFrontIterator.h:82
itk::QuadEdgeMeshFrontBaseIterator::m_Mesh
MeshType * m_Mesh
Definition: itkQuadEdgeMeshFrontIterator.h:211
itk::QuadEdgeMeshFrontBaseIterator::FrontType
std::list< FrontAtom > FrontType
Definition: itkQuadEdgeMeshFrontIterator.h:138
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom::FrontAtom
FrontAtom(QEType *e=(QEType *) 0, const CoordRepType c=0)
Definition: itkQuadEdgeMeshFrontIterator.h:103
itk::QuadEdgeMeshFrontBaseIterator::GetMesh
MeshType * GetMesh() const
Definition: itkQuadEdgeMeshFrontIterator.h:188
itk::QuadEdgeMeshFrontBaseIterator::m_Front
FrontTypePointer m_Front
Definition: itkQuadEdgeMeshFrontIterator.h:220
itk::MapContainer
A wrapper of the STL "map" container.
Definition: itkMapContainer.h:45
itk::QuadEdgeMeshFrontBaseIterator::CoordRepType
typename MeshType::CoordRepType CoordRepType
Definition: itkQuadEdgeMeshFrontIterator.h:87
itk::QuadEdgeMeshFrontBaseIterator::IsVisitedPointerType
typename IsVisitedContainerType::Pointer IsVisitedPointerType
Definition: itkQuadEdgeMeshFrontIterator.h:146
itk::QuadEdgeMeshFrontBaseIterator
Front iterator on Mesh class.
Definition: itkQuadEdgeMeshFrontIterator.h:75
itk::QuadEdgeMeshFrontIterator
Non const quad edge front iterator.
Definition: itkQuadEdgeMeshFrontIterator.h:236
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom::operator=
FrontAtom & operator=(const FrontAtom &r)
Definition: itkQuadEdgeMeshFrontIterator.h:109
itk::QuadEdgeMeshFrontIterator::QuadEdgeMeshFrontIterator
QuadEdgeMeshFrontIterator(MeshType *mesh=(MeshType *) 0, bool start=true, QEType *seed=nullptr)
Definition: itkQuadEdgeMeshFrontIterator.h:248
itk::QuadEdgeMeshFrontBaseIterator::QEType
TQE QEType
Definition: itkQuadEdgeMeshFrontIterator.h:83
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom::m_Cost
CoordRepType m_Cost
Definition: itkQuadEdgeMeshFrontIterator.h:132
itk::QuadEdgeMeshFrontBaseIterator::operator=
Self & operator=(const Self &r)
Definition: itkQuadEdgeMeshFrontIterator.h:155
itk::QuadEdgeMeshFrontBaseIterator::m_Start
bool m_Start
Definition: itkQuadEdgeMeshFrontIterator.h:217
itk::QuadEdgeMeshFrontBaseIterator::m_CurrentEdge
QEType * m_CurrentEdge
Definition: itkQuadEdgeMeshFrontIterator.h:226
itk::QuadEdgeMeshConstFrontIterator::Value
const QEType * Value() const
Definition: itkQuadEdgeMeshFrontIterator.h:296
itk::QuadEdgeMeshConstFrontIterator
Const quad edge mesh front iterator.
Definition: itkQuadEdgeMeshFrontIterator.h:267
itk::QuadEdgeMeshFrontBaseIterator::FrontTypeIterator
typename FrontType::iterator FrontTypeIterator
Definition: itkQuadEdgeMeshFrontIterator.h:139
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::QuadEdgeMeshFrontBaseIterator::QEOriginType
typename QEType::OriginRefType QEOriginType
Definition: itkQuadEdgeMeshFrontIterator.h:89
itk::QuadEdgeMeshFrontIterator::Value
QEType * Value()
Definition: itkQuadEdgeMeshFrontIterator.h:253
itk::QuadEdgeMeshFrontBaseIterator::GetCost
virtual CoordRepType GetCost(QEType *)
Definition: itkQuadEdgeMeshFrontIterator.h:204
itk::Math::e
static constexpr double e
Definition: itkMath.h:56
AddImageFilter
Definition: itkAddImageFilter.h:81
itkMapContainer.h
itk::QuadEdgeMeshFrontBaseIterator::operator++
Self & operator++(int)
Definition: itkQuadEdgeMeshFrontIterator.h:182
itk::QuadEdgeMeshConstFrontIterator::operator=
Self & operator=(const NoConstType &r)
Definition: itkQuadEdgeMeshFrontIterator.h:288