ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkAddPixelAccessor.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkAddPixelAccessor_h
00019 #define __itkAddPixelAccessor_h
00020 
00021 #include "itkNumericTraits.h"
00022 
00023 namespace itk
00024 {
00025 namespace Accessor
00026 {
00043 template< class TPixel >
00044 class ITK_EXPORT AddPixelAccessor
00045 {
00046 public:
00048   typedef   AddPixelAccessor Self;
00049 
00052   typedef     TPixel ExternalType;
00053 
00056   typedef     TPixel InternalType;
00057 
00059   inline void Set(InternalType & output, const ExternalType & input) const
00060   { output = static_cast< InternalType >( input - m_Value ); }
00061 
00063   inline ExternalType Get(const InternalType & input) const
00064   { return static_cast< ExternalType >( input + m_Value ); }
00065 
00067   void SetValue(const TPixel & newvalue)
00068   { m_Value = newvalue; }
00069 
00071   TPixel GetValue() const
00072   { return m_Value; }
00073 
00075   Self & operator=(const Self & apa)
00076   {
00077     this->m_Value = apa.m_Value;
00078     return *this;
00079   }
00080 
00082   AddPixelAccessor():m_Value(NumericTraits< TPixel >::Zero) {}
00083   AddPixelAccessor(const Self & apa):m_Value(apa.m_Value) {}
00084 private:
00086 
00087   TPixel m_Value;
00088 };
00089 }  // end namespace Accessor
00090 }  // end namespace itk
00091 
00092 #endif
00093