< Home

< Reference Manual

< Supported File Formats

PROGRAMMING GUIDE

Contents

Programming with Exchange

Working with the Exchange API

Parsing a PRC File

Creating a PRC file that uses boundary representation

Creating a tessellation entity for representing faceted objects

Parsing tessellation PRC entities

Tessellation entities represent polygon facets.

Parse tessellation base data

  1. Parse the entity base. (See Parsing root-base entity data.) Save the entity name and other relevant data to your export structure.
  2. Populate an A3DTessBaseData structure with the tessellation base data by invoking the A3DTessBaseGet function. The first argument (p in the following example) is a pointer to the tessellation base data, and the second argument (&sData in the following example) is the location of the A3DTessBaseData structure.
    A3DTessBaseData sData;
    A3D_INITIALIZE_DATA(sData);
    A3DInt32 iRet = A3DTessBaseGet(p, &sData);
  3. Export the coordinate size (sData.m_uiCoordSize), the coordinates array (sData.m_pdCoords), and the calculate attributes (sData.m_bIsCalculated) to your tessellation base data element.
  4. Parse the tessellation data based on its type. The PRC format defines these types for tessellation data:
    • kA3DTypeTess3D, which is used for solids and surfaces (See Parse 3D tessellation data).
    • kA3DTypeTess3DWire, which is used for 3D wireframes
    • kA3DTypeTessMarkup, which is used for markups
    A3DEEntityType eType;
    A3DInt32 iErr = A3DEntityGetType(p, &eType);
    if (iErr == A3D_SUCCESS) {
    	switch(eType) {
    case kA3DTypeTess3D:
    	parse3DTess(p, pRepItem, pFatherAttr);
    	break;
    case kA3DTypeTess3DWire:
    	parse3DWireTess(p);
    	break;
    case kA3DTypeTessMarkup:
    	parse3DTessMarkup(p); 
    	break;
    default:
    	// error response.
    }
  5. Delete the A3DTessBaseData created in Step 2 by invoking the A3DRiBrepModelGet function with the first argument set to NULL and the second argument set to the location of the structure (&sData in the following example).
    A3DTessBaseGet(NULL, &sData);

Parse 3D tessellation data

  1. Parse the entity base. (See Parsing root-base entity data.) Save the entity name and other relevant data to your export structure.
  2. Populate an A3DTess3DData structure with the tessellation data by invoking the A3DTess3DGet function.
    A3DTess3DData sData;
    A3D_INITIALIZE_DATA(sData);
    A3DInt32 iRet = A3DTess3DGet(p, &sData);
  3. Represent relevant data from the 3D tessellation data element in your export structure.
  4. For each face in the tessellation data, create and push the cascaded attributes face data and then access its data members. (See Parsing graphic attributes using miscellaneous cascaded attributes.) In the following example, the CreateAndPushCascadedAttributesFace is a private function that pushes the miscellaneous cascaded attributes for a tessellation face onto the stack.
    A3DUns32 uiNumberOfFaces = sData.m_uiFaceTessSize;
     
    for (A3DUns32 ui = 0; ui < uiNumberOfFaces; ui++) {
    	A3DTessFaceData& sTessFaceData = sData.m_psFaceTessData[ui];
     
    	A3DMiscCascadedAttributes* pAttr;
    	A3DMiscCascadedAttributesData sAttrData;
    	// Read CascadedAttributes for one of the facec
    	CreateAndPushCascadedAttributesFace(pRepItem, p, &sTessFaceData, 
    		ui, pFatherAttr, &pAttr, &sAttrData);
     
    	A3DMiscCascadedAttributesDelete(pAttr);
    	A3DMiscCascadedAttributesGet(NULL, &sAttrData);
    }
  5. Delete the cascaded attributes data structure.
    A3DMiscCascadedAttributesDelete(pAttr);
  6. Delete the cascaded attributes structure.
    A3DMiscCascadedAttributesGet(NULL, &sAttrData);
  7. Delete the A3DTess3DData structure created in Step 2.
    A3DTess3DGet(NULL, &sData);