3. Converting From/to ASCII

With the implementation of BRL-CAD’s machine-independent database format, the need for converting to or from ASCII format has rapidly diminished. Nonetheless, BRL-CAD still supports ASCII conversions, and release 6.0 introduced a new ASCII format. This format is simply a Tcl[1] script that (when executed by a properly empowered Tcl interpreter) rebuilds the database from which it was derived. In contrast, the old ASCII format consisted of a sequence of one-line records that corresponded to the old database format records.

1. Converting From ASCII

The asc2g utility is used to convert ASCII format databases into the new binary format. This utility will always create the new binary format, but it will accept either of the two ASCII formats.

The usage for this utility is as follows:

asc2g input.asc output.g

In this command, input.asc is a file previously created using g2asc and output.g is the name where the resulting binary database should be stored.

2. Converting to ASCII

The converse of the asc2g utility is the g2asc utility, which is used to convert from either the current database format or the prerelease 6.0 database format to an ASCII format. Databases in the new format will be converted to the new (Tcl script) ASCII format. Databases in the old format will be converted to the old ASCII format.

The command for this utility is as follows:

g2asc input.g output.asc

In this command, the input.g is a BRL-CAD database (old or new format) and output.asc is the name where the ASCII output is placed. As mentioned previously, the form of the ASCII output depends on which database format is used by the input database. If it is known that the input database is in the older BRL-CAD format, then the g2asc may be executed using redirected input and output, as follows:

g2asc < input.g > output.g

If this is attempted using the newer database format, however, an error message will be displayed and no conversion will be performed.

1. Tcl/Tk is an interpreted programming language that can be used to extend/customize BRL-CAD functionality. Users are encouraged to consult one of the many texts on Tcl/Tk syntax and use, including Practical Programming in Tcl and Tk (Welch, 1999) and TCL/TK in a Nutshell (Raines and Tranter, 1999).