static Ppoint_t *ops;
static int opn;
-static void triangulate(pointnlink_t **, int);
+static int triangulate(pointnlink_t **, int);
static int isdiagonal(int, int, pointnlink_t **, int);
static void loadtriangle(pointnlink_t *, pointnlink_t *, pointnlink_t *);
static void connecttris(int, int);
#endif
/* generate list of triangles */
- triangulate(pnlps, pnll);
+ if (triangulate(pnlps, pnll))
+ return -2;
#if defined(DEBUG) && DEBUG >= 2
fprintf(stderr, "triangles\n%d\n", tril);
}
/* triangulate polygon */
-static void triangulate(pointnlink_t ** pnlps, int pnln)
+static int triangulate(pointnlink_t ** pnlps, int pnln)
{
int pnli, pnlip1, pnlip2;
loadtriangle(pnlps[pnli], pnlps[pnlip1], pnlps[pnlip2]);
for (pnli = pnlip1; pnli < pnln - 1; pnli++)
pnlps[pnli] = pnlps[pnli + 1];
- triangulate(pnlps, pnln - 1);
- return;
+ return triangulate(pnlps, pnln - 1);
}
}
prerror("triangulation failed");
}
else
loadtriangle(pnlps[0], pnlps[1], pnlps[2]);
+
+ return 0;
}
/* check if (i, i + 2) is a diagonal */