]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpaPlugins/ImageRegionGrow.cxx
...
[FrontAlgorithms.git] / lib / fpaPlugins / ImageRegionGrow.cxx
index 19eba80f431eb1565f36a3acf1b2f7110ab2f9aa..07697ce48fb15481a06e66a0fa5c6cde4464369c 100644 (file)
@@ -1,41 +1,22 @@
 #include "ImageRegionGrow.h"
 
 #include <cpPlugins/Interface/Image.h>
-#include <cpPlugins/Interface/PointList.h>
-
 #include <fpaPlugins/GrowFunction.h>
-
 #include <fpa/Image/RegionGrow.h>
 #include <fpa/Image/Functors/RegionGrowAllBelongsFunction.h>
 
-#include <vtkRenderWindow.h>
-#include <vtkRenderWindowInteractor.h>
-
 // -------------------------------------------------------------------------
 fpaPlugins::ImageRegionGrow::
 ImageRegionGrow( )
   : Superclass( )
 {
-  this->_AddInput( "Input" );
-  this->_AddInput( "GrowFunction" );
-  this->_AddInput( "Seeds" );
-  this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
+  this->_AddInput( "GrowFunction", false );
 
-  this->m_Parameters->ConfigureAsBool( "VisualDebug" );
-  this->m_Parameters->ConfigureAsBool( "StopAtOneFront" );
   this->m_Parameters->ConfigureAsReal( "InsideValue" );
   this->m_Parameters->ConfigureAsReal( "OutsideValue" );
 
-  this->m_Parameters->SetBool( "VisualDebug", false );
-  this->m_Parameters->SetBool( "StopAtOneFront", false );
   this->m_Parameters->SetReal( "InsideValue", 1 );
   this->m_Parameters->SetReal( "OutsideValue", 0 );
-
-  std::vector< std::string > orders;
-  orders.push_back( "1" );
-  orders.push_back( "2" );
-  this->m_Parameters->ConfigureAsChoices( "NeighborhoodOrder", orders );
-  this->m_Parameters->SetSelectedChoice( "NeighborhoodOrder", "1" );
 }
 
 // -------------------------------------------------------------------------
@@ -50,9 +31,6 @@ _GenerateData( )
 {
   auto input =
     this->GetInputData< cpPlugins::Interface::Image >( "Input" );
-  if( input == NULL )
-    return( "fpaPlugins::ImageRegionGrow: No input image." );
-
   itk::DataObject* image = NULL;
   std::string r = "";
   cpPlugins_Image_Demangle_AllScalarTypes( 2, input, image, r, _GD0 );
@@ -70,17 +48,9 @@ _GD0( itk::DataObject* data )
   typedef itk::Image< _TOutPixel, I::ImageDimension > _TOut;
   typedef fpa::Image::RegionGrow< I, _TOut >          _TFilter;
   typedef typename _TFilter::TGrowingFunction         _TFunctor;
-  typedef typename I::PointType                       _TPoint;
 
-  auto seeds =
-    this->GetInputData< cpPlugins::Interface::PointList >( "Seeds" );
-  if( seeds == NULL )
-    return( "fpaPlugins::ImageRegionGrow: No given seeds." );
-  I* image = dynamic_cast< I* >( data );
-
-  // Create filter and connect input
-  _TFilter* filter = this->_CreateITK< _TFilter >( );
-  filter->SetInput( image );
+  // Create filter
+  _TFilter* filter = this->_ConfigureFilter< _TFilter >( );
 
   // Connect grow functor (or create a tautology)
   typename _TFunctor::Pointer functor;
@@ -94,39 +64,16 @@ _GD0( itk::DataObject* data )
   filter->SetGrowingFunction( functor );
 
   // Set numeric parameters
-  Superclass::TParameters* params = this->m_Parameters;
-  std::string order = params->GetSelectedChoice( "NeighborhoodOrder" );
-  filter->SetNeighborhoodOrder( order[ 0 ] - '0' );
-  filter->SetStopAtOneFront( params->GetBool( "StopAtOneFront" ) );
-  filter->SetInsideValue( _TOutPixel( params->GetReal( "InsideValue" ) ) );
-  filter->SetOutsideValue( _TOutPixel( params->GetReal( "OutsideValue" ) ) );
-
-  // Assign seeds
-  filter->ClearSeeds( );
-  for( unsigned int s = 0; s < seeds->GetNumberOfPoints( ); ++s )
-  {
-    _TPoint pnt = seeds->GetPoint< _TPoint >( s );
-    typename I::IndexType idx;
-    if( image->TransformPhysicalPointToIndex( pnt, idx ) )
-      filter->AddSeed( idx, 0 );
-
-  } // rof
+  filter->SetInsideValue(
+    _TOutPixel( this->m_Parameters->GetReal( "InsideValue" ) )
+    );
+  filter->SetOutsideValue(
+    _TOutPixel( this->m_Parameters->GetReal( "OutsideValue" ) )
+    );
 
   // Go!!!
-  this->_ConfigureDebugger( filter );
-  filter->Update( );
-  this->_DeconfigureDebugger( filter );
-
-  // Connect output
-  auto out =
-    this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
-  if( out != NULL )
-  {
-    out->SetITK< _TOut >( filter->GetOutput( ) );
-    return( "" );
-  }
-  else
-    return( "fpaPlugins::ImageRegionGrow: output not correctly created." );
+  this->_ExecuteFilter( filter );
+  return( "" );
 }
 
 // eof - $RCSfile$