itkQuadEdgeMeshFrontIterator.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkQuadEdgeMeshFrontIterator_h
00018 #define __itkQuadEdgeMeshFrontIterator_h
00019
00020
00021 #define itkQEDefineFrontIteratorMethodsMacro( MeshTypeArg ) \
00022 \
00023 \
00024 \
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
00082 typedef QuadEdgeMeshFrontBaseIterator Self;
00083
00084
00085 typedef TMesh MeshType;
00086 typedef TQE QEType;
00087
00088 protected:
00089
00090 typedef typename MeshType::CoordRepType CoordRepType;
00091
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
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