#include #include #include // ------------------------------------------------------------------------- fpaPluginsImageAlgorithms::Dijkstra:: Dijkstra( ) : Superclass( ) { typedef cpPlugins::BaseObjects::DataObject _TData; typedef cpInstances::Image _TMST; this->_ConfigureInput< _TData >( "Cost", false, false ); this->_ConfigureInput< _TData >( "CostConversion", false, false ); this->_ConfigureOutput< _TMST >( "MST" ); std::vector< std::string > choices; choices.push_back( "float" ); choices.push_back( "double" ); this->m_Parameters.ConfigureAsChoices( "ResultType", choices ); this->m_Parameters.SetSelectedChoice( "ResultType", "float" ); } // ------------------------------------------------------------------------- fpaPluginsImageAlgorithms::Dijkstra:: ~Dijkstra( ) { } // ------------------------------------------------------------------------- void fpaPluginsImageAlgorithms::Dijkstra:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > void fpaPluginsImageAlgorithms::Dijkstra:: _GD0( _TImage* image ) { typedef itk::Image< float, _TImage::ImageDimension > _TFloat; typedef itk::Image< double, _TImage::ImageDimension > _TDouble; auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" ); if ( rtype == "float" ) this->_GD1< _TImage, _TFloat >( image ); else if( rtype == "double" ) this->_GD1< _TImage, _TDouble >( image ); } // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > void fpaPluginsImageAlgorithms::Dijkstra:: _GD1( _TInputImage* image ) { typedef fpa::Image::Dijkstra< _TInputImage, _TOutputImage > _TFilter; typedef typename _TFilter::TCostConversionFunction _TCostConversion; typedef typename _TFilter::TCostFunction _TCost; auto filter = this->_CreateITK< _TFilter >( ); this->_ConfigureFilter( filter, image ); auto cost = this->GetInputData< _TCost >( "Cost" ); auto conv = this->GetInputData< _TCostConversion >( "CostConversion" ); if( cost != NULL ) filter->SetCostFunction( cost ); if( conv != NULL ) filter->SetCostConversionFunction( conv ); filter->Update( ); this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); this->GetOutput( "MST" )->SetITK( filter->GetMinimumSpanningTree( ) ); } // eof - $RCSfile$