#define __FPA__BASE__MINIMUMSPANNINGTREE__H__
#include <map>
-#include <utility>
#include <vector>
-#include <itkSimpleDataObjectDecorator.h>
+#include <utility>
+#include <itkPoint.h>
#include <itkSmartPointer.h>
namespace fpa
{
/**
*/
- template< class V, class B >
+ template< class _TSuperclass, class _TVertex >
class MinimumSpanningTree
- : public itk::SimpleDataObjectDecorator< std::map< V, std::pair< V, short >, B > >
+ : public _TSuperclass
{
public:
- typedef std::pair< V, short > TNodeInfo;
- typedef std::map< V, TNodeInfo, B > 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 B 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 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 );
+
+ itkGetConstReferenceMacro( Collisions, TCollisions );
+ itkGetConstReferenceMacro( NodeQueue, TNodeQueue );
+ itkGetConstMacro( FillNodeQueue, bool );
- itkGetConstMacro( Collisions, TCollisions );
+ 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 std::vector< V > GetPath( const V& a, const V& b ) const;
-
- template< class I >
- std::vector< typename I::PointType > GetPathFromImage(
- const V& a, const V& b,
- const I* image, unsigned int kernel = 0
+ 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
protected:
TCollisions m_Collisions;
_TMatrix m_FrontPaths;
+ TNodeQueue m_NodeQueue;
+ bool m_FillNodeQueue;
+
static const unsigned long INF_VALUE;
};
} // ecapseman
+#ifndef ITK_MANUAL_INSTANTIATION
#include <fpa/Base/MinimumSpanningTree.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
#endif // __FPA__BASE__MINIMUMSPANNINGTREE__H__