]> 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 #include <limits>
9
10 // -------------------------------------------------------------------------
11 template< class _TDataInterface >
12 void fpa::Filters::RandomWalker< _TDataInterface >::
13 SetWeightFunction( TScalarWeight* p )
14 {
15   if( this->m_ScalarWeight.GetPointer( ) != p )
16   {
17     this->_Deassociate( this->m_ScalarWeight );
18     this->m_ScalarWeight = p;
19     this->_Associate( this->m_ScalarWeight );
20     this->Modified( );
21
22   } // fi
23 }
24
25 // -------------------------------------------------------------------------
26 template< class _TDataInterface >
27 void fpa::Filters::RandomWalker< _TDataInterface >::
28 SetWeightFunction( TVertexWeight* p )
29 {
30   if( this->m_VertexWeight.GetPointer( ) != p )
31   {
32     this->_Deassociate( this->m_VertexWeight );
33     this->m_VertexWeight = p;
34     this->_Associate( this->m_VertexWeight );
35     this->Modified( );
36
37   } // fi
38 }
39
40 // -------------------------------------------------------------------------
41 template< class _TDataInterface >
42 fpa::Filters::RandomWalker< _TDataInterface >::
43 RandomWalker( )
44   : Superclass( false )
45 {
46   this->SetInitValue( TCost( 0 ) );
47   this->SetFillValue( std::numeric_limits< TCost >::max( ) );
48   /* TODO
49      this->SetWeight(
50      fpa::Functors::RegionGrow::Tautology< TInputValue >::New( )
51      );
52   */
53 }
54
55 // -------------------------------------------------------------------------
56 template< class _TDataInterface >
57 fpa::Filters::RandomWalker< _TDataInterface >::
58 ~RandomWalker( )
59 {
60 }
61
62 // -------------------------------------------------------------------------
63 template< class _TDataInterface >
64 void fpa::Filters::RandomWalker< _TDataInterface >::
65 _PostComputeOutputValue( TNode& n )
66 {
67   // Nothing to do with this algorithm
68 }
69
70 // -------------------------------------------------------------------------
71 template< class _TDataInterface >
72 void fpa::Filters::RandomWalker< _TDataInterface >::
73 _PreComputeOutputValue( TNode& n )
74 {
75   if( this->m_VertexWeight.IsNotNull( ) )
76   {
77     TCost c = this->m_VertexWeight->Evaluate( n.Vertex, n.Parent );
78     if( this->m_ScalarWeight.IsNotNull( ) )
79       c = this->m_ScalarWeight->Evaluate( c );
80     n.Value = c + this->_GetOutputValue( n.Parent );
81   }
82   else
83     n.Value = TCost( -1 );
84 }
85
86 #endif // __fpa__Filters__RandomWalker__hxx__
87 // eof - $RCSfile$