29 |
|
|
30 |
|
#define RFTEMPLATE "rfXXXXXX" |
31 |
|
|
32 |
+ |
#ifndef SIGCONT |
33 |
+ |
#define SIGCONT SIGIO |
34 |
+ |
#endif |
35 |
+ |
|
36 |
|
int dimlist[MAXDIM]; /* sampling dimensions */ |
37 |
|
int ndims = 0; /* number of sampling dimensions */ |
38 |
|
int samplendx; /* sample index number */ |
82 |
|
extern long time(); |
83 |
|
extern long tstart; /* starting time */ |
84 |
|
|
85 |
< |
extern long nrays; /* number of rays traced */ |
85 |
> |
extern unsigned long nrays; /* number of rays traced */ |
86 |
|
|
87 |
|
#define MAXDIV 16 /* maximum sample size */ |
88 |
|
|
119 |
|
t += (rubuf.ru_utime.tv_usec + rubuf.ru_stime.tv_usec) / 1e6; |
120 |
|
t += rubuf.ru_utime.tv_sec + rubuf.ru_stime.tv_sec; |
121 |
|
|
122 |
< |
sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f CPU hours\n", |
122 |
> |
sprintf(errmsg, "%lu rays, %4.2f%% done after %5.4f CPU hours\n", |
123 |
|
nrays, pctdone, t/3600.0); |
124 |
|
eputs(errmsg); |
125 |
|
tlastrept = time((long *)0); |
128 |
|
report() /* report progress */ |
129 |
|
{ |
130 |
|
tlastrept = time((long *)0); |
131 |
< |
sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f hours\n", |
131 |
> |
sprintf(errmsg, "%lu rays, %4.2f%% done after %5.4f hours\n", |
132 |
|
nrays, pctdone, (tlastrept-tstart)/3600.0); |
133 |
|
eputs(errmsg); |
134 |
< |
signal(SIGALRM, report); |
134 |
> |
signal(SIGCONT, report); |
135 |
|
} |
136 |
|
#endif |
137 |
|
|
153 |
|
{ |
154 |
|
extern char *rindex(), *strncpy(), *strcat(), *strcpy(); |
155 |
|
char fbuf[128], fbuf2[128]; |
156 |
+ |
int npicts; |
157 |
|
register char *cp; |
158 |
|
RESOLU rs; |
159 |
|
double pa; |
198 |
|
} |
199 |
|
} |
200 |
|
} |
201 |
< |
/* render sequence */ |
201 |
> |
npicts = 0; /* render sequence */ |
202 |
|
do { |
203 |
|
if (seq && nextview(stdin) == EOF) |
204 |
|
break; |
205 |
+ |
pctdone = 0.0; |
206 |
|
if (pout != NULL) { |
207 |
|
sprintf(fbuf, pout, seq); |
208 |
+ |
if (prvr == NULL && access(fbuf, F_OK) == 0) |
209 |
+ |
continue; /* don't clobber */ |
210 |
|
if (freopen(fbuf, "w", stdout) == NULL) { |
211 |
|
sprintf(errmsg, |
212 |
|
"cannot open output file \"%s\"", fbuf); |
254 |
|
cp = NULL; |
255 |
|
render(cp, prvr); |
256 |
|
prvr = NULL; |
257 |
+ |
npicts++; |
258 |
|
} while (seq++); |
259 |
+ |
/* check that we did something */ |
260 |
+ |
if (npicts == 0) |
261 |
+ |
error(WARNING, "no output produced"); |
262 |
|
} |
263 |
|
|
264 |
|
|
304 |
|
sampdens[i] = hstep; |
305 |
|
} else |
306 |
|
sampdens = NULL; |
307 |
< |
/* open z file */ |
307 |
> |
/* open z-file */ |
308 |
|
if (zfile != NULL) { |
309 |
|
if ((zfd = open(zfile, O_WRONLY|O_CREAT, 0666)) == -1) { |
310 |
< |
sprintf(errmsg, "cannot open z file \"%s\"", zfile); |
310 |
> |
sprintf(errmsg, "cannot open z-file \"%s\"", zfile); |
311 |
|
error(SYSTEM, errmsg); |
312 |
|
} |
313 |
|
#ifdef MSDOS |
329 |
|
i = salvage(oldfile); |
330 |
|
if (zfd != -1 && i > 0 && |
331 |
|
lseek(zfd, (long)i*hres*sizeof(float), 0) == -1) |
332 |
< |
error(SYSTEM, "z file seek error in render"); |
332 |
> |
error(SYSTEM, "z-file seek error in render"); |
333 |
|
pctdone = 100.0*i/vres; |
334 |
|
if (ralrm > 0) /* report init stats */ |
335 |
|
report(); |
336 |
|
#ifndef BSD |
337 |
|
else |
338 |
|
#endif |
339 |
< |
signal(SIGALRM, report); |
339 |
> |
signal(SIGCONT, report); |
340 |
|
ypos = vres-1 - i; |
341 |
|
fillscanline(scanbar[0], zbar[0], sampdens, hres, ypos, hstep); |
342 |
|
/* compute scanlines */ |
359 |
|
fillscanbar(scanbar, zbar, hres, ypos, ystep); |
360 |
|
/* write it out */ |
361 |
|
#ifndef BSD |
362 |
< |
signal(SIGALRM, SIG_IGN); /* don't interrupt writes */ |
362 |
> |
signal(SIGCONT, SIG_IGN); /* don't interrupt writes */ |
363 |
|
#endif |
364 |
|
for (i = ystep; i > 0; i--) { |
365 |
|
if (zfd != -1 && write(zfd, (char *)zbar[i], |
377 |
|
report(); |
378 |
|
#ifndef BSD |
379 |
|
else |
380 |
< |
signal(SIGALRM, report); |
380 |
> |
signal(SIGCONT, report); |
381 |
|
#endif |
382 |
|
} |
383 |
|
/* clean up */ |
384 |
< |
signal(SIGALRM, SIG_IGN); |
384 |
> |
signal(SIGCONT, SIG_IGN); |
385 |
|
if (zfd != -1) { |
386 |
|
if (write(zfd, (char *)zbar[0], hres*sizeof(float)) |
387 |
|
< hres*sizeof(float)) |
401 |
|
pctdone = 100.0; |
402 |
|
if (ralrm > 0) |
403 |
|
report(); |
404 |
+ |
signal(SIGCONT, SIG_DFL); |
405 |
|
return; |
406 |
|
writerr: |
407 |
|
error(SYSTEM, "write error in render"); |