38 #include <visp3/ustk_gui/usVTKConverter.h>
40 #ifdef USTK_HAVE_VTK_QT
42 #include <vtkDataArray.h>
43 #include <vtkImageImport.h>
44 #include <vtkPointData.h>
50 vtkSmartPointer<vtkImageData> &vtkPostScanImage, vtkSmartPointer<vtkImageImport> importer)
52 if (importer == NULL) {
53 importer = vtkSmartPointer<vtkImageImport>::New();
54 importer->SetDataScalarTypeToUnsignedChar();
55 importer->SetWholeExtent(0, postScanImage.
getWidth() - 1, 0, postScanImage.
getHeight() - 1, 0,
57 importer->SetDataExtentToWholeExtent();
58 importer->SetNumberOfScalarComponents(1);
59 importer->SetImportVoidPointer((
void *)postScanImage.
getConstData(), 1);
61 importer->SetImportVoidPointer((
void *)postScanImage.
getConstData());
65 vtkPostScanImage = importer->GetOutput();
74 vtkSmartPointer<vtkImageData> &vtkPreScanImage, vtkSmartPointer<vtkImageImport> importer)
76 if (importer == NULL) {
77 importer = vtkSmartPointer<vtkImageImport>::New();
78 importer->SetDataScalarTypeToUnsignedChar();
79 importer->SetImportVoidPointer((
void *)preScanImage.
getConstData());
80 importer->SetWholeExtent(0, preScanImage.
getWidth() - 1, 0, preScanImage.
getHeight() - 1, 0,
82 importer->SetDataExtentToWholeExtent();
83 importer->SetNumberOfScalarComponents(1);
85 importer->SetImportVoidPointer((
void *)preScanImage.
getConstData());
89 vtkPreScanImage = importer->GetOutput();
100 vtkPostScanImage->GetDimensions(imageDims);
102 vtkPostScanImage->GetSpacing(spacing);
104 postScanImage.resize(imageDims[1], imageDims[0]);
106 for (
int i = 0; i < imageDims[0]; i++) {
107 for (
int j = 0; j < imageDims[1]; j++) {
108 postScanImage[j][i] =
109 (
unsigned char)(vtkPostScanImage->GetScalarComponentAsDouble(i, imageDims[1] - j - 1, 0, 0));
122 for (
int i = 0; i < 4; i++)
123 for (
int j = 0; j < 4; j++)
124 vtkMatrix->SetElement(i, j, vispMatrix[i][j]);
132 for (
int i = 0; i < 4; i++)
133 for (
int j = 0; j < 4; j++)
134 vispMatrix[i][j] = vtkMatrix->GetElement(i, j);
unsigned int getNumberOfFrames() const
Type * getConstData() const
unsigned int getHeight() const
unsigned int getWidth() const
void setHeightResolution(double heightResolution)
void setWidthResolution(double widthResolution)
double getElementSpacingX() const
double getElementSpacingY() const
double getElementSpacingZ() const
static void convert(const usImagePostScan3D< unsigned char > &postScanImage, vtkSmartPointer< vtkImageData > &vtkPostScanImage, vtkSmartPointer< vtkImageImport > importer=NULL)