作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我注意到我正在调用的函数的返回类型是 vtkFloatArray
。我想检查此数组的组件,但不确定如何遍历其组件。
因为当我尝试遍历元素时,出现了以下错误:
TypeError: 'vtkobject' object is not iterable
为什么会出现这样的错误?
谢谢。
最佳答案
如果您的数组不是元组:
float value;
for(int i = 0; i < array->GetNumberOfTuples(); i++)
{
value = array->GetValue(i);
std::cout << value << std::endl;
}
如果你的数组是一个大小为 3 的元组:
double * values;
for(int i = 0; i < array->GetNumberOfTuples(); i++)
{
values = array->GetTuple3(i);
std::cout << values[0] << " " << values[1] << " " << values[2] << std::endl;
}
关于c++ - 遍历 vtkFloatArray,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31638648/
我注意到我正在调用的函数的返回类型是 vtkFloatArray。我想检查此数组的组件,但不确定如何遍历其组件。 因为当我尝试遍历元素时,出现了以下错误: TypeError: 'vtkobject'
问题 以下代码片段配置了一个 python/VTKFloatArray,以便将来填充单位立方体的顶点坐标。设置 3 个分量 (x,y,z) 的 8 个元组。看来二传手不通勤。这是预期的行为吗?似乎必须
我是一名优秀的程序员,十分优秀!