feat: support header_type UInt32#83
Conversation
|
Thanks a lot for your contribution!
We use the repository https://github.com/JuliaVTK/ReadVTK_examples to store example files. Please
|
|
After merging JuliaVTK/ReadVTK_examples#3, I will push the new test here. |
|
I merged your PR adding the new example file. |
sloede
left a comment
There was a problem hiding this comment.
Very nice PR, thanks a lot for this feature! I have only two minor remarks, after which this PR is ready to merge.
| # If data is stored compressed, the first four integers of type `header_type` are the header and | ||
| # must be discarded | ||
| first = 1 + 4 * sizeof(header_type(data_array.vtk_file)) | ||
| # If data is stored compressed, the header consists of `3 + num_blocks` integers of type |
There was a problem hiding this comment.
Do you have a reference where this information can be found that you can put here?
There was a problem hiding this comment.
Not really. It is found via experiments and I do not really guarantee it is universal.
| end | ||
|
|
||
| uncompressed = transcode(ZlibDecompressor, raw[first:last]) | ||
| uncompressed = transcode(ZlibDecompressor, raw[first_data:last_data]) |
There was a problem hiding this comment.
Does this work even if the data is compressed in multiple blocks? That is, it is not necessary to decompress block by block?
There was a problem hiding this comment.
Yes. I have tried it on one sample data with 19 blocks, and it also works. The sample test file I added has only 1 block though.
|
Thanks a lot! I will merge this now and release the new version. It would be great if you could create a second PR (to the examples repository and afterward to this repository) with another file having multiple blocks to ensure that this feature continues to work in the future. |
This PR addresses two main issues related to parsing VTK files, improving compatibility with files generated by third-party tools like ParaView/PyVista (#78):
Support for UInt32 Header Types: Previously, the dataset header type was hardcoded to UInt64. This PR updates the
VTKFileparser to dynamically read theheader_typeXML attribute and properly support both UInt32 and UInt64 headers across the package.Support for Multi-Block Zlib Compressed Data: Fixes a ZlibError: incorrect header check (code: -3) encountered when reading appended or binary data that has been compressed into multiple blocks (a common behavior in ParaView/PyVista output). The previous implementation assumed a hardcoded compression header size of 4 integers, which is only valid for single-block compression (such as the default used by
WriteVTK.jl). The parsing logic in get_data has been updated to reliably read num_blocks from the start of the header, dynamically calculate the correct header length (3 + num_blocks integers), and accurately define the byte range for the Zlib decompression step.Changes Made
src/ReadVTK.jl:README.mdanddocs/src/index.mdto remove the caveat stating thatheader_typemust be UInt64.Note that I have not added new test for this feature since I don't know how to add a proper minimal test. Feel free to come up with a suitable test in the dataset.