X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FFilters%2FRandomWalker.hxx;fp=lib%2Ffpa%2FFilters%2FRandomWalker.hxx;h=18b8d2b7988b9f79c1edd11039bfa00d27cd048f;hb=bd89a1af0c14ed2ac0afeca923103de54283cbaf;hp=0000000000000000000000000000000000000000;hpb=a8ac405fe1422bc0792a810f7f0693096a22c20e;p=FrontAlgorithms.git diff --git a/lib/fpa/Filters/RandomWalker.hxx b/lib/fpa/Filters/RandomWalker.hxx new file mode 100644 index 0000000..18b8d2b --- /dev/null +++ b/lib/fpa/Filters/RandomWalker.hxx @@ -0,0 +1,84 @@ +// ========================================================================= +// @author Leonardo Florez Valencia +// @email florez-l@javeriana.edu.co +// ========================================================================= +#ifndef __fpa__Filters__RandomWalker__hxx__ +#define __fpa__Filters__RandomWalker__hxx__ + +// ------------------------------------------------------------------------- +template< class _TDataInterface > +void fpa::Filters::RandomWalker< _TDataInterface >:: +SetWeightFunction( TScalarWeight* p ) +{ + if( this->m_ScalarWeight.GetPointer( ) != p ) + { + this->_Deassociate( this->m_ScalarWeight ); + this->m_ScalarWeight = p; + this->_Associate( this->m_ScalarWeight ); + this->Modified( ); + + } // fi +} + +// ------------------------------------------------------------------------- +template< class _TDataInterface > +void fpa::Filters::RandomWalker< _TDataInterface >:: +SetWeightFunction( TVertexWeight* p ) +{ + if( this->m_VertexWeight.GetPointer( ) != p ) + { + this->_Deassociate( this->m_VertexWeight ); + this->m_VertexWeight = p; + this->_Associate( this->m_VertexWeight ); + this->Modified( ); + + } // fi +} + +// ------------------------------------------------------------------------- +template< class _TDataInterface > +fpa::Filters::RandomWalker< _TDataInterface >:: +RandomWalker( ) + : Superclass( false ) +{ + this->SetInitValue( TCost( 0 ) ); + /* TODO + this->SetWeight( + fpa::Functors::RegionGrow::Tautology< TInputValue >::New( ) + ); + */ +} + +// ------------------------------------------------------------------------- +template< class _TDataInterface > +fpa::Filters::RandomWalker< _TDataInterface >:: +~RandomWalker( ) +{ +} + +// ------------------------------------------------------------------------- +template< class _TDataInterface > +void fpa::Filters::RandomWalker< _TDataInterface >:: +_PostComputeOutputValue( TNode& n ) +{ + // Nothing to do with this algorithm +} + +// ------------------------------------------------------------------------- +template< class _TDataInterface > +void fpa::Filters::RandomWalker< _TDataInterface >:: +_PreComputeOutputValue( TNode& n ) +{ + if( this->m_VertexWeight.IsNotNull( ) ) + { + TCost c = this->m_VertexWeight->Evaluate( n.Vertex, n.Parent ); + if( this->m_ScalarWeight.IsNotNull( ) ) + c = this->m_ScalarWeight->Evaluate( c ); + n.Value = c + this->_GetOutputValue( n.Parent ); + } + else + n.Value = TCost( -1 ); +} + +#endif // __fpa__Filters__RandomWalker__hxx__ +// eof - $RCSfile$