|
||
Edges and Vertices
|
|
|||||||||||
Vertices Each object in SilverScreen has a set of vertices. Each vertex in the set may be addressed by its vertex number. For an object that has n vertices, the range of vertex numbers is 1 through n.
For a given object and a given vertex number, the function xyz_of_vertex returns a pointer to the xyz-coordinate associated with that vertex. The following will display the coordinates of all vertices in the object obj:
|
|
|||||||||||
Edges Each object also has a set of edges. Each edge is addressable with an edge number, and is associated with two vertex numbers.
For a given object and a given edge number, the function vertex1_of_edge will return the vertex number of the first vertex, while vertex2_of_edge will return the vertex number of the second. The following displays the vertex numbers of all edges in obj:
For obj, the addresses of the coordinates of the vertices of edge i can be expressed as:
However, two additional functions, xyz1_of_edge and xyz2_of_edge, allow simpler expressions that are equivalent to those shown above:
The following can thus be used to display the coordinates of the edges of obj:
|
|
|||||||||||
Primitive Structures The structures of the point, line and round (circle/arc) nodes are shown below:
Each of these primitives uses references to the edge and vertex lists. LINE_NODE has an edge number that can be used to retrieve the endpoints of the line. POINT_NODE and ROUND_NODE have vertex numbers that can be used to retrieve the coordinate of a point. We give several examples.
LINE_NODE contains an edge number edge. For LINE_NODE *p , the addresses of endpoints of p are given by the expressions:
The ROUND_NODE contains a vertex number center. For ROUND_NODE *r , the address of the center coordinate is given by:
In both cases above, note that r->parent is a pointer to the OBJECT_NODE that contains p.
Note: The distributed sample program lister.c , which lists the components of a SilverScreen drawing, provides a guide to navigating the drawing data structure. |
|