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: 2006/03/29 14:53:40 $
00007   Version:   $Revision: 1.30 $
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 
00024 namespace itk
00025 {
00026   
00056 namespace Functor {  
00057   
00058 template< class TInput, class TOutput >
00059 class Add1
00060 {
00061 public:
00062   typedef typename NumericTraits< TInput >::AccumulateType AccumulatorType;
00063   Add1() {}
00064   ~Add1() {}
00065   inline TOutput operator()( const Array< TInput > & B)
00066   {
00067     AccumulatorType sum = NumericTraits< TOutput >::Zero;
00068     for( unsigned int i=0; i< B.size(); i++ )
00069       {
00070       sum += static_cast< TOutput >(B[i]);
00071       }       
00072     return static_cast<TOutput>( sum );
00073   }
00074   bool operator== (const Add1&) const
00075   {
00076     return true;
00077   }
00078   bool operator!= (const Add1&) const
00079   {
00080     return false;
00081   }
00082 }; 
00083 }
00084 template <class TInputImage, class TOutputImage>
00085 class ITK_EXPORT NaryAddImageFilter :
00086     public
00087 NaryFunctorImageFilter<TInputImage,TOutputImage, 
00088                        Functor::Add1<typename TInputImage::PixelType,  typename TInputImage::PixelType > > 
00089 {
00090 public:
00092   typedef NaryAddImageFilter  Self;
00093   typedef NaryFunctorImageFilter<TInputImage,TOutputImage, 
00094                                  Functor::Add1<typename TInputImage::PixelType,  
00095                                  typename TInputImage::PixelType  > >  Superclass;
00096   typedef SmartPointer<Self>   Pointer;
00097   typedef SmartPointer<const Self>  ConstPointer;
00098 
00100   itkNewMacro(Self);
00101 
00102 #ifdef ITK_USE_CONCEPT_CHECKING
00103 
00104   itkConceptMacro(InputConvertibleToOutputCheck,
00105     (Concept::Convertible<typename TInputImage::PixelType,
00106                           typename TOutputImage::PixelType>));
00107   itkConceptMacro(InputHasNumericTraitsCheck,
00108     (Concept::HasNumericTraits<typename TInputImage::PixelType>));
00109 
00111 #endif
00112 
00113 protected:
00114   NaryAddImageFilter() {}
00115   virtual ~NaryAddImageFilter() {}
00116 
00117 private:
00118   NaryAddImageFilter(const Self&); //purposely not implemented
00119   void operator=(const Self&); //purposely not implemented
00120 
00121 };
00122 
00123 } // end namespace itk
00124 
00125 
00126 #endif
00127 

Generated at Sat Sep 2 20:53:53 2006 for ITK by doxygen 1.4.7 written by Dimitri van Heesch, © 1997-2000