File Formats
for VTK Version 4.2
(Taken from The VTK User’s Guide
Contact Kitware www.kitware.com to purchase)
VTK File Formats
The Visualization Toolkit provides a number of source and writer objects to read and write popular data file formats. The
Visualization Toolkit also provides some of its own file formats. The main reason for creating yet another data file format
is to offer a consistent data representation scheme for a variety of dataset types, and to provide a simple method to com-
municate data between software. Whenever possible, we recommend that you use formats that are more widely used. But
if this is not possible, the Visualization Toolkit formats described here can be used instead. Note that these formats may not
be supported by many other tools.
There are two different styles of file formats available in VTK. The simplest are the legacy, serial formats that are
easy to read and write either by hand or programmatically. However, these formats are less flexible than the XML based
file formats described later in this section. The XML formats support random access, parallel I/O, and portable data com-
pression and are preferred to the serial VTK file formats whenever possible.
Simple Legacy Formats
The legacy VTK file formats consist of five basic parts.
1. The first part is the file version and identifier. This part contains the single line:
# vtk DataFile Version x.x.
This line must be exactly as shown with the exception of the version number
x.x, which will vary with different
releases of VTK. (Note: the current version number is 3.0. Version 1.0 and 2.0 files are compatible with version 3.0
files.)
2. The second part is the header. The header consists of a character string terminated by end-of-line character
.The
header is 256 characters maximum. The header can be used to describe the data and include any other pertinent
information.
3. The next part is the file format. The file format describes the type of file, either ASCII or binary. On this line the sin-
gle word
ASCII or BINARY must appear.
4. The fourth part is the dataset structure. The geometry part describes the geometry and topology of the dataset. This
part begins with a line containing the keyword
DATASET followed by a keyword describing the type of dataset.
Then, depending upon the type of dataset, other keyword/data combinations define the actual data.
5. The final part describes the dataset attributes. This part begins with the keywords
POINT_DATA or CELL_DATA,fol-
lowed by an integer number specifying the number of points or cells, respectively. (It doesn’t matter whether
POINT_DATA or CELL_DATA comes first.) Other keyword/data combinations then define the actual dataset attribute
values (i.e., scalars, vectors, tensors, normals, texture coordinates, or field data).
An overview of the file format is shown in Figure 1. The first three parts are mandatory, but the other two are optional.
Thus you have the flexibility of mixing and matching dataset attributes and geometry, either by operating system file
manipulation or using VTK filters to merge data. Keywords are case insensitive, and may be separated by whitespace.
Before describing the data file formats please note the following.
• dataType is one of the types
bit, unsigned_char, char, unsigned_short, short, unsigned_int, int,
unsigned_long, long, float,ordouble. These keywords are used to describe the form of the data, both for
reading from file, as well as constructing the appropriate internal objects. Not all data types are supported for all
classes.
评论0