Open StopkaKris opened 3 years ago
The bug report form says:
To Reproduce A minimal code example that reproduces the problem would be a big help if you can provide it. Attach a small mesh file if necessary.
The attached .vtk file (uploaded as a .txt file because .vtk files cannot be uploaded) should reproduce the error in either version of meshio mentioned above.
This may be unimportant, but the .vtk files described that cause the error were created by importing an unstructured mesh into ParaView and using the filters described at this link to create a voxelated mesh. The attached screenshot shows the filter free used to generate the 4x4x4 voxel mesh .vtk file uploaded here.
Thanks for reporting, I am also seeing this issue over here.
The additional line of code provided allowed me to read the vtk mesh in using meshio.
I saved a file in ParaView version 5.10 as a "Legacy VTK File "(*.vtk) and attempted to read this mesh using meshio. In ParaView, it is a voxelated data set. The first 12 lines of the .vtk file are shown below. Meshio (versions 4.3.6 and version 5.0.2) gives an error that the
offsets
variable in thevtk_cells_from_data()
function in the _vtk_common.py file has type None (TypeError: object of type 'NoneType' has no len()
) and fails at this line of code -->if len(offsets) != len(types):
.To get around this, I added this line of code right before the line above
offsets = np.arange(1,len(connectivity)+1,9)
I am unsure where offsets is supposed to be read/determined by the script otherwise. I suspect the current code expects some type of variable declaration or section of the .vtk file that specifies this. Maybe this is because meshio does not realize that theSTRUCTURED_POINTS
data set implicitly contains the necessary information provided in theoffsets
variable.I realize that this 'fix' may not work for other types of
DATASET
or older version of .vtk.UPDATE: Although I can read in a .vtk file with the change above, if I write the same mesh to a new file and then attempt to read that .vtk file, I get an error at the same line because the meshio-generated .vtk file does, in fact, contain a list of OFFSETS.