protected override void OnPolygonComplete(Polygon2f input) { polygon = input; polygon.MakeCCW(); polygon.BuildIndices(); polygon.BuildHoleIndices(); if (polygon.IsSimple) { if (mode == TRIANGULATION_MODE.CONSTRAINTED) { mesh = ConstraintedTriangulation2.Triangulate(polygon); } else { ConformingCriteria criteria = new ConformingCriteria(); criteria.angBounds = 0.125f; criteria.lenBounds = 0.2f; criteria.iterations = iterations; mesh = ConformingTriangulation2.Triangulate(polygon, criteria); } } else { mesh = new Mesh2f(0, 0); } }
void Start() { points = new Vector2f[100]; FillWithRandom(points); lines = CreateLines(); mesh = ConstraintedTriangulation2.Triangulate(lines, points); }
public void Triangulate() { Polygon2f polygon = CreatePolygon2.FromBox(new Vector2f(-1), new Vector2f(1)); Mesh2f mesh = ConstraintedTriangulation2.Triangulate(polygon); Assert.AreEqual(4, mesh.VerticesCount); Assert.AreEqual(6, mesh.IndicesCount); for (int i = 0; i < mesh.IndicesCount / 3; i++) { Vector2f a = mesh.Positions[mesh.Indices[i * 3 + 0]]; Vector2f b = mesh.Positions[mesh.Indices[i * 3 + 1]]; Vector2f c = mesh.Positions[mesh.Indices[i * 3 + 2]]; Triangle2f tri = new Triangle2f(a, b, c); Assert.IsTrue(tri.SignedArea > 0); } }