Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkNaryAddImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkNaryAddImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-04-01 14:36:31 $
00007   Version:   $Revision: 1.36 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkNaryAddImageFilter_h
00018 #define __itkNaryAddImageFilter_h
00019 
00020 #include "itkNaryFunctorImageFilter.h"
00021 #include "itkNumericTraits.h"
00022 
00023 namespace itk
00024 {
00025   
00055 namespace Functor {  
00056   
00057 template< class TInput, class TOutput >
00058 class Add1
00059 {
00060 public:
00061   typedef typename NumericTraits< TInput >::AccumulateType AccumulatorType;
00062   Add1() {}
00063   ~Add1() {}
00064   inline TOutput operator()( const std::vector< TInput > & B) const
00065     {
00066     AccumulatorType sum = NumericTraits< TOutput >::Zero;
00067     for( unsigned int i=0; i< B.size(); i++ )
00068       {
00069       sum += static_cast< TOutput >(B[i]);
00070       }
00071     return static_cast<TOutput>( sum );
00072     }
00073   bool operator== (const Add1&) const
00074     {
00075     return true;
00076     }
00077   bool operator!= (const Add1&) const
00078     {
00079     return false;
00080     }
00081 }; 
00082 }
00083 template <class TInputImage, class TOutputImage>
00084 class ITK_EXPORT NaryAddImageFilter :
00085     public
00086 NaryFunctorImageFilter<TInputImage,TOutputImage, 
00087                        Functor::Add1<typename TInputImage::PixelType,  typename TInputImage::PixelType > > 
00088 {
00089 public:
00091   typedef NaryAddImageFilter        Self;
00092   typedef NaryFunctorImageFilter<
00093     TInputImage,TOutputImage, 
00094     Functor::Add1<typename TInputImage::PixelType,  
00095                   typename TInputImage::PixelType> >
00096                                     Superclass;
00097   typedef SmartPointer<Self>        Pointer;
00098   typedef SmartPointer<const Self>  ConstPointer;
00099 
00101   itkNewMacro(Self);
00102 
00104   itkTypeMacro(NaryAddImageFilter, 
00105                NaryFunctorImageFilter);
00106 
00107 #ifdef ITK_USE_CONCEPT_CHECKING
00108 
00109   itkConceptMacro(InputConvertibleToOutputCheck,
00110     (Concept::Convertible<typename TInputImage::PixelType,
00111                           typename TOutputImage::PixelType>));
00112   itkConceptMacro(InputHasZeroCheck,
00113     (Concept::HasZero<typename TInputImage::PixelType>));
00114 
00116 #endif
00117 
00118 protected:
00119   NaryAddImageFilter() {}
00120   virtual ~NaryAddImageFilter() {}
00121 
00122 private:
00123   NaryAddImageFilter(const Self&); //purposely not implemented
00124   void operator=(const Self&); //purposely not implemented
00125 
00126 };
00127 
00128 } // end namespace itk
00129 
00130 
00131 #endif
00132 

Generated at Thu May 28 10:56:05 2009 for ITK by doxygen 1.5.5 written by Dimitri van Heesch, © 1997-2000