]> Creatis software - cpPlugins.git/blobdiff - appli/examples/plugins/CreateCylinderAndSave.cxx
...
[cpPlugins.git] / appli / examples / plugins / CreateCylinderAndSave.cxx
diff --git a/appli/examples/plugins/CreateCylinderAndSave.cxx b/appli/examples/plugins/CreateCylinderAndSave.cxx
new file mode 100644 (file)
index 0000000..659b3af
--- /dev/null
@@ -0,0 +1,41 @@
+
+#include <cpPlugins/Interface/Plugins.h>
+
+int main( int argc, char* argv[] )
+{
+  // Useful types
+  typedef cpPlugins::Interface::Plugins _TPlugins;
+
+  // Load an interface to the plugins system
+  _TPlugins::Pointer plugins = _TPlugins::New( );
+
+  try
+  {
+    // Guess reachable plugins
+    plugins->GuessPlugins( );
+
+    // Create cylinder source
+    auto source = plugins->CreateFilter( "MeshSources", "CylinderSource" );
+    source->GetParameters( )->SetReal( "Height", 10 );
+    source->GetParameters( )->SetReal( "Radius", 2 );
+    source->GetParameters( )->SetUint( "Resolution", 80 );
+
+    // Create mesh writer
+    auto writer = plugins->CreateFilter( "IO", "MeshWriter" );
+    writer->SetInput( "Input", source->GetOutput( "Output" ) );
+    writer->GetParameters( )->SetSaveFileName( "FileName", "cylinder.vtk" );
+
+    // Update pipeline
+    writer->Update( );
+  }
+  catch( std::exception& err )
+  {
+    std::cerr << "Error: " << err.what( ) << std::endl;
+    return( 1 );
+
+  } // yrt
+
+  return( 0 );
+}
+
+// eof - $RCSfile$