X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2Fexamples%2Fplugins%2Fexample_ReadWriteImage.cxx;h=7da797cf4336428b1b9dc22976915d33ea02e346;hb=b9fd406b0196ce00c4152da45572b8be3cb3c805;hp=3eb89d82fb0d6531448b57aa3675ed779f6212f8;hpb=b67cad9ff3c38b4e99ac48a4852e9e94cb879c6a;p=cpPlugins.git diff --git a/appli/examples/plugins/example_ReadWriteImage.cxx b/appli/examples/plugins/example_ReadWriteImage.cxx index 3eb89d8..7da797c 100644 --- a/appli/examples/plugins/example_ReadWriteImage.cxx +++ b/appli/examples/plugins/example_ReadWriteImage.cxx @@ -3,11 +3,11 @@ int main( int argc, char* argv[] ) { - if( argc < 4 ) + if( argc < 3 ) { std::cerr << "Usage: " << argv[ 0 ] - << " plugins_library input_image(s) output_image" << std::endl; + << " input_image(s) output_image" << std::endl; return( 1 ); } // fi @@ -15,19 +15,7 @@ int main( int argc, char* argv[] ) // Load interface int ret = 0; cpPlugins::Interface interface; - try - { - interface.LoadPluginFile( argv[ 1 ] ); - } - catch( std::exception& err ) - { - std::cerr - << "Interface load failed on \"" << argv[ 1 ] << "\": " - << err.what( ) - << std::endl; - ret = 1; - - } // fi + interface.GuessAccesiblePlugins( ); // Create filters cpPlugins::ProcessObject::Pointer reader; @@ -38,8 +26,7 @@ int main( int argc, char* argv[] ) if( reader.IsNull( ) ) { std::cerr - << "\"IO::ImageReader\" creation failed from \"" - << argv[ 1 ] << "\"" + << "\"IO::ImageReader\" creation failed." << std::endl; ret = 1; @@ -48,8 +35,7 @@ int main( int argc, char* argv[] ) if( writer.IsNull( ) ) { std::cerr - << "\"IO::ImageWriter\" creation failed from \"" - << argv[ 1 ] << "\"" + << "\"IO::ImageWriter\" creation failed." << std::endl; ret = 1; @@ -58,7 +44,7 @@ int main( int argc, char* argv[] ) catch( std::exception& err ) { std::cerr - << "Filter creation failed on \"" << argv[ 1 ] << "\": " + << "Filter creation failed: " << err.what( ) << std::endl; ret = 1; @@ -69,17 +55,20 @@ int main( int argc, char* argv[] ) { // Configure filters auto reader_params = reader->GetParameters( ); - for( int i = 2; i < argc - 1; ++i ) + for( int i = 1; i < argc - 1; ++i ) reader_params->AddToOpenFileNameList( "FileNames", argv[ i ] ); auto writer_params = writer->GetParameters( ); writer_params->SetSaveFileName( "FileName", argv[ argc - 1 ] ); // Connect filters - writer->SetInput( "Input", reader->GetOutput( "Output" ) ); + writer->SetInputPort( "Input", reader->GetOutputPort( "Output" ) ); // Execute filters - std::string err = writer->Update( ); - if( err != "" ) + try + { + writer->Update( ); + } + catch( itk::ExceptionObject& err ) { std::cout << "Error caught: " << err << std::endl; ret = 1;