SilverScreen Solid Modeler

Primitive Structures

Primitive Structures

Previous topic Next topic  

Primitive Structures

Previous topic Next topic JavaScript is required for the print function  

SilverScreenAPI

 

Primitive Structures

 

 


Primitives are only contained in objects. The following primitives are supported in SilverScreen. Each of these primitive types has a structure definition. The names of these structures are:

 

Primitive

Corresponding structure

arc

ROUND_NODE

circle/ellipse

ROUND_NODE

line

LINE_NODE

point

POINT_NODE

polygon

POLYGON_NODE

polyline

POLYLINE_NODE

Bezier point

BPOINT_NODE

Spline point

SPOINT_NODE

Bezier curve

CURVE_NODE

Spline curve

CURVE_NODE

 

All primitives are directly or indirectly contained in objects. However, primitives may be contained within other primitives. A polyline, for example, consists of a set of lines; a Bezier curve consists of a set of Bezier points.

 

The following summarizes the rules of association for primitives:

 

r_point An arc may be an independent primitive.

r_point An arc may be contained in a polyline or polygon.

 

r_point A circle/ellipse is an independent primitive.

 

r_point A line may be an independent primitive.

r_point A line may be contained in a polyline or polygon.

 

r_point A polygon consists of lines and arcs.

r_point A polyline consists of lines and arcs.

r_point A point is an independent primitive.

 

r_point A spline curve consists of a set of control points.

r_point A Bezier curve consists of a set of control points.

 

Holes give a second level of association for certain primitives. Here are the rules of association for holes:

 

r_point A circle/ellipse may contain one or more holes.

r_point A polygon may contain one or more holes.

r_point A closed spline curve may contain one or more holes.

r_point A closed Bezier curve may contain one or more holes.

 

r_point A circle/ellipse may be a hole.

r_point A polygon may be a hole.

r_point A closed spline curve may be a hole.

r_point A closed Bezier curve may be a hole.

 

r_point No other primitive may be a hole.

 

Another level of associativity is the phantom. Phantoms give additional information about a primitive.

To understand the use of the phantom, consider the following: A rectangle is drawn and filleted on all four corners. This results in a polygon that consists of four lines and four arcs. This polygon is then swept linearly to produce a solid. Since the SilverScreen solid consists of polygons that contain only lines, the arc information would seemingly be lost in producing the solid.

 

However, to retain this arc information, a new association is formed. This association relates the polygon to the arcs that, prior to the sweep, were part of the polygon. Arcs (and circles) of this type are called phantoms. Phantoms, while not visible on the screen, may be used for dimensioning or for export to CAM.

Here are the rules of association for phantoms:

 

r_point A phantom may be either a circle/ellipse or an arc.

r_point A phantom may be contained in either a polygon or a polyline.

r_point A phantom may not contain holes.

 

 


PRIM_NODE

All primitive structures have a common prefix consisting of 5 fields. This common structure is PRIM_NODE, a structure which is shown below.

 

C / C++ Code

 

 PRIM_NODE

    {

    int          bits,

    int          id;

    PRIM_NODE     *next_node,

    PRIM_NODE     *prev_node;

    OBJECT_NODE   *parent;

    };

 

 

This structure contains:

 

Member

Description

bits

identifies node type and contains node information.

id

within the parent object, a unique primitive identifier.

next_node

a pointer to the next node within the object.

prev_node

a pointer to the previous node within the object.

parent

a pointer to the parent (an object).

 

The following shows the definitions that are used to identify the various node types:

 

C / C++ Code

 

 #define BITS_LINE              0x0001
 #define BITS_POLYGON           0x0002
 #define BITS_SPLINE            0x0004
 #define BITS_ROUND             0x0010
 #define BITS_CIRCLE            0x1000
 #define BITS_ARC               0x2000
 #define BITS_SPOINT            0x0020
 #define BITS_BEZIER            0x0040
 #define BITS_BPOINT            0x0080
 #define BITS_POLYLINE          0x0400
 #define BITS_POINT             0x0800

 

 
The OBJECT_NODE has a first_node pointer that gives access to all of the primitives within an object. Each primitive has a pointer to the next primitive (next_node) that is directly contained within the object. The next_node list terminates with a null pointer.

 

The following illustrates a traversal of the primitives that linked directly to an object node:

 

C / C++ Code

 

 void display_primitives( OBJECT_NODE *obj )

 {

 PRIM_NODE *prim;

 

 for ( prim = obj->first_node ; prim ; prim = prim->next_node )

    {

    if ( prim->bits & BITS_LINE )

       ss_command ( "note Line with id %d", prim->id );

    else if ( prim->bits & BITS_POLYGON )

       ss_command ( "note Polygon with id %d", prim->id );

    else if ( prim->bits & BITS_POLYLINE )

       ss_command ( "note Polyline with id %d", prim->id );

    else

       ss_command ( "note Other type with id %d", prim->id );

    }

 }

 

 

The above function only identifies three primitive types. The remaining types are lumped together as "Other type".

 

The structure of the polygon node is displayed below:

 

C / C++ Code

 

 POLYGON_NODE
    {
    // Common PRIM_NODE section omitted.

    PRIM_NODE      *first_hole;
    SURFACE_NODE   *sn;
    RGB            surface_rgb;
    int            surface_pattern_number;
    PRIM_NODE      *first_node;
    PRIM_NODE      *first_phantom;
    TEXTURE_DATA   *texture;
    };

 

 

The following function will list the lines that are contained in polygons that are directly within the object. This function uses a first_node pointer in the POLYGON_NODE to locate the first primitive in a list of primitives within the polygon. These primitives (within the polygon) are linked via the next_node pointer and terminate with a null pointer.

 

C / C++ Code

 

void display_lines_in_polygons( OBJECT_NODE *obj )

 {

 PRIM_NODE *prim;

 

 for ( prim = obj->first_node ; prim ; prim = prim->next_node )

    {

    if ( prim->bits & BITS_POLYGON )

       {

       ss_command ( "note Polygon with id %d", prim->id )

       poly = (POLYGON_NODE *)prim;

       for ( prim2 = poly->first_node ; prim2 ; prim2 = prim2->next_node )

          {

          if ( prim2->bits & BITS_LINE)

             ss_command ( "note Line with id %d", prim2->id );

          }

       }

    }

 }

 

 
This function ignores all primitives other than polygons. Also, for each polygon, the function lists only lines, ignoring any arcs that might appear in the polygon.