The MESH_OBJ procedure generates a polygon mesh (vertex list and polygon list) that represent the desired primitive object. The available primitive objects are: triangulated surface, rectangular surface, polar surface, cylindrical surface, spherical surface, surface of extrusion, surface of revolution, and ruled surface.
This routine is written in the IDL language. Its source code can be found in the file mesh_obj.pro in the lib subdirectory of the IDL distribution.
Examples
MESH_OBJ, 3, Vertex_List, Polygon_List, $
Replicate(0.25, 48, 64), P4=0.5
T3D, /RESET
T3D, ROTATE=[0.0, 30.0, 0.0]
T3D, ROTATE=[0.0, 0.0, 40.0]
T3D, TRANSLATE=[0.25, 0.25, 0.25]
VERTEX_LIST = VERT_T3D(Vertex_List)
WINDOW, 0, XSIZE=512, YSIZE=512
CREATE_VIEW, WINX=512, WINY=512
SET_SHADING, LIGHT=[0.5, 0.5, 2.0], REJECT=0
TVSCL, POLYSHADE(Vertex_List, Polygon_List, /NORMAL)
MESH_OBJ, 6, Vertex_List, Polygon_List, $
[[0.75, 0.0, 0.25], [0.5, 0.0, 0.75]], $
P1=16, P2=[0.5, 0.0, 0.0]
WINDOW, 0, XSIZE=512, YSIZE=512
CREATE_VIEW, WINX=512, WINY=512, AX=30.0, AY=(140.0), ZOOM=0.5
SET_SHADING, LIGHT=[0.5, 0.5, 2.0], REJECT=0
TVSCL, POLYSHADE(Vertex_List, Polygon_List, /DATA, /T3D)
Syntax
MESH_OBJ, Type, Vertex_List, Polygon_List, Array1 [, Array2] [, /CLOSED] [, /DEGREES] [, P1, P2, P3, P4, P5=value]
Arguments
Type
An integer that specifies what type of object to create. The various surface types are described in the table below.
Type 
Surface Type 
0 
Triangulated 
1 
Rectangular 
2 
Polar 
3 
Cylindrical 
4 
Spherical 
5 
Extrusion 
6 
Revolution 
7 
Ruled 
Other values 
None 
Vertex_List
A named variable that will contain the mesh vertices. Vertex_List has the same format as the lists returned by the SHADE_VOLUME procedure.
Polygon_List
A named variable that will contain the mesh indexes. Polygon_List has the same format as the lists returned by the SHADE_VOLUME procedure.
Array1
An array whose use depends on the type of object being created. The following table describes the differences.
Surface Type 
Array1 Type

Triangulated 
A (3, n) array containing random [x, y, z] points to build a triangulated surface from. The resulting polygon mesh will have n vertices. When shading a triangulated mesh, the shading array should have (n) elements.

Rectangular 
A two dimensional (n, m) array containing z values. The resulting polygon mesh will have n x m vertices. When shading a rectangular mesh, the shading array should have (n, m) elements.

Polar 
A two dimensional (n, m) array containing z values. The resulting polygon mesh will have n x m vertices. The n dimension of the array is mapped to the polar angle, and the m dimension is mapped to the polar radius. When shading a polar mesh, the shading array should have (n, m) elements.

Cylindrical 
A two dimensional (n, m) array containing radius values. The resulting polygon mesh will have n x m vertices. The n dimension of the array is mapped to the polar angle, and the m dimension is mapped to the Z axis. When shading a cylindrical mesh, the shading array should have (n, m) elements.

Spherical 
A two dimensional (n, m) array containing radius values. The resulting polygon mesh will have n x m vertices. The n dimension of the array is mapped to the longitude (0.0 to 360.0 degrees), and the m dimension is mapped to the latitude (90.0 to +90.0 degrees). When shading a spherical mesh, the shading array should have (n, m) elements.

Extrusion 
A (3, n) array of connected 3D points which define the shape to extrude. The resulting polygon mesh will have n x (steps+1) vertices (where steps is the number of “segments” in the extrusion). (See the P1 keyword). If the order of the elements in Array1 is reversed, then the polygon facing is reversed. When shading an extrusion mesh, the shading array should have (n, steps+1) elements.

Revolution 
A (3, n) array of connected 3D points which define the shape to revolve. The resulting polygon mesh will have n x ((steps>3)+1) vertices (where steps is the number of “steps” in the revolution). (See the P1 keyword). If the order of the elements in Array1 is reversed, then the polygon facing is reversed. When shading a revolution mesh, the shading array should have (n, (steps>3)+1) elements.

