]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/RegionGrow.h
...
[FrontAlgorithms.git] / lib / fpa / Base / RegionGrow.h
index 6a3c9e6faebff789ed87514e7255bb5292eeaa74..34bb0851c589285c6837aaa55f1f7cac3134d3c7 100644 (file)
@@ -1,9 +1,15 @@
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+
 #ifndef __fpa__Base__RegionGrow__h__
 #define __fpa__Base__RegionGrow__h__
 
-#include <queue>
-#include <fpa/Base/QueueAlgorithm.h>
-#include <fpa/Base/Functors/RegionGrow/Base.h>
+#include <deque>
+
+#include <itkConceptChecking.h>
+#include <itkFunctionBase.h>
 
 namespace fpa
 {
@@ -11,48 +17,71 @@ namespace fpa
   {
     /**
      */
-    template< class _TSuperclass >
+    template< class _TAlgorithm >
     class RegionGrow
-      : public fpa::Base::QueueAlgorithm< _TSuperclass >
+      : public _TAlgorithm
     {
     public:
-      typedef RegionGrow                                Self;
-      typedef fpa::Base::QueueAlgorithm< _TSuperclass > 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 Superclass::TOutput TOutput;
-      typedef typename Superclass::TVertex TVertex;
-      typedef fpa::Base::Functors::RegionGrow::Base< TVertex, TOutput > TGrowFunction;
+      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;
 
-    protected:
-      typedef typename Superclass::_TQueueNode _TQueueNode;
+      typedef std::deque< TNode >                    TQueue;
+      typedef itk::FunctionBase< TInputValue, bool > TValuePredicate;
+      typedef itk::FunctionBase< TVertex, bool >     TVertexPredicate;
+
+    public:
+      itkConceptMacro(
+        Check_TOutputValue,
+        ( itk::Concept::IsUnsignedInteger< TOutputValue > )
+        );
 
     public:
-      itkTypeMacro( RegionGrow, Algorithm );
+      itkGetObjectMacro( ValuePredicate, TValuePredicate );
+      itkGetObjectMacro( VertexPredicate, TVertexPredicate );
+      itkGetConstMacro( InsideValue, TOutputValue );
+
+      itkSetMacro( InsideValue, TOutputValue );
 
     public:
-      TGrowFunction* GetGrowFunction( );
-      const TGrowFunction* GetGrowFunction( ) const;
-      TOutput GetInsideValue( ) const;
-      TOutput GetOutsideValue( ) const;
+      virtual itk::ModifiedTimeType GetMTime( ) const override;
+      virtual TOutputValue GetOutsideValue( ) const;
+      virtual void SetOutsideValue( const TOutputValue& v );
 
-      void SetGrowFunction( TGrowFunction* f );
-      void SetInsideValue( const TOutput& v );
-      void SetOutsideValue( const TOutput& v );
+      void SetPredicate( TValuePredicate* p );
+      void SetPredicate( TVertexPredicate* p );
 
     protected:
       RegionGrow( );
       virtual ~RegionGrow( );
 
-      virtual bool _UpdateValue(
-        _TQueueNode& v, const _TQueueNode& p
-        ) override;
+      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 defined
+      // Purposely not implemented.
       RegionGrow( const Self& other );
       Self& operator=( const Self& other );
+
+    protected:
+      typename TValuePredicate::Pointer  m_ValuePredicate;
+      typename TVertexPredicate::Pointer m_VertexPredicate;
+
+      TOutputValue m_InsideValue;
+
+      TQueue m_Queue;
     };
 
   } // ecapseman