00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkVectorIndexSelectionCastImageFilter_h
00018 #define __itkVectorIndexSelectionCastImageFilter_h
00019
00020 #include "itkUnaryFunctorImageFilter.h"
00021
00022 namespace itk
00023 {
00024
00025 namespace Functor {
00026
00027 template< class TInput, class TOutput>
00028 class VectorIndexSelectionCast
00029 {
00030 public:
00031 VectorIndexSelectionCast() {m_Index = 0;}
00032 ~VectorIndexSelectionCast() {}
00033
00034 unsigned int GetIndex() const { return m_Index; }
00035 void SetIndex(unsigned int i) { m_Index = i; }
00036
00037 inline TOutput operator()( const TInput & A )
00038 {
00039 return static_cast<TOutput>( A[m_Index] );
00040 }
00041
00042 private:
00043 unsigned int m_Index;
00044 };
00045 }
00046
00047
00048
00066 template <class TInputImage, class TOutputImage>
00067 class ITK_EXPORT VectorIndexSelectionCastImageFilter :
00068 public
00069 UnaryFunctorImageFilter<TInputImage,TOutputImage,
00070 Functor::VectorIndexSelectionCast< typename TInputImage::PixelType,
00071 typename TOutputImage::PixelType> >
00072 {
00073 public:
00075 typedef VectorIndexSelectionCastImageFilter Self;
00076 typedef UnaryFunctorImageFilter<TInputImage,TOutputImage,
00077 Functor::VectorIndexSelectionCast< typename TInputImage::PixelType,
00078 typename TOutputImage::PixelType> > Superclass;
00079 typedef SmartPointer<Self> Pointer;
00080 typedef SmartPointer<const Self> ConstPointer;
00081
00083 itkNewMacro(Self);
00084
00086 void SetIndex(unsigned int i)
00087 {
00088 if (i != this->GetFunctor().GetIndex())
00089 {
00090 this->GetFunctor().SetIndex(i);
00091 this->Modified();
00092 }
00093 }
00094 unsigned int GetIndex(void) const { return this->GetFunctor().GetIndex(); }
00095
00096 protected:
00097 VectorIndexSelectionCastImageFilter() {}
00098 virtual ~VectorIndexSelectionCastImageFilter() {}
00099
00100 private:
00101 VectorIndexSelectionCastImageFilter(const Self&);
00102 void operator=(const Self&);
00103 };
00104
00105 }
00106
00107
00108 #endif