00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkScalarToArrayCastImageFilter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2002/06/11 07:17:00 $ 00007 Version: $Revision: 1.1 $ 00008 00009 Copyright (c) 2002 Insight Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkScalarToArrayCastImageFilter_h 00018 #define __itkScalarToArrayCastImageFilter_h 00019 00020 #include "itkUnaryFunctorImageFilter.h" 00021 00022 namespace itk 00023 { 00024 00041 namespace Functor { 00042 00043 template< class TInput, class TOutput> 00044 class ScalarToArrayCast 00045 { 00046 public: 00047 ScalarToArrayCast() {} 00048 ~ScalarToArrayCast() {} 00049 inline TOutput operator()( const TInput & A ) 00050 { 00051 typedef typename TOutput::ValueType OutputValueType; 00052 00053 TOutput value; 00054 value[0] = static_cast<OutputValueType>( A ); 00055 return value; 00056 } 00057 }; 00058 } 00059 00060 template <class TInputImage, class TOutputImage> 00061 class ITK_EXPORT ScalarToArrayCastImageFilter : 00062 public 00063 UnaryFunctorImageFilter<TInputImage,TOutputImage, 00064 Functor::ScalarToArrayCast< typename TInputImage::PixelType, 00065 typename TOutputImage::PixelType> > 00066 { 00067 public: 00069 typedef ScalarToArrayCastImageFilter Self; 00070 typedef UnaryFunctorImageFilter<TInputImage,TOutputImage, 00071 Functor::ScalarToArrayCast< typename TInputImage::PixelType, 00072 typename TOutputImage::PixelType> > Superclass; 00073 typedef SmartPointer<Self> Pointer; 00074 typedef SmartPointer<const Self> ConstPointer; 00075 00077 itkNewMacro(Self); 00078 00079 protected: 00080 ScalarToArrayCastImageFilter() {} 00081 virtual ~ScalarToArrayCastImageFilter() {} 00082 00083 private: 00084 ScalarToArrayCastImageFilter(const Self&); //purposely not implemented 00085 void operator=(const Self&); //purposely not implemented 00086 00087 }; 00088 00089 } // end namespace itk 00090 00091 00092 #endif