#include #include #include #include #include #include #include #include #include #include #include #include #include #include // ------------------------------------------------------------------------- // type definiftions 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 cpExtensions::Visualization::ImageSliceActors TSliceActors; typedef cpExtensions::Interaction::SphereWidget TSphereWidget; // ------------------------------------------------------------------------- std::string _pathIOplugin = "C://dev//creatis//cpPlugins//build//Debug//cpPluginsIO.dll"; std::string _img = "C://img//SphereVolume.mhd"; int main(int argc, char* argv[]) { if (argc >= 3) { _pathIOplugin = argv[1]; _img = argv[2]; } // Create interface TInterface plugins; if (!plugins.Load(_pathIOplugin)) { std::cerr << "Failed to load plugins." << std::endl; return(1); } // Create reader TProcessObject::Pointer reader; reader = plugins.CreateProcessObject("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); } // Configure reader TParameters* reader_params = reader->GetParameters(); reader_params->AddToStringList("FileNames", _img); // Execute pipeline std::string err = reader->Update(); if (err != "") { std::cerr << "ERROR: " << err << std::endl; return(1); } TImage* image = reader->GetOutput< TImage >("Output"); // Configure visualization objects vtkSmartPointer< vtkRenderer > renderer = vtkSmartPointer< vtkRenderer >::New(); renderer->SetBackground(0.1, 0.1, 0.1); vtkSmartPointer< vtkRenderWindow > window = vtkSmartPointer< vtkRenderWindow >::New(); window->AddRenderer(renderer); window->SetSize(600, 600); // Set up the interaction vtkSmartPointer< vtkRenderWindowInteractor > interactor = vtkSmartPointer< vtkRenderWindowInteractor >::New(); window->SetInteractor(interactor); // Create slice actors vtkSmartPointer< TSliceActors > image_actors = vtkSmartPointer< TSliceActors >::New(); image_actors->AddInputData(image->GetVTK< vtkImageData >()); image_actors->SetAxis(2); image_actors->PushActorsInto(window); vtkSmartPointer< vtkImageActorPointPlacer > placer = vtkSmartPointer< vtkImageActorPointPlacer >::New(); placer->SetImageActor(image_actors->GetImageActor()); // Create a sphere widget vtkSmartPointer sphereWidget = vtkSmartPointer::New(); sphereWidget->SetInteractor(interactor); // sphereWidget->CreateDefaultRepresentation(); /* vtkSphereRepresentation* sphereRepresentation = vtkSphereRepresentation::SafeDownCast(sphereWidget->GetRepresentation()); sphereRepresentation->HandleVisibilityOn();*/ // Begin interaction renderer->ResetCamera(); window->Render(); sphereWidget->On(); interactor->Start(); return(0); }