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 CoordinateType = typename MeshType::CoordinateType;
88 #ifndef ITK_FUTURE_LEGACY_REMOVE
89  using CoordRepType ITK_FUTURE_DEPRECATED(
90  "ITK 6 discourages using `CoordRepType`. Please use `CoordinateType` instead!") = CoordinateType;
91 #endif
92  // QE types
93  using QEOriginType = typename QEType::OriginRefType;
94 
104  class FrontAtom
105  {
106  public:
107  FrontAtom(QEType * e = (QEType *)0, const CoordinateType c = 0)
108  : m_Edge(e)
109  , m_Cost(c)
110  {}
111  virtual ~FrontAtom() = default;
112  FrontAtom &
113  operator=(const FrontAtom & r)
114  {
115  m_Edge = r.m_Edge;
116  m_Cost = r.m_Cost;
117  return *this;
118  }
119  bool
120  operator==(const FrontAtom & r) const
121  {
122  return (m_Edge == r.m_Edge);
123  }
126  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(FrontAtom);
127 
128  bool
129  operator<(const FrontAtom & r) const
130  {
131  return (m_Cost < r.m_Cost);
132  }
133 
134  public:
137  };
138 
142  using FrontType = std::list<FrontAtom>;
143  using FrontTypeIterator = typename FrontType::iterator;
145 
151 
152 public:
154  QuadEdgeMeshFrontBaseIterator(MeshType * mesh = nullptr, bool start = true, QEType * seed = nullptr);
158  Self &
159  operator=(const Self & r)
160  {
161  if (this != &r)
162  {
163  m_Mesh = r.m_Mesh;
164  m_Start = r.m_Start;
165  m_Seed = r.m_Seed;
166  m_Front = r.m_Front;
167  m_IsPointVisited = r.m_IsPointVisited;
168  m_CurrentEdge = r.m_CurrentEdge;
169  }
170  return (*this);
171  }
172 
173  // Iteration methods.
174  bool
175  operator==(const Self & r) const
176  {
177  return (m_Start == r.m_Start);
178  }
179 
180  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Self);
181 
182  Self &
183  operator++();
184 
185  Self &
187  {
188  return (this->operator++());
189  }
190 
191  MeshType *
192  GetMesh() const
193  {
194  return this->m_Mesh;
195  }
196 
197 protected:
201  QEType *
202  FindDefaultSeed();
203 
207  virtual CoordinateType
208  GetCost(QEType * itkNotUsed(edge))
209  {
210  return (1);
211  }
212 
213 protected:
215  MeshType * m_Mesh{};
216 
218  QEType * m_Seed{};
219 
221  bool m_Start{};
222 
224  FrontTypePointer m_Front{};
225 
227  IsVisitedPointerType m_IsPointVisited{};
228 
230  QEType * m_CurrentEdge{};
231 };
232 
239 template <typename TMesh, typename TQE>
240 class ITK_TEMPLATE_EXPORT QuadEdgeMeshFrontIterator : public QuadEdgeMeshFrontBaseIterator<TMesh, TQE>
241 {
242 public:
243 
247  using typename Superclass::MeshType;
248  using typename Superclass::QEType;
249 
250 public:
252  QuadEdgeMeshFrontIterator(MeshType * mesh = (MeshType *)0, bool start = true, QEType * seed = nullptr)
253  : Superclass(mesh, start, seed)
254  {}
255  ~QuadEdgeMeshFrontIterator() override = default;
256  QEType *
258  {
259  return (this->m_CurrentEdge);
260  }
261 };
270 template <typename TMesh, typename TQE = typename TMesh::QEType>
271 class ITK_TEMPLATE_EXPORT QuadEdgeMeshConstFrontIterator : public QuadEdgeMeshFrontBaseIterator<TMesh, TQE>
272 {
273 public:
274 
278  using typename Superclass::QEType;
279  using typename Superclass::MeshType;
281 
282 public:
284  QuadEdgeMeshConstFrontIterator(const MeshType * itkNotUsed(mesh) = (MeshType *)0,
285  bool itkNotUsed(start) = true,
286  QEType * itkNotUsed(seed) = (QEType *)nullptr)
287  {}
288 
290  ~QuadEdgeMeshConstFrontIterator() override = default;
291  Self &
293  {
294  this->m_Mesh = r.GetMesh();
295  return (*this);
296  }
299  const QEType *
300  Value() const
301  {
302  return (this->m_CurrentEdge);
303  }
304 };
305 } // namespace itk
306 
307 #include "itkQuadEdgeMeshFrontIterator.hxx"
308 
309 #endif
itk::QuadEdgeMeshFrontBaseIterator::GetCost
virtual CoordinateType GetCost(QEType *)
Definition: itkQuadEdgeMeshFrontIterator.h:208
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom::FrontAtom
FrontAtom(QEType *e=(QEType *) 0, const CoordinateType c=0)
Definition: itkQuadEdgeMeshFrontIterator.h:107
itk::QuadEdgeMeshFrontBaseIterator::FrontTypePointer
FrontType * FrontTypePointer
Definition: itkQuadEdgeMeshFrontIterator.h:144
itk::QuadEdgeMeshFrontBaseIterator::operator==
bool operator==(const Self &r) const
Definition: itkQuadEdgeMeshFrontIterator.h:175
itk::QuadEdgeMeshFrontBaseIterator::m_IsPointVisited
IsVisitedPointerType m_IsPointVisited
Definition: itkQuadEdgeMeshFrontIterator.h:227
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom::operator==
bool operator==(const FrontAtom &r) const
Definition: itkQuadEdgeMeshFrontIterator.h:120
itk::operator<
bool operator<(const Index< VDimension > &one, const Index< VDimension > &two)
Definition: itkIndex.h:566
itk::QuadEdgeMeshFrontBaseIterator::m_Seed
QEType * m_Seed
Definition: itkQuadEdgeMeshFrontIterator.h:218
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom
Atomic information associated to each edge of the front.
Definition: itkQuadEdgeMeshFrontIterator.h:104
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom::m_Edge
QEType * m_Edge
Definition: itkQuadEdgeMeshFrontIterator.h:135
itk::QuadEdgeMeshConstFrontIterator::QuadEdgeMeshConstFrontIterator
QuadEdgeMeshConstFrontIterator(const MeshType *=(MeshType *) 0, bool=true, QEType *=(QEType *) nullptr)
Definition: itkQuadEdgeMeshFrontIterator.h:284
itk::QuadEdgeMeshFrontBaseIterator::MeshType
TMesh MeshType
Definition: itkQuadEdgeMeshFrontIterator.h:82
itk::QuadEdgeMeshFrontBaseIterator::m_Mesh
MeshType * m_Mesh
Definition: itkQuadEdgeMeshFrontIterator.h:215
itk::QuadEdgeMeshFrontBaseIterator::FrontType
std::list< FrontAtom > FrontType
Definition: itkQuadEdgeMeshFrontIterator.h:142
itk::QuadEdgeMeshFrontBaseIterator::GetMesh
MeshType * GetMesh() const
Definition: itkQuadEdgeMeshFrontIterator.h:192
itk::QuadEdgeMeshFrontBaseIterator::CoordinateType
typename MeshType::CoordinateType CoordinateType
Definition: itkQuadEdgeMeshFrontIterator.h:87
itk::QuadEdgeMeshFrontBaseIterator::m_Front
FrontTypePointer m_Front
Definition: itkQuadEdgeMeshFrontIterator.h:224
itk::MapContainer
A wrapper of the STL "map" container.
Definition: itkMapContainer.h:45
itk::QuadEdgeMeshFrontBaseIterator::IsVisitedPointerType
typename IsVisitedContainerType::Pointer IsVisitedPointerType
Definition: itkQuadEdgeMeshFrontIterator.h:150
itk::QuadEdgeMeshFrontBaseIterator
Front iterator on Mesh class.
Definition: itkQuadEdgeMeshFrontIterator.h:75
itk::QuadEdgeMeshFrontIterator
Non const quad edge front iterator.
Definition: itkQuadEdgeMeshFrontIterator.h:240
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom::operator=
FrontAtom & operator=(const FrontAtom &r)
Definition: itkQuadEdgeMeshFrontIterator.h:113
itk::QuadEdgeMeshFrontIterator::QuadEdgeMeshFrontIterator
QuadEdgeMeshFrontIterator(MeshType *mesh=(MeshType *) 0, bool start=true, QEType *seed=nullptr)
Definition: itkQuadEdgeMeshFrontIterator.h:252
itk::QuadEdgeMeshFrontBaseIterator::QEType
TQE QEType
Definition: itkQuadEdgeMeshFrontIterator.h:83
itk::QuadEdgeMeshFrontBaseIterator::operator=
Self & operator=(const Self &r)
Definition: itkQuadEdgeMeshFrontIterator.h:159
itk::QuadEdgeMeshFrontBaseIterator::m_Start
bool m_Start
Definition: itkQuadEdgeMeshFrontIterator.h:221
itk::QuadEdgeMeshFrontBaseIterator::m_CurrentEdge
QEType * m_CurrentEdge
Definition: itkQuadEdgeMeshFrontIterator.h:230
itk::QuadEdgeMeshConstFrontIterator::Value
const QEType * Value() const
Definition: itkQuadEdgeMeshFrontIterator.h:300
itk::QuadEdgeMeshConstFrontIterator
Const quad edge mesh front iterator.
Definition: itkQuadEdgeMeshFrontIterator.h:271
itk::QuadEdgeMeshFrontBaseIterator::FrontTypeIterator
typename FrontType::iterator FrontTypeIterator
Definition: itkQuadEdgeMeshFrontIterator.h:143
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:93
itk::QuadEdgeMeshFrontIterator::Value
QEType * Value()
Definition: itkQuadEdgeMeshFrontIterator.h:257
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:186
itk::QuadEdgeMeshFrontBaseIterator::FrontAtom::m_Cost
CoordinateType m_Cost
Definition: itkQuadEdgeMeshFrontIterator.h:136
itk::QuadEdgeMeshConstFrontIterator::operator=
Self & operator=(const NoConstType &r)
Definition: itkQuadEdgeMeshFrontIterator.h:292