-#ifndef __FPA__BASE__REGIONGROW__H__
-#define __FPA__BASE__REGIONGROW__H__
+#ifndef __fpa__Base__RegionGrow__h__
+#define __fpa__Base__RegionGrow__h__
#include <queue>
-#include <utility>
-#include <fpa/Base/Algorithm.h>
+#include <fpa/Base/QueueAlgorithm.h>
+#include <fpa/Base/Functors/RegionGrow/Base.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 VC Vertex lexicographical compare.
- * @param B Base class for this algorithm. It should be any itk-based
- * filter (itk::ProcessObject).
- *
*/
- template< class V, class C, class R, class VC, class B >
+ template< class _TSuperclass >
class RegionGrow
- : public Algorithm< V, C, R, VC, B >
+ : public fpa::Base::QueueAlgorithm< _TSuperclass >
{
public:
- typedef RegionGrow Self;
- typedef Algorithm< V, C, R, VC, B > 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::TVertex TVertex;
- typedef typename Superclass::TValue TValue;
- typedef typename Superclass::TResult TResult;
- typedef typename Superclass::TVertexCompare TVertexCompare;
+ typedef typename Superclass::TOutput TOutput;
+ typedef typename Superclass::TVertex TVertex;
+ typedef fpa::Base::Functors::RegionGrow::Base< TVertex, TOutput > TGrowFunction;
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 std::queue< std::pair< TVertex, _TNode > > _TQueue;
+ typedef typename Superclass::_TQueueNode _TQueueNode;
public:
itkTypeMacro( RegionGrow, Algorithm );
- itkGetConstMacro( InsideValue, TResult );
- itkGetConstMacro( OutsideValue, TResult );
+ public:
+ TGrowFunction* GetGrowFunction( );
+ const TGrowFunction* GetGrowFunction( ) const;
+ TOutput GetInsideValue( ) const;
+ TOutput GetOutsideValue( ) const;
- itkSetMacro( InsideValue, TResult );
- itkSetMacro( OutsideValue, TResult );
+ void SetGrowFunction( TGrowFunction* f );
+ void SetInsideValue( const TOutput& v );
+ void SetOutsideValue( const TOutput& v );
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;
+ virtual bool _UpdateValue(
+ _TQueueNode& v, const _TQueueNode& p
+ ) 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 );
+ }
- // Queue-related abstract methods
- virtual bool _IsQueueEmpty( ) const;
- virtual void _QueuePush( const TVertex& v, const _TNode& n );
- virtual void _QueuePop( TVertex& v, _TNode& n );
- virtual void _QueueClear( );
private:
- // Purposely not implemented
+ // Purposely not defined
RegionGrow( const Self& other );
Self& operator=( const Self& other );
protected:
- TResult m_InsideValue;
- TResult m_OutsideValue;
- _TQueue m_Queue;
+ typename TGrowFunction::Pointer m_GrowFunction;
};
} // 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$