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

itkQuadEdgeMeshFrontIterator.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkQuadEdgeMeshFrontIterator.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-08-05 20:26:37 $
00007   Version:   $Revision: 1.8 $
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 #ifndef __itkQuadEdgeMeshFrontIterator_h
00018 #define __itkQuadEdgeMeshFrontIterator_h
00019 
00020 // -------------------------------------------------------------------------
00021 #define itkQEDefineFrontIteratorMethodsMacro( MeshTypeArg )                  \
00022     /* Dual definition placed before others because of .NET that cannot */   \
00023     /* cope with definition of FrontIterator (that further hides the    */   \
00024     /* defintion of the template).                                      */   \
00025     typedef typename MeshTypeArg::QEDual QEDualType;                         \
00026     typedef typename MeshTypeArg::QEPrimal QEPrimalType;                     \
00027     typedef QuadEdgeMeshFrontIterator< MeshTypeArg,                          \
00028                                              QEDualType > FrontDualIterator; \
00029     typedef QuadEdgeMeshConstFrontIterator< MeshTypeArg,                     \
00030                                                   QEDualType >               \
00031                                                      ConstFrontDualIterator; \
00032     typedef QuadEdgeMeshFrontIterator< MeshTypeArg,                          \
00033                                              QEPrimalType >   FrontIterator; \
00034     typedef QuadEdgeMeshConstFrontIterator< MeshTypeArg,                     \
00035                                                   QEPrimalType >             \
00036                                                          ConstFrontIterator; \
00037                                                                              \
00038     virtual FrontIterator BeginFront( QEPrimalType* seed =(QEPrimalType*)0 ) \
00039     { return( FrontIterator( this, true, seed ) ); }                         \
00040                                                                              \
00041     virtual ConstFrontIterator BeginFront( QEPrimalType* seed ) const        \
00042     { return( ConstFrontIterator( this, true, seed ) ); }                    \
00043                                                                              \
00044     virtual FrontIterator EndFront( )                                        \
00045     { return( FrontIterator( this, false ) ); }                              \
00046                                                                              \
00047     virtual ConstFrontIterator EndFront( ) const                             \
00048     { return( ConstFrontIterator( this, false ) ); }                         \
00049                                                                              \
00050     virtual FrontDualIterator BeginDualFront( QEDualType* seed =(QEDualType*) 0 )    \
00051     { return( FrontDualIterator( this, true, seed ) ); }                     \
00052                                                                              \
00053     virtual ConstFrontDualIterator BeginDualFront( QEDualType* seed ) const      \
00054     { return( ConstFrontDualIterator( this, true, seed ) ); }                \
00055                                                                              \
00056     virtual FrontDualIterator EndDualFront( )                                \
00057     { return( FrontDualIterator( this, false ) ); }                          \
00058                                                                              \
00059     virtual ConstFrontDualIterator EndDualFront( ) const                     \
00060     { return( ConstFrontDualIterator( this, false ) ); }
00061 
00062 namespace itk
00063 {
00064 
00077 template< typename TMesh, typename TQE >
00078 class QuadEdgeMeshFrontBaseIterator
00079 {
00080 public:
00081   // Hierarchy typedefs & values.
00082   typedef QuadEdgeMeshFrontBaseIterator Self;
00083 
00084   // Template types
00085   typedef TMesh  MeshType;
00086   typedef TQE    QEType;
00087 
00088 protected:
00089   // Mesh types
00090   typedef typename MeshType::CoordRepType    CoordRepType;
00091   // QE types
00092   typedef typename QEType::OriginRefType     QEOriginType;
00093 
00102   class FrontAtom
00103     {
00104     public:
00105     FrontAtom( QEType* e = (QEType*)0, const CoordRepType c = 0 )
00106       : m_Edge( e ), m_Cost( c )
00107       { }
00108       virtual ~FrontAtom( ) { }
00109       FrontAtom& operator=( const FrontAtom& r )
00110       { m_Edge = r.m_Edge; m_Cost = r.m_Cost; return *this; }
00111       bool operator==( const FrontAtom& r ) const
00112       { return( m_Edge == r.m_Edge ); }
00113       bool operator!=( const FrontAtom& r ) const
00114       { return( m_Edge != r.m_Edge ); }
00115       bool operator<( const FrontAtom& r ) const
00116       { return( m_Cost < r.m_Cost ); }
00118 
00119     public:
00120       QEType*      m_Edge;
00121       CoordRepType m_Cost;
00122   };
00123 
00127   typedef std::list< FrontAtom >       FrontType;
00128   typedef typename FrontType::iterator FrontTypeIterator;
00129   typedef FrontType*                   FrontTypePointer;
00130 
00134   typedef MapContainer< QEOriginType, bool >       IsVisitedContainerType;
00135   typedef typename IsVisitedContainerType::Pointer IsVisitedPointerType;
00136 
00137 public:
00139   QuadEdgeMeshFrontBaseIterator( MeshType* mesh  = (MeshType*)0,
00140                                  bool      start = true,
00141                                  QEType*   seed  = (QEType*)0 );
00142   virtual ~QuadEdgeMeshFrontBaseIterator( ) { }
00143 
00144   Self& operator=( const Self& r )
00145     {
00146     m_Mesh  = r.m_Mesh;
00147     m_Start = r.m_Start;
00148     m_Seed  = r.m_Seed;
00149     m_Front = r.m_Front;
00150     m_IsPointVisited = r.m_IsPointVisited;
00151     m_CurrentEdge = r.m_CurrentEdge;
00152     return( *this );
00153     }
00154 
00155   // Iteration methods.
00156   bool operator==( Self & r )
00157     {
00158     return( m_Start == r.m_Start );
00159     }
00160 
00161   bool operator==( const Self & r ) const
00162     {
00163     return( m_Start == r.m_Start );
00164     }
00165 
00166   bool operator!=( Self & r )
00167     {
00168     return( !( this->operator==( r ) ) );
00169     }
00170 
00171   bool operator!=( const Self & r ) const
00172     {
00173     return( !( this->operator==( r ) ) );
00174     }
00175 
00176   Self & operator++( );
00177 
00178   Self & operator++( int ) { return( this->operator++( ) ); }
00179   
00180   MeshType* GetMesh() const { return this->m_Mesh; }
00181 
00182 protected:
00186   QEType* FindDefaultSeed( );
00187 
00191   virtual CoordRepType GetCost( QEType* edge ){ (void)edge; return( 1 ); }
00192 
00193 protected:
00195   MeshType* m_Mesh;
00197   QEType* m_Seed;
00199   bool m_Start;
00201   FrontTypePointer m_Front;
00203   IsVisitedPointerType m_IsPointVisited;
00205   QEType* m_CurrentEdge;
00206 };
00207 
00213 template< typename TMesh, typename TQE >
00214 class QuadEdgeMeshFrontIterator
00215   : public QuadEdgeMeshFrontBaseIterator< TMesh, TQE  >
00216 {
00217 public:
00218 
00220   typedef QuadEdgeMeshFrontIterator                   Self;
00221   typedef QuadEdgeMeshFrontBaseIterator< TMesh, TQE > Superclass;
00222   typedef typename Superclass::MeshType               MeshType;
00223   typedef typename Superclass::QEType                 QEType;
00224 
00225 public:
00227   QuadEdgeMeshFrontIterator( MeshType* mesh = (MeshType*)0,
00228                              bool      start = true,
00229                              QEType*   seed  = (QEType*)0 )
00230     : Superclass( mesh, start, seed ) { }
00231   virtual ~QuadEdgeMeshFrontIterator( ) { }
00232   QEType* Value( ) { return( this->m_CurrentEdge ); }
00233 };
00235 
00241 template< class TMesh, class TQE = typename TMesh::QEType >
00242 class QuadEdgeMeshConstFrontIterator
00243   : public QuadEdgeMeshFrontBaseIterator< TMesh, TQE >
00244 {
00245 public:
00246 
00248   typedef QuadEdgeMeshConstFrontIterator                Self;
00249   typedef QuadEdgeMeshFrontBaseIterator< TMesh, TQE >   Superclass;
00250   typedef typename Superclass::QEType                   QEType;
00251   typedef typename Superclass::MeshType                 MeshType;
00252   typedef QuadEdgeMeshFrontIterator< MeshType, QEType > NoConstType;
00253 
00254 public:
00256   QuadEdgeMeshConstFrontIterator( const MeshType* mesh = (MeshType*)0,
00257                                   bool     start = true,
00258                                   QEType*  seed  = (QEType*)0 )
00259     {
00260     (void)mesh;
00261     (void)start;
00262     (void)seed;
00263     }
00264 
00266   virtual ~QuadEdgeMeshConstFrontIterator( ) { }
00267   Self& operator=( const NoConstType& r )
00268     {
00269     this->m_Mesh  = r.GetMesh( );
00270     return( *this );
00271     }
00272   const QEType* Value( ) const { return( this->m_CurrentEdge ); }
00273 };
00275 
00276 } 
00277 
00278 #include "itkQuadEdgeMeshFrontIterator.txx"
00279 
00280 #endif 
00281 

Generated at Tue Sep 15 04:27:41 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000