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
00022 namespace itk
00023 {
00024
00046 template <class TImage, class TAccessor >
00047 class ITK_EXPORT ImageAdaptor : public ImageBase< ::itk::GetImageDimension<TImage>::ImageDimension>
00048 {
00049 public:
00054 itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension);
00055
00057 typedef ImageAdaptor Self;
00058 typedef ImageBase<itkGetStaticConstMacro(ImageDimension)> Superclass;
00059 typedef SmartPointer<Self> Pointer;
00060 typedef SmartPointer<const Self> ConstPointer;
00061 typedef WeakPointer<const Self> ConstWeakPointer;
00062
00064 itkTypeMacro(ImageAdaptor, ImageBase);
00065
00067 typedef TImage InternalImageType;
00068
00070 itkNewMacro(Self);
00071
00074 typedef typename TAccessor::ExternalType PixelType;
00075
00078 typedef typename TAccessor::InternalType InternalPixelType;
00079
00082 typedef TAccessor AccessorType;
00083
00085 typedef typename Superclass::IndexType IndexType;
00086 typedef typename IndexType::IndexValueType IndexValueType;
00087
00089 typedef typename Superclass::SizeType SizeType;
00090 typedef typename SizeType::SizeValueType SizeValueType;
00091
00093 typedef typename Superclass::OffsetType OffsetType;
00094 typedef typename OffsetType::OffsetValueType OffsetValueType;
00095
00098 typedef typename Superclass::RegionType RegionType;
00099
00102 typedef typename Superclass::SpacingType SpacingType;
00103
00106 typedef typename Superclass::PointType PointType;
00107
00114 virtual void SetLargestPossibleRegion(const RegionType ®ion);
00115
00119 virtual void SetBufferedRegion(const RegionType ®ion);
00120
00124 virtual void SetRequestedRegion(const RegionType ®ion);
00125
00130 virtual void SetRequestedRegion(DataObject *data);
00131
00138 virtual const RegionType & GetRequestedRegion() const;
00139
00148 virtual const RegionType& GetLargestPossibleRegion() const;
00149
00155 virtual const RegionType& GetBufferedRegion() const;
00156
00158 inline void Allocate();
00159
00160
00163 virtual void Initialize();
00164
00166 void SetPixel(const IndexType &index, const PixelType & value)
00167 { m_PixelAccessor.Set( m_Image->GetPixel(index), value ); }
00168
00170 PixelType GetPixel(const IndexType &index) const
00171 { return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
00172
00174 PixelType operator[](const IndexType &index) const
00175 { return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
00176
00178 const OffsetValueType *GetOffsetTable() const;
00179
00181 IndexType ComputeIndex(OffsetValueType offset) const;
00182
00185 typedef typename TImage::PixelContainer PixelContainer;
00186 typedef typename TImage::PixelContainerPointer PixelContainerPointer;
00187 typedef typename TImage::PixelContainerConstPointer PixelContainerConstPointer;
00188
00190 PixelContainerPointer GetPixelContainer()
00191 { return m_Image->GetPixelContainer(); };
00192
00195 void SetPixelContainer( PixelContainer *container );
00196
00207 virtual void Graft(const Superclass *data);
00208
00210 typedef InternalPixelType * InternalPixelPointerType;
00211
00214 InternalPixelType *GetBufferPointer();
00215 const InternalPixelType *GetBufferPointer() const;
00216 void GetBufferPointer2( InternalPixelPointerType & );
00217
00219 virtual void SetSpacing( const SpacingType values );
00220 virtual void SetSpacing( const double values[ImageDimension] );
00221 virtual void SetSpacing( const float values[ImageDimension] );
00222
00226 virtual const SpacingType& GetSpacing() const;
00227
00231 virtual const PointType& GetOrigin() const;
00232
00234 virtual void SetOrigin( const PointType values);
00235 virtual void SetOrigin( const double values[ImageDimension] );
00236 virtual void SetOrigin( const float values[ImageDimension] );
00237
00239 virtual void SetImage( TImage * );
00240
00242 virtual void Modified() const;
00243
00245 virtual unsigned long GetMTime() const;
00246
00248 AccessorType & GetPixelAccessor( void )
00249 { return m_PixelAccessor; }
00250
00252 const AccessorType & GetPixelAccessor( void ) const
00253 { return m_PixelAccessor; }
00254
00256 void SetPixelAccessor( const AccessorType & accessor )
00257 { m_PixelAccessor = accessor; }
00258
00260 virtual void Update();
00261 virtual void CopyInformation(const DataObject *data);
00262
00265 virtual void UpdateOutputInformation();
00266 virtual void SetRequestedRegionToLargestPossibleRegion();
00267 virtual void PropagateRequestedRegion() throw (InvalidRequestedRegionError);
00268 virtual void UpdateOutputData();
00269 virtual bool VerifyRequestedRegion();
00270
00271 protected:
00272 ImageAdaptor();
00273 virtual ~ImageAdaptor();
00274 void PrintSelf(std::ostream& os, Indent indent) const;
00275
00276 private:
00277 ImageAdaptor(const Self&);
00278 void operator=(const Self&);
00279
00280
00281
00282 typename TImage::Pointer m_Image;
00283
00284
00285
00286 AccessorType m_PixelAccessor;
00287
00288
00289 };
00290
00291 }
00292
00293 #ifndef ITK_MANUAL_INSTANTIATION
00294 #include "itkImageAdaptor.txx"
00295 #endif
00296
00297
00298
00299 #endif
00300