ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkAddPixelAccessor.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkAddPixelAccessor_h
19 #define __itkAddPixelAccessor_h
20 
21 #include "itkNumericTraits.h"
22 
23 namespace itk
24 {
25 namespace Accessor
26 {
43 template< class TPixel >
44 class ITK_EXPORT AddPixelAccessor
45 {
46 public:
49 
52  typedef TPixel ExternalType;
53 
56  typedef TPixel InternalType;
57 
59  inline void Set(InternalType & output, const ExternalType & input) const
60  { output = static_cast< InternalType >( input - m_Value ); }
61 
63  inline ExternalType Get(const InternalType & input) const
64  { return static_cast< ExternalType >( input + m_Value ); }
65 
67  void SetValue(const TPixel & newvalue)
68  { m_Value = newvalue; }
69 
71  TPixel GetValue() const
72  { return m_Value; }
73 
75  Self & operator=(const Self & apa)
76  {
77  this->m_Value = apa.m_Value;
78  return *this;
79  }
80 
82  AddPixelAccessor():m_Value(NumericTraits< TPixel >::Zero) {}
83  AddPixelAccessor(const Self & apa):m_Value(apa.m_Value) {}
85 
86 private:
87 
88  TPixel m_Value;
89 };
90 } // end namespace Accessor
91 } // end namespace itk
92 
93 #endif
94