---
name: "VoxelSize"
section: "3"
platform: "linux"
package: "libvolpack1-dev"
version: "1.0b3-10"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/VoxelSize"
---

# VoxelSize(3)

define the size of a voxel

## NAME

vpSetVoxelSize - define the size of a voxel

## SYNOPSIS

\#include \<volpack.h\>

vpResult

**vpSetVoxelSize(***vpc, bytes\_per\_voxel, num\_voxel\_fields,* *num\_shade\_fields, num\_classify\_fields***)**

-

  vpContext \**vpc;*

-

  int *bytes\_per\_voxel;*

-

  int *num\_voxel\_fields;*

-

  int *num\_shade\_fields;*

-

  int *num\_classify\_fields;*

## ARGUMENTS

- *vpc*

  VolPack context from **vpCreateContext.**

- *bytes\_per\_voxel*

  Size of one voxel in bytes.

- *num\_voxel\_fields*

  Number of fields in a voxel.

- *num\_shade\_fields*

  Number of voxel fields that are arguments to the shading function.

- *num\_classify\_fields*

  Number of voxel fields that are arguments to the opacity transfer function.

## DESCRIPTION

**vpSetVoxelSize** is used to define the size in bytes and the number of fields in a voxel.  Each voxel field is analogous to a field in a C structure and the contents of each field is user-defined.  See the **vpSetVoxelField** function (vpSetVoxelField(3)) for setting the size and offset of each field.  **vpSetVoxelSize** should be called before **vpSetVoxelField** and before any functions that access the contents of a voxel.

Typically, some of the voxel fields are used as arguments to a shading function and some (possibly the same) fields are used as arguments to an opacity transfer function (for classification).  The fields that are used for shading should come first, i.e. they should have the smallest offsets, followed by any fields that are only used for classification.  The classification fields can then be stripped off to save space during the precomputation stage for the fast rendering algorithm.  The parameter *num\_shade\_fields* indicates the number of fields (starting from the first) that must not be stripped off.

The parameter *num\_clsfy\_fields* indicates the total number of fields that are used as parameters to the opacity transfer function. These fields do not necessarily have to be contiguous, although any fields that are not also used for shading should be the last fields in the voxel.

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

## STATE VARIABLES

The current voxel size parameters can be retrieved with the following state variable codes (see vpGeti(3)): VP\_BYTES\_PER\_VOXEL, VP\_VOXEL\_FIELD\_COUNT, VP\_SHADE\_FIELD\_COUNT, VP\_CLASSIFY\_FIELD\_COUNT.

## ERRORS

The normal return value is VP\_OK.  The following error return values are possible:

- VPERROR\_LIMIT\_EXCEEDED

  The number of voxel fields exceeds the implementation limit.  This limit can be increased by editing volpack.h and recompiling the library.

- VPERROR\_BAD\_VALUE

  Either *num\_clsfy\_fields* or *num\_shade\_fields* is out of range.

## SEE ALSO

[VolPack(3)](/VolPack/3.md), vpCreateContext(3), vpSetVoxelField(3)
