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: 2009-04-01 14:36:10 $
00007   Version:   $Revision: 1.16 $
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   
00045 namespace Functor {  
00046   
00047 template< class TInput, class TOutput>
00048 class Cast
00049 {
00050 public:
00051   Cast() {};
00052   virtual ~Cast() {};
00053   bool operator!=( const Cast & ) const
00054     {
00055     return false;
00056     }
00057   bool operator==( const Cast & other ) const
00058     {
00059     return !(*this != other);
00060     }
00061   inline TOutput operator()( const TInput & A ) const
00062     {
00063     return static_cast<TOutput>( A );
00064     }
00065 };
00066 }
00067 
00068 template <class TInputImage, class TOutputImage>
00069 class ITK_EXPORT CastImageFilter :
00070     public
00071 UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00072                         Functor::Cast< 
00073   typename TInputImage::PixelType, 
00074   typename TOutputImage::PixelType> >
00075 {
00076 public:
00078   typedef CastImageFilter               Self;
00079   typedef UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00080                         Functor::Cast< 
00081                           typename TInputImage::PixelType, 
00082                           typename TOutputImage::PixelType>   
00083                                      >  Superclass;
00084   typedef SmartPointer<Self>            Pointer;
00085   typedef SmartPointer<const Self>      ConstPointer;
00086 
00088   itkNewMacro(Self);
00089 
00091   itkTypeMacro(CastImageFilter, UnaryFunctorImageFilter);
00092 
00093 #ifdef ITK_USE_CONCEPT_CHECKING
00094 
00095   itkConceptMacro(InputConvertibleToOutputCheck,
00096     (Concept::Convertible<typename TInputImage::PixelType,
00097                           typename TOutputImage::PixelType>));
00098 
00100 #endif
00101 
00102 protected:
00103   CastImageFilter() {}
00104   virtual ~CastImageFilter() {}
00105 
00106   void GenerateData()
00107     {
00108     if( this->GetInPlace() && this->CanRunInPlace() )
00109       {
00110       // nothing to do, so avoid iterating over all the pixels
00111       // for nothing! Allocate the output, generate a fake progress and exit
00112       this->AllocateOutputs();
00113       ProgressReporter progress(this, 0, 1);
00114       return;
00115       }
00116     Superclass::GenerateData();
00117     }
00118   
00119 
00120   
00121 private:
00122   CastImageFilter(const Self&); //purposely not implemented
00123   void operator=(const Self&); //purposely not implemented
00124 
00125 };
00126 
00127 
00128 } // end namespace itk
00129 
00130 #endif
00131 

Generated at Fri Apr 16 18:02:03 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000