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

itkVectorImage.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkVectorImage.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-10-19 20:27:36 $
00007   Version:   $Revision: 1.21 $
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 __itkVectorImage_h
00018 #define __itkVectorImage_h
00019 
00020 #include "itkImageBase.h"
00021 #include "itkImageRegion.h"
00022 #include "itkImportImageContainer.h"
00023 #include "itkDefaultVectorPixelAccessor.h"
00024 #include "itkDefaultVectorPixelAccessorFunctor.h"
00025 #include "itkVectorImageNeighborhoodAccessorFunctor.h"
00026 #include "itkPoint.h"
00027 #include "itkContinuousIndex.h"
00028 #include "itkVariableLengthVector.h"
00029 #include "itkWeakPointer.h"
00030 
00031 namespace itk
00032 {
00033 
00078 template <class TPixel, unsigned int VImageDimension=3 >
00079 class ITK_EXPORT VectorImage : 
00080     public ImageBase< VImageDimension >
00081 {
00082 public:
00084   typedef VectorImage                  Self;
00085   typedef ImageBase< VImageDimension > Superclass;
00086   typedef SmartPointer<Self>           Pointer;
00087   typedef SmartPointer<const Self>     ConstPointer;
00088   typedef WeakPointer<const Self>      ConstWeakPointer;
00089 
00091   itkNewMacro(Self);
00092 
00094   itkTypeMacro(VectorImage, ImageBase);
00095 
00100   typedef VariableLengthVector< TPixel > PixelType;
00101 
00105   typedef TPixel InternalPixelType;
00106 
00108   typedef PixelType ValueType;
00109 
00110   typedef InternalPixelType  IOPixelType;
00111 
00114   typedef DefaultVectorPixelAccessor< InternalPixelType > AccessorType;
00115 
00118   typedef DefaultVectorPixelAccessorFunctor< Self >       AccessorFunctorType;
00119 
00121   typedef VectorImageNeighborhoodAccessorFunctor< 
00122                           Self >              NeighborhoodAccessorFunctorType;
00123 
00128   itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);
00129 
00131   typedef ImportImageContainer<unsigned long, InternalPixelType> PixelContainer;
00132 
00134   typedef typename Superclass::IndexType       IndexType;
00135   typedef typename Superclass::IndexValueType  IndexValueType;
00136 
00138   typedef typename Superclass::OffsetType OffsetType;
00139 
00141   typedef typename Superclass::SizeType  SizeType;
00142 
00144   typedef typename Superclass::DirectionType  DirectionType;
00145 
00147   typedef typename Superclass::RegionType  RegionType;
00148 
00151   typedef typename Superclass::SpacingType SpacingType;
00152 
00155   typedef typename Superclass::PointType PointType;
00156 
00158   typedef typename PixelContainer::Pointer PixelContainerPointer;
00159   typedef typename PixelContainer::ConstPointer PixelContainerConstPointer;
00160 
00162   typedef typename Superclass::OffsetValueType OffsetValueType;
00163 
00164   typedef unsigned int VectorLengthType;
00165 
00168   void Allocate();
00169 
00173   void SetRegions(RegionType region)
00174     {
00175     this->SetLargestPossibleRegion(region);
00176     this->SetBufferedRegion(region);
00177     this->SetRequestedRegion(region);
00178     };
00180 
00181   void SetRegions(SizeType size)
00182     {
00183     RegionType region; region.SetSize(size);
00184     this->SetLargestPossibleRegion(region);
00185     this->SetBufferedRegion(region);
00186     this->SetRequestedRegion(region);
00187     };
00188 
00191   virtual void Initialize();
00192 
00195   void FillBuffer(const PixelType& value);
00196 
00202    void SetPixel( const IndexType &index, const PixelType& value )
00203     {
00204     OffsetValueType offset = m_VectorLength * this->ComputeOffset(index);
00205     for( VectorLengthType i = 0; i < m_VectorLength; i++ )
00206       {
00207       (*m_Buffer)[offset + i] = value[i];
00208       }
00209     }
00210 
00216   const PixelType GetPixel(const IndexType &index) const
00217     {
00218     OffsetValueType offset = m_VectorLength * this->ComputeOffset(index);
00219     PixelType p( &((*m_Buffer)[offset]), m_VectorLength ); 
00220     return p;
00221     }
00222 
00227   PixelType  GetPixel(const IndexType &index )
00228     {
00229     OffsetValueType offset = m_VectorLength * this->ComputeOffset(index);
00230     PixelType p( &((*m_Buffer)[offset]), m_VectorLength ); 
00231     return p;
00232     }
00233 
00239   PixelType operator[](const IndexType &index)
00240      { return this->GetPixel(index); }
00241 
00247   PixelType operator[](const IndexType &index) const
00248      { return this->GetPixel(index); }
00249 
00252   InternalPixelType * GetBufferPointer()
00253     { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00254   const InternalPixelType *GetBufferPointer() const
00255     { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00257 
00259   PixelContainer* GetPixelContainer()
00260     { return m_Buffer.GetPointer(); }
00261 
00263   const PixelContainer* GetPixelContainer() const
00264     { return m_Buffer.GetPointer(); }
00265 
00268   void SetPixelContainer( PixelContainer *container );
00269 
00280   virtual void Graft(const DataObject *data);
00281 
00283   AccessorType GetPixelAccessor( void ) 
00284     { return AccessorType( m_VectorLength ); }
00285 
00287   const AccessorType GetPixelAccessor( void ) const
00288     { return AccessorType( m_VectorLength ); }
00289 
00291   NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() 
00292     { return NeighborhoodAccessorFunctorType( m_VectorLength ); }
00293 
00295   const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
00296     { return NeighborhoodAccessorFunctorType(m_VectorLength); }
00297 
00298   
00300   itkSetMacro( VectorLength, VectorLengthType );
00301   itkGetConstReferenceMacro( VectorLength, VectorLengthType );
00303 
00305   virtual unsigned int GetNumberOfComponentsPerPixel() const;
00306   virtual void SetNumberOfComponentsPerPixel( unsigned int  n );
00308 
00309 protected:
00310   VectorImage();
00311   void PrintSelf( std::ostream& os, Indent indent ) const;
00312   virtual ~VectorImage() {};
00313   
00314 private:
00315   VectorImage( const Self & ); // purposely not implementated
00316   void operator=(const Self&); //purposely not implemented
00317  
00319   VectorLengthType m_VectorLength;
00320 
00322   PixelContainerPointer m_Buffer;
00323 }; 
00324 
00325 
00326 } // end namespace itk
00327 
00328 // Define instantiation macro for this template.
00329 #define ITK_TEMPLATE_VectorImage(_, EXPORT, x, y) namespace itk { \
00330   _(2(class EXPORT VectorImage< ITK_TEMPLATE_2 x >)) \
00331   namespace Templates { typedef VectorImage< ITK_TEMPLATE_2 x > VectorImage##y; } \
00332   }
00333 
00334 #if ITK_TEMPLATE_EXPLICIT
00335 # include "Templates/itkVectorImage+-.h"
00336 #endif
00337 
00338 #if ITK_TEMPLATE_TXX
00339 # include "itkVectorImage.txx"
00340 #endif
00341 
00342 #endif
00343 

Generated at Sat Feb 28 13:46:11 2009 for ITK by doxygen 1.5.6 written by Dimitri van Heesch, © 1997-2000