Skip to content
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

zlib compressor error #45

Open
henry2004y opened this issue Oct 8, 2023 · 2 comments
Open

zlib compressor error #45

henry2004y opened this issue Oct 8, 2023 · 2 comments

Comments

@henry2004y
Copy link
Contributor

Hi again,

I have a vti file generated by ParaView 5.11. If I choose no compressor when saving data from ParaView, then the generated file and the corresponding point data can be read by ReadVTK.jl; however, if I choose the zlib compressor, then I get the error:

julia> vtk = VTKFile("test2.vti")
VTKFile("test2.vti", <XMLDocument>, "ImageData", "2.2.0", "LittleEndian", "vtkZLibDataCompressor", <appended_data>, 8000, 6859)

julia> point_data = get_point_data(vtk)
VTKData()

julia> B = get_data(point_data["B"])
ERROR: zlib error: incorrect header check (code: -3)
Stacktrace:
 [1] unsafe_transcode!(output::TranscodingStreams.Buffer, codec::CodecZlib.ZlibDecompressor, input::TranscodingStreams.Buffer)
   @ TranscodingStreams C:\Users\hyzho\.julia\packages\TranscodingStreams\2McN2\src\transcode.jl:183
 [2] transcode!
   @ C:\Users\hyzho\.julia\packages\TranscodingStreams\2McN2\src\transcode.jl:127 [inlined]
 [3] transcode(codec::CodecZlib.ZlibDecompressor, input::TranscodingStreams.Buffer, output::Nothing)
   @ TranscodingStreams C:\Users\hyzho\.julia\packages\TranscodingStreams\2McN2\src\transcode.jl:109
 [4] transcode
   @ C:\Users\hyzho\.julia\packages\TranscodingStreams\2McN2\src\transcode.jl:108 [inlined]
 [5] transcode
   @ C:\Users\hyzho\.julia\packages\TranscodingStreams\2McN2\src\transcode.jl:189 [inlined]
 [6] transcode(#unused#::Type{CodecZlib.ZlibDecompressor}, args::Vector{UInt8})
   @ TranscodingStreams C:\Users\hyzho\.julia\packages\TranscodingStreams\2McN2\src\transcode.jl:37
 [7] get_data(data_array::VTKDataArray{Float64, 3, ReadVTK.FormatAppended})
   @ ReadVTK D:\Computer\ReadVTK.jl\src\ReadVTK.jl:740
 [8] top-level scope
   @ REPL[5]:1

This generated compressed vti file can be read by ParaView. Does it indicate that there are different types of compression zlib format?

A link to the test file is here.

@sloede
Copy link
Member

sloede commented Oct 9, 2023

Hi @henry2004y. Unfortunately, I cannot make anything of it. The issue seems related to the decoding of the compressed data stored in the VTI file. Unfortunately, zlib only gives somewhat nondescript error messages, which makes it hard for us non-experts to infer what's going on.

It would be great if you could try to dig in a little deeper. A good start would maybe to create the absolute minimum working example of a file that causes this error - e.g., a simple mesh with just one cell and one data variable (or even without data variables). Then we could try to figure what's what.

My feeling is that this might be related to #44, i.e., that ParaView uses a different encoding strategy of the header information in the compressed data than what is written in the docs.

@henry2004y
Copy link
Contributor Author

Here is a MWE. First, a vti file can be generated in ParaView:

from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()

# create a new 'Fast Uniform Grid'
fastUniformGrid1 = FastUniformGrid(registrationName='FastUniformGrid1')

# save data
SaveData('test.vti', proxy=fastUniformGrid1, ChooseArraysToWrite=1,
    PointDataArrays=['DistanceSquared'],
    CompressorType='ZLib')

By default Paraview sets the compressor level for zlib to 6. Then with ReadVTK,

julia> using ReadVTK

julia> vtk = VTKFile("test.vti")
VTKFile("test.vti", <XMLDocument>, "ImageData", "1.0.0", "LittleEndian", "vtkZLibDataCompressor", <appended_data>, 1331, 1000)

julia> point_data = get_point_data(vtk)
VTKData()

julia> data = get_data(point_data["DistanceSquared"])
ERROR: zlib error: incorrect header check (code: -3)
Stacktrace:
 [1] unsafe_transcode!(output::TranscodingStreams.Buffer, codec::CodecZlib.ZlibDecompressor, input::TranscodingStreams.Buffer)
   @ TranscodingStreams C:\Users\hyzho\.julia\packages\TranscodingStreams\2McN2\src\transcode.jl:183
 [2] transcode!
   @ C:\Users\hyzho\.julia\packages\TranscodingStreams\2McN2\src\transcode.jl:127 [inlined]
 [3] transcode(codec::CodecZlib.ZlibDecompressor, input::TranscodingStreams.Buffer, output::Nothing)
   @ TranscodingStreams C:\Users\hyzho\.julia\packages\TranscodingStreams\2McN2\src\transcode.jl:109
 [4] transcode
   @ C:\Users\hyzho\.julia\packages\TranscodingStreams\2McN2\src\transcode.jl:108 [inlined]
 [5] transcode
   @ C:\Users\hyzho\.julia\packages\TranscodingStreams\2McN2\src\transcode.jl:189 [inlined]
 [6] transcode(#unused#::Type{CodecZlib.ZlibDecompressor}, args::Vector{UInt8})
   @ TranscodingStreams C:\Users\hyzho\.julia\packages\TranscodingStreams\2McN2\src\transcode.jl:37
 [7] get_data(data_array::VTKDataArray{Float32, 1, ReadVTK.FormatAppended})
   @ ReadVTK D:\Computer\ReadVTK.jl\src\ReadVTK.jl:740
 [8] top-level scope
   @ REPL[5]:1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants