KWStyle - itkDefaultPixelAccessorFunctor.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkDefaultPixelAccessorFunctor.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:34 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) Insight Software Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17 #ifndef __itkDefaultPixelAccessorFunctor_h
18 #define __itkDefaultPixelAccessorFunctor_h
19
20 namespace itk
21 {
22 /** \class DefaultPixelAccessorFunctor
23  * \brief This class provides a common API for pixel accessors for Image and 
24 LEN  * VectorImage. (between the DefaultVectorPixelAccessor and DefaultPixelAccessor).
25  * 
26  * The pixel accessor is set with the SetPixelAccessor method. This accessor is 
27  * meant to be used for Image and not for VectorImage. 
28  *
29  * \thanks
30  * This work is part of the National Alliance for Medical Image Computing 
31  * (NAMIC), funded by the National Institutes of Health through the NIH Roadmap
32  * for Medical Research, Grant U54 EB005149.
33  *
34  * \ingroup ImageAdaptors
35  * 
36  * \sa DefaultVectorPixelAccessor
37  * \sa DefaultPixelAccessor
38  * \sa DefaultVectorPixelAccessorFunctor
39  */
40 template <class TImageType >
41 class ITK_EXPORT DefaultPixelAccessorFunctor
42 {
43 public:
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   
50   static void SetVectorLength( ImageType *, VectorLengthType )
51     { 
52     }
53
54   static VectorLengthType GetVectorLength( const ImageType * )
55     {
56     return 1;
57     } 
58   
59 LEN   /** Set the PixelAccessor. This is set at construction time by the image iterators. 
60 LEN    * The type PixelAccessorType is obtained from the ImageType over which the iterators
61    * are templated.
62    * */
63   inline void SetPixelAccessor( PixelAccessorType& accessor ) 
64     {
65     m_PixelAccessor = accessor;
66     }
67
68   /** Set the pointer index to the start of the buffer. 
69    * The method exists to maintain consistency in the API of the 
70    * DefaultPixelAccessorFunctor and the DefaultVectorPixelAccessorFunctor. */
71   inline void SetBegin( const InternalPixelType *itkNotUsed(begin) ) {};
72   
73   /** Set output using the value in input */
74 LEN   inline void Set( InternalPixelType & output, const ExternalPixelType &input ) const
75     {
76     m_PixelAccessor.Set( output, input );
77     }
78
79   /** Get the value from input */
80   inline ExternalPixelType Get( InternalPixelType &input ) const
81     {
82     return m_PixelAccessor.Get( input );
83     }
84
85   /** Get a const reference to the pixel. */
86   inline const ExternalPixelType Get( const InternalPixelType & input ) const
87     {
88     return m_PixelAccessor.Get( input );
89     }
90   
91 private:
92   PixelAccessorType m_PixelAccessor; // The pixel accessor
93 };
94
95 }
96
97 #endif    
98

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:05PM
© Kitware Inc.