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 __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 }
00167
00170 bool
00171 operator==(const Self &it) const
00172 {
00173
00174 return (m_Position) == (it.m_Position);
00175 }
00176
00179 bool
00180 operator<=(const Self &it) const
00181 {
00182
00183
00184 return (m_Position) <= (it.m_Position);
00185 }
00186
00189 bool
00190 operator<(const Self &it) const
00191 {
00192
00193
00194 return (m_Position) < (it.m_Position);
00195 }
00196
00199 bool
00200 operator>=(const Self &it) const
00201 {
00202
00203
00204 return (m_Position) >= (it.m_Position);
00205 }
00206
00209 bool
00210 operator>(const Self &it) const
00211 {
00212
00213
00214 return (m_Position) > (it.m_Position);
00215 }
00216
00219 const IndexType & GetIndex() const
00220 { return m_PositionIndex; }
00221
00224 const RegionType& GetRegion() const
00225 { return m_Region; }
00226
00229 void SetIndex(const IndexType &ind)
00230 {
00231 m_Position = m_Image->GetBufferPointer() + m_Image->ComputeOffset( ind );
00232 m_PositionIndex = ind;
00233 }
00235
00237 PixelType Get(void) const
00238 { return m_PixelAccessorFunctor.Get(*m_Position); }
00239
00243 const PixelType & Value(void) const
00244 { return *m_Position; }
00245
00248 Self Begin(void) const;
00249
00251 void GoToBegin(void);
00252
00255 Self End(void) const;
00256
00258 void GoToReverseBegin(void);
00259
00261 bool IsAtReverseEnd(void) const
00262 {
00263 return !m_Remaining;
00264 }
00265
00267 bool IsAtEnd(void) const
00268 {
00269 return !m_Remaining;
00270 }
00271
00273 bool Remaining()
00274 {
00275 return m_Remaining;
00276 }
00277
00278 protected:
00279 typename TImage::ConstWeakPointer m_Image;
00280
00281 IndexType m_PositionIndex;
00282 IndexType m_BeginIndex;
00283 IndexType m_EndIndex;
00284
00285
00286
00287 RegionType m_Region;
00288
00289 unsigned long m_OffsetTable[ ImageDimension + 1 ];
00290
00291 const InternalPixelType *m_Position;
00292 const InternalPixelType *m_Begin;
00293 const InternalPixelType *m_End;
00294
00295 bool m_Remaining;
00296
00297 AccessorType m_PixelAccessor;
00298 AccessorFunctorType m_PixelAccessorFunctor;
00299
00300 };
00301
00302 }
00303
00304
00305 #define ITK_TEMPLATE_ImageConstIteratorWithIndex(_, EXPORT, x, y) namespace itk { \
00306 _(1(class EXPORT ImageConstIteratorWithIndex< ITK_TEMPLATE_1 x >)) \
00307 namespace Templates { typedef ImageConstIteratorWithIndex< ITK_TEMPLATE_1 x > ImageConstIteratorWithIndex##y; } \
00308 }
00309
00310
00311 #if ITK_TEMPLATE_EXPLICIT
00312 # include "Templates/itkImageConstIteratorWithIndex+-.h"
00313 #endif
00314
00315 #if ITK_TEMPLATE_TXX
00316 # include "itkImageConstIteratorWithIndex.txx"
00317 #endif
00318
00319 #endif
00320