00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkUnaryFunctorImageFilter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2008-10-07 17:31:02 $ 00007 Version: $Revision: 1.25 $ 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 __itkUnaryFunctorImageFilter_h 00018 #define __itkUnaryFunctorImageFilter_h 00019 00020 #include "itkInPlaceImageFilter.h" 00021 #include "itkImageRegionIteratorWithIndex.h" 00022 00023 namespace itk 00024 { 00025 00042 template <class TInputImage, class TOutputImage, class TFunction > 00043 class ITK_EXPORT UnaryFunctorImageFilter : public InPlaceImageFilter<TInputImage,TOutputImage> 00044 { 00045 public: 00047 typedef UnaryFunctorImageFilter Self; 00048 typedef InPlaceImageFilter<TInputImage,TOutputImage> Superclass; 00049 typedef SmartPointer<Self> Pointer; 00050 typedef SmartPointer<const Self> ConstPointer; 00051 00053 itkNewMacro(Self); 00054 00056 itkTypeMacro(UnaryFunctorImageFilter, InPlaceImageFilter); 00057 00059 typedef TFunction FunctorType; 00060 00061 typedef TInputImage InputImageType; 00062 typedef typename InputImageType::ConstPointer InputImagePointer; 00063 typedef typename InputImageType::RegionType InputImageRegionType; 00064 typedef typename InputImageType::PixelType InputImagePixelType; 00065 00066 typedef TOutputImage OutputImageType; 00067 typedef typename OutputImageType::Pointer OutputImagePointer; 00068 typedef typename OutputImageType::RegionType OutputImageRegionType; 00069 typedef typename OutputImageType::PixelType OutputImagePixelType; 00070 00075 FunctorType& GetFunctor() { return m_Functor; }; 00076 const FunctorType& GetFunctor() const { return m_Functor; } 00078 00085 void SetFunctor(const FunctorType& functor) 00086 { 00087 if (m_Functor != functor) 00088 { 00089 m_Functor = functor; 00090 this->Modified(); 00091 } 00092 } 00094 00095 protected: 00096 UnaryFunctorImageFilter(); 00097 virtual ~UnaryFunctorImageFilter() {}; 00098 00107 virtual void GenerateOutputInformation(); 00108 00119 void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, 00120 int threadId ); 00121 00122 private: 00123 UnaryFunctorImageFilter(const Self&); //purposely not implemented 00124 void operator=(const Self&); //purposely not implemented 00125 00126 FunctorType m_Functor; 00127 }; 00128 00129 } // end namespace itk 00130 00131 #ifndef ITK_MANUAL_INSTANTIATION 00132 #include "itkUnaryFunctorImageFilter.txx" 00133 #endif 00134 00135 #endif 00136