|
||
|
Traversing Entities with BosList
|
|
||
One of the ways that SilverSharp extends the SilverEngine platform is by providing enumerators which allow C# programmers to make use of the foreach statement to traverse the geometry of a SilverScreen drawing much more simply. While recursion is an elegant way to traverse a tree, it can be a difficult concept to grasp (there isn't anything like a self-referential definition in the natural world). We at SDC think that the BosList class will quickly become a favorite because its methods simplify a complex task without losing functionality. |
|
|||
The best way to illustrate the worth of this new technique is to compare it with the old technique. The first example will use SilverC code to traverse the current drawing, recursively searching for objects beginning with the prefix "door" and counting them. The second example will use C# code to perform the same function. |
|
|||
The following code counts objects whose names begin with the prefix "door". It uses recursion to visit all of the OBJECT_NODEs in a SilverScreen drawing.
|
|
|||
The following code also counts objects whose names begin with the prefix "door":
For a detailed look at the use of BosList to traverse a SilverScreen drawing see the Lister SilverSharp sample.
For a detailed look at the use of recursion to traverse a SilverScreen drawing see the Lister SilverC sample.
|
|
|||
|