]> Creatis software - FrontAlgorithms.git/blobdiff - plugins/ImageAlgorithms/FastMarching.cxx
...
[FrontAlgorithms.git] / plugins / ImageAlgorithms / FastMarching.cxx
index 5805e307adc2a629b68b61e3051b7d046f07a38a..355c882f3773b240f5e87e76004d020e698f0466 100644 (file)
@@ -1,19 +1,18 @@
-#include <ImageAlgorithms/FastMarching.h>
+#include "FastMarching.h"
+#include <cpPlugins/Pipeline/Functor.h>
 #include <cpInstances/DataObjects/Image.h>
 
 #include <fpa/Image/FastMarching.h>
 
 // -------------------------------------------------------------------------
-fpaPluginsImageAlgorithms::FastMarching::
+fpaPlugins_ImageAlgorithms::FastMarching::
 FastMarching( )
   : Superclass( )
 {
-  typedef cpPlugins::Pipeline::DataObject _TData;
-  typedef cpInstances::DataObjects::Image _TMST;
+  typedef cpPlugins::Pipeline::DataObject _TFunctor;
 
-  this->_ConfigureInput< _TData >( "VertexFunction", false, false );
-  this->_ConfigureInput< _TData >( "ConversionFunction", false, false );
-  this->_ConfigureOutput< _TMST >( "MST" );
+  this->_ConfigureInput< _TFunctor >( "VertexFunction", false, false );
+  this->_ConfigureInput< _TFunctor >( "ConversionFunction", false, false );
 
   std::vector< std::string > choices;
   choices.push_back( "float" );
@@ -23,13 +22,13 @@ FastMarching( )
 }
 
 // -------------------------------------------------------------------------
-fpaPluginsImageAlgorithms::FastMarching::
+fpaPlugins_ImageAlgorithms::FastMarching::
 ~FastMarching( )
 {
 }
 
 // -------------------------------------------------------------------------
-void fpaPluginsImageAlgorithms::FastMarching::
+void fpaPlugins_ImageAlgorithms::FastMarching::
 _GenerateData( )
 {
   auto o = this->GetInputData( "Input" );
@@ -39,7 +38,7 @@ _GenerateData( )
 
 // -------------------------------------------------------------------------
 template< class _TImage >
-void fpaPluginsImageAlgorithms::FastMarching::
+void fpaPlugins_ImageAlgorithms::FastMarching::
 _GD0( _TImage* image )
 {
   typedef itk::Image< float, _TImage::ImageDimension >  _TFloat;
@@ -52,35 +51,46 @@ _GD0( _TImage* image )
 
 // -------------------------------------------------------------------------
 template< class _TInputImage, class _TOutputImage >
-void fpaPluginsImageAlgorithms::FastMarching::
+void fpaPlugins_ImageAlgorithms::FastMarching::
 _GD1( _TInputImage* image )
 {
+  typedef cpPlugins::Pipeline::Functor _TFunctor;
   typedef fpa::Image::FastMarching< _TInputImage, _TOutputImage > _TFilter;
   typedef typename _TFilter::TConversionFunction      _TConversionFunction;
   typedef typename _TFilter::TVertexFunction              _TVertexFunction;
 
+  // Create filter
   auto filter = this->_CreateITK< _TFilter >( );
   std::vector< typename _TInputImage::IndexType > seeds;
   this->_ConfigureFilter( filter, image, seeds );
+
+  // Instantiate functors
+  auto cost_conversion = this->GetInputData< _TFunctor >( "ConversionFunction" );
+  if( cost_conversion != NULL )
+  {
+    cost_conversion->Instantiate( filter );
+    auto cost_conversion_functor = cost_conversion->GetFunctor< _TConversionFunction >( );
+    if( cost_conversion_functor != NULL )
+      filter->SetConversionFunction( cost_conversion_functor );
+
+  } // fi
+
+  auto vertex = this->GetInputData< _TFunctor >( "VertexFunction" );
+  if( vertex != NULL )
+  {
+    vertex->Instantiate( filter );
+    auto vertex_functor = vertex->GetFunctor< _TVertexFunction >( );
+    if( vertex_functor != NULL )
+      filter->SetVertexFunction( vertex_functor );
+
+  } // fi
+
+  // Finish filter's configuration
   filter->ClearSeeds( );
   for( auto seed : seeds )
     filter->AddSeed( seed, ( typename _TOutputImage::PixelType )( 0 ) );
   filter->Update( );
   this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
-
-  /* TODO
-     auto filter = this->_CreateITK< _TFilter >( );
-     this->_ConfigureFilter( filter, image );
-     auto cost = this->GetInputData< _TCost >( "Cost" );
-     auto conv = this->GetInputData< _TCostConversion >( "CostConversion" );
-     if( cost != NULL )
-     filter->SetCostFunction( cost );
-     if( conv != NULL )
-     filter->SetCostConversionFunction( conv );
-     filter->Update( );
-     this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
-     this->GetOutput( "MST" )->SetITK( filter->GetMinimumSpanningTree( ) );
-  */
 }
 
 // eof - $RCSfile$