]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/RegionGrow.h
...
[FrontAlgorithms.git] / lib / fpa / Base / RegionGrow.h
index 6028b754622fb5f91c9413cf92b79cca0da7a9bc..34bb0851c589285c6837aaa55f1f7cac3134d3c7 100644 (file)
@@ -1,90 +1,97 @@
-#ifndef __FPA__BASE__REGIONGROW__H__
-#define __FPA__BASE__REGIONGROW__H__
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
 
-#include <queue>
-#include <fpa/Base/Algorithm.h>
+#ifndef __fpa__Base__RegionGrow__h__
+#define __fpa__Base__RegionGrow__h__
+
+#include <deque>
+
+#include <itkConceptChecking.h>
+#include <itkFunctionBase.h>
 
 namespace fpa
 {
   namespace Base
   {
     /**
-     * Region grow is a front propagation with no costs.
-     *
-     * @param V Vertex type.
-     * @param C Vertex value type.
-     * @param R Result value type.
-     * @param B Base class for this algorithm. It should be any itk-based
-     *          filter (itk::ProcessObject).
-     *
      */
-    template< class V, class C, class R, class B >
+    template< class _TAlgorithm >
     class RegionGrow
-      : public Algorithm< V, C, R, B >
+      : public _TAlgorithm
     {
     public:
-      typedef RegionGrow                       Self;
-      typedef Algorithm< V, C, R, B >          Superclass;
-      typedef itk::SmartPointer< Self >        Pointer;
-      typedef itk::SmartPointer< const Self >  ConstPointer;
+      typedef RegionGrow                      Self;
+      typedef _TAlgorithm                     Superclass;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
+
+      typedef typename _TAlgorithm::TNode        TNode;
+      typedef typename _TAlgorithm::TNodes       TNodes;
+      typedef typename _TAlgorithm::TInputValue  TInputValue;
+      typedef typename _TAlgorithm::TOutputValue TOutputValue;
+      typedef typename _TAlgorithm::TFrontId     TFrontId;
+      typedef typename _TAlgorithm::TVertex      TVertex;
+
+      typedef std::deque< TNode >                    TQueue;
+      typedef itk::FunctionBase< TInputValue, bool > TValuePredicate;
+      typedef itk::FunctionBase< TVertex, bool >     TVertexPredicate;
 
-      typedef typename Superclass::TVertex TVertex;
-      typedef typename Superclass::TValue  TValue;
-      typedef typename Superclass::TResult TResult;
+    public:
+      itkConceptMacro(
+        Check_TOutputValue,
+        ( itk::Concept::IsUnsignedInteger< TOutputValue > )
+        );
 
-    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:
+      itkGetObjectMacro( ValuePredicate, TValuePredicate );
+      itkGetObjectMacro( VertexPredicate, TVertexPredicate );
+      itkGetConstMacro( InsideValue, TOutputValue );
 
-      typedef std::queue< _TNode > _TQueue;
+      itkSetMacro( InsideValue, TOutputValue );
 
     public:
-      itkTypeMacro( RegionGrow, Algorithm );
+      virtual itk::ModifiedTimeType GetMTime( ) const override;
+      virtual TOutputValue GetOutsideValue( ) const;
+      virtual void SetOutsideValue( const TOutputValue& v );
 
-      itkGetConstMacro( InsideValue, TResult );
-      itkGetConstMacro( OutsideValue, TResult );
-
-      itkSetMacro( InsideValue, TResult );
-      itkSetMacro( OutsideValue, TResult );
+      void SetPredicate( TValuePredicate* p );
+      void SetPredicate( TVertexPredicate* p );
 
     protected:
       RegionGrow( );
       virtual ~RegionGrow( );
 
-      virtual bool _CheckMembership( const TVertex& v ) const = 0;
-
-      // Results-related abstract methods
-      virtual bool _ComputeNeighborResult(
-        TResult& result, const TVertex& neighbor, const TVertex& parent
-        ) const;
-
-      // Queue-related abstract methods
-      virtual bool _IsQueueEmpty( ) const;
-      virtual void _QueuePush( const _TNode& n );
-      virtual _TNode _QueuePop( );
-      virtual void _QueueClear( );
+      virtual TOutputValue _ComputeOutputValue( const TNode& n ) override;
+      virtual void _QueueClear( ) override;
+      virtual TNode _QueuePop( ) override;
+      virtual void _QueuePush( const TNode& node ) override;
+      virtual unsigned long _QueueSize( ) const override;
+      virtual void _PrepareSeeds( TNodes& nodes ) override;
 
     private:
-      // Purposely not implemented
+      // Purposely not implemented.
       RegionGrow( const Self& other );
       Self& operator=( const Self& other );
 
     protected:
-      TResult m_InsideValue;
-      TResult m_OutsideValue;
-      _TQueue m_Queue;
+      typename TValuePredicate::Pointer  m_ValuePredicate;
+      typename TVertexPredicate::Pointer m_VertexPredicate;
+
+      TOutputValue m_InsideValue;
+
+      TQueue m_Queue;
     };
 
   } // ecapseman
 
 } // ecapseman
 
-#include <fpa/Base/RegionGrow.hxx>
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <fpa/Base/RegionGrow.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
 
-#endif // __FPA__BASE__REGIONGROW__H__
+#endif // __fpa__Base__RegionGrow__h__
 
 // eof - $RCSfile$