A tessellator object decomposes a polygon description into a set of triangles. Use the tessellator object to convert complex and/or concave polygons into a form suitable for drawing with the IDLgrPolygon object. IDLgrPolygon can draw only convex polygons correctly.
The polygon contours may intersect each other and may be self-intersecting. The contours may be disjoint, overlapping, or contained within other contours. The contours may also be degenerate, may contain repeated points, and may or may not be closed. The order of the vertices may be either counter-clockwise or clockwise. For best results, the polygon contours should be coplanar.
The tessellator object uses the "odd-winding rule" to determine if a point is in the interior of the polygon and therefore contained in a triangle output by the tessellator. With this rule, a point is in the interior if it is circled an odd number of times as we travel around each of the contours.
Specify polygon contours with calls to the IDLgrTessellator::AddPolygon method. After adding all the contours, use the IDLgrTessellator::Tessellate method to perform the tessellation and retrieve the resulting list of vertices and connectivity array.
If the polygon contours contain intersecting or self-intersecting contours, the tessellator may return vertices that were not in the original set of vertices specified with the IDLgrTessellator::AddPolygon method. These vertices are created by the intersecting contours.
If your vertex data also includes other information, such as a color for each vertex, then you may wish for this extra information to be created for any new vertices generated by the tessellator. Use the AUXDATA keywords for IDLgrTessellator::AddPolygon and IDLgrTessellator::Tessellate to pass in and retrieve your per-vertex data. The tessellator object interpolates the per-vertex data from neighboring vertices to create new per-vertex data for the new vertices it generates.
In the following example of handling per-vertex data with generated vertices, the polygon is a simple self-intersecting "bow-tie" polygon. It is submitted to the tessellator with four vertices, but the tessellator returns a fifth at the point of self-intersection. Color data for the four original vertices is also supplied, and the tessellator returns a fifth color.
PRO tessaux oTess = OBJ_NEW('IDLgrTessellator') colors = [[0,255,0],[0,255,0],[0,64,0],[0,64,0]] oTess->AddPolygon, [0,1,0,1], [0,0,1,1], AUXDATA=colors result = oTess->Tessellate(v, c, AUXDATA=aux) PRINT, v[*,4] PRINT, aux[*,4] oPoly = OBJ_NEW('IDLgrPolygon', v, POLYGONS=c, $ VERT_COLORS=aux, SHADING=1) XOBJVIEW, oPoly, /BLOCK OBJ_DESTROY, [oTess, oPoly] END
The generated output will be:
0 159 0
Objects of this class have no properties of their own.
This class has the following methods:
In addition, this class inherits the methods of its superclasses (if any).