00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkVectorImage_h
00018 #define __itkVectorImage_h
00019
00020 #include "itkImage.h"
00021 #include "itkImageRegion.h"
00022 #include "itkImportImageContainer.h"
00023 #include "itkDefaultVectorPixelAccessor.h"
00024 #include "itkDefaultVectorPixelAccessorFunctor.h"
00025 #include "itkPoint.h"
00026 #include "itkContinuousIndex.h"
00027 #include "itkArray.h"
00028 #include "itkWeakPointer.h"
00029
00030 namespace itk
00031 {
00032
00073 template <class TPixel, unsigned int VImageDimension=3 >
00074 class ITK_EXPORT VectorImage :
00075 public Image< Array< TPixel >, VImageDimension >
00076 {
00077 public:
00079 typedef VectorImage Self;
00080 typedef ImageBase<VImageDimension> Superclass;
00081 typedef SmartPointer<Self> Pointer;
00082 typedef SmartPointer<const Self> ConstPointer;
00083 typedef WeakPointer<const Self> ConstWeakPointer;
00084
00086 itkNewMacro(Self);
00087
00089 itkTypeMacro(VectorImage, Image);
00090
00095 typedef Array< TPixel > PixelType;
00096
00100 typedef TPixel InternalPixelType;
00101
00103 typedef TPixel ValueType ;
00104
00107 typedef DefaultVectorPixelAccessor< InternalPixelType > AccessorType;
00108
00111 typedef DefaultVectorPixelAccessorFunctor< Self > AccessorFunctorType;
00112
00114 typedef ImportImageContainer<unsigned long, InternalPixelType> PixelContainer;
00115
00117 typedef typename Superclass::IndexType IndexType;
00118
00120 typedef typename Superclass::OffsetType OffsetType;
00121
00123 typedef typename Superclass::SizeType SizeType;
00124
00126 typedef typename Superclass::DirectionType DirectionType;
00127
00129 typedef typename Superclass::RegionType RegionType;
00130
00133 typedef typename Superclass::SpacingType SpacingType;
00134
00137 typedef typename Superclass::PointType PointType;
00138
00140 typedef typename PixelContainer::Pointer PixelContainerPointer;
00141 typedef typename PixelContainer::ConstPointer PixelContainerConstPointer;
00142
00144 typedef typename Superclass::OffsetValueType OffsetValueType;
00145
00146 typedef unsigned int VectorLengthType;
00147
00150 void Allocate();
00151
00154 virtual void Initialize();
00155
00158 void FillBuffer(const PixelType& value);
00159
00160 void SetPixel( const IndexType &index, const PixelType& value )
00161 {
00162 OffsetValueType offset = m_VectorLength * this->ComputeOffset(index);
00163 for( VectorLengthType i = 0; i < m_VectorLength; i++ )
00164 {
00165 (*m_Buffer)[offset + i] = value[i];
00166 }
00167 }
00168
00173 const PixelType GetPixel(const IndexType &index) const
00174 {
00175 OffsetValueType offset = m_VectorLength * this->ComputeOffset(index);
00176 PixelType p( &((*m_Buffer)[offset]), m_VectorLength );
00177 return p;
00178 }
00179
00184 PixelType GetPixel(const IndexType &index )
00185 {
00186 OffsetValueType offset = m_VectorLength * this->ComputeOffset(index);
00187 PixelType p( &((*m_Buffer)[offset]), m_VectorLength );
00188 return p;
00189 }
00190
00193 InternalPixelType *GetBufferPointer()
00194 { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00195 const InternalPixelType *GetBufferPointer() const
00196 { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00197
00199 PixelContainer* GetPixelContainer()
00200 { return m_Buffer.GetPointer(); }
00201
00203 const PixelContainer* GetPixelContainer() const
00204 { return m_Buffer.GetPointer(); }
00205
00208 void SetPixelContainer( PixelContainer *container );
00209
00220 virtual void Graft(const ImageBase<VImageDimension> *data);
00221
00223 AccessorType GetPixelAccessor( void )
00224 { return AccessorType( m_VectorLength ); }
00225
00227 const AccessorType GetPixelAccessor( void ) const
00228 { return AccessorType( m_VectorLength ); }
00229
00230
00232 itkSetMacro( VectorLength, VectorLengthType );
00233 itkGetConstReferenceMacro( VectorLength, VectorLengthType );
00234
00235 protected:
00236 VectorImage();
00237 void PrintSelf( std::ostream& os, Indent indent ) const;
00238 virtual ~VectorImage() {};
00239
00240 private:
00241 VectorImage( const Self & );
00242 void operator=(const Self&);
00243
00244
00245 private:
00247 VectorLengthType m_VectorLength;
00248
00250 PixelContainerPointer m_Buffer;
00251 };
00252
00253
00254 }
00255 #ifndef ITK_MANUAL_INSTANTIATION
00256 #include "itkVectorImage.txx"
00257 #endif
00258
00259 #endif