#include "ImageInterpolatorSource.h" #include #include #include // ------------------------------------------------------------------------- cpPlugins::BasicFilters::ImageInterpolatorSource:: ImageInterpolatorSource( ) : Superclass( ) { this->_AddInput( "ReferenceImage", true ); this->_AddOutput< cpPlugins::Interface::DataObject >( "Output" ); std::vector< std::string > type_choices; type_choices.push_back( "Linear" ); type_choices.push_back( "NearestNeighbor" ); this->m_Parameters->ConfigureAsChoices( "InterpolationType", type_choices ); this->m_Parameters->SetSelectedChoice( "InterpolationType", "Linear" ); std::vector< std::string > scalar_choices; scalar_choices.push_back( "float" ); scalar_choices.push_back( "double" ); this->m_Parameters->ConfigureAsChoices( "ScalarType", scalar_choices ); this->m_Parameters->SetSelectedChoice( "ScalarType", "float" ); } // ------------------------------------------------------------------------- cpPlugins::BasicFilters::ImageInterpolatorSource:: ~ImageInterpolatorSource( ) { } // ------------------------------------------------------------------------- std::string cpPlugins::BasicFilters::ImageInterpolatorSource:: _GenerateData( ) { auto image = this->GetInputData< cpPlugins::Interface::Image >( "ReferenceImage" ); if( image == NULL ) return( "ImageInterpolatorSource: No input image." ); itk::DataObject* itk_image = NULL; std::string r = ""; cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 ); else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 ); else cpPlugins_Image_Demangle_AllScalarTypes( 4, image, itk_image, r, _GD0 ); else r = "ImageInterpolatorSource: Input image type not supported."; return( r ); } // ------------------------------------------------------------------------- template< class I > std::string cpPlugins::BasicFilters::ImageInterpolatorSource:: _GD0( itk::DataObject* dobj ) { std::string int_choice = this->m_Parameters->GetSelectedChoice( "InterpolationType" ); std::string scalar_choice = this->m_Parameters->GetSelectedChoice( "ScalarType" ); if( int_choice == "Linear" ) { if( scalar_choice == "float" ) return( this->_GD1< itk::LinearInterpolateImageFunction< I, float > >( ) ); else if( scalar_choice == "double" ) return( this->_GD1< itk::LinearInterpolateImageFunction< I, double > >( ) ); else return( "ImageInterpolatorSource: Invalid scalar type" ); } else if( int_choice == "NearestNeighbor" ) { if( scalar_choice == "float" ) return( this->_GD1< itk::NearestNeighborInterpolateImageFunction< I, float > >( ) ); else if( scalar_choice == "double" ) return( this->_GD1< itk::NearestNeighborInterpolateImageFunction< I, double > >( ) ); else return( "ImageInterpolatorSource: Invalid scalar type" ); } else return( "ImageInterpolatorSource: Invalid interpolator" ); } // ------------------------------------------------------------------------- template< class T > std::string cpPlugins::BasicFilters::ImageInterpolatorSource:: _GD1( ) { auto out = this->GetOutputData< cpPlugins::Interface::DataObject >( "Output" ); if( out->GetITK< T >( ) == NULL ) { typename T::Pointer res = T::New( ); out->SetITK( res.GetPointer( ) ); } // fi return( "" ); } // eof - $RCSfile$