SilverScreen Solid Modeler

Edges and Vertices

Edges and Vertices

Previous topic Next topic  

Edges and Vertices

Previous topic Next topic JavaScript is required for the print function  

SilverScreenAPI

 

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:

 

C / C++ Code

 

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

    ss_command ( "note edge: %d  %z %z",
                i,
                vertex1_of_edge (obj,i),
                vertex2_of_edge (obj,i) );

 

 

For obj, the addresses of the coordinates of the vertices of edge i can be expressed as:

 

C / C++ Code

 

 xyz_of_vertex (vertex1_of_edge (obj,i));

 xyz_of_vertex (vertex2_of_edge (obj,i));

 

 

However, two additional functions, xyz1_of_edge and xyz2_of_edge, allow simpler expressions that are equivalent to those shown above:

 

C / C++ Code

 

 xyz1_of_edge ( obj, i );

 xyz2_of_edge ( obj, i );

 

 

The following can thus be used to display the coordinates of the edges of obj:

 

C / C++ Code

 

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

    ss_command ( "note edge: %d %z %z", i,

                  xyz1_of_edge ( obj, i ),
                  xyz2_of_edge ( obj, i ) );

 

 

 


Primitive Structures

The structures of the point, line and round (circle/arc) nodes are shown below:

 

C / C++ Code

 

 POINT_NODE
    {
    // Common PRIM_NODE section omitted.

    VERTEX      point;
    int         point_type;
    USINT       point_width_style;
    double      point_size;
    RGB         point_rgb;
    };

 

 

 

C / C++ Code

 

 LINE_NODE
    {
    // Common PRIM_NODE section omitted.

    EDGE        edge;
    };

 

 

 

C / C++ Code

 

 ROUND_NODE
    {
    // Common PRIM_NODE section omitted.

    XYZ            horizontal;
    XYZ            vertical;
    double         start_angle;
    double         stop_angle;
    SURFACE_NODE   *sn;
    RGB            surface_rgb;
    RGB            round_rgb;
    int            surface_pattern_number;
    USINT          round_width_style;
    VERTEX         center;
    int            round_type;
    TEXTURE_DATA   *texture;
    };

 

 

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.