Given a 3D volume and a contour value, SHADE_VOLUME produces a list of vertices and polygons describing the contour surface. This surface can then be displayed as a shaded surface by the POLYSHADE procedure. Shading is obtained from either a single light-source model or from user-specified values.
SHADE_VOLUME computes the polygons that describe a three dimensional contour surface. Each volume element (voxel) is visited to find the polygons formed by the intersections of the contour surface and the voxel edges. The method used by SHADE VOLUME is that of Klemp, McIrvin and Boyd, 1990: "PolyPaint--A Three-Dimensional Rendering Package," American Meteorology Society Proceedings, Sixth International Conference on Interactive Information and Processing Systems . This method is similar to the marching cubes algorithm described by Lorenson and Cline, 1987: "Marching Cubes: A High Resolution 3D Surface Construction Algorithm," Computer Graphics 21 , 163-169.
This routine is limited to processing datasets that will fit in memory.
A three-dimensional array that contains the dataset to be contoured. If the
Volume
array is dimensioned
(D
0
, D
1
, D
2
)
, the resulting vertex coordinates are as follows:
0 < X <
D
0
- 1; 0 < Y <
D
1
- 1; 0 < Z <
D
2
- 1.
The scalar contour value. This value specifies the constant-density surface (also called an isosurface) to be rendered.
The name of a variable to receive the vertex array. On output, this variable is set to a (3, n ) floating-point array, suitable for input to POLYSHADE.
A named variable to receive the polygon list, an m -element, longword array. This list describes the vertices of each polygon and is suitable for input to POLYSHADE. The vertices of each polygon are listed in counterclockwise order when observed from outside the surface. The vertex description of each polygon is a vector of the form: [ n , i 0 , i 1 , ..., i n-1 ] and the Poly array is the concatenation of the lists of each polygon. For example, when rendering a pyramid consisting of four triangles, Poly would contain 16 elements, made by concatenating four, four-element vectors of the form [3, V 0 , V 1 , V 2 ]. V 0 , V 1 , and V 2 are the indices of the vertices describing each triangle.
Set this keyword to display the low side of the contour surface (i.e., the contour surfaces enclose high data values). If this keyword is omitted or is 0, the high side of the contour surface is displayed and the contour encloses low data values. If this parameter is incorrectly specified, errors in shading will result.
An optional array, converted to byte type before use, that contains the user-specified shading color index for each voxel. This array must have the same dimensions as Volume . On exit, this array is replaced by another array, that contains the shading value for each vertex, contained in Vertex .
CAUTION:
When using the SHADES keyword on True Color devices, we recommend that decomposed color support be turned off, by setting DECOMPOSED=0 for
DEVICE
.
Set this keyword to print a message indicating the number of polygons and vertices that are produced.
An optional two-element vector that contains the limits, over the first dimension, of the sub-volume to be considered.
The following procedure shades a volume passed as a parameter. It uses the SCALE3 procedure to establish the viewing transformation. It then calls SHADE_VOLUME to produce the vertex and polygon lists, and POLYSHADE to draw the contour surface.
Pro SHOWVOLUME, vol, thresh, LOW = low ; Display the contour surface of a volume.
s = SIZE(vol) ; Get the dimensions of the volume.
IF s[0] NE 3 THEN ... ... ; Error, must be a 3D array.
SCALE3, XRANGE=[0, S[1]], YRANGE=[0, S[2]], ZRANGE=[0, S[3]]
;
Use SCALE3 to establish the 3D transformation and coordinate ranges.
IF N_ELEMENTS(low) EQ 0 THEN low = 0 ; Default = view high side of contour surface.
SHADE_VOLUME, vol, thresh, v, p, LOW = low ; Produce vertices and polygons.
TV, POLYSHADE(v,p,/T3D) ; Produce image of surface and display.