X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FBase%2FMinimumSpanningTree.h;h=bc9ce93c0cfa603c45197ea2c19a51fee154ea01;hb=826a318db2e9b41fbd865e41ebb5906efdefbb02;hp=a020d4795d1f78e25f0d13fab1cc006971c63f46;hpb=dba0f8d24a98fabeb461b337ed78efaf06cb057c;p=FrontAlgorithms.git diff --git a/lib/fpa/Base/MinimumSpanningTree.h b/lib/fpa/Base/MinimumSpanningTree.h index a020d47..bc9ce93 100644 --- a/lib/fpa/Base/MinimumSpanningTree.h +++ b/lib/fpa/Base/MinimumSpanningTree.h @@ -2,9 +2,9 @@ #define __FPA__BASE__MINIMUMSPANNINGTREE__H__ #include -#include #include -#include +#include +#include #include namespace fpa @@ -13,54 +13,67 @@ namespace fpa { /** */ - template< class V, class C, class VC > + template< class _TSuperclass, class _TVertex > class MinimumSpanningTree - : public itk::SimpleDataObjectDecorator< std::map< V, std::pair< V, short >, VC > > + : public _TSuperclass { public: - 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 MinimumSpanningTree Self; + typedef _TSuperclass Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; - typedef V TVertex; - typedef C TCollisions; - typedef VC TVertexCompare; + typedef _TVertex TVertex; + typedef std::vector< TVertex > TVertices; + typedef std::pair< TVertex, bool > TCollision; + typedef std::vector< TCollision > TCollisionsRow; + typedef std::vector< TCollisionsRow > TCollisions; + + typedef itk::Point< double, TVertex::Dimension > TPoint; + typedef std::vector< TPoint > TPoints; + typedef std::multimap< double, TVertex > TNodeQueue; protected: typedef std::vector< unsigned long > _TRow; typedef std::vector< _TRow > _TMatrix; public: - itkNewMacro( Self ); - itkTypeMacro( MinimumSpanningTree, itkSimpleDataObjectDecorator ); + itkTypeMacro( MinimumSpanningTree, _TSuperclass ); + + itkBooleanMacro( FillNodeQueue ); - itkGetConstMacro( Collisions, TCollisions ); + itkGetConstReferenceMacro( Collisions, TCollisions ); + itkGetConstReferenceMacro( NodeQueue, TNodeQueue ); + itkGetConstMacro( FillNodeQueue, bool ); + + itkSetMacro( FillNodeQueue, bool ); 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 + TVertices GetPath( const TVertex& a ) const; + TVertices GetPath( const TVertex& a, const TVertex& b ) const; + + virtual TPoints GetEuclideanPath( const TVertex& a ) const; + virtual TPoints GetEuclideanPath( + const TVertex& a, const TVertex& b ) const; + virtual bool IsDefinedInEuclideanSpace( ) const; + + virtual void SetNode( + const TVertex& v, + const TVertex& p, + const short& fid, + const double& cost + ); + virtual void Clear( ); protected: MinimumSpanningTree( ); virtual ~MinimumSpanningTree( ); - virtual void _Path( std::vector< V >& path, const V& a ) const; + virtual bool _HasVertex( const TVertex& a ) const = 0; + virtual short _FrontId( const TVertex& a ) const = 0; + virtual void _Path( TVertices& path, const TVertex& a ) const = 0; private: // Purposely not implemented @@ -70,6 +83,9 @@ namespace fpa protected: TCollisions m_Collisions; _TMatrix m_FrontPaths; + TNodeQueue m_NodeQueue; + bool m_FillNodeQueue; + static const unsigned long INF_VALUE; }; @@ -77,7 +93,9 @@ namespace fpa } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __FPA__BASE__MINIMUMSPANNINGTREE__H__