#include "ExtractPathFromMinimumSpanningTree.h" #include #include #include // ------------------------------------------------------------------------- fpaPlugins::ExtractPathFromMinimumSpanningTree:: ExtractPathFromMinimumSpanningTree( ) : Superclass( ) { this->_AddInput( "MST" ); this->_AddInput( "Seeds" ); this->_AddOutput< cpPlugins::Path >( "Output" ); this->m_Parameters.ConfigureAsUint( "Vertex0" ); this->m_Parameters.ConfigureAsUint( "Vertex1" ); this->m_Parameters.SetUint( "Vertex0", 0 ); this->m_Parameters.SetUint( "Vertex1", 1 ); } // ------------------------------------------------------------------------- fpaPlugins::ExtractPathFromMinimumSpanningTree:: ~ExtractPathFromMinimumSpanningTree( ) { } // ------------------------------------------------------------------------- std::string fpaPlugins::ExtractPathFromMinimumSpanningTree:: _GenerateData( ) { typedef fpa::Image::MinimumSpanningTree< 2 > _2DMST; typedef fpa::Image::MinimumSpanningTree< 3 > _3DMST; auto mst = this->GetInputData( "MST" )->GetITK< itk::DataObject >( ); auto mst2 = dynamic_cast< _2DMST* >( mst ); auto mst3 = dynamic_cast< _3DMST* >( mst ); std::string r = this->_GD0( mst2 ); if( r != "" ) r = this->_GD0( mst3 ); return( r ); } // ------------------------------------------------------------------------- template< class _TMST > std::string fpaPlugins::ExtractPathFromMinimumSpanningTree:: _GD0( _TMST* mst ) { typedef fpa::Base::ExtractPathFromMinimumSpanningTree< _TMST > _TFilter; typedef cpExtensions::DataStructures::ImageIndexesContainer< _TMST::Dimension > _TVertices; if( mst == NULL ) return( "fpaPlugins::ExtractPathFromMinimumSpanningTree: No valid input tree." ); auto vertices = this->GetInputData( "Seeds" )->GetITK< _TVertices >( ); if( vertices == NULL ) return( "fpaPlugins::ExtractPathFromMinimumSpanningTree: No valid vertices." ); if( vertices->Get( ).size( ) < 2 ) return( "fpaPlugins::ExtractPathFromMinimumSpanningTree: Not enough vertices." ); auto v0 = vertices->Get( )[ this->m_Parameters.GetUint( "Vertex0" ) ]; auto v1 = vertices->Get( )[ this->m_Parameters.GetUint( "Vertex1" ) ]; // Create filter and connect input _TFilter* filter = this->_CreateITK< _TFilter >( ); filter->SetInput( mst ); filter->SetVertex0( v0 ); filter->SetVertex1( v1 ); filter->Update( ); // Connect output and finish this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); return( "" ); } // eof - $RCSfile$