1 |
< |
/* Copyright (c) 1993 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1994 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
32 |
|
|
33 |
|
extern char *atos(); |
34 |
|
|
35 |
< |
extern char rifname[]; /* rad input file name */ |
35 |
> |
extern FILE *popen(); |
36 |
|
|
37 |
+ |
extern char rifname[128]; /* rad input file name */ |
38 |
+ |
|
39 |
|
extern char VersionID[]; |
40 |
|
extern char *progname; |
41 |
|
extern char *octname; |
140 |
|
else { |
141 |
|
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
142 |
|
} |
143 |
+ |
sprintf(buf, "fore and aft clipping plane (%.6g %.6g): ", |
144 |
+ |
ourview.vfore, ourview.vaft); |
145 |
+ |
(*dev->comout)(buf); |
146 |
+ |
(*dev->comin)(buf, NULL); |
147 |
+ |
if (buf[0] == CTRL('C')) return; |
148 |
+ |
if (sscanf(buf, "%lf %lf", &nv.vfore, &nv.vaft) == 2) |
149 |
+ |
change++; |
150 |
+ |
else { |
151 |
+ |
nv.vfore = ourview.vfore; nv.vaft = ourview.vaft; |
152 |
+ |
} |
153 |
|
sprintf(buf, "view shift and lift (%.6g %.6g): ", |
154 |
|
ourview.hoff, ourview.voff); |
155 |
|
(*dev->comout)(buf); |
175 |
|
|
176 |
|
if (sscanf(s, "%s", buf) == 1) { /* get parameters from a file */ |
177 |
|
copystruct(&nv, &stdview); |
178 |
< |
if ((fname = getpath(buf, NULL, 0)) == NULL || |
178 |
> |
if ((fname = getpath(buf, "", R_OK)) == NULL || |
179 |
|
(success = viewfile(fname, &nv, NULL)) == -1) { |
180 |
|
sprintf(errmsg, "cannot open \"%s\"", buf); |
181 |
|
error(COMMAND, errmsg); |
205 |
|
char *fname; |
206 |
|
FILE *fp; |
207 |
|
|
208 |
< |
if (*atos(view, sizeof(view), s)) |
208 |
> |
if (*atos(view, sizeof(view), s)) { |
209 |
> |
if (isint(view)) { |
210 |
> |
error(COMMAND, "cannot write view by number"); |
211 |
> |
return; |
212 |
> |
} |
213 |
|
s = sskip(s); |
214 |
< |
if (sscanf(s, "%s", rifname) != 1 && rifname[0] == '\0') { |
214 |
> |
} |
215 |
> |
while (isspace(*s)) |
216 |
> |
s++; |
217 |
> |
if (*s) |
218 |
> |
atos(rifname, sizeof(rifname), s); |
219 |
> |
else if (rifname[0] == '\0') { |
220 |
|
error(COMMAND, "no previous rad file"); |
221 |
|
return; |
222 |
|
} |
247 |
|
s = sskip(s); |
248 |
|
else |
249 |
|
strcat(buf, "1"); |
250 |
< |
if (sscanf(s, "%s", rifname) != 1 && rifname[0] == '\0') { |
250 |
> |
if (*s) |
251 |
> |
atos(rifname, sizeof(rifname), s); |
252 |
> |
else if (rifname[0] == '\0') { |
253 |
|
error(COMMAND, "no previous rad file"); |
254 |
|
return; |
255 |
|
} |
256 |
< |
fname = getpath(rifname, NULL, 0); |
234 |
< |
if (fname == NULL || access(fname, R_OK) == -1) { |
256 |
> |
if ((fname = getpath(rifname, "", R_OK)) == NULL) { |
257 |
|
sprintf(errmsg, "cannot access \"%s\"", rifname); |
258 |
|
error(COMMAND, errmsg); |
259 |
|
return; |
360 |
|
register PNODE *p = &ptrunk; |
361 |
|
int adapt = 0; |
362 |
|
double e = 1.0; |
363 |
< |
start: |
363 |
> |
|
364 |
|
for (cp = s; isspace(*cp); cp++) |
365 |
|
; |
366 |
|
if (*cp == '@') { |
367 |
|
adapt++; |
368 |
< |
goto start; |
368 |
> |
while (isspace(*++cp)) |
369 |
> |
; |
370 |
|
} |
371 |
|
if (*cp == '\0') { /* normalize to point */ |
372 |
|
if (dev->getcur == NULL) |
500 |
|
extern int do_irrad; |
501 |
|
extern double specjitter; |
502 |
|
extern double specthresh; |
503 |
+ |
extern int backvis; |
504 |
|
char buf[128]; |
505 |
|
|
506 |
|
if (s[0] == '\0') { |
507 |
|
(*dev->comout)( |
508 |
< |
"aa ab ad ar as av b dc di dj ds dt i lr lw ps pt sj st: "); |
508 |
> |
"aa ab ad ar as av b dc di dj ds dt i lr lw ps pt sj st bv: "); |
509 |
|
(*dev->comin)(buf, NULL); |
510 |
|
s = buf; |
511 |
|
} |
544 |
|
goto badparam; |
545 |
|
} |
546 |
|
break; |
547 |
< |
case 'b': /* black and white */ |
548 |
< |
getparam(s+1, "black and white", 'b', &greyscale); |
547 |
> |
case 'b': /* back faces or black and white */ |
548 |
> |
switch (s[1]) { |
549 |
> |
case 'v': /* back face visibility */ |
550 |
> |
getparam(s+2, "back face visibility", 'b', &backvis); |
551 |
> |
break; |
552 |
> |
case '\0': /* black and white */ |
553 |
> |
case 'y': case 'Y': case 't': case 'T': case '1': case '+': |
554 |
> |
case 'n': case 'N': case 'f': case 'F': case '0': case '-': |
555 |
> |
getparam(s+1, "black and white", 'b', &greyscale); |
556 |
> |
break; |
557 |
> |
default: |
558 |
> |
goto badparam; |
559 |
> |
} |
560 |
|
break; |
561 |
|
case 'i': /* irradiance */ |
562 |
|
getparam(s+1, "irradiance", 'b', &do_irrad); |
632 |
|
int x, y; |
633 |
|
RAY thisray; |
634 |
|
|
635 |
+ |
thisray.rmax = 0.0; |
636 |
+ |
|
637 |
|
if (!sscanvec(s, thisray.rorg) || |
638 |
|
!sscanvec(sskip(sskip(sskip(s))), thisray.rdir)) { |
639 |
|
|
643 |
|
if ((*dev->getcur)(&x, &y) == ABORT) |
644 |
|
return; |
645 |
|
|
646 |
< |
if (viewray(thisray.rorg, thisray.rdir, &ourview, |
647 |
< |
(x+.5)/hresolu, (y+.5)/vresolu) < 0) { |
646 |
> |
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, |
647 |
> |
&ourview, (x+.5)/hresolu, (y+.5)/vresolu)) < -FTINY) { |
648 |
|
error(COMMAND, "not on image"); |
649 |
|
return; |
650 |
|
} |
661 |
|
if (thisray.ro == NULL) |
662 |
|
(*dev->comout)("ray hit nothing"); |
663 |
|
else { |
664 |
< |
sprintf(buf, "ray hit %s %s \"%s\"", |
665 |
< |
objptr(thisray.ro->omod)->oname, |
664 |
> |
sprintf(buf, "ray hit %s%s %s \"%s\"", |
665 |
> |
thisray.rod < 0.0 ? "back of " : "", |
666 |
> |
thisray.ro->omod == OVOID ? VOIDID : |
667 |
> |
objptr(thisray.ro->omod)->oname, |
668 |
|
ofun[thisray.ro->otype].funame, |
669 |
|
thisray.ro->oname); |
670 |
|
(*dev->comout)(buf); |
697 |
|
COLR *scanline; |
698 |
|
int y; |
699 |
|
|
700 |
< |
if (sscanf(s, "%s", buf) != 1 && buf[0] == '\0') { |
700 |
> |
while (isspace(*s)) |
701 |
> |
s++; |
702 |
> |
if (*s) |
703 |
> |
atos(buf, sizeof(buf), s); |
704 |
> |
else if (buf[0] == '\0') { |
705 |
|
error(COMMAND, "no file"); |
706 |
|
return; |
707 |
|
} |
718 |
|
(*dev->comout)(fname); |
719 |
|
(*dev->comout)("\"...\n"); |
720 |
|
/* write header */ |
721 |
+ |
newheader("RADIANCE", fp); |
722 |
|
fputs(progname, fp); |
723 |
|
fprintview(&ourview, fp); |
724 |
|
if (octname != NULL) |