00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkImageRegionConstIterator_h
00018 #define __itkImageRegionConstIterator_h
00019
00020 #include "itkImageConstIterator.h"
00021 #include "itkImageIterator.h"
00022
00023 #if defined(_MSC_VER) && !defined(ITK_LEAN_AND_MEAN)
00024 #define ITK_LEAN_AND_MEAN
00025 #endif
00026
00027 namespace itk
00028 {
00029
00107 template<typename TImage>
00108 class ITK_EXPORT ImageRegionConstIterator : public ImageConstIterator<TImage>
00109 {
00110 public:
00112 typedef ImageRegionConstIterator Self;
00113 typedef ImageConstIterator<TImage> Superclass;
00114
00119 itkStaticConstMacro(ImageIteratorDimension, unsigned int,
00120 Superclass::ImageIteratorDimension);
00121
00124 typedef typename Superclass::IndexType IndexType;
00125
00128 typedef typename Superclass::SizeType SizeType;
00129
00131 typedef typename Superclass::RegionType RegionType;
00132
00135 typedef typename Superclass::ImageType ImageType;
00136
00140 typedef typename Superclass::PixelContainer PixelContainer;
00141 typedef typename Superclass::PixelContainerPointer PixelContainerPointer;
00142
00144 typedef typename Superclass::InternalPixelType InternalPixelType;
00145
00147 typedef typename Superclass::PixelType PixelType;
00148
00151 typedef typename Superclass::AccessorType AccessorType;
00152
00154 itkTypeMacro(ImageRegionConstIterator, ImageIterator);
00155
00157 ImageRegionConstIterator() : ImageConstIterator<TImage>()
00158 {
00159 m_SpanBeginOffset = 0;
00160 m_SpanEndOffset = 0;
00161 }
00162
00165 ImageRegionConstIterator(const ImageType *ptr,
00166 const RegionType ®ion)
00167 : ImageConstIterator<TImage>(ptr, region)
00168 {
00169 m_SpanBeginOffset = this->m_BeginOffset;
00170 m_SpanEndOffset = this->m_BeginOffset + static_cast<long>(this->m_Region.GetSize()[0]);
00171 }
00173
00180 ImageRegionConstIterator( const ImageIterator<TImage> &it)
00181 {
00182 this->ImageConstIterator<TImage>::operator=(it);
00183 IndexType ind = this->GetIndex();
00184 m_SpanEndOffset = this->m_Offset + static_cast<long>(this->m_Region.GetSize()[0])
00185 - (ind[0] - this->m_Region.GetIndex()[0]);
00186 m_SpanBeginOffset = m_SpanEndOffset
00187 - static_cast<long>(this->m_Region.GetSize()[0]);
00188 }
00190
00197 ImageRegionConstIterator( const ImageConstIterator<TImage> &it)
00198 {
00199 this->ImageConstIterator<TImage>::operator=(it);
00200 IndexType ind = this->GetIndex();
00201 m_SpanEndOffset = this->m_Offset + static_cast<long>(this->m_Region.GetSize()[0])
00202 - (ind[0] - this->m_Region.GetIndex()[0]);
00203 m_SpanBeginOffset = m_SpanEndOffset
00204 - static_cast<long>(this->m_Region.GetSize()[0]);
00205 }
00207
00210 void GoToBegin()
00211 {
00212 Superclass::GoToBegin();
00213
00214
00215 m_SpanBeginOffset = this->m_BeginOffset;
00216 m_SpanEndOffset = this->m_BeginOffset + static_cast<long>(this->m_Region.GetSize()[0]);
00217 }
00218
00221 void GoToEnd()
00222 {
00223 Superclass::GoToEnd();
00224
00225
00226 m_SpanEndOffset = this->m_EndOffset;
00227 m_SpanBeginOffset = m_SpanEndOffset - static_cast<long>(this->m_Region.GetSize()[0]);
00228 }
00229
00233 Self Begin(void) const;
00234
00238 Self End(void) const;
00239
00240
00244 void SetIndex(const IndexType &ind)
00245 {
00246 Superclass::SetIndex(ind);
00247 m_SpanEndOffset = this->m_Offset + static_cast<long>(this->m_Region.GetSize()[0])
00248 - (ind[0] - this->m_Region.GetIndex()[0]);
00249 m_SpanBeginOffset = m_SpanEndOffset - static_cast<long>(this->m_Region.GetSize()[0]);
00250 }
00252
00260 Self &
00261 operator++()
00262 {
00263 if (++this->m_Offset >= m_SpanEndOffset)
00264 {
00265 this->Increment();
00266 }
00267 return *this;
00268 }
00270
00278 Self & operator--()
00279 {
00280 if (--this->m_Offset < m_SpanBeginOffset)
00281 {
00282 this->Decrement();
00283 }
00284 return *this;
00285 }
00287
00288
00289 protected:
00290 unsigned long m_SpanBeginOffset;
00291 unsigned long m_SpanEndOffset;
00292
00293 private:
00294 void Increment();
00295 void Decrement();
00296
00297 };
00298
00299 }
00300
00301
00302 #define ITK_TEMPLATE_ImageRegionConstIterator(_, EXPORT, x, y) namespace itk { \
00303 _(1(class EXPORT ImageRegionConstIterator< ITK_TEMPLATE_1 x >)) \
00304 namespace Templates { typedef ImageRegionConstIterator< ITK_TEMPLATE_1 x > ImageRegionConstIterator##y; } \
00305 }
00306
00307
00308 #if ITK_TEMPLATE_EXPLICIT
00309 # include "Templates/itkImageRegionConstIterator+-.h"
00310 #endif
00311
00312 #if ITK_TEMPLATE_TXX
00313 # include "itkImageRegionConstIterator.txx"
00314 #endif
00315
00316 #if defined(_MSC_VER)
00317 #undef ITK_LEAN_AND_MEAN
00318 #endif
00319
00320 #endif
00321