]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/MinimumSpanningTree.h
...
[FrontAlgorithms.git] / lib / fpa / Base / MinimumSpanningTree.h
index dc0c6d1fcea928411c34880564b8e929a78edd12..35cb6e4c0488616d700ab6c49547f93e146910a6 100644 (file)
@@ -1,11 +1,12 @@
-#ifndef __FPA__BASE__MINIMUMSPANNINGTREE__H__
-#define __FPA__BASE__MINIMUMSPANNINGTREE__H__
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+
+#ifndef __fpa__Base__MinimumSpanningTree__h__
+#define __fpa__Base__MinimumSpanningTree__h__
 
-#include <functional>
-#include <map>
-#include <utility>
 #include <vector>
-#include <itkSimpleDataObjectDecorator.h>
 
 namespace fpa
 {
@@ -13,79 +14,54 @@ namespace fpa
   {
     /**
      */
-    template< class _TVertex, class _TScalar, class _TVertexCompare = std::less< _TVertex > >
+    template< class _TVertex, class _Superclass >
     class MinimumSpanningTree
-      : public itk::SimpleDataObjectDecorator< std::map< _TVertex, std::pair< _TVertex, std::pair< _TScalar, long > >, _TVertexCompare > >
+      : public _Superclass
     {
     public:
-      typedef std::pair< _TScalar, long >                    TData;
-      typedef std::pair< _TVertex, TData >                   TParent;
-      typedef std::map< _TVertex, TParent, _TVertexCompare > TContainer;
-      typedef itk::SimpleDataObjectDecorator< TContainer >   Superclass;
-      typedef MinimumSpanningTree                            Self;
-      typedef itk::SmartPointer< Self >                      Pointer;
-      typedef itk::SmartPointer< const Self >                ConstPointer;
-
-      typedef _TVertex        TVertex;
-      typedef _TScalar        TScalar;
-      typedef _TVertexCompare TVertexCompare;
+      typedef MinimumSpanningTree             Self;
+      typedef _Superclass                     Superclass;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
 
-      typedef std::vector< TVertex >        TVertices;
+      typedef _TVertex                      TVertex;
       typedef std::pair< TVertex, bool >    TCollision;
       typedef std::vector< TCollision >     TCollisionsRow;
       typedef std::vector< TCollisionsRow > TCollisions;
-
-      typedef std::multimap< double, _TVertex > TNodeQueue;
+      typedef std::vector< TVertex >        TVertices;
 
     protected:
-      typedef std::vector< unsigned long >  _TRow;
-      typedef std::vector< _TRow > _TMatrix;
+      typedef std::vector< unsigned long > _TRow;
+      typedef std::vector< _TRow >         _TMatrix;
 
     public:
-      itkNewMacro( Self );
-      itkTypeMacro( MinimumSpanningTree, itk::SimpleDataObjectDecorator );
-
-      itkBooleanMacro( FillNodeQueue );
-
-      itkGetConstReferenceMacro( Collisions, TCollisions );
-      itkGetConstReferenceMacro( NodeQueue, TNodeQueue );
-      itkGetConstMacro( FillNodeQueue, bool );
-
-      itkSetMacro( FillNodeQueue, bool );
+      itkTypeMacro( fpa::Base::MinimumSpanningTree, _Superclass );
 
     public:
+      const TCollisions& GetCollisions( ) const;
       void SetCollisions( const TCollisions& collisions );
-      TVertices GetPath( const _TVertex& a ) const;
-      TVertices GetPath( const _TVertex& a, const _TVertex& b ) const;
 
-      virtual void SetNode(
-        const _TVertex& vertex,
-        const _TVertex& parent,
-        const long& fid = -1,
-        const _TScalar& result = _TScalar( 0 )
-        );
-      virtual void Clear( );
+      void ClearSeeds( );
+      void AddSeed( const TVertex& seed );
+
+      virtual TVertex GetParent( const TVertex& v ) const = 0;
+      virtual void SetParent( const TVertex& v, const TVertex& p ) = 0;
+
+      virtual TVertices GetPath( const TVertex& a ) const;
+      virtual TVertices GetPath( const TVertex& a, const TVertex& b ) const;
 
     protected:
       MinimumSpanningTree( );
       virtual ~MinimumSpanningTree( );
 
-      virtual bool _HasVertex( const _TVertex& a ) const;
-      virtual long _FrontId( const _TVertex& a ) const;
-      virtual void _Path( TVertices& path, const _TVertex& a ) const;
-
     private:
-      // Purposely not implemented
       MinimumSpanningTree( const Self& other );
       Self& operator=( const Self& other );
 
     protected:
       TCollisions m_Collisions;
       _TMatrix    m_FrontPaths;
-      TNodeQueue  m_NodeQueue;
-      bool        m_FillNodeQueue;
-
-      static const unsigned long INF_VALUE;
+      std::vector< TVertex > m_Seeds;
     };
 
   } // ecapseman
@@ -94,8 +70,8 @@ namespace fpa
 
 #ifndef ITK_MANUAL_INSTANTIATION
 #  include <fpa/Base/MinimumSpanningTree.hxx>
-#endif
+#endif // ITK_MANUAL_INSTANTIATION
 
-#endif // __FPA__BASE__MINIMUMSPANNINGTREE__H__
+#endif // __fpa__Base__MinimumSpanningTree__h__
 
 // eof - $RCSfile$