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 }
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 }
00108
00109
00110 #endif
00111