Question

I am new to ITK/VTK and in learning process, in VTK how do we call multiple Visualization output windows at a time (splitter screen with different functionality for different output window). i tried implementing the above using multiple threads but i am not able to achieve the above desired..

// output window function 1
std::string inputFilename="E:\\DICOM_work\\CE53E85F";
vtkSmartPointer<vtkDICOMImageReader> reader =vtkSmartPointer<vtkDICOMImageReader>::New();
reader->SetFileName(inputFilename.c_str());
reader->Update();

// Visualize
vtkSmartPointer<vtkImageViewer2> imageViewer = vtkSmartPointer<vtkImageViewer2>::New();
imageViewer->SetInputConnection(reader->GetOutputPort());
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =  vtkSmartPointer<vtkRenderWindowInteractor>::New();
imageViewer->SetupInteractor(renderWindowInteractor);
imageViewer->Render();
imageViewer->GetRenderer()->ResetCamera();
imageViewer->Render();
renderWindowInteractor->Start();
} 
  // output window function 2 
void display1(void *)
{
std::string inputFilename="E:\\DICOM_work\\CE53E85Fg2";
vtkSmartPointer<vtkDICOMImageReader> reader1 = vtkSmartPointer<vtkDICOMImageReader>::New();
 reader1->SetFileName(inputFilename.c_str());
 reader1->Update();

// Visualize
vtkSmartPointer<vtkImageViewer2> imageViewer2 = vtkSmartPointer<vtkImageViewer2>::New();
imageViewer2->SetInputConnection(reader1->GetOutputPort());
 vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor1 = vtkSmartPointer<vtkRenderWindowInteractor>::New();
imageViewer2->SetupInteractor(renderWindowInteractor1);
imageViewer2->Render();
imageViewer2->GetRenderer()->ResetCamera();
imageViewer2->Render();
renderWindowInteractor1->Start();
 }

when ever i try to execute it.. the code executes till...
renderWindowInteractor->Start();

then the code exits with out executing the other function. Kindly help!

Was it helpful?

Solution

In the VTK official wiki, there is an example of an application that opens multiple vtkRenderWindows. Did you have a look at it? Basically, that program creates a vector of vtkRenderWindowInteractor:

std::vector<vtkSmartPointer<vtkRenderWindowInteractor> > interactors;

and, at the end, it calls the Start() method on the last element of it:

interactors[3]->Start();

('3' because it opens 4 windows). Maybe you can adapt that logic to the application of yours...

Just as a final note, consider that - if you like - you can also have a single vtkRenderWindow with multiple viewports.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top