X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2Fexamples%2Fexample_View2DImage.cxx;h=be654b2217e23599f24766f5e7638361ba68739b;hb=7e29f3aec097ba1bff1894fed6eb1094276c5b72;hp=2778e8844a785901a6c1f374eb6b63a30d81468d;hpb=ad814fa27df55cd06a071e474e56efc27f9f8fa5;p=cpPlugins.git diff --git a/appli/examples/example_View2DImage.cxx b/appli/examples/example_View2DImage.cxx index 2778e88..be654b2 100644 --- a/appli/examples/example_View2DImage.cxx +++ b/appli/examples/example_View2DImage.cxx @@ -1,25 +1,20 @@ #include #include #include +#include #include #include #include -#include -#include +#include #include #include // ------------------------------------------------------------------------- -typedef cpPlugins::Interface::Interface TInterface; -typedef cpPlugins::Interface::ProcessObject TProcessObject; -typedef cpPlugins::Interface::DataObject TDataObject; -typedef cpPlugins::Interface::Image TImage; -typedef cpPlugins::Interface::Parameters TParameters; -typedef TInterface::TClasses TClasses; - +typedef cpPlugins::Interface::Plugins TPlugins; +typedef cpPlugins::Interface::Image TImage; typedef cpExtensions::Visualization::ImageSliceActors TSliceActors; // ------------------------------------------------------------------------- @@ -29,53 +24,39 @@ int main( int argc, char* argv[] ) { std::cerr << "Usage: " << argv[ 0 ] - << " plugins_file input_image [widget]" + << " plugins_file input_image" << std::endl; return( 1 ); } // fi - // Create interface - TInterface plugins; - if( !plugins.Load( argv[ 1 ] ) ) + // Load plugins + cpPlugins::Interface::Plugins plugins; + if( !plugins.LoadPluginsPath( argv[ 1 ] ) ) { std::cerr << "Failed to load plugins." << std::endl; return( 1 ); } // fi - // Create objects - TProcessObject::Pointer reader; - reader = plugins.CreateObject( "cpPlugins::IO::ImageReader" ); - if( reader.IsNull( ) ) - { - std::cerr - << "No suitable reader found in plugins." << std::endl - << "Reader: " << reader.GetPointer( ) << std::endl - << std::endl; - return( 1 ); - - } // fi - - // Configure reader - TParameters* reader_params = reader->GetParameters( ); - if( argc > 4 ) + // Associate filenames + std::vector< std::string > fnames; + for( int i = 2; i < argc; ++i ) + fnames.push_back( argv[ i ] ); + + // Read image + std::string name = ""; + try { - for( int i = 2; i < argc; ++i ) - reader_params->AddToStringList( "FileNames", argv[ i ] ); + name = plugins.ReadImage( fnames, "" ); } - else - reader_params->AddToStringList( "FileNames", argv[ 2 ] ); - - // Execute pipeline - std::string err = reader->Update( ); - if( err != "" ) + catch( std::exception& err ) { - std::cerr << "ERROR: " << err << std::endl; + std::cerr << err.what( ) << std::endl; return( 1 ); - } // fi - TImage* image = reader->GetOutput< TImage >( "Output" ); + } // yrt + TImage* image = plugins.GetData< TImage >( name ); // Configure visualization objects vtkSmartPointer< vtkRenderer > renderer = @@ -95,7 +76,7 @@ int main( int argc, char* argv[] ) // Create slice actors vtkSmartPointer< TSliceActors > image_actors = vtkSmartPointer< TSliceActors >::New( ); - image_actors->AddInputData( image->GetVTK< vtkImageData >( ) ); + image_actors->SetInputImage( image->GetVTK< vtkImageData >( ) ); image_actors->SetAxis( 2 ); image_actors->PushActorsInto( window ); @@ -114,7 +95,7 @@ int main( int argc, char* argv[] ) } // fi // Begin interaction - image_actors->ResetCamera( ); + renderer->ResetCamera( ); window->Render( ); interactor->Start( );