Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkQuadEdge.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkQuadEdge.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-09-30 21:27:47 $
00007   Version:   $Revision: 1.17 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 
00018 #ifndef __itkQuadEdge_h
00019 #define __itkQuadEdge_h
00020 
00021 #include "itkQuadEdgeMeshBaseIterator.h"
00022 
00023 #include "itkMacro.h"
00024 
00025 #include <assert.h>
00026 
00027 // Debugging macros for classes that do not derive from the itkObject.
00028 // FIXME: Maybe variations of these macros should be moved into
00029 // itkMacro.h
00030 //
00031 #define itkQEDebugMacro( x )                                        \
00032 {                                                                   \
00033     OStringStream itkmsg;                                           \
00034     itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n"   \
00035            << " (" << this << "): " x                               \
00036            << "\n\n";                                               \
00037     OutputWindowDisplayDebugText( itkmsg.str( ).c_str( ) );         \
00038 }
00039 #define itkQEWarningMacro( x )                                      \
00040 {                                                                   \
00041     OStringStream itkmsg;                                           \
00042     itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" \
00043            << " (" << this << "): " x                               \
00044            << "\n\n";                                               \
00045     OutputWindowDisplayWarningText( itkmsg.str( ).c_str( ) );       \
00046 }
00047 
00048 
00049 // -------------------------------------------------------------------------
00058 #define itkQEAccessorsMacro( st, pt, dt )                               \
00059    pt* GetOnext()                                                       \
00060     {                                                                   \
00061     return( dynamic_cast<  pt* >( this->st::GetOnext() ) );             \
00062     }                                                                   \
00063                                                                         \
00064    dt* GetRot()                                                         \
00065     {                                                                   \
00066     return( dynamic_cast<  dt* >( this->st::GetRot() ) );               \
00067     }                                                                   \
00068                                                                         \
00069    pt* GetSym()                                                         \
00070     {                                                                   \
00071     return( dynamic_cast<  pt* >( this->st::GetSym() ) );               \
00072     }                                                                   \
00073                                                                         \
00074    pt* GetLnext()                                                       \
00075     {                                                                   \
00076     return( dynamic_cast<  pt* >( this->st::GetLnext() ) );             \
00077     }                                                                   \
00078                                                                         \
00079    pt* GetRnext()                                                       \
00080     {                                                                   \
00081     return( dynamic_cast<  pt* >( this->st::GetRnext() ) );             \
00082     }                                                                   \
00083                                                                         \
00084    pt* GetDnext()                                                       \
00085     {                                                                   \
00086     return( dynamic_cast<  pt* >( this->st::GetDnext() ) );             \
00087     }                                                                   \
00088                                                                         \
00089    pt* GetOprev()                                                       \
00090     {                                                                   \
00091     return( dynamic_cast<  pt* >( this->st::GetOprev() ) );             \
00092     }                                                                   \
00093                                                                         \
00094    pt* GetLprev()                                                       \
00095     {                                                                   \
00096     return( dynamic_cast<  pt* >( this->st::GetLprev() ) );             \
00097     }                                                                   \
00098                                                                         \
00099    pt* GetRprev()                                                       \
00100     {                                                                   \
00101     return( dynamic_cast<  pt* >( this->st::GetRprev() ) );             \
00102     }                                                                   \
00103                                                                         \
00104    pt* GetDprev()                                                       \
00105     {                                                                   \
00106     return( dynamic_cast<  pt* >( this->st::GetDprev() ) );             \
00107     }                                                                   \
00108                                                                         \
00109    dt* GetInvRot()                                                      \
00110     {                                                                   \
00111     return( dynamic_cast< dt* >( this->st::GetInvRot() ) );             \
00112     }                                                                   \
00113                                                                         \
00114    pt* GetInvOnext()                                                    \
00115     {                                                                   \
00116     return( dynamic_cast<  pt* >( this->st::GetInvOnext() ) );          \
00117     }                                                                   \
00118                                                                         \
00119    pt* GetInvLnext()                                                    \
00120     {                                                                   \
00121     return( dynamic_cast<  pt* >( this->st::GetInvLnext() ) );          \
00122     }                                                                   \
00123                                                                         \
00124    pt* GetInvRnext()                                                    \
00125     {                                                                   \
00126     return( dynamic_cast<  pt* >( this->st::GetInvRnext() ) );          \
00127     }                                                                   \
00128                                                                         \
00129    pt* GetInvDnext()                                                    \
00130     {                                                                   \
00131     return( dynamic_cast<  pt* >( this->st::GetInvDnext() ) );          \
00132     }                                                                   \
00133   const pt* GetOnext() const                                            \
00134     {                                                                   \
00135     return( dynamic_cast< const pt* >( this->st::GetOnext() ) );        \
00136     }                                                                   \
00137                                                                         \
00138   const dt* GetRot() const                                              \
00139     {                                                                   \
00140     return( dynamic_cast< const dt* >( this->st::GetRot() ) );          \
00141     }                                                                   \
00142                                                                         \
00143   const pt* GetSym() const                                              \
00144     {                                                                   \
00145     return( dynamic_cast< const pt* >( this->st::GetSym() ) );          \
00146     }                                                                   \
00147                                                                         \
00148   const pt* GetLnext() const                                            \
00149     {                                                                   \
00150     return( dynamic_cast< const pt* >( this->st::GetLnext() ) );        \
00151     }                                                                   \
00152                                                                         \
00153   const pt* GetRnext() const                                            \
00154     {                                                                   \
00155     return( dynamic_cast< const pt* >( this->st::GetRnext() ) );        \
00156     }                                                                   \
00157                                                                         \
00158   const pt* GetDnext() const                                            \
00159     {                                                                   \
00160     return( dynamic_cast< const pt* >( this->st::GetDnext() ) );        \
00161     }                                                                   \
00162                                                                         \
00163   const pt* GetOprev() const                                            \
00164     {                                                                   \
00165     return( dynamic_cast< const pt* >( this->st::GetOprev() ) );        \
00166     }                                                                   \
00167                                                                         \
00168   const pt* GetLprev() const                                            \
00169     {                                                                   \
00170     return( dynamic_cast< const pt* >( this->st::GetLprev() ) );        \
00171     }                                                                   \
00172                                                                         \
00173   const pt* GetRprev() const                                            \
00174     {                                                                   \
00175     return( dynamic_cast< const pt* >( this->st::GetRprev() ) );        \
00176     }                                                                   \
00177                                                                         \
00178   const pt* GetDprev() const                                            \
00179     {                                                                   \
00180     return( dynamic_cast< const pt* >( this->st::GetDprev() ) );        \
00181     }                                                                   \
00182                                                                         \
00183   const dt* GetInvRot() const                                           \
00184     {                                                                   \
00185     return( dynamic_cast< const dt* >( this->st::GetInvRot() ) );       \
00186     }                                                                   \
00187                                                                         \
00188   const pt* GetInvOnext() const                                         \
00189     {                                                                   \
00190     return( dynamic_cast< const pt* >( this->st::GetInvOnext() ) );     \
00191     }                                                                   \
00192                                                                         \
00193   const pt* GetInvLnext() const                                         \
00194     {                                                                   \
00195     return( dynamic_cast< const pt* >( this->st::GetInvLnext() ) );     \
00196     }                                                                   \
00197                                                                         \
00198   const pt* GetInvRnext() const                                         \
00199     {                                                                   \
00200     return( dynamic_cast< const pt* >( this->st::GetInvRnext() ) );     \
00201     }                                                                   \
00202                                                                         \
00203   const pt* GetInvDnext() const                                         \
00204     {                                                                   \
00205     return( dynamic_cast< const pt* >( this->st::GetInvDnext() ) );     \
00206     }
00207 
00208 
00209 namespace itk
00210 {
00211 
00225 class QuadEdge
00226 {
00227 public:
00229   typedef QuadEdge Self;
00230 
00232   typedef QuadEdgeMeshIterator< Self >      Iterator;
00233   typedef QuadEdgeMeshConstIterator< Self > ConstIterator;
00234 
00236   inline itkQEDefineIteratorMethodsMacro( Onext );
00237   // itkQEDefineIteratorMethodsMacro( Sym );
00238   // itkQEDefineIteratorMethodsMacro( Lnext );
00239   // itkQEDefineIteratorMethodsMacro( Rnext );
00240   // itkQEDefineIteratorMethodsMacro( Dnext );
00241   // itkQEDefineIteratorMethodsMacro( Oprev );
00242   // itkQEDefineIteratorMethodsMacro( Lprev );
00243   // itkQEDefineIteratorMethodsMacro( Rprev );
00244   // itkQEDefineIteratorMethodsMacro( Dprev );
00245   // itkQEDefineIteratorMethodsMacro( InvOnext );
00246   // itkQEDefineIteratorMethodsMacro( InvLnext );
00247   // itkQEDefineIteratorMethodsMacro( InvRnext );
00248   // itkQEDefineIteratorMethodsMacro( InvDnext );
00250 
00252   QuadEdge();
00253   virtual ~QuadEdge();
00255 
00257   inline void SetOnext( Self* onext ) { this->m_Onext = onext; }
00258   inline void SetRot( Self* rot )     { this->m_Rot = rot; }
00260 
00264   inline Self* GetOnext() {return this->m_Onext;}
00265   inline Self* GetRot()   {return this->m_Rot;}
00266   inline const Self* GetOnext() const {return this->m_Onext;}
00267   inline const Self* GetRot() const   {return this->m_Rot;}
00269 
00287   inline void Splice( Self* b )
00288     {
00289     Self * aNext     = this->GetOnext();
00290     Self * bNext     = b->GetOnext();
00291     Self * alpha     = aNext->GetRot();
00292     Self * beta      = bNext->GetRot();
00293     Self * alphaNext = alpha->GetOnext();
00294     Self * betaNext  = beta->GetOnext();
00296 
00297     this->SetOnext( bNext );
00298     b->SetOnext( aNext );
00299     alpha->SetOnext( betaNext );
00300     beta->SetOnext( alphaNext );
00301     }
00302 
00303 
00304   //  Second order accessors.
00305 
00308   inline Self* GetSym() 
00309     { 
00310     if(this->m_Rot) 
00311       {
00312       return( this->m_Rot->m_Rot );
00313       }
00314     return( this->m_Rot );
00315     }
00316   inline const Self* GetSym() const
00317     {
00318     if( this->m_Rot) 
00319       {
00320       return( this->m_Rot->m_Rot );
00321       }
00322     return( this->m_Rot );
00323     }
00325 
00328   Self* GetLnext(); 
00329   const Self* GetLnext() const;
00331 
00335   Self* GetRnext();
00336   const Self* GetRnext() const;
00338 
00342   Self* GetDnext();
00343   const Self* GetDnext() const;
00345 
00348   Self* GetOprev();
00349   const Self* GetOprev() const;
00351 
00355   Self* GetLprev();
00356   const Self* GetLprev() const;
00358 
00362   Self* GetRprev();
00363   const Self* GetRprev() const;
00365 
00369   Self* GetDprev();
00370   const Self* GetDprev() const;
00372 
00374   inline Self * GetInvRot() 
00375     { Self * p1 = this->GetRot();
00376     if( !p1 ) return NULL;
00377     Self * p2 = p1->GetRot();
00378     if( !p2 ) return NULL;
00379     Self * p3 = p2->GetRot();
00380     if( !p3 ) return NULL;
00381     return p3; }
00382   inline Self * GetInvOnext() { return this->GetOprev(); }
00383   inline Self * GetInvLnext() { return this->GetLprev(); }
00384   inline Self * GetInvRnext() { return this->GetRprev(); }
00385   inline Self * GetInvDnext() { return this->GetDprev(); }
00386   inline const Self * GetInvRot() const 
00387     { const Self * p1 = this->GetRot();
00388     if( !p1 ) return NULL;
00389     const Self * p2 = p1->GetRot();
00390     if( !p2 ) return NULL;
00391     const Self * p3 = p2->GetRot();
00392     if( !p3 ) return NULL;
00393     return p3; }
00394   inline const Self * GetInvOnext() const { return this->GetOprev(); }
00395   inline const Self * GetInvLnext() const { return this->GetLprev(); }
00396   inline const Self * GetInvRnext() const { return this->GetRprev(); }
00397   inline const Self * GetInvDnext() const { return this->GetDprev(); }
00399 
00401   inline bool IsHalfEdge() const { return( ( m_Onext == this ) || ( m_Rot == NULL ) ); }
00402   inline bool IsIsolated() const { return( this == this->GetOnext() ); }
00403   bool IsEdgeInOnextRing( Self* testEdge ) const;
00404   bool IsLnextGivenSizeCyclic( const int size ) const;
00405   unsigned int GetOrder() const;
00407 
00408 private: 
00409   Self* m_Onext; 
00410   Self* m_Rot;   
00411 };
00412 
00413 } 
00414 
00415 #endif 
00416 

Generated at Wed Nov 5 23:34:54 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000