ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkNaryFunctorImageFilter.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 __itkNaryFunctorImageFilter_h
00019 #define __itkNaryFunctorImageFilter_h
00020 
00021 #include "itkInPlaceImageFilter.h"
00022 #include "itkImageIterator.h"
00023 #include "itkArray.h"
00024 
00025 namespace itk
00026 {
00041 template< class TInputImage, class TOutputImage, class TFunction >
00042 class ITK_EXPORT NaryFunctorImageFilter:
00043   public InPlaceImageFilter< TInputImage, TOutputImage >
00044 
00045 {
00046 public:
00048   typedef NaryFunctorImageFilter                          Self;
00049   typedef InPlaceImageFilter< TInputImage, TOutputImage > Superclass;
00050   typedef SmartPointer< Self >                            Pointer;
00051   typedef SmartPointer< const Self >                      ConstPointer;
00052 
00054   itkNewMacro(Self);
00055 
00057   itkTypeMacro(NaryFunctorImageFilter, InPlaceImageFilter);
00058 
00060   typedef TFunction                            FunctorType;
00061   typedef TInputImage                          InputImageType;
00062   typedef typename InputImageType::Pointer     InputImagePointer;
00063   typedef typename InputImageType::RegionType  InputImageRegionType;
00064   typedef typename InputImageType::PixelType   InputImagePixelType;
00065   typedef TOutputImage                         OutputImageType;
00066   typedef typename OutputImageType::Pointer    OutputImagePointer;
00067   typedef typename OutputImageType::RegionType OutputImageRegionType;
00068   typedef typename OutputImageType::PixelType  OutputImagePixelType;
00069   typedef std::vector< InputImagePixelType >   NaryArrayType;
00070 
00075   FunctorType & GetFunctor() { return m_Functor; }
00076 
00083   void SetFunctor(FunctorType & functor)
00084   {
00085     if ( m_Functor != functor )
00086       {
00087       m_Functor = functor;
00088       this->Modified();
00089       }
00090   }
00092 
00094   itkStaticConstMacro(
00095     InputImageDimension, unsigned int, TInputImage::ImageDimension);
00096   itkStaticConstMacro(
00097     OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
00099 
00100 #ifdef ITK_USE_CONCEPT_CHECKING
00101 
00102   itkConceptMacro( SameDimensionCheck,
00103                    ( Concept::SameDimension< InputImageDimension, OutputImageDimension > ) );
00104   itkConceptMacro( OutputHasZeroCheck,
00105                    ( Concept::HasZero< OutputImagePixelType > ) );
00106 
00108 #endif
00109 protected:
00110   NaryFunctorImageFilter();
00111   virtual ~NaryFunctorImageFilter() {}
00112 
00123   void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
00124                             ThreadIdType threadId);
00125 
00126 private:
00127   NaryFunctorImageFilter(const Self &); //purposely not implemented
00128   void operator=(const Self &);         //purposely not implemented
00129 
00130   FunctorType m_Functor;
00131 };
00132 } // end namespace itk
00133 
00134 #ifndef ITK_MANUAL_INSTANTIATION
00135 #include "itkNaryFunctorImageFilter.hxx"
00136 #endif
00137 
00138 #endif
00139