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 = (QEPrimalType *)nullptr) \
36  { \
37  return (FrontIterator(this, true, seed)); \
38  } \
39  \
40  virtual ConstFrontIterator BeginFront(QEPrimalType * seed) const { return (ConstFrontIterator(this, true, seed)); } \
41  \
42  virtual FrontIterator EndFront() { return (FrontIterator(this, false)); } \
43  \
44  virtual ConstFrontIterator EndFront() const { return (ConstFrontIterator(this, false)); } \
45  \
46  virtual FrontDualIterator BeginDualFront(QEDualType * seed = (QEDualType *)0) \
47  { \
48  return (FrontDualIterator(this, true, seed)); \
49  } \
50  \
51  virtual ConstFrontDualIterator BeginDualFront(QEDualType * seed) const \
52  { \
53  return (ConstFrontDualIterator(this, true, seed)); \
54  } \
55  \
56  virtual FrontDualIterator EndDualFront() { return (FrontDualIterator(this, false)); } \
57  \
58  virtual ConstFrontDualIterator EndDualFront() const { return (ConstFrontDualIterator(this, false)); } \
59  \
60  ITK_MACROEND_NOOP_STATEMENT
61 
62 namespace itk
63 {
77 template <typename TMesh, typename TQE>
78 class ITK_TEMPLATE_EXPORT QuadEdgeMeshFrontBaseIterator
79 {
80 public:
81  // Hierarchy type alias & values.
83 
84  // Template types
85  using MeshType = TMesh;
86  using QEType = TQE;
87 
88 protected:
89  // Mesh types
90  using CoordRepType = typename MeshType::CoordRepType;
91  // QE types
92  using QEOriginType = typename QEType::OriginRefType;
93 
103  class FrontAtom
104  {
105  public:
106  FrontAtom(QEType * e = (QEType *)0, const CoordRepType c = 0)
107  : m_Edge(e)
108  , m_Cost(c)
109  {}
110  virtual ~FrontAtom() = default;
111  FrontAtom &
112  operator=(const FrontAtom & r)
113  {
114  m_Edge = r.m_Edge;
115  m_Cost = r.m_Cost;
116  return *this;
117  }
118  bool
119  operator==(const FrontAtom & r) const
120  {
121  return (m_Edge == r.m_Edge);
122  }
125  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(FrontAtom);
126 
127  bool
128  operator<(const FrontAtom & r) const
129  {
130  return (m_Cost < r.m_Cost);
131  }
132 
133  public:
136  };
137 
141  using FrontType = std::list<FrontAtom>;
142  using FrontTypeIterator = typename FrontType::iterator;
144 
150 
151 public:
153  QuadEdgeMeshFrontBaseIterator(MeshType * mesh = (MeshType *)nullptr,
154  bool start = true,
155  QEType * seed = (QEType *)nullptr);
159  Self &
160  operator=(const Self & r)
161  {
162  if (this != &r)
163  {
164  m_Mesh = r.m_Mesh;
165  m_Start = r.m_Start;
166  m_Seed = r.m_Seed;
167  m_Front = r.m_Front;
168  m_IsPointVisited = r.m_IsPointVisited;
169  m_CurrentEdge = r.m_CurrentEdge;
170  }
171  return (*this);
172  }
173 
174  // Iteration methods.
175  bool
176  operator==(const Self & r) const
177  {
178  return (m_Start == r.m_Start);
179  }
180 
181  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Self);
182 
183  Self &
184  operator++();
185 
186  Self &
188  {
189  return (this->operator++());
190  }
191 
192  MeshType *
193  GetMesh() const
194  {
195  return this->m_Mesh;
196  }
197 
198 protected:
202  QEType *
203  FindDefaultSeed();
204 
208  virtual CoordRepType
209  GetCost(QEType * itkNotUsed(edge))
210  {
211  return (1);
212  }
213 
214 protected:
216  MeshType * m_Mesh{};
217 
219  QEType * m_Seed{};
220 
222  bool m_Start{};
223 
225  FrontTypePointer m_Front{};
226 
228  IsVisitedPointerType m_IsPointVisited{};
229 
231  QEType * m_CurrentEdge{};
232 };
233 
240 template <typename TMesh, typename TQE>
241 class ITK_TEMPLATE_EXPORT QuadEdgeMeshFrontIterator : public QuadEdgeMeshFrontBaseIterator<TMesh, TQE>
242 {
243 public:
244 
248  using typename Superclass::MeshType;
249  using typename Superclass::QEType;
250 
251 public:
253  QuadEdgeMeshFrontIterator(MeshType * mesh = (MeshType *)0, bool start = true, QEType * seed = (QEType *)nullptr)
254  : Superclass(mesh, start, seed)
255  {}
256  ~QuadEdgeMeshFrontIterator() override = default;
257  QEType *
259  {
260  return (this->m_CurrentEdge);
261  }
262 };
271 template <typename TMesh, typename TQE = typename TMesh::QEType>
272 class ITK_TEMPLATE_EXPORT QuadEdgeMeshConstFrontIterator : public QuadEdgeMeshFrontBaseIterator<TMesh, TQE>
273 {
274 public:
275 
279  using typename Superclass::QEType;
280  using typename Superclass::MeshType;
282 
283 public:
285  QuadEdgeMeshConstFrontIterator(const MeshType * itkNotUsed(mesh) = (MeshType *)0,
286  bool itkNotUsed(start) = true,
287  QEType * itkNotUsed(seed) = (QEType *)nullptr)
288  {}
289 
291  ~QuadEdgeMeshConstFrontIterator() override = default;
292  Self &
294  {
295  this->m_Mesh = r.GetMesh();
296  return (*this);
297  }
300  const QEType *
301  Value() const
302  {
303  return (this->m_CurrentEdge);
304  }
305 };
306 } // namespace itk
307 
308 #include "itkQuadEdgeMeshFrontIterator.hxx"
309 
310 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::QuadEdgeMeshFrontBaseIterator::FrontTypePointer
FrontType * FrontTypePointer
Definition: itkQuadEdgeMeshFrontIterator.h:143
itk::QuadEdgeMeshFrontBaseIterator::operator==
bool operator==(const Self &r) const
Definition: itkQuadEdgeMeshFrontIterator.h:176
itk::QuadEdgeMeshFrontBaseIterator::m_IsPointVisited
IsVisitedPointerType m_IsPointVisited
Definition: itkQuadEdgeMeshFrontIterator.h:228
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom::operator==
bool operator==(const FrontAtom &r) const
Definition: itkQuadEdgeMeshFrontIterator.h:119
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:219
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom
Atomic information associated to each edge of the front.
Definition: itkQuadEdgeMeshFrontIterator.h:103
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom::m_Edge
QEType * m_Edge
Definition: itkQuadEdgeMeshFrontIterator.h:134
itk::QuadEdgeMeshConstFrontIterator::QuadEdgeMeshConstFrontIterator
QuadEdgeMeshConstFrontIterator(const MeshType *=(MeshType *) 0, bool=true, QEType *=(QEType *) nullptr)
Definition: itkQuadEdgeMeshFrontIterator.h:285
itk::QuadEdgeMeshFrontBaseIterator::MeshType
TMesh MeshType
Definition: itkQuadEdgeMeshFrontIterator.h:85
itk::QuadEdgeMeshFrontBaseIterator::m_Mesh
MeshType * m_Mesh
Definition: itkQuadEdgeMeshFrontIterator.h:216
itk::QuadEdgeMeshFrontBaseIterator::FrontType
std::list< FrontAtom > FrontType
Definition: itkQuadEdgeMeshFrontIterator.h:141
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom::FrontAtom
FrontAtom(QEType *e=(QEType *) 0, const CoordRepType c=0)
Definition: itkQuadEdgeMeshFrontIterator.h:106
itk::QuadEdgeMeshFrontBaseIterator::GetMesh
MeshType * GetMesh() const
Definition: itkQuadEdgeMeshFrontIterator.h:193
itk::QuadEdgeMeshFrontBaseIterator::m_Front
FrontTypePointer m_Front
Definition: itkQuadEdgeMeshFrontIterator.h:225
itk::QuadEdgeMeshFrontIterator::QuadEdgeMeshFrontIterator
QuadEdgeMeshFrontIterator(MeshType *mesh=(MeshType *) 0, bool start=true, QEType *seed=(QEType *) nullptr)
Definition: itkQuadEdgeMeshFrontIterator.h:253
itk::MapContainer
A wrapper of the STL "map" container.
Definition: itkMapContainer.h:45
itk::QuadEdgeMeshFrontBaseIterator::CoordRepType
typename MeshType::CoordRepType CoordRepType
Definition: itkQuadEdgeMeshFrontIterator.h:90
itk::QuadEdgeMeshFrontBaseIterator::IsVisitedPointerType
typename IsVisitedContainerType::Pointer IsVisitedPointerType
Definition: itkQuadEdgeMeshFrontIterator.h:149
itk::QuadEdgeMeshFrontBaseIterator
Front iterator on Mesh class.
Definition: itkQuadEdgeMeshFrontIterator.h:78
itk::QuadEdgeMeshFrontIterator
Non const quad edge front iterator.
Definition: itkQuadEdgeMeshFrontIterator.h:241
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom::operator=
FrontAtom & operator=(const FrontAtom &r)
Definition: itkQuadEdgeMeshFrontIterator.h:112
itk::QuadEdgeMeshFrontBaseIterator::QEType
TQE QEType
Definition: itkQuadEdgeMeshFrontIterator.h:86
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom::m_Cost
CoordRepType m_Cost
Definition: itkQuadEdgeMeshFrontIterator.h:135
itk::QuadEdgeMeshFrontBaseIterator::operator=
Self & operator=(const Self &r)
Definition: itkQuadEdgeMeshFrontIterator.h:160
itk::QuadEdgeMeshFrontBaseIterator::m_Start
bool m_Start
Definition: itkQuadEdgeMeshFrontIterator.h:222
itk::QuadEdgeMeshFrontBaseIterator::m_CurrentEdge
QEType * m_CurrentEdge
Definition: itkQuadEdgeMeshFrontIterator.h:231
itk::QuadEdgeMeshConstFrontIterator::Value
const QEType * Value() const
Definition: itkQuadEdgeMeshFrontIterator.h:301
itk::QuadEdgeMeshConstFrontIterator
Const quad edge mesh front iterator.
Definition: itkQuadEdgeMeshFrontIterator.h:272
itk::QuadEdgeMeshFrontBaseIterator::FrontTypeIterator
typename FrontType::iterator FrontTypeIterator
Definition: itkQuadEdgeMeshFrontIterator.h:142
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::QuadEdgeMeshFrontBaseIterator::QEOriginType
typename QEType::OriginRefType QEOriginType
Definition: itkQuadEdgeMeshFrontIterator.h:92
itk::QuadEdgeMeshFrontIterator::Value
QEType * Value()
Definition: itkQuadEdgeMeshFrontIterator.h:258
itk::QuadEdgeMeshFrontBaseIterator::GetCost
virtual CoordRepType GetCost(QEType *)
Definition: itkQuadEdgeMeshFrontIterator.h:209
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:187
itk::QuadEdgeMeshConstFrontIterator::operator=
Self & operator=(const NoConstType &r)
Definition: itkQuadEdgeMeshFrontIterator.h:293