5 #include <cpPlugins/Interface/Interface.h>
6 #include <cpPlugins/Interface/ProcessObject.h>
8 int main( int argc, char* argv[] )
13 << "Usage: " << argv[ 0 ]
15 << " input_image value output_mesh" << std::endl;
21 typedef cpPlugins::Interface::Interface TInterface;
22 typedef TInterface::TClasses TClasses;
24 if( !plugins.Load( argv[ 1 ] ) )
26 std::cerr << "Failed to load plugins." << std::endl;
32 typedef cpPlugins::Interface::ProcessObject TProcessObject;
33 typedef cpPlugins::Interface::DataObject TDataObject;
34 typedef cpPlugins::Interface::Parameters TParameters;
35 cpPlugins::Interface::ProcessObject::Pointer reader, writer, mc;
36 reader = plugins.CreateProcessObject( "cpPlugins::ImageReader" );
37 writer = plugins.CreateProcessObject( "cpPlugins::MeshWriter" );
38 mc = plugins.CreateProcessObject( "cpPlugins::MarchingCubes" );
39 if( reader.IsNull( ) || writer.IsNull( ) || mc.IsNull( ) )
41 std::cerr << "No suitable objects found in plugins." << std::endl;
47 TParameters reader_params = reader->GetDefaultParameters( );
48 for( int i = 2; i < argc - 2; ++i )
49 reader_params.AddValueToStringList( "FileNames", argv[ i ] );
50 reader->SetParameters( reader_params );
52 // Configure marching cubes
53 TParameters mc_params = mc->GetDefaultParameters( );
54 mc_params.AddValueToRealList( "Thresholds", std::atof( argv[ argc - 2 ] ) );
55 mc->SetParameters( mc_params );
58 TParameters writer_params = writer->GetDefaultParameters( );
59 writer_params.SetValueAsString( "FileName", argv[ argc - 1 ] );
60 writer->SetParameters( writer_params );
63 mc->SetInput( 0, reader->GetOutput< TDataObject >( 0 ) );
64 writer->SetInput( 0, mc->GetOutput< TDataObject >( 0 ) );
67 std::string err = writer->Update( );
70 std::cerr << "ERROR: " << err << std::endl;