1 #include "ImageDijkstra.h"
2 // TODO: #include "MinimumSpanningTree.h"
4 #include <cpPlugins/DataObjects/Image.h>
5 #include <fpa/Image/Dijkstra.h>
7 #include <fpa/Base/Algorithm.hxx>
8 #include <fpa/Base/Dijkstra.hxx>
9 #include <fpa/Image/Algorithm.hxx>
10 #include <fpa/Image/Dijkstra.hxx>
12 // -------------------------------------------------------------------------
13 fpaPlugins::ImageDijkstra::
17 this->_ConfigureInput< cpPlugins::BaseObjects::DataObject >( "CostFunctor", false, false );
18 this->_ConfigureOutput< cpPlugins::BaseObjects::DataObject >( "MST" );
19 std::vector< std::string > choices;
20 choices.push_back( "float" );
21 choices.push_back( "double" );
22 this->m_Parameters.ConfigureAsChoices( "ResultType", choices );
23 this->m_Parameters.SetSelectedChoice( "ResultType", "float" );
24 this->m_Parameters.ConfigureAsBool( "FillNodeQueue" );
25 this->m_Parameters.SetBool( "FillNodeQueue", false );
28 // -------------------------------------------------------------------------
29 fpaPlugins::ImageDijkstra::
34 // -------------------------------------------------------------------------
35 void fpaPlugins::ImageDijkstra::
38 auto o = this->GetInputData( "Input" );
39 cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 );
40 else this->_Error( "Invalid input image." );
43 // -------------------------------------------------------------------------
44 template< class _TImage >
45 void fpaPlugins::ImageDijkstra::
46 _GD0( _TImage* image )
48 auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
49 if( rtype == "float" ) this->_GD1< _TImage, float >( image );
50 else if( rtype == "double" ) this->_GD1< _TImage, double >( image );
53 // -------------------------------------------------------------------------
54 template< class _TInputImage, class _TOutput >
55 void fpaPlugins::ImageDijkstra::
56 _GD1( _TInputImage* input )
58 typedef itk::Image< _TOutput, _TInputImage::ImageDimension > _TOutputImage;
59 typedef fpa::Image::Dijkstra< _TInputImage, _TOutputImage > _TFilter;
60 typedef typename _TFilter::TCostConversionFunction _TCostFunctor;
64 this->GetInputData< itk::LightObject >( "CostFunctor" );
65 _TCostFunctor* functor = NULL;
66 if( base_functor != NULL )
68 functor = dynamic_cast< _TCostFunctor* >( base_functor );
70 this->_Error( "Given cost functor is invalid." );
75 _TFilter* filter = this->_ConfigureFilter< _TFilter >( );
76 // TODO: filter->SetFillNodeQueue( this->m_Parameters.GetBool( "FillNodeQueue" ) );
77 filter->SetCostConversionFunction( functor );
80 this->_ExecuteFilter( filter );
82 // Connect remaining output
83 this->GetOutput( "MST" )->SetITK( filter->GetMinimumSpanningTree( ) );