Other Alias
vpFieldOffsetSYNOPSIS
#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);
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.