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: 2009-04-01 14:36:06 $
00007   Version:   $Revision: 1.19 $
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 ) const
00052     {
00053     return m_Accessor.Get( A );
00054     }
00056 
00058   AccessorType& GetAccessor() 
00059     {
00060     return m_Accessor;
00061     }
00062 
00064   AccessorFunctor & operator=( const AccessorFunctor & functor )
00065     {
00066     m_Accessor = functor.m_Accessor; 
00067     return *this;
00068     }
00069 
00075   void SetAccessor(AccessorType& accessor) 
00076     {
00077     m_Accessor = accessor;
00078     }
00079 
00081   bool operator!=( const Self& functor ) const
00082     {
00083     return (m_Accessor != functor.m_Accessor);
00084     }
00085   bool operator==( const Self& other ) const
00086     {
00087     return !(*this != other);
00088     }
00090 
00091 private:
00092   AccessorType m_Accessor;
00093 }; 
00094 }
00095 
00122 template <class TInputImage, class TOutputImage, class TAccessor>
00123 class ITK_EXPORT AdaptImageFilter:
00124     public UnaryFunctorImageFilter<TInputImage,TOutputImage,Functor::AccessorFunctor<ITK_TYPENAME TInputImage::PixelType, TAccessor> >
00125 {
00126 public:
00128   typedef AdaptImageFilter  Self;
00129 
00130   typedef UnaryFunctorImageFilter< TInputImage,
00131                                    TOutputImage,
00132                                    Functor::AccessorFunctor<
00133     ITK_TYPENAME TInputImage::PixelType, 
00134     TAccessor> >  Superclass;
00135 
00136   typedef SmartPointer<Self>               Pointer;
00137   typedef SmartPointer<const Self>         ConstPointer;
00138   typedef typename Superclass::FunctorType FunctorType;
00139 
00141   itkNewMacro(Self);
00142 
00144   typedef TAccessor AccessorType;
00145 
00147   itkTypeMacro(AdaptImageFilter, UnaryFunctorImageFilter);
00148 
00150   AccessorType& GetAccessor() { return this->GetFunctor().GetAccessor(); };
00151 
00153   void SetAccessor(AccessorType& accessor)
00154     {
00155     FunctorType functor;
00156     functor = this->GetFunctor();
00157     if (accessor != functor.GetAccessor())
00158       {
00159       functor.SetAccessor( accessor );
00160       this->SetFunctor( functor );
00161       this->Modified();
00162       }
00163     }
00165 
00166 protected:
00167   AdaptImageFilter() {}
00168   virtual ~AdaptImageFilter() {}
00169 
00170 private:
00171   AdaptImageFilter(const Self&); //purposely not implemented
00172   void operator=(const Self&); //purposely not implemented
00173 
00174 };
00175 
00176   
00177 } // end namespace itk
00178   
00179 #endif
00180 

Generated at Fri Apr 16 17:46:07 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000