#include #include #include // ------------------------------------------------------------------------- cpPluginsITKImageGenericFilters_1::CastImageFilter:: CastImageFilter( ) : Superclass( ) { this->_ConfigureInput< cpInstances::DataObjects::Image >( "Input", true, false ); this->_ConfigureOutput< cpInstances::DataObjects::Image >( "Output" ); this->m_Parameters.ConfigureAsScalarTypesChoices( "OutputPixelType" ); } // ------------------------------------------------------------------------- cpPluginsITKImageGenericFilters_1::CastImageFilter:: ~CastImageFilter( ) { } // ------------------------------------------------------------------------- void cpPluginsITKImageGenericFilters_1::CastImageFilter:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- template< class _TInput > void cpPluginsITKImageGenericFilters_1::CastImageFilter:: _GD0( _TInput* input ) { std::string o_type = this->m_Parameters.GetSelectedChoice( "OutputPixelType" ); if( o_type == "char" ) this->_GD1< _TInput, char >( input ); else if( o_type == "short" ) this->_GD1< _TInput, short >( input ); else if( o_type == "int" ) this->_GD1< _TInput, int >( input ); else if( o_type == "long" ) this->_GD1< _TInput, long >( input ); else if( o_type == "uchar" ) this->_GD1< _TInput, unsigned char >( input ); else if( o_type == "ushort" ) this->_GD1< _TInput, unsigned short >( input ); else if( o_type == "uint" ) this->_GD1< _TInput, unsigned int >( input ); else if( o_type == "ulong" ) this->_GD1< _TInput, unsigned long >( input ); else if( o_type == "float" ) this->_GD1< _TInput, float >( input ); else if( o_type == "double" ) this->_GD1< _TInput, double >( input ); } // ------------------------------------------------------------------------- template< class _TInput, class _TOutputPixel > void cpPluginsITKImageGenericFilters_1::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$