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:
00051
00056 itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension);
00057
00059 typedef ImageAdaptor Self;
00060 typedef ImageBase<itkGetStaticConstMacro(ImageDimension)> Superclass;
00061 typedef SmartPointer<Self> Pointer;
00062 typedef SmartPointer<const Self> ConstPointer;
00063 typedef WeakPointer<const Self> ConstWeakPointer;
00064
00066 itkTypeMacro(ImageAdaptor, ImageBase);
00067
00069 typedef TImage InternalImageType;
00070
00072 itkNewMacro(Self);
00073
00076 typedef typename TAccessor::ExternalType PixelType;
00077
00080 typedef typename TAccessor::InternalType InternalPixelType;
00081
00082 typedef PixelType IOPixelType;
00083
00086 typedef TAccessor AccessorType;
00087
00090 typedef DefaultPixelAccessorFunctor< Self > AccessorFunctorType;
00091
00093 typedef typename Superclass::IndexType IndexType;
00094 typedef typename IndexType::IndexValueType IndexValueType;
00095
00097 typedef typename Superclass::SizeType SizeType;
00098 typedef typename SizeType::SizeValueType SizeValueType;
00099
00101 typedef typename Superclass::OffsetType OffsetType;
00102 typedef typename OffsetType::OffsetValueType OffsetValueType;
00103
00106 typedef typename Superclass::RegionType RegionType;
00107
00110 typedef typename Superclass::SpacingType SpacingType;
00111
00114 typedef typename Superclass::PointType PointType;
00115
00122 virtual void SetLargestPossibleRegion(const RegionType ®ion);
00123
00127 virtual void SetBufferedRegion(const RegionType ®ion);
00128
00132 virtual void SetRequestedRegion(const RegionType ®ion);
00133
00138 virtual void SetRequestedRegion(DataObject *data);
00139
00146 virtual const RegionType & GetRequestedRegion() const;
00147
00156 virtual const RegionType& GetLargestPossibleRegion() const;
00157
00163 virtual const RegionType& GetBufferedRegion() const;
00164
00166 inline void Allocate();
00167
00168
00171 virtual void Initialize();
00172
00174 void SetPixel(const IndexType &index, const PixelType & value)
00175 { m_PixelAccessor.Set( m_Image->GetPixel(index), value ); }
00176
00178 PixelType GetPixel(const IndexType &index) const
00179 { return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
00180
00182 PixelType operator[](const IndexType &index) const
00183 { return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
00184
00186 const OffsetValueType *GetOffsetTable() const;
00187
00189 IndexType ComputeIndex(OffsetValueType offset) const;
00190
00193 typedef typename TImage::PixelContainer PixelContainer;
00194 typedef typename TImage::PixelContainerPointer PixelContainerPointer;
00195 typedef typename TImage::PixelContainerConstPointer PixelContainerConstPointer;
00196
00198 PixelContainerPointer GetPixelContainer()
00199 { return m_Image->GetPixelContainer(); };
00200
00203 void SetPixelContainer( PixelContainer *container );
00204
00215 virtual void Graft(const DataObject *data);
00216
00218 typedef InternalPixelType * InternalPixelPointerType;
00219
00222 InternalPixelType *GetBufferPointer();
00223 const InternalPixelType *GetBufferPointer() const;
00225
00227 virtual void SetSpacing( const SpacingType values );
00228 virtual void SetSpacing( const double* values );
00229 virtual void SetSpacing( const float* values );
00231
00235 virtual const SpacingType& GetSpacing() const;
00236
00240 virtual const PointType& GetOrigin() const;
00241
00243 virtual void SetOrigin( const PointType values);
00244 virtual void SetOrigin( const double* values );
00245 virtual void SetOrigin( const float* values );
00247
00249 virtual void SetImage( TImage * );
00250
00252 virtual void Modified() const;
00253
00255 virtual unsigned long GetMTime() const;
00256
00258 AccessorType & GetPixelAccessor( void )
00259 { return m_PixelAccessor; }
00260
00262 const AccessorType & GetPixelAccessor( void ) const
00263 { return m_PixelAccessor; }
00264
00266 void SetPixelAccessor( const AccessorType & accessor )
00267 { m_PixelAccessor = accessor; }
00268
00270 virtual void Update();
00271 virtual void CopyInformation(const DataObject *data);
00273
00276 virtual void UpdateOutputInformation();
00277 virtual void SetRequestedRegionToLargestPossibleRegion();
00278 virtual void PropagateRequestedRegion() throw (InvalidRequestedRegionError);
00279 virtual void UpdateOutputData();
00280 virtual bool VerifyRequestedRegion();
00282
00283 protected:
00284 ImageAdaptor();
00285 virtual ~ImageAdaptor();
00286 void PrintSelf(std::ostream& os, Indent indent) const;
00287
00288 private:
00289 ImageAdaptor(const Self&);
00290 void operator=(const Self&);
00291
00292
00293
00294 typename TImage::Pointer m_Image;
00295
00296
00297
00298 AccessorType m_PixelAccessor;
00299
00300
00301 };
00302
00303 }
00304
00305 #ifndef ITK_MANUAL_INSTANTIATION
00306 #include "itkImageAdaptor.txx"
00307 #endif
00308
00309
00310
00311 #endif
00312
00313