#include #include #include #include #include // ------------------------------------------------------------------------- fpaPluginsDijkstraFunctors::ExtractPathFromMinimumSpanningTree:: ExtractPathFromMinimumSpanningTree( ) : Superclass( ) { typedef cpPlugins::BaseObjects::DataObject _TData; typedef cpInstances::Image _TMST; typedef cpInstances::PolyLineParametricPath _TPath; this->_ConfigureInput< _TMST >( "MST", true, false ); this->_ConfigureInput< _TData >( "Seeds", true, false ); this->_ConfigureOutput< _TPath >( "Output" ); } // ------------------------------------------------------------------------- fpaPluginsDijkstraFunctors::ExtractPathFromMinimumSpanningTree:: ~ExtractPathFromMinimumSpanningTree( ) { } // ------------------------------------------------------------------------- void fpaPluginsDijkstraFunctors::ExtractPathFromMinimumSpanningTree:: _GenerateData( ) { typedef fpa::Image::MinimumSpanningTree< 2 > _TMST2; typedef fpa::Image::MinimumSpanningTree< 3 > _TMST3; auto mst2 = this->GetInputData< _TMST2 >( "MST" ); auto mst3 = this->GetInputData< _TMST3 >( "MST" ); if ( mst2 != NULL ) this->_GD0( mst2 ); else if( mst3 != NULL ) this->_GD0( mst3 ); else this->_Error( "Invalid input spanning tree." ); } // ------------------------------------------------------------------------- template< class _TMST > void fpaPluginsDijkstraFunctors::ExtractPathFromMinimumSpanningTree:: _GD0( _TMST* mst ) { typedef typename _TMST::IndexType _TIndex; typedef typename _TMST::TPath _TPath; // Get seeds std::vector< _TIndex > seeds; auto points = this->GetInputData< vtkPolyData >( "Seeds" ); if( points != NULL ) { if( points->GetNumberOfPoints( ) < 2 ) this->_Error( "Not enough seeds (<2)." ); typename _TMST::PointType pnt; typename _TMST::IndexType idx; unsigned int dim = ( _TMST::ImageDimension < 3 )? _TMST::ImageDimension: 3; for( unsigned int i = 0; i < 2; ++i ) { double buf[ 3 ]; points->GetPoint( i, buf ); pnt.Fill( 0 ); for( unsigned int d = 0; d < dim; ++d ) pnt[ d ] = buf[ d ]; if( mst->TransformPhysicalPointToIndex( pnt, idx ) ) seeds.push_back( idx ); } // rof } // fi typename _TPath::Pointer path; mst->GetPath( path, seeds[ 0 ], seeds[ 1 ] ); this->GetOutput( "Output" )->SetITK( path ); } // eof - $RCSfile$