]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/MinimumSpanningTree.h
more experiments...
[FrontAlgorithms.git] / lib / fpa / Base / MinimumSpanningTree.h
index a020d4795d1f78e25f0d13fab1cc006971c63f46..bc9ce93c0cfa603c45197ea2c19a51fee154ea01 100644 (file)
@@ -2,9 +2,9 @@
 #define __FPA__BASE__MINIMUMSPANNINGTREE__H__
 
 #include <map>
-#include <utility>
 #include <vector>
-#include <itkSimpleDataObjectDecorator.h>
+#include <utility>
+#include <itkPoint.h>
 #include <itkSmartPointer.h>
 
 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 <fpa/Base/MinimumSpanningTree.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
 
 #endif // __FPA__BASE__MINIMUMSPANNINGTREE__H__