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
00039
namespace Functor {
00040
00041
template<
class TInput,
class TOutput>
00042 class VectorIndexSelectionCast
00043 {
00044
public:
00045 VectorIndexSelectionCast() {m_Index = 0;}
00046 ~VectorIndexSelectionCast() {}
00047
00048 unsigned int GetIndex()
const {
return m_Index; }
00049 void SetIndex(
unsigned int i) { m_Index = i; }
00050
00051 inline TOutput
operator()(
const TInput & A )
00052 {
00053
return static_cast<TOutput>( A[m_Index] );
00054 }
00055
00056
private:
00057
unsigned int m_Index;
00058 };
00059 }
00060
00061
template <
class TInputImage,
class TOutputImage>
00062 class ITK_EXPORT VectorIndexSelectionCastImageFilter :
00063
public
00064
UnaryFunctorImageFilter<TInputImage,TOutputImage,
00065 Functor::VectorIndexSelectionCast< typename TInputImage::PixelType,
00066 typename TOutputImage::PixelType> >
00067 {
00068
public:
00070 typedef VectorIndexSelectionCastImageFilter
Self;
00071
typedef UnaryFunctorImageFilter<TInputImage,TOutputImage,
00072
Functor::VectorIndexSelectionCast<
typename TInputImage::PixelType,
00073 typename TOutputImage::PixelType> >
Superclass;
00074 typedef SmartPointer<Self> Pointer;
00075 typedef SmartPointer<const Self> ConstPointer;
00076
00078
itkNewMacro(
Self);
00079
00081 void SetIndex(
unsigned int i)
00082 {
00083
if (i != this->GetFunctor().GetIndex())
00084 {
00085 this->GetFunctor().SetIndex(i);
00086 this->Modified();
00087 }
00088 }
00089 unsigned int GetIndex(
void)
const {
return this->GetFunctor().GetIndex(); }
00090
00091
protected:
00092 VectorIndexSelectionCastImageFilter() {}
00093 virtual ~VectorIndexSelectionCastImageFilter() {}
00094
00095
private:
00096 VectorIndexSelectionCastImageFilter(
const Self&);
00097
void operator=(
const Self&);
00098 };
00099
00100 }
00101
00102
00103
#endif