Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkImageAdaptor.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkImageAdaptor.h,v $
00005   Language:  C++
00006   Date:      $Date: 2003/02/25 05:00:38 $
00007   Version:   $Revision: 1.41 $
00008 
00009   Copyright (c) 2002 Insight Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
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   
00063   itkTypeMacro(ImageAdaptor, ImageBase);
00064 
00066   typedef TImage InternalImageType;
00067   
00069   itkNewMacro(Self);  
00070 
00073   typedef typename TAccessor::ExternalType PixelType;
00074 
00077   typedef typename TAccessor::InternalType InternalPixelType;
00078 
00081   typedef   TAccessor   AccessorType;
00082 
00084   typedef Index<itkGetStaticConstMacro(ImageDimension)>  IndexType;
00085   typedef typename IndexType::IndexValueType    IndexValueType;
00086   
00088   typedef Size<itkGetStaticConstMacro(ImageDimension)>   SizeType;
00089   typedef typename SizeType::SizeValueType      SizeValueType;
00090     
00092   typedef Offset<itkGetStaticConstMacro(ImageDimension)> OffsetType;
00093   typedef typename OffsetType::OffsetValueType  OffsetValueType;
00094     
00097   typedef ImageRegion<itkGetStaticConstMacro(ImageDimension)> RegionType;
00098 
00105   virtual void SetLargestPossibleRegion(const RegionType &region);
00106 
00110   virtual void SetBufferedRegion(const RegionType &region);
00111 
00115   virtual void SetRequestedRegion(const RegionType &region);
00116 
00121   virtual void SetRequestedRegion(DataObject *data);
00122 
00129   virtual const RegionType & GetRequestedRegion() const;
00130 
00139   virtual const RegionType& GetLargestPossibleRegion() const;
00140 
00146   virtual const RegionType& GetBufferedRegion() const;
00147 
00149   inline void Allocate();
00150 
00151 
00154   virtual void Initialize();
00155 
00157   void SetPixel(const IndexType &index, const PixelType & value)
00158     { m_PixelAccessor.Set( m_Image->GetPixel(index), value ); }
00159   
00161   PixelType GetPixel(const IndexType &index) const
00162     { return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
00163 
00165   PixelType operator[](const IndexType &index) const
00166     { return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
00167 
00169   const OffsetValueType *GetOffsetTable() const;
00170 
00172   IndexType ComputeIndex(OffsetValueType offset) const;
00173 
00176   typedef typename TImage::PixelContainer        PixelContainer;
00177   typedef typename TImage::PixelContainerPointer PixelContainerPointer;
00178   
00180   PixelContainerPointer GetPixelContainer()
00181     { return m_Image->GetPixelContainer(); };
00182 
00185   void SetPixelContainer( PixelContainer *container );
00186   
00188   typedef InternalPixelType * InternalPixelPointerType;
00189 
00192   InternalPixelType *GetBufferPointer();
00193   const InternalPixelType *GetBufferPointer() const;
00194   void GetBufferPointer2( InternalPixelPointerType  & );
00195   
00197   virtual void SetSpacing( const double values[TImage::ImageDimension] );
00198   virtual void SetSpacing( const float values[TImage::ImageDimension] );
00199   
00204   virtual const double* GetSpacing() const;
00205  
00210   virtual const double * GetOrigin() const;
00211 
00213   virtual void SetOrigin( const double values[TImage::ImageDimension] );
00214   virtual void SetOrigin( const float values[TImage::ImageDimension] );
00215   
00217   virtual void SetImage( TImage * );
00218 
00220   virtual void Modified() const;
00221 
00223   virtual unsigned long GetMTime() const;
00224 
00226   AccessorType & GetPixelAccessor( void ) 
00227     { return m_PixelAccessor; }
00228     
00230   const AccessorType & GetPixelAccessor( void ) const
00231     { return m_PixelAccessor; }
00232 
00234   virtual void Update();
00235   virtual void UpdateOutputInformation();
00236   virtual void SetRequestedRegionToLargestPossibleRegion();
00237   virtual void CopyInformation(const DataObject *data);
00238    
00239 protected:
00240   ImageAdaptor();
00241   virtual ~ImageAdaptor();
00242   void PrintSelf(std::ostream& os, Indent indent) const;
00243   
00244 private:
00245   ImageAdaptor(const Self&); //purposely not implemented
00246   void operator=(const Self&); //purposely not implemented
00247   
00248   // Adapted image, most of the calls to ImageAdaptor
00249   // will be delegated to this image
00250   typename TImage::Pointer   m_Image;
00251 
00252   // Data accessor object, 
00253   // it converts the presentation of a pixel
00254   AccessorType               m_PixelAccessor;
00255   
00256 
00257 };
00258   
00259 } // end namespace itk
00260 
00261 #ifndef ITK_MANUAL_INSTANTIATION
00262 #include "itkImageAdaptor.txx"
00263 #endif
00264   
00265   
00266 
00267 #endif
00268 

Generated at Fri May 21 01:14:52 2004 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000