]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/DijkstraBase.h
4f08eb94bf94a9ab1ae95c3b6d214c43c6cc1fcf
[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::TNodes       TNodes;
32       typedef typename _TAlgorithm::TInputValue  TInputValue;
33       typedef typename _TAlgorithm::TOutputValue TOutputValue;
34       typedef typename _TAlgorithm::TVertex      TVertex;
35
36       typedef std::vector< TNode > TQueue;
37       struct TQueueOrder
38       {
39         bool operator()( const TNode& a, const TNode& b ) const
40           {
41             return( b.Value < a.Value );
42           }
43       };
44       typedef fpa::Base::Functors::Dijkstra::Function< TVertex, TOutputValue > TWeightFunction;
45
46     public:
47       itkConceptMacro(
48         Check_TOutputValue,
49         ( itk::Concept::IsFloatingPoint< TOutputValue > )
50         );
51
52     public:
53       itkGetObjectMacro( WeightFunction, TWeightFunction );
54       itkSetObjectMacro( WeightFunction, TWeightFunction );
55
56     public:
57       virtual itk::ModifiedTimeType GetMTime( ) const override;
58
59     protected:
60       DijkstraBase( );
61       virtual ~DijkstraBase( );
62
63       virtual void _ComputeOutputValue( TNode& n ) 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       virtual void _PrepareSeeds( TNodes& nodes ) override;
69
70     private:
71       // Purposely not implemented.
72       DijkstraBase( const Self& other );
73       Self& operator=( const Self& other );
74
75     protected:
76       typename TWeightFunction::Pointer m_WeightFunction;
77
78       TQueue      m_Queue;
79       TQueueOrder m_QueueOrder;
80     };
81
82   } // ecapseman
83
84 } // ecapseman
85
86 #ifndef ITK_MANUAL_INSTANTIATION
87 #  include <fpa/Base/DijkstraBase.hxx>
88 #endif // ITK_MANUAL_INSTANTIATION
89
90 #endif // __fpa__Base__DijkstraBase__h__
91
92 // eof - $RCSfile$