]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Filters/RandomWalker.hxx
...
[FrontAlgorithms.git] / lib / fpa / Filters / RandomWalker.hxx
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5 #ifndef __fpa__Filters__RandomWalker__hxx__
6 #define __fpa__Filters__RandomWalker__hxx__
7
8 // -------------------------------------------------------------------------
9 template< class _TDataInterface >
10 void fpa::Filters::RandomWalker< _TDataInterface >::
11 SetWeightFunction( TScalarWeight* p )
12 {
13   if( this->m_ScalarWeight.GetPointer( ) != p )
14   {
15     this->_Deassociate( this->m_ScalarWeight );
16     this->m_ScalarWeight = p;
17     this->_Associate( this->m_ScalarWeight );
18     this->Modified( );
19
20   } // fi
21 }
22
23 // -------------------------------------------------------------------------
24 template< class _TDataInterface >
25 void fpa::Filters::RandomWalker< _TDataInterface >::
26 SetWeightFunction( TVertexWeight* p )
27 {
28   if( this->m_VertexWeight.GetPointer( ) != p )
29   {
30     this->_Deassociate( this->m_VertexWeight );
31     this->m_VertexWeight = p;
32     this->_Associate( this->m_VertexWeight );
33     this->Modified( );
34
35   } // fi
36 }
37
38 // -------------------------------------------------------------------------
39 template< class _TDataInterface >
40 fpa::Filters::RandomWalker< _TDataInterface >::
41 RandomWalker( )
42   : Superclass( false )
43 {
44   this->SetInitValue( TCost( 0 ) );
45   /* TODO
46      this->SetWeight(
47      fpa::Functors::RegionGrow::Tautology< TInputValue >::New( )
48      );
49   */
50 }
51
52 // -------------------------------------------------------------------------
53 template< class _TDataInterface >
54 fpa::Filters::RandomWalker< _TDataInterface >::
55 ~RandomWalker( )
56 {
57 }
58
59 // -------------------------------------------------------------------------
60 template< class _TDataInterface >
61 void fpa::Filters::RandomWalker< _TDataInterface >::
62 _PostComputeOutputValue( TNode& n )
63 {
64   // Nothing to do with this algorithm
65 }
66
67 // -------------------------------------------------------------------------
68 template< class _TDataInterface >
69 void fpa::Filters::RandomWalker< _TDataInterface >::
70 _PreComputeOutputValue( TNode& n )
71 {
72   if( this->m_VertexWeight.IsNotNull( ) )
73   {
74     TCost c = this->m_VertexWeight->Evaluate( n.Vertex, n.Parent );
75     if( this->m_ScalarWeight.IsNotNull( ) )
76       c = this->m_ScalarWeight->Evaluate( c );
77     n.Value = c + this->_GetOutputValue( n.Parent );
78   }
79   else
80     n.Value = TCost( -1 );
81 }
82
83 #endif // __fpa__Filters__RandomWalker__hxx__
84 // eof - $RCSfile$