]> Creatis software - cpPlugins.git/blob - appli/examples/plugins/CreateCylinderAndSave.cxx
Cast image filter added. ROI filter modified.
[cpPlugins.git] / appli / examples / plugins / CreateCylinderAndSave.cxx
1
2 #include <cpPlugins/Interface/Plugins.h>
3
4 int main( int argc, char* argv[] )
5 {
6   // Useful types
7   typedef cpPlugins::Interface::Plugins _TPlugins;
8
9   // Load an interface to the plugins system
10   _TPlugins::Pointer plugins = _TPlugins::New( );
11
12   try
13   {
14     // Guess reachable plugins
15     plugins->GuessPlugins( );
16
17     // Create cylinder source
18     auto source = plugins->CreateFilter( "MeshSources", "CylinderSource" );
19     source->GetParameters( )->SetReal( "Height", 10 );
20     source->GetParameters( )->SetReal( "Radius", 2 );
21     source->GetParameters( )->SetUint( "Resolution", 80 );
22
23     // Create mesh writer
24     auto writer = plugins->CreateFilter( "IO", "MeshWriter" );
25     writer->SetInput( "Input", source->GetOutput( "Output" ) );
26     writer->GetParameters( )->SetSaveFileName( "FileName", "cylinder.vtk" );
27
28     // Update pipeline
29     writer->Update( );
30   }
31   catch( std::exception& err )
32   {
33     std::cerr << "Error: " << err.what( ) << std::endl;
34     return( 1 );
35
36   } // yrt
37
38   return( 0 );
39 }
40
41 // eof - $RCSfile$