14 #ifndef __itkSpatiallyDenseSparseVectorImage_h    15 #define __itkSpatiallyDenseSparseVectorImage_h    21 #include "itkNeighborhoodAccessorFunctor.h"    22 #include "itkVariableLengthVector.h"    39 template <
class TValueType, 
unsigned int VImageDimension, 
typename TKeyType = 
unsigned long>
    41     public ImageBase< VImageDimension >
    58   typedef VariableLengthVector< TValueType > 
PixelType;
    72   itkStaticConstMacro( ImageDimension, 
unsigned int, VImageDimension );
    75   typedef ImportImageContainer< SizeValueType, InternalPixelType > 
PixelContainer;
    93   typedef typename Superclass::SizeType 
SizeType;
   130   void Allocate(
bool UseDefaultConstructor = 
false) 
ITK_OVERRIDE;
   138     this->SetLargestPossibleRegion(region);
   139     this->SetBufferedRegion(region);
   140     this->SetRequestedRegion(region);
   145     RegionType region; region.SetSize(size);
   146     this->SetLargestPossibleRegion(region);
   147     this->SetBufferedRegion(region);
   148     this->SetRequestedRegion(region);
   164   { 
return this->GetLargestPossibleRegion(); }
   172     OffsetValueType offset=0;
   173     const OffsetValueType *offsetTable = this->GetOffsetTable();
   175     for (
int i=ImageDimension-1; i > 0; i--)
   177       offset += ind[i]*offsetTable[i];
   186   void FillBuffer(
const PixelType& value);
   193    void SetPixel( 
const IndexType &index, 
const PixelType &value )
   195     PixelMapType *map = (this->GetInternalPixel(index)).GetDataPointer();
   199     for ( VectorLengthType i = 0; i < m_VectorLength; i++ )
   203         (*map)[i] = value[i];
   213   const PixelType 
GetPixel(
const IndexType &index)
 const   216     pixel.SetSize(m_VectorLength);
   218     const PixelMapType *map = (this->GetInternalPixel(index)).GetDataPointer();
   220     for ( VectorLengthType i = 0; i < m_VectorLength; i++ )
   222       typename PixelMapType::const_iterator it = map->find( i );
   224       if ( it == map->end() )
   226         pixel[i] = m_FillBufferValue[i];
   230         pixel[i] = it->second;
   244     pixel.SetSize(m_VectorLength);
   246     const PixelMapType *map = (this->GetInternalPixel(index)).GetDataPointer();
   248     for ( VectorLengthType i = 0; i < m_VectorLength; i++ )
   250       typename PixelMapType::const_iterator it = map->find( i );
   252       if ( it == map->end() )
   254         pixel[i] = m_FillBufferValue[i];
   258         pixel[i] = it->second;
   272     OffsetValueType offset = this->ComputeOffset(index);
   273     return (*m_Container)[offset];
   283     OffsetValueType offset = this->ComputeOffset(index);
   284     return (*m_Container)[offset];
   293      { 
return this->GetPixel(index); }
   300      { 
return this->GetPixel(index); }
   305     return m_Container.GetPointer();
   311     return m_Container.GetPointer();
   317     return m_Container->GetBufferPointer();
   321     return m_Container->GetBufferPointer();
   326   void SetPixelContainer( PixelContainer *container );
   338   virtual void Graft(
const DataObject *data) 
ITK_OVERRIDE;
   343     return AccessorType(m_FillBufferValue, m_VectorLength);
   349     return AccessorType(m_FillBufferValue, m_VectorLength);
   365   itkSetMacro(VectorLength, VectorLengthType);
   366   itkGetConstReferenceMacro(VectorLength, VectorLengthType);
   369   virtual unsigned int GetNumberOfComponentsPerPixel() 
const ITK_OVERRIDE;
   371   virtual void SetNumberOfComponentsPerPixel(
unsigned int n) 
ITK_OVERRIDE;
   375   void PrintSelf( std::ostream& os, Indent indent ) 
const ITK_OVERRIDE;
   380   void operator=(
const Self&); 
   393 #ifndef ITK_MANUAL_INSTANTIATION 
SpatiallyDenseSparseVectorImagePixelAccessor< ValueType, KeyType > AccessorType
InternalPixelType::InternalDataType PixelMapType
PixelMapType::iterator PixelMapIterator
PixelType m_FillBufferValue
const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const 
PixelContainer * GetPixelContainer()
void SetRegions(const SizeType &size) ITK_OVERRIDE
const InternalPixelType & GetInternalPixel(const IndexType &index) const 
Get an internal pixel (read only version). 
InternalPixelType IOPixelType
PixelType GetPixel(const IndexType &index)
Get a reference to a pixel (e.g. for editing). 
Superclass::IndexType IndexType
SpatiallyDenseSparseVectorImageNeighborhoodAccessorFunctor< Self > NeighborhoodAccessorFunctorType
const PixelType GetPixel(const IndexType &index) const 
Get a pixel (read only version). 
SpatiallyDenseSparseVectorImagePixelAccessorFunctor< Self > AccessorFunctorType
ImportImageContainer< SizeValueType, InternalPixelType > PixelContainer
WeakPointer< const Self > ConstWeakPointer
virtual void SetBufferedRegion(const RegionType ®ion) ITK_OVERRIDE
unsigned long VectorLengthType
Represents a sparse array. 
PixelType operator[](const IndexType &index) const 
Access a pixel. 
void ComputeOffsetTable(const std::vector< int > &size, std::vector< int > &offsetTable, const int storedWay)
OffsetValueType ComputeOffset(const IndexType &ind) const 
virtual const RegionType & GetBufferedRegion() const ITK_OVERRIDE
VariableLengthVector< TValueType > PixelType
Superclass::OffsetType OffsetType
const InternalPixelType * GetBufferPointer() const 
InternalPixelType * GetBufferPointer()
Superclass::RegionType RegionType
VectorLengthType m_VectorLength
Give access to partial aspects of a type. 
SmartPointer< const Self > ConstPointer
Superclass::DirectionType DirectionType
virtual ~SpatiallyDenseSparseVectorImage()
const AccessorType GetPixelAccessor(void) const 
Superclass::OffsetValueType OffsetValueType
void SetPixel(const IndexType &index, const PixelType &value)
Set a pixel value. 
const PixelContainer * GetPixelContainer() const 
PixelMapType::const_iterator PixelMapConstIterator
SmartPointer< Self > Pointer
NeighborhoodAccessorFunctorType GetNeighborhoodAccessor()
Provides accessor interfaces to Access pixels and is meant to be used by iterators. 
Provides accessor interfaces to Access pixels and is meant to be used on pointers to pixels held by t...
Superclass::PointType PointType
Superclass::SpacingType SpacingType
PixelContainerPointer m_Container
AccessorType GetPixelAccessor(void)
SparseVector< TValueType, TKeyType > InternalPixelType
PixelContainer::ConstPointer PixelContainerConstPointer
utl_unordered_map< TKeyType, TValueType > InternalDataType
Superclass::SizeType SizeType
ImageBase< VImageDimension > Superclass
SpatiallyDenseSparseVectorImage Self
InternalPixelType & GetInternalPixel(const IndexType &index)
Get an internal pixel (e.g. for editing). 
An n-dimensional vector image with a sparse memory model. 
PixelType operator[](const IndexType &index)
Access a pixel. This version cannot be an lvalue because the pixel is converted on the fly to a Varia...
PixelContainer::Pointer PixelContainerPointer