ITK  5.2.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  * 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 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" \
34  << " (" << this << "): " x << "\n\n"; \
35  OutputWindowDisplayDebugText(itkmsg.str().c_str()); \
36  } \
37  ITK_MACROEND_NOOP_STATEMENT
38 #define itkQEWarningMacro(x) \
39  { \
40  std::ostringstream itkmsg; \
41  itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" \
42  << " (" << this << "): " x << "\n\n"; \
43  OutputWindowDisplayWarningText(itkmsg.str().c_str()); \
44  } \
45  ITK_MACROEND_NOOP_STATEMENT
46 
47 // -------------------------------------------------------------------------
57 #define itkQEAccessorsMacro(st, pt, dt) \
58  pt * GetOnext() { return (dynamic_cast<pt *>(this->st::GetOnext())); } \
59  \
60  dt * GetRot() { return (dynamic_cast<dt *>(this->st::GetRot())); } \
61  \
62  pt * GetSym() { return (dynamic_cast<pt *>(this->st::GetSym())); } \
63  \
64  pt * GetLnext() { return (dynamic_cast<pt *>(this->st::GetLnext())); } \
65  \
66  pt * GetRnext() { return (dynamic_cast<pt *>(this->st::GetRnext())); } \
67  \
68  pt * GetDnext() { return (dynamic_cast<pt *>(this->st::GetDnext())); } \
69  \
70  pt * GetOprev() { return (dynamic_cast<pt *>(this->st::GetOprev())); } \
71  \
72  pt * GetLprev() { return (dynamic_cast<pt *>(this->st::GetLprev())); } \
73  \
74  pt * GetRprev() { return (dynamic_cast<pt *>(this->st::GetRprev())); } \
75  \
76  pt * GetDprev() { return (dynamic_cast<pt *>(this->st::GetDprev())); } \
77  \
78  dt * GetInvRot() { return (dynamic_cast<dt *>(this->st::GetInvRot())); } \
79  \
80  pt * GetInvOnext() { return (dynamic_cast<pt *>(this->st::GetInvOnext())); } \
81  \
82  pt * GetInvLnext() { return (dynamic_cast<pt *>(this->st::GetInvLnext())); } \
83  \
84  pt * GetInvRnext() { return (dynamic_cast<pt *>(this->st::GetInvRnext())); } \
85  \
86  pt * GetInvDnext() { return (dynamic_cast<pt *>(this->st::GetInvDnext())); } \
87  const pt * GetOnext() const { return (dynamic_cast<const pt *>(this->st::GetOnext())); } \
88  \
89  const dt * GetRot() const { return (dynamic_cast<const dt *>(this->st::GetRot())); } \
90  \
91  const pt * GetSym() const { return (dynamic_cast<const pt *>(this->st::GetSym())); } \
92  \
93  const pt * GetLnext() const { return (dynamic_cast<const pt *>(this->st::GetLnext())); } \
94  \
95  const pt * GetRnext() const { return (dynamic_cast<const pt *>(this->st::GetRnext())); } \
96  \
97  const pt * GetDnext() const { return (dynamic_cast<const pt *>(this->st::GetDnext())); } \
98  \
99  const pt * GetOprev() const { return (dynamic_cast<const pt *>(this->st::GetOprev())); } \
100  \
101  const pt * GetLprev() const { return (dynamic_cast<const pt *>(this->st::GetLprev())); } \
102  \
103  const pt * GetRprev() const { return (dynamic_cast<const pt *>(this->st::GetRprev())); } \
104  \
105  const pt * GetDprev() const { return (dynamic_cast<const pt *>(this->st::GetDprev())); } \
106  \
107  const dt * GetInvRot() const { return (dynamic_cast<const dt *>(this->st::GetInvRot())); } \
108  \
109  const pt * GetInvOnext() const { return (dynamic_cast<const pt *>(this->st::GetInvOnext())); } \
110  \
111  const pt * GetInvLnext() const { return (dynamic_cast<const pt *>(this->st::GetInvLnext())); } \
112  \
113  const pt * GetInvRnext() const { return (dynamic_cast<const pt *>(this->st::GetInvRnext())); } \
114  \
115  const pt * GetInvDnext() const { return (dynamic_cast<const pt *>(this->st::GetInvDnext())); }
116 
117 
118 namespace itk
119 {
136 class ITKQuadEdgeMesh_EXPORT QuadEdge
137 {
138 public:
140  using Self = QuadEdge;
141 
145 
147  inline itkQEDefineIteratorMethodsMacro(Onext);
148  // itkQEDefineIteratorMethodsMacro( Sym );
149  // itkQEDefineIteratorMethodsMacro( Lnext );
150  // itkQEDefineIteratorMethodsMacro( Rnext );
151  // itkQEDefineIteratorMethodsMacro( Dnext );
152  // itkQEDefineIteratorMethodsMacro( Oprev );
153  // itkQEDefineIteratorMethodsMacro( Lprev );
154  // itkQEDefineIteratorMethodsMacro( Rprev );
155  // itkQEDefineIteratorMethodsMacro( Dprev );
156  // itkQEDefineIteratorMethodsMacro( InvOnext );
157  // itkQEDefineIteratorMethodsMacro( InvLnext );
158  // itkQEDefineIteratorMethodsMacro( InvRnext );
159  // itkQEDefineIteratorMethodsMacro( InvDnext );
161 
163  QuadEdge();
164  QuadEdge(const QuadEdge &) = default;
165  QuadEdge(QuadEdge &&) = default;
166  QuadEdge &
167  operator=(const QuadEdge &) = default;
168  QuadEdge &
169  operator=(QuadEdge &&) = default;
170  virtual ~QuadEdge();
172 
174  inline void
175  SetOnext(Self * onext)
176  {
177  this->m_Onext = onext;
178  }
179  inline void
180  SetRot(Self * rot)
181  {
182  this->m_Rot = rot;
183  }
185 
189  inline Self *
191  {
192  return this->m_Onext;
193  }
194  inline Self *
196  {
197  return this->m_Rot;
198  }
199  inline const Self *
200  GetOnext() const
201  {
202  return this->m_Onext;
203  }
204  inline const Self *
205  GetRot() const
206  {
207  return this->m_Rot;
208  }
210 
227  // TODO fix this ref
228  // * \sa \ref DoxySurgeryConnectivity
229  inline void
231  {
232  Self * aNext = this->GetOnext();
233  Self * bNext = b->GetOnext();
234  Self * alpha = aNext->GetRot();
235  Self * beta = bNext->GetRot();
236  Self * alphaNext = alpha->GetOnext();
237  Self * betaNext = beta->GetOnext();
239 
240  this->SetOnext(bNext);
241  b->SetOnext(aNext);
242  alpha->SetOnext(betaNext);
243  beta->SetOnext(alphaNext);
244  }
245 
246  // Second order accessors.
247 
250  inline Self *
252  {
253  if (this->m_Rot)
254  {
255  return (this->m_Rot->m_Rot);
256  }
257  return (this->m_Rot);
258  }
260 
261  inline const Self *
262  GetSym() const
263  {
264  if (this->m_Rot)
265  {
266  return (this->m_Rot->m_Rot);
267  }
268  return (this->m_Rot);
269  }
270 
273  Self *
274  GetLnext();
275 
276  const Self *
277  GetLnext() const;
278 
282  Self *
283  GetRnext();
284 
285  const Self *
286  GetRnext() const;
287 
291  Self *
292  GetDnext();
293 
294  const Self *
295  GetDnext() const;
296 
299  Self *
300  GetOprev();
301 
302  const Self *
303  GetOprev() const;
304 
308  Self *
309  GetLprev();
310 
311  const Self *
312  GetLprev() const;
313 
317  Self *
318  GetRprev();
319 
320  const Self *
321  GetRprev() const;
322 
326  Self *
327  GetDprev();
328 
329  const Self *
330  GetDprev() const;
331 
333  inline Self *
335  {
336 #ifdef NDEBUG
337  return (this->GetRot()->GetRot()->GetRot());
338 #else
339  Self * p1 = this->GetRot();
340  if (!p1)
341  {
342  return nullptr;
343  }
344  Self * p2 = p1->GetRot();
345  if (!p2)
346  {
347  return nullptr;
348  }
349  Self * p3 = p2->GetRot();
350  if (!p3)
351  {
352  return nullptr;
353  }
354  return p3;
355 #endif
356  }
358 
359  inline Self *
361  {
362  return this->GetOprev();
363  }
364  inline Self *
366  {
367  return this->GetLprev();
368  }
369  inline Self *
371  {
372  return this->GetRprev();
373  }
374  inline Self *
376  {
377  return this->GetDprev();
378  }
379  inline const Self *
380  GetInvRot() const
381  {
382 #ifdef NDEBUG
383  return (this->GetRot()->GetRot()->GetRot());
384 #else
385  const Self * p1 = this->GetRot();
386  if (!p1)
387  {
388  return nullptr;
389  }
390  const Self * p2 = p1->GetRot();
391  if (!p2)
392  {
393  return nullptr;
394  }
395  const Self * p3 = p2->GetRot();
396  if (!p3)
397  {
398  return nullptr;
399  }
400  return p3;
401 #endif
402  }
403 
404  inline const Self *
405  GetInvOnext() const
406  {
407  return this->GetOprev();
408  }
409  inline const Self *
410  GetInvLnext() const
411  {
412  return this->GetLprev();
413  }
414  inline const Self *
415  GetInvRnext() const
416  {
417  return this->GetRprev();
418  }
419  inline const Self *
420  GetInvDnext() const
421  {
422  return this->GetDprev();
423  }
424 
426  inline bool
427  IsHalfEdge() const
428  {
429  return ((m_Onext == this) || (m_Rot == nullptr));
430  }
431  inline bool
432  IsIsolated() const
433  {
434  return (this == this->GetOnext());
435  }
436  bool
437  IsEdgeInOnextRing(Self * testEdge) const;
439 
440  bool
441  IsLnextGivenSizeCyclic(const int size) const;
442 
443  unsigned int
444  GetOrder() const;
445 
446 private:
450 };
451 } // namespace itk
452 
453 #endif
itk::QuadEdge::GetInvRnext
const Self * GetInvRnext() const
Definition: itkQuadEdge.h:415
itk::QuadEdge::GetOnext
Self * GetOnext()
Definition: itkQuadEdge.h:190
itk::QuadEdge::GetInvOnext
const Self * GetInvOnext() const
Definition: itkQuadEdge.h:405
itk::QuadEdgeMeshConstIterator
Const iterator for QuadEdgeMesh.
Definition: itkQuadEdgeMeshBaseIterator.h:319
itk::QuadEdge::GetInvLnext
Self * GetInvLnext()
Definition: itkQuadEdge.h:365
itkQEDefineIteratorMethodsMacro
#define itkQEDefineIteratorMethodsMacro(Op)
Definition: itkQuadEdgeMeshBaseIterator.h:24
itk::QuadEdge::GetInvDnext
const Self * GetInvDnext() const
Definition: itkQuadEdge.h:420
itk::QuadEdge::IsIsolated
bool IsIsolated() const
Definition: itkQuadEdge.h:432
itk::QuadEdge::GetInvLnext
const Self * GetInvLnext() const
Definition: itkQuadEdge.h:410
itk::QuadEdge::Splice
void Splice(Self *b)
Basic quad-edge topological method.
Definition: itkQuadEdge.h:230
itk::QuadEdge::GetOnext
const Self * GetOnext() const
Definition: itkQuadEdge.h:200
itkMacro.h
itk::QuadEdge::GetInvRnext
Self * GetInvRnext()
Definition: itkQuadEdge.h:370
itk::QuadEdge::SetOnext
void SetOnext(Self *onext)
Definition: itkQuadEdge.h:175
itk::QuadEdge::GetSym
Self * GetSym()
Definition: itkQuadEdge.h:251
itk::QuadEdge::SetRot
void SetRot(Self *rot)
Definition: itkQuadEdge.h:180
itk::QuadEdge
Base class for the implementation of a quad-edge data structure as proposed in "Guibas and Stolfi 198...
Definition: itkQuadEdge.h:136
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:205
itk::QuadEdge::GetSym
const Self * GetSym() const
Definition: itkQuadEdge.h:262
itk::QuadEdge::GetInvOnext
Self * GetInvOnext()
Definition: itkQuadEdge.h:360
itk::QuadEdgeMeshIterator
Non const iterator for QuadMesh.
Definition: itkQuadEdgeMeshBaseIterator.h:251
itk::QuadEdge::GetInvRot
const Self * GetInvRot() const
Definition: itkQuadEdge.h:380
itk::QuadEdge::IsHalfEdge
bool IsHalfEdge() const
Definition: itkQuadEdge.h:427
itk::QuadEdge::GetInvDnext
Self * GetInvDnext()
Definition: itkQuadEdge.h:375
itk::QuadEdge::GetRot
Self * GetRot()
Definition: itkQuadEdge.h:195
itk::QuadEdge::GetInvRot
Self * GetInvRot()
Definition: itkQuadEdge.h:334
itkQuadEdgeMeshBaseIterator.h