|
Object Programming: Creating Volume Objects |
|
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 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. Enter .EDIT obj_vol.pro to display the file in the IDL Editor window. You can run the example procedure by entering OBJ_VOL at the IDL command prompt. The procedure file stops after each operation (roughly corresponding to each section below) and requests that you press return before continuing. |
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.
IDL Online Help (March 06, 2007)