]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Filters/DijkstraBase.h
...
[FrontAlgorithms.git] / lib / fpa / Filters / DijkstraBase.h
diff --git a/lib/fpa/Filters/DijkstraBase.h b/lib/fpa/Filters/DijkstraBase.h
new file mode 100644 (file)
index 0000000..da844ee
--- /dev/null
@@ -0,0 +1,97 @@
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+#ifndef __fpa__Filters__DijkstraBase__h__
+#define __fpa__Filters__DijkstraBase__h__
+
+#include <vector>
+#include <itkConceptChecking.h>
+#include <itkFunctionBase.h>
+#include <fpa/Filters/Algorithm.h>
+#include <fpa/Functors/BaseVertexFunction.h>
+
+namespace fpa
+{
+  namespace Filters
+  {
+    /**
+     */
+    template< class _TTraits >
+    class DijkstraBase
+      : public fpa::Filters::Algorithm< _TTraits >
+    {
+    public:
+      typedef _TTraits TTraits;
+      fpaTraitsMacro( typename, TTraits );
+
+      typedef fpa::Filters::Algorithm< TTraits > Superclass;
+      typedef DijkstraBase                       Self;
+      typedef itk::SmartPointer< Self >          Pointer;
+      typedef itk::SmartPointer< const Self >    ConstPointer;
+
+      typedef std::vector< TNode > TQueue;
+      struct TQueueOrder
+      {
+        bool operator()( const TNode& a, const TNode& b ) const
+          {
+            return( b.Value < a.Value );
+          }
+      };
+
+      typedef itk::FunctionBase< TOutputValue, TOutputValue > TScalarWeight;
+      typedef fpa::Functors::BaseVertexFunction< TVertex, TOutputValue > TVertexWeight;
+
+    protected:
+      itkConceptMacro(
+        Check_TOutputValue,
+        ( itk::Concept::IsFloatingPoint< TOutputValue > )
+        );
+
+    public:
+      itkTypeMacro( fpa::Filters::DijkstraBase, fpa::Filters::Algorithm );
+
+      itkGetConstObjectMacro( ScalarWeight, TScalarWeight );
+      itkGetObjectMacro( ScalarWeight, TScalarWeight );
+
+      itkGetConstObjectMacro( VertexWeight, TVertexWeight );
+      itkGetObjectMacro( VertexWeight, TVertexWeight );
+
+    public:
+      void SetWeightFunction( TScalarWeight* w );
+      void SetWeightFunction( TVertexWeight* w );
+
+    protected:
+      DijkstraBase( );
+      virtual ~DijkstraBase( );
+
+      virtual void _UpdateOutputValue( TNode& n ) override;
+      virtual void _QueueClear( ) override;
+      virtual TNode _QueuePop( ) override;
+      virtual void _QueuePush( const TNode& n ) override;
+      virtual unsigned long _QueueSize( ) const override;
+      virtual void _ComputeOutputValue( TNode& n ) override;
+
+    private:
+      // Purposely not implemented.
+      DijkstraBase( const Self& other );
+      Self& operator=( const Self& other );
+
+    protected:
+      typename TScalarWeight::Pointer m_ScalarWeight;
+      typename TVertexWeight::Pointer m_VertexWeight;
+
+      TQueue       m_Queue;
+      TQueueOrder m_QueueOrder;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <fpa/Filters/DijkstraBase.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __fpa__Filters__DijkstraBase__h__
+// eof - $RCSfile$