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: 2009-03-03 15:11:40 $
00007   Version:   $Revision: 1.22 $
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 
00122   typedef VectorImageNeighborhoodAccessorFunctor< 
00123                           Self >              NeighborhoodAccessorFunctorType;
00124 
00129   itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);
00130 
00132   typedef ImportImageContainer<unsigned long, InternalPixelType> PixelContainer;
00133 
00135   typedef typename Superclass::IndexType       IndexType;
00136   typedef typename Superclass::IndexValueType  IndexValueType;
00137 
00139   typedef typename Superclass::OffsetType OffsetType;
00140 
00142   typedef typename Superclass::SizeType  SizeType;
00143 
00145   typedef typename Superclass::DirectionType  DirectionType;
00146 
00148   typedef typename Superclass::RegionType  RegionType;
00149 
00152   typedef typename Superclass::SpacingType SpacingType;
00153 
00156   typedef typename Superclass::PointType PointType;
00157 
00159   typedef typename PixelContainer::Pointer      PixelContainerPointer;
00160   typedef typename PixelContainer::ConstPointer PixelContainerConstPointer;
00161 
00163   typedef typename Superclass::OffsetValueType OffsetValueType;
00164 
00165   typedef unsigned int VectorLengthType;
00166 
00169   void Allocate();
00170 
00174   void SetRegions(RegionType region)
00175     {
00176     this->SetLargestPossibleRegion(region);
00177     this->SetBufferedRegion(region);
00178     this->SetRequestedRegion(region);
00179     }
00181 
00182   void SetRegions(SizeType size)
00183     {
00184     RegionType region; region.SetSize(size);
00185     this->SetLargestPossibleRegion(region);
00186     this->SetBufferedRegion(region);
00187     this->SetRequestedRegion(region);
00188     }
00189 
00192   virtual void Initialize();
00193 
00196   void FillBuffer(const PixelType& value);
00197 
00203    void SetPixel( const IndexType &index, const PixelType& value )
00204     {
00205     OffsetValueType offset = m_VectorLength * this->ComputeOffset(index);
00206     for( VectorLengthType i = 0; i < m_VectorLength; i++ )
00207       {
00208       (*m_Buffer)[offset + i] = value[i];
00209       }
00210     }
00211 
00217   const PixelType GetPixel(const IndexType &index) const
00218     {
00219     OffsetValueType offset = m_VectorLength * this->ComputeOffset(index);
00220     PixelType p( &((*m_Buffer)[offset]), m_VectorLength ); 
00221     return p;
00222     }
00223 
00228   PixelType  GetPixel(const IndexType &index )
00229     {
00230     OffsetValueType offset = m_VectorLength * this->ComputeOffset(index);
00231     PixelType p( &((*m_Buffer)[offset]), m_VectorLength ); 
00232     return p;
00233     }
00234 
00240   PixelType operator[](const IndexType &index)
00241     { return this->GetPixel(index); }
00242 
00248   PixelType operator[](const IndexType &index) const
00249      { return this->GetPixel(index); }
00250 
00253   InternalPixelType * GetBufferPointer()
00254     { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00255   const InternalPixelType *GetBufferPointer() const
00256     { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00258 
00260   PixelContainer* GetPixelContainer()
00261     { return m_Buffer.GetPointer(); }
00262 
00264   const PixelContainer* GetPixelContainer() const
00265     { return m_Buffer.GetPointer(); }
00266 
00269   void SetPixelContainer( PixelContainer *container );
00270 
00281   virtual void Graft(const DataObject *data);
00282 
00284   AccessorType GetPixelAccessor( void ) 
00285     { return AccessorType( m_VectorLength ); }
00286 
00288   const AccessorType GetPixelAccessor( void ) const
00289     { return AccessorType( m_VectorLength ); }
00290 
00292   NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() 
00293     { return NeighborhoodAccessorFunctorType( m_VectorLength ); }
00294 
00296   const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
00297     { return NeighborhoodAccessorFunctorType(m_VectorLength); }
00298 
00299   
00301   itkSetMacro( VectorLength, VectorLengthType );
00302   itkGetConstReferenceMacro( VectorLength, VectorLengthType );
00304 
00306   virtual unsigned int GetNumberOfComponentsPerPixel() const;
00307   virtual void SetNumberOfComponentsPerPixel( unsigned int  n );
00309 
00310 protected:
00311   VectorImage();
00312   void PrintSelf( std::ostream& os, Indent indent ) const;
00313   virtual ~VectorImage() {}
00314   
00315 private:
00316   VectorImage( const Self & ); // purposely not implementated
00317   void operator=(const Self&); //purposely not implemented
00318  
00320   VectorLengthType m_VectorLength;
00321 
00323   PixelContainerPointer m_Buffer;
00324 }; 
00325 
00326 
00327 } // end namespace itk
00328 
00329 // Define instantiation macro for this template.
00330 #define ITK_TEMPLATE_VectorImage(_, EXPORT, x, y) namespace itk { \
00331   _(2(class EXPORT VectorImage< ITK_TEMPLATE_2 x >)) \
00332   namespace Templates { typedef VectorImage< ITK_TEMPLATE_2 x > VectorImage##y; } \
00333   }
00334 
00335 #if ITK_TEMPLATE_EXPLICIT
00336 # include "Templates/itkVectorImage+-.h"
00337 #endif
00338 
00339 #if ITK_TEMPLATE_TXX
00340 # include "itkVectorImage.txx"
00341 #endif
00342 
00343 #endif
00344 

Generated at Mon Jul 12 2010 20:10:12 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000