00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkCastImageFilter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:28:45 $ 00007 Version: $Revision: 1.9 $ 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 00022 namespace itk 00023 { 00024 00044 namespace Functor { 00045 00046 template< class TInput, class TOutput> 00047 class Cast 00048 { 00049 public: 00050 Cast() {}; 00051 ~Cast() {}; 00052 inline TOutput operator()( const TInput & A ) 00053 { 00054 return static_cast<TOutput>( A ); 00055 } 00056 }; 00057 } 00058 00059 template <class TInputImage, class TOutputImage> 00060 class ITK_EXPORT CastImageFilter : 00061 public 00062 UnaryFunctorImageFilter<TInputImage,TOutputImage, 00063 Functor::Cast< 00064 typename TInputImage::PixelType, 00065 typename TOutputImage::PixelType> > 00066 { 00067 public: 00069 typedef CastImageFilter Self; 00070 typedef UnaryFunctorImageFilter<TInputImage,TOutputImage, 00071 Functor::Cast< 00072 typename TInputImage::PixelType, 00073 typename TOutputImage::PixelType> 00074 > Superclass; 00075 typedef SmartPointer<Self> Pointer; 00076 typedef SmartPointer<const Self> ConstPointer; 00077 00079 itkNewMacro(Self); 00080 00082 itkTypeMacro(CastImageFilter, UnaryFunctorImageFilter); 00083 00084 protected: 00085 CastImageFilter() {} 00086 virtual ~CastImageFilter() {} 00087 00088 00089 private: 00090 CastImageFilter(const Self&); //purposely not implemented 00091 void operator=(const Self&); //purposely not implemented 00092 00093 }; 00094 00095 00096 } // end namespace itk 00097 00098 #endif