Man Linux: Main Page and Category List

NAME

       vpSetVoxelField,  vpFieldOffset  -  define  the  size and location of a
       voxel field

SYNOPSIS

       #include <volpack.h>

       vpResult
       vpSetVoxelField(vpc, field_num, field_size, field_offset, field_max)
           vpContext *vpc;
           int field_num;
           int field_size;
           int field_offset;
           int field_max;

       int
       vpFieldOffset(voxel_ptr, field_name)
           vpContext *vpc;
           LITERAL field_name;

ARGUMENTS

       vpc    VolPack context from vpCreateContext.

       field_num
              Field number for the field to define (first field is 0).

       field_size
              Size of the field in bytes.

       field_offset
              Number of bytes from the beginning of the voxel to the beginning
              of the field.

       field_max
              Maximum possible value of the field.

       voxel_ptr
              Pointer to a C structure defining the fields in the voxel.

       field_name
              Literal name of the voxel field in the C structure.

DESCRIPTION

       vpSetVoxelField  is  used to define the size and location of each field
       in a voxel.  Once you have chosen the sizes and  order  for  the  voxel
       fields, call vpSetVoxelSize once and then call vpSetVoxelField once for
       each field.  Each field  has  a  unique  field  number  (the  field_num
       argument);  the  first  field is 0, the next is 1, and so on, up to one
       less than the total number of fields defined with VpSetVoxelSize.   The
       field_max  argument  is  used to determine the required size for lookup
       tables indexed by the value in a particular field;  the  maximum  field
       value  may  be  any  number  from  0  to  the  maximum unsigned integer
       representable by the field size.

       If you have declared the layout of a voxel using a C structure then you
       can  use the sizeof operator and the vpFieldOffset macro to compute the
       field sizes and offsets.  vpFieldOffset returns  the  number  of  bytes
       from  the  beginning  of a C structure to the beginning of a particular
       field in the structure.  For example, the following code shows  how  to
       declare the size and offset for one voxel field:

           struct voxel {
               char field0;
               char field1;
               short field2;
           } *dummy_voxel;

           #define SIZE_0    sizeof(char)
           #define OFFSET_0  vpFieldOffset(dummy_voxel, field0)
           #define MAX_0     127

           vpSetVoxelField(vpc, 0, SIZE_0, OFFSET_0, MAX_0);

       The size of each field must be 1, 2 or 4 bytes.
       You must also obey any byte-alignment restrictions required by your
       hardware.  On many machines, two-byte fields must begin on a two-byte
       boundary and four-byte fields must begin on a four-byte boundary.
       The total size of a voxel may also need to be padded so that voxels
       packed one after the other still obey the alignment restrictions.
       If you declare your voxel as a C structure and use the sizeof
       operator and the vpFieldOffset macro then you should always get
       correct results.  However, if you do not consider alignment
       restrictions when choosing the voxel field ordering the compiler may
       have to insert padding for you, resulting in wasted memory.

       Some of the VolPack routines require you to declare fields of a
       particular size in order to store their results.  The functions to
       precompute surface normals and gradient magnitudes (see
       vpVolumeNormals(3), vpScanlineNormals(3), vpClassifyVolume(3),
       vpClassifyScalars(3) and vpClassifyScanline(3)) can optionally store a
       one-byte scalar value, a one-byte
       gradient magnitude, and a two-byte surface normal value in each voxel.
       The following constants defined in volpack.h give the corresponding
       maximum field values: VP_SCALAR_MAX, VP_GRAD_MAX, and VP_NORM_MAX.
       If you choose not to use these functions then there is no need to
       declare these fields.

       It is usually not necessary to declare a field for the voxel opacity
       if the opacity can be computed from the other voxel fields.  See
       vpSetClassifierTable(3) for further discussion.

       If the call to vpSetVoxelSize succeeds, any existing precomputed
       volume data structures in the context are destroyed.

STATE VARIABLES

       The  current voxel field parameters can be retrieved with the following
       state variable codes (see vpGeti(3)): VP_FIELD_SIZES, VP_FIELD_OFFSETS,
       VP_FIELD_MAXES.

ERRORS

       The  normal return value is VP_OK.  The following error return value is
       possible:

       VPERROR_BAD_VALUE
              The field number, size or offset is out of range.

SEE ALSO

       VolPack(3), vpCreateContext(3), vpSetVoxelSize(3)