1 |
< |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
1 |
> |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ SGI"; |
191 |
|
VSUM(edgeA, cp[1], cp[0], -1.0); |
192 |
|
VSUM(edgeB, cp[3], cp[1], -1.0); |
193 |
|
fcross(crossp[i], edgeA, edgeB); |
194 |
– |
VSUM(edgeA, cp[2], cp[3], -1.0); |
195 |
– |
VSUM(edgeB, cp[0], cp[2], -1.0); |
196 |
– |
fcross(v, edgeA, edgeB); |
197 |
– |
VSUM(crossp[i], crossp[i], v, 1.0); |
194 |
|
/* compute center */ |
195 |
|
cent[i][0] = 0.5*(cp[0][0] + cp[2][0]); |
196 |
|
cent[i][1] = 0.5*(cp[0][1] + cp[2][1]); |
199 |
|
/* compute difference vector */ |
200 |
|
VSUM(diffv, cent[1], cent[0], -1.0); |
201 |
|
for (i = 0; i < 2; i++) { /* compute volume contributions */ |
202 |
< |
vol[i] = 0.25*DOT(crossp[i], diffv); |
202 |
> |
vol[i] = 0.5*DOT(crossp[i], diffv); |
203 |
|
if (vol[i] < 0.) vol[i] = -vol[i]; |
204 |
|
} |
205 |
|
return(vol[0] + vol[1]); /* return total volume */ |
212 |
|
double frac; |
213 |
|
int i; |
214 |
|
register int j, k; |
215 |
< |
/* free old list */ |
216 |
< |
if (complen > 0) |
215 |
> |
/* free old list and empty queue */ |
216 |
> |
if (complen > 0) { |
217 |
|
free((char *)complist); |
218 |
+ |
done_packets(flush_queue()); |
219 |
+ |
} |
220 |
|
/* allocate beam list */ |
221 |
|
complen = 0; |
222 |
|
for (j = 0; hdlist[j] != NULL; j++) |
229 |
|
for (j = 0; hdlist[j] != NULL; j++) { |
230 |
|
frac = 512. * hdlist[j]->wg[0] * |
231 |
|
hdlist[j]->wg[1] * hdlist[j]->wg[2]; |
232 |
+ |
if (frac < 0.) frac = -frac; |
233 |
|
for (i = nbeams(hdlist[j]); i > 0; i--) { |
234 |
|
complist[k].hd = j; |
235 |
|
complist[k].bi = i; |
236 |
|
complist[k].nr = frac*beamvolume(hdlist[j], i) + 0.5; |
237 |
+ |
complist[k].nc = bnrays(hdlist[j], i); |
238 |
|
wtotal += complist[k++].nr; |
239 |
|
} |
240 |
|
} |
250 |
|
|
251 |
|
|
252 |
|
mergeclists(cdest, cl1, n1, cl2, n2) /* merge two sorted lists */ |
253 |
< |
PACKHEAD *cdest; |
254 |
< |
PACKHEAD *cl1, *cl2; |
253 |
> |
register PACKHEAD *cdest; |
254 |
> |
register PACKHEAD *cl1, *cl2; |
255 |
|
int n1, n2; |
256 |
|
{ |
257 |
< |
int cmp; |
257 |
> |
register int cmp; |
258 |
|
|
259 |
|
while (n1 | n2) { |
260 |
|
if (!n1) cmp = 1; |
319 |
|
* list and start again from the beginning. Since |
320 |
|
* a merge sort is used, the sorting costs are minimal. |
321 |
|
*/ |
322 |
< |
next_packet(p) /* prepare packet for computation */ |
322 |
> |
next_packet(p, n) /* prepare packet for computation */ |
323 |
|
register PACKET *p; |
324 |
+ |
int n; |
325 |
|
{ |
326 |
|
register int i; |
327 |
|
|
335 |
|
p->nr = complist[listpos].nr - p->nc; |
336 |
|
if (p->nr <= 0) |
337 |
|
return(0); |
338 |
< |
if (p->nr > RPACKSIZ) |
339 |
< |
p->nr = RPACKSIZ; |
338 |
> |
#ifdef DEBUG |
339 |
> |
if (n < 1 | n > RPACKSIZ) |
340 |
> |
error(CONSISTENCY, "next_packet called with bad n value"); |
341 |
> |
#endif |
342 |
> |
if (p->nr > n) |
343 |
> |
p->nr = n; |
344 |
|
complist[listpos].nc += p->nr; /* find where this one would go */ |
345 |
|
while (lastin > listpos && |
346 |
|
beamcmp(complist+lastin, complist+listpos) > 0) |