ITK  5.4.0
Insight Toolkit
itkQuadEdge.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 itkQuadEdge_h
19 #define itkQuadEdge_h
20 
22 #include "ITKQuadEdgeMeshExport.h"
23 
24 #include "itkMacro.h"
25 
26 // Debugging macros for classes that do not derive from the itkObject.
27 // FIXME: Maybe variations of these macros should be moved into
28 // itkMacro.h
29 //
30 #define itkQEDebugMacro(x) \
31  { \
32  std::ostringstream itkmsg; \
33  itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << '\n' << " (" << this << "): " x << "\n\n"; \
34  OutputWindowDisplayDebugText(itkmsg.str().c_str()); \
35  } \
36  ITK_MACROEND_NOOP_STATEMENT
37 #define itkQEWarningMacro(x) \
38  { \
39  std::ostringstream itkmsg; \
40  itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << '\n' << " (" << this << "): " x << "\n\n"; \
41  OutputWindowDisplayWarningText(itkmsg.str().c_str()); \
42  } \
43  ITK_MACROEND_NOOP_STATEMENT
44 
45 // -------------------------------------------------------------------------
55 #define itkQEAccessorsMacro(st, pt, dt) \
56  pt * GetOnext() { return (dynamic_cast<pt *>(this->st::GetOnext())); } \
57  \
58  dt * GetRot() { return (dynamic_cast<dt *>(this->st::GetRot())); } \
59  \
60  pt * GetSym() { return (dynamic_cast<pt *>(this->st::GetSym())); } \
61  \
62  pt * GetLnext() { return (dynamic_cast<pt *>(this->st::GetLnext())); } \
63  \
64  pt * GetRnext() { return (dynamic_cast<pt *>(this->st::GetRnext())); } \
65  \
66  pt * GetDnext() { return (dynamic_cast<pt *>(this->st::GetDnext())); } \
67  \
68  pt * GetOprev() { return (dynamic_cast<pt *>(this->st::GetOprev())); } \
69  \
70  pt * GetLprev() { return (dynamic_cast<pt *>(this->st::GetLprev())); } \
71  \
72  pt * GetRprev() { return (dynamic_cast<pt *>(this->st::GetRprev())); } \
73  \
74  pt * GetDprev() { return (dynamic_cast<pt *>(this->st::GetDprev())); } \
75  \
76  dt * GetInvRot() { return (dynamic_cast<dt *>(this->st::GetInvRot())); } \
77  \
78  pt * GetInvOnext() { return (dynamic_cast<pt *>(this->st::GetInvOnext())); } \
79  \
80  pt * GetInvLnext() { return (dynamic_cast<pt *>(this->st::GetInvLnext())); } \
81  \
82  pt * GetInvRnext() { return (dynamic_cast<pt *>(this->st::GetInvRnext())); } \
83  \
84  pt * GetInvDnext() { return (dynamic_cast<pt *>(this->st::GetInvDnext())); } \
85  const pt * GetOnext() const { return (dynamic_cast<const pt *>(this->st::GetOnext())); } \
86  \
87  const dt * GetRot() const { return (dynamic_cast<const dt *>(this->st::GetRot())); } \
88  \
89  const pt * GetSym() const { return (dynamic_cast<const pt *>(this->st::GetSym())); } \
90  \
91  const pt * GetLnext() const { return (dynamic_cast<const pt *>(this->st::GetLnext())); } \
92  \
93  const pt * GetRnext() const { return (dynamic_cast<const pt *>(this->st::GetRnext())); } \
94  \
95  const pt * GetDnext() const { return (dynamic_cast<const pt *>(this->st::GetDnext())); } \
96  \
97  const pt * GetOprev() const { return (dynamic_cast<const pt *>(this->st::GetOprev())); } \
98  \
99  const pt * GetLprev() const { return (dynamic_cast<const pt *>(this->st::GetLprev())); } \
100  \
101  const pt * GetRprev() const { return (dynamic_cast<const pt *>(this->st::GetRprev())); } \
102  \
103  const pt * GetDprev() const { return (dynamic_cast<const pt *>(this->st::GetDprev())); } \
104  \
105  const dt * GetInvRot() const { return (dynamic_cast<const dt *>(this->st::GetInvRot())); } \
106  \
107  const pt * GetInvOnext() const { return (dynamic_cast<const pt *>(this->st::GetInvOnext())); } \
108  \
109  const pt * GetInvLnext() const { return (dynamic_cast<const pt *>(this->st::GetInvLnext())); } \
110  \
111  const pt * GetInvRnext() const { return (dynamic_cast<const pt *>(this->st::GetInvRnext())); } \
112  \
113  const pt * GetInvDnext() const { return (dynamic_cast<const pt *>(this->st::GetInvDnext())); }
114 
116 namespace itk
117 {
134 class ITKQuadEdgeMesh_EXPORT QuadEdge
135 {
136 public:
138  using Self = QuadEdge;
139 
143 
145  inline itkQEDefineIteratorMethodsMacro(Onext);
146  // itkQEDefineIteratorMethodsMacro( Sym );
147  // itkQEDefineIteratorMethodsMacro( Lnext );
148  // itkQEDefineIteratorMethodsMacro( Rnext );
149  // itkQEDefineIteratorMethodsMacro( Dnext );
150  // itkQEDefineIteratorMethodsMacro( Oprev );
151  // itkQEDefineIteratorMethodsMacro( Lprev );
152  // itkQEDefineIteratorMethodsMacro( Rprev );
153  // itkQEDefineIteratorMethodsMacro( Dprev );
154  // itkQEDefineIteratorMethodsMacro( InvOnext );
155  // itkQEDefineIteratorMethodsMacro( InvLnext );
156  // itkQEDefineIteratorMethodsMacro( InvRnext );
157  // itkQEDefineIteratorMethodsMacro( InvDnext );
161  QuadEdge();
162  QuadEdge(const QuadEdge &) = default;
163  QuadEdge(QuadEdge &&) = default;
164  QuadEdge &
165  operator=(const QuadEdge &) = default;
166  QuadEdge &
167  operator=(QuadEdge &&) = default;
168  virtual ~QuadEdge();
172  inline void
173  SetOnext(Self * onext)
174  {
175  this->m_Onext = onext;
176  }
177  inline void
178  SetRot(Self * rot)
179  {
180  this->m_Rot = rot;
181  }
187  inline Self *
189  {
190  return this->m_Onext;
191  }
192  inline Self *
194  {
195  return this->m_Rot;
196  }
197  inline const Self *
198  GetOnext() const
199  {
200  return this->m_Onext;
201  }
202  inline const Self *
203  GetRot() const
204  {
205  return this->m_Rot;
206  }
225  // TODO fix this ref
226  // * \sa \ref DoxySurgeryConnectivity
227  inline void
229  {
230  Self * aNext = this->GetOnext();
231  Self * bNext = b->GetOnext();
232  Self * alpha = aNext->GetRot();
233  Self * beta = bNext->GetRot();
234  Self * alphaNext = alpha->GetOnext();
235  Self * betaNext = beta->GetOnext();
238  this->SetOnext(bNext);
239  b->SetOnext(aNext);
240  alpha->SetOnext(betaNext);
241  beta->SetOnext(alphaNext);
242  }
243 
244  // Second order accessors.
245 
248  inline Self *
250  {
251  if (this->m_Rot)
252  {
253  return (this->m_Rot->m_Rot);
254  }
255  return (this->m_Rot);
256  }
259  inline const Self *
260  GetSym() const
261  {
262  if (this->m_Rot)
263  {
264  return (this->m_Rot->m_Rot);
265  }
266  return (this->m_Rot);
267  }
268 
271  Self *
272  GetLnext();
273 
274  const Self *
275  GetLnext() const;
276 
280  Self *
281  GetRnext();
282 
283  const Self *
284  GetRnext() const;
285 
289  Self *
290  GetDnext();
291 
292  const Self *
293  GetDnext() const;
294 
297  Self *
298  GetOprev();
299 
300  const Self *
301  GetOprev() const;
302 
306  Self *
307  GetLprev();
308 
309  const Self *
310  GetLprev() const;
311 
315  Self *
316  GetRprev();
317 
318  const Self *
319  GetRprev() const;
320 
324  Self *
325  GetDprev();
326 
327  const Self *
328  GetDprev() const;
329 
331  inline Self *
333  {
334 #ifdef NDEBUG
335  return (this->GetRot()->GetRot()->GetRot());
336 #else
337  Self * p1 = this->GetRot();
338  if (!p1)
339  {
340  return nullptr;
341  }
342  Self * p2 = p1->GetRot();
343  if (!p2)
344  {
345  return nullptr;
346  }
347  Self * p3 = p2->GetRot();
348  if (!p3)
349  {
350  return nullptr;
351  }
352  return p3;
353 #endif
354  }
357  inline Self *
359  {
360  return this->GetOprev();
361  }
362  inline Self *
364  {
365  return this->GetLprev();
366  }
367  inline Self *
369  {
370  return this->GetRprev();
371  }
372  inline Self *
374  {
375  return this->GetDprev();
376  }
377  inline const Self *
378  GetInvRot() const
379  {
380 #ifdef NDEBUG
381  return (this->GetRot()->GetRot()->GetRot());
382 #else
383  const Self * p1 = this->GetRot();
384  if (!p1)
385  {
386  return nullptr;
387  }
388  const Self * p2 = p1->GetRot();
389  if (!p2)
390  {
391  return nullptr;
392  }
393  const Self * p3 = p2->GetRot();
394  if (!p3)
395  {
396  return nullptr;
397  }
398  return p3;
399 #endif
400  }
401 
402  inline const Self *
403  GetInvOnext() const
404  {
405  return this->GetOprev();
406  }
407  inline const Self *
408  GetInvLnext() const
409  {
410  return this->GetLprev();
411  }
412  inline const Self *
413  GetInvRnext() const
414  {
415  return this->GetRprev();
416  }
417  inline const Self *
418  GetInvDnext() const
419  {
420  return this->GetDprev();
421  }
422 
424  inline bool
425  IsHalfEdge() const
426  {
427  return ((m_Onext == this) || (m_Rot == nullptr));
428  }
429  inline bool
430  IsIsolated() const
431  {
432  return (this == this->GetOnext());
433  }
434  bool
435  IsEdgeInOnextRing(Self * testEdge) const;
438  bool
439  IsLnextGivenSizeCyclic(const int size) const;
440 
441  unsigned int
442  GetOrder() const;
443 
444 private:
448 };
449 } // namespace itk
450 
451 #endif
itk::QuadEdge::GetInvRnext
const Self * GetInvRnext() const
Definition: itkQuadEdge.h:413
itk::QuadEdge::GetOnext
Self * GetOnext()
Definition: itkQuadEdge.h:188
itk::QuadEdge::GetInvOnext
const Self * GetInvOnext() const
Definition: itkQuadEdge.h:403
itk::QuadEdgeMeshConstIterator
Const iterator for QuadEdgeMesh.
Definition: itkQuadEdgeMeshBaseIterator.h:302
itk::QuadEdge::GetInvLnext
Self * GetInvLnext()
Definition: itkQuadEdge.h:363
itkQEDefineIteratorMethodsMacro
#define itkQEDefineIteratorMethodsMacro(Op)
Definition: itkQuadEdgeMeshBaseIterator.h:24
itk::QuadEdge::GetInvDnext
const Self * GetInvDnext() const
Definition: itkQuadEdge.h:418
itk::QuadEdge::IsIsolated
bool IsIsolated() const
Definition: itkQuadEdge.h:430
itk::QuadEdge::GetInvLnext
const Self * GetInvLnext() const
Definition: itkQuadEdge.h:408
itk::QuadEdge::Splice
void Splice(Self *b)
Basic quad-edge topological method.
Definition: itkQuadEdge.h:228
itk::QuadEdge::GetOnext
const Self * GetOnext() const
Definition: itkQuadEdge.h:198
itkMacro.h
itk::QuadEdge::GetInvRnext
Self * GetInvRnext()
Definition: itkQuadEdge.h:368
itk::QuadEdge::SetOnext
void SetOnext(Self *onext)
Definition: itkQuadEdge.h:173
itk::QuadEdge::GetSym
Self * GetSym()
Definition: itkQuadEdge.h:249
itk::QuadEdge::SetRot
void SetRot(Self *rot)
Definition: itkQuadEdge.h:178
itk::QuadEdge
Base class for the implementation of a quad-edge data structure as proposed in "Guibas and Stolfi 198...
Definition: itkQuadEdge.h:134
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::QuadEdge::GetRot
const Self * GetRot() const
Definition: itkQuadEdge.h:203
itk::QuadEdge::GetSym
const Self * GetSym() const
Definition: itkQuadEdge.h:260
itk::QuadEdge::GetInvOnext
Self * GetInvOnext()
Definition: itkQuadEdge.h:358
AddImageFilter
Definition: itkAddImageFilter.h:81
itk::QuadEdgeMeshIterator
Non const iterator for QuadMesh.
Definition: itkQuadEdgeMeshBaseIterator.h:234
itk::QuadEdge::GetInvRot
const Self * GetInvRot() const
Definition: itkQuadEdge.h:378
itk::QuadEdge::IsHalfEdge
bool IsHalfEdge() const
Definition: itkQuadEdge.h:425
itk::QuadEdge::GetInvDnext
Self * GetInvDnext()
Definition: itkQuadEdge.h:373
itk::QuadEdge::GetRot
Self * GetRot()
Definition: itkQuadEdge.h:193
itk::QuadEdge::GetInvRot
Self * GetInvRot()
Definition: itkQuadEdge.h:332
itkQuadEdgeMeshBaseIterator.h