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