1 #include "ExtractBranchesFromMinimumSpanningTree.h"
5 #include <cpPlugins/Interface/PointList.h>
6 #include <cpPlugins/Interface/PolyLineParametricPath.h>
7 #include <fpaPlugins/MinimumSpanningTree.h>
9 #include <fpa/Base/MinimumSpanningTree.h>
10 #include <fpa/Base/ExtractBranchesFromMinimumSpanningTree.h>
12 // -------------------------------------------------------------------------
13 fpaPlugins::ExtractBranchesFromMinimumSpanningTree::
14 ExtractBranchesFromMinimumSpanningTree( )
17 this->_AddInput( "MinimumSpanningTree" );
18 this->_AddInput( "EndPoints" );
19 this->_AddOutput< cpPlugins::Interface::PolyLineParametricPath >( "Output" );
22 // -------------------------------------------------------------------------
23 fpaPlugins::ExtractBranchesFromMinimumSpanningTree::
24 ~ExtractBranchesFromMinimumSpanningTree( )
28 // -------------------------------------------------------------------------
29 std::string fpaPlugins::ExtractBranchesFromMinimumSpanningTree::
32 std::string err = this->_GD0< 2 >( );
34 err = this->_GD0< 3 >( );
36 err = this->_GD0< 4 >( );
40 // -------------------------------------------------------------------------
41 template< unsigned int D >
42 std::string fpaPlugins::ExtractBranchesFromMinimumSpanningTree::
45 typedef itk::Index< D > _V;
46 typedef itk::Functor::IndexLexicographicCompare< D > _VC;
47 typedef fpa::Base::MinimumSpanningTree< _V, _VC > _MST;
48 typedef fpa::Base::ExtractBranchesFromMinimumSpanningTree< _MST > _Filter;
52 this->GetInputData< fpaPlugins::MinimumSpanningTree >(
56 return( "fpaPlugins::ExtractBranchesFromMinimumSpanningTree: Input MST type not supported." );
58 this->GetInputData< cpPlugins::Interface::PointList >( "EndPoints" );
59 if( endpoints->GetNumberOfPoints( ) < 2 )
60 return( "fpaPlugins::ExtractBranchesFromMinimumSpanningTree: Not enough end-points (<2)." );
61 if( endpoints->HaveEuclideanPoints( ) )
62 return( "fpaPlugins::ExtractBranchesFromMinimumSpanningTree: end-points are on euclidean space." );
64 // Create filter and connect input
65 _Filter* filter = this->_CreateITK< _Filter >( );
66 filter->SetInput( tree );
67 for( unsigned int i = 0; i < endpoints->GetNumberOfPoints( ); ++i )
68 filter->AddEndPoint( endpoints->GetPoint< _V >( i ) );
71 // Connect output and finish
73 this->GetOutputData< cpPlugins::Interface::PolyLineParametricPath >( "Output" );
74 out->SetITK( filter->GetOutput( ) );