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-07-01 15:45:43 $
00007   Version:   $Revision: 1.16 $
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() { if(this->m_Rot) return( this->m_Rot->m_Rot );
00309                           else return( this->m_Rot ); };
00310   inline const Self* GetSym() const { if( this->m_Rot) return( this->m_Rot->m_Rot );
00311                           else return( this->m_Rot ); };
00313 
00316   Self* GetLnext(); 
00317   const Self* GetLnext() const;
00319 
00323   Self* GetRnext();
00324   const Self* GetRnext() const;
00326 
00330   Self* GetDnext();
00331   const Self* GetDnext() const;
00333 
00336   Self* GetOprev();
00337   const Self* GetOprev() const;
00339 
00343   Self* GetLprev();
00344   const Self* GetLprev() const;
00346 
00350   Self* GetRprev();
00351   const Self* GetRprev() const;
00353 
00357   Self* GetDprev();
00358   const Self* GetDprev() const;
00360 
00362   inline Self * GetInvRot() 
00363     { Self * p1 = this->GetRot();
00364     if( !p1 ) return NULL;
00365     Self * p2 = p1->GetRot();
00366     if( !p2 ) return NULL;
00367     Self * p3 = p2->GetRot();
00368     if( !p3 ) return NULL;
00369     return p3; };
00370   inline Self * GetInvOnext() { return this->GetOprev(); };
00371   inline Self * GetInvLnext() { return this->GetLprev(); };
00372   inline Self * GetInvRnext() { return this->GetRprev(); };
00373   inline Self * GetInvDnext() { return this->GetDprev(); };
00374   inline const Self * GetInvRot() const 
00375     { const Self * p1 = this->GetRot();
00376     if( !p1 ) return NULL;
00377     const Self * p2 = p1->GetRot();
00378     if( !p2 ) return NULL;
00379     const Self * p3 = p2->GetRot();
00380     if( !p3 ) return NULL;
00381     return p3; };
00382   inline const Self * GetInvOnext() const { return this->GetOprev(); };
00383   inline const Self * GetInvLnext() const { return this->GetLprev(); };
00384   inline const Self * GetInvRnext() const { return this->GetRprev(); };
00385   inline const Self * GetInvDnext() const { return this->GetDprev(); };
00387 
00389   inline bool IsHalfEdge() const { return( ( m_Onext == this ) || ( m_Rot == NULL ) ); };
00390   inline bool IsIsolated() const { return( this == this->GetOnext() ); };
00391   bool IsEdgeInOnextRing( Self* testEdge ) const;
00392   bool IsLnextGivenSizeCyclic( const int size ) const;
00393   unsigned int GetOrder() const;
00395 
00396 private: 
00397   Self* m_Onext; 
00398   Self* m_Rot;   
00399 };
00400 
00401 } 
00402 
00403 #endif 
00404 

Generated at Tue Jul 29 21:48:40 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000