QApplication breaks vtkDICOMImageReader
Hi all,
reading a series of DICOM images is broken when instantiating a QApplication context before reading them.
Minimal reproducible example (tested on macOS and Windows with the sample data set from: http://www.vtk.org/Wiki/images/1/12/VTK_Examples_StandardFormats_Input_DicomTestImages.zip):
#include <QApplication>
#include <vtkNew.h>
#include <vtkImageData.h>
#include <vtkDICOMImageReader.h>
#include <iostream>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
vtkNew<vtkDICOMImageReader> reader;
reader->SetDirectoryName(argv[1]);
reader->Update();
// works if declared here, *after* reader->Update()
// QApplication app(argc, argv);
vtkNew<vtkImageData> imageData;
imageData->ShallowCopy(reader->GetOutput());
auto *p1 = imageData->GetPoint(1);
std::cout << "p1: " << p1[0] << "," << p1[1] << "," << p1[2] << std::endl;
auto *bounds = imageData->GetBounds();
std::cout << "bounds: " <<
bounds[0] << "," << bounds[1] << "," << bounds[2] << "," <<
bounds[3] << "," << bounds[4] << "," << bounds[5] << std::endl;
return EXIT_SUCCESS;
}
Expected output:
p1: 0.859375,0,0
bounds: 0,219.141,0,219.141,0,132.464
Actual output:
p1: 0,0,0
bounds: 0,0,0,0,0,0
Edited by Kai Wolf