Ruled 
A (3, n) array of connected 3D points which define the shape of the first ruled vector. The optional (3, m) Array2 parameter defines the shape of the second ruled vector. The resulting polygon mesh will have (n > m)*(steps+1) vertices (where steps is the number of intermediate “steps”). (See the P1 keyword). When shading a ruled mesh, the shading array should have (n > m, steps+1) elements.

Array2
If the object type is 7 (Ruled Surface) then Array2 is a (3, m) array containing the 3D points which define the second ruled vector. If Array2 has fewer elements than Array1 then Array2 is processed with CONGRID to give it the same number of elements as Array1. If Array1 has fewer elements than Array2 then Array1 is processed with CONGRID to give it the same number of elements as Array2. Array2 must be supplied if the object type is 7. Otherwise, Array2 is ignored.
Keywords
CLOSED
Set this keyword to “close” the polygonal mesh topologically by using the first vertex in a given row for both the first and last polygons in that row. This keyword is only applicable to the CYLINDRICAL, SPHERICAL, REVOLUTION, and EXTRUSION surface types. Setting the CLOSED keyword removes the discontinuity when the mesh wraps back around on itself, which can improve the mesh’s appearance when viewing it as a shaded object. For the EXTRUSION surface type, this procedure handles input polygons that form a closed loop with the last vertex being a copy of the first vertex, as well as those that do not.
DEGREES
If set, then the input parameters are in degrees (where applicable). Otherwise, the angles are in radians.
P1
P2
P3
P4
P5
The meaning of the keywords P1 through P5 vary depending upon the object type. The table below describes the differences.
Surface Type 
Keywords 
Triangulated 
P1 through P5 are ignored.

Rectangular 
If Array1 is an (n, m) array, and if P1 has n elements, then the values contained in P1 are the X coordinates for each column of vertices. Otherwise, FINDGEN(n) is used for the X coordinates. If P2 has m elements, then the values contained in P2 are the Y coordinates for each row of vertices. Otherwise, FINDGEN(m) is used for the Y coordinates. The polygon facing is reversed if the order of either P1 or P2 (but not both) is reversed. P3, P4, and P5 are ignored.

Polar 
P1 specifies the polar angle of the first column of Array1 (the default is 0). P2 specifies the polar angle of the last column of Array1 (the default is 2*PI). If P2 is less than P1 then the polygon facing is reversed. P3 specifies the radius of the first row of Array1 (the default is 0). P4 specifies the radius of the last row of Array1 (the default is m1). If P4 is less than P3 then the polygon facing is reversed. P5 is ignored.

Cylindrical 
P1 specifies the polar angle of the first column of Array1 (the default is 0). P2 specifies the polar angle of the last column of Array1 (the default is 2*PI). If P2 is less than P1 then the polygon facing is reversed. P3 specifies the Z coordinate of the first row of Array1 (the default is 0). P4 specifies the Z coordinate of the last row of Array1 (the default is m1). If P4 is less than P3 then the polygon facing is reversed. P5 is ignored.

Spherical 
P1 specifies the longitude of the first column of Array1 (the default is 0). P2 specifies the longitude of the last column of Array1 (the default is 2*PI). IF P2 is less than P1 then the polygon facing is reversed. P3 specifies the latitude of the first row of Array1 (the default is PI/2). P4 specifies the latitude of the last row of Array1 (the default is +PI/2). If P4 is less than P3 then the polygon facing is reversed. P5 is ignored.

Extrusion 
P1 specifies the number of steps in the extrusion (the default is 1). P2 is a three element vector specifying the direction (and length) of the extrusion (the default is [0, 0, 1]). P3, P4, and P5 are ignored.

Revolution 
P1 specifies the number of “facets” in the revolution (the default is 3). If P1 is less than 3 then 3 is used. P2 is a three element vector specifying a point that the rotation vector passes through (the default is [0, 0, 0]). P3 is a three element vector specifying the direction of the rotation vector (the default is [0, 0, 1]). P4 specifies the starting angle for the revolution (the default is 0). P5 specifies the ending angle for the revolution (the default is 2*PI). If P5 is less than P4 then the polygon facing is reversed.

Ruled 
P1 specifies the number of “steps” in the ruling (the default is 1). P2, P3, P4, and P5 are ignored.

Version History
See Also
CROSSP, MESH_CLIP, MESH_DECIMATE, MESH_ISSOLID, MESH_MERGE, MESH_NUMTRIANGLES, MESH_SMOOTH, MESH_SURFACEAREA, MESH_VALIDATE, MESH_VOLUME, VERT_T3D