--- ray/src/rt/rv2.c 1993/08/25 14:13:51 2.18 +++ ray/src/rt/rv2.c 1994/12/20 20:18:37 2.26 @@ -1,4 +1,4 @@ -/* Copyright (c) 1993 Regents of the University of California */ +/* Copyright (c) 1994 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -32,8 +32,10 @@ static char SCCSid[] = "$SunId$ LBL"; extern char *atos(); -extern char rifname[]; /* rad input file name */ +extern FILE *popen(); +extern char rifname[128]; /* rad input file name */ + extern char VersionID[]; extern char *progname; extern char *octname; @@ -138,6 +140,16 @@ char *s; else { nv.horiz = ourview.horiz; nv.vert = ourview.vert; } + sprintf(buf, "fore and aft clipping plane (%.6g %.6g): ", + ourview.vfore, ourview.vaft); + (*dev->comout)(buf); + (*dev->comin)(buf, NULL); + if (buf[0] == CTRL('C')) return; + if (sscanf(buf, "%lf %lf", &nv.vfore, &nv.vaft) == 2) + change++; + else { + nv.vfore = ourview.vfore; nv.vaft = ourview.vaft; + } sprintf(buf, "view shift and lift (%.6g %.6g): ", ourview.hoff, ourview.voff); (*dev->comout)(buf); @@ -163,7 +175,7 @@ char *s; if (sscanf(s, "%s", buf) == 1) { /* get parameters from a file */ copystruct(&nv, &stdview); - if ((fname = getpath(buf, NULL, 0)) == NULL || + if ((fname = getpath(buf, "", R_OK)) == NULL || (success = viewfile(fname, &nv, NULL)) == -1) { sprintf(errmsg, "cannot open \"%s\"", buf); error(COMMAND, errmsg); @@ -193,9 +205,18 @@ char *s; char *fname; FILE *fp; - if (*atos(view, sizeof(view), s)) + if (*atos(view, sizeof(view), s)) { + if (isint(view)) { + error(COMMAND, "cannot write view by number"); + return; + } s = sskip(s); - if (sscanf(s, "%s", rifname) != 1 && rifname[0] == '\0') { + } + while (isspace(*s)) + s++; + if (*s) + atos(rifname, sizeof(rifname), s); + else if (rifname[0] == '\0') { error(COMMAND, "no previous rad file"); return; } @@ -226,12 +247,13 @@ char *s; s = sskip(s); else strcat(buf, "1"); - if (sscanf(s, "%s", rifname) != 1 && rifname[0] == '\0') { + if (*s) + atos(rifname, sizeof(rifname), s); + else if (rifname[0] == '\0') { error(COMMAND, "no previous rad file"); return; } - fname = getpath(rifname, NULL, 0); - if (fname == NULL || access(fname, R_OK) == -1) { + if ((fname = getpath(rifname, "", R_OK)) == NULL) { sprintf(errmsg, "cannot access \"%s\"", rifname); error(COMMAND, errmsg); return; @@ -338,12 +360,13 @@ char *s; register PNODE *p = &ptrunk; int adapt = 0; double e = 1.0; -start: + for (cp = s; isspace(*cp); cp++) ; if (*cp == '@') { adapt++; - goto start; + while (isspace(*++cp)) + ; } if (*cp == '\0') { /* normalize to point */ if (dev->getcur == NULL) @@ -597,6 +620,8 @@ char *s; int x, y; RAY thisray; + thisray.rmax = 0.0; + if (!sscanvec(s, thisray.rorg) || !sscanvec(sskip(sskip(sskip(s))), thisray.rdir)) { @@ -606,8 +631,8 @@ char *s; if ((*dev->getcur)(&x, &y) == ABORT) return; - if (viewray(thisray.rorg, thisray.rdir, &ourview, - (x+.5)/hresolu, (y+.5)/vresolu) < 0) { + if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, + &ourview, (x+.5)/hresolu, (y+.5)/vresolu)) < -FTINY) { error(COMMAND, "not on image"); return; } @@ -624,8 +649,10 @@ char *s; if (thisray.ro == NULL) (*dev->comout)("ray hit nothing"); else { - sprintf(buf, "ray hit %s %s \"%s\"", - objptr(thisray.ro->omod)->oname, + sprintf(buf, "ray hit %s%s %s \"%s\"", + thisray.rod < 0.0 ? "back of " : "", + thisray.ro->omod == OVOID ? VOIDID : + objptr(thisray.ro->omod)->oname, ofun[thisray.ro->otype].funame, thisray.ro->oname); (*dev->comout)(buf); @@ -658,7 +685,11 @@ char *s; COLR *scanline; int y; - if (sscanf(s, "%s", buf) != 1 && buf[0] == '\0') { + while (isspace(*s)) + s++; + if (*s) + atos(buf, sizeof(buf), s); + else if (buf[0] == '\0') { error(COMMAND, "no file"); return; } @@ -675,6 +706,7 @@ char *s; (*dev->comout)(fname); (*dev->comout)("\"...\n"); /* write header */ + newheader("RADIANCE", fp); fputs(progname, fp); fprintview(&ourview, fp); if (octname != NULL)