]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/DijkstraBase.h
fd36890738e6c18f88d5b125521b02d4710940da
[FrontAlgorithms.git] / lib / fpa / Base / DijkstraBase.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __fpa__Base__DijkstraBase__h__
7 #define __fpa__Base__DijkstraBase__h__
8
9 #include <vector>
10
11 #include <itkConceptChecking.h>
12 #include <fpa/Base/Functors/Dijkstra/Function.h>
13
14 namespace fpa
15 {
16   namespace Base
17   {
18     /**
19      */
20     template< class _TAlgorithm >
21     class DijkstraBase
22       : public _TAlgorithm
23     {
24     public:
25       typedef DijkstraBase                    Self;
26       typedef _TAlgorithm                     Superclass;
27       typedef itk::SmartPointer< Self >       Pointer;
28       typedef itk::SmartPointer< const Self > ConstPointer;
29
30       typedef typename _TAlgorithm::TNode        TNode;
31       typedef typename _TAlgorithm::TInputValue  TInputValue;
32       typedef typename _TAlgorithm::TOutputValue TOutputValue;
33       typedef typename _TAlgorithm::TVertex      TVertex;
34
35       typedef std::vector< TNode > TQueue;
36       struct TQueueOrder
37       {
38         bool operator()( const TNode& a, const TNode& b ) const
39           {
40             return( b.Value < a.Value );
41           }
42       };
43       typedef fpa::Base::Functors::Dijkstra::Function< TVertex, TOutputValue > TWeightFunction;
44
45     public:
46       itkConceptMacro(
47         Check_TOutputValue,
48         ( itk::Concept::IsFloatingPoint< TOutputValue > )
49         );
50
51     public:
52       itkGetObjectMacro( WeightFunction, TWeightFunction );
53       itkSetObjectMacro( WeightFunction, TWeightFunction );
54
55     public:
56       virtual itk::ModifiedTimeType GetMTime( ) const override;
57
58     protected:
59       DijkstraBase( );
60       virtual ~DijkstraBase( );
61
62       virtual TOutputValue _ComputeOutputValue( const TNode& n ) override;
63       virtual void _QueueInit( ) override;
64       virtual void _QueueClear( ) override;
65       virtual TNode _QueuePop( ) override;
66       virtual void _QueuePush( const TNode& node ) override;
67       virtual unsigned long _QueueSize( ) const override;
68
69     private:
70       // Purposely not implemented.
71       DijkstraBase( const Self& other );
72       Self& operator=( const Self& other );
73
74     protected:
75       typename TWeightFunction::Pointer m_WeightFunction;
76
77       TQueue      m_Queue;
78       TQueueOrder m_QueueOrder;
79     };
80
81   } // ecapseman
82
83 } // ecapseman
84
85 #ifndef ITK_MANUAL_INSTANTIATION
86 #  include <fpa/Base/DijkstraBase.hxx>
87 #endif // ITK_MANUAL_INSTANTIATION
88
89 #endif // __fpa__Base__DijkstraBase__h__
90
91 // eof - $RCSfile$