Writing certain data crashes ParaView
efaulhaber opened this issue · comments
using WriteVTK
file = joinpath("out", "test")
points = zeros(2, 5)
cells = [MeshCell(VTKCellTypes.VTK_VERTEX, (i,)) for i in axes(points, 2)]
vtk_grid(file, points, cells) do vtk
vtk["123456"] = "12345"
end
When exporting exactly 5 points and writing an attribute with a 6 letter name and a 5 letter string value, the resulting file crashes ParaView.
Is this maybe a padding issue that results in an invalid VTU file?
No, it's not a padding issue. It's because your data ("12345"
) has length 5, which is also your number of points (and also cells in your case), so WriteVTK assumes that this dataset is attached to points. Thanks for reporting this since it's clearly a bug, as we shouldn't do this when the input data is a string. It will be fixed soon.
As explained in the docs, by default WriteVTK tries to guess the kind of data (point, cell or field data) from its dimensions. But one can explicitly tell WriteVTK about the kind of data.
So, as an immediate workaround, in your case you can do:
vtk["123456", VTKFieldData()] = "12345"
Here I'm assuming you interpret this attribute as field data (not attached to individual points or cells).
Amazing. Thanks for the quick reply and workaround!