CAD Exchanger SDK
Polygonal Representation

Overview

Polygonal representation (ModelData_PolyRepresentation) contains an approximated (tessellated) description of a part (ModelData_Part). A part may have none, one or multiple polygonal representations. In the latter case, they are to considered to define multiple level of details (or LOD's) of the part.

Polygonal representation contains ModelData_PolyShapeList, which is a list of vertex sets (ModelData_PolyVertexSet).

The following example demonstrates how to iterate over root vertex sets:

ModelData_Part aPart = ...;
ModelData_PolyRepresentation aPoly = aPart.PolyRepresentation (ModelData_RM_Poly); //retrieve first (fine) poly
if (aPoly) {
const ModelData_PolyShapeList& aList = aPoly.Get(); //retrieve roots
for (ModelData_PolyShapeList::SizeType i = 0; i < aList.Size(); ++i) {
const ModelData_PolyVertexSet& aSet = aList[i];
//...
}
}

Adding vertex set to Polygonal representation is done with ModelData_PolyRepresentation::Add() or provided in the constructor, for instance:

ModelData_IndexedTriangleSet aTriangulation = ...;
ModelData_PolyRepresentation aPoly (aTriangulation);
ModelData_Part aPart (aBRep, aPoly, "my_part");

Polygonal object types

CAD Exchanger supports the following vertex sets:

The following picture demonstrates each of these types:

faceset_256.png
Triangle set
lineset_256.png
Polyline set
pointset_256.png
Point set

Each of the above classes subclass ModelData_PolyVertexSet which defines a set of vertex coordinates. The vertex set can also have optional appearance (ModelData_Appearance) or particular colors attached to vertices. The latter is very rarely used as it incurs the greatest memory footprint (although allows the highest flexibility).

Attachment of appearance can also be relatively rare given that the most frequent case is attachment of appearance to a part holding the representations. An example of explicit appearance attached to each vertex set is given below. In this case a part contains one polygonal representation which in its turn contains multiple triangle sets each holding its own color (green or orange):

dm_multi_triangleset.png
Multiple triangle sets in one polygonal representation

.

Creation

Bottom-up creation

A polygonal representation is initially created with an empty list of vertex sets. Adding vertex sets is done with the help of ModelData_PolyRepresentation::Add() or provided in the constructor, for instance:

ModelData_IndexedTriangleSet aTS = ...;
ModelData_PolyRepresentation aPoly (aTS);
ModelData_Part aPart (aPoly, "my_part");

Each subclass of ModelData_PolyVertexSet provides API to construct the respective object bottom-up.

Generation from B-Rep representation

A polygonal representation can be created from a B-Rep representation with the help of visulization or computational meshers (see Overview).

The following example demonstrates how to create a part from one B-Rep representation and one polygonal representation using visualization mesher with fine granularity settings:

ModelData_Solid aSolid = ...;
ModelData_BRepRepresentation aBRep (aSolid);
ModelData_PolyRepresentation aPoly (aBRep, ModelAlgo_BRepMesherParameters::Fine);
ModelData_Part aPart (aBRep, aPoly, "my_part");

ModelAlgo_BRepMesher is used underneath to generate the polygonal representation. It may also be used explicitly, for instance, to create polygonal representations for all parts which have B-Rep representations and do not have polygonal representations:

ModelData_Model aModel = ...;
ModelAlgo_BRepMesher aMesher (ModelAlgo_BRepMesherParameters::Fine);
aMesher.Compute (aModel);

Examples

Refer to Model Explorer, Meshing Example.