--- ray/src/rt/rpict.c 1992/10/15 21:13:17 2.17 +++ ray/src/rt/rpict.c 1992/11/19 20:25:57 2.20 @@ -45,7 +45,7 @@ double shadthresh = .05; /* shadow threshold */ double shadcert = .5; /* shadow certainty */ int directrelay = 1; /* number of source relays */ int vspretest = 512; /* virtual source pretest density */ -int directinvis = 0; /* sources invisible? */ +int directvis = 1; /* sources visible? */ double srcsizerat = .25; /* maximum ratio source size/dist. */ double specthresh = .15; /* specular sampling threshold */ @@ -149,23 +149,17 @@ openheader() /* save standard output to header file } -closeheader() /* done with header output */ -{ - if (hfname == NULL) - return; - if (fflush(stdout) == EOF || (hfp = fopen(hfname, "r")) == NULL) - error(SYSTEM, "error reopening header file"); -#ifdef MSDOS - setmode(fileno(hfp), O_BINARY); -#endif -} - - dupheader() /* repeat header on standard output */ { register int c; - if (fseek(hfp, 0L, 0) < 0) + if (hfp == NULL) { + if ((hfp = fopen(hfname, "r")) == NULL) + error(SYSTEM, "error reopening header file"); +#ifdef MSDOS + setmode(fileno(hfp), O_BINARY); +#endif + } else if (fseek(hfp, 0L, 0) < 0) error(SYSTEM, "seek error on header file"); while ((c = getc(hfp)) != EOF) putchar(c); @@ -192,8 +186,6 @@ char *pout, *zout, *prvr; register char *cp; RESOLU rs; double pa; - /* finished writing header */ - closeheader(); /* check sampling */ if (psample < 1) psample = 1; @@ -217,13 +209,15 @@ char *pout, *zout, *prvr; error(USER, "unexpected EOF on view input"); prvr = fbuf; /* mark for renaming */ } - if (pout != NULL) { + if (pout != NULL & prvr != NULL) { sprintf(fbuf, pout, seq); - if (prvr != NULL && !strcmp(prvr, fbuf)) { /* rename */ - fbuf2[0] = '\0'; - if ((cp = rindex(fbuf, '/')) != NULL) - strncpy(fbuf2, fbuf, cp-fbuf+1); - strcat(fbuf2, RFTEMPLATE); + if (!strcmp(prvr, fbuf)) { /* rename */ + strcpy(fbuf2, fbuf); + for (cp = fbuf2; *cp; cp++) + ; + while (cp > fbuf2 && !ISDIRSEP(cp[-1])) + cp--; + strcpy(cp, RFTEMPLATE); prvr = mktemp(fbuf2); if (rename(fbuf, prvr) < 0 && errno != ENOENT) { sprintf(errmsg, @@ -602,7 +596,7 @@ char *oldfile; setmode(fileno(fp), O_BINARY); #endif /* discard header */ - getheader(fp, NULL); + getheader(fp, NULL, NULL); /* get picture size */ if (!fscnresolu(&x, &y, fp)) { sprintf(errmsg, "bad recover file \"%s\"", oldfile);