26 |
|
|
27 |
|
#include "random.h" |
28 |
|
|
29 |
+ |
#include "paths.h" |
30 |
+ |
|
31 |
|
int dimlist[MAXDIM]; /* sampling dimensions */ |
32 |
|
int ndims = 0; /* number of sampling dimensions */ |
33 |
|
int samplendx; /* sample index number */ |
79 |
|
|
80 |
|
#define pixjitter() (.5+dstrpix*(.5-frandom())) |
81 |
|
|
82 |
< |
#define HFTEMPLATE "/tmp/hfXXXXXX" |
82 |
> |
#define RFTEMPLATE "rfXXXXXX" |
83 |
> |
#define HFTEMPLATE TEMPLATE |
84 |
|
|
85 |
|
static char *hfname = NULL; /* header file name */ |
86 |
|
static FILE *hfp = NULL; /* header file pointer */ |
182 |
|
*/ |
183 |
|
{ |
184 |
|
extern char *rindex(), *strncpy(), *strcat(); |
185 |
< |
char fbuf[128], fbuf2[128], *zf; |
185 |
> |
char fbuf[128], fbuf2[128]; |
186 |
> |
register char *cp; |
187 |
|
RESOLU rs; |
188 |
|
double pa; |
189 |
|
/* finished writing header */ |
201 |
|
if (seq <= 0) |
202 |
|
seq = 0; |
203 |
|
else if (prvr != NULL && isint(prvr)) { |
204 |
< |
int rn; /* skip to specified view */ |
204 |
> |
register int rn; /* skip to specified view */ |
205 |
|
if ((rn = atoi(prvr)) < seq) |
206 |
|
error(USER, "recover frame less than start frame"); |
207 |
|
if (pout == NULL) |
213 |
|
} |
214 |
|
if (pout != NULL) { |
215 |
|
sprintf(fbuf, pout, seq); |
216 |
< |
if (!strcmp(prvr, fbuf)) { /* rename recover file */ |
216 |
> |
if (prvr != NULL && !strcmp(prvr, fbuf)) { /* rename */ |
217 |
|
fbuf2[0] = '\0'; |
218 |
< |
if ((prvr = rindex(fbuf, '/')) != NULL) |
219 |
< |
strncpy(fbuf2, fbuf, prvr-fbuf+1); |
220 |
< |
strcat(fbuf2, "rfXXXXXX"); |
218 |
> |
if ((cp = rindex(fbuf, '/')) != NULL) |
219 |
> |
strncpy(fbuf2, fbuf, cp-fbuf+1); |
220 |
> |
strcat(fbuf2, RFTEMPLATE); |
221 |
|
prvr = mktemp(fbuf2); |
222 |
|
if (rename(fbuf, prvr) < 0 && errno != ENOENT) { |
223 |
|
sprintf(errmsg, |
248 |
|
"cannot recover view parameters from \"%s\"", prvr); |
249 |
|
error(WARNING, errmsg); |
250 |
|
} else { |
247 |
– |
char *err; |
248 |
– |
if ((err = setview(&ourview)) != NULL) |
249 |
– |
error(USER, err); |
251 |
|
pa = 0.0; |
252 |
|
hres = scanlen(&rs); |
253 |
|
vres = numscans(&rs); |
254 |
|
} |
255 |
+ |
if ((cp = setview(&ourview)) != NULL) |
256 |
+ |
error(USER, cp); |
257 |
|
normaspect(viewaspect(&ourview), &pa, &hres, &vres); |
258 |
|
if (seq) { |
259 |
|
if (ralrm > 0) { |
260 |
< |
sprintf(errmsg, "starting frame %d\n", seq); |
261 |
< |
eputs(errmsg); |
260 |
> |
fprintf(stderr, "FRAME %d:", seq); |
261 |
> |
fprintview(&ourview, stderr); |
262 |
> |
putc('\n', stderr); |
263 |
> |
fflush(stderr); |
264 |
|
} |
265 |
|
printf("FRAME=%d\n", seq); |
266 |
|
} |
272 |
|
fputformat(COLRFMT, stdout); |
273 |
|
putchar('\n'); |
274 |
|
if (zout != NULL) |
275 |
< |
sprintf(zf=fbuf, zout, seq); |
275 |
> |
sprintf(cp=fbuf, zout, seq); |
276 |
|
else |
277 |
< |
zf = NULL; |
278 |
< |
render(zf, prvr); |
277 |
> |
cp = NULL; |
278 |
> |
render(cp, prvr); |
279 |
|
prvr = NULL; |
280 |
|
} while (seq++); |
281 |
|
} |
284 |
|
nextview(fp) /* get next view from fp */ |
285 |
|
FILE *fp; |
286 |
|
{ |
287 |
< |
char linebuf[256], *err; |
287 |
> |
char linebuf[256]; |
288 |
|
|
289 |
|
while (fgets(linebuf, sizeof(linebuf), fp) != NULL) |
290 |
< |
if (isview(linebuf) && sscanview(&ourview, linebuf) > 0) { |
286 |
< |
if ((err = setview(&ourview)) != NULL) |
287 |
< |
error(USER, err); |
290 |
> |
if (isview(linebuf) && sscanview(&ourview, linebuf) > 0) |
291 |
|
return(0); |
289 |
– |
} |
292 |
|
return(EOF); |
293 |
|
} |
294 |
|
|
415 |
|
if (sampdens != NULL) |
416 |
|
free(sampdens); |
417 |
|
pctdone = 100.0; |
418 |
+ |
if (ralrm > 0) |
419 |
+ |
report(); |
420 |
|
return; |
421 |
|
writerr: |
422 |
|
error(SYSTEM, "write error in render"); |
619 |
|
unlink(oldfile); |
620 |
|
return(y); |
621 |
|
writerr: |
622 |
< |
error(SYSTEM, "write error in salvage"); |
622 |
> |
sprintf(errmsg, "write error during recovery of \"%s\"", oldfile); |
623 |
> |
error(SYSTEM, errmsg); |
624 |
|
} |
625 |
|
|
626 |
|
|