X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FBase%2FMinimumSpanningTree.h;h=40562678d23e2717c8793b32c59b6ec6a60caf8c;hb=6468f1fda5fed2788fbaef1a7925c91ecff83d13;hp=ec744e69a10229753e96a55ab27d8114b81ad769;hpb=db33ebb226fd58f493b7db245fc8b807f895ee6e;p=FrontAlgorithms.git diff --git a/lib/fpa/Base/MinimumSpanningTree.h b/lib/fpa/Base/MinimumSpanningTree.h index ec744e6..4056267 100644 --- a/lib/fpa/Base/MinimumSpanningTree.h +++ b/lib/fpa/Base/MinimumSpanningTree.h @@ -1,7 +1,10 @@ #ifndef __FPA__BASE__MINIMUMSPANNINGTREE__H__ #define __FPA__BASE__MINIMUMSPANNINGTREE__H__ +#include +#include #include +#include #include namespace fpa @@ -10,42 +13,60 @@ namespace fpa { /** */ - template< class V, class C, class B > + template< class V, class C, class VC > class MinimumSpanningTree - : public B + : public itk::SimpleDataObjectDecorator< std::map< V, std::pair< V, short >, VC > > { public: - typedef MinimumSpanningTree Self; - typedef B Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; + typedef std::pair< V, short > TNodeInfo; + typedef std::map< V, TNodeInfo, VC > TDecorated; + typedef MinimumSpanningTree Self; + typedef itk::SimpleDataObjectDecorator< TDecorated > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; - typedef V TVertex; - typedef C TCollisions; + typedef V TVertex; + typedef C TCollisions; + typedef VC TVertexCompare; protected: typedef std::vector< unsigned long > _TRow; typedef std::vector< _TRow > _TMatrix; public: - itkTypeMacro( MinimumSpanningTree, B ); + itkNewMacro( Self ); + itkTypeMacro( MinimumSpanningTree, itkSimpleDataObjectDecorator ); itkGetConstMacro( Collisions, TCollisions ); public: void SetCollisions( const TCollisions& collisions ); - + void SetParent( const TVertex& v, const TVertex& p, const short& fid ) + { + this->Get( )[ v ] = TNodeInfo( p, fid ); + this->Modified( ); + } + void Clear( ) + { + this->Get( ).clear( ); + this->m_Collisions.clear( ); + this->m_FrontPaths.clear( ); + } virtual void GetPath( std::vector< V >& path, const V& a, const V& b ) const; + template< class I, class P > + void GetPathFromImage( + std::vector< P >& path, const V& a, const V& b, + const I* image, unsigned int kernel = 0 + ) const; + protected: MinimumSpanningTree( ); virtual ~MinimumSpanningTree( ); virtual void _Path( std::vector< V >& path, const V& a ) const; - virtual long _FrontId( const V& v ) const = 0; - virtual V _Parent( const V& v ) const = 0; private: // Purposely not implemented