]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/Dijkstra.h
Plugins updated
[FrontAlgorithms.git] / lib / fpa / Base / Dijkstra.h
index 3831526a553e5a85bd4c9ccd77d9367e0a735b07..69fe86a798289509fb31557b6927c90dbbd64466 100644 (file)
@@ -11,26 +11,43 @@ namespace fpa
     /**
      * Dijkstra is a front propagation algorithm that minimizes costs
      *
-     * @param V Vertex type.
-     * @param C Vertex value type.
-     * @param R Result value type.
-     * @param B Base class for this algorithm. It should be any itk-based
-     *          filter (itk::ProcessObject).
+     * @param V  Vertex type.
+     * @param C  Vertex value type.
+     * @param R  Result value type.
+     * @param S  Space type where vertices are.
+     * @param VC Vertex lexicographical compare.
+     * @param B  Base class for this algorithm. It should be any itk-based
+     *           filter (itk::ProcessObject).
      *
      */
-    template< class V, class C, class R, class B >
+    template< class V, class C, class R, class S, class VC, class B >
     class Dijkstra
-      : public Algorithm< V, C, R, B >
+      : public Algorithm< V, C, R, S, VC, B >
     {
     public:
       typedef Dijkstra                         Self;
-      typedef Algorithm< V, C, R, B >          Superclass;
+      typedef Algorithm< V, C, R, S, VC, B >   Superclass;
       typedef itk::SmartPointer< Self >        Pointer;
       typedef itk::SmartPointer< const Self >  ConstPointer;
 
-      typedef typename Superclass::TVertex TVertex;
-      typedef typename Superclass::TValue  TValue;
-      typedef typename Superclass::TResult TResult;
+      typedef typename Superclass::TVertex              TVertex;
+      typedef typename Superclass::TValue               TValue;
+      typedef typename Superclass::TResult              TResult;
+      typedef typename Superclass::TSpace               TSpace;
+      typedef typename Superclass::TVertexCompare       TVertexCompare;
+      typedef typename Superclass::TMinimumSpanningTree TMinimumSpanningTree;
+
+      typedef typename Superclass::TStartEvent     TStartEvent;
+      typedef typename Superclass::TStartLoopEvent TStartLoopEvent;
+      typedef typename Superclass::TEndEvent       TEndEvent;
+      typedef typename Superclass::TEndLoopEvent   TEndLoopEvent;
+      typedef typename Superclass::TAliveEvent     TAliveEvent;
+      typedef typename Superclass::TFrontEvent     TFrontEvent;
+      typedef typename Superclass::TFreezeEvent    TFreezeEvent;
+
+      typedef typename Superclass::TStartBacktrackingEvent TStartBacktrackingEvent;
+      typedef typename Superclass::TEndBacktrackingEvent TEndBacktrackingEvent;
+      typedef typename Superclass::TBacktrackingEvent TBacktrackingEvent;
 
     protected:
       typedef typename Superclass::_TVertices      _TVertices;
@@ -40,17 +57,24 @@ namespace fpa
       typedef typename Superclass::_TNode          _TNode;
       typedef typename Superclass::_TNodes         _TNodes;
 
-      typedef std::vector< _TNode > _TQueue;
-      struct _TNodeCompare
+      struct _TQueueNode
       {
+        TVertex Vertex;
+        _TNode  Node;
+
         // Make the min-heap behave as a max-heap
-        bool operator()( const _TNode& a, const _TNode& b ) const
-          { return( b.Result < a.Result ); }
+        bool operator<( const _TQueueNode& other ) const
+          { return( other.Node.Result < this->Node.Result ); }
       };
+      typedef std::vector< _TQueueNode > _TQueue;
 
     public:
       itkTypeMacro( Dijkstra, Algorithm );
 
+      itkBooleanMacro( LocalCosts );
+      itkGetConstMacro( LocalCosts, bool );
+      itkSetMacro( LocalCosts, bool );
+
     protected:
       Dijkstra( );
       virtual ~Dijkstra( );
@@ -64,8 +88,8 @@ namespace fpa
 
       // Queue-related abstract methods
       virtual bool _IsQueueEmpty( ) const;
-      virtual void _QueuePush( const _TNode& n );
-      virtual _TNode _QueuePop( );
+      virtual void _QueuePush( const TVertex& v, const _TNode& n );
+      virtual void _QueuePop( TVertex& v, _TNode& n );
       virtual void _QueueClear( );
 
     private:
@@ -74,8 +98,8 @@ namespace fpa
       Self& operator=( const Self& other );
 
     protected:
+      bool m_LocalCosts;
       _TQueue m_Queue;
-      static _TNodeCompare m_NodeCompare;
     };
 
   } // ecapseman