1 #include "ExtractBranchesFromMinimumSpanningTree.h"
5 #include <cpPlugins/Interface/PointList.h>
6 #include <fpaPlugins/MinimumSpanningTree.h>
8 #include <fpa/Base/MinimumSpanningTree.h>
9 #include <fpa/Base/ExtractBranchesFromMinimumSpanningTree.h>
11 // -------------------------------------------------------------------------
12 fpaPlugins::ExtractBranchesFromMinimumSpanningTree::
13 ExtractBranchesFromMinimumSpanningTree( )
16 this->_AddInput( "MinimumSpanningTree" );
17 this->_AddInput( "EndPoints" );
18 this->_AddOutput< cpPlugins::Interface::DataObject >( "Output" );
21 // -------------------------------------------------------------------------
22 fpaPlugins::ExtractBranchesFromMinimumSpanningTree::
23 ~ExtractBranchesFromMinimumSpanningTree( )
27 // -------------------------------------------------------------------------
28 std::string fpaPlugins::ExtractBranchesFromMinimumSpanningTree::
31 std::string err = this->_GD0< 2 >( );
33 err = this->_GD0< 3 >( );
35 err = this->_GD0< 4 >( );
39 // -------------------------------------------------------------------------
40 template< unsigned int D >
41 std::string fpaPlugins::ExtractBranchesFromMinimumSpanningTree::
44 typedef itk::Index< D > _V;
45 typedef itk::Functor::IndexLexicographicCompare< D > _VC;
46 typedef fpa::Base::MinimumSpanningTree< _V, _VC > _MST;
47 typedef fpa::Base::ExtractBranchesFromMinimumSpanningTree< _MST > _Filter;
51 this->GetInputData< fpaPlugins::MinimumSpanningTree >(
55 return( "fpaPlugins::ExtractBranchesFromMinimumSpanningTree: Input MST type not supported." );
57 this->GetInputData< cpPlugins::Interface::PointList >( "EndPoints" );
58 if( endpoints->GetNumberOfPoints( ) < 2 )
59 return( "fpaPlugins::ExtractBranchesFromMinimumSpanningTree: Not enough end-points (<2)." );
60 if( endpoints->HaveEuclideanPoints( ) )
61 return( "fpaPlugins::ExtractBranchesFromMinimumSpanningTree: end-points are on euclidean space." );
63 // Create filter and connect input
64 _Filter* filter = this->_CreateITK< _Filter >( );
65 filter->SetInput( tree );
66 for( unsigned int i = 0; i < endpoints->GetNumberOfPoints( ); ++i )
67 filter->AddEndPoint( endpoints->GetPoint< _V >( i ) );
70 // Connect output and finish
72 this->GetOutputData< cpPlugins::Interface::DataObject >( "Output" );
73 out->SetITK( filter->GetOutput( ) );