]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Image/Algorithm.h
...
[FrontAlgorithms.git] / lib / fpa / Image / Algorithm.h
index 2fd40bc1c242cef832e920189a844a63263a43dc..58dc5eee8c1649e1fd5bba48bc623036593d6e19 100644 (file)
@@ -1,86 +1,82 @@
-#ifndef __FPA__IMAGE__ALGORITHM__H__
-#define __FPA__IMAGE__ALGORITHM__H__
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+
+#ifndef __fpa__Image__Algorithm__h__
+#define __fpa__Image__Algorithm__h__
 
-#include <fpa/Base/Algorithm.h>
 #include <itkImage.h>
 #include <itkImageToImageFilter.h>
 
+#include <fpa/Base/Algorithm.h>
+
 namespace fpa
 {
   namespace Image
   {
     /**
      */
-    template< class _TInputImage, class _TOutputImage >
+    template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
     class Algorithm
-      : public fpa::Base::Algorithm< typename _TInputImage::IndexType, typename _TOutputImage::PixelType, itk::ImageToImageFilter< _TInputImage, _TOutputImage >, typename _TInputImage::IndexType::LexicographicCompare >
+      : public fpa::Base::Algorithm< itk::ImageToImageFilter< _TInputImage, _TOutputImage >, _TMarksInterface, _TSeedsInterface >
     {
     public:
-      typedef fpa::Base::Algorithm< typename _TInputImage::IndexType, typename _TOutputImage::PixelType, itk::ImageToImageFilter< _TInputImage, _TOutputImage >, typename _TInputImage::IndexType::LexicographicCompare > Superclass;
-      typedef Algorithm                       Self;
+      typedef _TInputImage     TInputImage;
+      typedef _TOutputImage    TOutputImage;
+      typedef _TMarksInterface TMarksInterface;
+      typedef _TSeedsInterface TSeedsInterface;
+      typedef itk::ImageToImageFilter< TInputImage, TOutputImage > TFilter;
+
+      typedef Algorithm Self;
+      typedef fpa::Base::Algorithm< TFilter, TMarksInterface, TSeedsInterface > Superclass;
       typedef itk::SmartPointer< Self >       Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
-      // Input types
-      typedef _TInputImage  TInputImage;
-      typedef _TOutputImage TOutputImage;
-      itkConceptMacro(
-        ImagesSameDimension,
-        (
-          itk::Concept::
-          SameDimension<
-          TInputImage::ImageDimension,
-          TOutputImage::ImageDimension
-          >
-          )
-        );
-
-      // Template arguments
-      typedef typename Superclass::TVertex        TVertex;
-      typedef typename Superclass::TScalar        TScalar;
-      typedef typename Superclass::TFilter        TFilter;
-      typedef typename Superclass::TVertexCompare TVertexCompare;
-      typedef typename Superclass::TFrontId       TFrontId;
-      typedef typename Superclass::TCollision     TCollision;
-      typedef typename Superclass::TCollisionsRow TCollisionsRow;
-      typedef typename Superclass::TCollisions    TCollisions;
-      typedef typename Superclass::TNodeLabel     TNodeLabel;
-      typedef typename Superclass::TNode          TNode;
-      typedef typename Superclass::TNodes         TNodes;
-      typedef typename Superclass::TVertices      TVertices;
-
-      typedef itk::Image< TFrontId, TInputImage::ImageDimension > TMarkImage;
+      typedef typename TInputImage::PixelType    TInputValue;
+      typedef typename TOutputImage::PixelType   TOutputValue;
+      typedef typename Superclass::TFrontId      TFrontId;
+      typedef typename Superclass::TNeighborhood TNeighborhood;
+      typedef typename Superclass::TNode         TNode;
+      typedef typename Superclass::TNodes        TNodes;
+      typedef typename Superclass::TSeeds        TSeeds;
+      typedef typename Superclass::TVertex       TVertex;
+      typedef typename Superclass::TPoint        TPoint;
+
+      typedef itk::Image< TFrontId, TInputImage::ImageDimension > TMarks;
 
     public:
-      itkTypeMacro( Algorithm, _TFilter );
+      itkTypeMacro( fpa::Image::Algorithm, fpa::Base::Algorithm );
+
+      itkGetConstMacro( NeigborhoodOrder, unsigned int );
+      itkSetMacro( NeigborhoodOrder, unsigned int );
 
-      itkGetConstMacro( NeighborhoodOrder, unsigned short );
-      itkSetMacro( NeighborhoodOrder, unsigned short );
+    public:
+      TMarks* GetMarks( );
+      const TMarks* GetMarks( ) const;
 
     protected:
-      // Methods to extend itk-imaged architecture
       Algorithm( );
       virtual ~Algorithm( );
 
-      // Front propagation methods to be overloaded
-      virtual void _BeforeGenerateData( ) fpa_OVERRIDE;
-      virtual void _InitMarks( ) fpa_OVERRIDE;
-      virtual void _InitResults( ) fpa_OVERRIDE;
-      virtual void _DeallocateAuxiliary( ) fpa_OVERRIDE;
-      virtual TFrontId _GetMark( const TVertex& v ) fpa_OVERRIDE;
-      virtual void _Visit( const TNode& n ) fpa_OVERRIDE;
-      virtual TVertices _GetNeighborhood(
-        const TVertex& v
-        ) const fpa_OVERRIDE;
+      virtual TNodes _UnifySeeds( ) override;
+      virtual void _ConfigureOutput( const TOutputValue& v ) override;
+      virtual TNeighborhood _GetNeighbors( const TVertex& v ) const override;
+      virtual TInputValue _GetInputValue( const TVertex& v ) const override;
+      virtual TOutputValue _GetOutputValue( const TVertex& v ) const override;
+      virtual void _UpdateOutputValue( TNode& n ) override;
+      virtual bool _IsMarked( const TVertex& v ) const override;
+      virtual unsigned long _GetMark( const TVertex& v ) const override;
+      virtual void _Mark( const TVertex& v, unsigned long frontId ) override;
 
     private:
-      // Purposely not implemented
+      // Purposely not implemented.
       Algorithm( const Self& other );
       Self& operator=( const Self& other );
 
     protected:
-      unsigned short m_NeighborhoodOrder;
-      typename TMarkImage::Pointer m_Marks;
+      unsigned long m_MarksIdx;
+      unsigned int  m_NeigborhoodOrder;
     };
 
   } // ecapseman
@@ -89,8 +85,8 @@ namespace fpa
 
 #ifndef ITK_MANUAL_INSTANTIATION
 #  include <fpa/Image/Algorithm.hxx>
-#endif
+#endif // ITK_MANUAL_INSTANTIATION
 
-#endif // __FPA__IMAGE__ALGORITHM__H__
+#endif // __fpa__Image__Algorithm__h__
 
 // eof - $RCSfile$