ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkQuadEdgeMeshFrontIterator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 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, \
31  QEDualType >; \
32  using ConstFrontDualIterator = QuadEdgeMeshConstFrontIterator< MeshTypeArg, \
33  QEDualType >; \
34  using FrontIterator = QuadEdgeMeshFrontIterator< MeshTypeArg, QEPrimalType >; \
35  using ConstFrontIterator = QuadEdgeMeshConstFrontIterator< MeshTypeArg, \
36  QEPrimalType >; \
37  \
38  virtual FrontIterator BeginFront(QEPrimalType * seed = (QEPrimalType *)0) \
39  { \
40  return ( FrontIterator(this, true, seed) ); \
41  } \
42  \
43  virtual ConstFrontIterator BeginFront(QEPrimalType * seed) const \
44  { return ( ConstFrontIterator(this, true, seed) ); } \
45  \
46  virtual FrontIterator EndFront() \
47  { \
48  return ( FrontIterator(this, false) ); \
49  } \
50  \
51  virtual ConstFrontIterator EndFront() const \
52  { return ( ConstFrontIterator(this, false) ); } \
53  \
54  virtual FrontDualIterator BeginDualFront(QEDualType * seed = (QEDualType *)0) \
55  { \
56  return ( FrontDualIterator(this, true, seed) ); \
57  } \
58  \
59  virtual ConstFrontDualIterator BeginDualFront(QEDualType * seed) const \
60  { return ( ConstFrontDualIterator(this, true, seed) ); } \
61  \
62  virtual FrontDualIterator EndDualFront() \
63  { \
64  return ( FrontDualIterator(this, false) ); \
65  } \
66  \
67  virtual ConstFrontDualIterator EndDualFront() const \
68  { return ( ConstFrontDualIterator(this, false) ); }
69 
70 namespace itk
71 {
85 template< typename TMesh, typename TQE >
86 class ITK_TEMPLATE_EXPORT QuadEdgeMeshFrontBaseIterator
87 {
88 public:
89  // Hierarchy type alias & values.
91 
92  // Template types
93  using MeshType = TMesh;
94  using QEType = TQE;
95 
96 protected:
97  // Mesh types
98  using CoordRepType = typename MeshType::CoordRepType;
99  // QE types
100  using QEOriginType = typename QEType::OriginRefType;
101 
111  class FrontAtom
112  {
113 public:
114  FrontAtom(QEType *e = (QEType *)0, const CoordRepType c = 0):
115  m_Edge(e), m_Cost(c)
116  {}
117  virtual ~FrontAtom() = default;
119  { m_Edge = r.m_Edge; m_Cost = r.m_Cost; return *this; }
120  bool operator==(const FrontAtom & r) const
121  { return ( m_Edge == r.m_Edge ); }
122  bool operator!=(const FrontAtom & r) const
123  { return ( m_Edge != r.m_Edge ); }
124  bool operator<(const FrontAtom & r) const
125  { return ( m_Cost < r.m_Cost ); }
127 
128 public:
131  };
132 
136  using FrontType = std::list< FrontAtom >;
137  using FrontTypeIterator = typename FrontType::iterator;
139 
145 
146 public:
149  bool start = true,
150  QEType *seed = (QEType *)nullptr);
153 
154  Self & operator=(const Self & r)
155  {
156  if(this != &r)
157  {
158  m_Mesh = r.m_Mesh;
159  m_Start = r.m_Start;
160  m_Seed = r.m_Seed;
161  m_Front = r.m_Front;
162  m_IsPointVisited = r.m_IsPointVisited;
163  m_CurrentEdge = r.m_CurrentEdge;
164  }
165  return ( *this );
166  }
167 
168  // Iteration methods.
169  bool operator==(Self & r)
170  {
171  return ( m_Start == r.m_Start );
172  }
173 
174  bool operator==(const Self & r) const
175  {
176  return ( m_Start == r.m_Start );
177  }
178 
179  bool operator!=(Self & r)
180  {
181  return ( !( this->operator==(r) ) );
182  }
183 
184  bool operator!=(const Self & r) const
185  {
186  return ( !( this->operator==(r) ) );
187  }
188 
189  Self & operator++();
190 
191  Self & operator++(int) { return ( this->operator++() ); }
192 
193  MeshType * GetMesh() const { return this->m_Mesh; }
194 
195 protected:
199  QEType * FindDefaultSeed();
200 
204  virtual CoordRepType GetCost(QEType *edge){ (void)edge; return ( 1 ); }
205 
206 protected:
209 
212 
214  bool m_Start;
215 
218 
221 
224 };
225 
232 template< typename TMesh, typename TQE >
233 class ITK_TEMPLATE_EXPORT QuadEdgeMeshFrontIterator:
234  public QuadEdgeMeshFrontBaseIterator< TMesh, TQE >
235 {
236 public:
237 
241  using MeshType = typename Superclass::MeshType;
242  using QEType = typename Superclass::QEType;
243 
244 public:
247  bool start = true,
248  QEType *seed = (QEType *)nullptr):
249  Superclass(mesh, start, seed) {}
250  ~QuadEdgeMeshFrontIterator() override = default;
251  QEType * Value() { return ( this->m_CurrentEdge ); }
252 };
254 
261 template< typename TMesh, typename TQE = typename TMesh::QEType >
262 class ITK_TEMPLATE_EXPORT QuadEdgeMeshConstFrontIterator:
263  public QuadEdgeMeshFrontBaseIterator< TMesh, TQE >
264 {
265 public:
266 
270  using QEType = typename Superclass::QEType;
271  using MeshType = typename Superclass::MeshType;
273 
274 public:
277  bool start = true,
278  QEType *seed = (QEType *)nullptr)
279  {
280  (void)mesh;
281  (void)start;
282  (void)seed;
283  }
285 
287  ~QuadEdgeMeshConstFrontIterator() override = default;
289  {
290  this->m_Mesh = r.GetMesh();
291  return ( *this );
292  }
294 
295  const QEType * Value() const { return ( this->m_CurrentEdge ); }
296 };
297 }
298 
299 #include "itkQuadEdgeMeshFrontIterator.hxx"
300 
301 #endif
typename FrontType::iterator FrontTypeIterator
A wrapper of the STL &quot;map&quot; container.
typename MeshType::CoordRepType CoordRepType
FrontAtom(QEType *e=(QEType *) 0, const CoordRepType c=0)
typename QEType::OriginRefType QEOriginType
Const quad edge mesh front iterator.
typename IsVisitedContainerType::Pointer IsVisitedPointerType
static constexpr double e
The base of the natural logarithm or Euler&#39;s number
Definition: itkMath.h:53
Atomic information associated to each edge of the front.
QuadEdgeMeshFrontIterator(MeshType *mesh=(MeshType *) 0, bool start=true, QEType *seed=(QEType *) nullptr)
Non const quad edge front iterator.
virtual CoordRepType GetCost(QEType *edge)
QuadEdgeMeshConstFrontIterator(const MeshType *mesh=(MeshType *) 0, bool start=true, QEType *seed=(QEType *) nullptr)