Go to the documentation of this file.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
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
00106
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&);
00118 void operator=(const Self&);
00119
00120 };
00121
00122
00123 }
00124
00125 #endif
00126