]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/ExtractBranchesFromMinimumSpanningTree.hxx
Branches extraction algorithm from MSTs updated
[FrontAlgorithms.git] / lib / fpa / Base / ExtractBranchesFromMinimumSpanningTree.hxx
1 #ifndef __FPA__BASE__EXTRACTBRANCHESFROMMINIMUMSPANNINGTREE__HXX__
2 #define __FPA__BASE__EXTRACTBRANCHESFROMMINIMUMSPANNINGTREE__HXX__
3
4 // -------------------------------------------------------------------------
5 template< class T >
6 const T* fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
7 GetInput( ) const
8 {
9   return(
10     dynamic_cast< const T* >( this->itk::ProcessObject::GetInput( 0 ) )
11     );
12 }
13
14 // -------------------------------------------------------------------------
15 template< class T >
16 void fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
17 SetInput( const T* tree )
18 {
19   this->itk::ProcessObject::SetNthInput( 0, const_cast< T* >( tree ) );
20 }
21
22 // -------------------------------------------------------------------------
23 template< class T >
24 typename fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
25 TBranches* fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
26 GetOutput( )
27 {
28   return(
29     itkDynamicCastInDebugMode< TBranches* >( this->GetPrimaryOutput( ) )
30     );
31 }
32
33 // -------------------------------------------------------------------------
34 template< class T >
35 void fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
36 ClearEndPoints( )
37 {
38   this->m_EndPoints.clear( );
39   this->Modified( );
40 }
41
42 // -------------------------------------------------------------------------
43 template< class T >
44 void fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
45 AddEndPoint( const TVertex& v )
46 {
47   if( this->m_EndPoints.find( v ) == this->m_EndPoints.end( ) )
48   {
49     std::cout << "Add " << v << std::endl;
50
51     this->m_EndPoints.insert( v );
52     this->Modified( );
53
54   } // fi
55 }
56
57 // -------------------------------------------------------------------------
58 template< class T >
59 bool fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
60 HasEndPoint( const TVertex& v ) const
61 {
62   return( this->m_EndPoints.find( v ) != this->m_EndPoints.end( ) );
63 }
64
65 // -------------------------------------------------------------------------
66 template< class T >
67 unsigned long fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
68 GetNumberOfEndPoints( ) const
69 {
70   return( this->m_EndPoints.size( ) );
71 }
72
73 // -------------------------------------------------------------------------
74 template< class T >
75 fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
76 ExtractBranchesFromMinimumSpanningTree( )
77   : Superclass( )
78 {
79   this->itk::ProcessObject::SetNumberOfRequiredInputs( 1 );
80
81   typename TBranches::Pointer out =
82     static_cast< TBranches* >( this->MakeOutput( 0 ).GetPointer( ) );
83   this->itk::ProcessObject::SetNumberOfRequiredOutputs( 1 );
84   this->itk::ProcessObject::SetNthOutput( 0, out.GetPointer( ) );
85 }
86
87 // -------------------------------------------------------------------------
88 template< class T >
89 fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
90 ~ExtractBranchesFromMinimumSpanningTree( )
91 {
92 }
93
94 // -------------------------------------------------------------------------
95 template< class T >
96 void fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
97 GenerateData( )
98 {
99   const T* tree = this->GetInput( );
100   TBranches* branches = this->GetOutput( );
101
102   auto e0It = this->m_EndPoints.begin( );
103   for( ; e0It != this->m_EndPoints.end( ); ++e0It )
104   {
105     auto e1It = e0It;
106     e1It++;
107     for( ; e1It != this->m_EndPoints.end( ); ++e1It )
108     {
109       std::cout << *e0It << " " << *e1It << std::endl;
110       // std::vector< TVertex > path = tree->GetPath( *e0It, *e1It );
111
112     } // rof
113
114   } // rof
115 }
116
117 /*
118   private:
119   // Purposely not implemented
120   ExtractBranchesFromMinimumSpanningTree( const Self& other );
121   Self& operator=( const Self& other );
122
123   protected:
124   TEndPoints m_EndPoints;
125   };
126
127   } // ecapseman
128
129   } // ecapseman
130 */
131
132 #endif // __FPA__BASE__EXTRACTBRANCHESFROMMINIMUMSPANNINGTREE__HXX__
133
134 // eof - $RCSfile$