Overview

A IfcxAsmProductIndex is an index that simplifies work with the spatial arrangement of IFC products. The ifcx_asm_product_index() function returns the product index object for a given file. The index is built by calling ifcx_asm_tag() after reading the file into memory.

The index is a list of products 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 products in its entire subtree, the kind of relationship (aggregates/contains) that associates it with its parent, and its transform.

All IFC assemblies are strictly hierarchic and no piece should be reused or have more than one parent. This differs significantly from STEP which frequently reuses products.

Refer to the IFC assembly page for an example that prints the spatial structure of an IFC file.

getAsmAsProduct/Project()

IfcProduct * getAsmAsProduct(unsigned idx);
IfcProject * getAsmAsProject(unsigned idx);

The getAsmAsProduct() and getAsmAsProject() functions return the given element of the index cast as the given C++ type. The index contains mostly products, but the root of a spatial structure should be a project. Use the isProduct() function to test the type of a given element. Use the getAsmObjDef() function if you don't care about the specific type.

getAsmDepth()

unsigned getAsmDepth (unsigned i);

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

getAsmGlobalXform()

const double * getAsmGlobalXform(unsigned i);

The getAsmGlobalXform() function returns a pointer to a double[16] with the transform matrix to place the product shape within the global space. The pointer only remains valid as long as the index is not changed, so use or copy the matrix immediately.

getAsmObjDef()

IfcObjectDefinition * getAsmObjDef(unsigned idx);

The getAsmObjDef() function returns the element index as an object definition pointer, which is a superclass of both project and product. Use the getAsmAsProduct() or getAsmAsProject() functions to get the value cast to a more specific type.

getAsmObjDefUse()

unsigned getAsmObjDefUse(
	IfcObjectDefinition * pd
	);
	
rose_uint_vector * getAsmObjDefUses(
	IfcObjectDefinition * pd
	);

The getAsmObjDefUse() function returns the position within the index of the given product or project. Normally, there is only a single use of an object within an IFC assembly. The getAsmObjDefUses() can return a list of all uses in case the data is not well formed.

getAsmParentUse()

unsigned getAsmParentUse(unsigned i);

The getAsmParentUse() function returns the position within the index of the parent for a given object use. The function returns ROSE_NOTFOUND if the object is the root of an assembly.

getAsmRel()

IfcRelationship * getAsmRel(unsigned idx);

The getAsmRel() function returns the relationship object that associates this use with its parent. Since it may be either an aggregates or contains relationship, this function returns the supertype. The getAsmRelAgg() and getAsmRelContained() functions return the value as a subtype pointer. The isContained() function tests whether a relationship is aggregates or contains.

getAsmRelAgg()

IfcRelAggregates * getAsmRelAgg(unsigned idx);

The getAsmRelAgg() function returns the relationship object that associates this use with its parent, cast as an aggregates relationship. If it is not an aggregates relationship, the function returns null.

getAsmRelContained()

IfcRelContainedInSpatialStructure * getAsmRelContained(unsigned idx);

The getAsmRelContained() function returns the relationship object that associates this use with its parent, cast as a contained relationship. If it is not a contained relationship, the function returns null.

getAsmSize()

unsigned getAsmSize(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.

getRootProjectUse()

unsigned getRootProjectUse(unsigned idx);

The getRootProjectUse() function returns the position of the root project within the index for a given product use. Normally an IFC file will have a single project that is the root of all products, so this function would return zero, the first element in the index.

getRootProject()

IfcProject * getRootProject(unsigned idx);

The getRootProject() function returns the project object that is the root of the spatial structure for a given product use. Normally an IFC file will only have a single project.

hasVoids()

int hasVoids(unsigned idx);

The hasVoids() function returns nonzero if the given product use has voids relationships defined on it. Use ifcx_asm_void_objs_get() on the object definition to retrieve the subtraction objects.

isContained()

int isContained(unsigned idx);   // contained vs aggregates

The isContained() function returns nonzero if the given product use is associated with its parent by a contains relationship, and false if it is associated by an aggregates relationship.

isProduct()

int isProduct(unsigned idx);   // product vs project

The isProduct() function returns nonzero if the given object definition is an IfcProduct, and zero if it is an IfcProject.

size()

unsigned size();

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