I've found the Eigen::Map class for converting a raw array to an Eigen class (and some useful snippets here https://stackoverflow.com/a/12007784/1136458 )
Is there any Eigen or vtk class to convert a vtk array to an Eigen class (and back)? What I am trying right now is:
- convert vtkDoubleArray to std::vector of std::vector (as in How to get the the values of a vtkDoubleArray in a std::vector )
using map to have a matrixxd
Eigen::MatrixXd eig_arr; eig_arr = Eigen::Map<Eigen::MatrixXd> (cpp_matrix.data(), n_rows, n_components)
But I get the following error:
error C2665: 'Eigen::Map::Map' : none of the 4 overloads could convert all the argument types
I don't necessarily need the intermediate cpp_matrix, if there is a direct method that would be fine as well
curTuple
fromvtk_arr->GetTuple(i, curTuple)
component-wise tocpp_matrix
there. Why dont you write it directly component-wise into theEigen::Matrix
? – Tobias