File formats used by KnotPlot

KnotPlot uses at least 15 different file formats, either as input or as output. This page does not describe them all, just a few of the most important ones.


KnotPlot knot and link format

This is probably the single most important file format used by KnotPlot. It is the format that the load and save commands use (although both commands can also work with a simple ascii format). A simple program, kpfsnoop.c is provided for examining the contents of KnotPlot files. Another program, unknot.c is included as a complete example of writing a link file. Note that the load command can also read input data in the form of ascii text, similar to that output by the coords command.

This format consists of an ascii header, followed by one or more fields or sections.

Header

This can consist of arbitrary text but must begin with the string

KnotPlot 1.0
indicating that the file is a KnotPlot version 1 file. The header ends with a control-L character (new-page character, ascii value 12) followed by exactly one character (of arbitrary value, but usually set to a new-line character). The reason for the control-L new-line combination is that this allows for easy viewing of the header using the UNIX command more without having to have to see any of the binary data that follows the header.

Fields

After the header, the file must contain at least one field. All fields are optional, except for the endf field, which must be the last field present. Each field consists of a four character string which is the field name, followed by a data segment (possibly null). There are three types of fields, depending on the kind and amount of data following. The fields can be distinguished by the case of the first two characters in the field name:
Both lower case
This indicates a field that has a null data segment. Examples are the endf and comp fields. Such fields are usually used to indicate an event or milestone of some sort, and they need no other data.
Both upper case
Following the field name, these fields have a four byte long which indicates the number of remaining bytes in the data segment. Therefore if this number is K, the total length of the field (including the field name) is K + 8 bytes. This makes it easy for software that doesn't understand how to deal with the field to simply skip the remaining part of the data segment by skipping the K bytes following the four byte long. Examples are the LOCF and LOCS fields.
First character upper, second lower case
The data segment in these fields consists of exactly the four bytes following the field name. An example is the Attr field.

endf field

comp field

LOCF field

LOCS field

IDEN field

VIEW field

COMM field

Attr field


PGM format


PPM format


[KnotPlot Manual], [View Window], [Control Panel], [Command Window], [Overview]
[Rob Scharein's main WWW site], [KnotPlot Site]