< 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 topology PRC entities

The Exchange API Reference groups the PRC entities that specify topology into the topology module. The PRC entities in this module specify the surfaces of 3D objects. This section describes how to parse the topology data in a B-rep model.

Topology data in a B-rep model contains data specific to the B-rep and data that is generic to topology models.

Data specific to B-rep topology models

The following entities contain the geometric data that represents the B-rep data:

Data general to all topology models

The following entities contain data that applies to any topology model:

Parse topology body 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. Get the topology body data by invoking the A3DTopoBodyGet function. The first argument (p in the following example) is a pointer to the B-rep model's topology body data, and the second argument (&sData in the following example) is the location of the A3DTopoBodyData structure.
    A3DTopoBodyData sData;
    A3D_INITIALIZE_DATA(sData);
    A3DInt32 iRet = A3DTopoBodyGet(p, &sData);
  3. Parse the context of the topology body context data, referenced by the m_pContext member. (See Parse topology context data.)
  4. parseContext(sData.m_pContext);
  5. Delete the A3DTopoBodyData structure created in Step 2, by invoking the A3DTopoBodyGet function with the first argument set to NULL and the second argument set to the location of the structure (&sData in the following example).
    A3DTopoBodyGet(NULL, &sData);

Parse topology context 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. Get the data in the topology context data by invoking the A3DTopoContextGet function. The first argument (p in the following example) is a pointer to the topology context data, and the second argument (&sData in the following example) is the location of the A3DTopoContextData structure.
    A3DTopoContextData sData;
    A3D_INITIALIZE_DATA(sData);
    A3DInt32 iRet = A3DTopoContextGet(p, &sData);
  3. If you plan to evaluate graphic data relative to the current surface, save the Body Scale for use in scaling the face's surface data to fit the NURBS surface. (See Parse the face's surface data.) Body scale has no particular meaning for NURBS data conversion and can be called only on specific surface types.
    stdContextScale = sData.m_dScale;
  4. Delete the A3DTopoContextData structure, created in Step 2, by invoking the A3DTopoContextGet function with the first argument set to NULL and the second argument set to the location of the structure (&sData in the following example).
    A3DTopoContextGet(NULL, &sData);

Parse the B-rep model's 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. Get the data in the B-rep model by invoking the A3DTopoBrepDataGet function. The first argument (p in the following example) is a pointer to the B-rep model's data, and the second argument (&sData in the following example) is the location of the A3DBrepDataData structure.
  3. A3DTopoBrepDataData sData;
    A3D_INITIALIZE_DATA(sData);
    A3DInt32 iRet = A3DTopoBrepDataGet(p, &sData);
  4. The B-rep data can reference Connex entities. The m_uiConnexSize member indicates the number of such references, and the m_ppConnexes[] member provides the references. Parse each Connex entry. (See Parse Connex data.)
    for(A3DUns32 ui = 0; ui < sData.m_uiConnexSize; ui++)
    	parseConnex(sData.m_ppConnexes[ui]);
  5. Save the bounding box referenced by m_sBoundingBox as an attribute of the B-rep data element in your export structure.
  6. Delete the A3DTopoBrepDataData structure, created in Step 2, by invoking the A3DTopoBrepDataGet function with the first argument set to NULL and the second argument set to the location of the structure (&sData in the following example).
    A3DTopoBrepDataGet(NULL, &sData);

Parse Connex 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. Get the data in the B-rep model by invoking the A3DTopoConnexGet function. The first argument (p in the following example) is a pointer to the Connex entity, and the second argument (&sData in the following example) is the location of the A3DTopoConnexData structure.
    A3DTopoConnexData sData;
    A3D_INITIALIZE_DATA(sData);
    A3DInt32 iRet = A3DTopoConnexGet(p, &sData);
  3. The Connex data can reference multiple Shell entities. The m_uiShellSize member indicates the number of such references, and the m_ppShells[] member provides the references. Parse each Shell entity. (See Parse a shell entity.)
    	
    for(A3DUns32 ui = 0; ui < sData.m_uiShellSize; ui++)
    	parseShell(sData.m_ppShells[ui]);
  4. Delete the A3DTopoConnexData structure, created in Step 2, by invoking the A3DTopoConnexGet function with the first argument set to NULL and the second argument set to the location of the structure (&sData in the following example).
    	
    A3DTopoConnexGet(NULL, &sData);

Parse a shell entity

  1. Parse the entity base. (See Parsing root-base entity data.) Save the entity name and other relevant data to your export structure.
  2. Get the data in the topology shell entity by invoking the A3DTopoShellGet function. The first argument (p in the following example) is a pointer to the topology shell entity, and the second argument (&sData in the following example) is the location of the A3DTopoShellData structure.
    	
    A3DTopoShellData sData;
    A3D_INITIALIZE_DATA(sData);
    A3DInt32 iRet = A3DTopoShellGet(p, &sData);
  3. The shell data can reference multiple face entities. The m_uiFaceSize member indicates the number of such references, and the m_ppFaces[] member provides the references. Parse each face entity, as described in Parse the face's surface data.
    	
    for(A3DUns32 ui = 0; ui < sData.m_uiFaceSize; ui++)
    	parseFace(ui, sData.m_ppFaces[ui]);
  4. Save the closed indicator (the m_bClosed member) and the orientation of the surface normal with respect to the shell normal (the m_pucOrientationWithShell member) as attributes in the shell element in your export structure.
  5. Delete the A3DTopoShellData structure, created in Step 2, by invoking the A3DTopoShellGet function with the first argument set to NULL and the second argument set to the location of the structure (&sData in the following example).
  6. 	
    A3DTopoShellGet(NULL, &sData);

