VTK
VTK Legacy Reader/Writer Information Format

Overview

The legacy vtk data file readers / writers store certain vtkInformation entries that are set on vtkAbstractArray's GetInformation() object. Support is currently limited to numeric and string information keys, both single- and vector-valued. Only the information objects attached to arrays are encoded.

Array Metadata Blocks

A block of metadata may immediately follow the specification of an array. Whitespace is permitted between the array data and the opening METADATA tag. The metadata block is terminated by an empty line.

1 # vtk DataFile Version 4.1
2 vtk output
3 ASCII
4 DATASET UNSTRUCTURED_GRID
5 POINTS 6 float
6 0 0 0 1 0 0 0.5 1 0
7 0.5 0.5 1 0.5 -1 0 0.5 -0.5 1
8 
9 METADATA
10 COMPONENT_NAMES
11 X%20coordinates
12 Y%20coordinates
13 Z%20coordinates
14 INFORMATION 8
15 NAME Double LOCATION TestKey
16 DATA 1
17 NAME DoubleVector LOCATION TestKey
18 DATA 3 1 90 260
19 NAME IdType LOCATION TestKey
20 DATA 5
21 NAME String LOCATION TestKey
22 DATA Test%20String!%0ALine2
23 NAME Integer LOCATION TestKey
24 DATA 408
25 NAME IntegerVector LOCATION TestKey
26 DATA 3 1 5 45
27 NAME StringVector LOCATION TestKey
28 DATA 3
29 First
30 Second%20(with%20whitespace!)
31 Third%20(with%0Anewline!)
32 NAME UnsignedLong LOCATION TestKey
33 DATA 9
34 
35 CELLS 3 15
36 4 0 1 2 3
37 4 0 4 1 5
38 4 5 3 1 0
39 
40 CELL_TYPES 3
41 10
42 10
43 10
44 
45 CELL_DATA 3
46 FIELD FieldData 1
47 vtkGhostType 1 3 unsigned_char
48 0 1 1
49 METADATA
50 COMPONENT_NAMES
51 Ghost%20level%20information
52 INFORMATION 1
53 NAME UNITS_LABEL LOCATION vtkDataArray
54 DATA radians

As shown, a metadata block can have two sections, COMPONENT_NAMES and INFORMATION. The INFORMATION tag is followed by the number of information keys that follow.

COMPONENT_NAMES

If the METADATA block contains the line COMPONENT_NAMES, the following lines are expected to be encoded strings containing the names of each component. There must be one line per component.

INFORMATION

If the METADATA block contains the line INFORMATION, the number of information keys is read from the INFORMATION line and vtkInformation data that follows is parsed. The general form of a single valued information entry is:

1 NAME [key name] LOCATION [key location (e.g. class name)]
2 DATA [value]

A vector information key is generally represented as:

1 NAME [key name] LOCATION [key location (e.g. class name)]
2 DATA [vector length] [value0] [value1] [value2] ...

The exception is a string vector, which contains encoded entries separated by newlines.

Specific examples of supported key types:

vtkInformationDoubleKey

1 NAME Double LOCATION TestKey
2 DATA 1

vtkInformationDoubleVectorKey

1 NAME DoubleVector LOCATION TestKey
2 DATA 3 1 90 260

vtkInformationIdTypeKey

1 NAME IdType LOCATION TestKey
2 DATA 5

vtkInformationStringKey

1 NAME String LOCATION TestKey
2 DATA Test%20String!%0ALine2

vtkInformationIntegerKey

1 NAME Integer LOCATION TestKey
2 DATA 408

vtkInformationIntegerVectorKey

1 NAME IntegerVector LOCATION TestKey
2 DATA 3 1 5 45

vtkInformationStringVectorKey

1 NAME StringVector LOCATION TestKey
2 DATA 3
3 First
4 Second%20(with%20whitespace!)
5 Third%20(with%0Anewline!)

vtkInformationUnsignedLongKey

1 NAME UnsignedLong LOCATION TestKey
2 DATA 9