]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/Dijkstra.h
...
[FrontAlgorithms.git] / lib / fpa / Base / Dijkstra.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __fpa__Base__Dijkstra__h__
7 #define __fpa__Base__Dijkstra__h__
8
9 #include <itkFunctionBase.h>
10 #include <fpa/Base/MinimumSpanningTree.h>
11 #include <fpa/Base/Functors/VertexParentBase.h>
12
13 namespace fpa
14 {
15   namespace Base
16   {
17     /**
18      */
19     template< class _TFilter, class _TMarksInterface, class _TSeedsInterface, class _TMST >
20     class Dijkstra
21       : public _TFilter,
22         public _TMarksInterface,
23         public _TSeedsInterface
24     {
25     public:
26       typedef Dijkstra                        Self;
27       typedef _TFilter                        Superclass;
28       typedef _TMarksInterface                TMarksInterface;
29       typedef _TSeedsInterface                TSeedsInterface;
30       typedef _TMST                           TMST;
31       typedef itk::SmartPointer< Self >       Pointer;
32       typedef itk::SmartPointer< const Self > ConstPointer;
33
34       typedef typename Superclass::TInputValue  TInputValue;
35       typedef typename Superclass::TOutputValue TOutputValue;
36       typedef typename Superclass::TVertex      TVertex;
37       typedef typename Superclass::TVertices    TVertices;
38
39       typedef itk::FunctionBase< TInputValue, TOutputValue > TIntensityFunctor;
40       typedef fpa::Base::Functors::VertexParentBase< TVertex, TOutputValue > TVertexFunctor;
41
42     protected:
43       struct _TNode
44       {
45         TVertex Vertex;
46         TVertex Parent;
47         TOutputValue Cost;
48         unsigned long FrontId;
49         _TNode( const TVertex& v, const TVertex& p, const unsigned long& fId )
50           {
51             this->Vertex = v;
52             this->Parent = p;
53             this->FrontId = fId;
54             this->Cost = TOutputValue( 0 );
55           }
56         bool operator<( const _TNode& b ) const
57           {
58             return( b.Cost < this->Cost );
59           }
60       };
61
62     public:
63       itkTypeMacro( Dijkstra, TFilter );
64
65     public:
66       TMST* GetMinimumSpanningTree( );
67       const TMST* GetMinimumSpanningTree( ) const;
68
69       const TIntensityFunctor* GetIntensityFunctor( ) const;
70       const TVertexFunctor* GetVertexFunctor( ) const;
71
72       void SetFunctor( TIntensityFunctor* functor );
73       void SetFunctor( TVertexFunctor* functor );
74
75     protected:
76       Dijkstra( );
77       virtual ~Dijkstra( );
78
79       virtual void GenerateData( ) override;
80
81     private:
82       Dijkstra( const Self& other );
83       Self& operator=( const Self& other );
84
85     protected:
86       typename TIntensityFunctor::Pointer m_IntensityFunctor;
87       typename TVertexFunctor::Pointer m_VertexFunctor;
88       unsigned long m_MSTIndex;
89     };
90
91   } // ecapseman
92
93 } // ecapseman
94
95 #ifndef ITK_MANUAL_INSTANTIATION
96 #  include <fpa/Base/Dijkstra.hxx>
97 #endif // ITK_MANUAL_INSTANTIATION
98
99 #endif // __fpa__Base__Dijkstra__h__
100
101 // eof - $RCSfile$