求大神帮忙把这段c++代码转换成python语言,十分感谢 20
vtkSmartPointer<vtkStructuredPointsReader>rs=vtkSmartPointer<vtkStructuredPointsReade...
vtkSmartPointer<vtkStructuredPointsReader> rs = vtkSmartPointer<vtkStructuredPointsReader>::New();
rs->SetFileName("D://Saint Helen//shm_10m.vtk");
rs->Update();
int dim[3];//if dim[2], there would be memory leakage!
rs->GetOutput()->GetDimensions(dim);
long count = 0;
vtk_create(vtkPoints, points);
for (int y = 0; y < dim[1]; y++)
{
for (int x = 0; x < dim[0]; x++)
{
float* scalar = static_cast<float*>(rs->GetOutput()->GetScalarPointer(x, y, 0));
//scalar[0] = 1;
double pos[3];
vtkIdType i = y*dim[0] + x;
rs->GetOutput()->GetPoint(i, pos);
//points->InsertNextPoint(x, y, (*scalar)/16.0);
//points->InsertNextPoint(pos[0], pos[1], pos[2]);
points->InsertNextPoint(pos[0], pos[1], *scalar);
}
}
vtk_create(vtkPolyData, pd);
pd->SetPoints(points); 展开
rs->SetFileName("D://Saint Helen//shm_10m.vtk");
rs->Update();
int dim[3];//if dim[2], there would be memory leakage!
rs->GetOutput()->GetDimensions(dim);
long count = 0;
vtk_create(vtkPoints, points);
for (int y = 0; y < dim[1]; y++)
{
for (int x = 0; x < dim[0]; x++)
{
float* scalar = static_cast<float*>(rs->GetOutput()->GetScalarPointer(x, y, 0));
//scalar[0] = 1;
double pos[3];
vtkIdType i = y*dim[0] + x;
rs->GetOutput()->GetPoint(i, pos);
//points->InsertNextPoint(x, y, (*scalar)/16.0);
//points->InsertNextPoint(pos[0], pos[1], pos[2]);
points->InsertNextPoint(pos[0], pos[1], *scalar);
}
}
vtk_create(vtkPolyData, pd);
pd->SetPoints(points); 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏20(财富值+成长值)
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询