#ifndef __fpa__Base__FastMarching__hxx__ #define __fpa__Base__FastMarching__hxx__ // ------------------------------------------------------------------------- template< class _TSuperclass > fpa::Base::FastMarching< _TSuperclass >:: FastMarching( ) : Superclass( ) { } // ------------------------------------------------------------------------- template< class _TSuperclass > fpa::Base::FastMarching< _TSuperclass >:: ~FastMarching( ) { } // ------------------------------------------------------------------------- template< class _TSuperclass > bool fpa::Base::FastMarching< _TSuperclass >:: _UpdateValue( _TQueueNode& v, const _TQueueNode& p ) { // Compute quadratic coefficients double a = double( 0 ); double b = double( 0 ); double c = double( 0 ); TFastMarchingNeighborhood neighs = this->_FastMarchingNeighbors( v.Vertex ); for( unsigned int i = 0; i < neighs.size( ); i += 2 ) { double tn = double( this->_GetResult( neighs[ i ].first ) ); double tp = double( this->_GetResult( neighs[ i + 1 ].first ) ); double dd = double( 0 ); double td = this->m_InitResult; if( tn < tp ) { td = tn; dd = neighs[ i ].second; } else { td = tp; dd = neighs[ i + 1 ].second; } // fi if( td < double( this->m_InitResult ) ) { dd = double( 1 ) / ( dd * dd ); a += dd; b += td * dd; c += td * td * dd; } // fi } // rof double F = double( this->_GetInputValue( v, p ) ); c -= double( 1 ) / ( F * F ); // Solve quadratic equation double d = ( b * b ) - ( a * c ); if( d >= double( 0 ) ) { d = std::sqrt( d ); b *= double( -1 ); double s1 = std::fabs( ( b + d ) / a ); double s2 = std::fabs( ( b - d ) / a ); v.Result = TOutput( ( s2 < s1 )? s1: s2 ); if( v.Result < this->_GetResult( v.Vertex ) ) this->_UpdateResult( v ); } else { std::cout << std::endl << "-- FM --> " << v.Vertex << " " << d << std::endl; std::exit( 1 ); } return( true ); } #endif // __fpa__Base__FastMarching__hxx__ // eof - $RCSfile$