enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.3k stars 284 forks source link

Support VTK_LONG_LONG #1135

Closed yellowshippo closed 2 years ago

yellowshippo commented 2 years ago

This PR adds supports for VTK_LONG_LONG ~and VTK_UNSIGNED_LONG_LONG~ to tvtk/array_handler.py.

It is necessary because some files can contain arrays of these types. In particular, VTU files exported using ParaView can have Int64 ~and UInt64~, as attached below. mesh.vtu.zip

I also added some lines in tvtk/tests/test_array_handler.py and confirmed the VTU file attached was successfully loaded using the modified code.

Edit: I removed the description related to VTK_UNSIGNED_LONG_LONG, which is not necessary (at least) for my usage.

prabhuramachandran commented 2 years ago

@yellowshippo -- thank you for the PR! Will run the tests to see if this passes.

yellowshippo commented 2 years ago

Thank you for your quick response. It seems the test failed for Windows. Since I have no Windows environment, I couldn't investigate the problem deeply. Any ideas to fix it?

prabhuramachandran commented 2 years ago

@yellowshippo -- yes so this seems like a windows specific issue. I too do not have a Windows environment handy right now. One way to do this is to try a more defensive approach as done early in the same module, where we try to detect the type by instantiating a vtkUnsignedLongLongArray and checking its type and mapping to that. You can try making a change and pushing here to see if that works. @rahulporuri -- do you have access to a windows machine?

yellowshippo commented 2 years ago

One way to do this is to try a more defensive approach as done early in the same module, where we try to detect the type by instantiating a vtkUnsignedLongLongArray and checking its type and mapping to that.

OK, I can give it a try, but where can I find the relevant code? I could not find anything related to vtkUnsignedLongLongArray in tvtk/array_handler.py and tvtk/tests/test_array_handler.py.

prabhuramachandran commented 2 years ago

Sorry I mean, if you look at line 35, you will see this: VTK_ID_TYPE_SIZE = vtk.vtkIdTypeArray().GetDataTypeSize(), perhaps something similar, there is also a GetDataTypeAsString() method that may be useful?

yellowshippo commented 2 years ago

@prabhuramachandran Thank you for the clarification. After some consideration, I found that I only need VTK_LONG_LONG and I have no use case for VTK_UNSIGNED_LONG_LONG, thus I simply removed lines related to VTK_UNSIGNED_LONG_LONG. Now it works.

prabhuramachandran commented 2 years ago

Merged, thank you!