00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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 }
00111
00112
00113 #endif
00114
00115