]> Creatis software - cpPlugins.git/blobdiff - appli/examples/example_ReadWriteImage.cxx
More tree visualization
[cpPlugins.git] / appli / examples / example_ReadWriteImage.cxx
index 8c562a96dcb0ea9aebcc94faea5b9c11a6d6c9c8..b051277e30cad06e532e62495f19a39c56153899 100644 (file)
@@ -4,7 +4,16 @@
 
 #include <cpPlugins/Interface/Interface.h>
 #include <cpPlugins/Interface/ProcessObject.h>
+#include <cpPlugins/Interface/Image.h>
 
+// -------------------------------------------------------------------------
+typedef cpPlugins::Interface::Interface     TInterface;
+typedef cpPlugins::Interface::ProcessObject TProcessObject;
+typedef cpPlugins::Interface::DataObject    TDataObject;
+typedef cpPlugins::Interface::Parameters    TParameters;
+typedef TInterface::TClasses                TClasses;
+
+// -------------------------------------------------------------------------
 int main( int argc, char* argv[] )
 {
   if( argc < 4 )
@@ -18,8 +27,6 @@ int main( int argc, char* argv[] )
   } // fi
 
   // Create interface
-  typedef cpPlugins::Interface::Interface TInterface;
-  typedef TInterface::TClasses            TClasses;
   TInterface plugins;
   if( !plugins.Load( argv[ 1 ] ) )
   {
@@ -29,20 +36,16 @@ int main( int argc, char* argv[] )
   } // fi
 
   // Create objects
-  typedef cpPlugins::Interface::ProcessObject TProcessObject;
-  typedef cpPlugins::Interface::Parameters    TParameters;
-  cpPlugins::Interface::ProcessObject::Pointer reader, writer;
-  reader = plugins.CreateProcessObject( "cpPlugins::ImageReader" );
-  if( reader.IsNull( ) )
+  TProcessObject::Pointer reader, writer;
+  reader = plugins.CreateProcessObject( "cpPlugins::IO::ImageReader" );
+  writer = plugins.CreateProcessObject( "cpPlugins::IO::ImageWriter" );
+  if( reader.IsNull( ) || writer.IsNull( ) )
   {
-    std::cerr << "No suitable reader found in plugins." << std::endl;
-    return( 1 );
-
-  } // fi
-  writer = plugins.CreateProcessObject( "cpPlugins::ImageWriter" );
-  if( writer.IsNull( ) )
-  {
-    std::cerr << "No suitable writer found in plugins." << std::endl;
+    std::cerr
+      << "No suitable reader found in plugins." << std::endl
+      << "Reader: " << reader.GetPointer( ) << std::endl
+      << "Writer: " << writer.GetPointer( ) << std::endl
+      << std::endl;
     return( 1 );
 
   } // fi
@@ -59,7 +62,7 @@ int main( int argc, char* argv[] )
   writer->SetParameters( writer_params );
 
   // Connect pipeline
-  writer->SetInput( 0, reader->GetOutput( 0 ) );
+  writer->SetInput( 0, reader->GetOutput< TDataObject >( 0 ) );
 
   // Execute pipeline
   std::string err = writer->Update( );
@@ -69,6 +72,7 @@ int main( int argc, char* argv[] )
     return( 1 );
 
   } // fi
+
   return( 0 );
 }