ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkUnaryFunctorImageFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkUnaryFunctorImageFilter_h
00019 #define __itkUnaryFunctorImageFilter_h
00020 
00021 #include "itkInPlaceImageFilter.h"
00022 #include "itkImageRegionIteratorWithIndex.h"
00023 
00024 namespace itk
00025 {
00047 template< class TInputImage, class TOutputImage, class TFunction >
00048 class ITK_EXPORT UnaryFunctorImageFilter:public InPlaceImageFilter< TInputImage, TOutputImage >
00049 {
00050 public:
00052   typedef UnaryFunctorImageFilter                         Self;
00053   typedef InPlaceImageFilter< TInputImage, TOutputImage > Superclass;
00054   typedef SmartPointer< Self >                            Pointer;
00055   typedef SmartPointer< const Self >                      ConstPointer;
00056 
00058   itkNewMacro(Self);
00059 
00061   itkTypeMacro(UnaryFunctorImageFilter, InPlaceImageFilter);
00062 
00064   typedef TFunction FunctorType;
00065 
00066   typedef TInputImage                              InputImageType;
00067   typedef typename    InputImageType::ConstPointer InputImagePointer;
00068   typedef typename    InputImageType::RegionType   InputImageRegionType;
00069   typedef typename    InputImageType::PixelType    InputImagePixelType;
00070 
00071   typedef TOutputImage                             OutputImageType;
00072   typedef typename     OutputImageType::Pointer    OutputImagePointer;
00073   typedef typename     OutputImageType::RegionType OutputImageRegionType;
00074   typedef typename     OutputImageType::PixelType  OutputImagePixelType;
00075 
00080   FunctorType &       GetFunctor() { return m_Functor; }
00081   const FunctorType & GetFunctor() const { return m_Functor; }
00083 
00090   void SetFunctor(const FunctorType & functor)
00091   {
00092     if ( m_Functor != functor )
00093       {
00094       m_Functor = functor;
00095       this->Modified();
00096       }
00097   }
00099 
00100 protected:
00101   UnaryFunctorImageFilter();
00102   virtual ~UnaryFunctorImageFilter() {}
00103 
00112   virtual void GenerateOutputInformation();
00113 
00124   void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
00125                             ThreadIdType threadId);
00126 
00127 private:
00128   UnaryFunctorImageFilter(const Self &); //purposely not implemented
00129   void operator=(const Self &);          //purposely not implemented
00130 
00131   FunctorType m_Functor;
00132 };
00133 } // end namespace itk
00134 
00135 #ifndef ITK_MANUAL_INSTANTIATION
00136 #include "itkUnaryFunctorImageFilter.hxx"
00137 #endif
00138 
00139 #endif
00140