1 |
< |
/* Copyright (c) 1987 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
22 |
|
|
23 |
|
#define CTRL(c) ('c'-'@') |
24 |
|
|
25 |
+ |
extern char VersionID[]; |
26 |
|
extern char *progname; |
27 |
+ |
extern char *octname; |
28 |
|
|
29 |
|
|
30 |
|
getframe(s) /* get a new frame */ |
43 |
|
|
44 |
|
if (getrect(s, &box) < 0) |
45 |
|
return; |
46 |
< |
paintrect(&ptrunk, 0, 0, ourview.hresolu, ourview.vresolu, &box); |
46 |
> |
paintrect(&ptrunk, 0, 0, hresolu, vresolu, &box); |
47 |
|
} |
48 |
|
|
49 |
|
|
65 |
|
} |
66 |
|
fputs(progname, fp); |
67 |
|
fprintview(&ourview, fp); |
68 |
+ |
fputs(sskip(s), fp); |
69 |
|
fputs("\n", fp); |
70 |
|
fclose(fp); |
71 |
|
return; |
72 |
|
} |
73 |
|
sprintf(buf, "view type (%c): ", ourview.type); |
74 |
|
(*dev->comout)(buf); |
75 |
< |
(*dev->comin)(buf); |
75 |
> |
(*dev->comin)(buf, NULL); |
76 |
|
if (buf[0] == CTRL(C)) return; |
77 |
|
if (buf[0] && buf[0] != ourview.type) { |
78 |
|
nv.type = buf[0]; |
82 |
|
sprintf(buf, "view point (%.6g %.6g %.6g): ", |
83 |
|
ourview.vp[0], ourview.vp[1], ourview.vp[2]); |
84 |
|
(*dev->comout)(buf); |
85 |
< |
(*dev->comin)(buf); |
85 |
> |
(*dev->comin)(buf, NULL); |
86 |
|
if (buf[0] == CTRL(C)) return; |
87 |
|
if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) == 3) |
88 |
|
change++; |
91 |
|
sprintf(buf, "view direction (%.6g %.6g %.6g): ", |
92 |
|
ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]); |
93 |
|
(*dev->comout)(buf); |
94 |
< |
(*dev->comin)(buf); |
94 |
> |
(*dev->comin)(buf, NULL); |
95 |
|
if (buf[0] == CTRL(C)) return; |
96 |
|
if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) == 3) |
97 |
|
change++; |
100 |
|
sprintf(buf, "view up (%.6g %.6g %.6g): ", |
101 |
|
ourview.vup[0], ourview.vup[1], ourview.vup[2]); |
102 |
|
(*dev->comout)(buf); |
103 |
< |
(*dev->comin)(buf); |
103 |
> |
(*dev->comin)(buf, NULL); |
104 |
|
if (buf[0] == CTRL(C)) return; |
105 |
|
if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) == 3) |
106 |
|
change++; |
109 |
|
sprintf(buf, "view horiz and vert size (%.6g %.6g): ", |
110 |
|
ourview.horiz, ourview.vert); |
111 |
|
(*dev->comout)(buf); |
112 |
< |
(*dev->comin)(buf); |
112 |
> |
(*dev->comin)(buf, NULL); |
113 |
|
if (buf[0] == CTRL(C)) return; |
114 |
|
if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2) |
115 |
|
change++; |
116 |
|
else { |
117 |
|
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
118 |
|
} |
119 |
< |
sprintf(buf, "x and y resolution (%d %d): ", |
120 |
< |
ourview.hresolu, ourview.vresolu); |
119 |
> |
sprintf(buf, "view shift and lift (%.6g %.6g): ", |
120 |
> |
ourview.hoff, ourview.voff); |
121 |
|
(*dev->comout)(buf); |
122 |
< |
(*dev->comin)(buf); |
122 |
> |
(*dev->comin)(buf, NULL); |
123 |
|
if (buf[0] == CTRL(C)) return; |
124 |
< |
if (sscanf(buf, "%d %d", &nv.hresolu, &nv.vresolu) == 2) |
124 |
> |
if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2) |
125 |
|
change++; |
126 |
|
else { |
127 |
< |
nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu; |
127 |
> |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
128 |
|
} |
129 |
|
if (change) |
130 |
|
newview(&nv); |
140 |
|
VIEW nv; |
141 |
|
|
142 |
|
if (sscanf(s, "%s", buf) == 1) { /* get parameters from a file */ |
143 |
< |
bcopy(&stdview, &nv, sizeof(VIEW)); |
143 |
> |
copystruct(&nv, &stdview); |
144 |
|
if ((fname = getpath(buf, NULL, 0)) == NULL || |
145 |
< |
(success = viewfile(fname, &nv)) == -1) { |
145 |
> |
(success = viewfile(fname, &nv, 0, 0)) == -1) { |
146 |
|
sprintf(errmsg, "cannot open \"%s\"", buf); |
147 |
|
error(COMMAND, errmsg); |
148 |
|
return; |
153 |
|
newview(&nv); |
154 |
|
return; |
155 |
|
} |
156 |
< |
if (oldview.hresolu == 0) { /* no old view! */ |
156 |
> |
if (oldview.type == 0) { /* no old view! */ |
157 |
|
error(COMMAND, "no previous view"); |
158 |
|
return; |
159 |
|
} |
160 |
< |
bcopy(&ourview, &nv, sizeof(VIEW)); |
161 |
< |
bcopy(&oldview, &ourview, sizeof(VIEW)); |
162 |
< |
bcopy(&nv, &oldview, sizeof(VIEW)); |
160 |
> |
copystruct(&nv, &ourview); |
161 |
> |
copystruct(&ourview, &oldview); |
162 |
> |
copystruct(&oldview, &nv); |
163 |
|
newimage(); |
164 |
|
} |
165 |
|
|
173 |
|
|
174 |
|
if (getinterest(s, 1, nv.vdir, &zfact) < 0) |
175 |
|
return; |
176 |
+ |
nv.type = ourview.type; |
177 |
|
VCOPY(nv.vp, ourview.vp); |
178 |
|
VCOPY(nv.vup, ourview.vup); |
179 |
< |
nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu; |
180 |
< |
if ((nv.type = ourview.type) == VT_PAR) { |
181 |
< |
nv.horiz = ourview.horiz / zfact; |
178 |
< |
nv.vert = ourview.vert / zfact; |
179 |
< |
} else { |
180 |
< |
nv.horiz = atan(tan(ourview.horiz*(PI/180./2.))/zfact) / |
181 |
< |
(PI/180./2.); |
182 |
< |
nv.vert = atan(tan(ourview.vert*(PI/180./2.))/zfact) / |
183 |
< |
(PI/180./2.); |
184 |
< |
} |
179 |
> |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
180 |
> |
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
181 |
> |
zoomview(&nv, zfact); |
182 |
|
newview(&nv); |
183 |
|
} |
184 |
|
|
208 |
|
error(COMMAND, "missing angle"); |
209 |
|
return; |
210 |
|
} |
211 |
+ |
nv.type = ourview.type; |
212 |
|
VCOPY(nv.vp, ourview.vp); |
213 |
|
VCOPY(nv.vup, ourview.vup); |
214 |
< |
nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu; |
214 |
> |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
215 |
|
spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.)); |
216 |
|
if (elev != 0.0) { |
217 |
|
fcross(v1, nv.vdir, ourview.vup); |
218 |
|
normalize(v1); |
219 |
|
spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.)); |
220 |
|
} |
221 |
< |
if ((nv.type = ourview.type) == VT_PAR) { |
222 |
< |
nv.horiz = ourview.horiz / zfact; |
225 |
< |
nv.vert = ourview.vert / zfact; |
226 |
< |
} else { |
227 |
< |
nv.horiz = atan(tan(ourview.horiz*(PI/180./2.))/zfact) / |
228 |
< |
(PI/180./2.); |
229 |
< |
nv.vert = atan(tan(ourview.vert*(PI/180./2.))/zfact) / |
230 |
< |
(PI/180./2.); |
231 |
< |
} |
221 |
> |
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
222 |
> |
zoomview(&nv, zfact); |
223 |
|
newview(&nv); |
224 |
|
} |
225 |
|
|
261 |
|
if ((*dev->getcur)(&x, &y) == ABORT) |
262 |
|
return; |
263 |
|
r.l = r.d = 0; |
264 |
< |
r.r = ourview.hresolu; r.u = ourview.vresolu; |
264 |
> |
r.r = hresolu; r.u = vresolu; |
265 |
|
p = findrect(x, y, &ptrunk, &r, -1); |
266 |
|
e = 1.0; |
267 |
|
} else { |
273 |
|
if (*cp == '\0') { /* interactive */ |
274 |
|
sprintf(buf, "exposure (%lf): ", exposure); |
275 |
|
(*dev->comout)(buf); |
276 |
< |
(*dev->comin)(buf); |
276 |
> |
(*dev->comin)(buf, NULL); |
277 |
|
for (cp = buf; isspace(*cp); cp++) |
278 |
|
; |
279 |
|
if (*cp == '\0') |
303 |
|
} |
304 |
|
|
305 |
|
|
306 |
+ |
getparam(str, dsc, typ, ptr) /* get variable from user */ |
307 |
+ |
char *str, *dsc; |
308 |
+ |
int typ; |
309 |
+ |
register union {int i; double d; COLOR C;} *ptr; |
310 |
+ |
{ |
311 |
+ |
extern char *index(); |
312 |
+ |
int i0; |
313 |
+ |
double d0, d1, d2; |
314 |
+ |
char buf[48]; |
315 |
+ |
|
316 |
+ |
switch (typ) { |
317 |
+ |
case 'i': /* integer */ |
318 |
+ |
if (sscanf(str, "%d", &i0) != 1) { |
319 |
+ |
(*dev->comout)(dsc); |
320 |
+ |
sprintf(buf, " (%d): ", ptr->i); |
321 |
+ |
(*dev->comout)(buf); |
322 |
+ |
(*dev->comin)(buf, NULL); |
323 |
+ |
if (sscanf(buf, "%d", &i0) != 1) |
324 |
+ |
break; |
325 |
+ |
} |
326 |
+ |
ptr->i = i0; |
327 |
+ |
break; |
328 |
+ |
case 'r': /* real */ |
329 |
+ |
if (sscanf(str, "%lf", &d0) != 1) { |
330 |
+ |
(*dev->comout)(dsc); |
331 |
+ |
sprintf(buf, " (%.6g): ", ptr->d); |
332 |
+ |
(*dev->comout)(buf); |
333 |
+ |
(*dev->comin)(buf, NULL); |
334 |
+ |
if (sscanf(buf, "%lf", &d0) != 1) |
335 |
+ |
break; |
336 |
+ |
} |
337 |
+ |
ptr->d = d0; |
338 |
+ |
break; |
339 |
+ |
case 'b': /* boolean */ |
340 |
+ |
if (sscanf(str, "%1s", buf) != 1) { |
341 |
+ |
(*dev->comout)(dsc); |
342 |
+ |
sprintf(buf, " (%c): ", ptr->i ? 'y' : 'n'); |
343 |
+ |
(*dev->comout)(buf); |
344 |
+ |
(*dev->comin)(buf, NULL); |
345 |
+ |
if (buf[0] == '\0' || |
346 |
+ |
index("yY+1tTnN-0fF", buf[0]) == NULL) |
347 |
+ |
break; |
348 |
+ |
} |
349 |
+ |
ptr->i = index("yY+1tT", buf[0]) != NULL; |
350 |
+ |
break; |
351 |
+ |
case 'C': /* color */ |
352 |
+ |
if (sscanf(str, "%lf %lf %lf", &d0, &d1, &d2) != 3) { |
353 |
+ |
(*dev->comout)(dsc); |
354 |
+ |
sprintf(buf, " (%.6g %.6g %.6g): ", |
355 |
+ |
colval(ptr->C,RED), |
356 |
+ |
colval(ptr->C,GRN), |
357 |
+ |
colval(ptr->C,BLU)); |
358 |
+ |
(*dev->comout)(buf); |
359 |
+ |
(*dev->comin)(buf, NULL); |
360 |
+ |
if (sscanf(buf, "%lf %lf %lf", &d0, &d1, &d2) != 3) |
361 |
+ |
break; |
362 |
+ |
} |
363 |
+ |
setcolor(ptr->C, d0, d1, d2); |
364 |
+ |
break; |
365 |
+ |
} |
366 |
+ |
} |
367 |
+ |
|
368 |
+ |
|
369 |
|
setparam(s) /* get/set program parameter */ |
370 |
|
register char *s; |
371 |
|
{ |
383 |
|
extern int ambdiv; |
384 |
|
extern int ambssamp; |
385 |
|
extern int ambounce; |
386 |
< |
int i0; |
387 |
< |
double d0, d1, d2; |
386 |
> |
extern int directinvis; |
387 |
> |
extern int do_irrad; |
388 |
|
char buf[128]; |
389 |
|
|
390 |
|
if (s[0] == '\0') { |
391 |
< |
(*dev->comout)("aa ab ad ar as av dc dj dt lr lw sp st: "); |
392 |
< |
(*dev->comin)(buf); |
391 |
> |
(*dev->comout)( |
392 |
> |
"aa ab ad ar as av b dc di dj dt i lr lw sp st: "); |
393 |
> |
(*dev->comin)(buf, NULL); |
394 |
|
s = buf; |
395 |
|
} |
396 |
|
switch (s[0]) { |
397 |
|
case 'l': /* limit */ |
398 |
|
switch (s[1]) { |
399 |
|
case 'w': /* weight */ |
400 |
< |
if (sscanf(s+2, "%lf", &d0) != 1) { |
346 |
< |
sprintf(buf, "limit weight (%.6g): ", |
347 |
< |
minweight); |
348 |
< |
(*dev->comout)(buf); |
349 |
< |
(*dev->comin)(buf); |
350 |
< |
if (sscanf(buf, "%lf", &d0) != 1) |
351 |
< |
break; |
352 |
< |
} |
353 |
< |
minweight = d0; |
400 |
> |
getparam(s+2, "limit weight", 'r', &minweight); |
401 |
|
break; |
402 |
|
case 'r': /* reflection */ |
403 |
< |
if (sscanf(s+2, "%d", &i0) != 1) { |
357 |
< |
sprintf(buf, "limit reflection (%d): ", |
358 |
< |
maxdepth); |
359 |
< |
(*dev->comout)(buf); |
360 |
< |
(*dev->comin)(buf); |
361 |
< |
if (sscanf(buf, "%d", &i0) != 1) |
362 |
< |
break; |
363 |
< |
} |
364 |
< |
maxdepth = i0; |
403 |
> |
getparam(s+2, "limit reflection", 'i', &maxdepth); |
404 |
|
break; |
405 |
|
default: |
406 |
|
goto badparam; |
409 |
|
case 'd': /* direct */ |
410 |
|
switch (s[1]) { |
411 |
|
case 'j': /* jitter */ |
412 |
< |
if (sscanf(s+2, "%lf", &d0) != 1) { |
374 |
< |
sprintf(buf, "direct jitter (%.6g): ", |
375 |
< |
dstrsrc); |
376 |
< |
(*dev->comout)(buf); |
377 |
< |
(*dev->comin)(buf); |
378 |
< |
if (sscanf(buf, "%lf", &d0) != 1) |
379 |
< |
break; |
380 |
< |
} |
381 |
< |
dstrsrc = d0; |
412 |
> |
getparam(s+2, "direct jitter", 'r', &dstrsrc); |
413 |
|
break; |
414 |
|
case 'c': /* certainty */ |
415 |
< |
if (sscanf(s+2, "%lf", &d0) != 1) { |
385 |
< |
sprintf(buf, "direct certainty (%.6g): ", |
386 |
< |
shadcert); |
387 |
< |
(*dev->comout)(buf); |
388 |
< |
(*dev->comin)(buf); |
389 |
< |
if (sscanf(buf, "%lf", &d0) != 1) |
390 |
< |
break; |
391 |
< |
} |
392 |
< |
shadcert = d0; |
415 |
> |
getparam(s+2, "direct certainty", 'r', &shadcert); |
416 |
|
break; |
417 |
|
case 't': /* threshold */ |
418 |
< |
if (sscanf(s+2, "%lf", &d0) != 1) { |
396 |
< |
sprintf(buf, "direct threshold (%.6g): ", |
397 |
< |
shadthresh); |
398 |
< |
(*dev->comout)(buf); |
399 |
< |
(*dev->comin)(buf); |
400 |
< |
if (sscanf(buf, "%lf", &d0) != 1) |
401 |
< |
break; |
402 |
< |
} |
403 |
< |
shadthresh = d0; |
418 |
> |
getparam(s+2, "direct threshold", 'r', &shadthresh); |
419 |
|
break; |
420 |
+ |
case 'i': /* invisibility */ |
421 |
+ |
getparam(s+2, "direct invisibility", |
422 |
+ |
'b', &directinvis); |
423 |
+ |
break; |
424 |
|
default: |
425 |
|
goto badparam; |
426 |
|
} |
427 |
|
break; |
428 |
+ |
case 'b': /* black and white */ |
429 |
+ |
getparam(s+1, "black and white", 'b', &greyscale); |
430 |
+ |
break; |
431 |
+ |
case 'i': /* irradiance */ |
432 |
+ |
getparam(s+1, "irradiance", 'b', &do_irrad); |
433 |
+ |
break; |
434 |
|
case 'a': /* ambient */ |
435 |
|
switch (s[1]) { |
436 |
|
case 'v': /* value */ |
437 |
< |
if (sscanf(s+2, "%lf %lf %lf", &d0, &d1, &d2) != 3) { |
413 |
< |
sprintf(buf, |
414 |
< |
"ambient value (%.6g %.6g %.6g): ", |
415 |
< |
colval(ambval,RED), |
416 |
< |
colval(ambval,GRN), |
417 |
< |
colval(ambval,BLU)); |
418 |
< |
(*dev->comout)(buf); |
419 |
< |
(*dev->comin)(buf); |
420 |
< |
if (sscanf(buf, "%lf %lf %lf", |
421 |
< |
&d0, &d1, &d2) != 3) |
422 |
< |
break; |
423 |
< |
} |
424 |
< |
setcolor(ambval, d0, d1, d2); |
437 |
> |
getparam(s+2, "ambient value", 'C', ambval); |
438 |
|
break; |
439 |
|
case 'a': /* accuracy */ |
440 |
< |
if (sscanf(s+2, "%lf", &d0) != 1) { |
428 |
< |
sprintf(buf, "ambient accuracy (%.6g): ", |
429 |
< |
ambacc); |
430 |
< |
(*dev->comout)(buf); |
431 |
< |
(*dev->comin)(buf); |
432 |
< |
if (sscanf(buf, "%lf", &d0) != 1) |
433 |
< |
break; |
434 |
< |
} |
435 |
< |
ambacc = d0; |
440 |
> |
getparam(s+2, "ambient accuracy", 'r', &ambacc); |
441 |
|
break; |
442 |
|
case 'd': /* divisions */ |
443 |
< |
if (sscanf(s+2, "%d", &i0) != 1) { |
439 |
< |
sprintf(buf, "ambient divisions (%d): ", |
440 |
< |
ambdiv); |
441 |
< |
(*dev->comout)(buf); |
442 |
< |
(*dev->comin)(buf); |
443 |
< |
if (sscanf(buf, "%d", &i0) != 1) |
444 |
< |
break; |
445 |
< |
} |
446 |
< |
ambdiv = i0; |
443 |
> |
getparam(s+2, "ambient divisions", 'i', &ambdiv); |
444 |
|
break; |
445 |
|
case 's': /* samples */ |
446 |
< |
if (sscanf(s+2, "%d", &i0) != 1) { |
450 |
< |
sprintf(buf, "ambient super-samples (%d): ", |
451 |
< |
ambssamp); |
452 |
< |
(*dev->comout)(buf); |
453 |
< |
(*dev->comin)(buf); |
454 |
< |
if (sscanf(buf, "%d", &i0) != 1) |
455 |
< |
break; |
456 |
< |
} |
457 |
< |
ambssamp = i0; |
446 |
> |
getparam(s+2, "ambient super-samples", 'i', &ambssamp); |
447 |
|
break; |
448 |
|
case 'b': /* bounces */ |
449 |
< |
if (sscanf(s+2, "%d", &i0) != 1) { |
461 |
< |
sprintf(buf, "ambient bounces (%d): ", |
462 |
< |
ambounce); |
463 |
< |
(*dev->comout)(buf); |
464 |
< |
(*dev->comin)(buf); |
465 |
< |
if (sscanf(buf, "%d", &i0) != 1) |
466 |
< |
break; |
467 |
< |
} |
468 |
< |
ambounce = i0; |
449 |
> |
getparam(s+2, "ambient bounces", 'i', &ambounce); |
450 |
|
break; |
451 |
|
case 'r': |
452 |
< |
if (sscanf(s+2, "%d", &i0) != 1) { |
472 |
< |
sprintf(buf, "ambient resolution (%d): ", |
473 |
< |
ambres); |
474 |
< |
(*dev->comout)(buf); |
475 |
< |
(*dev->comin)(buf); |
476 |
< |
if (sscanf(buf, "%d", &i0) != 1) |
477 |
< |
break; |
478 |
< |
} |
479 |
< |
ambres = i0; |
452 |
> |
getparam(s+2, "ambient resolution", 'i', &ambres); |
453 |
|
minarad = ambres > 0 ? thescene.cusize/ambres : 0.0; |
454 |
|
break; |
455 |
|
default: |
459 |
|
case 's': /* sample */ |
460 |
|
switch (s[1]) { |
461 |
|
case 'p': /* pixel */ |
462 |
< |
if (sscanf(s+2, "%d", &i0) != 1) { |
490 |
< |
sprintf(buf, "sample pixel (%d): ", psample); |
491 |
< |
(*dev->comout)(buf); |
492 |
< |
(*dev->comin)(buf); |
493 |
< |
if (sscanf(buf, "%d", &i0) != 1) |
494 |
< |
break; |
495 |
< |
} |
496 |
< |
psample = i0; |
462 |
> |
getparam(s+2, "sample pixel", 'i', &psample); |
463 |
|
pdepth = 0; |
464 |
|
break; |
465 |
|
case 't': /* threshold */ |
466 |
< |
if (sscanf(s+2, "%lf", &d0) != 1) { |
501 |
< |
sprintf(buf, "sample threshold (%.6g): ", |
502 |
< |
maxdiff); |
503 |
< |
(*dev->comout)(buf); |
504 |
< |
(*dev->comin)(buf); |
505 |
< |
if (sscanf(buf, "%lf", &d0) != 1) |
506 |
< |
break; |
507 |
< |
} |
508 |
< |
maxdiff = d0; |
466 |
> |
getparam(s+2, "sample threshold", 'r', &maxdiff); |
467 |
|
pdepth = 0; |
468 |
|
break; |
469 |
|
default: |
474 |
|
break; |
475 |
|
default:; |
476 |
|
badparam: |
477 |
+ |
*sskip(s) = '\0'; |
478 |
|
sprintf(errmsg, "%s: unknown variable", s); |
479 |
|
error(COMMAND, errmsg); |
480 |
|
break; |
499 |
|
if ((*dev->getcur)(&x, &y) == ABORT) |
500 |
|
return; |
501 |
|
|
502 |
< |
rayview(thisray.rorg, thisray.rdir, &ourview, x+.5, y+.5); |
503 |
< |
|
502 |
> |
if (viewray(thisray.rorg, thisray.rdir, &ourview, |
503 |
> |
(x+.5)/hresolu, (y+.5)/vresolu) < 0) { |
504 |
> |
error(COMMAND, "not on image"); |
505 |
> |
return; |
506 |
> |
} |
507 |
> |
|
508 |
|
} else if (normalize(thisray.rdir) == 0.0) { |
509 |
|
error(COMMAND, "zero ray direction"); |
510 |
|
return; |
522 |
|
ofun[thisray.ro->otype].funame, |
523 |
|
thisray.ro->oname); |
524 |
|
(*dev->comout)(buf); |
525 |
< |
(*dev->comin)(buf); |
525 |
> |
(*dev->comin)(buf, NULL); |
526 |
|
if (thisray.rot >= FHUGE) |
527 |
|
(*dev->comout)("at infinity"); |
528 |
|
else { |
530 |
|
thisray.rop[1], thisray.rop[2]); |
531 |
|
(*dev->comout)(buf); |
532 |
|
} |
533 |
< |
(*dev->comin)(buf); |
533 |
> |
(*dev->comin)(buf, NULL); |
534 |
|
sprintf(buf, "with value (%.6g %.6g %.6g)", |
535 |
|
colval(thisray.rcol,RED), |
536 |
|
colval(thisray.rcol,GRN), |
537 |
|
colval(thisray.rcol,BLU)); |
538 |
|
(*dev->comout)(buf); |
539 |
|
} |
540 |
< |
(*dev->comin)(buf); |
540 |
> |
(*dev->comin)(buf, NULL); |
541 |
|
} |
542 |
|
|
543 |
|
|
566 |
|
/* write header */ |
567 |
|
fputs(progname, fp); |
568 |
|
fprintview(&ourview, fp); |
569 |
< |
putc('\n', fp); |
569 |
> |
if (octname != NULL) |
570 |
> |
fprintf(fp, " %s\n", octname); |
571 |
> |
else |
572 |
> |
putc('\n', fp); |
573 |
> |
fprintf(fp, "SOFTWARE= %s\n", VersionID); |
574 |
|
if (exposure != 1.0) |
575 |
< |
fprintf(fp, "EXPOSURE=%e\n", exposure); |
575 |
> |
fputexpos(exposure, fp); |
576 |
> |
if (dev->pixaspect != 1.0) |
577 |
> |
fputaspect(dev->pixaspect, fp); |
578 |
> |
fputformat(COLRFMT, fp); |
579 |
|
putc('\n', fp); |
580 |
< |
fputresolu(YMAJOR|YDECR, ourview.hresolu, ourview.vresolu, fp); |
580 |
> |
fputresolu(YMAJOR|YDECR, hresolu, vresolu, fp); |
581 |
|
|
582 |
< |
scanline = (COLR *)malloc(ourview.hresolu*sizeof(COLR)); |
583 |
< |
if (scanline == NULL) |
584 |
< |
error(SYSTEM, "out of memory in writepict"); |
585 |
< |
for (y = ourview.vresolu-1; y >= 0; y--) { |
586 |
< |
getpictcolrs(y, scanline, &ptrunk, |
587 |
< |
ourview.hresolu, ourview.vresolu); |
588 |
< |
if (fwritecolrs(scanline, ourview.hresolu, fp) < 0) |
582 |
> |
scanline = (COLR *)malloc(hresolu*sizeof(COLR)); |
583 |
> |
if (scanline == NULL) { |
584 |
> |
error(COMMAND, "not enough memory!"); |
585 |
> |
fclose(fp); |
586 |
> |
unlink(fname); |
587 |
> |
return; |
588 |
> |
} |
589 |
> |
for (y = vresolu-1; y >= 0; y--) { |
590 |
> |
getpictcolrs(y, scanline, &ptrunk, hresolu, vresolu); |
591 |
> |
if (fwritecolrs(scanline, hresolu, fp) < 0) |
592 |
|
break; |
593 |
|
} |
594 |
+ |
free((char *)scanline); |
595 |
|
if (fclose(fp) < 0) |
596 |
|
error(COMMAND, "write error"); |
623 |
– |
free((char *)scanline); |
597 |
|
} |