00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkImageConstIteratorWithIndex_h
00018 #define __itkImageConstIteratorWithIndex_h
00019
00020 #include "itkIndex.h"
00021 #include "itkImage.h"
00022 #include <memory>
00023
00024 namespace itk
00025 {
00026
00090 template<typename TImage>
00091 class ITK_EXPORT ImageConstIteratorWithIndex
00092 {
00093 public:
00095 typedef ImageConstIteratorWithIndex Self;
00096
00101 itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension);
00102
00104 typedef typename TImage::IndexType IndexType;
00105 typedef typename IndexType::IndexValueType IndexValueType;
00106
00108 typedef typename TImage::SizeType SizeType;
00109 typedef typename SizeType::SizeValueType SizeValueType;
00110
00112 typedef typename TImage::RegionType RegionType;
00113
00115 typedef TImage ImageType;
00116
00120 typedef typename TImage::PixelContainer PixelContainer;
00121 typedef typename PixelContainer::Pointer PixelContainerPointer;
00122
00124 typedef typename TImage::InternalPixelType InternalPixelType;
00125
00127 typedef typename TImage::PixelType PixelType;
00128
00131 typedef typename TImage::AccessorType AccessorType;
00132 typedef typename TImage::AccessorFunctorType AccessorFunctorType;
00133
00135 typedef typename TImage::OffsetType OffsetType;
00136 typedef typename OffsetType::OffsetValueType OffsetValueType;
00137
00140 ImageConstIteratorWithIndex();
00141
00144 ImageConstIteratorWithIndex(const Self& it);
00145
00148 ImageConstIteratorWithIndex( const TImage *ptr,
00149 const RegionType& region );
00150
00153 Self &operator=(const Self& it);
00154
00156 static unsigned int GetImageDimension()
00157 {return ImageDimension;}
00158
00161 bool
00162 operator!=(const Self &it) const
00163 {
00164
00165 return (m_Position) != (it.m_Position);
00166 };
00168
00171 bool
00172 operator==(const Self &it) const
00173 {
00174
00175 return (m_Position) == (it.m_Position);
00176 };
00178
00181 bool
00182 operator<=(const Self &it) const
00183 {
00184
00185
00186 return (m_Position) <= (it.m_Position);
00187 };
00189
00192 bool
00193 operator<(const Self &it) const
00194 {
00195
00196
00197 return (m_Position) < (it.m_Position);
00198 };
00200
00203 bool
00204 operator>=(const Self &it) const
00205 {
00206
00207
00208 return (m_Position) >= (it.m_Position);
00209 };
00211
00214 bool
00215 operator>(const Self &it) const
00216 {
00217
00218
00219 return (m_Position) > (it.m_Position);
00220 };
00222
00225 const IndexType & GetIndex() const
00226 { return m_PositionIndex; }
00227
00230 const RegionType& GetRegion() const
00231 { return m_Region; };
00232
00235 void SetIndex(const IndexType &ind)
00236 { m_Position = m_Image->GetBufferPointer() + m_Image->ComputeOffset( ind );
00237 m_PositionIndex = ind; }
00239
00241 PixelType Get(void) const
00242 { return m_PixelAccessorFunctor.Get(*m_Position); }
00243
00247 const PixelType & Value(void) const
00248 { return *m_Position; }
00249
00252 Self Begin(void) const;
00253
00255 void GoToBegin(void);
00256
00259 Self End(void) const;
00260
00262 void GoToReverseBegin(void);
00263
00265 bool IsAtReverseEnd(void) const
00266 {
00267 return !m_Remaining;
00268 }
00269
00271 bool IsAtEnd(void) const
00272 {
00273 return !m_Remaining;
00274 }
00275
00277 bool Remaining()
00278 {
00279 return m_Remaining;
00280 }
00281
00282 protected:
00283 typename TImage::ConstWeakPointer m_Image;
00284
00285 IndexType m_PositionIndex;
00286 IndexType m_BeginIndex;
00287 IndexType m_EndIndex;
00288
00289
00290
00291 RegionType m_Region;
00292
00293 unsigned long m_OffsetTable[ ImageDimension + 1 ];
00294
00295 const InternalPixelType *m_Position;
00296 const InternalPixelType *m_Begin;
00297 const InternalPixelType *m_End;
00298
00299 bool m_Remaining;
00300
00301 AccessorType m_PixelAccessor;
00302 AccessorFunctorType m_PixelAccessorFunctor;
00303
00304 };
00305
00306 }
00307
00308
00309 #define ITK_TEMPLATE_ImageConstIteratorWithIndex(_, EXPORT, x, y) namespace itk { \
00310 _(1(class EXPORT ImageConstIteratorWithIndex< ITK_TEMPLATE_1 x >)) \
00311 namespace Templates { typedef ImageConstIteratorWithIndex< ITK_TEMPLATE_1 x > ImageConstIteratorWithIndex##y; } \
00312 }
00313
00314
00315 #if ITK_TEMPLATE_EXPLICIT
00316 # include "Templates/itkImageConstIteratorWithIndex+-.h"
00317 #endif
00318
00319 #if ITK_TEMPLATE_TXX
00320 # include "itkImageConstIteratorWithIndex.txx"
00321 #endif
00322
00323 #endif
00324