VTK XML Formats: Difference between revisions
No edit summary |
|||
Line 36: | Line 36: | ||
NNNN<i>[DATA]</i> | NNNN<i>[DATA]</i> | ||
where "NNNN" is a 32-bit unsigned integer value specifying the number of <b>bytes</b> in the block of data following it. The rest of the data immediately follow it. | where "NNNN" is a 32-bit unsigned integer value specifying the number of <b>bytes</b> in the block of data following it. The rest of the data immediately follow it. The byte count and all data are in the byte order specified by the "byte_order" attribute at the top of the file. In general a raw, uncompressed AppendedData element has the form | ||
<AppendedData encoding="raw"> | |||
_<i><n1><data1><n2><data2>...</i> | |||
</AppendedData> | |||
where the "<n1>"-style tokens indicate 32-bit unsigned integer byte counts and "<data1>"-style tokens indicate the corresponding blocks of binary data. |
Revision as of 14:14, 11 June 2008
This page briefly documents VTK XML File format details to help those attempting to create home-grown writers. It is not indended as a complete or authoritative document. See the VTK Users's Guide for more information about the format. We encourage developers to use the C++, C, or Fortan interfaces provided by VTK to use the official writers instead of using the information in this document.
The VTKFile Element
The top-level document element of any VTK XML file is called "VTKFile":
<VTKFile type="..." byte_order="byte-order"> ...rest of file... </VTKFile>
The byte order specified may be either "LittleEndian" or "BigEndian" and indicates the byte order used for any binary data in the file.
Appended Data Section
The appended data section is stored in an XML element just before the end of the file. A file with an AppendedData element has this form:
<VTKFile ...> ... <AppendedData encoding="raw"> _...[DATA]... </AppendedData> </VTKFile>
Note the literal underscore ('_') at the beginning of the data. This character separates whitespace to its left from the data to its right. Extra whitespace AFTER the data has no effect. The AppendedData section CDATA can be base-64 encoded to produce a fully valid XML file, but may also be left raw. In this document we assume the raw encoding because it is simpler.
DataArray elements elsewhere in the file reference the AppendedData section like this:
<DataArray ... format="appended" offset="0"/>
The value in the "offset" attribute is the file offset in bytes beyond the leading underscore. An offset of "0" means the first character after the underscore. Each DataArray's data are stored in a contiguous block. The block can be either compressed or uncompressed, but by default it is uncompressed (compression is global to the file and marked by an attribute on the VTKFile element).
Uncompressed Data
A block representing a data array without compression has this format:
NNNN[DATA]
where "NNNN" is a 32-bit unsigned integer value specifying the number of bytes in the block of data following it. The rest of the data immediately follow it. The byte count and all data are in the byte order specified by the "byte_order" attribute at the top of the file. In general a raw, uncompressed AppendedData element has the form
<AppendedData encoding="raw"> _<n1><data1><n2><data2>... </AppendedData>
where the "<n1>"-style tokens indicate 32-bit unsigned integer byte counts and "<data1>"-style tokens indicate the corresponding blocks of binary data.