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
00087 #ifdef ITK_USE_CONCEPT_CHECKING
00088
00089 itkConceptMacro(InputHasNumericTraitsCheck,
00090 (Concept::HasNumericTraits<typename TInputImage::PixelType::ValueType>));
00091 itkConceptMacro(OutputHasNumericTraitsCheck,
00092 (Concept::HasNumericTraits<typename TOutputImage::PixelType::ValueType>));
00093 itkConceptMacro(InputConvertibleToOutputCheck,
00094 (Concept::Convertible<typename TInputImage::PixelType::ValueType,
00095 typename TOutputImage::PixelType::ValueType>));
00096
00098 #endif
00099
00100 protected:
00101 VectorCastImageFilter() {}
00102 virtual ~VectorCastImageFilter() {}
00103
00104 private:
00105 VectorCastImageFilter(const Self&);
00106 void operator=(const Self&);
00107
00108 };
00109
00110 }
00111
00112
00113 #endif
00114