]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/ExtractPathFromMinimumSpanningTree.hxx
...
[FrontAlgorithms.git] / lib / fpa / Base / ExtractPathFromMinimumSpanningTree.hxx
1 #ifndef __FPA__BASE__EXTRACTPATHFROMMINIMUMSPANNINGTREE__HXX__
2 #define __FPA__BASE__EXTRACTPATHFROMMINIMUMSPANNINGTREE__HXX__
3
4 // -------------------------------------------------------------------------
5 template< class T >
6 const T* fpa::Base::ExtractPathFromMinimumSpanningTree< 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::ExtractPathFromMinimumSpanningTree< 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::ExtractPathFromMinimumSpanningTree< T >::
25 TPath* fpa::Base::ExtractPathFromMinimumSpanningTree< T >::
26 GetOutput( )
27 {
28   return(
29     itkDynamicCastInDebugMode< TPath* >( this->GetPrimaryOutput( ) )
30     );
31 }
32
33 // -------------------------------------------------------------------------
34 template< class T >
35 fpa::Base::ExtractPathFromMinimumSpanningTree< T >::
36 ExtractPathFromMinimumSpanningTree( )
37   : Superclass( )
38 {
39   this->itk::ProcessObject::SetNumberOfRequiredInputs( 1 );
40
41   typename TPath::Pointer out = TPath::New( );
42   this->itk::ProcessObject::SetNumberOfRequiredOutputs( 1 );
43   this->itk::ProcessObject::SetNthOutput( 0, out.GetPointer( ) );
44 }
45
46 // -------------------------------------------------------------------------
47 template< class T >
48 fpa::Base::ExtractPathFromMinimumSpanningTree< T >::
49 ~ExtractPathFromMinimumSpanningTree( )
50 {
51 }
52
53 // -------------------------------------------------------------------------
54 template< class T >
55 void fpa::Base::ExtractPathFromMinimumSpanningTree< T >::
56 GenerateData( )
57 {
58   auto tree = this->GetInput( );
59   auto path = this->GetOutput( );
60
61   auto lst = tree->GetPath( this->m_Vertex0, this->m_Vertex1 );
62   path->Initialize( );
63   for( auto i = lst.begin( ); i != lst.end( ); ++i )
64     path->AddVertex( *i );
65   path->SetReferenceImage( tree );
66 }
67
68 #endif // __FPA__BASE__EXTRACTPATHFROMMINIMUMSPANNINGTREE__HXX__
69
70 // eof - $RCSfile$