]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/Dijkstra.hxx
9de7912d2597427ed381279679432b659115f72a
[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   return(
16     dynamic_cast< TMST* >(
17       this->itk::ProcessObject::GetOutput( this->m_MSTIdx )
18       )
19     );
20 }
21
22 // -------------------------------------------------------------------------
23 template< class _TAlgorithm, class _TMST >
24 const typename fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
25 TMST* fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
26 GetMinimumSpanningTree( ) const
27 {
28   return(
29     dynamic_cast< const TMST* >(
30       this->itk::ProcessObject::GetOutput( this->m_MSTIdx )
31       )
32     );
33 }
34
35 // -------------------------------------------------------------------------
36 template< class _TAlgorithm, class _TMST >
37 fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
38 Dijkstra( )
39   : Superclass( )
40 {
41   this->m_MSTIdx = this->GetNumberOfRequiredOutputs( );
42   this->itk::ProcessObject::SetNumberOfRequiredOutputs( this->m_MSTIdx + 1 );
43   this->SetNthOutput( this->m_MSTIdx, TMST::New( ) );
44 }
45
46 // -------------------------------------------------------------------------
47 template< class _TAlgorithm, class _TMST >
48 fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
49 ~Dijkstra( )
50 {
51 }
52
53 // -------------------------------------------------------------------------
54 template< class _TAlgorithm, class _TMST >
55 void fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
56 _AfterGenerateData( )
57 {
58   this->Superclass::_AfterGenerateData( );
59
60   TMST* mst = this->GetMinimumSpanningTree( );
61   mst->ClearSeeds( );
62   mst->SetCollisions( this->m_Collisions );
63
64   const TSeeds& seeds = this->GetSeeds( );
65   typename TSeeds::const_iterator sIt = seeds.begin( );
66   for( ; sIt != seeds.end( ); ++sIt )
67   {
68     if( sIt->IsUnified )
69       mst->AddSeed( sIt->Vertex );
70
71   } // rof
72 }
73
74 // -------------------------------------------------------------------------
75 template< class _TAlgorithm, class _TMST >
76 void fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
77 _UpdateOutputValue( TNode& n )
78 {
79   this->Superclass::_UpdateOutputValue( n );
80   this->GetMinimumSpanningTree( )->SetParent( n.Vertex, n.Parent );
81 }
82
83 #endif // __fpa__Base__Dijkstra__hxx__
84
85 // eof - $RCSfile$