#ifndef __FPA__BASE__ALGORITHM__H__
#define __FPA__BASE__ALGORITHM__H__
+#include <map>
#include <utility>
#include <vector>
#include <fpa/Base/Events.h>
+#include <fpa/Base/MinimumSpanningTree.h>
namespace fpa
{
* vertex could be marked as "visited", "in the front", "not yet there"
* or "freezed".
*
- * @param V Vertex type.
- * @param C Vertex value type.
- * @param R Result value type.
- * @param B Base class for this algorithm. It should be any itk-based
- * filter (itk::ProcessObject).
+ * @param V Vertex type.
+ * @param C Vertex value type.
+ * @param R Result value type.
+ * @param VC Vertex lexicographical compare.
+ * @param B Base class for this algorithm. It should be any itk-based
+ * filter (itk::ProcessObject).
*
*/
- template< class V, class C, class R, class B >
+ template< class V, class C, class R, class VC, class B >
class Algorithm
: public B
{
typedef itk::SmartPointer< Self > Pointer;
typedef itk::SmartPointer< const Self > ConstPointer;
- typedef V TVertex;
- typedef C TValue;
- typedef R TResult;
+ typedef V TVertex;
+ typedef C TValue;
+ typedef R TResult;
+ typedef VC TVertexCompare;
fpa_Base_NewEvent( TStartEvent );
fpa_Base_NewEvent( TStartLoopEvent );
+ fpa_Base_NewEvent( TStartBacktrackingEvent );
fpa_Base_NewEvent( TEndEvent );
fpa_Base_NewEvent( TEndLoopEvent );
+ fpa_Base_NewEvent( TEndBacktrackingEvent );
fpa_Base_NewEventWithVertex( TAliveEvent, TVertex );
fpa_Base_NewEventWithVertex( TFrontEvent, TVertex );
fpa_Base_NewEventWithVertex( TFreezeEvent, TVertex );
+ fpa_Base_NewEventWithVertex( TBacktrackingEvent, TVertex );
protected:
typedef std::vector< TVertex > _TVertices;
virtual ~_TNode( );
public:
- TVertex Vertex;
- TVertex Parent;
- TResult Result;
- long FrontId;
- _TNodeLabel Label;
+ TVertex Parent;
+ TResult Result;
+ short FrontId;
+ char Label;
};
- typedef std::vector< _TNode > _TNodes;
+ typedef std::map< TVertex, _TNode, TVertexCompare > _TNodes;
+
+ public:
+ typedef fpa::Base::MinimumSpanningTree< TVertex, _TCollisions, TVertexCompare > TMinimumSpanningTree;
public:
itkTypeMacro( Algorithm, B );
itkSetMacro( StopAtOneFront, bool );
public:
+ TMinimumSpanningTree* GetMinimumSpanningTree( );
+ const TMinimumSpanningTree* GetMinimumSpanningTree( ) const;
+ void GraftMinimumSpanningTree( itk::DataObject* obj );
+
virtual void InvokeEvent( const itk::EventObject& e );
virtual void InvokeEvent( const itk::EventObject& e ) const;
) const = 0;
virtual void _InitResults( ) = 0;
virtual const TResult& _Result( const TVertex& v ) const = 0;
- virtual void _SetResult( const TVertex& v, const TResult& r ) = 0;
+ virtual void _SetResult( const TVertex& v, const _TNode& n ) = 0;
// Marks-related abstract methods
- virtual const _TNode& _Node( const TVertex& v ) const = 0;
- virtual void _InitMarks( ) = 0;
- virtual void _Mark( const _TNode& node ) = 0;
+ virtual _TNode& _Node( const TVertex& v );
+ virtual const _TNode& _Node( const TVertex& v ) const;
+ virtual void _InitMarks( );
+ virtual void _Mark( const TVertex& v, const _TNode& node );
// Queue-related abstract methods
virtual void _InitQueue( );
virtual bool _IsQueueEmpty( ) const = 0;
- virtual void _QueuePush( const _TNode& n ) = 0;
- virtual _TNode _QueuePop( ) = 0;
+ virtual void _QueuePush( const TVertex& v, const _TNode& n ) = 0;
+ virtual void _QueuePop( TVertex& v, _TNode& n ) = 0;
virtual void _QueueClear( ) = 0;
private:
bool m_ThrowEvents;
bool m_StopAtOneFront;
_TNodes m_Seeds;
+ _TVertices m_SeedVertices;
+ _TNodes m_Marks;
_TCollisions m_Collisions;
+
+ unsigned int m_MinimumSpanningTreeIndex;
};
} // ecapseman