简体   繁体   中英

How to convert a vtkDoubleArray to an Eigen::matrix

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM