DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
itkSpatiallyDenseSparseVectorImagePixelAccessorFunctor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Spatially Dense Sparse Vector Image Pixel Accessor Functor
4 
5  Copyright (c) Pew-Thian Yap. All rights reserved.
6  See http://www.unc.edu/~ptyap/ for details.
7 
8  This software is distributed WITHOUT ANY WARRANTY; without even
9  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10  PURPOSE. See the above copyright notices for more information.
11 
12  =========================================================================*/
13 
14 #ifndef __itkSpatiallyDenseSparseVectorImagePixelAccessorFunctor_h
15 #define __itkSpatiallyDenseSparseVectorImagePixelAccessorFunctor_h
16 
17 #include "itkMacro.h"
18 
19 
20 namespace itk
21 {
39 template <class TImageType >
41 {
42 public:
43 
44  typedef TImageType ImageType;
45  typedef typename ImageType::InternalPixelType InternalPixelType;
46  typedef typename ImageType::PixelType ExternalPixelType;
47  typedef typename ImageType::AccessorType PixelAccessorType;
48  typedef unsigned int VectorLengthType;
49 
54  inline void SetPixelAccessor( PixelAccessorType& accessor )
55  {
56  m_PixelAccessor = accessor;
57  }
58 
60  inline void SetBegin( const InternalPixelType * begin ) // NOTE: begin is always 0
61  {
62  this->m_Begin = const_cast< InternalPixelType * >( begin );
63  }
64 
66  inline void Set( InternalPixelType & output, const ExternalPixelType &input ) const
67  {
68  m_PixelAccessor.Set( output, input, (&output)-m_Begin ); // NOTE: begin is always 0
69  }
70 
72  inline ExternalPixelType Get( const InternalPixelType &input ) const
73  {
74  return m_PixelAccessor.Get( input, (&input)-m_Begin ); // NOTE: begin is always 0
75  }
76 
78  static void SetVectorLength( ImageType *image, VectorLengthType length)
79  {
80  image->SetVectorLength(length);
81  }
82 
84  static VectorLengthType GetVectorLength( const ImageType *image)
85  {
86  return image->GetVectorLength();
87  }
88 
89 private:
90  PixelAccessorType m_PixelAccessor; // The pixel accessor
91  InternalPixelType *m_Begin; // Begin of the buffer, always 0
92 };
93 
94 }
95 
96 #endif
void Set(InternalPixelType &output, const ExternalPixelType &input) const
Provides accessor interfaces to Access pixels and is meant to be used by iterators.