SilverScreen Solid Modeler

Entity Structures

Entity Structures

Previous topic Next topic  

Entity Structures

Previous topic Next topic JavaScript is required for the print function  

SilverScreenAPI

 

Entity Structures

 

 


BOS_NODE

 

Although the structure for each type of entity is unique, there is a structural prefix that is common to all entity types. For convenience, these common fields are defined as an independent structure called the BOS_NODE . Informally, we speak of the of entity nodes as being BOS nodes. In actuality, there is no entity whose structure corresponds exactly with the structure of the BOS_NODE .  Here is the BOS_NODE structure:

 

C / C++ Code

 

BOS_NODE

    {

    int          bits1;

    int          bits2;

    SS_XYZ       high;

    SS_XYZ       low;

    SS_XYZ       center;

    SS_XYZ       top_axis;

    SS_XYZ       bottom_axis;

    SS_XYZ       local_horz;

    SS_XYZ       local_vert;

    SS_XYZ       local_base;

    NAME         name;

    int          force_style_color;

    RGB          force_rgb;

    BOS_NODE     *next_bos;

    BOS_NODE     *prev_bos;

    BLOCK_NODE   *parent;

    };

 

 

This structure contains:

 

Element

Description

bits1, bits2

entity type and entity information.

high, low

extent information for the entity.

name

the name of the entity.

center

the base point used in scaling and rotation.

top_axis, bottom_axis

the axis used in axial rotation.

local_horz, local_vert, local_base

e-space information for entity.

next_bos

a pointer to the next entity within the block.

prev_bos

a pointer to the previous entity within the block.

parent

a pointer to the parent block.

 

An entity may be a block, an object, a symbol, a detail, or a text line.  To distinguish between the different entity types, the bits1 field in the BOS_NODE can be examined.  A specific bit of this field is set for each of the five entity types.  The BITS_OBJECT bit (0x0002) is used to identify objects.  If this bit is set then the entity is an object.  Similar bit settings are defined in SSNODES.H for the other entity types:

 

C / C++ Code

 

 #define BITS_BLOCK             0x0001
 #define BITS_OBJECT            0x0002
 #define BITS_SYMBOL            0x0004
 #define BITS_TEXT              0x0400
 #define BITS_DETAIL            0x0100

 

 
Here is an example showing how entities might be identified:

 

C / C++ Code

 

 BOS_NODE *bos;
 
 if ( bos->bits1 & BITS_BLOCK )
    ss_command (“note This is a block”);
 else if ( bos->bits1 & BITS_OBJECT )
    ss_command(“note This is an object”);
 else if ( bos->bits1 & BITS_SYMBOL )
    ss_command(“note This is a symbol”);
 else if ( bos->bits1 & BITS_TEXT )
    ss_command(“note This is text”);
 else if ( bos->bits1 & BITS_DETAIL )
    ss_command(“note This is a detail”);

 

 

The annotation block (A-Block) has a special purpose within the SilverScreen hierarchical structure.  This type of block is used to store the details (and possibly other entities) that belong to a specific annotation block.  A-blocks always appear at the root and can be identified through the bits2 field and the BITS_ANNOTATE definition.  An A-Block is identified below:

 

C / C++ Code

 

 BOS_NODE *bos;
 
 if ( bos->bits1 & BITS_BLOCK )
    {
    if ( bos->bits2 & BITS_ANNOTATE )
       ss_command (“note This is an annotation block”);
    else
       ss_command(“note This is not an annotation block”);
    }

 

 

 


BLOCK_NODE
 
The BLOCK_NODE structure is shown below.  Note that the first portion of the structure is identical to that of the BOS_NODE.
 

C / C++ Code

 

BLOCK_NODE

  {

  int          bits1;

  int          bits2;

  SS_XYZ       high;

  SS_XYZ       low;

  SS_XYZ       center;

  SS_XYZ       top_axis;

  SS_XYZ       bottom_axis;

  SS_XYZ       local_horz;

  SS_XYZ       local_vert;

  SS_XYZ       local_base;

  NAME         name;

  int          force_style_color;

  RGB          force_rgb;

  BOS_NODE     *next_bos;

  BOS_NODE     *prev_bos;

 
  BLOCK_NODE   *parent;

  BOS_NODE     *first_bos;

  SCHEMA_NODE  *first_schema;

  void         *unused1;

  };

 

 

The BLOCK_NODE structure contains first_bos , a pointer to the first entity within the block.

 

To access the entities within a block, the first_bos pointer is used to locate the first entity of the block. Once this first entity has been located, the next_bos pointer can then be used to traverse the list of entities within the block.  The list terminates with a null pointer.

 

The following will display the entity names of a drawing in in-order sequence. Note that the function display_block is used recursively.

 

C / C++ Code

 

 #include "silver.h"

 #include "ssnodes.h"

 

 . . .

 

 BLOCK_NODE *root;

 // Get pointer to root of tree

 root = (BLOCK_NODE *) get_bos ( "\\" );

 display_block( root );

 . . .

 

 void display_block( BLOCK_NODE *blk )

 {

 BOS_NODE *bos;

 

 ss_command ( "note Block Name: %s", bos->parent?bos->name:”ROOT” );

 

 for ( bos = blk->first_bos ; bos ; bos = bos->next_bos )

    {

    if ( bos->bits1 & BITS_BLOCK )

       display_block( (BLOCK_NODE *)bos );

    else

       ss_command ( "note name: %s", bos->name );
    }

 }

 

 
Note the manner in which the BOS_NODE pointer bos is cast to a BLOCK_NODE pointer. This technique is frequently used in accessing drawing structures. That is, the bits of the BOS_NODE are examined to determine the entity type of the node. If the bit setting in bits1 corresponds to that of an OBJECT_NODE , then the BOS_NODE pointer is cast to an OBJECT_NODE pointer.

 

 


OBJECT_NODE

The OBJECT_NODE is the organizational unit for the drawing primitives within a drawing. Each object has a pointer to the first primitive within the list of primitives contained in the object. These primitives may have pointers to other primitives. The organization of this structure is described in the next section.

 

 


SYMBOL_NODE

The SYMBOL_NODE contains a pointer to a MODEL_NODE. The MODEL_NODE contains a pointer to a BLOCK_NODE which in turn contains a pointer to the first BOS_NODE within the model. The geometry of the model is viewed through the transformation matrix contained in the SYMBOL_NODE. Since the MODEL_NODE may contain symbols that have their own transformation matrices, the viewing of points should be handled with composite transformation matrices using a push-pop technique.