Parsing graphic attributes using miscellaneous cascaded attributes
Miscellaneous cascaded attributes manage the inheritable graphics data that can be applied to a PRC entity. Such inheritable data includes the show and remove settings, style attributes such as color and pattern, layer attributes, and coordinate system transformations.
The A3DGraphicsCreate function lets you set the graphics data for an entity. It also lets you set inheritance behavior for the attributes. These bits can specify that an attribute be inherited from a child entity or from a parent entity.
The A3DGraphicsGet function gets the graphics data for an entity, but it does not take into account inherited settings.
The following diagram illustrates the steps required to create and push miscellaneous cascaded attributes, depending on whether the entity represents a tessellation face.
To create and push a miscellaneous cascaded attributes structure
- Declare the structure for creating and pushing a cascaded attributes structure.
- Create and push a cascaded attributes structure. For entities in the tessellation module, include a pointer to the tessellation base entity (see Create and push a cascaded attributes structure for entities in the tessellated module. For all other entities in the graphics module, see Create and push a cascaded attributes structure for graphic entities.
- Delete the structure created for the miscellaneous cascaded attributes.
Declare the structure for creating and pushing a cascaded attributes structure
- Declare an empty cascaded data structure in which the cascaded attributes are to be stored. The macro A3D_INITIALIZE_DATA clears the memory allocated to the structure and checks the size of the structure to avoid alignment problems.
A3DMiscCascadedAttributesData sAttrData;
A3D_INITIALIZE_DATA(sAttrData);
- Declare a null pointer to a miscellaneous cascaded attributes object.
A3DMiscCascadedAttributes* pAttr;
Create and push a cascaded attributes structure for graphic entities
- Create an empty miscellaneous cascaded attributes object by invoking the A3DMiscCascadedAttributesCreate function, providing as an argument the address of the previously created null pointer.
A3DInt32 iRet = A3DMiscCascadedAttributesCreate(&pAttr);
- Invoke the A3DMiscCascadedAttributesPush function, which creates the A3DMiscCascadedAttributes object for the current PRC entity and pushes the parent A3DMiscCascadedAttributes object onto the stack. Provide the following arguments to A3DMiscCascadedAttributesPush.
- The first argument (pAttr in the following example) is a pointer to an empty miscellaneous cascaded attribute object. The A3DMiscCascadedAttributesPush function populates this object.
- The second argument (pBase in the following example) is a pointer to the PRC entity of interest, recast as a const A3DRootBaseWithGraphics*.
- The third argument (pFatherAttr in the following example) is a pointer to the parent entity's A3DMiscCascadedAttributes object. Do not confuse this structure with the parent entity's A3DMiscCascadedAttributesData structure. See example below:
iRet = A3DMiscCascadedAttributesPush (pAttr, pBase, pFatherAttr);
- Get the data from the newly created cascaded attributes structure by invoking the A3DMiscCascadedAttributesGet function. Provide the following arguments:
- The first argument (pAttr in the following example) references the cascaded attribute structure populated in Step 2.
- The second argument (sAttrData in the following example) references the empty A3DMiscCascadedAttributesData structure created previously. (See Declare the structure for creating and pushing a cascaded attributes structure.) The A3DMiscCascadedAttributesGet function stores the entity's attributes in this structure. See example below:
iRet = A3DMiscCascadedAttributesGet(pAttr, &sAttrData);
Create and push a cascaded attributes structure for entities in the tessellated module
- Invoke the A3DMiscCascadedAttributesPushTessFace function, providing the following arguments:
- The first argument (pAttr in the following example) is a pointer to an empty miscellaneous cascaded attribute object. The A3DMiscCascadedAttributesPushTessFace function populates this object.
- The second argument (pRepItem in the following example) is a pointer to the representation item that contains the tessellation face.
- The third argument (pTessBase in the following example) is a pointer to the tessellation entity that contains the face, recast as a const A3DTessBase* pointer. This argument can be cast from the A3DTess3D entity.
- The fourth argument (psTessFaceData in the following example) references an array of pointers to the A3DTessFaceData structures that contain the face data. Use the A3DTess3DGet function to obtain that structure.
- The fifth argument (uiFaceIndex in the following example) is the face index used with the fourth argument to access the face data from the m_psFaceTessData member of the psTess3DData structure.
- The sixth argument (pFatherAttr in the following example) is a pointer to the parent entity's A3DMiscCascadedAttributes object. Do not confuse this structure with the parent entity's A3DMiscCascadedAttributesData structure. See example below:
A3DInt32 iRet = A3DMiscCascadedAttributesCreate(ppAttr);
// This API is dedicated to tessellation
iRet = A3DMiscCascadedAttributesPushTessFace(pAttr, pRepItem, pTessBase,
psTessFaceData, uiFaceIndex, pFatherAttr);
A3D_INITIALIZE_DATA((*psAttrData));
iRet = A3DMiscCascadedAttributesGet(*ppAttr, psAttrData);
- Save relevant data to your export structure.
Delete the structure created for the miscellaneous cascaded attributes
- Delete the A3DMiscCascadedAttributes structure by invoking the A3DMiscCascadedAttributesDelete function.
A3DMiscCascadedAttributesDelete(pAttr);
- Delete the A3DMiscCascadedAttributesData structure by invoking the A3DMiscCascadedAttributesGet function, setting the first argument to NULL and the second to the address of the structure. Here is an example:
A3DMiscCascadedAttributesGet(NULL, &sAttrData);
A3DMiscCascadedAttributes* pAttr;