00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkVectorCastImageFilter_h
00018 #define __itkVectorCastImageFilter_h
00019
00020 #include "itkUnaryFunctorImageFilter.h"
00021
00022 namespace itk
00023 {
00024
00040 namespace Functor {
00041
00042 template< class TInput, class TOutput>
00043 class VectorCast
00044 {
00045 public:
00046 VectorCast() {}
00047 ~VectorCast() {}
00048 bool operator!=( const VectorCast & ) const
00049 {
00050 return false;
00051 }
00052 bool operator==( const VectorCast & other ) const
00053 {
00054 return !(*this != other);
00055 }
00056 inline TOutput operator()( const TInput & A ) const
00057 {
00058 typedef typename TOutput::ValueType OutputValueType;
00059
00060 TOutput value;
00061 for( unsigned int k = 0; k < TOutput::Dimension; k++ )
00062 { value[k] = static_cast<OutputValueType>( A[k] ); }
00063 return value;
00064 }
00065 };
00066 }
00067
00068 template <class TInputImage, class TOutputImage>
00069 class ITK_EXPORT VectorCastImageFilter :
00070 public
00071 UnaryFunctorImageFilter<TInputImage,TOutputImage,
00072 Functor::VectorCast< typename TInputImage::PixelType,
00073 typename TOutputImage::PixelType> >
00074 {
00075 public:
00077 typedef VectorCastImageFilter Self;
00078 typedef UnaryFunctorImageFilter<TInputImage,TOutputImage,
00079 Functor::VectorCast< typename TInputImage::PixelType,
00080 typename TOutputImage::PixelType> > Superclass;
00081 typedef SmartPointer<Self> Pointer;
00082 typedef SmartPointer<const Self> ConstPointer;
00083
00085 itkNewMacro(Self);
00086
00088 itkTypeMacro(VectorCastImageFilter,
00089 UnaryFunctorImageFilter);
00090
00091 #ifdef ITK_USE_CONCEPT_CHECKING
00092
00093 itkConceptMacro(InputHasNumericTraitsCheck,
00094 (Concept::HasNumericTraits<typename TInputImage::PixelType::ValueType>));
00095 itkConceptMacro(OutputHasNumericTraitsCheck,
00096 (Concept::HasNumericTraits<typename TOutputImage::PixelType::ValueType>));
00097 itkConceptMacro(InputConvertibleToOutputCheck,
00098 (Concept::Convertible<typename TInputImage::PixelType::ValueType,
00099 typename TOutputImage::PixelType::ValueType>));
00100
00102 #endif
00103
00104 protected:
00105 VectorCastImageFilter() {}
00106 virtual ~VectorCastImageFilter() {}
00107
00108 private:
00109 VectorCastImageFilter(const Self&);
00110 void operator=(const Self&);
00111
00112 };
00113
00114 }
00115
00116
00117 #endif
00118