]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/RegionGrow.h
...
[FrontAlgorithms.git] / lib / fpa / Base / RegionGrow.h
index 5cd36de8a2c202cea2e69ff418920fde0e2c27e2..4790b851a9273768e1d0ae5f4cf1e79e03d025aa 100644 (file)
@@ -2,8 +2,8 @@
 #define __fpa__Base__RegionGrow__h__
 
 #include <queue>
-#include <fpa/Config.h>
-#include <fpa/Base/RegionGrowFunctionBase.h>
+#include <fpa/Base/QueueAlgorithm.h>
+#include <fpa/Base/Functors/RegionGrow/Base.h>
 
 namespace fpa
 {
@@ -13,33 +13,33 @@ namespace fpa
      */
     template< class _TSuperclass >
     class RegionGrow
-      : public _TSuperclass
+      : public fpa::Base::QueueAlgorithm< _TSuperclass >
     {
     public:
-      typedef RegionGrow                      Self;
-      typedef _TSuperclass                    Superclass;
-      typedef itk::SmartPointer< Self >       Pointer;
-      typedef itk::SmartPointer< const Self > ConstPointer;
+      typedef RegionGrow                                Self;
+      typedef fpa::Base::QueueAlgorithm< _TSuperclass > 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::RegionGrowFunctionBase< TVertex > TGrowFunction;
+      typedef fpa::Base::Functors::RegionGrow::Base< TVertex, TOutput > TGrowFunction;
 
     protected:
       typedef typename Superclass::_TQueueNode _TQueueNode;
-      typedef std::queue< _TQueueNode > _TQueue;
 
     public:
       itkTypeMacro( RegionGrow, Algorithm );
 
-      itkGetObjectMacro( GrowFunction, TGrowFunction );
-      itkGetConstMacro( InsideValue, TOutput );
-      itkGetConstMacro( OutsideValue, TOutput );
+    public:
+      TGrowFunction* GetGrowFunction( );
+      const TGrowFunction* GetGrowFunction( ) const;
+      TOutput GetInsideValue( ) const;
+      TOutput GetOutsideValue( ) const;
 
-      itkSetObjectMacro( GrowFunction, TGrowFunction );
-      itkSetMacro( InsideValue, TOutput );
-      itkSetMacro( OutsideValue, TOutput );
+      void SetGrowFunction( TGrowFunction* f );
+      void SetInsideValue( const TOutput& v );
+      void SetOutsideValue( const TOutput& v );
 
     protected:
       RegionGrow( );
@@ -47,11 +47,15 @@ namespace fpa
 
       virtual bool _UpdateValue(
         _TQueueNode& v, const _TQueueNode& p
-        ) fpa_OVERRIDE;
-      virtual unsigned long _QueueSize( ) const fpa_OVERRIDE;
-      virtual void _QueueClear( ) fpa_OVERRIDE;
-      virtual void _QueuePush( const _TQueueNode& node ) fpa_OVERRIDE;
-      virtual _TQueueNode _QueuePop( ) fpa_OVERRIDE;
+        ) override;
+      virtual TOutput _GetInputValue( const _TQueueNode& v, const _TQueueNode& p ) override
+        {
+          TOutput res = this->m_InitResult;
+          if( this->m_GrowFunction.IsNotNull( ) )
+            res = this->m_GrowFunction->Evaluate( v.Vertex, p.Vertex );
+          return( res );
+        }
+
 
     private:
       // Purposely not defined
@@ -59,9 +63,6 @@ namespace fpa
       Self& operator=( const Self& other );
 
     protected:
-      TOutput m_InsideValue;
-      TOutput m_OutsideValue;
-      _TQueue m_Queue;
       typename TGrowFunction::Pointer m_GrowFunction;
     };