]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/Dijkstra.h
...
[FrontAlgorithms.git] / lib / fpa / Base / Dijkstra.h
1 #ifndef __fpa__Base__Dijkstra__h__
2 #define __fpa__Base__Dijkstra__h__
3
4 #include <vector>
5 #include <fpa/Config.h>
6 #include <itkFunctionBase.h>
7 #include <fpa/Base/DijkstraCostFunctionBase.h>
8
9 namespace fpa
10 {
11   namespace Base
12   {
13     /**
14      */
15     template< class _TSuperclass, class _TMST >
16     class Dijkstra
17       : public _TSuperclass
18     {
19     public:
20       typedef Dijkstra                        Self;
21       typedef _TSuperclass                    Superclass;
22       typedef itk::SmartPointer< Self >       Pointer;
23       typedef itk::SmartPointer< const Self > ConstPointer;
24
25       typedef _TMST TMST;
26       typedef typename Superclass::TOutput TOutput;
27       typedef typename Superclass::TVertex TVertex;
28
29       typedef itk::FunctionBase< TOutput, TOutput > TCostConversionFunction;
30       typedef DijkstraCostFunctionBase< TVertex, TOutput > TCostFunction;
31
32     protected:
33       typedef typename Superclass::_TQueueNode _TQueueNode;
34       struct _TQueueNodeCompare
35       {
36         bool operator( )( const _TQueueNode& a, const _TQueueNode& b )
37           {
38             return( b.Result < a.Result );
39           }
40       };
41       typedef std::vector< _TQueueNode > _TQueue;
42
43     public:
44       itkTypeMacro( Dijkstra, Algorithm );
45
46       itkGetObjectMacro( CostFunction, TCostFunction );
47       itkGetObjectMacro( CostConversionFunction, TCostConversionFunction );
48       itkSetObjectMacro( CostFunction, TCostFunction );
49       itkSetObjectMacro( CostConversionFunction, TCostConversionFunction );
50
51     public:
52       _TMST* GetMinimumSpanningTree( );
53       const _TMST* GetMinimumSpanningTree( ) const;
54
55     protected:
56       Dijkstra( );
57       virtual ~Dijkstra( );
58
59       virtual void _AfterGenerateData( ) fpa_OVERRIDE;
60
61       virtual void _UpdateResult( const _TQueueNode& n ) fpa_OVERRIDE;
62       virtual bool _UpdateValue(
63         _TQueueNode& v, const _TQueueNode& p
64         ) fpa_OVERRIDE;
65       virtual unsigned long _QueueSize( ) const fpa_OVERRIDE;
66       virtual void _QueueClear( ) fpa_OVERRIDE;
67       virtual void _QueuePush( const _TQueueNode& node ) fpa_OVERRIDE;
68       virtual _TQueueNode _QueuePop( ) fpa_OVERRIDE;
69
70     private:
71       // Purposely not defined
72       Dijkstra( const Self& other );
73       Self& operator=( const Self& other );
74
75     protected:
76       _TQueue m_Queue;
77       typename TCostFunction::Pointer m_CostFunction;
78       typename TCostConversionFunction::Pointer m_CostConversionFunction;
79
80       unsigned long m_MSTIndex;
81     };
82
83   } // ecapseman
84
85 } // ecapseman
86
87 #ifndef ITK_MANUAL_INSTANTIATION
88 #  include <fpa/Base/Dijkstra.hxx>
89 #endif // ITK_MANUAL_INSTANTIATION
90
91 #endif // __fpa__Base__Dijkstra__h__
92
93 // eof - $RCSfile$