]> Creatis software - cpPlugins.git/blobdiff - appli/examples/plugins/ImageTracer.cxx
...
[cpPlugins.git] / appli / examples / plugins / ImageTracer.cxx
index a8624d1b8e75494d4e8f1e2386b29788c2ed518b..cff73bd429682fe983c287f966d16bc490953576 100644 (file)
 #include <vtkImageData.h>
 #include <vtkPolyData.h>
 
-/* TODO
-   #include <vtkImageTracerWidget.h>
-   #include <vtkSplineWidget.h>
-   #include <vtkSmartPointer.h>
-   #include <vtkGlyphSource2D.h>
-   #include <vtkProp.h>
-*/
-
 #endif // cpExtensions_QT4
 
 //----------------------------------------------------------------------------
@@ -56,14 +48,23 @@ int main( int argc, char* argv[] )
   typedef cpPlugins::Interface::Workspace _TWorkspace;
   _TWorkspace::Pointer ws = _TWorkspace::New( );
   ws->PrintExecutionOn( );
+  ws->Load( argv[ 1 ] );
 
   // Configure filters
-  auto reader = ws->CreateFilter( "IO", "ImageReader", "reader" );
-  auto widget = ws->CreateFilter( "Widgets", "SplineWidget", "spline" );
-  ws->Connect( "reader", "spline", "Output", "Input" );
-  auto params = reader->GetParameters( );
-  for( int i = 1; i < argc; ++i )
-    params->AddToOpenFileNameList( "FileNames",  argv[ i ] );
+  /* TODO
+     auto reader = ws->CreateFilter( "IO", "ImageReader", "reader" );
+     auto widget = ws->CreateFilter( "Widgets", "SplineWidget", "spline" );
+     ws->Connect( "reader", "spline", "Output", "Input" );
+     auto params = reader->GetParameters( );
+     for( int i = 1; i < argc; ++i )
+     params->AddToOpenFileNameList( "FileNames",  argv[ i ] );
+  */
+  auto reader = ws->GetFilter( "reader" );
+  auto spline = ws->GetFilter( "spline" );
+  auto seeds = ws->GetFilter( "seeds" );
+  auto axis = ws->GetFilter( "axis" );
+  auto writer = ws->GetFilter( "writer" );
+  auto raster = ws->GetFilter( "raster" );
 
   // Execute reader
   try
@@ -85,17 +86,39 @@ int main( int argc, char* argv[] )
   view.SetImage(
     reader->GetOutputData< vtkImageData >( "Output" ), 2, "image"
     );
-  widget->AddInteractor( view.GetInteractor( ) );
-  widget->Update( );
+  spline->AddInteractor( view.GetInteractor( ) );
+  seeds->AddInteractor( view.GetInteractor( ) );
+  spline->Update( );
+  seeds->Update( );
 
   // Start application and show data
   wnd.setCentralWidget( &view );
   wnd.show( );
-  int r = app.exec( );
-  widget->Modified( );
-  widget->Update( );
-  widget->GetOutputData< vtkPolyData >( "Output" )->Print( std::cout );
-  return( r );
+  app.exec( );
+  spline->Modified( );
+  spline->Update( );
+  raster->Update( );
+  writer->Update( );
+
+  wnd.show( );
+  app.exec( );
+  
+  seeds->Modified( );
+  seeds->Update( );
+  axis->Update( );
+  // view.Add( axis->GetOutputData< vtkPolyData >( "Output" ) );
+  wnd.show( );
+  return( app.exec( ) );
+
+  // TODO: widget->GetOutputData< vtkPolyData >( "Output" )->Print( std::cout );
+
+  /*
+    auto raster = ws->CreateFilter( "MeshToImageFilters", "RasterMeshFilter", "raster" );
+    ws->Connect( "spline", "raster", "Output", "Input" );
+    ws->Connect( "reader", "raster", "Output", "Template" );
+    raster->Update( );
+  */
+  
 #else // cpExtensions_QT4
   return( 0 );
 #endif // cpExtensions_QT4