]> Creatis software - cpPlugins.git/blob - appli/examples/ComplexAppend.cxx
Moved to version 1.0
[cpPlugins.git] / appli / examples / ComplexAppend.cxx
1 // =========================================================================
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // =========================================================================
4
5 #include <iostream>
6 #include <cpPlugins/Filter.h>
7 #include <cpPlugins/Pipeline.h>
8
9 int main( int argc, char* argv[] )
10 {
11   if( argc != 7 )
12   {
13     std::cerr << "Usage: " << argv[ 0 ] << " input output" << std::endl;
14     return( 1 );
15   } // end if
16
17   try
18   {
19     typedef cpPlugins::Pipeline TPipeline;
20
21     TPipeline::SharedPtr pipeline = TPipeline::New( );
22
23     cpPlugins::Filter* r1 =
24       pipeline->CreateNode( "cpPluginsBase::RawFileReader", "r1" )->
25       Cast< cpPlugins::Filter >( );
26
27     cpPlugins::Filter* r2 =
28       pipeline->CreateNode( "cpPluginsBase::RawFileReader", "r2" )->
29       Cast< cpPlugins::Filter >( );
30
31     cpPlugins::Filter* r3 =
32       pipeline->CreateNode( "cpPluginsBase::RawFileReader", "r3" )->
33       Cast< cpPlugins::Filter >( );
34
35     cpPlugins::Filter* r4 =
36       pipeline->CreateNode( "cpPluginsBase::RawFileReader", "r4" )->
37       Cast< cpPlugins::Filter >( );
38
39     cpPlugins::Filter* r5 =
40       pipeline->CreateNode( "cpPluginsBase::RawFileReader", "r5" )->
41       Cast< cpPlugins::Filter >( );
42
43     cpPlugins::Filter* a1 =
44       pipeline->CreateNode( "cpPluginsBase::AppendRawDataFilter", "a1" )->
45       Cast< cpPlugins::Filter >( );
46
47     cpPlugins::Filter* a2 =
48       pipeline->CreateNode( "cpPluginsBase::AppendRawDataFilter", "a2" )->
49       Cast< cpPlugins::Filter >( );
50
51     cpPlugins::Filter* a3 =
52       pipeline->CreateNode( "cpPluginsBase::AppendRawDataFilter", "a3" )->
53       Cast< cpPlugins::Filter >( );
54
55     cpPlugins::Filter* w =
56       pipeline->CreateNode( "cpPluginsBase::RawFileWriter", "w" )->
57       Cast< cpPlugins::Filter >( );
58
59     a1->SetInput( "Input", r1->GetOutput( "Output" ) );
60     a1->SetInput( "Input", r2->GetOutput( "Output" ) );
61
62     a2->SetInput( "Input", a1->GetOutput( "Output" ) );
63     a2->SetInput( "Input", r3->GetOutput( "Output" ) );
64     a2->SetInput( "Input", r4->GetOutput( "Output" ) );
65
66     a3->SetInput( "Input", a2->GetOutput( "Output" ) );
67     a3->SetInput( "Input", r5->GetOutput( "Output" ) );
68
69     w->SetInput( "Input", a3->GetOutput( "Output" ) );
70
71     r1->SetInValue( "FileName", std::string( argv[ 1 ] ) );
72     r2->SetInValue( "FileName", std::string( argv[ 2 ] ) );
73     r3->SetInValue( "FileName", std::string( argv[ 3 ] ) );
74     r4->SetInValue( "FileName", std::string( argv[ 4 ] ) );
75     r5->SetInValue( "FileName", std::string( argv[ 5 ] ) );
76     w->SetInValue( "FileName", std::string( argv[ 6 ] ) );
77
78     w->Update( );
79   }
80   catch( std::exception& err )
81   {
82     std::cerr << "ERROR CAUGHT: " << err.what( ) << std::endl;
83     return( 1 );
84   } // end try
85   return( 0 );
86 }
87
88 // eof - $RCSfile$