Parse the face's surface 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. Get the data in the topology face entity by invoking the A3DTopoFaceGet function. The first argument (p in the following example) is a pointer to the topology face entity, and the second argument (&sData in the following example) is the location of the A3DTopoFaceData structure.
    	
    A3DTopoFaceData sData;
    A3D_INITIALIZE_DATA(sData);
    A3DInt32 iRet = A3DTopoFaceGet(p, &sData);
  3. Parse the surface data referenced by the m_pSurface member in the A3DTopoFaceData structure. (See Parse generic surface data.)
  4. If you are converting the PRC data to a 3D model that does not support UV mapping, you must create a curve on surface and convert it to NURBS data. (See Convert surface data to NURBS (for other than UV-mapped surfaces).)
  5. Delete the A3DTopoFaceData structure created in Step 2 by invoking the A3DTopoFaceGet function with the first argument set to NULL and the second argument set to the location of the structure (&sData in the following example).
    	
    A3DTopoFaceGet(NULL, &sData);

Convert surface data to NURBS (for other than UV-mapped surfaces)

  1. Declare and initialize an A3DCrvOnSurfData structure.
  2. Populate the A3DCrvOnSurfData structure with the surface base and surface domain information from the A3DTopoFaceData structure.
  3. Create an A3DCrvOnSurf PRC entity by invoking the A3DCrvOnSurfCreate function. The first argument in this function call is the A3DCrvOnSurfData structure, and the second is a pointer to the resulting PRC entity.
  4. Convert a curve on the surface in the A3DCrvOnSurf PRC entity by invoking the A3DCrvBaseGetAsNurbs function.

Parse generic surface data

  1. Determine the type of surface data by invoking the A3DEntityGetType function. The first argument references the surface, and the second is a pointer to a variable in which the function stores the type enumerator.
  2. Parse the surface data using the Acrobat 3D API functions most appropriate for the surface type. Use the A3DEntityGetType function to determine surface type. If the surface type is of type kA3DTypeSurfNurbs or if the surface type is unknown, parse the surface data as NURBS surface data (see Parse NURBS surface data).
    A3DEEntityType eType;
    iRet = A3DEntityGetType(p, &eType);
    switch (eType) {
    case kA3DTypeSurfNurbs:
    	parseSurfaceNurbs(p);
    	break;
    case kA3DTypeSurfSphere:
    	parseSurfSphere(p);
    	break;
    case kA3DTypeSurfBlend01:
    	parseSurfaceBlend01(p);
    	break;
    }

Parse NURBS surface data

  1. Declare and initialize an A3DSurfNurbsData structure.
  2. Populate the surface NURBS data structure by invoking the A3DSurfBaseGetAsNurbs function, providing the following arguments:
    • The first argument (sData.m_pSurface in the following example) is a pointer to the surface base entity.
    • The second argument (1e-3 / stdContextScale) is a ratio that the function uses to scale the NURBS data. The value 1e-3 specifies the desired tolerance (0.001 mm in the following example). The stdContextScale global variable is the Body Scale, which was obtained from the A3DTopoContextData structure. (See Parse topology body data.) The adjustment is calculated by dividing the targeted tolerance by the Body Scale.
    • The third argument (bUseSameParameterization) specifies that the conversion from the surface data to NURBS data should use the parameterization data (if any) that is already specified in the face's surface definition.
    • The fourth argument (&sNurbsData) is a pointer to an empty structure in which the function stores the NURBS data.
      A3DBool bUseSameParameterization = TRUE;
      A3DSurfNurbsData sNurbsData;
      A3D_INITIALIZE_DATA(sNurbsData);
      iRet = A3DSurfBaseGetAsNurbs(sData.m_pSurface, 1e-3 / stdContextScale, 
      	bUseSameParametrization, &sNurbsData);
  3. Determine the result of the A3DSurfBaseGetAsNurbs function. In addition to returning the standard success and failure values, this function can also return the warning A3D_SRF_NURBS_CANNOT_KEEP_PARAMETERIZATION. This warning indicates that the conversion yielded a valid NURBS surface but that associated space parametric trimming curves may be unreliable.
    if (iRet == A3D_SUCCESS || 
    	iRet == A3D_SRF_NURBS_CANNOT_KEEP_PARAMETERIZATION) {
    	// ...
    }
  4. If Step 3 did not return with an error, delete the A3DSurfNurbsData structure by invoking the A3DSurfNurbsGet function with the first argument set to NULL and the second argument set to the location of the structure (&sNurbsData in the following example).
    A3DSurfNurbsGet(NULL, &sNurbsData);