20 |
|
#define MAXMODLIST 1024 /* maximum modifiers we'll track */ |
21 |
|
#endif |
22 |
|
|
23 |
< |
int treebufsiz = BUFSIZ; /* current tree buffer size */ |
23 |
> |
ssize_t treebufsiz = BUFSIZ; /* current tree buffer size */ |
24 |
|
|
25 |
|
typedef double DCOLOR[3]; /* double-precision color */ |
26 |
|
|
92 |
|
struct rtproc *next; /* next in list of processes */ |
93 |
|
SUBPROC pd; /* rtrace pipe descriptors */ |
94 |
|
unsigned long raynum; /* ray number for this tree */ |
95 |
< |
int bsiz; /* ray tree buffer length */ |
95 |
> |
size_t bsiz; /* ray tree buffer length */ |
96 |
|
char *buf; /* ray tree buffer */ |
97 |
< |
int nbr; /* number of bytes from rtrace */ |
97 |
> |
size_t nbr; /* number of bytes from rtrace */ |
98 |
|
}; /* rtrace process buffer */ |
99 |
|
|
100 |
|
/* rtrace command and defaults */ |
101 |
|
char *rtargv[256+2*MAXMODLIST] = { "rtrace", |
102 |
< |
"-dj", ".5", "-dr", "3", |
102 |
> |
"-dj", ".9", "-dr", "3", |
103 |
|
"-ab", "1", "-ad", "350", }; |
104 |
|
|
105 |
|
int rtargc = 9; |
107 |
|
char *myrtopts[] = { "-h-", "-x", "1", "-y", "0", |
108 |
|
"-dt", "0", "-as", "0", "-aa", "0", NULL }; |
109 |
|
|
110 |
< |
#define RTCOEFF "-o~~TmWdp" /* compute coefficients only */ |
111 |
< |
#define RTCONTRIB "-o~~TmVdp" /* compute ray contributions */ |
110 |
> |
#define RTCOEFF "-o~~~TmWdp" /* compute coefficients only */ |
111 |
> |
#define RTCONTRIB "-o~~~TmVdp" /* compute ray contributions */ |
112 |
|
|
113 |
|
struct rtproc rt0; /* head of rtrace process list */ |
114 |
|
|
131 |
|
int outfmt = 'a'; /* output format */ |
132 |
|
|
133 |
|
int header = 1; /* output header? */ |
134 |
– |
int accumulate = 0; /* accumulate ray values? */ |
134 |
|
int force_open = 0; /* truncate existing output? */ |
135 |
|
int recover = 0; /* recover previous output? */ |
136 |
+ |
int accumulate = 1; /* input rays per output record */ |
137 |
|
int xres = 0; /* horiz. output resolution */ |
138 |
|
int yres = 0; /* vert. output resolution */ |
139 |
|
|
140 |
+ |
int account; /* current accumulation count */ |
141 |
|
unsigned long raysleft; /* number of rays left to trace */ |
142 |
|
long waitflush; /* how long until next flush */ |
143 |
|
|
167 |
|
|
168 |
|
void put_contrib(const DCOLOR cnt, FILE *fout); |
169 |
|
void add_contrib(const char *modn); |
170 |
< |
void done_contrib(void); |
170 |
> |
void done_contrib(int navg); |
171 |
|
|
172 |
|
/* return number of open rtrace processes */ |
173 |
|
static int |
246 |
|
while ((j = expandarg(&argc, &argv, i)) > 0) |
247 |
|
; |
248 |
|
if (j < 0) { |
249 |
< |
fprintf(stderr, "%s: cannot expand '%s'", |
249 |
> |
fprintf(stderr, "%s: cannot expand '%s'\n", |
250 |
|
argv[0], argv[i]); |
251 |
|
exit(1); |
252 |
|
} |
275 |
|
continue; |
276 |
|
} |
277 |
|
break; |
278 |
< |
case 'c': /* accumulate ray values */ |
279 |
< |
switch (argv[i][2]) { |
280 |
< |
case '\0': |
281 |
< |
accumulate = !accumulate; |
281 |
< |
continue; |
282 |
< |
case '+': case '1': |
283 |
< |
case 'T': case 't': |
284 |
< |
case 'Y': case 'y': |
285 |
< |
accumulate = 1; |
286 |
< |
continue; |
287 |
< |
case '-': case '0': |
288 |
< |
case 'F': case 'f': |
289 |
< |
case 'N': case 'n': |
290 |
< |
accumulate = 0; |
291 |
< |
continue; |
292 |
< |
} |
293 |
< |
break; |
278 |
> |
case 'c': /* input rays per output */ |
279 |
> |
if (argv[i][2] || i >= argc-2) break; |
280 |
> |
accumulate = atoi(argv[++i]); |
281 |
> |
continue; |
282 |
|
case 'r': /* recover output */ |
283 |
|
if (argv[i][2]) break; |
284 |
|
recover = 1; |
340 |
|
case 'b': /* bin expression/count */ |
341 |
|
if (i >= argc-2) break; |
342 |
|
if (argv[i][2] == 'n') { |
343 |
< |
bincnt = atoi(argv[++i]); |
343 |
> |
bincnt = (int)(eval(argv[++i]) + .5); |
344 |
|
continue; |
345 |
|
} |
346 |
|
if (argv[i][2]) break; |
368 |
|
} |
369 |
|
rtargv[rtargc++] = argv[i]; /* assume rtrace option */ |
370 |
|
} |
371 |
< |
if (accumulate) /* no output flushing for single record */ |
371 |
> |
if (accumulate <= 0) /* no output flushing for single record */ |
372 |
|
xres = yres = 0; |
373 |
|
/* set global argument list */ |
374 |
|
gargc = argc; gargv = argv; |
378 |
|
rtargv[rtargc++] = contrib ? RTCONTRIB : RTCOEFF; |
379 |
|
/* just asking for defaults? */ |
380 |
|
if (!strcmp(argv[i], "-defaults")) { |
381 |
< |
char sxres[16], syres[16]; |
381 |
> |
char nps[8], sxres[16], syres[16]; |
382 |
|
char *rtpath; |
383 |
< |
printf("-n %-2d\t\t\t\t# number of processes\n", nprocs); |
383 |
> |
printf("-c %-5d\t\t\t# accumulated rays per record\n", |
384 |
> |
accumulate); |
385 |
|
printf("-V%c\t\t\t\t# output %s\n", contrib ? '+' : '-', |
386 |
|
contrib ? "contributions" : "coefficients"); |
398 |
– |
printf("-c%c\t\t\t\t# %s\n", accumulate ? '+' : '-', |
399 |
– |
accumulate ? "accumulate ray values" : |
400 |
– |
"one output record per ray"); |
387 |
|
fflush(stdout); /* report OUR options */ |
388 |
+ |
rtargv[rtargc++] = "-n"; |
389 |
+ |
sprintf(nps, "%d", nprocs); |
390 |
+ |
rtargv[rtargc++] = nps; |
391 |
|
rtargv[rtargc++] = header ? "-h+" : "-h-"; |
392 |
|
sprintf(fmt, "-f%c%c", inpfmt, outfmt); |
393 |
|
rtargv[rtargc++] = fmt; |
543 |
|
raysleft = yres; |
544 |
|
} else |
545 |
|
raysleft = 0; |
546 |
< |
waitflush = xres; |
546 |
> |
if ((account = accumulate) > 0) |
547 |
> |
raysleft *= accumulate; |
548 |
> |
waitflush = (yres > 0) & (xres > 1) ? 0 : xres; |
549 |
|
if (!recover) |
550 |
|
return; |
551 |
|
/* recover previous values */ |
552 |
< |
if (accumulate) |
552 |
> |
if (accumulate <= 0) |
553 |
|
reload_output(); |
554 |
|
else |
555 |
|
recover_output(stdin); |
582 |
|
error(USER, errmsg); |
583 |
|
} |
584 |
|
if (nmods >= MAXMODLIST) |
585 |
< |
error(USER, "too many modifiers"); |
585 |
> |
error(INTERNAL, "too many modifiers"); |
586 |
|
modname[nmods++] = modn; /* XXX assumes static string */ |
587 |
|
lep->key = modn; /* XXX assumes static string */ |
588 |
|
mp = (MODCONT *)malloc(sizeof(MODCONT)); |
590 |
|
error(SYSTEM, "out of memory in addmodifier"); |
591 |
|
mp->outspec = outf; /* XXX assumes static string */ |
592 |
|
mp->modname = modn; /* XXX assumes static string */ |
593 |
< |
if (binv != NULL) |
594 |
< |
mp->binv = eparse(binv); |
595 |
< |
else |
596 |
< |
mp->binv = eparse("0"); |
597 |
< |
mp->nbins = 1; |
593 |
> |
if (binv == NULL) |
594 |
> |
binv = "0"; /* use single bin if unspecified */ |
595 |
> |
mp->binv = eparse(binv); |
596 |
> |
if (mp->binv->type == NUM) { /* check value if constant */ |
597 |
> |
bincnt = (int)(evalue(mp->binv) + 1.5); |
598 |
> |
if (bincnt != 1) { |
599 |
> |
sprintf(errmsg, "illegal non-zero constant for bin (%s)", |
600 |
> |
binv); |
601 |
> |
error(USER, errmsg); |
602 |
> |
} |
603 |
> |
} |
604 |
> |
mp->nbins = 1; /* initialize results holder */ |
605 |
|
setcolor(mp->cbin[0], 0., 0., 0.); |
606 |
< |
if (mp->binv->type == NUM) /* assume one bin if constant */ |
609 |
< |
bincnt = 1; |
610 |
< |
else if (bincnt > 1) |
606 |
> |
if (bincnt > 1) |
607 |
|
mp = growmodifier(mp, bincnt); |
608 |
|
lep->data = (char *)mp; |
609 |
|
/* allocate output streams */ |
666 |
|
mnp = cp; |
667 |
|
break; |
668 |
|
case 'd': |
669 |
+ |
case 'i': |
670 |
+ |
case 'o': |
671 |
+ |
case 'x': |
672 |
+ |
case 'X': |
673 |
|
if (bnp != NULL) |
674 |
|
return -1; |
675 |
|
bnp = cp; |
702 |
|
printheader(FILE *fout, const char *info) |
703 |
|
{ |
704 |
|
extern char VersionID[]; |
705 |
< |
FILE *fin = fopen(octree, "r"); |
706 |
< |
|
707 |
< |
if (fin == NULL) |
708 |
< |
quit(1); |
709 |
< |
checkheader(fin, "ignore", fout); /* copy octree header */ |
710 |
< |
fclose(fin); |
705 |
> |
/* copy octree header */ |
706 |
> |
if (octree[0] == '!') { |
707 |
> |
newheader("RADIANCE", fout); |
708 |
> |
fputs(octree+1, fout); |
709 |
> |
if (octree[strlen(octree)-1] != '\n') |
710 |
> |
fputc('\n', fout); |
711 |
> |
} else { |
712 |
> |
FILE *fin = fopen(octree, "r"); |
713 |
> |
if (fin == NULL) |
714 |
> |
quit(1); |
715 |
> |
checkheader(fin, "ignore", fout); |
716 |
> |
fclose(fin); |
717 |
> |
} |
718 |
|
printargs(gargc-1, gargv, fout); /* add our command */ |
719 |
|
fprintf(fout, "SOFTWARE= %s\n", VersionID); |
720 |
|
fputnow(fout); |
743 |
|
{ |
744 |
|
if ((xr > 0) & (yr > 0)) /* resolution string */ |
745 |
|
fprtresolu(xr, yr, fout); |
739 |
– |
if (xres > 0) /* global flush flag */ |
740 |
– |
fflush(fout); |
746 |
|
} |
747 |
|
|
748 |
|
/* Get output stream pointer (open and write header if new and noopen==0) */ |
763 |
|
if (header) |
764 |
|
printheader(stdout, NULL); |
765 |
|
printresolu(stdout, xres, yres); |
766 |
+ |
if (waitflush > 0) |
767 |
+ |
fflush(stdout); |
768 |
|
stdos.xr = xres; stdos.yr = yres; |
769 |
|
using_stdout = 1; |
770 |
|
} |
820 |
|
*cp = '\0'; |
821 |
|
printheader(sop->ofp, info); |
822 |
|
} |
823 |
+ |
if (accumulate > 0) { /* global resolution */ |
824 |
+ |
sop->xr = xres; sop->yr = yres; |
825 |
+ |
} |
826 |
|
printresolu(sop->ofp, sop->xr, sop->yr); |
827 |
|
/* play catch-up */ |
828 |
< |
for (i = accumulate ? 0 : lastdone; i--; ) { |
828 |
> |
for (i = accumulate > 0 ? lastdone/accumulate : 0; i--; ) { |
829 |
|
int j = sop->reclen; |
830 |
|
if (j <= 0) j = 1; |
831 |
|
while (j--) |
833 |
|
if (outfmt == 'a') |
834 |
|
putc('\n', sop->ofp); |
835 |
|
} |
836 |
< |
if (xres > 0) |
836 |
> |
if (waitflush > 0) |
837 |
|
fflush(sop->ofp); |
838 |
|
} |
839 |
|
sop->reclen += noopen; /* add to length if noopen */ |
967 |
|
|
968 |
|
/* output ray tallies and clear for next accumulation */ |
969 |
|
void |
970 |
< |
done_contrib(void) |
970 |
> |
done_contrib(int navg) |
971 |
|
{ |
972 |
+ |
double sf = 1.; |
973 |
|
int i, j; |
974 |
|
MODCONT *mp; |
975 |
|
STREAMOUT *sop; |
976 |
+ |
/* set average scaling */ |
977 |
+ |
if (navg > 1) |
978 |
+ |
sf = 1. / (double)navg; |
979 |
|
/* output modifiers in order */ |
980 |
|
for (i = 0; i < nmods; i++) { |
981 |
|
mp = (MODCONT *)lu_find(&modconttab,modname[i])->data; |
982 |
+ |
if (navg > 1) /* average scaling */ |
983 |
+ |
for (j = mp->nbins; j--; ) |
984 |
+ |
scalecolor(mp->cbin[j], sf); |
985 |
|
sop = getostream(mp->outspec, mp->modname, 0,0); |
986 |
|
put_contrib(mp->cbin[0], sop->ofp); |
987 |
|
if (mp->nbins > 3 && /* minor optimization */ |
1000 |
|
if (using_stdout & (outfmt == 'a')) |
1001 |
|
putc('\n', stdout); |
1002 |
|
if (!waitflush) { |
1003 |
< |
waitflush = xres; |
1003 |
> |
waitflush = (yres > 0) & (xres > 1) ? 0 : xres; |
1004 |
|
if (using_stdout) |
1005 |
|
fflush(stdout); |
1006 |
|
} |
1065 |
|
cp += sizeof(float)*9; n -= sizeof(float)*9; |
1066 |
|
add_contrib(modname); |
1067 |
|
} |
1068 |
< |
if (!accumulate) |
1069 |
< |
done_contrib(); /* sum up contributions & output */ |
1068 |
> |
/* time to produce record? */ |
1069 |
> |
if (account > 0 && !--account) |
1070 |
> |
done_contrib(account = accumulate); |
1071 |
|
lastdone = rtp->raynum; |
1072 |
|
if (rtp->buf != NULL) /* free up buffer space */ |
1073 |
|
free(rtp->buf); |
1082 |
|
{ |
1083 |
|
struct rtproc *rtfree = NULL; |
1084 |
|
fd_set readset, errset; |
1085 |
< |
int nr; |
1085 |
> |
ssize_t nr; |
1086 |
|
struct rtproc *rt; |
1087 |
|
int n; |
1088 |
|
|
1113 |
|
continue; |
1114 |
|
if (rt->buf == NULL) { |
1115 |
|
rt->bsiz = treebufsiz; |
1116 |
< |
rt->buf = (char *)malloc(treebufsiz); |
1116 |
> |
rt->buf = (char *)malloc(rt->bsiz); |
1117 |
|
} else if (rt->nbr + BUFSIZ > rt->bsiz) { |
1118 |
|
if (rt->bsiz + BUFSIZ <= treebufsiz) |
1119 |
|
rt->bsiz = treebufsiz; |
1120 |
< |
else |
1121 |
< |
treebufsiz = rt->bsiz += BUFSIZ; |
1120 |
> |
else if ((treebufsiz = rt->bsiz += BUFSIZ) < 0) |
1121 |
> |
error(INTERNAL, |
1122 |
> |
"ray buffer does not fit memory"); |
1123 |
|
rt->buf = (char *)realloc(rt->buf, rt->bsiz); |
1124 |
|
} |
1125 |
|
if (rt->buf == NULL) |
1126 |
|
error(SYSTEM, "out of memory in wait_rproc"); |
1127 |
< |
nr = read(rt->pd.r, rt->buf+rt->nbr, rt->bsiz-rt->nbr); |
1128 |
< |
if (nr <= 0) |
1127 |
> |
nr = rt->bsiz - rt->nbr; |
1128 |
> |
if (nr & ~0x7fffffff) /* avoid 32-bit OS issues */ |
1129 |
> |
nr = 0x7fffffff; |
1130 |
> |
nr = read(rt->pd.r, rt->buf+rt->nbr, nr); |
1131 |
> |
if (nr < 0) |
1132 |
> |
error(SYSTEM, "read error from rtrace"); |
1133 |
> |
if (!nr) |
1134 |
|
error(USER, "rtrace process died"); |
1135 |
|
rt->nbr += nr; /* advance & check */ |
1136 |
< |
if (rt->nbr >= 4 && !memcmp(rt->buf+rt->nbr-4, |
1137 |
< |
"~\t~\t", 4)) { |
1138 |
< |
rt->nbr -= 4; /* elide terminator */ |
1136 |
> |
if (rt->nbr >= 6 && !memcmp(rt->buf+rt->nbr-6, |
1137 |
> |
"~\t~\t~\t", 6)) { |
1138 |
> |
rt->nbr -= 6; /* elide terminator */ |
1139 |
|
queue_raytree(rt); |
1140 |
|
rtfree = rt; /* ready for next ray */ |
1141 |
|
} |
1160 |
|
void |
1161 |
|
trace_contribs(FILE *fin) |
1162 |
|
{ |
1163 |
+ |
static int ignore_warning_given = 0; |
1164 |
|
char inpbuf[128]; |
1165 |
|
int iblen; |
1166 |
|
struct rtproc *rtp; |
1167 |
|
/* loop over input */ |
1168 |
|
while ((iblen = getinp(inpbuf, fin)) >= 0) { |
1169 |
< |
if (!iblen || /* need reset? */ |
1169 |
> |
if (!iblen && accumulate != 1) { |
1170 |
> |
if (!ignore_warning_given++) |
1171 |
> |
error(WARNING, |
1172 |
> |
"dummy ray(s) ignored during accumulation\n"); |
1173 |
> |
continue; |
1174 |
> |
} |
1175 |
> |
if (!iblen || /* need flush/reset? */ |
1176 |
|
queue_length() > 10*nrtprocs() || |
1177 |
|
lastray+1 < lastray) { |
1178 |
|
while (wait_rproc() != NULL) |
1179 |
|
process_queue(); |
1180 |
< |
if (lastray+1 < lastray) |
1150 |
< |
lastdone = lastray = 0; |
1180 |
> |
lastdone = lastray = 0; |
1181 |
|
} |
1182 |
|
rtp = get_rproc(); /* get avail. rtrace process */ |
1183 |
|
rtp->raynum = ++lastray; /* assign ray */ |
1184 |
|
if (iblen) { /* trace ray if valid */ |
1185 |
|
writebuf(rtp->pd.w, inpbuf, iblen); |
1186 |
|
} else { /* else bypass dummy ray */ |
1187 |
< |
queue_raytree(rtp); /* empty tree */ |
1188 |
< |
if ((yres <= 0) | (waitflush > 1)) |
1189 |
< |
waitflush = 1; /* flush after this */ |
1187 |
> |
queue_raytree(rtp); /* queue empty ray/record */ |
1188 |
> |
if ((yres <= 0) | (xres <= 0)) |
1189 |
> |
waitflush = 1; /* flush right after */ |
1190 |
|
} |
1191 |
|
process_queue(); /* catch up with results */ |
1192 |
|
if (raysleft && !--raysleft) |
1194 |
|
} |
1195 |
|
while (wait_rproc() != NULL) /* process outstanding rays */ |
1196 |
|
process_queue(); |
1197 |
< |
if (accumulate) |
1198 |
< |
done_contrib(); /* output tallies */ |
1197 |
> |
if (accumulate <= 0) |
1198 |
> |
done_contrib(0); /* output tallies */ |
1199 |
> |
else if (account < accumulate) { |
1200 |
> |
error(WARNING, "partial accumulation in final record"); |
1201 |
> |
done_contrib(accumulate - account); |
1202 |
> |
} |
1203 |
|
if (raysleft) |
1204 |
|
error(USER, "unexpected EOF on input"); |
1205 |
|
lu_done(&ofiletab); /* close output files */ |
1241 |
|
STREAMOUT *sop = (STREAMOUT *)e->data; |
1242 |
|
|
1243 |
|
if (sop->ofp == NULL) |
1244 |
< |
return; |
1244 |
> |
return(0); |
1245 |
|
fclose(sop->ofp); |
1246 |
|
sop->ofp = NULL; |
1247 |
+ |
return(0); |
1248 |
|
} |
1249 |
|
|
1250 |
|
/* load previously accumulated values */ |
1318 |
|
} |
1319 |
|
if ((sout.xr > 0) & (sout.yr > 0) && |
1320 |
|
(!fscnresolu(&xr, &yr, sout.ofp) || |
1321 |
< |
xr != sout.xr || |
1322 |
< |
yr != sout.yr)) { |
1321 |
> |
(xr != sout.xr) | |
1322 |
> |
(yr != sout.yr))) { |
1323 |
|
sprintf(errmsg, "resolution mismatch for '%s'", |
1324 |
|
oname); |
1325 |
|
error(USER, errmsg); |
1326 |
|
} |
1327 |
|
} |
1293 |
– |
if (oent->key == NULL) /* new file entry */ |
1294 |
– |
oent->key = strcpy((char *) |
1295 |
– |
malloc(strlen(oname)+1), oname); |
1296 |
– |
if (oent->data == NULL) |
1297 |
– |
oent->data = (char *)malloc(sizeof(STREAMOUT)); |
1298 |
– |
*(STREAMOUT *)oent->data = sout; |
1328 |
|
/* read in RGB value */ |
1329 |
|
if (!get_contrib(rgbv, sout.ofp)) { |
1330 |
< |
if (!j) |
1330 |
> |
if (!j) { |
1331 |
> |
fclose(sout.ofp); |
1332 |
|
break; /* ignore empty file */ |
1333 |
< |
if (j && j < mp->nbins) { |
1333 |
> |
} |
1334 |
> |
if (j < mp->nbins) { |
1335 |
|
sprintf(errmsg, "missing data in '%s'", |
1336 |
|
oname); |
1337 |
|
error(USER, errmsg); |
1341 |
|
if (j >= mp->nbins) /* grow modifier size */ |
1342 |
|
ment->data = (char *)(mp = growmodifier(mp, j+1)); |
1343 |
|
copycolor(mp->cbin[j], rgbv); |
1344 |
+ |
if (oent->key == NULL) /* new file entry */ |
1345 |
+ |
oent->key = strcpy((char *) |
1346 |
+ |
malloc(strlen(oname)+1), oname); |
1347 |
+ |
if (oent->data == NULL) |
1348 |
+ |
oent->data = (char *)malloc(sizeof(STREAMOUT)); |
1349 |
+ |
*(STREAMOUT *)oent->data = sout; |
1350 |
|
} |
1351 |
|
} |
1352 |
|
lu_doall(&ofiletab, myclose, NULL); /* close all files */ |
1422 |
|
} else { |
1423 |
|
sout.reclen = 0; |
1424 |
|
sout.outpipe = 0; |
1388 |
– |
sout.xr = xres; sout.yr = yres; |
1425 |
|
sout.ofp = NULL; |
1426 |
|
} |
1427 |
|
if (sout.ofp != NULL) { /* already open? */ |
1462 |
|
oname); |
1463 |
|
error(USER, errmsg); |
1464 |
|
} |
1465 |
< |
if ((xres > 0) & (yres > 0) && |
1465 |
> |
sout.xr = xres; sout.yr = yres; |
1466 |
> |
if ((sout.xr > 0) & (sout.yr > 0) && |
1467 |
|
(!fscnresolu(&xr, &yr, sout.ofp) || |
1468 |
< |
xr != xres || |
1469 |
< |
yr != yres)) { |
1468 |
> |
(xr != sout.xr) | |
1469 |
> |
(yr != sout.yr))) { |
1470 |
|
sprintf(errmsg, "resolution mismatch for '%s'", |
1471 |
|
oname); |
1472 |
|
error(USER, errmsg); |
1495 |
|
error(WARNING, "no output files to recover"); |
1496 |
|
return; |
1497 |
|
} |
1498 |
< |
if (raysleft && lastout >= raysleft) { |
1498 |
> |
if (raysleft && lastout >= raysleft/accumulate) { |
1499 |
|
error(WARNING, "output appears to be complete"); |
1500 |
|
/* XXX should read & discard input? */ |
1501 |
|
quit(0); |
1507 |
|
for (nvals = 0; nvals < lastout; nvals++) |
1508 |
|
if (getinp(oname, fin) < 0) |
1509 |
|
error(USER, "unexpected EOF on input"); |
1510 |
< |
lastray = lastdone = (unsigned long)lastout; |
1510 |
> |
lastray = lastdone = (unsigned long)lastout * accumulate; |
1511 |
|
if (raysleft) |
1512 |
|
raysleft -= lastray; |
1513 |
|
} |