]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Image/Dijkstra.h
Major refactoring
[FrontAlgorithms.git] / lib / fpa / Image / Dijkstra.h
index 1464d3cfd2953d01bfa2c0714437bba3ce42ad12..4e5105ca90b65b99dfb2747813af60dae0bfdedd 100644 (file)
@@ -1,12 +1,11 @@
 #ifndef __FPA__IMAGE__DIJKSTRA__H__
 #define __FPA__IMAGE__DIJKSTRA__H__
 
-#include <itkImage.h>
-#include <itkImageFunction.h>
+#include <itkFunctionBase.h>
 #include <itkImageToImageFilter.h>
-#include <itkIndex.h>
 #include <fpa/Base/Dijkstra.h>
 #include <fpa/Image/Algorithm.h>
+#include <fpa/Image/Functors/ImageCostFunction.h>
 
 namespace fpa
 {
@@ -14,45 +13,75 @@ namespace fpa
   {
     /**
      * @param I Input image type
+     * @param O Output image type
      */
-    template< class I, class C >
+    template< class I, class O >
     class Dijkstra
-      : public Algorithm< I, fpa::Base::Dijkstra< typename I::IndexType, C, typename I::PixelType, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, itk::ImageToImageFilter< I, itk::Image< C, I::ImageDimension > > > >
+      : public Algorithm< I, O, fpa::Base::Dijkstra< typename I::IndexType, typename I::PixelType, typename O::PixelType, itk::ImageToImageFilter< I, O > > >
     {
     public:
-      // Standard class typdedefs
-      typedef typename I::IndexType TVertex;
-      typedef typename I::PixelType TVertexValue;
-      typedef itk::Image< C, I::ImageDimension > TCostImage;
-      typedef itk::ImageToImageFilter< I, TCostImage > TBaseFilter;
-      typedef fpa::Base::Dijkstra< TVertex, C, TVertexValue, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, TBaseFilter > TBaseAlgorithm;
-
-      typedef Dijkstra                        Self;
-      typedef Algorithm< I, TBaseAlgorithm >  Superclass;
-      typedef itk::SmartPointer< Self >       Pointer;
-      typedef itk::SmartPointer< const Self > ConstPointer;
+      typedef fpa::Base::Dijkstra< typename I::IndexType, typename I::PixelType, typename O::PixelType, itk::ImageToImageFilter< I, O > > TBaseAlgorithm;
+
+      typedef Dijkstra                          Self;
+      typedef Algorithm< I, O, TBaseAlgorithm > Superclass;
+      typedef itk::SmartPointer< Self >         Pointer;
+      typedef itk::SmartPointer< const Self >   ConstPointer;
+
+      typedef typename Superclass::TInputImage  TInputImage;
+      typedef typename Superclass::TOutputImage TOutputImage;
+      typedef typename Superclass::TVertex      TVertex;
+      typedef typename Superclass::TValue       TValue;
+      typedef typename Superclass::TResult      TResult;
+
+      typedef fpa::Image::Functors::ImageCostFunction< TInputImage, TResult > TCostFunction;
+      typedef itk::FunctionBase< TResult, TResult > TConversionFunction;
+
+    protected:
+      typedef typename Superclass::_TVertices      _TVertices;
+      typedef typename Superclass::_TCollision     _TCollision;
+      typedef typename Superclass::_TCollisionsRow _TCollisionsRow;
+      typedef typename Superclass::_TCollisions    _TCollisions;
+      typedef typename Superclass::_TNode          _TNode;
+      typedef typename Superclass::_TNodes         _TNodes;
 
     public:
       itkNewMacro( Self );
-      itkTypeMacro( Dijkstra, fpaBaseDijkstra );
+      itkTypeMacro( Dijkstra, Algorithm );
+
+      itkGetObjectMacro( CostFunction, TCostFunction );
+      itkGetObjectMacro( ConversionFunction, TConversionFunction );
+
+      itkGetConstObjectMacro( CostFunction, TCostFunction );
+      itkGetConstObjectMacro( ConversionFunction, TConversionFunction );
+
+      itkSetObjectMacro( CostFunction, TCostFunction );
+      itkSetObjectMacro( ConversionFunction, TConversionFunction );
 
     protected:
-      Dijkstra( )
-        : Superclass( )
-        { }
-      virtual ~Dijkstra( )
-        { }
+      Dijkstra( );
+      virtual ~Dijkstra( );
+
+      virtual TResult _Cost( const TVertex& v, const TVertex& p ) const;
+
+      virtual void _BeforeGenerateData( );
+      virtual void _InitResults( );
 
     private:
       // Purposely not implemented
-      Dijkstra( const Self& );
-      void operator=( const Self& );
+      Dijkstra( const Self& other );
+      Self& operator=( const Self& other );
+
+    protected:
+      typename TCostFunction::Pointer m_CostFunction;
+      typename TConversionFunction::Pointer m_ConversionFunction;
     };
 
   } // ecapseman
 
 } // ecapseman
 
+#include <fpa/Image/Dijkstra.hxx>
+
 #endif // __FPA__IMAGE__DIJKSTRA__H__
 
 // eof - $RCSfile$