Industrial Data Science
in C# and .NET:
Simple. Fast. Reliable.
 
 

ILNumerics - Technical Computing

Modern High Performance Tools for Technical

Computing and Visualization in Industry and Science

tgt

Accessing and Managing Nodes

Group provides the following functions for accessing child nodes. Children are located not only among its direct children but are searched recursively within the whole subtree.

The following example creates a number of nodes in a scene: a triangle, two points and a group node with a transparent sphere:

 

Fetching single nodes

Group is now used to find and access the nodes of the scene:

Group.First<T>() fetches the first node from the subtree, which matches the type

T. This function returns a scalar or null. Optional filter parameters exist:

The predicate and the tag filter parameters can be combined or omitted. Any filter that is omitted matches ALL nodes.

 

Fetching Multiple Nodes

Group.Find<T> allows the collection of multiple nodes, matching a certain criteria. The type argument T must be given as concrete type of the targets or as base class type, in order to find all triangles shapes:

To find and print the tag of all shapes, one can use Shape as common base type of points and triangles:

For our example, this results in:

Note: The sphere is not contained in the collection, since a sphere is a compound object which derives from Group and hence, is not a simple shape. However, it contains the shapes ‚Fill‘ and ‚Wireframe‘.

In order to increase the size of all points in the scene:

Group.Find<T>(tag, predicate) provides the same optional filter parameter, which allows a fine selection of the nodes. In order to find all shapes which are not direct children of our subtree root node:

This finds the Fill (Triangles) and the Wireframe (Lines) of the sphere, because they exist below the Sphere group node and not directly under the root group node.

Find<T>(tag, predicate) returns an IEnumerable<T>. Therefore, it is well prepared to work in conjunction with LINQ and foreach statements.