1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#ifndef __ImageRegionConstIteratorWithIndexOverride_h_
#define __ImageRegionConstIteratorWithIndexOverride_h_
#include "itkImageRegionConstIteratorWithIndex.h"
#include "itkImageLinearIteratorWithIndex.h"
template <class TIterator>
class IteratorExtender : public TIterator
{
public:
typedef IteratorExtender<TIterator> Self;
typedef TIterator Superclass;
typedef typename Superclass::RegionType RegionType;
typedef typename Superclass::ImageType ImageType;
typedef typename Superclass::InternalPixelType InternalPixelType;
IteratorExtender(ImageType *image, const RegionType ®ion)
: Superclass(image, region) {}
IteratorExtender(const ImageType *image, const RegionType ®ion)
: Superclass(const_cast<ImageType *>(image), region) {}
const InternalPixelType *GetPosition() { return this->m_Position; }
const InternalPixelType *GetBeginPosition() { return this->m_Begin; }
template <class TPixel, unsigned int VDim>
TPixel *GetPixelPointer(itk::Image<TPixel, VDim> *image)
{
long offset_in_pixels = this->m_Position - this->m_Image->GetBufferPointer();
return image->GetBufferPointer() + offset_in_pixels;
}
template <class TPixel, unsigned int VDim>
const TPixel *GetPixelPointer(const itk::Image<TPixel, VDim> *image)
{
long offset_in_pixels = this->m_Position - this->m_Image->GetBufferPointer();
return image->GetBufferPointer() + offset_in_pixels;
}
template <class TPixel, unsigned int VDim>
TPixel *GetPixelPointer(itk::VectorImage<TPixel, VDim> *image)
{
long offset_in_pixels = this->m_Position - this->m_Image->GetBufferPointer();
return image->GetBufferPointer() + offset_in_pixels * image->GetNumberOfComponentsPerPixel();
}
template <class TPixel, unsigned int VDim>
const TPixel *GetPixelPointer(const itk::VectorImage<TPixel, VDim> *image)
{
long offset_in_pixels = this->m_Position - this->m_Image->GetBufferPointer();
return image->GetBufferPointer() + offset_in_pixels * image->GetNumberOfComponentsPerPixel();
}
};
template <class TIterator>
class IteratorExtenderWithOffset : public IteratorExtender<TIterator>
{
public:
typedef IteratorExtender<TIterator> Superclass;
typedef typename Superclass::RegionType RegionType;
typedef typename Superclass::ImageType ImageType;
typedef typename TIterator::OffsetValueType OffsetValueType;
IteratorExtenderWithOffset(ImageType *image, const RegionType ®ion)
: Superclass(image, region) {}
const OffsetValueType GetOffset(int direction) { return this->m_OffsetTable[direction]; }
};
#endif
|