[Paraview] Base64 encoding in VTI files

D Haley mycae at yahoo.com
Tue Jun 26 08:16:01 EDT 2012


Dear List,

I am attempting to have a program I use write its own VTI files, in order to import image data into paraview more easily (we are usually using raw binary files!).

However, during the base64 encoding, some data sizes are rejected by the paraview reader.

As a small test case, the following file does not work.

<?xml version="1.0"?>
<VTKFile type="ImageData" version="0.1" byte_order="LittleEndian">
    <ImageData WholeExtent="0 0 0 0 0 0" Origin="0.5 0.5 0.5" Spacing="1 1 1">
        <Piece Extent="0 0 0 0 0 0">
            <PointData>
                <DataArray type="Float32" Name="scalars" format="binary" NumberOfComponents="1">AAAAAA==</DataArray>
            </PointData>
            <CellData>
            </CellData>
        </Piece>
    </ImageData>
</VTKFile>


Paraview complain that the data array is too short. However, there needs to be exactly one zero valued floating point entry there, which should be 4 bytes. The base64 encoded data is 6 A characters, followed by 2 significant byte markers - this totals to the first 4 'A's making 3 bytes, and the last 2 'A's making over 1 byte, but the markers indicating to only use 1 byte from the 2 'A's.

The completed dataset should thus be of the right size, unless I am missing something.

Trying to get paraview to do the same job (by saving a raw file) causes a different encoding to be emitted, where a sequence 1B and 10 'A's are emitted, with only one '=' significant byte marker 'BAAAAAAAAAA=' - this loads succesfully,

However, that sequence should decode to 8 bytes, which is too big - the file shouldn't load at all. Does anyone know what is going on? Why do I seem to need an extra byte? Why is there a nonzero value in the paraview version (sign bit negative?)?

To make matters more complicated, when I use large datasets of nonzero data, I only encounter this problem sometimes - so I was suspecting some form of alignment problem..

I'm unsure what paraview is doing here, and why - any advice or comments would be appreciated.


Thanks in advance!


More information about the ParaView mailing list