1 #ifndef __FPA__BASE__EXTRACTBRANCHESFROMMINIMUMSPANNINGTREE__HXX__
2 #define __FPA__BASE__EXTRACTBRANCHESFROMMINIMUMSPANNINGTREE__HXX__
4 // -------------------------------------------------------------------------
6 const T* fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
10 dynamic_cast< const T* >( this->itk::ProcessObject::GetInput( 0 ) )
14 // -------------------------------------------------------------------------
16 void fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
17 SetInput( const T* tree )
19 this->itk::ProcessObject::SetNthInput( 0, const_cast< T* >( tree ) );
22 // -------------------------------------------------------------------------
24 typename fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
25 TBranches* fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
29 itkDynamicCastInDebugMode< TBranches* >( this->GetPrimaryOutput( ) )
33 // -------------------------------------------------------------------------
35 void fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
38 this->m_EndPoints.clear( );
42 // -------------------------------------------------------------------------
44 void fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
45 AddEndPoint( const TVertex& v )
47 if( this->m_EndPoints.find( v ) == this->m_EndPoints.end( ) )
49 this->m_EndPoints.insert( v );
55 // -------------------------------------------------------------------------
57 bool fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
58 HasEndPoint( const TVertex& v ) const
60 return( this->m_EndPoints.find( v ) != this->m_EndPoints.end( ) );
63 // -------------------------------------------------------------------------
65 unsigned long fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
66 GetNumberOfEndPoints( ) const
68 return( this->m_EndPoints.size( ) );
71 // -------------------------------------------------------------------------
73 fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
74 ExtractBranchesFromMinimumSpanningTree( )
77 this->itk::ProcessObject::SetNumberOfRequiredInputs( 1 );
79 typename TBranches::Pointer out = TBranches::New( );
80 this->itk::ProcessObject::SetNumberOfRequiredOutputs( 1 );
81 this->itk::ProcessObject::SetNthOutput( 0, out.GetPointer( ) );
84 // -------------------------------------------------------------------------
86 fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
87 ~ExtractBranchesFromMinimumSpanningTree( )
91 // -------------------------------------------------------------------------
93 void fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
96 auto tree = this->GetInput( );
97 auto branches = this->GetOutput( );
100 TEndPoints bifurcations, marks;
101 auto e0It = this->m_EndPoints.begin( );
102 for( ; e0It != this->m_EndPoints.end( ); ++e0It )
106 for( ; e1It != this->m_EndPoints.end( ); ++e1It )
108 auto path = tree->GetPath( *e0It, *e1It );
109 std::cout << "path" << std::endl;
110 auto pIt = path.begin( );
111 for( ; pIt != path.end( ); ++pIt )
113 if( marks.find( *pIt ) == marks.end( ) )
114 marks.insert( *pIt );
116 bifurcations.insert( *pIt );
124 // Construct branches
125 std::cout << bifurcations.size( ) << std::endl;
128 #endif // __FPA__BASE__EXTRACTBRANCHESFROMMINIMUMSPANNINGTREE__HXX__