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"; |
11 |
|
#include "standard.h" |
12 |
|
#include "paths.h" |
13 |
|
#include <ctype.h> |
14 |
+ |
#include <sys/types.h> |
15 |
|
|
16 |
|
|
17 |
|
typedef struct { |
22 |
|
int (*fixval)(); /* assignment checking function */ |
23 |
|
} VARIABLE; |
24 |
|
|
25 |
< |
int onevalue(), catvalues(); |
25 |
> |
int onevalue(), catvalues(), boolvalue(), |
26 |
> |
qualvalue(), fltvalue(), intvalue(); |
27 |
|
|
28 |
|
/* variables */ |
29 |
|
#define OBJECT 0 /* object files */ |
30 |
|
#define SCENE 1 /* scene files */ |
31 |
|
#define MATERIAL 2 /* material files */ |
32 |
< |
#define RENDER 3 /* rendering options */ |
33 |
< |
#define OCONV 4 /* oconv options */ |
34 |
< |
#define PFILT 5 /* pfilt options */ |
35 |
< |
#define VIEW 6 /* view(s) for picture(s) */ |
36 |
< |
#define ZONE 7 /* simulation zone */ |
37 |
< |
#define QUALITY 8 /* desired rendering quality */ |
38 |
< |
#define OCTREE 9 /* octree file name */ |
39 |
< |
#define PICTURE 10 /* picture file name */ |
40 |
< |
#define AMBFILE 11 /* ambient file name */ |
41 |
< |
#define OPTFILE 12 /* rendering options file */ |
42 |
< |
#define EXPOSURE 13 /* picture exposure setting */ |
43 |
< |
#define RESOLUTION 14 /* maximum picture resolution */ |
44 |
< |
#define UP 15 /* view up (X, Y or Z) */ |
45 |
< |
#define INDIRECT 16 /* indirection in lighting */ |
46 |
< |
#define DETAIL 17 /* level of scene detail */ |
47 |
< |
#define PENUMBRAS 18 /* shadow penumbras are desired */ |
48 |
< |
#define VARIABILITY 19 /* level of light variability */ |
49 |
< |
#define REPORT 20 /* report frequency and errfile */ |
32 |
> |
#define ILLUM 3 /* mkillum input files */ |
33 |
> |
#define MKILLUM 4 /* mkillum options */ |
34 |
> |
#define RENDER 5 /* rendering options */ |
35 |
> |
#define OCONV 6 /* oconv options */ |
36 |
> |
#define PFILT 7 /* pfilt options */ |
37 |
> |
#define VIEW 8 /* view(s) for picture(s) */ |
38 |
> |
#define ZONE 9 /* simulation zone */ |
39 |
> |
#define QUALITY 10 /* desired rendering quality */ |
40 |
> |
#define OCTREE 11 /* octree file name */ |
41 |
> |
#define PICTURE 12 /* picture file name */ |
42 |
> |
#define AMBFILE 13 /* ambient file name */ |
43 |
> |
#define OPTFILE 14 /* rendering options file */ |
44 |
> |
#define EXPOSURE 15 /* picture exposure setting */ |
45 |
> |
#define RESOLUTION 16 /* maximum picture resolution */ |
46 |
> |
#define UP 17 /* view up (X, Y or Z) */ |
47 |
> |
#define INDIRECT 18 /* indirection in lighting */ |
48 |
> |
#define DETAIL 19 /* level of scene detail */ |
49 |
> |
#define PENUMBRAS 20 /* shadow penumbras are desired */ |
50 |
> |
#define VARIABILITY 21 /* level of light variability */ |
51 |
> |
#define REPORT 22 /* report frequency and errfile */ |
52 |
|
/* total number of variables */ |
53 |
< |
#define NVARS 21 |
53 |
> |
#define NVARS 23 |
54 |
|
|
55 |
|
VARIABLE vv[NVARS] = { /* variable-value pairs */ |
56 |
|
{"objects", 3, 0, NULL, catvalues}, |
57 |
|
{"scene", 3, 0, NULL, catvalues}, |
58 |
|
{"materials", 3, 0, NULL, catvalues}, |
59 |
+ |
{"illum", 3, 0, NULL, catvalues}, |
60 |
+ |
{"mkillum", 3, 0, NULL, catvalues}, |
61 |
|
{"render", 3, 0, NULL, catvalues}, |
62 |
|
{"oconv", 3, 0, NULL, catvalues}, |
63 |
|
{"pfilt", 2, 0, NULL, catvalues}, |
64 |
|
{"view", 2, 0, NULL, NULL}, |
65 |
|
{"ZONE", 2, 0, NULL, onevalue}, |
66 |
< |
{"QUALITY", 3, 0, NULL, onevalue}, |
66 |
> |
{"QUALITY", 3, 0, NULL, qualvalue}, |
67 |
|
{"OCTREE", 3, 0, NULL, onevalue}, |
68 |
|
{"PICTURE", 3, 0, NULL, onevalue}, |
69 |
|
{"AMBFILE", 3, 0, NULL, onevalue}, |
70 |
|
{"OPTFILE", 3, 0, NULL, onevalue}, |
71 |
< |
{"EXPOSURE", 3, 0, NULL, onevalue}, |
71 |
> |
{"EXPOSURE", 3, 0, NULL, fltvalue}, |
72 |
|
{"RESOLUTION", 3, 0, NULL, onevalue}, |
73 |
|
{"UP", 2, 0, NULL, onevalue}, |
74 |
< |
{"INDIRECT", 3, 0, NULL, onevalue}, |
75 |
< |
{"DETAIL", 3, 0, NULL, onevalue}, |
76 |
< |
{"PENUMBRAS", 3, 0, NULL, onevalue}, |
77 |
< |
{"VARIABILITY", 3, 0, NULL, onevalue}, |
74 |
> |
{"INDIRECT", 3, 0, NULL, intvalue}, |
75 |
> |
{"DETAIL", 3, 0, NULL, qualvalue}, |
76 |
> |
{"PENUMBRAS", 3, 0, NULL, boolvalue}, |
77 |
> |
{"VARIABILITY", 3, 0, NULL, qualvalue}, |
78 |
|
{"REPORT", 3, 0, NULL, onevalue}, |
79 |
|
}; |
80 |
|
|
81 |
|
VARIABLE *matchvar(); |
82 |
|
char *nvalue(); |
77 |
– |
int vscale(); |
83 |
|
|
84 |
|
#define UPPER(c) ((c)&~0x20) /* ASCII trick */ |
85 |
|
|
88 |
|
#define vval(vc) (vv[vc].value) |
89 |
|
#define vint(vc) atoi(vval(vc)) |
90 |
|
#define vlet(vc) UPPER(vval(vc)[0]) |
91 |
+ |
#define vscale vlet |
92 |
|
#define vbool(vc) (vlet(vc)=='T') |
93 |
|
|
94 |
< |
#define HIGH 2 |
95 |
< |
#define MEDIUM 1 |
96 |
< |
#define LOW 0 |
94 |
> |
#define HIGH 'H' |
95 |
> |
#define MEDIUM 'M' |
96 |
> |
#define LOW 'L' |
97 |
|
|
92 |
– |
int lowqopts(), medqopts(), hiqopts(); |
93 |
– |
int (*setqopts[3])() = {lowqopts, medqopts, hiqopts}; |
94 |
– |
|
95 |
– |
#define renderopts (*setqopts[vscale(QUALITY)]) |
96 |
– |
|
98 |
|
/* overture calculation file */ |
99 |
|
#ifdef NIX |
100 |
|
char overfile[] = "overture.raw"; |
102 |
|
char overfile[] = "/dev/null"; |
103 |
|
#endif |
104 |
|
|
105 |
< |
extern long fdate(), time(); |
105 |
> |
extern time_t fdate(), time(); |
106 |
|
|
107 |
< |
long scenedate; /* date of latest scene or object file */ |
108 |
< |
long octreedate; /* date of octree */ |
109 |
< |
long matdate; /* date of latest material file */ |
107 |
> |
time_t scenedate; /* date of latest scene or object file */ |
108 |
> |
time_t octreedate; /* date of octree */ |
109 |
> |
time_t matdate; /* date of latest material file */ |
110 |
> |
time_t illumdate; /* date of last illum file */ |
111 |
|
|
112 |
+ |
char *oct0name; /* name of pre-mkillum octree */ |
113 |
+ |
time_t oct0date; /* date of pre-mkillum octree */ |
114 |
+ |
char *oct1name; /* name of post-mkillum octree */ |
115 |
+ |
time_t oct1date; /* date of post-mkillum octree (>= matdate) */ |
116 |
+ |
|
117 |
+ |
int nowarn = 0; /* no warnings */ |
118 |
|
int explicate = 0; /* explicate variables */ |
119 |
|
int silent = 0; /* do work silently */ |
120 |
+ |
int touchonly = 0; /* touch files only */ |
121 |
|
int noaction = 0; /* don't do anything */ |
122 |
|
int sayview = 0; /* print view out */ |
123 |
|
char *rvdevice = NULL; /* rview output device */ |
126 |
|
int overture = 0; /* overture calculation needed */ |
127 |
|
|
128 |
|
char *progname; /* global argv[0] */ |
129 |
+ |
char *rifname; /* global rad input file name */ |
130 |
|
|
131 |
|
char radname[MAXPATH]; /* root Radiance file name */ |
132 |
|
|
136 |
|
char *argv[]; |
137 |
|
{ |
138 |
|
char ropts[512]; |
139 |
+ |
char popts[64]; |
140 |
|
int i; |
141 |
|
|
142 |
|
progname = argv[0]; |
149 |
|
case 'n': |
150 |
|
noaction++; |
151 |
|
break; |
152 |
+ |
case 't': |
153 |
+ |
touchonly++; |
154 |
+ |
break; |
155 |
|
case 'e': |
156 |
|
explicate++; |
157 |
|
break; |
164 |
|
case 'v': |
165 |
|
viewselect = argv[++i]; |
166 |
|
break; |
167 |
+ |
case 'w': |
168 |
+ |
nowarn++; |
169 |
+ |
break; |
170 |
|
default: |
171 |
|
goto userr; |
172 |
|
} |
173 |
|
if (i >= argc) |
174 |
|
goto userr; |
175 |
+ |
rifname = argv[i]; |
176 |
|
/* assign Radiance root file name */ |
177 |
< |
rootname(radname, argv[i]); |
177 |
> |
rootname(radname, rifname); |
178 |
|
/* load variable values */ |
179 |
< |
load(argv[i]); |
179 |
> |
load(rifname); |
180 |
|
/* get any additional assignments */ |
181 |
|
for (i++; i < argc; i++) |
182 |
|
setvariable(argv[i]); |
189 |
|
/* print all values if requested */ |
190 |
|
if (explicate) |
191 |
|
printvals(); |
192 |
< |
/* build octree */ |
192 |
> |
/* build octree (and run mkillum) */ |
193 |
|
oconv(); |
194 |
|
/* check date on ambient file */ |
195 |
|
checkambfile(); |
196 |
|
/* run simulation */ |
197 |
< |
renderopts(ropts); |
197 |
> |
renderopts(ropts, popts); |
198 |
|
xferopts(ropts); |
199 |
|
if (rvdevice != NULL) |
200 |
< |
rview(ropts); |
200 |
> |
rview(ropts, popts); |
201 |
|
else |
202 |
< |
rpict(ropts); |
202 |
> |
rpict(ropts, popts); |
203 |
|
exit(0); |
204 |
|
userr: |
205 |
|
fprintf(stderr, |
206 |
< |
"Usage: %s [-s][-n][-e][-v view][-o dev] rfile [VAR=value ..]\n", |
206 |
> |
"Usage: %s [-s][-n][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n", |
207 |
|
progname); |
208 |
|
exit(1); |
209 |
|
} |
224 |
|
} |
225 |
|
|
226 |
|
|
227 |
+ |
#define NOCHAR 127 /* constant for character to delete */ |
228 |
+ |
|
229 |
+ |
|
230 |
|
load(rfname) /* load Radiance simulation file */ |
231 |
|
char *rfname; |
232 |
|
{ |
242 |
|
for (cp = buf; *cp; cp++) { |
243 |
|
switch (*cp) { |
244 |
|
case '\\': |
245 |
< |
case '\n': |
225 |
< |
*cp = ' '; |
245 |
> |
*cp++ = NOCHAR; |
246 |
|
continue; |
247 |
|
case '#': |
248 |
|
*cp = '\0'; |
262 |
|
register char *ass; |
263 |
|
{ |
264 |
|
char varname[32]; |
265 |
+ |
int n; |
266 |
|
register char *cp; |
267 |
|
register VARIABLE *vp; |
268 |
|
register int i; |
248 |
– |
int n; |
269 |
|
|
270 |
|
while (isspace(*ass)) /* skip leading space */ |
271 |
|
ass++; |
279 |
|
/* trim value */ |
280 |
|
while (isspace(*ass) || *ass == '=') |
281 |
|
ass++; |
282 |
< |
cp = ass + strlen(ass); |
283 |
< |
do |
284 |
< |
*cp-- = '\0'; |
285 |
< |
while (cp >= ass && isspace(*cp)); |
266 |
< |
n = cp - ass + 1; |
267 |
< |
if (!n) { |
282 |
> |
for (n = strlen(ass); n > 0; n--) |
283 |
> |
if (!isspace(ass[n-1])) |
284 |
> |
break; |
285 |
> |
if (!n && !nowarn) { |
286 |
|
fprintf(stderr, "%s: warning - missing value for variable '%s'\n", |
287 |
|
progname, varname); |
288 |
|
return; |
306 |
|
vp->value = malloc(n+1); |
307 |
|
if (vp->value == NULL) |
308 |
|
syserr(progname); |
309 |
< |
strcpy(vp->value+i, ass); |
309 |
> |
cp = vp->value+i; /* copy value, squeezing spaces */ |
310 |
> |
*cp = *ass; |
311 |
> |
for (i = 1; i <= n; i++) { |
312 |
> |
if (ass[i] == NOCHAR) |
313 |
> |
continue; |
314 |
> |
if (isspace(*cp)) |
315 |
> |
while (isspace(ass[i])) |
316 |
> |
i++; |
317 |
> |
*++cp = ass[i]; |
318 |
> |
} |
319 |
> |
if (isspace(*cp)) /* remove trailing space */ |
320 |
> |
*cp = '\0'; |
321 |
|
vp->nass++; |
322 |
|
} |
323 |
|
|
353 |
|
} |
354 |
|
|
355 |
|
|
327 |
– |
int |
328 |
– |
vscale(vc) /* return scale for variable vc */ |
329 |
– |
int vc; |
330 |
– |
{ |
331 |
– |
switch(vlet(vc)) { |
332 |
– |
case 'H': |
333 |
– |
return(HIGH); |
334 |
– |
case 'M': |
335 |
– |
return(MEDIUM); |
336 |
– |
case 'L': |
337 |
– |
return(LOW); |
338 |
– |
} |
339 |
– |
badvalue(vc); |
340 |
– |
} |
341 |
– |
|
342 |
– |
|
356 |
|
checkvalues() /* check assignments */ |
357 |
|
{ |
358 |
|
register int i; |
368 |
|
{ |
369 |
|
if (vp->nass < 2) |
370 |
|
return; |
371 |
< |
fprintf(stderr, "%s: warning - multiple assignment of variable '%s'\n", |
371 |
> |
if (!nowarn) |
372 |
> |
fprintf(stderr, |
373 |
> |
"%s: warning - multiple assignment of variable '%s'\n", |
374 |
|
progname, vp->name); |
375 |
|
do |
376 |
|
vp->value += strlen(vp->value)+1; |
393 |
|
} |
394 |
|
|
395 |
|
|
396 |
< |
long |
396 |
> |
int |
397 |
> |
badmatch(tv, cv) /* case insensitive truncated comparison */ |
398 |
> |
register char *tv, *cv; |
399 |
> |
{ |
400 |
> |
if (!*tv) return(1); /* null string cannot match */ |
401 |
> |
do |
402 |
> |
if (UPPER(*tv) != *cv++) |
403 |
> |
return(1); |
404 |
> |
while (*++tv); |
405 |
> |
return(0); /* OK */ |
406 |
> |
} |
407 |
> |
|
408 |
> |
|
409 |
> |
boolvalue(vp) /* check boolean for legal values */ |
410 |
> |
register VARIABLE *vp; |
411 |
> |
{ |
412 |
> |
if (!vp->nass) return; |
413 |
> |
onevalue(vp); |
414 |
> |
switch (UPPER(vp->value[0])) { |
415 |
> |
case 'T': |
416 |
> |
if (badmatch(vp->value, "TRUE")) break; |
417 |
> |
return; |
418 |
> |
case 'F': |
419 |
> |
if (badmatch(vp->value, "FALSE")) break; |
420 |
> |
return; |
421 |
> |
} |
422 |
> |
fprintf(stderr, "%s: illegal value for boolean variable '%s'\n", |
423 |
> |
progname, vp->name); |
424 |
> |
exit(1); |
425 |
> |
} |
426 |
> |
|
427 |
> |
|
428 |
> |
qualvalue(vp) /* check qualitative var. for legal values */ |
429 |
> |
register VARIABLE *vp; |
430 |
> |
{ |
431 |
> |
if (!vp->nass) return; |
432 |
> |
onevalue(vp); |
433 |
> |
switch (UPPER(vp->value[0])) { |
434 |
> |
case 'L': |
435 |
> |
if (badmatch(vp->value, "LOW")) break; |
436 |
> |
return; |
437 |
> |
case 'M': |
438 |
> |
if (badmatch(vp->value, "MEDIUM")) break; |
439 |
> |
return; |
440 |
> |
case 'H': |
441 |
> |
if (badmatch(vp->value, "HIGH")) break; |
442 |
> |
return; |
443 |
> |
} |
444 |
> |
fprintf(stderr, "%s: illegal value for qualitative variable '%s'\n", |
445 |
> |
progname, vp->name); |
446 |
> |
exit(1); |
447 |
> |
} |
448 |
> |
|
449 |
> |
|
450 |
> |
intvalue(vp) /* check integer variable for legal values */ |
451 |
> |
register VARIABLE *vp; |
452 |
> |
{ |
453 |
> |
if (!vp->nass) return; |
454 |
> |
onevalue(vp); |
455 |
> |
if (isint(vp->value)) return; |
456 |
> |
fprintf(stderr, "%s: illegal value for integer variable '%s'\n", |
457 |
> |
progname, vp->name); |
458 |
> |
exit(1); |
459 |
> |
} |
460 |
> |
|
461 |
> |
|
462 |
> |
fltvalue(vp) /* check float variable for legal values */ |
463 |
> |
register VARIABLE *vp; |
464 |
> |
{ |
465 |
> |
if (!vp->nass) return; |
466 |
> |
onevalue(vp); |
467 |
> |
if (isflt(vp->value)) return; |
468 |
> |
fprintf(stderr, "%s: illegal value for real variable '%s'\n", |
469 |
> |
progname, vp->name); |
470 |
> |
exit(1); |
471 |
> |
} |
472 |
> |
|
473 |
> |
|
474 |
> |
time_t |
475 |
|
checklast(fnames) /* check files and find most recent */ |
476 |
|
register char *fnames; |
477 |
|
{ |
478 |
|
char thisfile[MAXPATH]; |
479 |
< |
long thisdate, lastdate = -1; |
479 |
> |
time_t thisdate, lastdate = 0; |
480 |
|
register char *cp; |
481 |
|
|
482 |
+ |
if (fnames == NULL) |
483 |
+ |
return(0); |
484 |
|
while (*fnames) { |
485 |
|
while (isspace(*fnames)) fnames++; |
486 |
|
cp = thisfile; |
487 |
|
while (*fnames && !isspace(*fnames)) |
488 |
|
*cp++ = *fnames++; |
489 |
|
*cp = '\0'; |
490 |
< |
if ((thisdate = fdate(thisfile)) < 0) |
490 |
> |
if (!(thisdate = fdate(thisfile))) |
491 |
|
syserr(thisfile); |
492 |
|
if (thisdate > lastdate) |
493 |
|
lastdate = thisdate; |
496 |
|
} |
497 |
|
|
498 |
|
|
499 |
+ |
char * |
500 |
+ |
newfname(orig, pred) /* create modified file name */ |
501 |
+ |
char *orig; |
502 |
+ |
int pred; |
503 |
+ |
{ |
504 |
+ |
extern char *rindex(); |
505 |
+ |
register char *cp; |
506 |
+ |
register int n; |
507 |
+ |
int suffix; |
508 |
+ |
|
509 |
+ |
n = 0; cp = orig; suffix = -1; /* suffix position, length */ |
510 |
+ |
while (*cp) { |
511 |
+ |
if (*cp == '.') suffix = n; |
512 |
+ |
else if (ISDIRSEP(*cp)) suffix = -1; |
513 |
+ |
cp++; n++; |
514 |
+ |
} |
515 |
+ |
if (suffix == -1) suffix = n; |
516 |
+ |
if ((cp = bmalloc(n+2)) == NULL) |
517 |
+ |
syserr(progname); |
518 |
+ |
strncpy(cp, orig, suffix); |
519 |
+ |
cp[suffix] = pred; /* root name + pred + suffix */ |
520 |
+ |
strcpy(cp+suffix+1, orig+suffix); |
521 |
+ |
return(cp); |
522 |
+ |
} |
523 |
+ |
|
524 |
+ |
|
525 |
|
checkfiles() /* check for existence and modified times */ |
526 |
|
{ |
527 |
< |
char *cp; |
407 |
< |
long objdate; |
527 |
> |
time_t objdate; |
528 |
|
|
529 |
|
if (!vdef(OCTREE)) { |
530 |
< |
if ((cp = bmalloc(strlen(radname)+5)) == NULL) |
530 |
> |
if ((vval(OCTREE) = bmalloc(strlen(radname)+5)) == NULL) |
531 |
|
syserr(progname); |
532 |
< |
sprintf(cp, "%s.oct", radname); |
413 |
< |
vval(OCTREE) = cp; |
532 |
> |
sprintf(vval(OCTREE), "%s.oct", radname); |
533 |
|
vdef(OCTREE)++; |
534 |
|
} |
535 |
|
octreedate = fdate(vval(OCTREE)); |
536 |
< |
scenedate = -1; |
537 |
< |
if (vdef(SCENE)) { |
538 |
< |
scenedate = checklast(vval(SCENE)); |
539 |
< |
if (vdef(OBJECT)) { |
540 |
< |
objdate = checklast(vval(OBJECT)); |
541 |
< |
if (objdate > scenedate) |
542 |
< |
scenedate = objdate; |
543 |
< |
} |
544 |
< |
} |
545 |
< |
if (octreedate < 0 & scenedate < 0) { |
546 |
< |
fprintf(stderr, "%s: need '%s' or '%s'\n", progname, |
547 |
< |
vnam(OCTREE), vnam(SCENE)); |
536 |
> |
if (vdef(ILLUM)) { /* illum requires secondary octrees */ |
537 |
> |
oct0name = newfname(vval(OCTREE), '0'); |
538 |
> |
oct1name = newfname(vval(OCTREE), '1'); |
539 |
> |
oct0date = fdate(oct0name); |
540 |
> |
oct1date = fdate(oct1name); |
541 |
> |
} else |
542 |
> |
oct0name = oct1name = vval(OCTREE); |
543 |
> |
if ((scenedate = checklast(vval(SCENE))) && |
544 |
> |
(objdate = checklast(vval(OBJECT))) > scenedate) |
545 |
> |
scenedate = objdate; |
546 |
> |
illumdate = checklast(vval(ILLUM)); |
547 |
> |
if (!octreedate & !scenedate & !illumdate) { |
548 |
> |
fprintf(stderr, "%s: need '%s' or '%s' or '%s'\n", progname, |
549 |
> |
vnam(OCTREE), vnam(SCENE), vnam(ILLUM)); |
550 |
|
exit(1); |
551 |
|
} |
552 |
< |
matdate = -1; |
432 |
< |
if (vdef(MATERIAL)) |
433 |
< |
matdate = checklast(vval(MATERIAL)); |
552 |
> |
matdate = checklast(vval(MATERIAL)); |
553 |
|
} |
554 |
|
|
555 |
|
|
558 |
|
{ |
559 |
|
extern FILE *popen(); |
560 |
|
static double oorg[3], osiz = 0.; |
561 |
< |
char buf[MAXPATH+16]; |
561 |
> |
double min[3], max[3]; |
562 |
> |
char buf[512]; |
563 |
|
FILE *fp; |
564 |
+ |
register int i; |
565 |
|
|
566 |
< |
if (osiz <= FTINY) { |
567 |
< |
oconv(); /* does nothing if done already */ |
568 |
< |
sprintf(buf, "getinfo -d < %s", vval(OCTREE)); |
569 |
< |
if ((fp = popen(buf, "r")) == NULL) |
570 |
< |
syserr("getinfo"); |
571 |
< |
if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1], |
572 |
< |
&oorg[2], &osiz) != 4) { |
573 |
< |
fprintf(stderr, |
566 |
> |
if (osiz <= FTINY) |
567 |
> |
if (noaction && fdate(oct1name) < |
568 |
> |
(scenedate>illumdate?scenedate:illumdate)) { |
569 |
> |
/* run getbbox */ |
570 |
> |
sprintf(buf, "getbbox -w -h %s", |
571 |
> |
vdef(SCENE) ? vval(SCENE) : vval(ILLUM)); |
572 |
> |
if ((fp = popen(buf, "r")) == NULL) |
573 |
> |
syserr("getbbox"); |
574 |
> |
if (fscanf(fp, "%lf %lf %lf %lf %lf %lf", |
575 |
> |
&min[0], &max[0], &min[1], &max[1], |
576 |
> |
&min[2], &max[2]) != 6) { |
577 |
> |
fprintf(stderr, |
578 |
> |
"%s: error reading bounding box from getbbox\n", |
579 |
> |
progname); |
580 |
> |
exit(1); |
581 |
> |
} |
582 |
> |
for (i = 0; i < 3; i++) |
583 |
> |
if (max[i] - min[i] > osiz) |
584 |
> |
osiz = max[i] - min[i]; |
585 |
> |
for (i = 0; i < 3; i++) |
586 |
> |
oorg[i] = (max[i]+min[i]-osiz)*.5; |
587 |
> |
pclose(fp); |
588 |
> |
} else { /* from octree */ |
589 |
> |
oconv(); /* does nothing if done already */ |
590 |
> |
sprintf(buf, "getinfo -d < %s", oct1name); |
591 |
> |
if ((fp = popen(buf, "r")) == NULL) |
592 |
> |
syserr("getinfo"); |
593 |
> |
if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1], |
594 |
> |
&oorg[2], &osiz) != 4) { |
595 |
> |
fprintf(stderr, |
596 |
|
"%s: error reading bounding cube from getinfo\n", |
597 |
< |
progname); |
598 |
< |
exit(1); |
597 |
> |
progname); |
598 |
> |
exit(1); |
599 |
> |
} |
600 |
> |
pclose(fp); |
601 |
|
} |
457 |
– |
pclose(fp); |
458 |
– |
} |
602 |
|
org[0] = oorg[0]; org[1] = oorg[1]; org[2] = oorg[2]; *sizp = osiz; |
603 |
|
} |
604 |
|
|
652 |
|
|
653 |
|
printvals() /* print variable values */ |
654 |
|
{ |
655 |
< |
register int i, j; |
655 |
> |
int i, j, clipline; |
656 |
> |
register char *cp; |
657 |
> |
register int k; |
658 |
|
|
659 |
< |
for (i = 0; i < NVARS; i++) |
660 |
< |
for (j = 0; j < vdef(i); j++) |
661 |
< |
printf("%s= %s\n", vnam(i), nvalue(vv+i, j)); |
659 |
> |
for (i = 0; i < NVARS; i++) /* print each variable */ |
660 |
> |
for (j = 0; j < vdef(i); j++) { /* print each assignment */ |
661 |
> |
fputs(vnam(i), stdout); |
662 |
> |
fputs("= ", stdout); |
663 |
> |
k = clipline = ( vv[i].fixval == catvalues ? 64 : 320 ) |
664 |
> |
- strlen(vnam(i)) ; |
665 |
> |
cp = nvalue(vv+i, j); |
666 |
> |
while (*cp) { |
667 |
> |
putchar(*cp++); |
668 |
> |
if (--k <= 0) { /* line too long */ |
669 |
> |
while (*cp && !isspace(*cp)) |
670 |
> |
putchar(*cp++); /* finish this word */ |
671 |
> |
if (*cp) { /* start new line */ |
672 |
> |
putchar('\n'); |
673 |
> |
fputs(vnam(i), stdout); |
674 |
> |
putchar('='); |
675 |
> |
k = clipline; |
676 |
> |
} |
677 |
> |
} |
678 |
> |
} |
679 |
> |
putchar('\n'); |
680 |
> |
} |
681 |
|
fflush(stdout); |
682 |
|
} |
683 |
|
|
684 |
|
|
685 |
< |
oconv() /* run oconv if necessary */ |
685 |
> |
oconv() /* run oconv and mkillum if necessary */ |
686 |
|
{ |
687 |
< |
char combuf[512], ocopts[64]; |
687 |
> |
static char illumtmp[] = "ilXXXXXX"; |
688 |
> |
char combuf[512], ocopts[64], mkopts[64]; |
689 |
|
|
690 |
< |
if (octreedate >= scenedate) /* check dates */ |
690 |
> |
oconvopts(ocopts); /* get options */ |
691 |
> |
if (octreedate < scenedate) { /* check date on original octree */ |
692 |
> |
if (touchonly && octreedate) |
693 |
> |
touch(vval(OCTREE)); |
694 |
> |
else { /* build command */ |
695 |
> |
if (vdef(MATERIAL)) |
696 |
> |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
697 |
> |
vval(MATERIAL), vval(SCENE), |
698 |
> |
vval(OCTREE)); |
699 |
> |
else |
700 |
> |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
701 |
> |
vval(SCENE), vval(OCTREE)); |
702 |
> |
|
703 |
> |
if (runcom(combuf)) { /* run it */ |
704 |
> |
fprintf(stderr, |
705 |
> |
"%s: error generating octree\n\t%s removed\n", |
706 |
> |
progname, vval(OCTREE)); |
707 |
> |
unlink(vval(OCTREE)); |
708 |
> |
exit(1); |
709 |
> |
} |
710 |
> |
} |
711 |
> |
octreedate = time((time_t *)NULL); |
712 |
> |
if (octreedate < scenedate) /* in case clock is off */ |
713 |
> |
octreedate = scenedate; |
714 |
> |
} |
715 |
> |
if (oct1name == vval(OCTREE)) /* no mkillum? */ |
716 |
> |
oct1date = octreedate > matdate ? octreedate : matdate; |
717 |
> |
if (oct1date >= octreedate & oct1date >= matdate |
718 |
> |
& oct1date >= illumdate) /* all done */ |
719 |
|
return; |
720 |
< |
/* build command */ |
721 |
< |
oconvopts(ocopts); |
722 |
< |
if (vdef(MATERIAL)) |
723 |
< |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
724 |
< |
vval(MATERIAL), vval(SCENE), vval(OCTREE)); |
725 |
< |
else |
726 |
< |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
727 |
< |
vval(SCENE), vval(OCTREE)); |
728 |
< |
|
729 |
< |
if (runcom(combuf)) { /* run it */ |
730 |
< |
fprintf(stderr, "%s: error generating octree\n\t%s removed\n", |
731 |
< |
progname, vval(OCTREE)); |
732 |
< |
unlink(vval(OCTREE)); |
733 |
< |
exit(1); |
720 |
> |
/* make octree0 */ |
721 |
> |
if (oct0date < scenedate | oct0date < illumdate) { |
722 |
> |
if (touchonly && oct0date) |
723 |
> |
touch(oct0name); |
724 |
> |
else { /* build command */ |
725 |
> |
if (octreedate) |
726 |
> |
sprintf(combuf, "oconv%s -i %s %s > %s", ocopts, |
727 |
> |
vval(OCTREE), vval(ILLUM), oct0name); |
728 |
> |
else if (vdef(MATERIAL)) |
729 |
> |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
730 |
> |
vval(MATERIAL), vval(ILLUM), oct0name); |
731 |
> |
else |
732 |
> |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
733 |
> |
vval(ILLUM), oct0name); |
734 |
> |
if (runcom(combuf)) { /* run it */ |
735 |
> |
fprintf(stderr, |
736 |
> |
"%s: error generating octree\n\t%s removed\n", |
737 |
> |
progname, oct0name); |
738 |
> |
unlink(oct0name); |
739 |
> |
exit(1); |
740 |
> |
} |
741 |
> |
} |
742 |
> |
oct0date = time((time_t *)NULL); |
743 |
> |
if (oct0date < octreedate) /* in case clock is off */ |
744 |
> |
oct0date = octreedate; |
745 |
> |
if (oct0date < illumdate) /* ditto */ |
746 |
> |
oct0date = illumdate; |
747 |
> |
} |
748 |
> |
if (touchonly && oct1date) |
749 |
> |
touch(oct1name); |
750 |
> |
else { |
751 |
> |
mkillumopts(mkopts); /* build mkillum command */ |
752 |
> |
mktemp(illumtmp); |
753 |
> |
sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts, |
754 |
> |
oct0name, vval(ILLUM), illumtmp); |
755 |
> |
if (runcom(combuf)) { /* run it */ |
756 |
> |
fprintf(stderr, "%s: error running mkillum\n", |
757 |
> |
progname); |
758 |
> |
unlink(illumtmp); |
759 |
> |
exit(1); |
760 |
> |
} |
761 |
> |
/* make octree1 (frozen) */ |
762 |
> |
if (octreedate) |
763 |
> |
sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts, |
764 |
> |
vval(OCTREE), illumtmp, oct1name); |
765 |
> |
else if (vdef(MATERIAL)) |
766 |
> |
sprintf(combuf, "oconv%s -f %s %s > %s", ocopts, |
767 |
> |
vval(MATERIAL), illumtmp, oct1name); |
768 |
> |
else |
769 |
> |
sprintf(combuf, "oconv%s -f %s > %s", ocopts, |
770 |
> |
illumtmp, oct1name); |
771 |
> |
if (runcom(combuf)) { /* run it */ |
772 |
> |
fprintf(stderr, |
773 |
> |
"%s: error generating octree\n\t%s removed\n", |
774 |
> |
progname, oct1name); |
775 |
> |
unlink(oct1name); |
776 |
> |
exit(1); |
777 |
> |
} |
778 |
> |
rmfile(illumtmp); |
779 |
|
} |
780 |
< |
octreedate = time(0); |
780 |
> |
oct1date = time((time_t *)NULL); |
781 |
> |
if (oct1date < oct0date) /* in case clock is off */ |
782 |
> |
oct1date = oct0date; |
783 |
|
} |
784 |
|
|
785 |
|
|
805 |
|
} |
806 |
|
|
807 |
|
|
808 |
+ |
mkillumopts(mo) /* get mkillum options */ |
809 |
+ |
register char *mo; |
810 |
+ |
{ |
811 |
+ |
/* BEWARE: This may be called via setdefaults(), so no assumptions */ |
812 |
+ |
|
813 |
+ |
*mo = '\0'; |
814 |
+ |
if (vdef(MKILLUM)) |
815 |
+ |
addarg(mo, vval(MKILLUM)); |
816 |
+ |
} |
817 |
+ |
|
818 |
+ |
|
819 |
|
checkambfile() /* check date on ambient file */ |
820 |
|
{ |
821 |
< |
long afdate; |
821 |
> |
time_t afdate; |
822 |
|
|
823 |
|
if (!vdef(AMBFILE)) |
824 |
|
return; |
825 |
< |
if ((afdate = fdate(vval(AMBFILE))) < 0) |
825 |
> |
if (!(afdate = fdate(vval(AMBFILE)))) |
826 |
|
return; |
827 |
< |
if (octreedate > afdate | matdate > afdate) |
828 |
< |
rmfile(vval(AMBFILE)); |
827 |
> |
if (oct1date > afdate) |
828 |
> |
if (touchonly) |
829 |
> |
touch(vval(AMBFILE)); |
830 |
> |
else |
831 |
> |
rmfile(vval(AMBFILE)); |
832 |
|
} |
833 |
|
|
834 |
|
|
836 |
|
ambval() /* compute ambient value */ |
837 |
|
{ |
838 |
|
if (vdef(EXPOSURE)) { |
585 |
– |
if (!isflt(vval(EXPOSURE))) |
586 |
– |
badvalue(EXPOSURE); |
839 |
|
if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-') |
840 |
|
return(.5/pow(2.,atof(vval(EXPOSURE)))); |
841 |
|
return(.5/atof(vval(EXPOSURE))); |
848 |
|
} |
849 |
|
|
850 |
|
|
851 |
< |
lowqopts(op) /* low quality rendering options */ |
851 |
> |
renderopts(op, po) /* set rendering options */ |
852 |
> |
char *op, *po; |
853 |
> |
{ |
854 |
> |
switch(vscale(QUALITY)) { |
855 |
> |
case LOW: |
856 |
> |
lowqopts(op, po); |
857 |
> |
break; |
858 |
> |
case MEDIUM: |
859 |
> |
medqopts(op, po); |
860 |
> |
break; |
861 |
> |
case HIGH: |
862 |
> |
hiqopts(op, po); |
863 |
> |
break; |
864 |
> |
} |
865 |
> |
} |
866 |
> |
|
867 |
> |
|
868 |
> |
lowqopts(op, po) /* low quality rendering options */ |
869 |
|
register char *op; |
870 |
+ |
char *po; |
871 |
|
{ |
872 |
|
double d, org[3], siz[3]; |
873 |
|
|
874 |
|
*op = '\0'; |
875 |
+ |
*po = '\0'; |
876 |
|
if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0], |
877 |
|
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) |
878 |
|
badvalue(ZONE); |
879 |
|
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; |
880 |
+ |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
881 |
+ |
badvalue(ZONE); |
882 |
|
getoctcube(org, &d); |
883 |
|
d *= 3./(siz[0]+siz[1]+siz[2]); |
884 |
|
switch (vscale(DETAIL)) { |
885 |
|
case LOW: |
886 |
< |
op = addarg(op, "-ps 16 -dp 16"); |
886 |
> |
po = addarg(po, "-ps 16"); |
887 |
> |
op = addarg(op, "-dp 64"); |
888 |
|
sprintf(op, " -ar %d", (int)(4*d)); |
889 |
|
op += strlen(op); |
890 |
|
break; |
891 |
|
case MEDIUM: |
892 |
< |
op = addarg(op, "-ps 8 -dp 32"); |
892 |
> |
po = addarg(po, "-ps 8"); |
893 |
> |
op = addarg(op, "-dp 128"); |
894 |
|
sprintf(op, " -ar %d", (int)(8*d)); |
895 |
|
op += strlen(op); |
896 |
|
break; |
897 |
|
case HIGH: |
898 |
< |
op = addarg(op, "-ps 4 -dp 64"); |
898 |
> |
po = addarg(po, "-ps 4"); |
899 |
> |
op = addarg(op, "-dp 256"); |
900 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
901 |
|
op += strlen(op); |
902 |
|
break; |
903 |
|
} |
904 |
< |
op = addarg(op, "-pt .16"); |
904 |
> |
po = addarg(po, "-pt .16"); |
905 |
|
if (vbool(PENUMBRAS)) |
906 |
|
op = addarg(op, "-ds .4"); |
907 |
|
else |
933 |
|
} |
934 |
|
|
935 |
|
|
936 |
< |
medqopts(op) /* medium quality rendering options */ |
936 |
> |
medqopts(op, po) /* medium quality rendering options */ |
937 |
|
register char *op; |
938 |
+ |
char *po; |
939 |
|
{ |
940 |
|
double d, org[3], siz[3]; |
941 |
|
|
942 |
|
*op = '\0'; |
943 |
+ |
*po = '\0'; |
944 |
|
if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0], |
945 |
|
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) |
946 |
|
badvalue(ZONE); |
947 |
|
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; |
948 |
+ |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
949 |
+ |
badvalue(ZONE); |
950 |
|
getoctcube(org, &d); |
951 |
|
d *= 3./(siz[0]+siz[1]+siz[2]); |
952 |
|
switch (vscale(DETAIL)) { |
953 |
|
case LOW: |
954 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8"); |
955 |
< |
op = addarg(op, "-dp 64"); |
954 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8"); |
955 |
> |
op = addarg(op, "-dp 256"); |
956 |
|
sprintf(op, " -ar %d", (int)(8*d)); |
957 |
|
op += strlen(op); |
958 |
|
break; |
959 |
|
case MEDIUM: |
960 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6"); |
961 |
< |
op = addarg(op, "-dp 128"); |
960 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6"); |
961 |
> |
op = addarg(op, "-dp 512"); |
962 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
963 |
|
op += strlen(op); |
964 |
|
break; |
965 |
|
case HIGH: |
966 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4"); |
967 |
< |
op = addarg(op, "-dp 256"); |
966 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4"); |
967 |
> |
op = addarg(op, "-dp 1024"); |
968 |
|
sprintf(op, " -ar %d", (int)(32*d)); |
969 |
|
op += strlen(op); |
970 |
|
break; |
971 |
|
} |
972 |
< |
op = addarg(op, "-pt .08"); |
972 |
> |
po = addarg(po, "-pt .08"); |
973 |
|
if (vbool(PENUMBRAS)) |
974 |
< |
op = addarg(op, "-ds .2 -dj .35"); |
974 |
> |
op = addarg(op, "-ds .2 -dj .5"); |
975 |
|
else |
976 |
|
op = addarg(op, "-ds .3"); |
977 |
|
op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1"); |
1004 |
|
} |
1005 |
|
|
1006 |
|
|
1007 |
< |
hiqopts(op) /* high quality rendering options */ |
1007 |
> |
hiqopts(op, po) /* high quality rendering options */ |
1008 |
|
register char *op; |
1009 |
+ |
char *po; |
1010 |
|
{ |
1011 |
|
double d, org[3], siz[3]; |
1012 |
|
|
1013 |
|
*op = '\0'; |
1014 |
+ |
*po = '\0'; |
1015 |
|
if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0], |
1016 |
|
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) |
1017 |
|
badvalue(ZONE); |
1018 |
|
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; |
1019 |
+ |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
1020 |
+ |
badvalue(ZONE); |
1021 |
|
getoctcube(org, &d); |
1022 |
|
d *= 3./(siz[0]+siz[1]+siz[2]); |
1023 |
|
switch (vscale(DETAIL)) { |
1024 |
|
case LOW: |
1025 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8"); |
1026 |
< |
op = addarg(op, "-dp 256"); |
1025 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8"); |
1026 |
> |
op = addarg(op, "-dp 1024"); |
1027 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
1028 |
|
op += strlen(op); |
1029 |
|
break; |
1030 |
|
case MEDIUM: |
1031 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5"); |
1032 |
< |
op = addarg(op, "-dp 512"); |
1031 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5"); |
1032 |
> |
op = addarg(op, "-dp 2048"); |
1033 |
|
sprintf(op, " -ar %d", (int)(32*d)); |
1034 |
|
op += strlen(op); |
1035 |
|
break; |
1036 |
|
case HIGH: |
1037 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3"); |
1038 |
< |
op = addarg(op, "-dp 1024"); |
1037 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3"); |
1038 |
> |
op = addarg(op, "-dp 4096"); |
1039 |
|
sprintf(op, " -ar %d", (int)(64*d)); |
1040 |
|
op += strlen(op); |
1041 |
|
break; |
1042 |
|
} |
1043 |
< |
op = addarg(op, "-pt .04"); |
1043 |
> |
po = addarg(po, "-pt .04"); |
1044 |
|
if (vbool(PENUMBRAS)) |
1045 |
< |
op = addarg(op, "-ds .1 -dj .7"); |
1045 |
> |
op = addarg(op, "-ds .1 -dj .65"); |
1046 |
|
else |
1047 |
|
op = addarg(op, "-ds .2"); |
1048 |
|
op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01"); |
1190 |
|
badvalue(ZONE); |
1191 |
|
for (i = 0; i < 3; i++) { |
1192 |
|
dim[i] -= cent[i]; |
1193 |
+ |
if (dim[i] <= FTINY) |
1194 |
+ |
badvalue(ZONE); |
1195 |
|
cent[i] += .5*dim[i]; |
1196 |
|
} |
1197 |
|
mult = vlet(ZONE)=='E' ? 2. : .45 ; |
1244 |
|
cp += strlen(cp); |
1245 |
|
} |
1246 |
|
} |
1247 |
< |
strcpy(cp, vs); /* append any additional options */ |
1247 |
> |
if (cp == viewopts) /* append any additional options */ |
1248 |
> |
vs++; /* skip prefixed space if unneeded */ |
1249 |
> |
strcpy(cp, vs); |
1250 |
|
#ifdef MSDOS |
1251 |
|
if (strlen(viewopts) > 40) { |
1252 |
|
setenv("VIEW", viewopts); |
1301 |
|
printview(vopts) /* print out selected view */ |
1302 |
|
register char *vopts; |
1303 |
|
{ |
1304 |
< |
extern char *atos(); |
1304 |
> |
extern char *atos(), *getenv(); |
1305 |
|
char buf[256]; |
1306 |
|
FILE *fp; |
1307 |
|
register char *cp; |
1336 |
|
while (isspace(*vopts)) |
1337 |
|
vopts++; |
1338 |
|
putchar(' '); |
1339 |
< |
while (*vopts && !isspace(*vopts)) |
1340 |
< |
putchar(*vopts++); |
1339 |
> |
#ifdef MSDOS |
1340 |
> |
if (*vopts == '$') { /* expand env. var. */ |
1341 |
> |
if (!*atos(buf, sizeof(buf), vopts+1)) |
1342 |
> |
return(-1); |
1343 |
> |
if ((cp = getenv(buf)) == NULL) |
1344 |
> |
return(-1); |
1345 |
> |
fputs(cp, stdout); |
1346 |
> |
vopts = sskip(vopts); |
1347 |
> |
} else |
1348 |
> |
#endif |
1349 |
> |
while (*vopts && !isspace(*vopts)) |
1350 |
> |
putchar(*vopts++); |
1351 |
|
} |
1352 |
|
} while (*vopts++); |
1353 |
|
putchar('\n'); |
1355 |
|
} |
1356 |
|
|
1357 |
|
|
1358 |
< |
rview(opts) /* run rview with first view */ |
1359 |
< |
char *opts; |
1358 |
> |
rview(opts, po) /* run rview with first view */ |
1359 |
> |
char *opts, *po; |
1360 |
|
{ |
1361 |
|
char *vw; |
1362 |
|
char combuf[512]; |
1363 |
|
/* build command */ |
1364 |
< |
if ((vw = getview(0, NULL)) == NULL) |
1364 |
> |
if (touchonly || (vw = getview(0, NULL)) == NULL) |
1365 |
|
return; |
1366 |
|
if (sayview) |
1367 |
|
printview(vw); |
1368 |
< |
sprintf(combuf, "rview %s%s ", vw, opts); |
1368 |
> |
sprintf(combuf, "rview %s%s%s -R %s ", vw, po, opts, rifname); |
1369 |
|
if (rvdevice != NULL) |
1370 |
|
sprintf(combuf+strlen(combuf), "-o %s ", rvdevice); |
1371 |
< |
strcat(combuf, vval(OCTREE)); |
1371 |
> |
if (vdef(EXPOSURE)) |
1372 |
> |
sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE)); |
1373 |
> |
strcat(combuf, oct1name); |
1374 |
|
if (runcom(combuf)) { /* run it */ |
1375 |
|
fprintf(stderr, "%s: error running rview\n", progname); |
1376 |
|
exit(1); |
1378 |
|
} |
1379 |
|
|
1380 |
|
|
1381 |
< |
rpict(opts) /* run rpict and pfilt for each view */ |
1382 |
< |
char *opts; |
1381 |
> |
rpict(opts, po) /* run rpict and pfilt for each view */ |
1382 |
> |
char *opts, *po; |
1383 |
|
{ |
1384 |
|
char combuf[1024]; |
1385 |
|
char rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH+16], res[32]; |
1386 |
|
char pfopts[128]; |
1387 |
|
char vs[32], *vw; |
1388 |
|
int vn, mult; |
1389 |
< |
long lastdate; |
1389 |
> |
time_t rfdt, pfdt; |
1390 |
|
/* get pfilt options */ |
1391 |
|
pfiltopts(pfopts); |
1392 |
|
/* get resolution, reporting */ |
1393 |
< |
mult = vscale(QUALITY)+1; |
1393 |
> |
switch (vscale(QUALITY)) { |
1394 |
> |
case LOW: |
1395 |
> |
mult = 1; |
1396 |
> |
break; |
1397 |
> |
case MEDIUM: |
1398 |
> |
mult = 2; |
1399 |
> |
break; |
1400 |
> |
case HIGH: |
1401 |
> |
mult = 3; |
1402 |
> |
break; |
1403 |
> |
} |
1404 |
|
{ |
1405 |
|
int xres, yres; |
1406 |
|
double aspect; |
1427 |
|
else |
1428 |
|
badvalue(REPORT); |
1429 |
|
} |
1120 |
– |
/* get update time */ |
1121 |
– |
lastdate = octreedate > matdate ? octreedate : matdate; |
1430 |
|
/* do each view */ |
1431 |
|
vn = 0; |
1432 |
|
while ((vw = getview(vn++, vs)) != NULL) { |
1436 |
|
sprintf(vs, "%d", vn); |
1437 |
|
sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs); |
1438 |
|
/* check date on picture */ |
1439 |
< |
if (fdate(picfile) >= lastdate) |
1439 |
> |
pfdt = fdate(picfile); |
1440 |
> |
if (pfdt >= oct1date) |
1441 |
|
continue; |
1442 |
< |
/* build rpict command */ |
1442 |
> |
/* get raw file name */ |
1443 |
|
sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs); |
1444 |
< |
if (fdate(rawfile) >= octreedate) /* recover */ |
1445 |
< |
sprintf(combuf, "rpict%s%s -ro %s %s", |
1446 |
< |
rep, opts, rawfile, vval(OCTREE)); |
1444 |
> |
rfdt = fdate(rawfile); |
1445 |
> |
if (touchonly) { /* update times only */ |
1446 |
> |
if (rfdt) { |
1447 |
> |
if (rfdt < oct1date) |
1448 |
> |
touch(rawfile); |
1449 |
> |
} else if (pfdt && pfdt < oct1date) |
1450 |
> |
touch(picfile); |
1451 |
> |
continue; |
1452 |
> |
} |
1453 |
> |
/* build rpict command */ |
1454 |
> |
if (rfdt >= oct1date) /* recover */ |
1455 |
> |
sprintf(combuf, "rpict%s%s%s -ro %s %s", |
1456 |
> |
rep, po, opts, rawfile, oct1name); |
1457 |
|
else { |
1458 |
|
if (overture) { /* run overture calculation */ |
1459 |
|
sprintf(combuf, |
1460 |
|
"rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s", |
1461 |
|
rep, vw, opts, |
1462 |
< |
vval(OCTREE), overfile); |
1462 |
> |
oct1name, overfile); |
1463 |
|
if (runcom(combuf)) { |
1464 |
|
fprintf(stderr, |
1465 |
|
"%s: error in overture for view %s\n", |
1470 |
|
rmfile(overfile); |
1471 |
|
#endif |
1472 |
|
} |
1473 |
< |
sprintf(combuf, "rpict%s %s %s%s %s > %s", |
1474 |
< |
rep, vw, res, opts, |
1475 |
< |
vval(OCTREE), rawfile); |
1473 |
> |
sprintf(combuf, "rpict%s %s %s%s%s %s > %s", |
1474 |
> |
rep, vw, res, po, opts, |
1475 |
> |
oct1name, rawfile); |
1476 |
|
} |
1477 |
|
if (runcom(combuf)) { /* run rpict */ |
1478 |
|
fprintf(stderr, "%s: error rendering view %s\n", |
1496 |
|
/* remove raw file */ |
1497 |
|
rmfile(rawfile); |
1498 |
|
} |
1499 |
+ |
} |
1500 |
+ |
|
1501 |
+ |
|
1502 |
+ |
touch(fn) /* update a file */ |
1503 |
+ |
char *fn; |
1504 |
+ |
{ |
1505 |
+ |
if (!silent) |
1506 |
+ |
printf("\ttouch %s\n", fn); |
1507 |
+ |
if (noaction) |
1508 |
+ |
return(0); |
1509 |
+ |
#ifdef notused |
1510 |
+ |
if (access(fn, F_OK) == -1) /* create it */ |
1511 |
+ |
if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1) |
1512 |
+ |
return(-1); |
1513 |
+ |
#endif |
1514 |
+ |
return(setfdate(fn, time((time_t *)NULL))); |
1515 |
|
} |
1516 |
|
|
1517 |
|
|