User Guide > Rendering Techniques > Importing and Generating Data for Rendering
  

Importing and Generating Data for Rendering
Before you can render data, you must import and/or generate data. There are several ways to render imported or generated data. The demonstration programs illustrate five ways:
*Import the data, manipulate the data, set up the data for viewing, and then render the imported data. Demonstration programs that illustrate this method are:
*vec_demo2
*vol_demo1
*Import the data, generate polygons or volumes, manipulate the data, set up the data for viewing, and then render the data. Examples are:
*poly_demo1
*vol_demo2
*vol_demo3
*Import the data, generate polygons or volumes, set up the data for viewing, and then render the data. Examples are:
*sphere_demo1
*gen_iso_head
*gen_amin
*gen_slic_head
*gen_flat_head
*gen_tran_head
*gen_core_head
*The gen_ routines import data, generate polygons or volumes, use the RENDER function to render images and then store the rendered images in a file.
*Generate polygons, manipulate the data, set up the data for viewing, and then render the data. Examples are:
*sphere_demo2
*sphere_demo3
*f_gridemo4
*grid_demo4
*Generate polygons, set up the data for viewing, and then render the data. Examples are:
*grid_demo5
*vec_demo1
*cube1
*cube2
Importing Data
You can render data that is imported from one or more files. Refer to Chapter 9: Working with Data Files from the PV‑WAVE Programmer’s Guide for details on importing data into PV‑WAVE. Example programs that import data from more than one file are poly_demo1, vec_demo2, and vol_demo1.
Generating Polygons and Volumes
PV‑WAVE provides routines for creating various types of polygons and volumes such as meshes, rectangular surfaces, spherical surfaces, cones, and cylinders.
Some of these routines are only used with the RENDER function (CONE, CYLINDER, MESH, SPHERE and VOLUME). For information on these RENDER-specific functions, see the section "Specifying RENDER Objects", as well as the individual function descriptions in PV‑WAVE Reference.
Many of the render routines and their utilities require a vertex_list and a polygon_list as input parameters. Routines that generate a vertex_list and a polygon_list representation for polygons and volumes are described in this section. These routines include POLY_SPHERE, POLY_SURF, and SHADE_VOLUME.
Vertex Lists and Polygon Lists
PV‑WAVE uses a very simple format for polygonal representation. It consists of an array of vertices and a flat one-dimensional array of polygons, as described below.
*vertex_list—A (3, n) array containing the three-dimensional coordinates of each vertex.
*polygon_list—An array containing the number of sides for each polygon and the subscripts into the vertex_list array.
Vertex List shows how to render two adjacent square polygons with a vertex_list:
 
Table 7-5: Vertex List
X-axis
Y-axis
Z-axis
0.0
0.0
0.0
1.0
0.0
0.0
2.0
0.0
0.0
2.0
1.0
0.0
1.0
1.0
0.0
0.0
1.0
0.0
As shown in Vertices of Two Square Polygons, there are only six vertices in the resulting vertex_list because two vertices are shared by both polygons.
 
Figure 7-2: Vertices of Two Square Polygons
The polygon_list then contains:
4   The first polygon has 4 sides.
0   The first vertex is vertex_list(*, 0).
1   The second vertex is vertex_list(*, 1).
4   The third vertex is vertex_list(*, 4).
5   The fourth vertex is vertex_list(*, 5).
4   The second polygon has 4 sides.
1   The first vertex is vertex_list(*, 1).
2   The second vertex is vertex_list(*, 2).
3   The third vertex is vertex_list(*, 3).
4   The fourth vertex is vertex_list(*, 4).
The rendering procedures POLYSHADE and POLY_PLOT both use a vertex_list and polygon_list as input parameters. Other routines that use either a vertex_list or a polygon_list include:
*POLY_C_CONV
*POLY_COUNT
*POLY_DEV
*POLY_NORM
*POLY_MERGE
*POLY_TRANS
The RENDER function also requires a vertex_list and a polygon_list if it is used to render polygonal meshes with the MESH function. Polygonal meshes representing objects that have been derived outside of PV‑WAVE can be imported, converted to the representation used by MESH, and then rendered with the RENDER function.
Examples of the RENDER function that use vertex_list and polygon_list to create polygonal meshes include "Example 1: Polygonal Mesh (Diffusely-shaded Polygons)", "Example 2: Polygonal Mesh (Flat-shaded Polygons)", and "Example 3: Polygonal Mesh (Many Polygons)".
Rectangular Surfaces
You can generate a vertex_list and a polygon_list for rectangular surfaces with the POLY_SURF procedure. This procedure generates a three-dimensional vertex_list and a polygon_list from a two-dimensional array that contains Z values. The example program poly_demo1 uses this procedure.
Spherical Surfaces
You can use the POLY_SPHERE procedure to generate a vertex_list and a polygon_list for a sphere. Demonstration programs that use this procedure are:
*grid_demo5
*sphere_demo1
*sphere_demo2
*sphere_demo3
Three-Dimensional Volumes
The SHADE_VOLUME procedure generates a vertex_list and polygon_list describing the contour iso-surface of a given three-dimensional volume. Example programs that use SHADE_VOLUME include:
*f_gridemo4
*grid_demo4
*vol_demo2
*vol_demo3
*vol_demo4
*gen_iso_head
For a complete description of the SHADE_VOLUME procedure and the other procedures mentioned in this section, see the PV‑WAVE Reference.

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.