X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FBase%2FDijkstra.h;h=c93d575c927c176c41a79bdaf22755e8594ec130;hb=ed2108383e59a45c6fa2e9259a27256a93d8aa6a;hp=a6212cf9b770fe178605f0d241fdfd3430dfd0d6;hpb=9622bd5b833a8845881003228207e0caca59b081;p=FrontAlgorithms.git diff --git a/lib/fpa/Base/Dijkstra.h b/lib/fpa/Base/Dijkstra.h index a6212cf..c93d575 100644 --- a/lib/fpa/Base/Dijkstra.h +++ b/lib/fpa/Base/Dijkstra.h @@ -1,8 +1,12 @@ -#ifndef __FPA__BASE__DIJKSTRA__H__ -#define __FPA__BASE__DIJKSTRA__H__ +// ========================================================================= +// @author Leonardo Florez Valencia +// @email florez-l@javeriana.edu.co +// ========================================================================= -#include -#include +#ifndef __fpa__Base__Dijkstra__h__ +#define __fpa__Base__Dijkstra__h__ + +#include namespace fpa { @@ -10,111 +14,58 @@ namespace fpa { /** */ - template< class V, class C, class VV, class VC > - class DijkstraTraits - { - public: - typedef V TVertex; - typedef C TResult; - typedef C TCost; - typedef VV TVertexValue; - typedef VC TVertexCmp; - typedef long TFrontId; - - class TNode - { - public: - TNode( ) - : Cost( 0 ) - { } - TNode( const TVertex& v, const TFrontId& f ) - : Vertex( v ), - Parent( v ), - Result( TResult( 0 ) ), - FrontId( f ), - Cost( TCost( 0 ) ) - { } - TNode( const TVertex& v, const TResult& r, const TFrontId& f ) - : Vertex( v ), - Parent( v ), - Result( r ), - FrontId( f ), - Cost( TCost( 0 ) ) - { } - virtual ~TNode( ) - { } - - // NOTE: stl::heaps work as maximum priority queues - bool operator<( const TNode& other ) const - { return( other.Cost < this->Cost ); } - - TVertex Vertex; - TVertex Parent; - TResult Result; - TFrontId FrontId; - TCost Cost; - }; - - typedef std::vector< TNode > TNodes; - }; - - /** - * Dijkstra is a front propagation algorithm that minimizes costs - */ - template< class V, class C, class VV, class VC, class B > + template< class _TAlgorithm, class _TMST > class Dijkstra - : public Algorithm< DijkstraTraits< V, C, VV, VC >, B > + : public fpa::Base::DijkstraBase< _TAlgorithm > { public: - // Templated types - typedef V TVertex; - typedef C TCost; - typedef VV TVertexValue; - typedef B TBaseFilter; - typedef DijkstraTraits< V, C, VV, VC > TTraits; - - // Standard class typdedefs - typedef Dijkstra Self; - typedef Algorithm< TTraits, B > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; + typedef Dijkstra Self; + typedef fpa::Base::DijkstraBase< _TAlgorithm > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; - protected: - typedef typename TTraits::TFrontId _TFrontId; - typedef typename TTraits::TNode _TNode; - typedef typename TTraits::TNodes _TNodes; + typedef _TMST TMST; + + typedef typename Superclass::TNode TNode; + typedef typename Superclass::TNodes TNodes; + typedef typename Superclass::TInputValue TInputValue; + typedef typename Superclass::TOutputValue TOutputValue; + typedef typename Superclass::TFrontId TFrontId; + typedef typename Superclass::TVertex TVertex; + typedef typename Superclass::TSeeds TSeeds; - typedef std::vector< _TNode > _TQueue; + typedef typename Superclass::TQueue TQueue; + typedef typename Superclass::TQueueOrder TQueueOrder; + typedef typename Superclass::TWeightFunction TWeightFunction; public: - itkTypeMacro( Dijkstra, Base ); + TMST* GetMinimumSpanningTree( ); + const TMST* GetMinimumSpanningTree( ) const; protected: Dijkstra( ); virtual ~Dijkstra( ); - virtual void _InitializeQueue ( ); - virtual bool _IsQueueEmpty ( ) const; - virtual void _QueuePush ( const _TNode& n ); - virtual _TNode _QueuePop ( ); - virtual void _QueueClear ( ); - virtual bool _UpdateNeigh ( _TNode& nn, const _TNode& n ); + virtual void _AfterGenerateData( ) override; + virtual void _UpdateOutputValue( const TNode& n ) override; private: - // Purposely not implemented - Dijkstra( const Self& ); - void operator=( const Self& ); + // Purposely not implemented. + Dijkstra( const Self& other ); + Self& operator=( const Self& other ); - private: - _TQueue m_Queue; + protected: + unsigned int m_MSTIdx; }; } // ecapseman } // ecapseman -#include +#ifndef ITK_MANUAL_INSTANTIATION +# include +#endif // ITK_MANUAL_INSTANTIATION -#endif // __FPA__BASE__DIJKSTRA__H__ +#endif // __fpa__Base__Dijkstra__h__ // eof - $RCSfile$