Tessellation Example

Creating a tessellation entity for representing facetted objects

This section explains how to add tessellation base data to an existing representation item for a theoretical STL file. The process is broken into two main parts: creating the root base data, and creating the tessellation facet data.

Create the tessellation base data

Step 1

Create a A3DTessBaseData structure and set its member values to represent the facets. The following explanation assumes facets are defined as triangles, although you could define facets having more than three points.

Step 2

Add coordinates for each vertex of each facet to the array referenced by the m_pdCoords member. The X, Y, and Z coordinates for each vertex are represented as sequential entries in the array, as shown in this example:

sTessBaseData.m_pdCoords[j++] = x;
sTessBaseData.m_pdCoords[j++] = y;
sTessBaseData.m_pdCoords[j++] = z;

Create the tessellation facet data

Step 1

Create an A3DTess3DData structure and set its members to represent the facet normals:

Step 2

Add the indices for each facet, considering the number of entries to represent each facet. Each facet contains the following sequential representations in this array:

In the following example for STL data, facetSize is set to 0 for the first facet represented by the array and to 1 for the second facet in the array.

sTess3DData.m_puiTriangulatedindices[4 * facetSize] = i;
sTess3DData.m_puiTriangulatedindices[4 * facetSize + 1] = j;
sTess3DData.m_puiTriangulatedindices[4 * facetSize+2] = j + 3;
sTess3DData.m_puiTriangulatedindices[4 * facetSize+3] = j + 6;

Step 3

Add the coordinates of each facet normal to the array referenced by the m_pdNormals member. The X, Y, and Z coordinates for each vector are represented in sequential entries in the array, as shown in this example:

sTess3DData.m_pdNormals[i++] = x;
sTess3DData.m_pdNormals[i++] = y;
sTess3DData.m_pdNormals[i++] = z;

Step 4

For each face, create an A3DTessFaceData entity and set its member values as follows:

Step 5

Set the A3DTess3DData structure's m_psFaceTessData member to reference an array that in turn references each face that applied to the facets. Set the m_uiFaceTessSize member to the number of faces in this array.

Step 6

Create the tessellation entity by invoking the A3DTess3DCreate function, providing the location of the A3DTess3DData structure as the first argument and the location of the A3DTess3D pointer as the second argument.

A3DTess3D* pTess3D = NULL;
A3DTess3DCreate(&sTess3DData, &pTess3D);

Step 7

Package the tessellation base data with in the A3DTess3D entity by invoking the A3DTessBaseSet function.

A3DTessBaseSet(&pTess3D, &sTessBaseData);

Step 8

Add the A3DTess3D data to a representation item.

The complete code sample can be found here. The code creates an A3D tessellation entity from a file that conforms to the STL format. It packages this entity with a poly B-rep model representation item. STL is a file format native to the stereolithography CAD software created by 3D Systems.

top_level:2 prog_guide:2