SilverScreen Solid Modeler

SilverC Class Compatibility

SilverC Class Compatibility

Previous topic Next topic  

SilverC Class Compatibility

Previous topic Next topic JavaScript is required for the print function  

SilverSharpAPI

 

SilverC Class Compatibility


We have kept the SilverSharp entity and primitive structures as familiar as possible to their SilverC counterparts. We have reused class names, such as OBJECT_NODE and PRIM_NODE, and field names within those classes, such as bits1 and next_node.

 

A SilverSharp BOS_NODE, for instance, contains a name property to retrieve the entity name. In SilverC environments, this would have been stored in a character buffer of type NAME. In SilverSharp environments this is stored in a System.String. So, the structure name is familiar, the field name is familiar, and the purpose of the field is equivalent. What differs is the SilverSharp data is in CLR format.

 

After implementing this strategy for our data types, we then set about extending the functionality. We added support for enumerators, we replaced preprocessor macros with enumerations, and we added convenient methods (i.e. Translate to the SilverSharp MATRIX object).

 

The upshot is, we hope, an environment that is both familiar to experienced SilverC developers and practical for experienced Visual C# developers.

 


It is  instructive to compare SilverC code with SilverSharp code to examine the similarities and differences. The following code shows how to traverse all primitives of an object using SilverC:

 

SilverC Code

 #include "silver.h"

 

 . . .

 

 PRIM_NODE *prim;

 OBJECT_NODE *obj;

 

 obj = (OBJECT_NODE *)get_bos("\\obj1");

 

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

    {

    VisitOnePrimitive(prim);

    }

 

 

 

The following code shows how to perform the same work, keeping as many similarities as possible. Some changes, such as the use of '.' rather than '->' are syntax differences between C and C#.

 

C# Code

 

 using SilverSharp;

 

 . . .

 

 PRIM_NODE   prim;

 OBJECT_NODE obj;

 

 obj = (OBJECT_NODE)SC.get_bos("\\obj1");

 

 for (prim = obj.first_node; prim != null; prim = prim.next_node)

    {

    VisitOnePrimitive(prim);

    }

 

 

Finally, the following code shows the same work once again, but this time uses the enumerators available to SilverSharp and favored by C# programmers:

 

C# Code

 

 using SilverSharp;

 

 . . .

 

 PrimList pl = PrimList.FromChildren("\\obj1");

   

 foreach ( PRIM_NODE prim in pl )

    {

    VisitOnePrimitive(prim);

    }

 

 

 

Learning Tip

Enabling statement completion in Visual Studio can aid the transition from SilverC to SilverSharp greatly. As you type you will be able to see method syntax and object members automatically.