Creating a Volume Object

A volume object contains a three dimensional data array of voxel values and a set of rendering attributes. The voxel array is mapped to colors and opacity values through a set of lookup tables in the volume object. Several rendering methods are provided to draw the volume to a destination.

To create a volume object, create a three dimensional array of voxels and pass them to the IDLgrVolume::Init method. Voxel arrays must be of BYTE type. For example, the following will create a simple volume data set and create a volume object which uses it:

data = BYTARR(64,64,64, /NOZERO) 
FOR i=0,63 DO data[*,i,0:i] = i*2  
data[5:15, 5:15, 5:55] = 128  
data[45:55, 45:55, 5:15] = 255 
myvolume = OBJ_NEW('IDLgrVolume', data) 

The volume contains a shaded prism along with two brighter cubes (one located within the prism).

See "IDLgrVolume" (IDL Reference Guide) for details on creating volume objects.

Example Code
The example code discussed in the following sections is contained in the procedure file obj_vol.pro, located in the examples/doc/objects subdirectory of the IDL distribution. Run the example procedure by entering .EDIT obj_vol at the IDL command prompt or view the file in an IDL Editor window by entering obj_vol.pro. The procedure file stops after each operation (roughly corresponding to each section below) and requests that you press return before continuing.

Using Volume Objects

A volume object has spatial dimensions equal to the size of the data in the volume. In the example, the volume object occupies the range 0-63 in the x-, y-, and z-axes. To make the volume easier to manipulate, we use the XCOORD_CONV, YCOORD_CONV, and ZCOORD_CONV properties of the volume object to center the volume at 0,0,0 and scale it to fit in a unit cube.

Figure 7-1: Volume Object

objvol1.gif