X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FBase%2FSeedsInterface.h;h=41debde26ae73c812224358b3c864ca825b699d8;hb=5c78aecb0f5a207ff020e24f99d1e9bd8c388ad1;hp=cfc1bd568e505af2aba29ef173dccf8bc70d9a0a;hpb=cd6b3f8433deaf2ba7c6bb0ece8e5912c760db17;p=FrontAlgorithms.git diff --git a/lib/fpa/Base/SeedsInterface.h b/lib/fpa/Base/SeedsInterface.h index cfc1bd5..41debde 100644 --- a/lib/fpa/Base/SeedsInterface.h +++ b/lib/fpa/Base/SeedsInterface.h @@ -6,8 +6,12 @@ #ifndef __fpa__Base__SeedsInterface__h__ #define __fpa__Base__SeedsInterface__h__ -#include +#include #include +#include + +#include +#include namespace fpa { @@ -15,29 +19,71 @@ namespace fpa { /** */ - template< class _TVertex, class _TCompare > + template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare = std::greater< _TVertex > > class SeedsInterface { public: - typedef _TVertex TVertex; - typedef _TCompare TCompare; + itkConceptMacro( + Check_TFrontId, + ( itk::Concept::IsUnsignedInteger< _TFrontId > ) + ); + + public: + typedef _TVertex TVertex; + typedef _TPoint TPoint; + typedef _TInputValue TInputValue; + typedef _TOutputValue TOutputValue; + typedef _TFrontId TFrontId; + typedef _TCompare TCompare; typedef SeedsInterface Self; - typedef std::set< TVertex, TCompare > TSeeds; + + struct TSeed + { + TVertex Vertex; + TPoint Point; + bool IsPoint; + bool IsUnified; + TFrontId FrontId; + TSeed( ) + : IsUnified( false ), + FrontId( TFrontId( 0 ) ) + { } + }; + typedef std::vector< TSeed > TSeeds; + + struct TNode + { + TVertex Vertex; + TVertex Parent; + TFrontId FrontId; + + // Hack to hide the fact that seed values need to be initialized + mutable TOutputValue Value; + }; + struct TNodeCompare + { + bool operator()( const TNode& a, const TNode& b ) const + { + TCompare cmp; + return( cmp( a.Vertex, b.Vertex ) ); + } + }; + typedef std::set< TNode, TNodeCompare > TNodes; public: - unsigned int GetNumberOfSeeds( ) const; const TSeeds& GetSeeds( ) const; - typename TSeeds::const_iterator BeginSeeds( ) const; - typename TSeeds::const_iterator EndSeeds( ) const; - void AddSeed( const TVertex& seed ); - void RemoveSeed( const TVertex& seed ); - void ClearSeeds( ); + virtual void AddSeed( const TVertex& seed ); + virtual void AddSeed( const TPoint& seed ); + virtual void ClearSeeds( ); protected: SeedsInterface( itk::ProcessObject* filter ); virtual ~SeedsInterface( ); + virtual TNodes _UnifySeeds( ) = 0; + virtual void _PrepareSeeds( TNodes& nodes ) = 0; + protected: TSeeds m_Seeds; itk::ProcessObject* m_Filter;