KWStyle - itkDefaultVectorPixelAccessorFunctor.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkDefaultVectorPixelAccessorFunctor.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 __itkDefaultVectorPixelAccessorFunctor_h
18 #define __itkDefaultVectorPixelAccessorFunctor_h
19
20 namespace itk
21 {
22 /** \class DefaultVectorPixelAccessorFunctor
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 only for VectorImage and not for Image. Prior to use, the
28  * start of the VectorImage buffer must also be set with the SetBegin method.
29  *
30  * \sa DefaultVectorPixelAccessor
31  * \sa DefaultPixelAccessor
32  * \sa DefaultPixelAccessorFunctor
33  * 
34  * \thanks
35  * This work is part of the National Alliance for Medical Image Computing 
36  * (NAMIC), funded by the National Institutes of Health through the NIH Roadmap
37  * for Medical Research, Grant U54 EB005149.
38  *
39  * \ingroup ImageAdaptors
40  */
41 template <class TImageType >
42 class ITK_EXPORT DefaultVectorPixelAccessorFunctor
43 {
44 public:
45
46   typedef TImageType                                   ImageType;
47   typedef typename ImageType::InternalPixelType        InternalPixelType;
48   typedef typename ImageType::PixelType                ExternalPixelType;
49   typedef typename ImageType::AccessorType             PixelAccessorType;
50   typedef unsigned int                                 VectorLengthType;
51   
52   static void SetVectorLength( ImageType *image, VectorLengthType length )
53     { 
54     image->SetVectorLength( length );
55     }
56
57   static VectorLengthType GetVectorLength( const ImageType * image )
58     {
59     return image->GetVectorLength();
60     } 
61   
62 LEN   /** Set the PixelAccessor. This is set at construction time by the image iterators. 
63 LEN    * The type PixelAccessorType is obtained from the ImageType over which the iterators
64    * are templated.
65    * */
66   inline void SetPixelAccessor( PixelAccessorType& accessor ) 
67     {
68     m_PixelAccessor = accessor;
69     }
70   
71   /** Set the pointer index to the start of the buffer. */
72   inline void SetBegin( const InternalPixelType * begin ) 
73     { this->m_Begin = const_cast< InternalPixelType * >( begin ); }
74   
75   /** Set output using the value in input */
76 LEN   inline void Set( InternalPixelType & output, const ExternalPixelType &input ) const
77     {
78     m_PixelAccessor.Set( output, input, (&output)-m_Begin );
79     }
80
81   /** Get the value from input */
82   inline ExternalPixelType Get( const InternalPixelType &input ) const
83     {
84     return m_PixelAccessor.Get( input, &input  - m_Begin );
85     }
86
87 private:
88   PixelAccessorType m_PixelAccessor; // The pixel accessor
89   InternalPixelType *m_Begin; // Begin of the buffer
90 };
91
92 }
93
94 #endif    
95

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