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

itkAdaptImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkAdaptImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2006-03-19 04:36:55 $
00007   Version:   $Revision: 1.17 $
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 __itkAdaptImageFilter_h
00018 #define __itkAdaptImageFilter_h
00019 
00020 #include "itkUnaryFunctorImageFilter.h"
00021 
00022 namespace itk
00023 {
00024 
00025 namespace Functor {  
00026   
00036 template <class TInput, class TAccessor>
00037 class AccessorFunctor
00038 {
00039 public:
00041   typedef AccessorFunctor Self;
00042   typedef TAccessor AccessorType;
00043 
00045   AccessorFunctor(): m_Accessor() {}
00046   ~AccessorFunctor() {}
00048 
00050   typedef typename TAccessor::ExternalType OutputType;
00051   inline OutputType operator()( const TInput & A )
00052   { return m_Accessor.Get( A ); }
00054 
00056   AccessorType& GetAccessor() 
00057   { return m_Accessor; }
00058 
00060   AccessorFunctor & operator=( const AccessorFunctor & functor )
00061   { m_Accessor = functor.m_Accessor; 
00062   return *this;}
00063 
00069   void SetAccessor(AccessorType& accessor) 
00070   { m_Accessor = accessor; };
00071 
00073   bool operator!=( const Self& functor ) const
00074   {
00075     return (m_Accessor != functor.m_Accessor);
00076   }
00077   bool operator==( const Self& other ) const
00078   {
00079     return !(*this != other);
00080   }
00082 
00083 private:
00084   AccessorType m_Accessor;
00085 }; 
00086 }
00087 
00114 template <class TInputImage, class TOutputImage, class TAccessor>
00115 class ITK_EXPORT AdaptImageFilter:
00116     public UnaryFunctorImageFilter<TInputImage,TOutputImage,Functor::AccessorFunctor<ITK_TYPENAME TInputImage::PixelType, TAccessor> >
00117 {
00118 public:
00120   typedef AdaptImageFilter  Self;
00121   typedef UnaryFunctorImageFilter< TInputImage,
00122                                    TOutputImage,
00123                                    Functor::AccessorFunctor<
00124     ITK_TYPENAME TInputImage::PixelType, 
00125     TAccessor> >  Superclass;
00126 
00127   typedef SmartPointer<Self>   Pointer;
00128   typedef SmartPointer<const Self>  ConstPointer;
00129   typedef typename Superclass::FunctorType FunctorType;
00130 
00132   itkNewMacro(Self);
00133 
00135   typedef TAccessor AccessorType;
00136 
00138   itkTypeMacro(AdaptImageFilter, UnaryFunctorImageFilter);
00139 
00141   AccessorType& GetAccessor() { return this->GetFunctor().GetAccessor(); };
00142 
00144   void SetAccessor(AccessorType& accessor)
00145   {
00146     FunctorType functor;
00147     functor = this->GetFunctor();
00148     if (accessor != functor.GetAccessor())
00149       {
00150       functor.SetAccessor( accessor );
00151       this->SetFunctor( functor );
00152       this->Modified();
00153       }
00154   }
00156 
00157 protected:
00158   AdaptImageFilter() {}
00159   virtual ~AdaptImageFilter() {}
00160 
00161 private:
00162   AdaptImageFilter(const Self&); //purposely not implemented
00163   void operator=(const Self&); //purposely not implemented
00164 
00165 };
00166 
00167   
00168 } // end namespace itk
00169   
00170 #endif
00171 

Generated at Mon Apr 14 11:33:58 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000