如何获取std::vector中vtkDoubleArray的值
How to get the the values of a vtkDoubleArray in a std::vector
我想将vtkDoubleArray
的元素复制到C++std::vector
中(如如何将vtkDoubleArray转换为Eigen::matrix(
我正在努力让它发挥作用:
typedef std::vector<double> row_type;
typedef std::vector<row_type> matrix_type;
int n_components = vtk_arr->GetNumberOfComponents();
int n_rows = vtk_arr->GetNumberOfTuples();
row_type curTuple(n_components);
matrix_type cpp_matrix(n_rows, row_type(n_components));
for (int i=0; i<n_rows; i++) {
vtk_arr->GetTuple(i, curTuple);
cpp_matrix[i] = curTuple;
}
目前我有这个错误:
error C2664: 'void vtkDataArrayTemplate<T>::GetTuple(vtkIdType,double
*)' : cannot convert parameter 2 from 'row_type' to 'double *'
是否有某种vtk
方法(希望更稳健、更高效(已经实现了这一点?
正如错误所说,您正在传递一个row_type
(std::vector<double>
(,它需要double*
。也许您想传递一个指向底层数据的指针:
vtk_arr->GetTuple(i, curTuple.data());
请参阅std::vector::data
了解更多信息。
相关文章:
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- 在c++中用vector填充一个简单的动态数组
- vector.resize()中的分配错误
- 使用std::vector的OpenCL矩阵乘法
- POCO::PostgreSQL:如何将std::vector支持添加到`Binder::bind`
- 在某些循环内使用vector.push_back时出现分段错误
- 当vector是tje全局变量时,c++中vector的内存管理
- std::vector的包装器,使数组的结构看起来像结构的数组
- 为什么(-1)%vector::size()总是返回0
- 在C++中将类(带有Vector成员)保存为二进制文件
- 编译器如何区分std::vector的构造函数
- 将 int 数组转换为 std::vector<int*>
- 使用 pqxx 将 std::vector 存储在 postgresql 中,并从数据库中检索它
- 在std::vector上存储带有模板的类实例
- 在main()之外初始化std::vector会导致性能下降(多线程)
- 为什么std::vector比数组慢
- std::vector::迭代器是否可以合法地作为指针
- 如何将二进制格式的 C++ 对象的 std::vector 保存到磁盘?
- 循环中的条件:为什么每次都调用strlen(),而vector.size()只调用一次
- 为什么std::vector和std::valarray初始化构造函数不同