Hide menu
Loading...
Searching...
No Matches
Bill of Materials (BOM) Example

Table of Contents

Traverses the product structure and computes the number of instances of unique parts and assemblies.

Description

As shown in model data guide product structure is provided by a graph of elements. The graph is often called a Scene Graph and elements are called Scene Graph Elements.

To traverse the Scene Graph here we use an ability of each Scene Graph Element to accept a visitor and call to corresponding visitor's methods.

Assembly: as1
--- Instance: noname
--- --- Assembly: rod-assembly
--- --- --- Instance: noname
--- --- --- --- Part: nut
--- --- --- Instance: noname
--- --- --- --- Part: nut
--- --- --- Instance: noname
--- --- --- --- Part: rod
--- Instance: noname
--- --- Assembly: l-bracket-assembly
--- --- --- Instance: noname
--- --- --- --- Assembly: nut-bolt-assembly
--- --- --- --- --- Instance: noname
--- --- --- --- --- --- Part: bolt
--- --- --- --- --- Instance: noname
--- --- --- --- --- --- Part: nut
--- --- --- Instance: noname
--- --- --- --- Assembly: nut-bolt-assembly
--- --- --- --- --- Instance: noname
--- --- --- --- --- --- Part: bolt
--- --- --- --- --- Instance: noname
--- --- --- --- --- --- Part: nut
--- --- --- Instance: noname
--- --- --- --- Assembly: nut-bolt-assembly
--- --- --- --- --- Instance: noname
--- --- --- --- --- --- Part: bolt
--- --- --- --- --- Instance: noname
--- --- --- --- --- --- Part: nut
--- --- --- Instance: noname
--- --- --- --- Part: l-bracket
--- Instance: noname
--- --- Part: plate
--- Instance: noname
--- --- Assembly: l-bracket-assembly
--- --- --- Instance: noname
--- --- --- --- Assembly: nut-bolt-assembly
--- --- --- --- --- Instance: noname
--- --- --- --- --- --- Part: bolt
--- --- --- --- --- Instance: noname
--- --- --- --- --- --- Part: nut
--- --- --- Instance: noname
--- --- --- --- Assembly: nut-bolt-assembly
--- --- --- --- --- Instance: noname
--- --- --- --- --- --- Part: bolt
--- --- --- --- --- Instance: noname
--- --- --- --- --- --- Part: nut
--- --- --- Instance: noname
--- --- --- --- Assembly: nut-bolt-assembly
--- --- --- --- --- Instance: noname
--- --- --- --- --- --- Part: bolt
--- --- --- --- --- Instance: noname
--- --- --- --- --- --- Part: nut
--- --- --- Instance: noname
--- --- --- --- Part: l-bracket

To count the number of unique elements in a Scene Graph we use a specific hash function.

Total:
name | type | count
l-bracket-assembly | Assembly | 2
as1 | Assembly | 1
nut | Part | 8
rod-assembly | Assembly | 1
l-bracket | Part | 2
rod | Part | 1
nut-bolt-assembly | Assembly | 6
plate | Part | 1
bolt | Part | 6

The use of a visitor is one of two possible ways of a Scene Graph traversal. Another way is to use an Iterator (example will be soon).

To learn more about Scene Graph concept please visit Product Structure section.

Usage

You can try this example with the following model:

./examples/models/as1.xml

Files