]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpaPlugins/ThresholdImageGrowFunctionSource.cxx
...
[FrontAlgorithms.git] / lib / fpaPlugins / ThresholdImageGrowFunctionSource.cxx
index 8ea176ee7f5577f92acbdd309c87cf1d802d3260..e518b6bbe215c595e535c131fa9d06b3c3fa19df 100644 (file)
@@ -11,13 +11,13 @@ ThresholdImageGrowFunctionSource( )
   : Superclass( )
 {
   this->_AddInput( "ReferenceImage" );
-  this->_MakeOutput< GrowFunction >( "Output" );
+  this->_AddOutput< GrowFunction >( "Output" );
 
   this->m_Parameters->ConfigureAsReal( "LowerThreshold" );
   this->m_Parameters->ConfigureAsReal( "UpperThreshold" );
 
   this->m_Parameters->SetReal( "LowerThreshold", 0 );
-  this->m_Parameters->SetReal( "UpperThreshold", 0 );
+  this->m_Parameters->SetReal( "UpperThreshold", 1 );
 }
 
 // -------------------------------------------------------------------------
@@ -30,17 +30,12 @@ fpaPlugins::ThresholdImageGrowFunctionSource::
 std::string fpaPlugins::ThresholdImageGrowFunctionSource::
 _GenerateData( )
 {
-  cpPlugins::Interface::Image* image =
-    this->GetInput< cpPlugins::Interface::Image >( "ReferenceImage" );
-  if( image == NULL )
-    return( "fpaPlugins::ThresholdImageGrowFunctionSource: No input reference image." );
-
+  auto image = this->GetInputData( "ReferenceImage" );
   itk::DataObject* itk_image = NULL;
   std::string r = "";
   cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
   else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 );
   else r = "fpaPlugins::ThresholdImageGrowFunctionSource: no valid reference image.";
-
   return( r );
 }
 
@@ -50,17 +45,19 @@ std::string fpaPlugins::ThresholdImageGrowFunctionSource::
 _GD0( itk::DataObject* data )
 {
   typedef fpa::Image::Functors::RegionGrowThresholdFunction< I > _F;
-  typename _F::Pointer functor = _F::New( );
 
-  // Connect output
-  GrowFunction* out = this->GetOutput< GrowFunction >( "Output" );
-  if( out != NULL )
+  auto out = this->GetOutputData( "Output" );
+  auto f = out->GetITK< _F >( );
+  if( f == NULL )
   {
-    out->SetITK< _F >( functor );
-    return( "" );
-  }
-  else
-    return( "fpaPlugins::ThresholdImageGrowFunctionSource: output not correctly created." );
+    typename _F::Pointer ptr_f = _F::New( );
+    f = ptr_f.GetPointer( );
+    out->SetITK( f );
+
+  } // fi
+  f->SetLowerThreshold( this->m_Parameters->GetReal( "LowerThreshold" ) );
+  f->SetUpperThreshold( this->m_Parameters->GetReal( "UpperThreshold" ) );
+  return( "" );
 }
 
 // eof - $RCSfile$