[vtkusers] QVTKOpenGLWidget::setInputData() slow when executed after vtkDICOMImageReader::Update()

ochampao ochampao at hotmail.com
Fri Feb 9 08:43:50 EST 2018


Hello vtkusers!

I am experimenting with a simple dicom viewer similar to the FourPaneViewer
example (see [1] for link). But I am observing a behaviour which I can't
explain. In particular, when I place the QVTKOpenGLWidget::setInputData()
calls before calling the vtkDICOMImageReader::Update(), the dataset is
loaded extremely fast (approximately 2 seconds). However when
QVTKOpenGLWidget::setInputData() calls are placed after
vtkDICOMImageReader::Update(), then loading the dataset requires
significantly more time to load (approximately 22 seconds). See code minimal
code example below.

Why is the code slower when executed after the Update() call and how can
this be avoided?

For the slower case, when stepping through the code with the debugger, I can
see that the call to Update() is still fast but the debugger spends most of
its time at setInputData().

Eventually, what I'd like to do is group the code that reads the dicom into
a separate function that returns a vtkImageData reference to the pipeline.
But from this experiment it seems to work very slow.

Thanks,
Panos.

=======

Here is a minimal example of my code to demonstrate the two situation
(commented is the slow case):

void addImage(const char* filename)
{
    vtkSmartPointer< vtkDICOMImageReader > reader =
        vtkSmartPointer< vtkDICOMImageReader >::New();
    reader->SetDirectoryName(filename);

    vtkSmartPointer<vtkImageData> data = 
        vtkSmartPointer<vtkImageData>::New();

    data = reader->GetOutput();
    
    //---------------------------------------
    // SetInputData() works very fast if here
    qVtkOpenGLWidget1->SetInputData(data);
    qVtkOpenGLWidget2->SetInputData(data);
    qVtkOpenGLWidget3->SetInputData(data);
    // ---------------------------------------

    reader->Update();
    
    //---------------------------------------
    // SetInputData() works very slow if here
    //
    //qVtkOpenGLWidget1->SetInputData(data);
    //qVtkOpenGLWidget2->SetInputData(data);
    //qVtkOpenGLWidget3->SetInputData(data);
    //---------------------------------------

    /* 
        code to setup widgets (orientation, slice#, window/level color)
    */

    qVtkOpenGLWidget1->Render();
    qVtkOpenGLWidget2->Render();
    qVtkOpenGLWidget3->Render();
}

========
References:

[1]:
https://github.com/Kitware/VTK/tree/master/Examples/GUI/Qt/FourPaneViewer



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list