12 #ifndef itkVectorImageRegionIteratorWithIndex_h 13 #define itkVectorImageRegionIteratorWithIndex_h 15 #include "itkImageRegionConstIterator.h" 16 #include "itkImageRegionIteratorWithIndex.h" 18 #include "itkVectorImage.h" 19 #include "itkVariableLengthVector.h" 62 template<
typename TImage >
74 TImage::ImageDimension);
77 typedef ImageRegionIteratorWithIndex< TImage >
Superclass;
82 typedef typename Superclass::SizeType
SizeType;
97 #ifdef ITK_USE_CONCEPT_CHECKING 98 itkConceptMacro( SameTypeCheck,
99 ( itk::Concept::SameType< ImageType, VectorImage<InternalPixelType, ImageIteratorDimension> > ) );
100 itkConceptMacro( SameTypeCheck2,
101 ( itk::Concept::SameType< PixelType, PixelVectorType> ) );
146 Superclass::operator=(it);
155 void SetVector(
const PixelVectorType & value,
const int offIndex=0)
const 159 this->m_PixelAccessorFunctor.Set(*( const_cast< InternalPixelType * >( this->m_Position ) ), value);
163 int numberOfComponens = this->m_Image->GetNumberOfComponentsPerPixel();
164 InternalPixelType* p =
const_cast<InternalPixelType*
>(this->
m_BeginBuffer + numberOfComponens*(this->m_Position-this->m_Begin));
175 void GetVector(PixelVectorType& vec,
const int offIndex=0)
const 179 vec = this->m_PixelAccessorFunctor.Get( *this->m_Position );
184 int numberOfComponens = this->m_Image->GetNumberOfComponentsPerPixel();
185 InternalPixelType* p =
const_cast<InternalPixelType*
>(this->
m_BeginBuffer + numberOfComponens*(this->m_Position-this->m_Begin));
199 void Initialize(TImage *ptr,
const RegionType & regionInput,
int vectorAxis=-1)
206 const InternalPixelType *buffer = this->m_Image->GetBufferPointer();
212 this->m_BeginIndex = regionInput.GetIndex();
213 this->m_PositionIndex = this->m_BeginIndex;
214 this->m_Region = regionInput;
216 if ( regionInput.GetNumberOfPixels() > 0 )
218 const RegionType & bufferedRegion = this->m_Image->GetBufferedRegion();
219 itkAssertOrThrowMacro( ( bufferedRegion.IsInside(this->m_Region) ),
220 "Region " << this->m_Region <<
" is outside of buffered region " << bufferedRegion );
223 std::copy(this->m_Image->GetOffsetTable(),
224 this->m_Image->GetOffsetTable()+Superclass::ImageDimension + 1 ,
225 this->m_OffsetTable);
228 OffsetValueType offs = this->m_Image->ComputeOffset(this->m_BeginIndex);
229 this->m_Begin = buffer + offs;
230 this->m_Position = this->m_Begin;
233 this->m_Remaining =
false;
235 for (
unsigned int i = 0; i < Superclass::ImageDimension; ++i )
237 SizeValueType size = regionInput.GetSize()[i];
240 this->m_Remaining =
true;
242 this->m_EndIndex[i] = this->m_BeginIndex[i] +
static_cast< OffsetValueType
>( size );
243 pastEnd[i] = this->m_BeginIndex[i] +
static_cast< OffsetValueType
>( size ) - 1;
245 this->m_End = buffer + this->m_Image->ComputeOffset(pastEnd);
247 this->m_PixelAccessor = this->m_Image->GetPixelAccessor();
248 this->m_PixelAccessorFunctor.SetPixelAccessor(this->m_PixelAccessor);
249 this->m_PixelAccessorFunctor.SetBegin(buffer);
261 typename RegionType::SizeType sizeInput = regionInput.GetSize();
262 typename RegionType::IndexType indexInput = regionInput.GetIndex();
266 region.SetIndex(indexInput);
267 region.SetSize(sizeInput);
270 this->m_BeginIndex = region.GetIndex();
271 this->m_PositionIndex = this->m_BeginIndex;
272 this->m_Region = region;
274 if ( region.GetNumberOfPixels() > 0 )
276 const RegionType & bufferedRegion = this->m_Image->GetBufferedRegion();
277 itkAssertOrThrowMacro( ( bufferedRegion.IsInside(this->m_Region) ),
278 "Region " << this->m_Region <<
" is outside of buffered region " << bufferedRegion );
281 std::copy(this->m_Image->GetOffsetTable(),
282 this->m_Image->GetOffsetTable()+Superclass::ImageDimension + 1 ,
283 this->m_OffsetTable);
286 OffsetValueType offs = this->m_Image->ComputeOffset(this->m_BeginIndex);
287 this->m_Begin = buffer + offs;
288 this->m_Position = this->m_Begin;
291 this->m_Remaining =
false;
293 for (
unsigned int i = 0; i < Superclass::ImageDimension; ++i )
297 SizeValueType size = region.GetSize()[i];
300 this->m_Remaining =
true;
302 this->m_EndIndex[i] = this->m_BeginIndex[i] +
static_cast< OffsetValueType
>( size );
303 pastEnd[i] = this->m_BeginIndex[i] +
static_cast< OffsetValueType
>( size ) - 1;
309 this->m_Remaining =
true;
312 this->m_End = buffer + this->m_Image->ComputeOffset(pastEnd);
314 this->m_PixelAccessor = this->m_Image->GetPixelAccessor();
315 this->m_PixelAccessorFunctor.SetPixelAccessor(this->m_PixelAccessor);
316 this->m_PixelAccessorFunctor.SetBegin(buffer);
322 SizeType size = ptr->GetLargestPossibleRegion().GetSize();
323 const typename ImageType::OffsetValueType* offsetTable = ptr->GetOffsetTable();
334 Self &
operator=(
const ImageRegionIteratorWithIndex< TImage > & it);
350 template <
typename TPixel,
unsigned int VImageDimension>
366 typedef ImageRegionIteratorWithIndex< Image<TPixel, VImageDimension> >
Superclass;
385 #ifdef ITK_USE_CONCEPT_CHECKING 386 itkConceptMacro( SameTypeCheck,
387 ( itk::Concept::SameType< ImageType, Image<InternalPixelType, VImageDimension> > ) );
407 m_VolumeSize = it.m_VolumeSize;
431 Superclass::operator=(it);
432 m_VolumeSize = it.m_VolumeSize;
441 void SetVector(
const PixelVectorType & value,
const int offIndex=0)
443 int off=offIndex*m_VolumeSize;
446 this->m_PixelAccessorFunctor.Set(
447 *( const_cast< InternalPixelType * >( this->m_Position + off) ), value[i]);
453 void GetVector(PixelVectorType& vec,
const int offIndex=0)
const 456 int off=offIndex*m_VolumeSize;
459 vec[i] = this->m_PixelAccessorFunctor.Get( *( this->m_Position + off ) );
467 void Initialize(ImageType *ptr,
const RegionType & regionInput,
int vectorAxis=-1)
472 const InternalPixelType *buffer = this->m_Image->GetBufferPointer();
474 m_VectorAxis = (vectorAxis==-1) ? Superclass::ImageDimension-1 : vectorAxis;
477 typename RegionType::SizeType size4d = this->m_Image->GetLargestPossibleRegion().GetSize();
479 for (
int i = 0; i < VImageDimension-1; ++i )
480 m_VolumeSize *= size4d[i];
482 typename RegionType::SizeType sizeInput = regionInput.GetSize();
483 typename RegionType::IndexType indexInput = regionInput.GetIndex();
494 region.SetIndex(indexInput);
495 region.SetSize(sizeInput);
498 this->m_BeginIndex = region.GetIndex();
499 this->m_PositionIndex = this->m_BeginIndex;
500 this->m_Region = region;
502 if ( region.GetNumberOfPixels() > 0 )
504 const RegionType & bufferedRegion = this->m_Image->GetBufferedRegion();
505 itkAssertOrThrowMacro( ( bufferedRegion.IsInside(this->m_Region) ),
506 "Region " << this->m_Region <<
" is outside of buffered region " << bufferedRegion );
509 std::copy(this->m_Image->GetOffsetTable(),
510 this->m_Image->GetOffsetTable()+Superclass::ImageDimension + 1 ,
511 this->m_OffsetTable);
514 OffsetValueType offs = this->m_Image->ComputeOffset(this->m_BeginIndex);
515 this->m_Begin = buffer + offs;
516 this->m_Position = this->m_Begin;
519 this->m_Remaining =
false;
521 for (
unsigned int i = 0; i < Superclass::ImageDimension; ++i )
525 SizeValueType size = region.GetSize()[i];
528 this->m_Remaining =
true;
530 this->m_EndIndex[i] = this->m_BeginIndex[i] +
static_cast< OffsetValueType
>( size );
531 pastEnd[i] = this->m_BeginIndex[i] +
static_cast< OffsetValueType
>( size ) - 1;
537 this->m_Remaining =
true;
540 this->m_End = buffer + this->m_Image->ComputeOffset(pastEnd);
542 this->m_PixelAccessor = this->m_Image->GetPixelAccessor();
543 this->m_PixelAccessorFunctor.SetPixelAccessor(this->m_PixelAccessor);
544 this->m_PixelAccessorFunctor.SetBegin(buffer);
550 SizeType size = ptr->GetLargestPossibleRegion().GetSize();
551 const typename ImageType::OffsetValueType* offsetTable = ptr->GetOffsetTable();
569 Self &
operator=(
const ImageRegionIteratorWithIndex< ImageType > & it);
581 template <
typename TPixel>
586 typedef ImageRegionIteratorWithIndex< Image<VariableLengthVector<TPixel>, 3> >
Superclass;
613 vec = Superclass::Get();
618 Superclass::Set(value);
OffsetValueType m_VectorStride
Superclass::SizeType SizeType
~VectorImageRegionIteratorWithIndex()
VariableLengthVector< InternalPixelType > PixelVectorType
Superclass::PixelType PixelType
Self & operator=(const Self &it)
VectorImageRegionIteratorWithIndex(const ImageIteratorWithIndex< ImageType > &it)
void GetVector(PixelVectorType &vec, const int offIndex=0) const
Superclass::SizeType SizeType
VectorImageRegionIteratorWithIndex(const Self &it)
VectorImageRegionIteratorWithIndex()
Superclass::InternalPixelType InternalPixelType
VectorImageRegionIteratorWithIndex(ImageType *ptr, const RegionType ®ion)
VectorImageRegionIteratorWithIndex(const Self &it)
Superclass::RegionType RegionType
VectorImageRegionIteratorWithIndex Self
ImageRegion< TImage::ImageDimension > VectorImageRegionType
ImageRegion< VImageDimension-1 > VectorImageRegionType
VectorImageRegionIteratorWithIndex()
ImageRegion< VImageDimension > NDImageRegionType
Superclass::InternalPixelType InternalPixelType
Superclass::PixelContainerPointer PixelContainerPointer
const InternalPixelType * m_BeginBuffer
ImageRegion< TImage::ImageDimension+1 > NDImageRegionType
Superclass::PixelType PixelType
void GetVector(PixelType &vec) const
VectorImageRegionIteratorWithIndex Self
Superclass::RegionType RegionType
Superclass::PixelContainer PixelContainer
VectorImageRegionIteratorWithIndex(ImageType *ptr, const RegionType ®ionInput, int vectorAxis=-1)
Superclass::AccessorType AccessorType
VectorImageRegionIteratorWithIndex Self
Superclass::IndexType IndexType
VariableLengthVector< InternalPixelType > PixelVectorType
void Initialize(TImage *ptr, const RegionType ®ionInput, int vectorAxis=-1)
OffsetValueType m_VectorStride
void Initialize(ImageType *ptr, const RegionType ®ionInput, int vectorAxis=-1)
Superclass::ImageType ImageType
static const unsigned int ImageIteratorDimension
ImageRegionIteratorWithIndex< Image< TPixel, VImageDimension > > Superclass
Superclass::PixelContainerPointer PixelContainerPointer
VectorImageRegionIteratorWithIndex()
Superclass::AccessorType AccessorType
~VectorImageRegionIteratorWithIndex()
Superclass::PixelContainer PixelContainer
Superclass::ImageType ImageType
Superclass::PixelContainerPointer PixelContainerPointer
ImageRegionIteratorWithIndex< Image< VariableLengthVector< TPixel >, 3 > > Superclass
void GetVector(PixelVectorType &vec, const int offIndex=0) const
Superclass::IndexType IndexType
Superclass::OffsetType OffsetType
Superclass::ImageType ImageType
Superclass::InternalPixelType InternalPixelType
void SetVector(const PixelVectorType &value, const int offIndex=0)
Superclass::OffsetType OffsetType
ImageRegionIteratorWithIndex< TImage > Superclass
Superclass::RegionType RegionType
Superclass::PixelContainer PixelContainer
Superclass::AccessorType AccessorType
OffsetValueType m_VolumeSize
Self & operator=(const Self &it)
A multi-dimensional iterator templated over image type. It provides the same interfaces for both itk:...
void SetVector(const PixelType &value)
Superclass::PixelType PixelType
Superclass::SizeType SizeType
void SetVector(const PixelVectorType &value, const int offIndex=0) const
Superclass::IndexType IndexType
VectorImageRegionIteratorWithIndex(TImage *ptr, const RegionType ®ionInput, int vectorAxis=-1)
Superclass::OffsetType OffsetType