main.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "tessellate.h"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. void run_example(const double vertices_array[],
  5. const double *contours_array[],
  6. int contours_size)
  7. {
  8. double *coordinates_out;
  9. int *tris_out;
  10. int nverts, ntris, i;
  11. const double *p = vertices_array;
  12. /* const double **contours = contours_array; */
  13. tessellate(&coordinates_out, &nverts,
  14. &tris_out, &ntris,
  15. contours_array, contours_array + contours_size);
  16. for (i=0; i<2 * nverts; ++i) {
  17. fprintf(stdout, "%g ", coordinates_out[i]);
  18. }
  19. fprintf(stdout, "\n");
  20. for (i=0; i<3 * ntris; ++i) {
  21. fprintf(stdout, "%d ", tris_out[i]);
  22. }
  23. fprintf(stdout, "\n");
  24. free(coordinates_out);
  25. if (tris_out)
  26. free(tris_out);
  27. }
  28. int main()
  29. {
  30. double a1[] = { 0, 0, 1, 5, 2, 0, -1, 3, 3, 3 };
  31. const double *c1[] = {a1, a1+10};
  32. int s1 = 2;
  33. run_example(a1, c1, 2);
  34. double a2[] = { 0, 0, 3, 0, 3, 3, 0, 3,
  35. 1, 1, 2, 1, 2, 2, 1, 2 };
  36. const double *c2[] = {a2, a2+8, a2+16};
  37. int s2 = 3;
  38. run_example(a2, c2, s2);
  39. double a3[] = { 441, 0, 326, 0, 326, 889, 12, 889, 12, 992, 755, 992, 755, 889, 441, 889 };
  40. const double *c3[] = { a3, a3+16 };
  41. int s3 = 2;
  42. run_example(a3, c3, s3);
  43. return 0;
  44. }