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 A3DAsmProductOccurrence.
- 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 A3DRiRepresentationItem.
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 Specification 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 A3DAsmModelFileData::m_bUnitFromCAD field. If the model uses a global scale, then this field will be true, and you can find the actual units in the A3DAsmModelFileData::m_dUnit field. 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 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 true. To better understand, consider the diagram below:
Although "Product Occurrence 4" is located higher in the assembly tree, and m_bUnitFromCAD is 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 A3DTopoContextData structure. The following code snippet demonstrates how you would get the unit scale in this case, in this case starting from a A3DRiCurveData structure:
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.