PROGRAMMING GUIDE
The Exchange API Reference groups the PRC entities that provide structure to the PRC document into the structure module. The PRC entities in the structure module are described here:
Model file: Is a root PRC entity. There is only one model file in a PRC file.
Product occurrence: Can contain multiple child product occurrences and one part definition. It can also reference other product occurrences used as prototypes or external data.
Part definition: Contains representation items.
Filter: Specifies inclusion or exclusion of topology, geometry, tessellation, or graphic entities, based on the entity's layer or entity type.
Load the PRC file into memory by invoking the A3DAsmModelFileLoadFromFile function. In the following example, the acFileName argument points to an A3DUTF8Char array that contains the name of the PRC file, the second parameter must be NULL, and the p pointer references a null A3DAsmModelFile object in which HOOPS Exchange stores the PRC model file.
A3DAsmModelFile* p = NULL; A3DInt32 iRet = A3DAsmModelFileLoadFromFile(acFileName, NULL, &p);
Populate the model file with the model file data by invoking the A3DAsmModelFileGet function to place the data in that structure. The A3D_INITIALIZE_DATA macro clears the memory allocated to the structure and checks the size of the structure to avoid alignment problems. The A3DAsmModelFileGet function creates a data structure from the model file pointer created in the previous step.
A3DAsmModelFileData sData; A3D_INITIALIZE_DATA(sData); A3DInt32 iRet = A3DAsmModelFileGet(p, &sData);
Save the value of the m_dUnit member in the structure in which you are saving data obtained from parsing the PRC file (your export structure). This member specifies a multiple of millimeters. The value of this member must be non-zero. A value of 1 indicates the units are in millimeters; and a value of 10 indicates the units are in centimeters. If the m_bUnitFromCAD is present, save its value in your export structure. If the bUnitFromCAD member is true, then the m_bUnit is from the native CAD file.
Parsing the entity base is described here.
The A3DMiscCascadedAttributes structure will be the root entry in a stack on which you store child product occurrences and other subordinate structures. This stack is used to iterate through the PRC structure.
A3DMiscCascadedAttributes* pAttr; A3DMiscCascadedAttributesCreate(&pAttr);
As you parse subsequent PRC entities, you push the attributes onto this stack. For more information about using cascaded attribute stacks, see Parsing PRC entities that specify graphics.
Parse each product occurrence pointer in the sData.m_ppPOccurrences array. The number of pointers is specified in sData.m_uiPOccurrencesSize.
for (A3DUns32 ui = 0; ui < sData.m_uiPOccurrencesSize; ui++) parsePOccurrence(sData.m_ppPOccurrences[ui], pAttr);
For information about parsing product occurrences, see the next section.
Step 1: Parse the entity base, saving the entity name and other relevant data to your export structure. (See Parsing root-base entity data.)
Step 2: Create and push a cascaded attributes structure for a product occurrence object, and push that structure onto the stack. (See Parsing graphic attributes using miscellaneous cascaded attributes.) Save relevant values to your export structure.
Step 3: Declare and initialize an A3DAsmProductOccurrenceData structure.
A3DAsmProductOccurrenceData sData; A3D_INITIALIZE_DATA(sData);
Step 4: Get the product occurrence data by invoking the A3DAsmProductOccurrenceGet function.
iRet = A3DAsmProductOccurrenceGet(p, &sData);
Step 5: Parse the product occurrence data to identify subordinate or imported product occurrences and recursively parse the contents of each, as described in this section. The member names and their significance are described below:
The following example parses prototype or external product occurrences. The sData variable is a populated A3DAsmProductOccurrenceData structure.
if (sData.m_pPrototype) { parsePOccurrence(sData.m_pPrototype, pAttr); } if (sData.m_pExternalData) { parsePOccurrence(sData.m_pExternalData, pAttr); }
The following example parses child product occurrences (sData.ppPOccurrences[ui]). As before, the sData variable is a populated A3DAsmProductOccurrenceData structure.
for (A3DUns32 ui = 0; ui < sData.m_uiPOccurrencesSize; ui++) parsePOccurrence(sData.m_ppPOccurrences[ui], pAttr);
Step 6: If the product occurrence data references a part (sData.m_pPart), parse it. (See Parse a product occurrence.)
Step 7: Parse any scene display parameters in the product occurrence.
Step 8: Delete the A3DAsmProductOccurrenceData structure created in Step 3 by invoking the A3DAsmProductOccurrenceGet function with the first argument set to NULL and the second argument pointing to the product occurrence data.
iRet = A3DAsmProductOccurrenceGet(NULL, &sData);
Step 1: Parse the entity base, saving the entity name and other relevant data to your export structure. (See Parsing root-base entity data.)
Step 2: Create and push a cascaded attributes structure for a product occurrence object, and push that structure onto the stack. (See Parsing graphic attributes using miscellaneous cascaded attributes.) Record information from the data structure of the miscellaneous cascaded attributes structure that is meaningful to your representation.
Step 3: Declare and initialize an A3DAsmPartDefinitionData structure, as shown in the following example:
A3DAsmPartDefinitionData sData; A3D_INITIALIZE_DATA(sData); iRet = A3DAsmPartDefinitionGet(p, &sData);
Step 4: Parse each representation item referenced by the part definition (See Parsing representation items.) In the following example, sData.m_uiRepItemsSize is the number of representation item entities in the part definition, and entry in the sData.m_ppRepItems[ui] array references a separate representation item.
for (A3DUns32 ui = 0; ui < sData.m_uiRepItemsSize; ui++) parseRI(sData.m_ppRepItems[ui], pAttr);
Step 5: Delete the A3DAsmPartDefinitionData structure created in Step 3 by invoking the A3DAsmPartDefinitionGet function with the first argument set to NULL and the second argument pointing to the part definition data.
A3DAsmPartDefinitionGet(NULL, &sData);