vtkSmartPointer<vtkImageData>imageData;
... //load
int scalarType = imageData->GetScalarType();
std::cout << "scalarType=" << scalarType << "\n";
if (imageData->GetScalarType() != VTK_SHORT) {
vtkSmartPointer<vtkImageCast> imgCast =
vtkSmartPointer<vtkImageCast>::New();
imgCast->SetInputData((vtkDataObject*)imageData);
imgCast->SetOutputScalarTypeToShort();
imgCast->Update();
imageData = imgCast->GetOutput();
scalarType = imageData->GetScalarType();
std::cout << "new scalarType=" << scalarType << "\n";
}
VTK数据类型强制转换(VTK_FLOAT to VTK_SHORT)
最新推荐文章于 2021-12-31 15:51:24 发布