1 #ifndef __fpa__Base__FastMarching__hxx__
2 #define __fpa__Base__FastMarching__hxx__
4 // -------------------------------------------------------------------------
5 template< class _TSuperclass >
6 fpa::Base::FastMarching< _TSuperclass >::
12 // -------------------------------------------------------------------------
13 template< class _TSuperclass >
14 fpa::Base::FastMarching< _TSuperclass >::
19 // -------------------------------------------------------------------------
20 template< class _TSuperclass >
21 bool fpa::Base::FastMarching< _TSuperclass >::
22 _UpdateValue( _TQueueNode& v, const _TQueueNode& p )
24 // Compute quadratic coefficients
25 double a = double( 0 );
26 double b = double( 0 );
27 double c = double( 0 );
28 TFastMarchingNeighborhood neighs = this->_FastMarchingNeighbors( v.Vertex );
29 for( unsigned int i = 0; i < neighs.size( ); i += 2 )
31 double tn = double( this->_GetResult( neighs[ i ].first ) );
32 double tp = double( this->_GetResult( neighs[ i + 1 ].first ) );
33 double dd = double( 0 );
34 double td = this->m_InitResult;
38 dd = neighs[ i ].second;
43 dd = neighs[ i + 1 ].second;
47 if( td < double( this->m_InitResult ) )
49 dd = double( 1 ) / ( dd * dd );
57 double F = double( this->_GetInputValue( v, p ) );
58 c -= double( 1 ) / ( F * F );
60 // Solve quadratic equation
61 double d = ( b * b ) - ( a * c );
62 if( d >= double( 0 ) )
66 double s1 = std::fabs( ( b + d ) / a );
67 double s2 = std::fabs( ( b - d ) / a );
68 v.Result = TOutput( ( s2 < s1 )? s1: s2 );
69 if( v.Result < this->_GetResult( v.Vertex ) )
70 this->_UpdateResult( v );
74 std::cout << std::endl << "-- FM --> " << v.Vertex << " " << d << std::endl;
80 #endif // __fpa__Base__FastMarching__hxx__