/// <summary>
/// Tessellates the input contours.
/// </summary>
/// <param name="windingRule"> Winding rule used for tessellation. See <see cref="WindingRule"/> for details. </param>
/// <param name="elementType"> Tessellation output type. See <see cref="ElementType"/> for details. </param>
/// <param name="polySize"> Number of vertices per polygon if output is polygons. </param>
/// <param name="combineCallback"> Interpolator used to determine the data payload of generated vertices. </param>
/// <param name="normal"> Normal of the input contours. If set to zero, the normal will be calculated during tessellation. </param>
public void Tessellate(WindingRule windingRule = WindingRule.EvenOdd, ElementType elementType = ElementType.Polygons, int polySize = 3,
CombineCallback combineCallback = null, Vec3 normal = new Vec3())
{
_normal = normal;
_vertices = null;
_elements = null;
_windingRule = windingRule;
_combineCallback = combineCallback;
if (_mesh == null)
{
return;
}
// Determine the polygon normal and project vertices onto the plane
// of the polygon.
ProjectPolygon();
// ComputeInterior computes the planar arrangement specified
// by the given contours, and further subdivides this arrangement
// into regions. Each region is marked "inside" if it belongs
// to the polygon, according to the rule given by windingRule.
// Each interior region is guaranteed be monotone.
ComputeInterior();
// If the user wants only the boundary contours, we throw away all edges
// except those which separate the interior from the exterior.
// Otherwise we tessellate all the regions marked "inside".
if (elementType == ElementType.BoundaryContours)
{
SetWindingNumber(1, true);
}
else
{
TessellateInterior();
}
_mesh.Check();
if (elementType == ElementType.BoundaryContours)
{
OutputContours();
}
else
{
OutputPolymesh(elementType, polySize);
}
_pool.Return(_mesh);
_mesh = null;
}