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     }
00073 
00075   inline ExternalType Get( const InternalType & input, const unsigned long offset ) const
00076     {
00077     ExternalType output( (&input)+(offset*m_OffsetMultiplier) , m_VectorLength );
00078     return output;
00079     }
00080 
00082   void SetVectorLength( VectorLengthType l) 
00083     { 
00084     m_VectorLength = l; 
00085     m_OffsetMultiplier = (l-1); 
00086     }
00087 
00089   VectorLengthType GetVectorLength() const { return m_VectorLength; }
00090 
00091   DefaultVectorPixelAccessor() {}
00092 
00094   DefaultVectorPixelAccessor( VectorLengthType l ) 
00095     { 
00096     m_VectorLength = l; 
00097     m_OffsetMultiplier = l-1;
00098     }
00099   
00100   virtual ~DefaultVectorPixelAccessor() {};
00101   
00102 private:
00103   VectorLengthType m_VectorLength;
00104   VectorLengthType m_OffsetMultiplier;
00105 };
00106   
00107 } // end namespace itk
00108   
00109 
00110 #endif
00111 

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