]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/Dijkstra.h
...
[FrontAlgorithms.git] / lib / fpa / Base / Dijkstra.h
index d231c7c41da897886b69c63d97f0fca117908646..11f553848b465cc8fa09ceb6a450c467a0d803fc 100644 (file)
@@ -6,9 +6,7 @@
 #ifndef __fpa__Base__Dijkstra__h__
 #define __fpa__Base__Dijkstra__h__
 
-#include <itkFunctionBase.h>
-#include <fpa/Base/MinimumSpanningTree.h>
-#include <fpa/Base/Functors/VertexParentBase.h>
+#include <fpa/Base/DijkstraBase.h>
 
 namespace fpa
 {
@@ -16,76 +14,48 @@ namespace fpa
   {
     /**
      */
-    template< class _TFilter, class _TMarksInterface, class _TSeedsInterface, class _TMST >
+    template< class _TAlgorithm, class _TMST >
     class Dijkstra
-      : public _TFilter,
-        public _TMarksInterface,
-        public _TSeedsInterface
+      : public fpa::Base::DijkstraBase< _TAlgorithm >
     {
     public:
-      typedef Dijkstra                        Self;
-      typedef _TFilter                        Superclass;
-      typedef _TMarksInterface                TMarksInterface;
-      typedef _TSeedsInterface                TSeedsInterface;
-      typedef _TMST                           TMST;
-      typedef itk::SmartPointer< Self >       Pointer;
-      typedef itk::SmartPointer< const Self > ConstPointer;
+      typedef Dijkstra                               Self;
+      typedef fpa::Base::DijkstraBase< _TAlgorithm > Superclass;
+      typedef itk::SmartPointer< Self >              Pointer;
+      typedef itk::SmartPointer< const Self >        ConstPointer;
 
+      typedef _TMST TMST;
+
+      typedef typename Superclass::TNode        TNode;
+      typedef typename Superclass::TNodes       TNodes;
       typedef typename Superclass::TInputValue  TInputValue;
       typedef typename Superclass::TOutputValue TOutputValue;
+      typedef typename Superclass::TFrontId     TFrontId;
       typedef typename Superclass::TVertex      TVertex;
-      typedef typename Superclass::TVertices    TVertices;
-
-      typedef itk::FunctionBase< TInputValue, TOutputValue > TIntensityFunctor;
-      typedef fpa::Base::Functors::VertexParentBase< TVertex, TOutputValue > TVertexFunctor;
+      typedef typename Superclass::TSeeds       TSeeds;
 
-    protected:
-      struct _TNode
-      {
-        TVertex Vertex;
-        TVertex Parent;
-        TOutputValue Cost;
-        unsigned long FrontId;
-        _TNode( const TVertex& v, const TVertex& p, const unsigned long& fId )
-          {
-            this->Vertex = v;
-            this->Parent = p;
-            this->FrontId = fId;
-            this->Cost = TOutputValue( 0 );
-          }
-        bool operator<( const _TNode& b ) const
-          {
-            return( b.Cost < this->Cost );
-          }
-      };
-
-    public:
-      itkTypeMacro( Dijkstra, TFilter );
+      typedef typename Superclass::TQueue          TQueue;
+      typedef typename Superclass::TQueueOrder     TQueueOrder;
+      typedef typename Superclass::TWeightFunction TWeightFunction;
 
     public:
       TMST* GetMinimumSpanningTree( );
       const TMST* GetMinimumSpanningTree( ) const;
 
-      const TIntensityFunctor* GetIntensityFunctor( ) const;
-      const TVertexFunctor* GetVertexFunctor( ) const;
-
-      void SetFunctor( TIntensityFunctor* functor );
-      void SetFunctor( TVertexFunctor* functor );
-
     protected:
       Dijkstra( );
       virtual ~Dijkstra( );
 
-      virtual void GenerateData( ) override;
+      virtual void _AfterGenerateData( ) override;
+      virtual void _UpdateOutputValue( TNode& n ) override;
 
     private:
+      // Purposely not implemented.
       Dijkstra( const Self& other );
       Self& operator=( const Self& other );
 
     protected:
-      typename TIntensityFunctor::Pointer m_IntensityFunctor;
-      typename TVertexFunctor::Pointer m_VertexFunctor;
-      unsigned long m_MSTIndex;
+      unsigned int m_MSTIdx;
     };
 
   } // ecapseman