]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/Dijkstra.hxx
40058e16e215541709704f455bb03ebbc79b1d6c
[FrontAlgorithms.git] / lib / fpa / Base / Dijkstra.hxx
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __fpa__Base__Dijkstra__hxx__
7 #define __fpa__Base__Dijkstra__hxx__
8
9 // -------------------------------------------------------------------------
10 template< class _TAlgorithm, class _TMST >
11 typename fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
12 TMST* fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
13 GetMinimumSpanningTree( )
14 {
15   dynamic_cast< TMST* >(
16     this->itk::ProcessObject::GetOutput( this->m_MSTIdx )
17     );
18 }
19
20 // -------------------------------------------------------------------------
21 template< class _TAlgorithm, class _TMST >
22 const typename fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
23 TMST* fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
24 GetMinimumSpanningTree( ) const
25 {
26   dynamic_cast< const TMST* >(
27     this->itk::ProcessObject::GetOutput( this->m_MSTIdx )
28     );
29 }
30
31 // -------------------------------------------------------------------------
32 template< class _TAlgorithm, class _TMST >
33 fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
34 Dijkstra( )
35   : Superclass( )
36 {
37   this->m_MSTIdx = this->GetNumberOfRequiredOutputs( );
38   this->itk::ProcessObject::SetNumberOfRequiredOutputs( this->m_MSTIdx + 1 );
39   this->SetNthOutput( this->m_MSTIdx, TMST::New( ) );
40 }
41
42 // -------------------------------------------------------------------------
43 template< class _TAlgorithm, class _TMST >
44 fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
45 ~Dijkstra( )
46 {
47 }
48
49 // -------------------------------------------------------------------------
50 template< class _TAlgorithm, class _TMST >
51 void fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
52 _AfterGenerateData( )
53 {
54   typedef typename Superclass::TSeedsInterface::TSeeds::iterator _TIt;
55
56   this->Superclass::_AfterGenerateData( );
57
58   TMST* mst = this->GetMinimumSpanningTree( );
59   mst->ClearSeeds( );
60   mst->SetCollisions( this->m_Collisions );
61   for( _TIt sIt = this->BeginSeeds( ); sIt != this->EndSeeds( ); ++sIt )
62     mst->AddSeed( sIt->Vertex );
63 }
64
65 // -------------------------------------------------------------------------
66 template< class _TAlgorithm, class _TMST >
67 void fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
68 _UpdateOutputValue( const TNode& n )
69 {
70   this->Superclass::_UpdateOutputValue( n );
71   this->GetMinimumSpanningTree( )->SetParent( n.Vertex, n.Parent );
72 }
73
74 #endif // __fpa__Base__Dijkstra__hxx__
75
76 // eof - $RCSfile$