]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/MinimumSpanningTree.h
Almost there...
[FrontAlgorithms.git] / lib / fpa / Base / MinimumSpanningTree.h
index ec744e69a10229753e96a55ab27d8114b81ad769..9adcd6d2e1cc44d7cd57f66cbbf45dbd2f956e26 100644 (file)
@@ -1,7 +1,10 @@
 #ifndef __FPA__BASE__MINIMUMSPANNINGTREE__H__
 #define __FPA__BASE__MINIMUMSPANNINGTREE__H__
 
+#include <map>
+#include <utility>
 #include <vector>
+#include <itkSimpleDataObjectDecorator.h>
 #include <itkSmartPointer.h>
 
 namespace fpa
@@ -10,30 +13,39 @@ 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:
+      itkNewMacro( Self );
       itkTypeMacro( MinimumSpanningTree, B );
 
       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( );
+        }
 
       virtual void GetPath(
         std::vector< V >& path, const V& a, const V& b
@@ -44,8 +56,6 @@ namespace fpa
       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