27 |
|
|
28 |
|
#include "paths.h" |
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 */ |
51 |
|
double shadcert = .5; /* shadow certainty */ |
52 |
|
int directrelay = 1; /* number of source relays */ |
53 |
|
int vspretest = 512; /* virtual source pretest density */ |
54 |
< |
int directinvis = 0; /* sources invisible? */ |
54 |
> |
int directvis = 1; /* sources visible? */ |
55 |
|
double srcsizerat = .25; /* maximum ratio source size/dist. */ |
56 |
|
|
57 |
|
double specthresh = .15; /* specular sampling threshold */ |
88 |
|
|
89 |
|
#define pixjitter() (.5+dstrpix*(.5-frandom())) |
90 |
|
|
85 |
– |
#define RFTEMPLATE "rfXXXXXX" |
86 |
– |
#define HFTEMPLATE TEMPLATE |
87 |
– |
|
88 |
– |
static char *hfname = NULL; /* header file name */ |
89 |
– |
static FILE *hfp = NULL; /* header file pointer */ |
90 |
– |
|
91 |
|
static int hres, vres; /* resolution for this frame */ |
92 |
|
|
93 |
|
extern char *mktemp(); |
100 |
|
{ |
101 |
|
if (code) /* report status */ |
102 |
|
report(); |
103 |
< |
if (hfname != NULL) { /* delete header file */ |
104 |
< |
if (hfp != NULL) |
105 |
< |
fclose(hfp); |
106 |
< |
unlink(hfname); |
107 |
< |
} |
103 |
> |
headclean(); /* delete header file */ |
104 |
> |
pfclean(); /* clean up persist files */ |
105 |
|
exit(code); |
106 |
|
} |
107 |
|
|
131 |
|
sprintf(errmsg, "%ld 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 |
|
|
138 |
|
|
142 |
– |
openheader() /* save standard output to header file */ |
143 |
– |
{ |
144 |
– |
hfname = mktemp(HFTEMPLATE); |
145 |
– |
if (freopen(hfname, "w", stdout) == NULL) { |
146 |
– |
sprintf(errmsg, "cannot open header file \"%s\"", hfname); |
147 |
– |
error(SYSTEM, errmsg); |
148 |
– |
} |
149 |
– |
} |
150 |
– |
|
151 |
– |
|
152 |
– |
dupheader() /* repeat header on standard output */ |
153 |
– |
{ |
154 |
– |
register int c; |
155 |
– |
|
156 |
– |
if (hfp == NULL) { |
157 |
– |
if ((hfp = fopen(hfname, "r")) == NULL) |
158 |
– |
error(SYSTEM, "error reopening header file"); |
159 |
– |
#ifdef MSDOS |
160 |
– |
setmode(fileno(hfp), O_BINARY); |
161 |
– |
#endif |
162 |
– |
} else if (fseek(hfp, 0L, 0) < 0) |
163 |
– |
error(SYSTEM, "seek error on header file"); |
164 |
– |
while ((c = getc(hfp)) != EOF) |
165 |
– |
putchar(c); |
166 |
– |
} |
167 |
– |
|
168 |
– |
|
139 |
|
rpict(seq, pout, zout, prvr) /* generate image(s) */ |
140 |
|
int seq; |
141 |
|
char *pout, *zout, *prvr; |
151 |
|
* sequenced file naming. |
152 |
|
*/ |
153 |
|
{ |
154 |
< |
extern char *rindex(), *strncpy(), *strcat(); |
154 |
> |
extern char *rindex(), *strncpy(), *strcat(), *strcpy(); |
155 |
|
char fbuf[128], fbuf2[128]; |
156 |
|
register char *cp; |
157 |
|
RESOLU rs; |
328 |
|
#ifndef BSD |
329 |
|
else |
330 |
|
#endif |
331 |
< |
signal(SIGALRM, report); |
331 |
> |
signal(SIGCONT, report); |
332 |
|
ypos = vres-1 - i; |
333 |
|
fillscanline(scanbar[0], zbar[0], sampdens, hres, ypos, hstep); |
334 |
|
/* compute scanlines */ |
351 |
|
fillscanbar(scanbar, zbar, hres, ypos, ystep); |
352 |
|
/* write it out */ |
353 |
|
#ifndef BSD |
354 |
< |
signal(SIGALRM, SIG_IGN); /* don't interrupt writes */ |
354 |
> |
signal(SIGCONT, SIG_IGN); /* don't interrupt writes */ |
355 |
|
#endif |
356 |
|
for (i = ystep; i > 0; i--) { |
357 |
|
if (zfd != -1 && write(zfd, (char *)zbar[i], |
369 |
|
report(); |
370 |
|
#ifndef BSD |
371 |
|
else |
372 |
< |
signal(SIGALRM, report); |
372 |
> |
signal(SIGCONT, report); |
373 |
|
#endif |
374 |
|
} |
375 |
|
/* clean up */ |
376 |
< |
signal(SIGALRM, SIG_IGN); |
376 |
> |
signal(SIGCONT, SIG_IGN); |
377 |
|
if (zfd != -1) { |
378 |
|
if (write(zfd, (char *)zbar[0], hres*sizeof(float)) |
379 |
|
< hres*sizeof(float)) |
566 |
|
setmode(fileno(fp), O_BINARY); |
567 |
|
#endif |
568 |
|
/* discard header */ |
569 |
< |
getheader(fp, NULL); |
569 |
> |
getheader(fp, NULL, NULL); |
570 |
|
/* get picture size */ |
571 |
|
if (!fscnresolu(&x, &y, fp)) { |
572 |
|
sprintf(errmsg, "bad recover file \"%s\"", oldfile); |