gpt4 book ai didi

c++ - VTK 7 - 为什么对象被销毁?

转载 作者:行者123 更新时间:2023-11-30 05:30:19 25 4
gpt4 key购买 nike

我正在尝试使用 vtkImageImport 加载原始图像数据并显示 2D 纹理:

    char* data = (char*)imgData->data(); // size is 786432

vtkSmartPointer<vtkImageImport> importer = vtkSmartPointer<vtkImageImport>::New();
importer->SetWholeExtent(0, 511, 0, 511, 0, 0);
importer->SetDataExtentToWholeExtent();
importer->SetDataScalarTypeToUnsignedChar();
importer->SetImportVoidPointer(data);
importer->SetNumberOfScalarComponents(3);
importer->Update();
double bounds[6];
vtkImageData* vtk_image_data = importer->GetOutput(); // this is null
vtk_image_data->GetBounds(bounds);

当我调用 importer->Update() 时,vtkDataSet 的析构函数被调用,并且 importer->GetOutput() 返回 null...知道为什么会这样?

最佳答案

我使用 VTK 6.2.0 在 MSVC 2010 上编译并运行了您的代码。我没有得到任何空的 vtk_image_data。查看一些可能有帮助的宏预处理器。

关于c++ - VTK 7 - 为什么对象被销毁?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36004823/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com