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 #include "itkNumericTraitsFixedArrayPixel.h"
00022
00023 namespace itk
00024 {
00025
00041 namespace Functor {
00042
00043 template< class TInput, class TOutput>
00044 class VectorCast
00045 {
00046 public:
00047 VectorCast() {}
00048 ~VectorCast() {}
00049 bool operator!=( const VectorCast & ) const
00050 {
00051 return false;
00052 }
00053 bool operator==( const VectorCast & other ) const
00054 {
00055 return !(*this != other);
00056 }
00057 inline TOutput operator()( const TInput & A ) const
00058 {
00059 typedef typename TOutput::ValueType OutputValueType;
00060
00061 TOutput value;
00062 for( unsigned int k = 0; k < TOutput::Dimension; k++ )
00063 { value[k] = static_cast<OutputValueType>( A[k] ); }
00064 return value;
00065 }
00066 };
00067 }
00068
00069 template <class TInputImage, class TOutputImage>
00070 class ITK_EXPORT VectorCastImageFilter :
00071 public
00072 UnaryFunctorImageFilter<TInputImage,TOutputImage,
00073 Functor::VectorCast< typename TInputImage::PixelType,
00074 typename TOutputImage::PixelType> >
00075 {
00076 public:
00078 typedef VectorCastImageFilter Self;
00079 typedef UnaryFunctorImageFilter<TInputImage,TOutputImage,
00080 Functor::VectorCast< typename TInputImage::PixelType,
00081 typename TOutputImage::PixelType> > Superclass;
00082 typedef SmartPointer<Self> Pointer;
00083 typedef SmartPointer<const Self> ConstPointer;
00084
00086 itkNewMacro(Self);
00087
00089 itkTypeMacro(VectorCastImageFilter,
00090 UnaryFunctorImageFilter);
00091
00092 #ifdef ITK_USE_CONCEPT_CHECKING
00093
00094 itkConceptMacro(InputHasNumericTraitsCheck,
00095 (Concept::HasNumericTraits<typename TInputImage::PixelType::ValueType>));
00096 itkConceptMacro(OutputHasNumericTraitsCheck,
00097 (Concept::HasNumericTraits<typename TOutputImage::PixelType::ValueType>));
00098 itkConceptMacro(InputConvertibleToOutputCheck,
00099 (Concept::Convertible<typename TInputImage::PixelType::ValueType,
00100 typename TOutputImage::PixelType::ValueType>));
00101
00103 #endif
00104
00105 protected:
00106 VectorCastImageFilter() {}
00107 virtual ~VectorCastImageFilter() {}
00108
00109 private:
00110 VectorCastImageFilter(const Self&);
00111 void operator=(const Self&);
00112
00113 };
00114
00115 }
00116
00117
00118 #endif
00119