46 int trimax,emax = 200;
51 double xp,yp,x1,y1,x2,y2,x3,y3,xc,yc,r;
52 double xmin,xmax,ymin,ymax,xmid,ymid;
57 if ((complete = malloc(trimax*
sizeof(
int))) == NULL) {
63 if ((edges = malloc(emax*(
long)
sizeof(
IEDGE))) == NULL) {
77 if (pxyz[i].x < xmin) xmin = pxyz[i].
x;
78 if (pxyz[i].x > xmax) xmax = pxyz[i].
x;
79 if (pxyz[i].y < ymin) ymin = pxyz[i].
y;
80 if (pxyz[i].y > ymax) ymax = pxyz[i].
y;
84 dmax = (dx > dy) ? dx : dy;
85 xmid = (xmax + xmin) / 2.0;
86 ymid = (ymax + ymin) / 2.0;
95 pxyz[nv+0].
x = xmid - 20 * dmax;
96 pxyz[nv+0].
y = ymid - dmax;
99 pxyz[nv+1].
y = ymid + 20 * dmax;
101 pxyz[nv+2].
x = xmid + 20 * dmax;
102 pxyz[nv+2].
y = ymid - dmax;
125 for (j=0;j<(*ntri);j++) {
128 x1 = pxyz[v[j].
p1].
x;
129 y1 = pxyz[v[j].
p1].
y;
130 x2 = pxyz[v[j].
p2].
x;
131 y2 = pxyz[v[j].
p2].
y;
132 x3 = pxyz[v[j].
p3].
x;
133 y3 = pxyz[v[j].
p3].
y;
134 inside =
CircumCircle(xp,yp,x1,y1,x2,y2,x3,y3,&xc,&yc,&r);
135 if (xc < xp && ((xp-xc)*(xp-xc)) > r)
139 if (nedge+3 >= emax) {
141 if ((edges = realloc(edges,emax*(
long)
sizeof(
IEDGE))) == NULL) {
146 edges[nedge+0].
p1 = v[j].
p1;
147 edges[nedge+0].
p2 = v[j].
p2;
148 edges[nedge+1].
p1 = v[j].
p2;
149 edges[nedge+1].
p2 = v[j].
p3;
150 edges[nedge+2].
p1 = v[j].
p3;
151 edges[nedge+2].
p2 = v[j].
p1;
154 complete[j] = complete[(*ntri)-1];
165 for (j=0;j<nedge-1;j++) {
166 for (k=j+1;k<nedge;k++) {
167 if ((edges[j].p1 == edges[k].p2) && (edges[j].p2 == edges[k].p1)) {
174 if ((edges[j].p1 == edges[k].p1) && (edges[j].p2 == edges[k].p2)) {
188 for (j=0;j<nedge;j++) {
189 if (edges[j].p1 < 0 || edges[j].p2 < 0)
191 if ((*ntri) >= trimax) {
195 v[*ntri].
p1 = edges[j].
p1;
196 v[*ntri].
p2 = edges[j].
p2;
198 complete[*ntri] =
FALSE;
207 for (i=0;i<(*ntri);i++) {
208 if (v[i].p1 >= nv || v[i].p2 >= nv || v[i].p3 >= nv) {
int CircumCircle(double xp, double yp, double x1, double y1, double x2, double y2, double x3, double y3, double *xc, double *yc, double *rsqr)