]> Creatis software - cpPlugins.git/blob - appli/examples/example_SphereSource.cxx
...
[cpPlugins.git] / appli / examples / example_SphereSource.cxx
1 #include <cstdlib>
2 #include <iostream>
3 #include <string>
4
5 #include <cpPlugins/Interface/Interface.h>
6 #include <cpPlugins/Interface/ProcessObject.h>
7
8 // -------------------------------------------------------------------------
9 typedef cpPlugins::Interface::Interface     TInterface;
10 typedef cpPlugins::Interface::ProcessObject TFilter;
11
12 // -------------------------------------------------------------------------
13 int main( int argc, char* argv[] )
14 {
15   if( argc < 6 )
16   {
17     std::cerr
18       << "Usage: " << argv[ 0 ]
19       << " plugins_dir"
20       << " radius phi_res theta_res output_mesh" << std::endl;
21     return( 1 );
22
23   } // fi
24
25   // Create interface and load plugins
26   TInterface interface;
27   if( interface.LoadFromFolder( argv[ 1 ], true ) )
28   {
29     TFilter::Pointer source =
30       interface.CreateObject( "cpPlugins::BasicFilters::SphereMeshSource" );
31     TFilter::Pointer writer =
32       interface.CreateObject( "cpPlugins::IO::MeshWriter" );
33
34     // Configure source
35     source->GetParameters( )->SetString( "Radius", argv[ 2 ], true );
36     source->GetParameters( )->SetString( "PhiResolution", argv[ 3 ], true );
37     source->GetParameters( )->SetString( "ThetaResolution", argv[ 4 ], true );
38
39     // Configure writer
40     writer->GetParameters( )->SetString( "FileName", argv[ 5 ], true );
41
42     // Connect filters
43     writer->SetInput( "Input", source->GetOutput( "Output" ) );
44
45     // Execute pipeline
46     std::cout << "Error: \"" << writer->Update( ) << "\"" << std::endl;
47   }
48   else
49     std::cerr << "No plugins found." << std::endl;
50
51   return( 0 );
52 }
53
54 // eof - $RCSfile$