[vtk-developers] Unpacking VTP
Andrii Iudin
andrii at ebi.ac.uk
Wed Mar 22 10:24:35 EDT 2017
Dear VTK Developers,
Apologies for the obvious question, of course the data is in blocks as
stated here:
http://www.vtk.org/Wiki/VTK_XML_Formats#Compressed_Data
To avoid any future confusion, it might be worth underlying on this page
that each block is compressed separately and to get the whole data back
it is necessary to parse the VTK header and use its contents to extract
and combine the data from the blocks.
Best regards,
Andrii
On 14/03/2017 13:27, Andrii Iudin wrote:
> Dear VTK Developers,
>
> Apologies for sending this question, if this is a wrong mailing list,
> but there has been no reply from the users list and the issue seems to
> be more to do with the specifics of the format, rather than something
> a general user is expected to know.
>
> We are working on a loader of VTP files into three.js to display these
> files on-line. The VTP files are saved as binary and compressed with
> Zlib. However, when decoding the contents of these files from base64
> and then decompressing, the result is truncated. Only 32768 bytes are
> obtained. This happens in the Javascript implementations of Zlib (both
> pako and zlib.js) and also when decompressing in Python. Please see
> the example files attached.
>
> emd_2557.vtp contains the binary compressed data
> emd_2557_ascii.vtp contains the ASCII data without compression
>
> Both files are perfectly viewable in Paraview, so the data has to be
> there.
>
>
> For example, the procedure in Python is the following:
> import base64
> import zlib
>
> s = "eJyFnXm4V1Pbx8/eKQ1UpnN+DVSKksxJoYkSIhpUFE0nGtC..." # The whole
> string of the first of the Polys except the VTK header
> a = bytearray( base64.b64decode( s ) )
> d = zlib.decompress( bytes( a ) )
> d[-8:-1]
> '\x83\x18\x00\x00\x00\x00\x00'
>
> which is 131 + 256 * 24 = 6275. That is, only first 4096 numbers from
> the first of the Polys are being obtained (as can be seen from the
> ASCII file). Is there a way, maybe a parameter that can be set in Zlib
> to allow obtaining the rest?
>
> Many thanks and best regards,
> Andrii
More information about the vtk-developers
mailing list