itkVectorCastImageFilter.h
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 __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 {
00064 value[k] = static_cast<OutputValueType>( A[k] );
00065 }
00066 return value;
00067 }
00068 };
00069 }
00070
00071 template <class TInputImage, class TOutputImage>
00072 class ITK_EXPORT VectorCastImageFilter :
00073 public
00074 UnaryFunctorImageFilter<TInputImage,TOutputImage,
00075 Functor::VectorCast< typename TInputImage::PixelType,
00076 typename TOutputImage::PixelType> >
00077 {
00078 public:
00080 typedef VectorCastImageFilter Self;
00081 typedef UnaryFunctorImageFilter<
00082 TInputImage,TOutputImage,
00083 Functor::VectorCast< typename TInputImage::PixelType,
00084 typename TOutputImage::PixelType> > Superclass;
00085 typedef SmartPointer<Self> Pointer;
00086 typedef SmartPointer<const Self> ConstPointer;
00087
00089 itkNewMacro(Self);
00090
00092 itkTypeMacro(VectorCastImageFilter,
00093 UnaryFunctorImageFilter);
00094
00095 #ifdef ITK_USE_CONCEPT_CHECKING
00096
00097 itkConceptMacro(InputHasNumericTraitsCheck,
00098 (Concept::HasNumericTraits<typename TInputImage::PixelType::ValueType>));
00099 itkConceptMacro(OutputHasNumericTraitsCheck,
00100 (Concept::HasNumericTraits<typename TOutputImage::PixelType::ValueType>));
00101 itkConceptMacro(InputConvertibleToOutputCheck,
00102 (Concept::Convertible<typename TInputImage::PixelType::ValueType,
00103 typename TOutputImage::PixelType::ValueType>));
00104
00106 #endif
00107
00108 protected:
00109 VectorCastImageFilter() {}
00110 virtual ~VectorCastImageFilter() {}
00111
00112 private:
00113 VectorCastImageFilter(const Self&);
00114 void operator=(const Self&);
00115
00116 };
00117
00118 }
00119
00120
00121 #endif
00122