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-02-10 05:07:49 $
00007   Version:   $Revision: 1.5 $
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; }
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 protected:
00184   QEType* FindDefaultSeed( );
00185 
00189   virtual CoordRepType GetCost( QEType* edge ){ (void)edge; return( 1 ); }
00190 
00191 protected:
00193   MeshType* m_Mesh;
00195   QEType* m_Seed;
00197   bool m_Start;
00199   FrontTypePointer m_Front;
00201   IsVisitedPointerType m_IsPointVisited;
00203   QEType* m_CurrentEdge;
00204 };
00205 
00211 template< typename TMesh, typename TQE >
00212 class QuadEdgeMeshFrontIterator
00213   : public QuadEdgeMeshFrontBaseIterator< TMesh, TQE  >
00214 {
00215 public:
00216 
00218   typedef QuadEdgeMeshFrontIterator                   Self;
00219   typedef QuadEdgeMeshFrontBaseIterator< TMesh, TQE > Superclass;
00220   typedef typename Superclass::MeshType               MeshType;
00221   typedef typename Superclass::QEType                 QEType;
00222 
00223 public:
00225   QuadEdgeMeshFrontIterator( MeshType* mesh = (MeshType*)0,
00226                              bool      start = true,
00227                              QEType*   seed  = (QEType*)0 )
00228     : Superclass( mesh, start, seed ) { }
00229   virtual ~QuadEdgeMeshFrontIterator( ) { }
00230   QEType* Value( ) { return( this->m_CurrentEdge ); }
00231 };
00233 
00239 template< class TMesh, class TQE = typename TMesh::QEType >
00240 class QuadEdgeMeshConstFrontIterator
00241   : public QuadEdgeMeshFrontBaseIterator< TMesh, TQE >
00242 {
00243 public:
00244 
00246   typedef QuadEdgeMeshConstFrontIterator                Self;
00247   typedef QuadEdgeMeshFrontBaseIterator< TMesh, TQE >   Superclass;
00248   typedef typename Superclass::QEType                   QEType;
00249   typedef typename Superclass::MeshType                 MeshType;
00250   typedef QuadEdgeMeshFrontIterator< MeshType, QEType > NoConstType;
00251 
00252 public:
00254   QuadEdgeMeshConstFrontIterator( const MeshType* mesh = (MeshType*)0,
00255                                   bool     start = true,
00256                                   QEType*  seed  = (QEType*)0 )
00257     {
00258     (void)mesh;
00259     (void)start;
00260     (void)seed;
00261     }
00262 
00264   virtual ~QuadEdgeMeshConstFrontIterator( ) { }
00265   Self& operator=( const NoConstType& r )
00266     {
00267     this->m_Mesh  = r.GetMesh( );
00268     return( *this );
00269     }
00270   const QEType* Value( ) const { return( this->m_CurrentEdge ); }
00271 };
00273 
00274 } 
00275 
00276 #include "itkQuadEdgeMeshFrontIterator.txx"
00277 
00278 #endif 
00279 

Generated at Sat Feb 28 13:20:19 2009 for ITK by doxygen 1.5.6 written by Dimitri van Heesch, © 1997-2000