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