开发环境:
- Windows 11 家庭中文版
- Microsoft Visual Studio Community 2019
- VTK-9.3.0.rc0
- vtk-example
demo解决问题:示范冲polydata中获取命名数组,并转换数组数据类型
关键点:
- 从 polydata 中获取数组,我们必须使用 SafeDownCast 转换为我们想要的类型。
// Get the distances from the polydata.
vtkDoubleArray* array = dynamic_cast<vtkDoubleArray*>(
polydata->GetPointData()->GetArray("Distances"));
- vtkDoubleArray->vtkIntArray
// Cast the double distances to ints.
vtkDoubleArray* doubleDistances = dynamic_cast<vtkDoubleArray*>(
polydata->GetPointData()->GetArray("Distances"));
vtkIntArray* intDistances = dynamic_cast<vtkIntArray*>
prj name: