## Overview

A **StixAsmProductIndex** is an index that simplifies work with
the product side of STEP assemblies — the logical structure of
products and their sub-assemblies.
The stix_asm_product_index()
function returns the product index object for a given file. The index
is built by calling
stix_asm_tag() after reading
the file into memory.

The index is a list of product use entries created by a depth first traversal over all assemblies. This gives us a unique number for each use of a product within repeated sub-assemblies. For any product use, we know its path up through the tree, the number of product uses for its entire subtree, the shape uses that describe its geometry, and the original STEP product definition and relationship objects.

## getAsmDepth()

unsignedgetAsmDepth(unsigned i);

The **getAsmDepth**() function returns the number of levels in
the shape tree above a given product usage. A root product has a depth
of zero, its children have a depth of one, and so on.

## getAsmNauo()

stp_product_definition_relationship *getAsmNauo(unsigned i);

The **getAsmNauo**() function returns the STEP "next assembly
usage occurrence" object that relates the product definition as a
subcomponent of its parent within an assembly. The function returns
null if the product is at the root of an assembly tree.

## getAsmNauoUses()

rose_uint_vector *getAsmNauoUses( stp_product_definition_relationship * nauo );

The **getAsmNauoUses**() function returns a list of product use
numbers for all of the appearances of the given STEP relationship in
all assemblies. The function returns null if the index has not been
built or if the relationship was created after the index was
built.

## getAsmParentUse()

unsignedgetAsmParentUse(unsigned i);

The **getAsmParentUse**() function returns the parent product
use for a given product use. The function
returns **ROSE_NOTFOUND** if the product is the root of an
assembly.

## getAsmPdef()

stp_product_definition *getAsmPdef(unsigned i);

The **getAsmPdef**() function returns the STEP product
definition object for a particular use in the product tree.

## getAsmPdefUses()

rose_uint_vector *getAsmPdefUses( stp_product_definition * pd );

The **getAsmPdefUses**() function returns a list of product use
numbers for all of the appearances of the given product definition in
all assemblies. The function returns null if the index has not been
built or if a product was created after the index was built.

## getAsmShapeSize()

unsignedgetAsmShapeSize(unsigned i);

The **getAsmShapeSize**() function returns the total number of
shape uses in the sub-assembly rooted at a given product use.

The shape index is built to follow the ordering of the product
index, rather than by an independant traversal of the shape tree. The
shapes for a product use "I" will be a continuous block in the shape
index starting at shape use `AsmShapeStart(I)`

and
extending for `AsmShapeSize(I)`

entries.

A product may have multiple shapes, even if it has no subcomponents. The shape tree for a product often has one shape representation containing a placement and a second one containing the advanced brep or other geometry. For example, the product and shape indexes for a simple assembly might look something like this.

Product Index Shape Index [0] Giant-Clam [0] shape-placement parent: none parent: none asm size: 3 product: [0] shape start: [0] shape size: 5 [1] Half-shell [1] shape-placement parent: [0] parent: [0] asm size: 1 product: [1] shape start: [1] shape size: 2 [2] shape-brep-solid parent: [1] product: [1] [2] Half-shell [3] shape-placement parent: [0] parent: [0] asm size: 1 product: [2] shape start: [3] shape size: 2 [4] shape-brep-solid parent: [3] product: [2]

## getAsmShapeStart()

unsignedgetAsmShapeStart(unsigned i);

The **getAsmShapeStart**() function returns the starting shape
uses in the shape index for the in the sub-assembly rooted at a given
product use. See getAsmShapeSize() for
more discussion.

## getAsmSize()

unsignedgetAsmSize(unsigned i);

The **getAsmSize**() function returns the total number of
product uses in the sub-assembly rooted at a given product use.

Because the index is built from a depth first traversal, the
sub-assembly for product use "I" is the continuous block of index
entries starting at `I`

and extending
for `AsmSize(I)`

entries. The size is one for leaf in the
assembly tree and greater than one if it has subcomponents.

## size()

unsignedsize();

The **size**() function returns the number of product uses in the
index.