0
votes

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:

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

2
You write curTuple from vtk_arr->GetTuple(i, curTuple) component-wise to cpp_matrix there. Why dont you write it directly component-wise into the Eigen::Matrix?Tobias
I just started this way because I hoped that there existed some method in vtk like GetRawArray, so that I could do: eig_arr = map(vtk_arr->getRawData). But yes, since I have already implemented how to scan the vtkarray I can just adapt that code.lib

2 Answers

1
votes

The memory layout of a std::vector<std::vector<double> > is not compatible with what Eigen::Map is expecting. All entries must be sequentially stored in memory with an optional constant space between each column. So if the memory layout of vtkDoubleArray is not comptable, then you have no other choice but copy the values using a manual for loop.

0
votes

What about converting vtkMappedDataArray to Eigen::matrix?

I stumpled upon "vtkMappedDataArray" and this discussion about "InSituDataStructures" for VTK. Unfortunatly I don't know any details but maybe it helps. Please let us know.