
v5.0
Returns a 1-dimensional packed Array of triangulation descriptions
corresponding to the tesselation of the polygon. The polygon is
tesselated into (NbPoints - 2) triangles, and 3 indices in the
range (0..NbPoints-1) are returned for each triangle. Each index
triplet describes a subtriangle of the polygon, and the indices
correspond to the vertex or node ordering within the polygon.
Notice that the triangulation of a polygon may change accordingly
to the deformation of the geometry.
// get accessor Object rtn = PolygonFace.TriangleSubIndexArray; |
/*
This example demonstrates how to describe the triangulation of some polygons.
*/
NewScene( null, false );
var SphereGeom = Application.ActiveSceneRoot.AddGeometry("Sphere", "MeshSurface").ActivePrimitive.Geometry;
var Polygons = SphereGeom.Polygons;
for(i = 0; i < Polygons.Count; i++)
{
var Polygon = Polygons.Item(i);
var NbTriangles = Polygon.NbPoints-2;
var PolygonVertices = Polygon.Vertices;
var PolygonNodes = Polygon.Nodes;
var TriangleSubIndices = Polygon.TriangleSubIndexArray.toArray();
for(j = 0; j < NbTriangles; j++)
{
Application.LogMessage("SubTriangle " + j + " of Polygon " + i + " correspond to vertices (" +
PolygonVertices.Item(TriangleSubIndices[j*3]).Index + ", " +
PolygonVertices.Item(TriangleSubIndices[j*3+1]).Index + ", " +
PolygonVertices.Item(TriangleSubIndices[j*3+2]).Index + ") and nodes (" +
PolygonNodes.Item(TriangleSubIndices[j*3]).Index + ", " +
PolygonNodes.Item(TriangleSubIndices[j*3+1]).Index + ", " +
PolygonNodes.Item(TriangleSubIndices[j*3+2]).Index + ").");
}
}
// Expected results:
//INFO : SubTriangle 0 of Polygon 0 correspond to vertices (9, 2, 0) and nodes (0, 1, 2).
//INFO : SubTriangle 0 of Polygon 1 correspond to vertices (2, 9, 10) and nodes (3, 4, 5).
//INFO : SubTriangle 1 of Polygon 1 correspond to vertices (2, 10, 3) and nodes (3, 5, 6).
//INFO : SubTriangle 0 of Polygon 2 correspond to vertices (3, 10, 11) and nodes (7, 8, 9).
//INFO : SubTriangle 1 of Polygon 2 correspond to vertices (3, 11, 4) and nodes (7, 9, 10).
//etc.
|