VTK XML Formats: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
(New page: =Appended Data Section= The appended data section is stored in an XML element just before the end of the file. It looks like this: <AppendedData encoding="raw"> _<i>...[DATA]...</...)
 
No edit summary
Line 1: Line 1:
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="<i>byte-order</i>">
    <i>...rest of file...</i>
  </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=
=Appended Data Section=


The appended data section is stored in an XML element just before the end of the file.  It looks like this:
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:


   <AppendedData encoding="raw">
   <VTKFile <i>...</i>>
    _<i>...[DATA]...</i>
    <i>...</i>
   </AppendedData>
    <AppendedData encoding="raw">
      _<i>...[DATA]...</i>
    </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.
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 <i>...</i> 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<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.

Revision as of 14:08, 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.