NestedElementTreeGenerator - STARIONGROUP/COMET-SDK-Community-Edition GitHub Wiki

Introduction

With the CDP4-COMET users can model an architecture of a complex system. This is done by means of ElementDefinitions and ElementUsages. With these two concepts an implicit architecture can be modelled. Each ElementDefinition can contain multiple ElementUsages that reference other ElementDefinitions than the one they are contained by.

Below you see an example of a car that contains a chassis which in turn contains 4 wheels:

var car = new ElementDefinition();
elementDefinition.Shortname = "CAR";
elementDefinition.Name = "Car"

var chassis = new ElementDefinition();
elementDefinition.Shortname = "CHASS";
elementDefinition.Name = "Chassis";

var chassis_1 = new ElementUsage();
chassis_1.ElementDefinition = chassis;

var body = new ElementDefinition();
elementDefinition.Shortname = "BOD";
elementDefinition.Name = "Body";

var body_1 = new ElementUsage();
body_1.ElementDefinition = body;

var wheel = new ElementDefinition();
elementDefinition.Shortname = "WHEEL";
elementDefinition.Name = "Wheel"

var wheel_1 = new ElementUsage();
wheelLeftFront.ElementDefinition = wheel;

var Wheel_2 = new ElementUsage();
wheelLeftFront.ElementDefinition = wheel;

var Wheel_3 = new ElementUsage();
wheelLeftFront.ElementDefinition = wheel;

var Wheel_4 = new ElementUsage();
wheelLeftFront.ElementDefinition = wheel;

car.ContainedElement.Add(chassis_1);
car.ContainedElement.Add(body_1);

chassis.ContainedElement.Add(wheel_1);
chassis.ContainedElement.Add(wheel_2);
chassis.ContainedElement.Add(wheel_3);
chassis.ContainedElement.Add(wheel_4);

From this implicit structure it is possible to create an explicit tree. This is done by recursively iterating through the ElementDefintions, their contained ElementUsages and the ElementDefintions that these reference. This tree can be created starting at any ElementDefinition. The CDP4® Data Model makes it possible to state that one ElementDefinition that is contained by an Iteration is the TopElement of that Iteration, also known as the root-node. From this root-node the complete explicit tree of a model can be generated.

An Iteration can also contain Options. Options make it possible to create design variances by explicitely stating that an ElementUsage that is contained by an ElementDefinition should be excluded from an Option. When an ElementUsage is excluded, it should be excluded when the explicit Option tree is created.

NestedElementTreeGenerator

The NestedElementTreeGenerator is used to create an explicit Option tree based on the ElementDefinitions, ElementUsages and Parameters contained in an iteration. The algorithm starts at the ElementDefinition that is the root node of an iteration and recursively iterates through the ElementUsages and referenced ElementDefinitions. These are translated into NestedElement objects; the contained Parameters, ParameterOverrides and ParameterSubscriptions are translated into NestedParameter objects. The result is an explicit tree of NestedElements and NesterParamters where one NestedElement is marked as being the root. The root NestedElement is a translation of the ElementDefinition that is the TopElement of the Iteration.