The program reads in all slices once into the memory before writing it out. If memory is a problem the slices can be read and written out one at a time. It is assumed that the byte ordering of the data is the same as the machine the program is running on. And as such it is read using the fread call.
The computation of the 3DVIEWNIX header is done in the function "Initialize_Output_Header". The most important items that need to be filled are the "type 1" fields (see  for details on type specification).
The function used for writing 3DVIEWNIX headers is VWriteHeader. This function requires that the file pointer be read/writable. The format of the function call is as follows.
There are three library functions used in writing the data. They are VSeekData, VWriteData, VCloseData. VSeekData moves the file pointer relative to the end of the header. This is used to skip the header before writing(reading) the data. The format of the function is as follows.
VWriteData writes the data from the machine dependent format (which is the format in memory) into the 3DVIEWNIX convention, see  (big endian byte order). The format of the function is as follows.
VCloseData simply sets the size of the data segment according to the ACR-NEMA convention and closes the file.
A.2 Writing Processing Programs
The example included here does scene filtering using a 2D Gaussian
operator. The source code (gaussian2D.c) for this program is available
PROCESS/PREPROCESS/SCENE_OPERATIONS/FILTER directory of the main
system. This should help you in writing programs that do not interact
the 3DVIEWNIX user interface. In addition to the data writing function
above, you would need a few additional 3DVIEWNIX library calls that
you to read the 3DVIEWNIX header and the data from the input file. The
processing consists of five steps.