]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Image/Algorithm.h
...
[FrontAlgorithms.git] / lib / fpa / Image / Algorithm.h
index 9a44146ddee238464b799a7faa236554273dedd5..d613ce3d8afce33b090f781c9abc04df658cc9d5 100644 (file)
@@ -1,94 +1,70 @@
-#ifndef __FPA__IMAGE__ALGORITHM__H__
-#define __FPA__IMAGE__ALGORITHM__H__
+#ifndef __fpa__Image__Algorithm__h__
+#define __fpa__Image__Algorithm__h__
 
-#include <itkImage.h>
+#include <itkFunctionBase.h>
+#include <itkImageToImageFilter.h>
+#include <fpa/Base/Algorithm.h>
+#include <fpa/Image/Functors/Base.h>
 
 namespace fpa
 {
   namespace Image
   {
     /**
-     * A generic front propagation algorithm were vertices are image pixels.
-     *
-     * @param I Input image type
-     * @param O Output image type
-     * @param A Base algorithm (RegionGrow, Dijkstra or FastMarching)
      */
-    template< class I, class O, class A >
+    template< class _TInputImage, class _TOutputImage >
     class Algorithm
-      : public A
+      : public fpa::Base::Algorithm< itk::ImageToImageFilter< _TInputImage, _TOutputImage >, typename _TInputImage::IndexType, typename _TOutputImage::PixelType >
     {
     public:
-      /// Standard class typdedefs
-      typedef Algorithm                       Self;
-      typedef A                               Superclass;
-      typedef itk::SmartPointer< Self >       Pointer;
-      typedef itk::SmartPointer< const Self > ConstPointer;
+      typedef itk::ImageToImageFilter< _TInputImage, _TOutputImage > TFilter;
+      typedef typename _TInputImage::IndexType                       TVertex;
+      typedef typename _TOutputImage::PixelType                      TOutput;
 
-      /// Template input values
-      typedef I TInputImage;
-      typedef O TOutputImage;
+      typedef Algorithm                                         Self;
+      typedef fpa::Base::Algorithm< TFilter, TVertex, TOutput > 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::TSpace               TSpace;
-      typedef typename Superclass::TVertexCompare       TVertexCompare;
-      typedef typename Superclass::TMinimumSpanningTree TMinimumSpanningTree;
+      typedef typename Superclass::TFrontId      TFrontId;
+      typedef typename Superclass::TNeighborhood TNeighborhood;
+      typedef fpa::Image::Functors::Base< itk::ImageBase< _TInputImage::ImageDimension >, itk::FunctionBase< TVertex, TNeighborhood > > TNeighborhoodFunction;
 
     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;
+      typedef typename Superclass::_TQueueNode _TQueueNode;
 
     public:
-      itkTypeMacro( Algorithm, TAlgorithm );
-
-      /// Set/Get
-      itkGetConstMacro( NeighborhoodOrder, unsigned int );
-      itkSetMacro( NeighborhoodOrder, unsigned int );
+      itkTypeMacro( fpa::Image::Algorithm, fpa::Base::Algorithm );
 
     protected:
       Algorithm( );
       virtual ~Algorithm( );
 
-      virtual void _BeforeGenerateData( );
-      virtual void _AfterGenerateData( );
-
-      // Graph-related abstract methods
-      virtual unsigned long _NumberOfVertices( ) const;
-      virtual const TValue& _VertexValue( const TVertex& v ) const;
-      virtual double _Distance(
-        const TVertex& a, const TVertex& b
-        ) const;
-      virtual bool _HasEdge( const TVertex& a, const TVertex& b ) const;
-      virtual void _Neighborhood(
-        _TVertices& neighborhood, const TVertex& v
-        ) const;
-
-      // Results-related abstract methods
-      virtual void _InitResults( );
-      virtual const TResult& _Result( const TVertex& v ) const;
-      virtual void _SetResult( const TVertex& v, const _TNode& n );
+      virtual void _BeforeGenerateData( ) override;
+      virtual void _InitMarks( ) override;
+      virtual void _InitResults( const TOutput& init_value ) override;
+      virtual bool _IsMarked( const TVertex& v ) const override;
+      virtual void _Mark( const _TQueueNode& n ) override;
+      virtual TFrontId _GetMark( const TVertex& v ) const override;
+      virtual void _UpdateResult( const _TQueueNode& n ) override;
 
     private:
-      // Purposely not implemented
+      // Purposely not defined
       Algorithm( const Self& other );
       Self& operator=( const Self& other );
 
     protected:
-      unsigned int m_NeighborhoodOrder;
+      unsigned int m_MarksIdx;
     };
 
   } // ecapseman
 
 } // ecapseman
 
-#include <fpa/Image/Algorithm.hxx>
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <fpa/Image/Algorithm.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
 
-#endif // __FPA__IMAGE__ALGORITHM__H__
+#endif // __fpa__Image__Algorithm__h__
 
 // eof - $RCSfile$