]> Creatis software - FrontAlgorithms.git/commitdiff
Add
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 17 Mar 2015 20:08:13 +0000 (15:08 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 17 Mar 2015 20:08:13 +0000 (15:08 -0500)
lib/fpa/Image/DijkstraWithSphereBacktracking.h
lib/fpa/Image/DijkstraWithSphereBacktracking.hxx

index 0cc0c4f637b7fabc5c6808db06bc0f25bfd26381..070a01a2706fb8f85189274307baa7f769a45e6b 100644 (file)
@@ -50,6 +50,7 @@ namespace fpa
 
       itkGetConstMacro( FinalTree, TTree );
       itkGetConstMacro( EndPoints, TVertices );
+      itkGetConstMacro( BifurcationPoints, TVertices );
 
     protected:
       DijkstraWithSphereBacktracking( );
@@ -69,6 +70,7 @@ namespace fpa
     protected:
       _TCandidates m_Candidates;
       TTree        m_FinalTree;
+      TVertices    m_BifurcationPoints;
       TVertices    m_EndPoints;
     };
 
index d71cef8798510f53709d418796f118778ccb54b2..95f8dcb0ac90901ac9026dba88cc7d37e28d5087 100644 (file)
@@ -73,11 +73,12 @@ _AfterMainLoop( )
   this->Superclass::_AfterMainLoop( );
   this->m_FinalTree.clear( );
   this->m_EndPoints.clear( );
+  this->m_BifurcationPoints.clear( );
   if( this->m_Candidates.size( ) == 0 )
     return;
   this->InvokeEvent( TEndEvent( ) );
 
-  // Get input values
+  // Get some input values
   const I* input = this->GetInput( );
   typename I::SpacingType spac = input->GetSpacing( );
   double max_spac = spac[ 0 ];
@@ -133,6 +134,7 @@ _AfterMainLoop( )
     this->m_EndPoints.push_back( max_vertex );
 
     // Construct path (at least the part that hasn't been iterated)
+    bool terminate = false;
     do
     {
       if( this->m_FinalTree.find( max_vertex ) == this->m_FinalTree.end( ) )
@@ -148,13 +150,24 @@ _AfterMainLoop( )
         // Next vertex in current path
         this->InvokeEvent( TBacktrackingEvent( max_vertex, backId ) );
         this->m_FinalTree[ max_vertex ] = this->_Parent( max_vertex );
+      }
+      else
+      {
+        // A bifurcation point has been reached!
+        this->m_BifurcationPoints.push_back( max_vertex );
+        terminate = true;
 
       } // fi
       max_vertex = this->_Parent( max_vertex );
 
-    } while( max_vertex != this->_Parent( max_vertex ) );
-    this->m_FinalTree[ max_vertex ] = max_vertex;
-    this->InvokeEvent( TEndBacktrackingEvent( backId ) );
+    } while( max_vertex != this->_Parent( max_vertex ) && !terminate );
+
+    if( !terminate )
+    {
+      this->m_FinalTree[ max_vertex ] = max_vertex;
+      this->InvokeEvent( TEndBacktrackingEvent( backId ) );
+
+    } // fi
 
   } // rof
 }
@@ -167,7 +180,8 @@ _UpdateNeigh( _TNode& nn, const _TNode& n )
   C nc = this->_Cost( nn.Vertex, n.Vertex );
   if( TCost( 0 ) < nc )
   {
-    nn.Cost = n.Cost + ( TCost( 1 ) / nc );
+    nc += TCost( 1 );
+    nn.Cost = n.Cost + ( TCost( 1 ) / std::pow( nc, 4 ) );
     nn.Result = nn.Cost;
     return( true );
   }