--- /dev/null
+#include <ImageGenericFilters/CastImageFilter.h>
+#include <cpPlugins/DataObjects/Image.h>
+#include <cpPlugins/DataObjects/Image_Demanglers.h>
+
+#include <itkCastImageFilter.h>
+
+// -------------------------------------------------------------------------
+cpPluginsImageGenericFilters::CastImageFilter::
+CastImageFilter( )
+ : Superclass( )
+{
+ typedef cpPlugins::DataObjects::Image _TImage;
+ this->_ConfigureInput< _TImage >( "Input", true, false );
+ this->_ConfigureOutput< _TImage >( "Output" );
+ this->m_Parameters.ConfigureAsScalarTypesChoices( "CastType" );
+}
+
+// -------------------------------------------------------------------------
+cpPluginsImageGenericFilters::CastImageFilter::
+~CastImageFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPluginsImageGenericFilters::CastImageFilter::
+_GenerateData( )
+{
+ auto o = this->GetInputData( "Input" );
+ cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
+ this->_Error( "Invalid input image." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInput >
+void cpPluginsImageGenericFilters::CastImageFilter::
+_GD0( _TInput* input )
+{
+ std::string out_res =
+ this->m_Parameters.GetSelectedChoice( "CastType" );
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_char
+ if( out_res == "char" ) this->_GD1< _TInput, char >( input );
+ if( out_res == "uchar" ) this->_GD1< _TInput, unsigned char >( input );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_char
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_short
+ if( out_res == "short" ) this->_GD1< _TInput, short >( input );
+ if( out_res == "ushort" ) this->_GD1< _TInput, unsigned short >( input );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_short
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_int
+ if( out_res == "int" ) this->_GD1< _TInput, int >( input );
+ if( out_res == "uint" ) this->_GD1< _TInput, unsigned int >( input );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_int
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_long
+ if( out_res == "long" ) this->_GD1< _TInput, long >( input );
+ if( out_res == "ulong" ) this->_GD1< _TInput, unsigned long >( input );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_long
+#ifdef cpPlugins_CONFIG_REAL_TYPES_float
+ if( out_res == "float" ) this->_GD1< _TInput, float >( input );
+#endif // cpPlugins_CONFIG_REAL_TYPES_float
+#ifdef cpPlugins_CONFIG_REAL_TYPES_double
+ if( out_res == "double" ) this->_GD1< _TInput, double >( input );
+#endif // cpPlugins_CONFIG_REAL_TYPES_double
+}
+
+// -------------------------------------------------------------------------
+template< class _TInput, class _TOutputPixel >
+void cpPluginsImageGenericFilters::CastImageFilter::
+_GD1( _TInput* input )
+{
+ typedef itk::Image< _TOutputPixel, _TInput::ImageDimension > _TOutput;
+ typedef itk::CastImageFilter< _TInput, _TOutput > _TFilter;
+
+ auto filter = this->_CreateITK< _TFilter >( );
+ filter->SetInput( input );
+ filter->Update( );
+ this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __cpPluginsImageGenericFilters__CastImageFilter__h__
+#define __cpPluginsImageGenericFilters__CastImageFilter__h__
+
+#include <cpPluginsImageGenericFilters_Export.h>
+#include <cpPlugins/BaseObjects/ProcessObject.h>
+
+namespace cpPluginsImageGenericFilters
+{
+ /**
+ */
+ class cpPluginsImageGenericFilters_EXPORT CastImageFilter
+ : public cpPlugins::BaseObjects::ProcessObject
+ {
+ cpPluginsObject(
+ CastImageFilter,
+ cpPlugins::BaseObjects::ProcessObject,
+ ImageFilters
+ );
+
+ protected:
+ template< class _TInput >
+ inline void _GD0( _TInput* input );
+
+ template< class _TInput, class _TOutputPixel >
+ inline void _GD1( _TInput* input );
+ };
+
+} // ecapseman
+
+#endif // __cpPluginsImageGenericFilters__CastImageFilter__h__
+
+// eof - $RCSfile$