[vtk-developers] vtkDataReader/vtkDataWriter and vtkLongArray

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Mon Dec 24 09:26:52 EST 2012


Folks,

Try opening the attached file and save it out in legacy VTK formats
(you can use ParaView to make it easier) saving as ASCII and  Binary.
On a 64-bit linux machine, when load both the saved out files, the
values for "material (long)" are different. The values read from the
binary file are wrong.

The problem is this: since long is 64-bit i.e. 8 bytes on my machine,
when saving out binary files, the writer saves out 8 bytes in
big-endian format handled by templated code (vtkDataWriter.cxx:996).
However, when reading, vtkDataReader thinks long is going to be 4
bytes and hence only consider 4 bytes when converting big-endian to
little-endian (vtkDataReader.cxx:1578).

Now since "long" doesn't have a fixed size across platforms (4 bytes
in some cases and 8 in others), what is the best way of dealing with
this for portable IO?

Utkarsh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gmvtest.cs.long.vs.float.vtu
Type: application/octet-stream
Size: 1856 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20121224/1a7f3915/attachment-0001.obj>


More information about the vtk-developers mailing list