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

itkDefaultVectorPixelAccessor.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkDefaultVectorPixelAccessor.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/09/16 15:00:37 $
00007   Version:   $Revision: 1.5 $
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 __itkDefaultVectorPixelAccessor_h
00018 #define __itkDefaultVectorPixelAccessor_h
00019 
00020 #include "itkMacro.h"
00021 #include "itkVariableLengthVector.h"
00022 
00023 namespace itk
00024 {
00025 
00047 template <class TType > 
00048 class ITK_EXPORT DefaultVectorPixelAccessor  
00049 {
00050 public:
00051 
00052   typedef unsigned int VectorLengthType;
00053   
00058   typedef VariableLengthVector< TType >  ExternalType;
00059 
00061   typedef TType          InternalType;
00062 
00064   inline void Set(InternalType & output, const ExternalType & input, 
00065                                           const unsigned long offset ) const
00066     { 
00067     InternalType *truePixel = (&output) + offset*m_OffsetMultiplier;
00068     for( VectorLengthType i=0; i< m_VectorLength; i++ ) 
00069       { 
00070       truePixel[i] = input[i];
00071       }
00072     }
00074 
00076   inline ExternalType Get( const InternalType & input, const unsigned long offset ) const
00077     {
00078     ExternalType output( (&input)+(offset*m_OffsetMultiplier) , m_VectorLength );
00079     return output;
00080     }
00082 
00084   void SetVectorLength( VectorLengthType l) 
00085     { 
00086     m_VectorLength = l; 
00087     m_OffsetMultiplier = (l-1); 
00088     }
00090 
00092   VectorLengthType GetVectorLength() const { return m_VectorLength; }
00093 
00094   DefaultVectorPixelAccessor() {}
00095 
00097   DefaultVectorPixelAccessor( VectorLengthType l ) 
00098     { 
00099     m_VectorLength = l; 
00100     m_OffsetMultiplier = l-1;
00101     }
00102 
00103   virtual ~DefaultVectorPixelAccessor() {};
00104   
00105 private:
00106   VectorLengthType m_VectorLength;
00107   VectorLengthType m_OffsetMultiplier;
00108 };
00109   
00110 } // end namespace itk
00111   
00112 
00113 #endif
00114 
00115 

Generated at Tue Jul 29 19:43:57 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000