Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkCastImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkCastImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2010-04-18 16:14:24 $
00007   Version:   $Revision: 1.17 $
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 __itkCastImageFilter_h
00018 #define __itkCastImageFilter_h
00019 
00020 #include "itkUnaryFunctorImageFilter.h"
00021 #include "itkProgressReporter.h"
00022 
00023 namespace itk
00024 {
00025   
00040 namespace Functor {  
00041   
00042 template< class TInput, class TOutput>
00043 class Cast
00044 {
00045 public:
00046   Cast() {};
00047   virtual ~Cast() {};
00048   bool operator!=( const Cast & ) const
00049     {
00050     return false;
00051     }
00052   bool operator==( const Cast & other ) const
00053     {
00054     return !(*this != other);
00055     }
00056   inline TOutput operator()( const TInput & A ) const
00057     {
00058     return static_cast<TOutput>( A );
00059     }
00060 };
00061 }
00062 
00063 template <class TInputImage, class TOutputImage>
00064 class ITK_EXPORT CastImageFilter :
00065     public
00066 UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00067                         Functor::Cast< 
00068   typename TInputImage::PixelType, 
00069   typename TOutputImage::PixelType> >
00070 {
00071 public:
00073   typedef CastImageFilter               Self;
00074   typedef UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00075                         Functor::Cast< 
00076                           typename TInputImage::PixelType, 
00077                           typename TOutputImage::PixelType>   
00078                                      >  Superclass;
00079   typedef SmartPointer<Self>            Pointer;
00080   typedef SmartPointer<const Self>      ConstPointer;
00081 
00083   itkNewMacro(Self);
00084 
00086   itkTypeMacro(CastImageFilter, UnaryFunctorImageFilter);
00087 
00088 #ifdef ITK_USE_CONCEPT_CHECKING
00089 
00090   itkConceptMacro(InputConvertibleToOutputCheck,
00091     (Concept::Convertible<typename TInputImage::PixelType,
00092                           typename TOutputImage::PixelType>));
00093 
00095 #endif
00096 
00097 protected:
00098   CastImageFilter() {}
00099   virtual ~CastImageFilter() {}
00100 
00101   void GenerateData()
00102     {
00103     if( this->GetInPlace() && this->CanRunInPlace() )
00104       {
00105       // nothing to do, so avoid iterating over all the pixels
00106       // for nothing! Allocate the output, generate a fake progress and exit
00107       this->AllocateOutputs();
00108       ProgressReporter progress(this, 0, 1);
00109       return;
00110       }
00111     Superclass::GenerateData();
00112     }
00113   
00114 
00115   
00116 private:
00117   CastImageFilter(const Self&); //purposely not implemented
00118   void operator=(const Self&); //purposely not implemented
00119 
00120 };
00121 
00122 
00123 } // end namespace itk
00124 
00125 #endif
00126 

Generated at Mon Jul 12 2010 18:00:07 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000