#include "ImageDijkstra.h" // TODO: #include "MinimumSpanningTree.h" #include #include #include #include #include #include // ------------------------------------------------------------------------- fpaPlugins::ImageDijkstra:: ImageDijkstra( ) : Superclass( ) { this->_ConfigureInput< cpPlugins::BaseObjects::DataObject >( "CostFunctor", false, false ); this->_ConfigureOutput< cpPlugins::BaseObjects::DataObject >( "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" ); this->m_Parameters.ConfigureAsBool( "FillNodeQueue" ); this->m_Parameters.SetBool( "FillNodeQueue", false ); } // ------------------------------------------------------------------------- fpaPlugins::ImageDijkstra:: ~ImageDijkstra( ) { } // ------------------------------------------------------------------------- void fpaPlugins::ImageDijkstra:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 ); else this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > void fpaPlugins::ImageDijkstra:: _GD0( _TImage* image ) { auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" ); if( rtype == "float" ) this->_GD1< _TImage, float >( image ); else if( rtype == "double" ) this->_GD1< _TImage, double >( image ); } // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutput > void fpaPlugins::ImageDijkstra:: _GD1( _TInputImage* input ) { typedef itk::Image< _TOutput, _TInputImage::ImageDimension > _TOutputImage; typedef fpa::Image::Dijkstra< _TInputImage, _TOutputImage > _TFilter; typedef typename _TFilter::TCostConversionFunction _TCostFunctor; // Get functor auto base_functor = this->GetInputData< itk::LightObject >( "CostFunctor" ); _TCostFunctor* functor = NULL; if( base_functor != NULL ) { functor = dynamic_cast< _TCostFunctor* >( base_functor ); if( functor == NULL ) this->_Error( "Given cost functor is invalid." ); } // fi // Create filter _TFilter* filter = this->_ConfigureFilter< _TFilter >( ); // TODO: filter->SetFillNodeQueue( this->m_Parameters.GetBool( "FillNodeQueue" ) ); filter->SetCostConversionFunction( functor ); // Go!!! this->_ExecuteFilter( filter ); // Connect remaining output this->GetOutput( "MST" )->SetITK( filter->GetMinimumSpanningTree( ) ); } // eof - $RCSfile$