]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Image/Dijkstra.hxx
...
[FrontAlgorithms.git] / lib / fpa / Image / Dijkstra.hxx
index eca6ce3672f6749e39d050da675afc8815f3e76b..f3c6a7216a47090a3fb10c23205422c91eb12f3c 100644 (file)
@@ -1,59 +1,60 @@
-#ifndef __FPA__IMAGE__DIJKSTRA__HXX__
-#define __FPA__IMAGE__DIJKSTRA__HXX__
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
 
-#include <limits>
+#ifndef __fpa__Image__Dijkstra__hxx__
+#define __fpa__Image__Dijkstra__hxx__
 
 // -------------------------------------------------------------------------
-template< class I, class O >
-fpa::Image::Dijkstra< I, O >::
+template< class _TInputImage, class _TOutputImage, class _TFrontId, class _TTraits >
+fpa::Image::Dijkstra< _TInputImage, _TOutputImage, _TFrontId, _TTraits >::
 Dijkstra( )
   : Superclass( )
 {
-  this->m_CostFunction = TCostFunction::New( );
 }
 
 // -------------------------------------------------------------------------
-template< class I, class O >
-fpa::Image::Dijkstra< I, O >::
+template< class _TInputImage, class _TOutputImage, class _TFrontId, class _TTraits >
+fpa::Image::Dijkstra< _TInputImage, _TOutputImage, _TFrontId, _TTraits >::
 ~Dijkstra( )
 {
 }
 
 // -------------------------------------------------------------------------
-template< class I, class O >
-typename fpa::Image::Dijkstra< I, O >::
-TResult fpa::Image::Dijkstra< I, O >::
-_Cost( const TVertex& v, const TVertex& p ) const
-{
-  if( this->_HasEdge( v, p ) )
-  {
-    TResult c = this->m_CostFunction->Evaluate( v, p );
-    if( this->m_ConversionFunction.IsNotNull( ) )
-      c = this->m_ConversionFunction->Evaluate( c );
-    return( c );
-  }
-  else
-    return( std::numeric_limits< TResult >::max( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class I, class O >
-void fpa::Image::Dijkstra< I, O >::
+template< class _TInputImage, class _TOutputImage, class _TFrontId, class _TTraits >
+void fpa::Image::Dijkstra< _TInputImage, _TOutputImage, _TFrontId, _TTraits >::
 _BeforeGenerateData( )
 {
   this->Superclass::_BeforeGenerateData( );
-  this->m_CostFunction->SetInputImage( this->GetInput( ) );
+  TWeightFunction* wf =
+    dynamic_cast< TWeightFunction* >( this->GetWeightFunction( ) );
+  if( wf != NULL )
+    wf->SetImage( this->GetInput( ) );
 }
 
 // -------------------------------------------------------------------------
-template< class I, class O >
-void fpa::Image::Dijkstra< I, O >::
-_InitResults( )
+template< class _TInputImage, class _TOutputImage, class _TFrontId, class _TTraits >
+void fpa::Image::Dijkstra< _TInputImage, _TOutputImage, _TFrontId, _TTraits >::
+_ConfigureOutput( const TOutputValue& v )
 {
-  this->Superclass::_InitResults( );
-  this->GetOutput( )->FillBuffer( std::numeric_limits< TResult >::max( ) );
+  this->Superclass::_ConfigureOutput( v );
+
+  const TInputImage* in = this->GetInput( );
+  TMST* mst = this->GetMinimumSpanningTree( );
+  mst->SetLargestPossibleRegion( in->GetLargestPossibleRegion( ) );
+  mst->SetRequestedRegion( in->GetRequestedRegion( ) );
+  mst->SetBufferedRegion( in->GetBufferedRegion( ) );
+  mst->SetSpacing( in->GetSpacing( ) );
+  mst->SetOrigin( in->GetOrigin( ) );
+  mst->SetDirection( in->GetDirection( ) );
+  mst->Allocate( );
+
+  typename TVertex::OffsetType o;
+  o.Fill( 0 );
+  mst->FillBuffer( o );
 }
 
-#endif // __FPA__IMAGE__DIJKSTRA__HXX__
+#endif // __fpa__Image__Dijkstra__hxx__
 
 // eof - $RCSfile$