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
00057
template<
typename TImage>
00058 class ITK_EXPORT ImageConstIteratorWithIndex
00059 {
00060
public:
00062 typedef ImageConstIteratorWithIndex
Self;
00063
00068
itkStaticConstMacro(ImageDimension,
unsigned int, TImage::ImageDimension);
00069
00071 typedef typename TImage::IndexType
IndexType;
00072 typedef typename IndexType::IndexValueType
IndexValueType;
00073
00075 typedef typename TImage::SizeType
SizeType;
00076 typedef typename SizeType::SizeValueType
SizeValueType;
00077
00079 typedef typename TImage::RegionType
RegionType;
00080
00082 typedef TImage
ImageType;
00083
00087 typedef typename TImage::PixelContainer
PixelContainer;
00088 typedef typename PixelContainer::Pointer
PixelContainerPointer;
00089
00091 typedef typename TImage::InternalPixelType
InternalPixelType;
00092
00094 typedef typename TImage::PixelType
PixelType;
00095
00098 typedef typename TImage::AccessorType
AccessorType;
00099
00101 typedef typename TImage::OffsetType
OffsetType;
00102 typedef typename OffsetType::OffsetValueType
OffsetValueType;
00103
00106 ImageConstIteratorWithIndex();
00107
00110 ImageConstIteratorWithIndex(
const Self& it);
00111
00114 ImageConstIteratorWithIndex(
const TImage *ptr,
00115
const RegionType& region );
00116
00119
Self &operator=(
const Self& it);
00120
00122 static unsigned int GetImageDimension()
00123 {
return ImageDimension;}
00124
00127
bool
00128 operator!=(
const Self &it)
const
00129
{
00130
00131
return (m_Position) != (it.
m_Position);
00132 };
00133
00136
bool
00137
operator==(
const Self &it)
const
00138 {
00139
00140
return (m_Position) == (it.m_Position);
00141 };
00142
00145
bool
00146 operator<=(
const Self &it)
const
00147
{
00148
00149
00150
return (m_Position) <= (it.m_Position);
00151 };
00152
00155
bool
00156 operator<(
const Self &it)
const
00157
{
00158
00159
00160
return (m_Position) < (it.m_Position);
00161 };
00162
00165
bool
00166 operator>=(
const Self &it)
const
00167
{
00168
00169
00170 return (m_Position) >= (it.m_Position);
00171 };
00172
00175
bool
00176 operator>(
const Self &it)
const
00177
{
00178
00179
00180
return (m_Position) > (it.m_Position);
00181 };
00182
00185
const IndexType GetIndex()
00186 {
return m_PositionIndex; }
00187
00190
const RegionType& GetRegion()
const
00191 {
return m_Region; };
00192
00195
void SetIndex(
const IndexType &ind)
00196 { m_Position = m_Begin + m_Image->ComputeOffset( ind );
00197 m_PositionIndex = ind; }
00198
00200 PixelType Get(
void)
const
00201 {
return m_PixelAccessor.Get(*m_Position); }
00202
00206
const PixelType & Value(
void)
const
00207 {
return *m_Position; }
00208
00211 Self Begin(
void) const;
00212
00214
void GoToBegin(
void);
00215
00218 Self End(
void) const;
00219
00221
void GoToReverseBegin(
void);
00222
00224
bool IsAtReverseEnd(
void)
const
00225
{
00226
return !m_Remaining;
00227 }
00228
00230
bool IsAtEnd(
void)
const
00231 {
00232
return !m_Remaining;
00233 }
00234
00236
bool Remaining()
00237 {
00238
return m_Remaining;
00239 }
00240
00241
protected:
00242
typename TImage::ConstPointer m_Image;
00243
00244
IndexType m_PositionIndex;
00245
IndexType m_BeginIndex;
00246
IndexType m_EndIndex;
00247
00248
00249
00250
RegionType m_Region;
00251
00252 unsigned long m_OffsetTable[ ImageDimension + 1 ];
00253
00254
const InternalPixelType *m_Position;
00255
const InternalPixelType *m_Begin;
00256
const InternalPixelType *m_End;
00257
00258
bool m_Remaining;
00259
00260
AccessorType m_PixelAccessor;
00261
00262 };
00263
00264 }
00265
00266
#ifndef ITK_MANUAL_INSTANTIATION
00267 #include "itkImageConstIteratorWithIndex.txx"
00268
#endif
00269
00270
#endif