00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkImageAdaptor_h
00018 #define __itkImageAdaptor_h
00019
00020 #include "itkImage.h"
00021 #include "itkDefaultPixelAccessorFunctor.h"
00022
00023 namespace itk
00024 {
00025
00047 template <class TImage, class TAccessor >
00048 class ITK_EXPORT ImageAdaptor : public ImageBase< ::itk::GetImageDimension<TImage>::ImageDimension>
00049 {
00050 public:
00055 itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension);
00056
00058 typedef ImageAdaptor Self;
00059 typedef ImageBase<itkGetStaticConstMacro(ImageDimension)> Superclass;
00060 typedef SmartPointer<Self> Pointer;
00061 typedef SmartPointer<const Self> ConstPointer;
00062 typedef WeakPointer<const Self> ConstWeakPointer;
00063
00065 itkTypeMacro(ImageAdaptor, ImageBase);
00066
00068 typedef TImage InternalImageType;
00069
00071 itkNewMacro(Self);
00072
00075 typedef typename TAccessor::ExternalType PixelType;
00076
00079 typedef typename TAccessor::InternalType InternalPixelType;
00080
00083 typedef TAccessor AccessorType;
00084
00087 typedef DefaultPixelAccessorFunctor< Self > AccessorFunctorType;
00088
00090 typedef typename Superclass::IndexType IndexType;
00091 typedef typename IndexType::IndexValueType IndexValueType;
00092
00094 typedef typename Superclass::SizeType SizeType;
00095 typedef typename SizeType::SizeValueType SizeValueType;
00096
00098 typedef typename Superclass::OffsetType OffsetType;
00099 typedef typename OffsetType::OffsetValueType OffsetValueType;
00100
00103 typedef typename Superclass::RegionType RegionType;
00104
00107 typedef typename Superclass::SpacingType SpacingType;
00108
00111 typedef typename Superclass::PointType PointType;
00112
00119 virtual void SetLargestPossibleRegion(const RegionType ®ion);
00120
00124 virtual void SetBufferedRegion(const RegionType ®ion);
00125
00129 virtual void SetRequestedRegion(const RegionType ®ion);
00130
00135 virtual void SetRequestedRegion(DataObject *data);
00136
00143 virtual const RegionType & GetRequestedRegion() const;
00144
00153 virtual const RegionType& GetLargestPossibleRegion() const;
00154
00160 virtual const RegionType& GetBufferedRegion() const;
00161
00163 inline void Allocate();
00164
00165
00168 virtual void Initialize();
00169
00171 void SetPixel(const IndexType &index, const PixelType & value)
00172 { m_PixelAccessor.Set( m_Image->GetPixel(index), value ); }
00173
00175 PixelType GetPixel(const IndexType &index) const
00176 { return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
00177
00179 PixelType operator[](const IndexType &index) const
00180 { return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
00181
00183 const OffsetValueType *GetOffsetTable() const;
00184
00186 IndexType ComputeIndex(OffsetValueType offset) const;
00187
00190 typedef typename TImage::PixelContainer PixelContainer;
00191 typedef typename TImage::PixelContainerPointer PixelContainerPointer;
00192 typedef typename TImage::PixelContainerConstPointer PixelContainerConstPointer;
00193
00195 PixelContainerPointer GetPixelContainer()
00196 { return m_Image->GetPixelContainer(); };
00197
00200 void SetPixelContainer( PixelContainer *container );
00201
00212 virtual void Graft(const DataObject *data);
00213
00215 typedef InternalPixelType * InternalPixelPointerType;
00216
00219 InternalPixelType *GetBufferPointer();
00220 const InternalPixelType *GetBufferPointer() const;
00221 void GetBufferPointer2( InternalPixelPointerType & );
00222
00224 virtual void SetSpacing( const SpacingType values );
00225 virtual void SetSpacing( const double* values );
00226 virtual void SetSpacing( const float* values );
00227
00231 virtual const SpacingType& GetSpacing() const;
00232
00236 virtual const PointType& GetOrigin() const;
00237
00239 virtual void SetOrigin( const PointType values);
00240 virtual void SetOrigin( const double* values );
00241 virtual void SetOrigin( const float* values );
00242
00244 virtual void SetImage( TImage * );
00245
00247 virtual void Modified() const;
00248
00250 virtual unsigned long GetMTime() const;
00251
00253 AccessorType & GetPixelAccessor( void )
00254 { return m_PixelAccessor; }
00255
00257 const AccessorType & GetPixelAccessor( void ) const
00258 { return m_PixelAccessor; }
00259
00261 void SetPixelAccessor( const AccessorType & accessor )
00262 { m_PixelAccessor = accessor; }
00263
00265 virtual void Update();
00266 virtual void CopyInformation(const DataObject *data);
00267
00270 virtual void UpdateOutputInformation();
00271 virtual void SetRequestedRegionToLargestPossibleRegion();
00272 virtual void PropagateRequestedRegion() throw (InvalidRequestedRegionError);
00273 virtual void UpdateOutputData();
00274 virtual bool VerifyRequestedRegion();
00275
00276 protected:
00277 ImageAdaptor();
00278 virtual ~ImageAdaptor();
00279 void PrintSelf(std::ostream& os, Indent indent) const;
00280
00281 private:
00282 ImageAdaptor(const Self&);
00283 void operator=(const Self&);
00284
00285
00286
00287 typename TImage::Pointer m_Image;
00288
00289
00290
00291 AccessorType m_PixelAccessor;
00292
00293
00294 };
00295
00296 }
00297
00298 #ifndef ITK_MANUAL_INSTANTIATION
00299 #include "itkImageAdaptor.txx"
00300 #endif
00301
00302
00303
00304 #endif
00305