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: 2002/10/01 00:59:34 $
00007   Version:   $Revision: 1.13 $
00008 
00009   Copyright (c) 2002 Insight 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() {}
00047 
00049     typedef typename TAccessor::ExternalType OutputType;
00050     inline OutputType operator()( const TInput & A )
00051       { return m_Accessor.Get( A ); }
00052 
00054     AccessorType& GetAccessor() 
00055       { return m_Accessor; }
00056 
00058     AccessorFunctor & operator=( const AccessorFunctor & functor )
00059      { m_Accessor = functor.m_Accessor; 
00060        return *this;}
00061 
00067     void SetAccessor(AccessorType& accessor) 
00068       { m_Accessor = accessor; };
00069 
00071     bool operator!=( const Self& functor ) const
00072       { return (m_Accessor != functor.m_Accessor); }
00073     
00074   private:
00075     AccessorType m_Accessor;
00076   }; 
00077 }
00078 
00105 template <class TInputImage, class TOutputImage, class TAccessor>
00106 class ITK_EXPORT AdaptImageFilter:
00107     public UnaryFunctorImageFilter<TInputImage,TOutputImage,Functor::AccessorFunctor<ITK_TYPENAME TInputImage::PixelType, TAccessor> >
00108 {
00109 public:
00111   typedef AdaptImageFilter  Self;
00112   typedef UnaryFunctorImageFilter< TInputImage,
00113                                    TOutputImage,
00114                                    Functor::AccessorFunctor<
00115                                       ITK_TYPENAME TInputImage::PixelType, 
00116                                       TAccessor> >  Superclass;
00117 
00118   typedef SmartPointer<Self>   Pointer;
00119   typedef SmartPointer<const Self>  ConstPointer;
00120   typedef typename Superclass::FunctorType FunctorType;
00121 
00123   itkNewMacro(Self);
00124 
00126   typedef TAccessor AccessorType;
00127   
00129   itkTypeMacro(AdaptImageFilter, UnaryFunctorImageFilter);
00130 
00132   AccessorType& GetAccessor() { return this->GetFunctor().GetAccessor(); };
00133 
00135   void SetAccessor(AccessorType& accessor)
00136   {
00137     FunctorType functor;
00138     functor = this->GetFunctor();
00139     if (accessor != functor.GetAccessor())
00140       {
00141       functor.SetAccessor( accessor );
00142       this->SetFunctor( functor );
00143       this->Modified();
00144       }
00145   }
00146 
00147 protected:
00148   AdaptImageFilter() {}
00149   virtual ~AdaptImageFilter() {}
00150 
00151 private:
00152   AdaptImageFilter(const Self&); //purposely not implemented
00153   void operator=(const Self&); //purposely not implemented
00154 
00155 };
00156 
00157   
00158 } // end namespace itk
00159   
00160 #endif

Generated at Fri May 21 01:14:23 2004 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000