00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkCastImageFilter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2002/10/17 16:20:16 $ 00007 Version: $Revision: 1.6 $ 00008 00009 Copyright (c) 2002 Insight 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 00022 namespace itk 00023 { 00024 00036 namespace Functor { 00037 00038 template< class TInput, class TOutput> 00039 class Cast 00040 { 00041 public: 00042 Cast() {}; 00043 ~Cast() {}; 00044 inline TOutput operator()( const TInput & A ) 00045 { 00046 return static_cast<TOutput>( A ); 00047 } 00048 }; 00049 } 00050 00051 template <class TInputImage, class TOutputImage> 00052 class ITK_EXPORT CastImageFilter : 00053 public 00054 UnaryFunctorImageFilter<TInputImage,TOutputImage, 00055 Functor::Cast< 00056 typename TInputImage::PixelType, 00057 typename TOutputImage::PixelType> > 00058 { 00059 public: 00061 typedef CastImageFilter Self; 00062 typedef UnaryFunctorImageFilter<TInputImage,TOutputImage, 00063 Functor::Cast< 00064 typename TInputImage::PixelType, 00065 typename TOutputImage::PixelType> 00066 > Superclass; 00067 typedef SmartPointer<Self> Pointer; 00068 typedef SmartPointer<const Self> ConstPointer; 00069 00071 itkNewMacro(Self); 00072 00074 itkTypeMacro(CastImageFilter, UnaryFunctorImageFilter); 00075 00076 protected: 00077 CastImageFilter() {} 00078 virtual ~CastImageFilter() {} 00079 00080 private: 00081 CastImageFilter(const Self&); //purposely not implemented 00082 void operator=(const Self&); //purposely not implemented 00083 00084 }; 00085 00086 00087 } // end namespace itk 00088 00089 00090 #endif