[comp.graphics.visualization] AVS field files

bob@sunc.osc.edu (Bob Marshall) (02/03/91)

>> ghenniga@nmsu.edu (Gary Hennigan) writes:
>>
>>        From what I can read in the manual it seems the best way to
>>write a nice general translator is to create an AVS "field" file but
>>the manual seems to be a little vague on how to write code to output
>>the correct format "field" file. I just keep getting the error from
>>AVS that the files I've been attempting to write are not AVS field
>>files.

I had a similar problem when writing a field file (AVS 2.0). Here is a
simple piece of code that converted an ASCII 3D file into a field for AVS.
The important part is the spaces on the lines after the header information.
I also put in comment for good measure. What I found was that some kind of
fixed length input is done and the spaces must be after the dim1, dim2, and
dim3 values as well as some of the other lines.



/*  write_fld.c */

#include <stdio.h>

main()
{
    int dim1,dim2,dim3;
    int x,y,z;
    float xout, yout, zout;
    char ff;
    char line[80];

    fgets(line, 80, stdin);
    sscanf(line, "%d %d %d", &dim1, &dim2, &dim3);

    printf("# AVS field file (%%W%% Stellar %%E%%)\n");
    printf("# creation date: Wed Dec  6 13:17:16 1989\n#\n");
    printf("ndim=3\t\t\t\t# number of dimensions in the field\n");
    printf("dim1=%d       \t\t\t# dimension of axis 1\n", dim1);
    printf("dim2=%d       \t\t\t# dimension of axis 2\n", dim2);
    printf("dim3=%d       \t\t# dimension of axis 3\n", dim3);
    printf("nspace=3\t\t\t# number of physical coordinates per point\n");
    printf("veclen=3\t\t\t# number of components at each point\n");
    printf("data=float      \t\t# data type (byte, integer, float, double)\n");
    printf("field=uniform    \t\t# field type (uniform, rectilinear, irregular)\n");

    ff = 014;
    fwrite(&ff, sizeof(char), 1, stdout);
    fwrite(&ff, sizeof(char), 1, stdout);

    for (z=0; z<dim3; z++)
    {
        for (y=0; y<dim2; y++)
        {
            for (x=0; x<dim1; x++)
            {
                fgets(line, 80, stdin);
                sscanf(line, "%f %f %f", &xout, &yout, &xout);
                fwrite(&xout, sizeof(float), 1, stdout);
                fwrite(&yout, sizeof(float), 1, stdout);
                fwrite(&zout, sizeof(float), 1, stdout);
            }
        }
    }
}

mmcneill@duchamp.ncsa.uiuc.edu (Michael Mcneill -Visualization) (02/05/91)

Ask your Stardent rep for a copy of the unsupported modules.  One of the 
modules is called "Build a field".  It allows you to create fields by giving
a high level description of your data................................Mike