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

itkVectorImageNeighborhoodAccessorFunctor.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkVectorImageNeighborhoodAccessorFunctor.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/10/31 22:16:43 $
00007   Version:   $Revision: 1.3 $
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 __itkVectorImageNeighborhoodAccessorFunctor_h
00018 #define __itkVectorImageNeighborhoodAccessorFunctor_h
00019 
00020 #include "itkVariableLengthVector.h"
00021 #include "itkImageBoundaryCondition.h"
00022 #include "itkNeighborhood.h"
00023 #include "itkImageBase.h"
00024 
00025 namespace itk
00026 {
00027  
00040 template< class TImage >
00041 class VectorImageNeighborhoodAccessorFunctor
00042 {
00043 public:
00044   typedef TImage                                ImageType;
00045   typedef typename ImageType::PixelType         PixelType;
00046   typedef typename ImageType::InternalPixelType InternalPixelType;
00047   typedef unsigned int                          VectorLengthType;
00048   typedef typename ImageType::OffsetType        OffsetType;
00049 
00050   typedef Neighborhood< InternalPixelType *,
00051           ::itk::GetImageDimension< TImage >::ImageDimension> NeighborhoodType;
00052 
00053   typedef ImageBoundaryCondition< ImageType > const 
00054                           *ImageBoundaryConditionConstPointerType;
00055   
00056   VectorImageNeighborhoodAccessorFunctor( VectorLengthType length ) 
00057       : m_VectorLength( length ), m_OffsetMultiplier( length -1 ) { };
00058   VectorImageNeighborhoodAccessorFunctor() 
00059       : m_VectorLength( 0 ), m_OffsetMultiplier( 0 ) {};
00060   
00074   inline void SetBegin( const InternalPixelType * begin ) 
00075     { this->m_Begin = const_cast< InternalPixelType * >( begin ); }
00076 
00084   inline PixelType Get( const InternalPixelType *pixelPointer ) const 
00085     { 
00086     return PixelType(pixelPointer+(pixelPointer-m_Begin)*m_OffsetMultiplier, m_VectorLength);
00087     }
00088   
00090   inline void Set( InternalPixelType* &pixelPointer, const PixelType &p ) const
00091     {
00092     InternalPixelType *truePixelPointer = 
00093       pixelPointer + (pixelPointer-m_Begin)*m_OffsetMultiplier;
00094     for( VectorLengthType i=0; i< m_VectorLength; i++ ) 
00095       { 
00096       truePixelPointer[i] = p[i];
00097       }
00098     }
00099  
00100   inline PixelType BoundaryCondition( 
00101       const OffsetType& point_index,
00102       const OffsetType &boundary_offset, 
00103       const NeighborhoodType *data,
00104       const ImageBoundaryConditionConstPointerType boundaryCondition) const
00105     {
00106     return boundaryCondition->operator()(point_index, boundary_offset, data, *this);
00107     }
00108 
00109 
00112   void SetVectorLength( VectorLengthType length )
00113     { 
00114     m_VectorLength = length;
00115     m_OffsetMultiplier = length - 1;
00116     }
00117 
00120   VectorLengthType GetVectorLength()
00121     {
00122     return m_VectorLength;
00123     }
00124    
00125 private:
00126    VectorLengthType m_VectorLength; 
00127    VectorLengthType m_OffsetMultiplier; // m_OffsetMultiplier = m_VectorLength-1
00128                                         // (precomputed for speedup).
00129    InternalPixelType *m_Begin; // Begin of the buffer. 
00130 };
00131 
00132 
00133 } // end namespace itk
00134 #endif

Generated at Thu May 25 00:12:56 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000