00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkQuadEdgeMeshBaseIterator_h
00018 #define __itkQuadEdgeMeshBaseIterator_h
00019
00020
00021 #define itkQEDefineIteratorMethodsMacro( Op ) \
00022 virtual Iterator Begin##Op() \
00023 { \
00024 return Iterator( this, Self::Iterator::Operator##Op, true ); \
00025 } \
00026 \
00027 virtual ConstIterator Begin##Op() const \
00028 { \
00029 return ConstIterator( this, Self::ConstIterator::Operator##Op, \
00030 true ); \
00031 } \
00032 \
00033 virtual Iterator End##Op() \
00034 { \
00035 return Iterator( this, Self::Iterator::Operator##Op, false ); \
00036 } \
00037 \
00038 virtual ConstIterator End##Op() const \
00039 { \
00040 return ConstIterator( this, Self::ConstIterator::Operator##Op, \
00041 false ); \
00042 }
00043
00044
00045 #define itkQEDefineIteratorGeomMethodsMacro( Op ) \
00046 virtual IteratorGeom BeginGeom##Op() \
00047 { \
00048 return IteratorGeom( this, Self::IteratorGeom::Operator##Op, \
00049 true ); \
00050 } \
00051 \
00052 virtual ConstIteratorGeom BeginGeom##Op() const \
00053 { \
00054 return ConstIteratorGeom( this, \
00055 Self::ConstIteratorGeom::Operator##Op, true ); \
00056 } \
00057 \
00058 virtual IteratorGeom EndGeom##Op() \
00059 { \
00060 return IteratorGeom( this, Self::IteratorGeom::Operator##Op, \
00061 false ); \
00062 } \
00063 \
00064 virtual ConstIteratorGeom EndGeom##Op() const \
00065 { \
00066 return ConstIteratorGeom( this, \
00067 Self::ConstIteratorGeom::Operator##Op, false ); \
00068 }
00069
00070
00071 namespace itk
00072 {
00078 template< typename TQuadEdge >
00079 class QuadEdgeMeshBaseIterator
00080 {
00081 public:
00082
00083 typedef QuadEdgeMeshBaseIterator Self;
00084 typedef TQuadEdge QuadEdgeType;
00085
00086
00087 enum
00088 {
00089 OperatorOnext = 0,
00090 OperatorSym = 1,
00091 OperatorLnext = 2,
00092 OperatorRnext = 3,
00093 OperatorDnext = 4,
00094 OperatorOprev = 5,
00095 OperatorLprev = 6,
00096 OperatorRprev = 7,
00097 OperatorDprev = 8,
00098 OperatorInvOnext = 9,
00099 OperatorInvLnext = 10,
00100 OperatorInvRnext = 11,
00101 OperatorInvDnext = 12
00102 };
00103
00104 public:
00105
00106 QuadEdgeMeshBaseIterator( QuadEdgeType* e,
00107 int op = OperatorOnext,
00108 bool start = true )
00109 : m_StartEdge( e ), m_Iterator( e ),
00110 m_OpType( op ), m_Start( start ) {}
00111
00112 virtual ~QuadEdgeMeshBaseIterator() {}
00113
00114 Self& operator=( const Self& r )
00115 {
00116 m_StartEdge = r.m_StartEdge;
00117 m_Iterator = r.m_Iterator;
00118 m_OpType = r.m_OpType;
00119 m_Start = r.m_Start;
00120 return( *this );
00121 }
00122
00123 QuadEdgeType* GetStartEdge() const { return( m_StartEdge ); }
00124 QuadEdgeType* GetIterator() const { return( m_Iterator ); }
00125 int GetOpType() const { return( m_OpType ); }
00126 bool GetStart() const { return( m_Start ); }
00127
00129 bool operator==( Self & r )
00130 {
00131 return( ( m_StartEdge == r.m_StartEdge ) &&
00132 ( m_Iterator == r.m_Iterator ) &&
00133 ( m_OpType == r.m_OpType ) &&
00134 ( m_Start == r.m_Start ) );
00135 }
00136
00137 bool operator==( const Self & r ) const
00138 {
00139 return( ( m_StartEdge == r.m_StartEdge ) &&
00140 ( m_Iterator == r.m_Iterator ) &&
00141 ( m_OpType == r.m_OpType ) &&
00142 ( m_Start == r.m_Start ) );
00143 }
00144
00145 bool operator!=( Self & r )
00146 {
00147 return( !( this->operator==( r ) ) );
00148 }
00149
00150 bool operator!=( const Self & r ) const
00151 {
00152 return( !( this->operator==( r ) ) );
00153 }
00154
00155 Self & operator++()
00156 {
00157 if( m_Start )
00158 {
00159 this->GoToNext();
00160 m_Start = !( m_Iterator == m_StartEdge );
00161 }
00162
00163 return( *this );
00164 }
00165
00166 Self & operator++( int )
00167 {
00168 if( m_Start )
00169 {
00170 this->GoToNext();
00171 m_Start = !( m_Iterator == m_StartEdge );
00172 }
00173 return( *this );
00174 }
00175
00176 protected:
00178 virtual void GoToNext()
00179 {
00180 switch( m_OpType )
00181 {
00182 case OperatorOnext : m_Iterator = m_Iterator->GetOnext();
00183 break;
00184 case OperatorSym : m_Iterator = m_Iterator->GetSym();
00185 break;
00186 case OperatorLnext : m_Iterator = m_Iterator->GetLnext();
00187 break;
00188 case OperatorRnext : m_Iterator = m_Iterator->GetRnext();
00189 break;
00190 case OperatorDnext : m_Iterator = m_Iterator->GetDnext();
00191 break;
00192 case OperatorOprev : m_Iterator = m_Iterator->GetOprev();
00193 break;
00194 case OperatorLprev : m_Iterator = m_Iterator->GetLprev();
00195 break;
00196 case OperatorRprev : m_Iterator = m_Iterator->GetRprev();
00197 break;
00198 case OperatorDprev : m_Iterator = m_Iterator->GetDprev();
00199 break;
00200 case OperatorInvOnext : m_Iterator = m_Iterator->GetInvOnext();
00201 break;
00202 case OperatorInvLnext : m_Iterator = m_Iterator->GetInvLnext();
00203 break;
00204 case OperatorInvRnext : m_Iterator = m_Iterator->GetInvRnext();
00205 break;
00206 case OperatorInvDnext : m_Iterator = m_Iterator->GetInvDnext();
00207 break;
00208 default: break;
00209 }
00210 }
00212
00213 protected:
00221 };
00222
00228 template< typename TQuadEdge >
00229 class QuadEdgeMeshIterator
00230 : public QuadEdgeMeshBaseIterator< TQuadEdge >
00231 {
00232 public:
00233
00235 typedef QuadEdgeMeshIterator Self;
00236 typedef QuadEdgeMeshBaseIterator< TQuadEdge > Superclass;
00237 typedef TQuadEdge QuadEdgeType;
00238
00239 public:
00241 QuadEdgeMeshIterator( QuadEdgeType* e = (QuadEdgeType*)0,
00242 int op = Superclass::OperatorOnext,
00243 bool start = true )
00244 : Superclass( e, op, start ) {}
00245
00246 virtual ~QuadEdgeMeshIterator() {}
00247
00248 QuadEdgeType * Value() { return( this->m_Iterator ); }
00249 const QuadEdgeType * Value() const { return( this->m_Iterator ); }
00250 };
00251
00257 template< typename TGeometricalQuadEdge >
00258 class QuadEdgeMeshIteratorGeom
00259 : public QuadEdgeMeshIterator< TGeometricalQuadEdge >
00260 {
00261 public:
00262
00264 typedef QuadEdgeMeshIterator< TGeometricalQuadEdge > Superclass;
00265 typedef TGeometricalQuadEdge QuadEdgeType;
00266
00268 typedef typename QuadEdgeType::OriginRefType OriginRefType;
00269
00270 public:
00271 QuadEdgeMeshIteratorGeom( QuadEdgeType* e = (QuadEdgeType*)0,
00272 int op = Superclass::OperatorOnext,
00273 bool start = true )
00274 : Superclass( e, op, start ) {}
00275 OriginRefType operator*() { return( this->m_Iterator->GetOrigin( ) ); }
00276 };
00277
00283 template< typename TQuadEdge >
00284 class QuadEdgeMeshConstIterator
00285 : public QuadEdgeMeshBaseIterator< TQuadEdge >
00286 {
00287 public:
00288
00290 typedef QuadEdgeMeshConstIterator Self;
00291 typedef QuadEdgeMeshBaseIterator< TQuadEdge > Superclass;
00292 typedef QuadEdgeMeshIterator< TQuadEdge > NoConstType;
00293 typedef TQuadEdge QuadEdgeType;
00294
00295 public:
00297 QuadEdgeMeshConstIterator( const QuadEdgeType* e = (QuadEdgeType*)0,
00298 int op = Superclass::OperatorOnext,
00299 bool start = true )
00300 : Superclass( const_cast<QuadEdgeType*>(e), op, start ) {}
00301
00302 virtual ~QuadEdgeMeshConstIterator() {}
00303
00304 Self& operator=( const NoConstType& r )
00305 {
00306 this->m_StartEdge = r.GetStartEdge();
00307 this->m_Iterator = r.GetIterator();
00308 this->m_OpType = r.GetOpType();
00309 this->m_Start = r.GetStart();
00310 return( *this );
00311 }
00312
00313 const QuadEdgeType* Value() const { return( this->m_Iterator ); }
00314 };
00315
00321 template< typename TGeometricalQuadEdge >
00322 class QuadEdgeMeshConstIteratorGeom
00323 : public QuadEdgeMeshConstIterator< TGeometricalQuadEdge >
00324 {
00325 public:
00326
00328 typedef QuadEdgeMeshConstIteratorGeom Self;
00329 typedef QuadEdgeMeshConstIterator< TGeometricalQuadEdge > Superclass;
00330 typedef QuadEdgeMeshIteratorGeom< TGeometricalQuadEdge > NoConstType;
00331 typedef TGeometricalQuadEdge QuadEdgeType;
00332
00334 typedef typename QuadEdgeType::OriginRefType OriginRefType;
00335
00336 public:
00337 QuadEdgeMeshConstIteratorGeom( const QuadEdgeType* e = (QuadEdgeType*)0,
00338 int op = Superclass::OperatorOnext,
00339 bool start = true )
00340 : Superclass( e, op, start ) {}
00341
00342 virtual ~QuadEdgeMeshConstIteratorGeom() {}
00343
00344 Self& operator=( const NoConstType& r )
00345 {
00346 this->m_StartEdge = r.GetStartEdge();
00347 this->m_Iterator = r.GetIterator();
00348 this->m_OpType = r.GetOpType();
00349 this->m_Start = r.GetStart();
00350 return( *this );
00351 }
00352
00353 const OriginRefType operator*() const
00354 {
00355 return( this->m_Iterator->GetOrigin() );
00356 }
00357 };
00358
00359 }
00360
00361 #endif
00362