00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkUnaryFunctorImageFilter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2007-09-03 13:45:32 $ 00007 Version: $Revision: 1.24 $ 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 typedef TInputImage InputImageType; 00061 typedef typename InputImageType::ConstPointer InputImagePointer; 00062 typedef typename InputImageType::RegionType InputImageRegionType; 00063 typedef typename InputImageType::PixelType InputImagePixelType; 00064 typedef TOutputImage OutputImageType; 00065 typedef typename OutputImageType::Pointer OutputImagePointer; 00066 typedef typename OutputImageType::RegionType OutputImageRegionType; 00067 typedef typename OutputImageType::PixelType OutputImagePixelType; 00068 00073 FunctorType& GetFunctor() { return m_Functor; }; 00074 const FunctorType& GetFunctor() const { return m_Functor; }; 00076 00083 void SetFunctor(const FunctorType& functor) 00084 { 00085 if (m_Functor != functor) 00086 { 00087 m_Functor = functor; 00088 this->Modified(); 00089 } 00090 } 00092 00093 protected: 00094 UnaryFunctorImageFilter(); 00095 virtual ~UnaryFunctorImageFilter() {}; 00096 00105 virtual void GenerateOutputInformation(); 00106 00117 void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, 00118 int threadId ); 00119 00120 private: 00121 UnaryFunctorImageFilter(const Self&); //purposely not implemented 00122 void operator=(const Self&); //purposely not implemented 00123 00124 FunctorType m_Functor; 00125 }; 00126 00127 } // end namespace itk 00128 00129 #ifndef ITK_MANUAL_INSTANTIATION 00130 #include "itkUnaryFunctorImageFilter.txx" 00131 #endif 00132 00133 #endif 00134