X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FImage%2FDijkstra.hxx;h=bf6b5f09d67f99382f012d75b129d0921adf12bc;hb=5f930b3a1e6f004d9f06bd50ae243724d7c007b8;hp=4f7b60beee216b3700d416017c4105395246a8dc;hpb=5e326afe442245572b6c3ec98ebeec8b45f9012f;p=FrontAlgorithms.git diff --git a/lib/fpa/Image/Dijkstra.hxx b/lib/fpa/Image/Dijkstra.hxx index 4f7b60b..bf6b5f0 100644 --- a/lib/fpa/Image/Dijkstra.hxx +++ b/lib/fpa/Image/Dijkstra.hxx @@ -1,59 +1,43 @@ -#ifndef __FPA__IMAGE__DIJKSTRA__HXX__ -#define __FPA__IMAGE__DIJKSTRA__HXX__ +#ifndef __fpa__Image__Dijkstra__hxx__ +#define __fpa__Image__Dijkstra__hxx__ -#include +#include // ------------------------------------------------------------------------- -template< class I, class O > -fpa::Image::Dijkstra< I, O >:: +template< class _TInputImage, class _TOutputImage > +fpa::Image::Dijkstra< _TInputImage, _TOutputImage >:: Dijkstra( ) : Superclass( ) { - this->m_CostFunction = TCostFunction::New( ); -} + typedef + fpa::Image::Functors::SimpleDijkstraCost< _TInputImage, TOutput > + _TCost; -// ------------------------------------------------------------------------- -template< class I, class O > -fpa::Image::Dijkstra< I, O >:: -~Dijkstra( ) -{ + typename _TCost::Pointer cost = _TCost::New( ); + this->SetCostFunction( cost ); } // ------------------------------------------------------------------------- -template< class I, class O > -typename fpa::Image::Dijkstra< I, O >:: -TResult fpa::Image::Dijkstra< I, O >:: -_Cost( const TVertex& v, const TVertex& p ) const +template< class _TInputImage, class _TOutputImage > +fpa::Image::Dijkstra< _TInputImage, _TOutputImage >:: +~Dijkstra( ) { - if( this->_HasEdge( v, p ) ) - { - TResult c = this->m_CostFunction->Evaluate( v, p ); - if( this->m_ConversionFunction.IsNotNull( ) ) - c = this->m_ConversionFunction->Evaluate( c ); - return( c ); - } - else - return( std::numeric_limits< TResult >::max( ) ); } // ------------------------------------------------------------------------- -template< class I, class O > -void fpa::Image::Dijkstra< I, O >:: +template< class _TInputImage, class _TOutputImage > +void fpa::Image::Dijkstra< _TInputImage, _TOutputImage >:: _BeforeGenerateData( ) { this->Superclass::_BeforeGenerateData( ); - this->m_CostFunction->SetInputImage( this->GetInput( ) ); -} -// ------------------------------------------------------------------------- -template< class I, class O > -void fpa::Image::Dijkstra< I, O >:: -_InitResults( ) -{ - this->Superclass::_InitResults( ); - this->GetOutput( )->FillBuffer( TResult( 0 ) ); + TCostFunction* cost = + dynamic_cast< TCostFunction* >( this->GetCostFunction( ) ); + if( cost == NULL ) + itkExceptionMacro( << "CostFunction not well defined." ); + cost->SetImage( this->GetInput( ) ); } -#endif // __FPA__IMAGE__DIJKSTRA__HXX__ +#endif // __fpa__Image__Dijkstra__hxx__ // eof - $RCSfile$