X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FBase%2FRegionGrow.h;h=8d7439f74e8a6e065e9730e17588445b01885572;hb=89393f2267e42e921571c0184320d6c6382f34ab;hp=e52fb6203c0e256624d8a010819ddc154b323cb7;hpb=9622bd5b833a8845881003228207e0caca59b081;p=FrontAlgorithms.git diff --git a/lib/fpa/Base/RegionGrow.h b/lib/fpa/Base/RegionGrow.h index e52fb62..8d7439f 100644 --- a/lib/fpa/Base/RegionGrow.h +++ b/lib/fpa/Base/RegionGrow.h @@ -1,9 +1,15 @@ -#ifndef __FPA__BASE__REGIONGROW__H__ -#define __FPA__BASE__REGIONGROW__H__ +// ========================================================================= +// @author Leonardo Florez Valencia +// @email florez-l@javeriana.edu.co +// ========================================================================= -#include -#include -#include +#ifndef __fpa__Base__RegionGrow__h__ +#define __fpa__Base__RegionGrow__h__ + +#include + +#include +#include namespace fpa { @@ -11,107 +17,82 @@ namespace fpa { /** */ - template< class V, class R, class VV, class VC > - class RegionGrowTraits - { - public: - typedef R TResult; - typedef V TVertex; - typedef VV TVertexValue; - typedef VC TVertexCmp; - - typedef bool TCost; - typedef long TFrontId; - - class TNode - { - public: - TNode( ) - { } - TNode( const TVertex& v, const TFrontId& f ) - : Vertex( v ), - Parent( v ), - FrontId( f ) - { } - TNode( const TVertex& v, const TResult& r, const TFrontId& f ) - : Vertex( v ), - Parent( v ), - Result( r ), - FrontId( f ) - { } - virtual ~TNode( ) - { } - - TVertex Vertex; - TVertex Parent; - TResult Result; - TFrontId FrontId; - }; - - typedef std::vector< TNode > TNodes; - }; - - /** - * Region grow is a front propagation with no costs. - */ - template< class V, class R, class VV, class VC, class B > + template< class _TAlgorithm > class RegionGrow - : public Algorithm< RegionGrowTraits< V, R, VV, VC >, B > + : public _TAlgorithm { public: - typedef V TVertex; - typedef R TResult; - typedef VV TVertexValue; - typedef B TBaseFilter; + 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; - /// Standard class typdedefs - typedef RegionGrowTraits< V, R, VV, VC > TTraits; - typedef RegionGrow Self; - typedef Algorithm< TTraits, B > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef typename TTraits::TCost TCost; + public: + itkConceptMacro( + Check_TOutputValue, + ( itk::Concept::IsUnsignedInteger< TOutputValue > ) + ); - protected: - typedef typename TTraits::TFrontId _TFrontId; - typedef typename TTraits::TNode _TNode; - typedef typename TTraits::TNodes _TNodes; + public: + itkGetObjectMacro( ValuePredicate, TValuePredicate ); + itkGetObjectMacro( VertexPredicate, TVertexPredicate ); + itkGetConstMacro( InsideValue, TOutputValue ); - private: - typedef std::queue< _TNode > _TQueue; + itkSetMacro( InsideValue, TOutputValue ); public: - itkTypeMacro( RegionGrow, Base ); + virtual itk::ModifiedTimeType GetMTime( ) const override; + virtual TOutputValue GetOutsideValue( ) const; + virtual void SetOutsideValue( const TOutputValue& v ); + + void SetPredicate( TValuePredicate* p ); + void SetPredicate( TVertexPredicate* p ); protected: RegionGrow( ); virtual ~RegionGrow( ); - virtual bool _UpdateResult ( _TNode& n ); - virtual void _InitializeQueue ( ); - virtual bool _IsQueueEmpty ( ) const; - virtual void _QueuePush ( const _TNode& n ); - virtual _TNode _QueuePop ( ); - virtual void _QueueClear ( ); - virtual bool _UpdateNeigh ( _TNode& nn, const _TNode& n ); - - virtual bool _CheckMembership( const _TNode& n ) const = 0; + virtual void _ComputeOutputValue( TNode& n ) override; + virtual void _UpdateOutputValue( 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: - RegionGrow( const Self& ); // Not impl. - void operator=( const Self& ); // Not impl. + // Purposely not implemented. + RegionGrow( const Self& other ); + Self& operator=( const Self& other ); - private: - _TQueue m_Queue; + protected: + typename TValuePredicate::Pointer m_ValuePredicate; + typename TVertexPredicate::Pointer m_VertexPredicate; + + TOutputValue m_InsideValue; + + TQueue m_Queue; }; } // ecapseman } // ecapseman -#include +#ifndef ITK_MANUAL_INSTANTIATION +# include +#endif // ITK_MANUAL_INSTANTIATION -#endif // __FPA__BASE__REGIONGROW__H__ +#endif // __fpa__Base__RegionGrow__h__ // eof - $RCSfile$