/************************************************************************ * * Copyright 1990-2003 Oregon Health and Science University * ************************************************************************* * * tritest.c - interface to Triangle * * Contents: * * ************************************************************************* */ /*****************************************************************************/ /* */ /* (tricall.c) */ /* */ /* Example program that demonstrates how to call Triangle. */ /* */ /* Accompanies Triangle Version 1.3 */ /* July 19, 1996 */ /* */ /* This file is placed in the public domain (but the file that it calls */ /* is still copyrighted!) by */ /* Jonathan Richard Shewchuk */ /* School of Computer Science */ /* Carnegie Mellon University */ /* 5000 Forbes Avenue */ /* Pittsburgh, Pennsylvania 15213-3891 */ /* jrs@cs.cmu.edu */ /* */ /*****************************************************************************/ #ifndef lint static char RCSid[] = "$Id: tritest.c,v 1.3 2004/01/06 00:08:06 pturner Exp $"; #endif #define REAL double #include #include #include #include "triangle.h" #include "defines.h" #include "globals.h" #ifndef _STDLIB_H_ extern void *malloc(); extern void free(); #endif /* _STDLIB_H_ */ /* testing the voronoi computation */ /* static double *vorx, *vory; static int nvor, nvoredges, *vorn1, *vorn2; void drawvoronoi(int n, int nedges, double *x, double *y, int *n1, int *n2); void do_vor(void) { if (nvor) { drawvoronoi(nvor, nvoredges, vorx, vory, vorn1, vorn2); } } void drawvoronoi(int n, int nedges, double *x, double *y, int *n1, int *n2) { int i; setcolor(9); for (i=0;i 0) { in.segmentlist = (int *) malloc(in.numberofsegments * 2 * sizeof(int)); in.segmentmarkerlist = (int *) malloc(in.numberofsegments * sizeof(int)); if (include_boundary) { cnt = 0; for (i = 0; i < grid[gridno].nbounds; i++) { bndno = grid[gridno].boundaries[i]; for (j = 0; j < boundary[bndno].nbpts; j++) { in.segmentlist[2 * cnt] = boundary[bndno].nodes[j] + 1; in.segmentlist[2 * cnt + 1] = boundary[bndno].nodes[(j + 1) % boundary[bndno].nbpts] + 1; in.segmentmarkerlist[cnt] = 0; cnt++; } } } } mid.pointlist = (REAL *) NULL; /* Not needed if -N switch used. */ mid.pointattributelist = (REAL *) NULL; mid.pointmarkerlist = (int *) NULL; /* Not needed if -N or -B switch used. */ mid.trianglelist = (int *) NULL; /* Not needed if -E switch used. */ /* switch (method) { case 0: strcpy(buf, "pa0.1"); strcpy(buf, "pq30X"); break; case 1: strcpy(buf, "pi"); break; case 2: strcpy(buf, "pF"); break; } */ triangulate(args, &in, &mid, NULL); /*triangulate(buf, &in, &mid, &vorout);*/ /* printf("Number of input points = %d, number of output points = %d\n", in.numberofpoints, mid.numberofpoints); */ nels = mid.numberoftriangles; Free_grid_only(gridno); Allocate_grid_only(gridno, nels, mid.numberofpoints); for (i = 0; i < mid.numberofpoints; i++) { grid[gridno].xord[i] = mid.pointlist[2 * i]; grid[gridno].yord[i] = mid.pointlist[2 * i + 1]; find_nearest_buildpt(bno, grid[gridno].xord[i], grid[gridno].yord[i], &ind); grid[gridno].depth[i] = build[bno].db[ind]; } for (i = 0; i < nels; i++) { grid[gridno].icon[i].type = 3; grid[gridno].icon[i].nn = 3; grid[gridno].icon[i].ngeom = 3; for (j = 0; j < mid.numberofcorners; j++) { grid[gridno].icon[i].nl[j] = mid.trianglelist[i * mid.numberofcorners + j] - 1; } } CleanGrid(&grid[gridno]); DeleteElements(&grid[gridno]); setlimits_grid(gridno); free(in.pointlist); free(in.pointattributelist); free(in.pointmarkerlist); free(in.regionlist); free(mid.pointlist); free(mid.pointattributelist); free(mid.pointmarkerlist); free(mid.trianglelist); free(mid.triangleattributelist); free(mid.trianglearealist); free(mid.neighborlist); free(mid.segmentlist); free(mid.segmentmarkerlist); free(mid.edgelist); free(mid.edgemarkerlist); }