The complexity of PRC structures generally reflects the complexity of the original model file. Among other things, geometry is often instanced, materials are often referenced multiple times, and whole subassemblies can be nested hundreds of levels deep. As a result, parsing and interpreting the PRC structures is non-trivial. This section explains how to traverse the assembly tree and calculate the attributes of each entity.
After successfully loading a model file, you will have access to the model file pointer. This object grants access to the root product occurrences of the assembly tree. Be aware that throughout the tree, the way in which sibling nodes are ordered in their respective arrays is significant, as the attributes of the first node may affect sibling nodes.
PRC consists of four main types of entities which form a hierarchy.
The list below describes the hierarchy starting at the root:
Model file is the root PRC entity, represented by
A3DAsmModelFile. There is only one model file per assembly tree. The model file structure contains references to the product occurrences as well as global information such as the unit scale and the modelling system used to create the file.
Product occurrence is a logical group of geometric information. These nodes are the building blocks of the PRC assembly tree and represent the root data structure for an assembly and all the information contained within. A product occurrence node may contain many child product occurrences, or it could represent just a single part. It can also be used to instance other geometry by referencing other product occurrences. The class name is
Part definitions contain metadata about the geometry such as as annotations, views, the bounding box, as well as a reference to the part’s geometric representation. The class name is
A3DAsmPartDefinition. A product occurrence may only contain a single part definition.
Representation items encapsulate information about how to draw the geometry. This includes the model transform, tessellation data, and B-rep information, if available. Particularly complex parts in the model may consist of multiple representation items. The class name is
Each entity exists as a single node in the assembly tree. In HOOPS Exchange, the nodes themselves contain no data - the developer must explicitly call for the actual data container to be filled. That process is described here.
Please note that in this section and throughout this manual, we will attempt to explain how to perform common tasks using HOOPS Exchange.
The manual does not go into fine detail regarding the PRC file format.
If you are planning a deep integration with HOOPS Exchange, you should familiarize yourself with the PRC standard.
That standard can be found in the
PRC format specifications document.
Most model files provide the measurement units for the geometry contained within. The unit type may be global - meaning it is applied to all geometry - or it may be provided for each assembly or even for each individual part.
You can determine if the model you’re loading uses a global scale by examining the
If the model uses a global scale, then this field will be A3D_TRUE, and you can find the actual units in the
The units are specified in multiples of millimeters.
Accordingly, a value of ‘1’ indicates millimeters, ‘10’ indicates centimeters, and so on.
It is not possible to have more than one valid unit. When assemblies of multiple parts specify different units, HOOPS Exchange will scale all units into a single unit type for simplicity.
How to Interpret Non-Global Unit Scale
If the m_bUnitFromCad field is A3D_FALSE, then you must parse the assembly tree to find the unit scale.
In this case, the unit value can be found on the first product occurrence encountered that has the flag
A3DAsmProductOccurrenceData.m_bUnitFromCAD set to A3D_TRUE.
To better understand, consider the diagram below:
Although “Product Occurrence 4” is located higher in the assembly tree, and m_bUnitFromCAD is A3D_TRUE, “Product Occurrence 3” will be parsed first - therefore, the unit scale that applies to the model is the one on “Product Occurrence 3”.
In some cases, you can override any unit setting from the model by setting the read parameter A3DRWParamsLoadData.A3DRWParamsGeneralData.m_eDefaultUnit accordingly. By setting the value to kA3DUnitUnknown, you will guarantee the native unit of the CAD file is used. See this field’s reference manual entry for details.
Dealing With B-Rep Units
When parsing a representation item with B-rep, you have to find the units in another way.
The scale you need access to is stored in each
The following code snippet demonstrates how you would get the unit scale in this case, in this case starting from a
A3DRiCurveData sDataRiCurve; A3D_INITIALIZE_DATA(sDataRiCurve); A3DRiCurveGet(pRiCrv, &sDataRiCurve); A3DTopoSingleWireBodyData sDataTopoSingleWireBody; A3D_INITIALIZE_DATA(sDataTopoSingleWireBody); A3DTopoSingleWireBodyGet(sDataRiCurve.m_pBody, &sDataTopoSingleWireBody); A3DTopoBodyData sBodyData; A3D_INITIALIZE_DATA(A3DTopoBodyData, sBodyData); A3DTopoBodyGet(sDataRiCurve.m_pBody, &sBodyData); A3DTopoContextData sContextData; A3D_INITIALIZE_DATA(A3DTopoContextData, sContextData); A3DTopoContextGet(sBodyData.m_pContext, &sContextData); double scale = 1.0; if (sContextData.m_bHaveScale) scale = sContextData.m_dScale;
Additional Notes Regarding Scale
In addition to the notes above regarding scale, you also need to consider any scale present on an entity’s individual transformation.
Compatibility With Different PRC Format Versions
HOOPS Exchange provides backward compatibility with other PRC format versions. In a major release, the HOOPS Exchange support for PRC is backward compatible. Each new version of the software can read PRC files that conform to an earlier PRC format version.