-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export leads to corrupted file #136
Comments
I was able to run your script and generate the output file. I had no problem opening and visualising the file in ParaView 5.12. I also checked that the file I generated is identical to the one contained in your zip file. I'm not sure what could be the problem. Maybe your operating system? A few things you could try (see here for details):
|
This certainly is interesting. In terms of operating systems I tried this on a 64bit Linux also using ParaView 5.12. However, the exact same file seems to work on MacOS 14.4 (Apple M1) with ParaView 5.11. Is there something strange going on with the binary XML (endianness, word size)? |
Strange, I'm also on 64 bit Linux. If it's an endianness problem, I would expect to see the issue in big endian machines, since the binary data was written in little endian order (WriteVTK decides this based on the value of |
Well, I switched to base64 as you suggested and everything seems to work fine. As an aside, I find the naming of the options to I was wondering about the format, since I didn't find anything official regarding raw binary data in XML files. I wasn't aware that this is an unofficial extension from KitWare. Naturally, any normal XML reader will flag the file as invalid... I would suspect that the problem lies in the data in the header, since zlib is quite well tested in general. Maybe the number of blocks / lengths is read differently based on some specific of the underlying system. Since this should likely not be the case, this looks like an error in ParaView / the file type specification, and not an error specific to your package... |
I agree that the naming could be better. In the VTK specification, "append" refers to writing data to an "AppendedData" section at the end of the XML file. In this section, data can be written either as base64 or raw binary, and in both cases it can be optionally compressed. In WriteVTK, "append" implies that data will be written as raw binary, since appending base64 data is simply not implemented. I understand how this can be unclear. And yes, as mentioned e.g. in these VTK docs, writing raw binary data to an XML file goes against the XML specification. However, in practice ParaView has generally no issues when reading such files. And when working with large datasets, it's the fastest and most compact possible format (if one wants to stay within the possiblities of VTK XML files). |
I'm using ParaView in version 5.12.0 on Linux and also have issues with appended data. It seems that
does not always hold. with |
@MarDiehl thanks for reporting this. Would you be able to provide a minimal working example to test the issue? |
I am using Damask.jl (https://github.com/eisenforschung/Damask.jl) 20grains16x16x16_tensionX_material_inc00.vti (extension is modified to allow upload to GitHub). The error message of Paraview is
ParaView reports
|
Once more, I wish I could reproduce the issue, but I have no trouble reading that file on ParaView 5.12.1. Note that I'm using the official binaries from kitware. My version information, in case it helps:
I'm guessing from your python paths that you're using the ParaView binaries from your linux distribution. Could you check if the issue disappears when using the official binaries? |
The official binary works. ParaView and vtk (which are separate builds) from the Arch Linux repositories fail. Both depend on libxml2 (current version 2.12.7) and pugixml (current version 1.14). As far as I see, ParaView vendors libxml 2.9.12 (via vtk, https://gitlab.kitware.com/vtk/vtk/-/tree/14d1d855e377876b5dc73a64da566d0fc3e852ff/ThirdParty/libxml2) and pugixml 1.11.4 (via vtk, https://gitlab.kitware.com/vtk/vtk/-/tree/14d1d855e377876b5dc73a64da566d0fc3e852ff/ThirdParty/pugixml). To me it seems plausible that these libraries are used for reading XML files and the newer versions are more strict when it comes to valid XML files. |
Well, to my mind the problem is the following: Despite how it looks, the VTK format is not XML. I cannot stress this enough. XML does not allow binary data, it is purely text-based. The binary data embedded in the files makes this format "homemade" loosely based on XML (unless of course you encode the binary data in base64, in which case the format may comply with XML specifications). |
I also think that the problem is not caused by WriteVTK.jl and only manifests itself here. Specifically, I think that the format is ad-hoc and a bit under-specified. Additionally, using an XML parser for a file that is not an XML file is just asking for trouble in my opinion. In my case I generated a file which parsed correctly on one system and incorrectly on another. This really should not happen. I think in order to get this properly fixed, the issue needs to be raised with the devs at KitWare who are after all in control of the file format itself... |
I agree. I'll file a bug at kitware |
I tried to reproduce this but can't anymore. Presumably because ParaView was updated from 5.12.0 to 5.12.1 and rebuild with ffmpeg 7 (Note: 5.12.0 from the official build works). When looking for bugs, I found https://gitlab.kitware.com/paraview/paraview/-/issues/20982. The solution for me is to avoid the binary format. Compressed base64 is good for my purposes. IMHO it's a bad idea to define an XML-based file format that is not compatible with XML. @jipolanco: I think the HDF5-based format (https://docs.vtk.org/en/latest/design_documents/VTKFileFormats.html#vtkhdf-file-format) is the better option and it seems that KitWare directs the development efforts towards it. Would including that into WriteVTK.jl be something you're interested in? |
I agree with both of you that putting binary data on XML files is asking for trouble, especially when VTK uses standard XML libraries to read and write files. Unfortunately, for very large datasets, binary ("appended") data provides by far the fastest and most compact way of dealing with data, which is why it's the default format in WriteVTK.jl. @MarDiehl Definitely, I'm very interested in the new VTKHDF format, which would solve this issue as well as being more convenient to work with. In fact I've been using it for a while in a separate project (not public yet). Adding support for VTKHDF in WriteVTK.jl, possibly as an alternative backend, would make a lot of sense, and it has been discussed in a few issues like #125. But I would need to find the time or someone motivated to implement this. |
I am trying to export data using WriteVTK v1.18.2 to be examined with paraview. Specifically, the data is based on a rectilinear grid of size 41 x 41.
The output script is given by
output.jl
The resulting output file is the following (zipped to allow upload):
output_file.zip
The file is corrupted and unreadable as reported by paraview:
This is confirmed using other XML libraries. Is there something wrong in the calls to the exporting or is this some error in the processing inside WriteVTK?
The text was updated successfully, but these errors were encountered: