]> Creatis software - cpPlugins.git/blob - appli/examples/example_ReadQuadEdgeMesh.cxx
Garbage collector added
[cpPlugins.git] / appli / examples / example_ReadQuadEdgeMesh.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 int main( int argc, char* argv[] )
9 {
10   if( argc < 5 )
11   {
12     std::cerr
13       << "Usage: " << argv[ 0 ]
14       << " plugins_file"
15       << " input_mesh"
16       << " dimensions pixel_type" << std::endl;
17     return( 1 );
18
19   } // fi
20   std::string plugins_file = argv[ 1 ];
21   std::string input_mesh_file = argv[ 2 ];
22   std::string dimensions = argv[ 3 ];
23   std::string pixel_type = argv[ 4 ];
24
25   // Create interface
26   typedef cpPlugins::Interface::Interface TInterface;
27   typedef TInterface::TClasses            TClasses;
28
29   TInterface plugins;
30   plugins.Load( plugins_file );
31
32   // Create objects
33   typedef cpPlugins::Interface::ProcessObject TProcessObject;
34   typedef TProcessObject::TParameters         TParameters;
35   cpPlugins::Interface::ProcessObject::Pointer reader;
36
37   reader = plugins.CreateProcessObject( "cpPlugins::Plugins::MeshReader" );
38   if( reader.IsNull( ) )
39   {
40     std::cerr << "No suitable reader found in plugins." << std::endl;
41     return( 1 );
42
43   } // fi
44
45   // Configure reader
46   TParameters reader_params = reader->GetDefaultParameters( );
47   reader_params[ "FileName" ].second = input_mesh_file;
48   reader_params[ "PixelType" ].second = pixel_type;
49   reader_params[ "MeshDimension" ].second = dimensions;
50   reader->SetParameters( reader_params );
51
52   // Execute reader
53   std::string msg = reader->Update( );
54
55   if( msg != "" )
56     std::cerr << "ERROR: " << msg << std::endl;
57
58   return( 0 );
59 }
60
61 // eof - $RCSfile$