]> Creatis software - cpPlugins.git/blobdiff - appli/examples/ComplexAppend.cxx
Moved to version 1.0
[cpPlugins.git] / appli / examples / ComplexAppend.cxx
diff --git a/appli/examples/ComplexAppend.cxx b/appli/examples/ComplexAppend.cxx
new file mode 100644 (file)
index 0000000..bae9874
--- /dev/null
@@ -0,0 +1,88 @@
+// =========================================================================
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// =========================================================================
+
+#include <iostream>
+#include <cpPlugins/Filter.h>
+#include <cpPlugins/Pipeline.h>
+
+int main( int argc, char* argv[] )
+{
+  if( argc != 7 )
+  {
+    std::cerr << "Usage: " << argv[ 0 ] << " input output" << std::endl;
+    return( 1 );
+  } // end if
+
+  try
+  {
+    typedef cpPlugins::Pipeline TPipeline;
+
+    TPipeline::SharedPtr pipeline = TPipeline::New( );
+
+    cpPlugins::Filter* r1 =
+      pipeline->CreateNode( "cpPluginsBase::RawFileReader", "r1" )->
+      Cast< cpPlugins::Filter >( );
+
+    cpPlugins::Filter* r2 =
+      pipeline->CreateNode( "cpPluginsBase::RawFileReader", "r2" )->
+      Cast< cpPlugins::Filter >( );
+
+    cpPlugins::Filter* r3 =
+      pipeline->CreateNode( "cpPluginsBase::RawFileReader", "r3" )->
+      Cast< cpPlugins::Filter >( );
+
+    cpPlugins::Filter* r4 =
+      pipeline->CreateNode( "cpPluginsBase::RawFileReader", "r4" )->
+      Cast< cpPlugins::Filter >( );
+
+    cpPlugins::Filter* r5 =
+      pipeline->CreateNode( "cpPluginsBase::RawFileReader", "r5" )->
+      Cast< cpPlugins::Filter >( );
+
+    cpPlugins::Filter* a1 =
+      pipeline->CreateNode( "cpPluginsBase::AppendRawDataFilter", "a1" )->
+      Cast< cpPlugins::Filter >( );
+
+    cpPlugins::Filter* a2 =
+      pipeline->CreateNode( "cpPluginsBase::AppendRawDataFilter", "a2" )->
+      Cast< cpPlugins::Filter >( );
+
+    cpPlugins::Filter* a3 =
+      pipeline->CreateNode( "cpPluginsBase::AppendRawDataFilter", "a3" )->
+      Cast< cpPlugins::Filter >( );
+
+    cpPlugins::Filter* w =
+      pipeline->CreateNode( "cpPluginsBase::RawFileWriter", "w" )->
+      Cast< cpPlugins::Filter >( );
+
+    a1->SetInput( "Input", r1->GetOutput( "Output" ) );
+    a1->SetInput( "Input", r2->GetOutput( "Output" ) );
+
+    a2->SetInput( "Input", a1->GetOutput( "Output" ) );
+    a2->SetInput( "Input", r3->GetOutput( "Output" ) );
+    a2->SetInput( "Input", r4->GetOutput( "Output" ) );
+
+    a3->SetInput( "Input", a2->GetOutput( "Output" ) );
+    a3->SetInput( "Input", r5->GetOutput( "Output" ) );
+
+    w->SetInput( "Input", a3->GetOutput( "Output" ) );
+
+    r1->SetInValue( "FileName", std::string( argv[ 1 ] ) );
+    r2->SetInValue( "FileName", std::string( argv[ 2 ] ) );
+    r3->SetInValue( "FileName", std::string( argv[ 3 ] ) );
+    r4->SetInValue( "FileName", std::string( argv[ 4 ] ) );
+    r5->SetInValue( "FileName", std::string( argv[ 5 ] ) );
+    w->SetInValue( "FileName", std::string( argv[ 6 ] ) );
+
+    w->Update( );
+  }
+  catch( std::exception& err )
+  {
+    std::cerr << "ERROR CAUGHT: " << err.what( ) << std::endl;
+    return( 1 );
+  } // end try
+  return( 0 );
+}
+
+// eof - $RCSfile$