public virtual int GetTriangleCount() { if (!tried) { throw new System.Exception("this not Triangle !"); } return(tris.Size() / 3); }
private float Area(TriangleBasic.PointList contour) { int n = contour.Size(); float sA = 0.0f; for (int p = n - 1, q = 0; q < n; p = q++) { TriangleBasic.Point contourP = contour.Get(p); TriangleBasic.Point contourQ = contour.Get(q); sA += contourP.GetX() * contourQ.GetY() - contourQ.GetX() * contourP.GetY(); } return(sA * 0.5f); }
public int GetPolyPointCount() { return(poly.Size()); }
private bool Process(TriangleBasic.PointList contour, TriangleBasic.PointList result) { result.Clear(); int n = contour.Size(); if (n < 3) { return(false); } int[] sV = new int[n]; if (0.0f < Area(contour)) { for (int v = 0; v < n; v++) { sV[v] = v; } } else { for (int v_0 = 0; v_0 < n; v_0++) { sV[v_0] = (n - 1) - v_0; } } int nv = n; int count = 2 * nv; for (int v_1 = nv - 1; nv > 2;) { if (0 >= (count--)) { return(false); } int u = v_1; if (nv <= u) { u = 0; } v_1 = u + 1; if (nv <= v_1) { v_1 = 0; } int w = v_1 + 1; if (nv <= w) { w = 0; } if (Snip(contour, u, v_1, w, nv, sV)) { int a, b, c, s, t; a = sV[u]; b = sV[v_1]; c = sV[w]; result.Add(contour.Get(a)); result.Add(contour.Get(b)); result.Add(contour.Get(c)); for (s = v_1, t = v_1 + 1; t < nv; s++, t++) { sV[s] = sV[t]; } nv--; count = 2 * nv; } } return(true); }