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: 2005/12/03 22:15:26 $
00007   Version:   $Revision: 1.58.2.1 $
00008 
00009   Copyright (c) Insight Software 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 #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 &region);
00120 
00124   virtual void SetBufferedRegion(const RegionType &region);
00125 
00129   virtual void SetRequestedRegion(const RegionType &region);
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 /*[ImageDimension]*/ );
00226   virtual void SetSpacing( const float* values /*[ImageDimension]*/ );
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 /*[ImageDimension]*/ );
00241   virtual void SetOrigin( const float* values /*[ImageDimension]*/ );
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&); //purposely not implemented
00283   void operator=(const Self&); //purposely not implemented
00284   
00285   // Adapted image, most of the calls to ImageAdaptor
00286   // will be delegated to this image
00287   typename TImage::Pointer   m_Image;
00288 
00289   // Data accessor object, 
00290   // it converts the presentation of a pixel
00291   AccessorType               m_PixelAccessor;
00292   
00293 
00294 };
00295   
00296 } // end namespace itk
00297 
00298 #ifndef ITK_MANUAL_INSTANTIATION
00299 #include "itkImageAdaptor.txx"
00300 #endif
00301   
00302   
00303 
00304 #endif
00305 

Generated at Wed May 24 23:19:01 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000