Edges and Vertices

Edges and Vertices

Edges and Vertices

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:

C / C++ Code

OBJECT_NODE *obj;

int i;

for ( i = 1 ; i <= obj->vertices ; i++ )

ss_command ( "note vertex: %d %z", i, xyz_of_vertex (obj,i) );

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:

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:

C / C++ Code

xyz1_of_edge ( p->parent, p->edge );

xyz2_of_edge ( p->parent, p->edge );

The ROUND_NODE contains a vertex number center. For ROUND_NODE *r , the address of the center coordinate is given by:

C / C++ Code

xyz_of_vertex ( r->parent, r->center );

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.