00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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 )
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
00111
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&);
00123 void operator=(const Self&);
00124
00125 };
00126
00127
00128 }
00129
00130 #endif
00131