]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Image/Algorithm.h
...
[FrontAlgorithms.git] / lib / fpa / Image / Algorithm.h
index 289eb6c0e7da7dad12899fcf8c929b3b0e58d5f1..6d68bb58786aa9703a44d9c37da518be7fc4e584 100644 (file)
@@ -2,7 +2,6 @@
 #define __FPA__IMAGE__ALGORITHM__H__
 
 #include <itkImage.h>
-#include <itkFunctionBase.h>
 
 namespace fpa
 {
@@ -11,10 +10,11 @@ namespace fpa
     /**
      * A generic front propagation algorithm were vertices are image pixels.
      *
-     * @param I    Input image type
-     * @param A    Base algorithm (RegionGrow, Dijkstra or FastMarching)
+     * @param I Input image type
+     * @param O Output image type
+     * @param A Base algorithm (RegionGrow, Dijkstra or FastMarching)
      */
-    template< class I, class A >
+    template< class I, class O, class A >
     class Algorithm
       : public A
     {
@@ -27,78 +27,67 @@ namespace fpa
 
       /// Template input values
       typedef I TInputImage;
-      typedef A TBaseAlgorithm;
+      typedef O TOutputImage;
 
-      typedef typename A::TTraits            TTraits;
-      typedef typename TTraits::TCost        TCost;
-      typedef typename TTraits::TResult      TResult;
-      typedef typename TTraits::TVertex      TVertex;
-      typedef typename TTraits::TVertexValue TVertexValue;
-
-      typedef itk::Image< TResult, I::ImageDimension > TOutputImage;
-      typedef itk::FunctionBase< TCost, TCost > TCostConversionFunction;
+      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;
 
     protected:
-      typedef typename TTraits::TFrontId _TFrontId;
-      typedef typename TTraits::TNode    _TNode;
-      typedef typename TTraits::TNodes   _TNodes;
-
-    private:
-      typedef itk::Image< bool, I::ImageDimension >      _TMarks;
-      typedef itk::Image< _TFrontId, I::ImageDimension > _TFrontsIds;
-      typedef itk::Image< TVertex, I::ImageDimension >   _TParents;
+      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:
       itkTypeMacro( Algorithm, TAlgorithm );
 
       /// Set/Get
       itkGetConstMacro( NeighborhoodOrder, unsigned int );
-      itkGetConstObjectMacro( CostConversion, TCostConversionFunction );
-      itkGetObjectMacro( CostConversion, TCostConversionFunction );
-
       itkSetMacro( NeighborhoodOrder, unsigned int );
-      itkSetObjectMacro( CostConversion, TCostConversionFunction );
 
     protected:
       Algorithm( );
       virtual ~Algorithm( );
 
-      /// Base interface
-      virtual bool _UpdateResult( _TNode& n );
-
-      /// Pure virtual interface: vertices
-      virtual unsigned long _NumberOfVertices ( ) const;
-      virtual  TVertexValue _Value            ( const TVertex& v ) const;
-      virtual       TResult _Result           ( const TVertex& v ) const;
-
-      /// Pure virtual interface: edges
-      virtual double _Norm ( const TVertex& a, const TVertex& b ) const;
-      virtual   bool _Edge ( const TVertex& a, const TVertex& b ) const;
-      virtual  TCost _Cost ( const TVertex& a, const TVertex& b ) const;
+      virtual void _BeforeGenerateData( ) ITK_OVERRIDE;
 
-      /// Pure virtual interface: neighborhood
-      virtual void _Neighs      ( const _TNode& n, _TNodes& N ) const;
-      virtual void _NeighsInDim ( const _TNode& n,
-                                  const unsigned int& d,
-                                  _TNodes& N );
+      // Graph-related abstract methods
+      virtual unsigned long _NumberOfVertices( ) const ITK_OVERRIDE;
+      virtual const TValue& _VertexValue( const TVertex& v ) const ITK_OVERRIDE;
+      virtual double _Distance(
+        const TVertex& a, const TVertex& b
+        ) const ITK_OVERRIDE;
+      virtual bool _HasEdge( const TVertex& a, const TVertex& b ) const ITK_OVERRIDE;
+      virtual void _Neighborhood(
+        _TVertices& neighborhood, const TVertex& v
+        ) const ITK_OVERRIDE;
 
-      /// Pure virtual interface: results
-      virtual void _InitializeResults ( );
+      // Results-related abstract methods
+      virtual void _InitResults( ) ITK_OVERRIDE;
+      virtual const TResult& _Result( const TVertex& v ) const ITK_OVERRIDE;
+      virtual void _SetResult( const TVertex& v, const _TNode& n ) ITK_OVERRIDE;
 
     private:
-      Algorithm( const Self& );      // Not impl.
-      void operator=( const Self& ); // Not impl.
+      // Purposely not implemented
+      Algorithm( const Self& other );
+      Self& operator=( const Self& other );
 
     protected:
-      unsigned int                              m_NeighborhoodOrder;
-      typename TCostConversionFunction::Pointer m_CostConversion;
+      unsigned int m_NeighborhoodOrder;
     };
 
   } // ecapseman
 
 } // ecapseman
 
+#ifndef ITK_MANUAL_INSTANTIATION
 #include <fpa/Image/Algorithm.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
 
 #endif // __FPA__IMAGE__ALGORITHM__H__