Question

I am working on a file whose endian is different from my desktop and I need to convert it, but When I visualized the vtk it worked. So are vtkreaders of vtk files endian independent

Was it helpful?

Solution

ParaView can read VTK files written using either big- or little-endian byte ordering and will try to work out which format has been used when writing a given file. From the VTK File format documentation:

Binary Files.

Binary files in VTK are portable across different computer systems as long as you observe two conditions.

First, make sure that the byte ordering of the data is correct, and second, make sure that the length of each data type is consistent. Most of the time VTK manages the byte ordering of binary files for you. When you write a binary file on one computer and read it in from another computer, the bytes representing the data will be automatically swapped as necessary. For example, binary files written on a Sun are stored in big endian order, while those on a PC are stored in little endian order. As a result, files written on a Sun workstation require byte swapping when read on a PC. (See the class vtkByteSwap for implementation details.) The VTK data files described here are written in big endian form.

Note, that if you are using the newer XML VTK file formats you can specify the byte ordering explicitly in the file, see, for example, the VTK wiki for more information on this. Basically the VTKFile element has the form

<VTKFile type="..." version="version" byte_order="byte-order" ...>
    ...rest of file...
</VTKFile>

where the byte_order specified:

may be either "LittleEndian" or "BigEndian" and indicates the byte order used for any binary data in the file.

It should be emphasied that this is only a issue for binary data. Legacy ASCII VTK files do not care about byte ordering.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top