| 1 |
/* Copyright (c) 1993 Regents of the University of California */
|
| 2 |
|
| 3 |
#ifndef lint
|
| 4 |
static char SCCSid[] = "$SunId$ LBL";
|
| 5 |
#endif
|
| 6 |
|
| 7 |
/*
|
| 8 |
* Executive program for oconv, rpict and pfilt
|
| 9 |
*/
|
| 10 |
|
| 11 |
#include "standard.h"
|
| 12 |
#include "paths.h"
|
| 13 |
#include <ctype.h>
|
| 14 |
|
| 15 |
|
| 16 |
typedef struct {
|
| 17 |
char *name; /* variable name */
|
| 18 |
short nick; /* # characters required for nickname */
|
| 19 |
short nass; /* # assignments made */
|
| 20 |
char *value; /* assigned value(s) */
|
| 21 |
int (*fixval)(); /* assignment checking function */
|
| 22 |
} VARIABLE;
|
| 23 |
|
| 24 |
int onevalue(), catvalues();
|
| 25 |
|
| 26 |
/* variables */
|
| 27 |
#define OBJECT 0 /* object files */
|
| 28 |
#define SCENE 1 /* scene files */
|
| 29 |
#define MATERIAL 2 /* material files */
|
| 30 |
#define RENDER 3 /* rendering options */
|
| 31 |
#define OCONV 4 /* oconv options */
|
| 32 |
#define PFILT 5 /* pfilt options */
|
| 33 |
#define VIEW 6 /* view(s) for picture(s) */
|
| 34 |
#define ZONE 7 /* simulation zone */
|
| 35 |
#define QUALITY 8 /* desired rendering quality */
|
| 36 |
#define OCTREE 9 /* octree file name */
|
| 37 |
#define PICTURE 10 /* picture file name */
|
| 38 |
#define AMBFILE 11 /* ambient file name */
|
| 39 |
#define OPTFILE 12 /* rendering options file */
|
| 40 |
#define EXPOSURE 13 /* picture exposure setting */
|
| 41 |
#define RESOLUTION 14 /* maximum picture resolution */
|
| 42 |
#define UP 15 /* view up (X, Y or Z) */
|
| 43 |
#define INDIRECT 16 /* indirection in lighting */
|
| 44 |
#define DETAIL 17 /* level of scene detail */
|
| 45 |
#define PENUMBRAS 18 /* shadow penumbras are desired */
|
| 46 |
#define VARIABILITY 19 /* level of light variability */
|
| 47 |
#define REPORT 20 /* report frequency and errfile */
|
| 48 |
/* total number of variables */
|
| 49 |
#define NVARS 21
|
| 50 |
|
| 51 |
VARIABLE vv[NVARS] = { /* variable-value pairs */
|
| 52 |
{"objects", 3, 0, NULL, catvalues},
|
| 53 |
{"scene", 3, 0, NULL, catvalues},
|
| 54 |
{"materials", 3, 0, NULL, catvalues},
|
| 55 |
{"render", 3, 0, NULL, catvalues},
|
| 56 |
{"oconv", 3, 0, NULL, catvalues},
|
| 57 |
{"pfilt", 2, 0, NULL, catvalues},
|
| 58 |
{"view", 2, 0, NULL, NULL},
|
| 59 |
{"ZONE", 2, 0, NULL, onevalue},
|
| 60 |
{"QUALITY", 3, 0, NULL, onevalue},
|
| 61 |
{"OCTREE", 3, 0, NULL, onevalue},
|
| 62 |
{"PICTURE", 3, 0, NULL, onevalue},
|
| 63 |
{"AMBFILE", 3, 0, NULL, onevalue},
|
| 64 |
{"OPTFILE", 3, 0, NULL, onevalue},
|
| 65 |
{"EXPOSURE", 3, 0, NULL, onevalue},
|
| 66 |
{"RESOLUTION", 3, 0, NULL, onevalue},
|
| 67 |
{"UP", 2, 0, NULL, onevalue},
|
| 68 |
{"INDIRECT", 3, 0, NULL, onevalue},
|
| 69 |
{"DETAIL", 3, 0, NULL, onevalue},
|
| 70 |
{"PENUMBRAS", 3, 0, NULL, onevalue},
|
| 71 |
{"VARIABILITY", 3, 0, NULL, onevalue},
|
| 72 |
{"REPORT", 3, 0, NULL, onevalue},
|
| 73 |
};
|
| 74 |
|
| 75 |
VARIABLE *matchvar();
|
| 76 |
char *nvalue();
|
| 77 |
int vscale();
|
| 78 |
|
| 79 |
#define UPPER(c) ((c)&~0x20) /* ASCII trick */
|
| 80 |
|
| 81 |
#define vnam(vc) (vv[vc].name)
|
| 82 |
#define vdef(vc) (vv[vc].nass)
|
| 83 |
#define vval(vc) (vv[vc].value)
|
| 84 |
#define vint(vc) atoi(vval(vc))
|
| 85 |
#define vlet(vc) UPPER(vval(vc)[0])
|
| 86 |
#define vbool(vc) (vlet(vc)=='T')
|
| 87 |
|
| 88 |
#define HIGH 2
|
| 89 |
#define MEDIUM 1
|
| 90 |
#define LOW 0
|
| 91 |
|
| 92 |
int lowqopts(), medqopts(), hiqopts();
|
| 93 |
int (*setqopts[3])() = {lowqopts, medqopts, hiqopts};
|
| 94 |
|
| 95 |
#define renderopts (*setqopts[vscale(QUALITY)])
|
| 96 |
|
| 97 |
/* overture calculation file */
|
| 98 |
#ifdef NIX
|
| 99 |
char overfile[] = "overture.raw";
|
| 100 |
#else
|
| 101 |
char overfile[] = "/dev/null";
|
| 102 |
#endif
|
| 103 |
|
| 104 |
extern long fdate(), time();
|
| 105 |
|
| 106 |
long scenedate; /* date of latest scene or object file */
|
| 107 |
long octreedate; /* date of octree */
|
| 108 |
|
| 109 |
int explicate = 0; /* explicate variables */
|
| 110 |
int silent = 0; /* do work silently */
|
| 111 |
int noaction = 0; /* don't do anything */
|
| 112 |
char *rvdevice = NULL; /* rview output device */
|
| 113 |
char *viewselect = NULL; /* specific view only */
|
| 114 |
|
| 115 |
int overture = 0; /* overture calculation needed */
|
| 116 |
|
| 117 |
char *progname; /* global argv[0] */
|
| 118 |
|
| 119 |
char radname[MAXPATH]; /* root Radiance file name */
|
| 120 |
|
| 121 |
|
| 122 |
main(argc, argv)
|
| 123 |
int argc;
|
| 124 |
char *argv[];
|
| 125 |
{
|
| 126 |
char ropts[512];
|
| 127 |
int i;
|
| 128 |
|
| 129 |
progname = argv[0];
|
| 130 |
/* get options */
|
| 131 |
for (i = 1; i < argc && argv[i][0] == '-'; i++)
|
| 132 |
switch (argv[i][1]) {
|
| 133 |
case 's':
|
| 134 |
silent++;
|
| 135 |
break;
|
| 136 |
case 'n':
|
| 137 |
noaction++;
|
| 138 |
break;
|
| 139 |
case 'e':
|
| 140 |
explicate++;
|
| 141 |
break;
|
| 142 |
case 'o':
|
| 143 |
rvdevice = argv[++i];
|
| 144 |
break;
|
| 145 |
case 'v':
|
| 146 |
viewselect = argv[++i];
|
| 147 |
break;
|
| 148 |
default:
|
| 149 |
goto userr;
|
| 150 |
}
|
| 151 |
if (i >= argc)
|
| 152 |
goto userr;
|
| 153 |
/* assign Radiance root file name */
|
| 154 |
rootname(radname, argv[i]);
|
| 155 |
/* load variable values */
|
| 156 |
load(argv[i]);
|
| 157 |
/* get any additional assignments */
|
| 158 |
for (i++; i < argc; i++)
|
| 159 |
setvariable(argv[i]);
|
| 160 |
/* check assignments */
|
| 161 |
checkvalues();
|
| 162 |
/* check files and dates */
|
| 163 |
checkfiles();
|
| 164 |
/* set default values as necessary */
|
| 165 |
setdefaults();
|
| 166 |
/* print all values if requested */
|
| 167 |
if (explicate)
|
| 168 |
printvals();
|
| 169 |
/* run simulation */
|
| 170 |
oconv();
|
| 171 |
renderopts(ropts);
|
| 172 |
xferopts(ropts);
|
| 173 |
if (rvdevice != NULL)
|
| 174 |
rview(ropts);
|
| 175 |
else
|
| 176 |
rpict(ropts);
|
| 177 |
exit(0);
|
| 178 |
userr:
|
| 179 |
fprintf(stderr,
|
| 180 |
"Usage: %s [-s][-n][-e][-v view][-o dev] rfile [VAR=value ..]\n",
|
| 181 |
progname);
|
| 182 |
exit(1);
|
| 183 |
}
|
| 184 |
|
| 185 |
|
| 186 |
rootname(rn, fn) /* remove tail from end of fn */
|
| 187 |
register char *rn, *fn;
|
| 188 |
{
|
| 189 |
char *tp, *dp;
|
| 190 |
|
| 191 |
for (tp = NULL, dp = rn; *rn = *fn++; rn++)
|
| 192 |
if (ISDIRSEP(*rn))
|
| 193 |
dp = rn;
|
| 194 |
else if (*rn == '.')
|
| 195 |
tp = rn;
|
| 196 |
if (tp != NULL && tp > dp)
|
| 197 |
*tp = '\0';
|
| 198 |
}
|
| 199 |
|
| 200 |
|
| 201 |
load(rfname) /* load Radiance simulation file */
|
| 202 |
char *rfname;
|
| 203 |
{
|
| 204 |
FILE *fp;
|
| 205 |
char buf[512];
|
| 206 |
register char *cp;
|
| 207 |
|
| 208 |
if (rfname == NULL)
|
| 209 |
fp = stdin;
|
| 210 |
else if ((fp = fopen(rfname, "r")) == NULL)
|
| 211 |
syserr(rfname);
|
| 212 |
while (fgetline(buf, sizeof(buf), fp) != NULL) {
|
| 213 |
for (cp = buf; *cp; cp++) {
|
| 214 |
switch (*cp) {
|
| 215 |
case '\\':
|
| 216 |
case '\n':
|
| 217 |
*cp = ' ';
|
| 218 |
continue;
|
| 219 |
case '#':
|
| 220 |
*cp = '\0';
|
| 221 |
break;
|
| 222 |
default:
|
| 223 |
continue;
|
| 224 |
}
|
| 225 |
break;
|
| 226 |
}
|
| 227 |
setvariable(buf);
|
| 228 |
}
|
| 229 |
fclose(fp);
|
| 230 |
}
|
| 231 |
|
| 232 |
|
| 233 |
setvariable(ass) /* assign variable according to string */
|
| 234 |
register char *ass;
|
| 235 |
{
|
| 236 |
char varname[32];
|
| 237 |
register char *cp;
|
| 238 |
register VARIABLE *vp;
|
| 239 |
register int i;
|
| 240 |
int n;
|
| 241 |
|
| 242 |
while (isspace(*ass)) /* skip leading space */
|
| 243 |
ass++;
|
| 244 |
cp = varname; /* extract name */
|
| 245 |
while (cp < varname+sizeof(varname)-1
|
| 246 |
&& *ass && !isspace(*ass) && *ass != '=')
|
| 247 |
*cp++ = *ass++;
|
| 248 |
*cp = '\0';
|
| 249 |
if (!varname[0])
|
| 250 |
return; /* no variable name! */
|
| 251 |
/* trim value */
|
| 252 |
while (isspace(*ass) || *ass == '=')
|
| 253 |
ass++;
|
| 254 |
cp = ass + strlen(ass);
|
| 255 |
do
|
| 256 |
*cp-- = '\0';
|
| 257 |
while (cp >= ass && isspace(*cp));
|
| 258 |
n = cp - ass + 1;
|
| 259 |
if (!n) {
|
| 260 |
fprintf(stderr, "%s: warning - missing value for variable '%s'\n",
|
| 261 |
progname, varname);
|
| 262 |
return;
|
| 263 |
}
|
| 264 |
/* match variable from list */
|
| 265 |
vp = matchvar(varname);
|
| 266 |
if (vp == NULL) {
|
| 267 |
fprintf(stderr, "%s: unknown variable '%s'\n",
|
| 268 |
progname, varname);
|
| 269 |
exit(1);
|
| 270 |
}
|
| 271 |
/* assign new value */
|
| 272 |
if (i = vp->nass) {
|
| 273 |
cp = vp->value;
|
| 274 |
while (i--)
|
| 275 |
while (*cp++)
|
| 276 |
;
|
| 277 |
i = cp - vp->value;
|
| 278 |
vp->value = realloc(vp->value, i+n+1);
|
| 279 |
} else
|
| 280 |
vp->value = malloc(n+1);
|
| 281 |
if (vp->value == NULL)
|
| 282 |
syserr(progname);
|
| 283 |
strcpy(vp->value+i, ass);
|
| 284 |
vp->nass++;
|
| 285 |
}
|
| 286 |
|
| 287 |
|
| 288 |
VARIABLE *
|
| 289 |
matchvar(nam) /* match a variable by its name */
|
| 290 |
char *nam;
|
| 291 |
{
|
| 292 |
int n = strlen(nam);
|
| 293 |
register int i;
|
| 294 |
|
| 295 |
for (i = 0; i < NVARS; i++)
|
| 296 |
if (n >= vv[i].nick && !strncmp(nam, vv[i].name, n))
|
| 297 |
return(vv+i);
|
| 298 |
return(NULL);
|
| 299 |
}
|
| 300 |
|
| 301 |
|
| 302 |
char *
|
| 303 |
nvalue(vp, n) /* return nth variable value */
|
| 304 |
VARIABLE *vp;
|
| 305 |
register int n;
|
| 306 |
{
|
| 307 |
register char *cp;
|
| 308 |
|
| 309 |
if (vp == NULL || n < 0 || n >= vp->nass)
|
| 310 |
return(NULL);
|
| 311 |
cp = vp->value;
|
| 312 |
while (n--)
|
| 313 |
while (*cp++)
|
| 314 |
;
|
| 315 |
return(cp);
|
| 316 |
}
|
| 317 |
|
| 318 |
|
| 319 |
int
|
| 320 |
vscale(vc) /* return scale for variable vc */
|
| 321 |
int vc;
|
| 322 |
{
|
| 323 |
switch(vlet(vc)) {
|
| 324 |
case 'H':
|
| 325 |
return(HIGH);
|
| 326 |
case 'M':
|
| 327 |
return(MEDIUM);
|
| 328 |
case 'L':
|
| 329 |
return(LOW);
|
| 330 |
}
|
| 331 |
badvalue(vc);
|
| 332 |
}
|
| 333 |
|
| 334 |
|
| 335 |
checkvalues() /* check assignments */
|
| 336 |
{
|
| 337 |
register int i;
|
| 338 |
|
| 339 |
for (i = 0; i < NVARS; i++)
|
| 340 |
if (vv[i].fixval != NULL)
|
| 341 |
(*vv[i].fixval)(vv+i);
|
| 342 |
}
|
| 343 |
|
| 344 |
|
| 345 |
onevalue(vp) /* only one assignment for this variable */
|
| 346 |
register VARIABLE *vp;
|
| 347 |
{
|
| 348 |
if (vp->nass < 2)
|
| 349 |
return;
|
| 350 |
fprintf(stderr, "%s: warning - multiple assignment of variable '%s'\n",
|
| 351 |
progname, vp->name);
|
| 352 |
do
|
| 353 |
vp->value += strlen(vp->value)+1;
|
| 354 |
while (--vp->nass > 1);
|
| 355 |
}
|
| 356 |
|
| 357 |
|
| 358 |
catvalues(vp) /* concatenate variable values */
|
| 359 |
register VARIABLE *vp;
|
| 360 |
{
|
| 361 |
register char *cp;
|
| 362 |
|
| 363 |
if (vp->nass < 2)
|
| 364 |
return;
|
| 365 |
for (cp = vp->value; vp->nass > 1; vp->nass--) {
|
| 366 |
while (*cp)
|
| 367 |
cp++;
|
| 368 |
*cp++ = ' ';
|
| 369 |
}
|
| 370 |
}
|
| 371 |
|
| 372 |
|
| 373 |
long
|
| 374 |
checklast(fnames) /* check files and find most recent */
|
| 375 |
register char *fnames;
|
| 376 |
{
|
| 377 |
char thisfile[MAXPATH];
|
| 378 |
long thisdate, lastdate = -1;
|
| 379 |
register char *cp;
|
| 380 |
|
| 381 |
while (*fnames) {
|
| 382 |
while (isspace(*fnames)) fnames++;
|
| 383 |
cp = thisfile;
|
| 384 |
while (*fnames && !isspace(*fnames))
|
| 385 |
*cp++ = *fnames++;
|
| 386 |
*cp = '\0';
|
| 387 |
if ((thisdate = fdate(thisfile)) < 0)
|
| 388 |
syserr(thisfile);
|
| 389 |
if (thisdate > lastdate)
|
| 390 |
lastdate = thisdate;
|
| 391 |
}
|
| 392 |
return(lastdate);
|
| 393 |
}
|
| 394 |
|
| 395 |
|
| 396 |
checkfiles() /* check for existence and modified times */
|
| 397 |
{
|
| 398 |
char *cp;
|
| 399 |
long objdate;
|
| 400 |
|
| 401 |
if (!vdef(OCTREE)) {
|
| 402 |
if ((cp = bmalloc(strlen(radname)+5)) == NULL)
|
| 403 |
syserr(progname);
|
| 404 |
sprintf(cp, "%s.oct", radname);
|
| 405 |
vval(OCTREE) = cp;
|
| 406 |
vdef(OCTREE)++;
|
| 407 |
}
|
| 408 |
octreedate = fdate(vval(OCTREE));
|
| 409 |
scenedate = -1;
|
| 410 |
if (vdef(SCENE)) {
|
| 411 |
scenedate = checklast(vval(SCENE));
|
| 412 |
if (vdef(OBJECT)) {
|
| 413 |
objdate = checklast(vval(OBJECT));
|
| 414 |
if (objdate > scenedate)
|
| 415 |
scenedate = objdate;
|
| 416 |
}
|
| 417 |
}
|
| 418 |
if (octreedate < 0 & scenedate < 0) {
|
| 419 |
fprintf(stderr, "%s: need '%s' or '%s'\n", progname,
|
| 420 |
vnam(OCTREE), vnam(SCENE));
|
| 421 |
exit(1);
|
| 422 |
}
|
| 423 |
}
|
| 424 |
|
| 425 |
|
| 426 |
getoctcube(org, sizp) /* get octree bounding cube */
|
| 427 |
double org[3], *sizp;
|
| 428 |
{
|
| 429 |
extern FILE *popen();
|
| 430 |
static double oorg[3], osiz = 0.;
|
| 431 |
char buf[MAXPATH+16];
|
| 432 |
FILE *fp;
|
| 433 |
|
| 434 |
if (osiz <= FTINY) {
|
| 435 |
oconv(); /* does nothing if done already */
|
| 436 |
sprintf(buf, "getinfo -d < %s", vval(OCTREE));
|
| 437 |
if ((fp = popen(buf, "r")) == NULL)
|
| 438 |
syserr("getinfo");
|
| 439 |
if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1],
|
| 440 |
&oorg[2], &osiz) != 4) {
|
| 441 |
fprintf(stderr,
|
| 442 |
"%s: error reading bounding cube from getinfo\n",
|
| 443 |
progname);
|
| 444 |
exit(1);
|
| 445 |
}
|
| 446 |
pclose(fp);
|
| 447 |
}
|
| 448 |
org[0] = oorg[0]; org[1] = oorg[1]; org[2] = oorg[2]; *sizp = osiz;
|
| 449 |
}
|
| 450 |
|
| 451 |
|
| 452 |
setdefaults() /* set default values for unassigned var's */
|
| 453 |
{
|
| 454 |
double org[3], size;
|
| 455 |
char buf[128];
|
| 456 |
|
| 457 |
if (!vdef(ZONE)) {
|
| 458 |
getoctcube(org, &size);
|
| 459 |
sprintf(buf, "E %g %g %g %g %g %g", org[0], org[0]+size,
|
| 460 |
org[1], org[1]+size, org[2], org[2]+size);
|
| 461 |
vval(ZONE) = savqstr(buf);
|
| 462 |
vdef(ZONE)++;
|
| 463 |
}
|
| 464 |
if (!vdef(INDIRECT)) {
|
| 465 |
vval(INDIRECT) = "0";
|
| 466 |
vdef(INDIRECT)++;
|
| 467 |
}
|
| 468 |
if (!vdef(QUALITY)) {
|
| 469 |
vval(QUALITY) = "L";
|
| 470 |
vdef(QUALITY)++;
|
| 471 |
}
|
| 472 |
if (!vdef(RESOLUTION)) {
|
| 473 |
vval(RESOLUTION) = "512";
|
| 474 |
vdef(RESOLUTION)++;
|
| 475 |
}
|
| 476 |
if (!vdef(PICTURE)) {
|
| 477 |
vval(PICTURE) = radname;
|
| 478 |
vdef(PICTURE)++;
|
| 479 |
}
|
| 480 |
if (!vdef(VIEW)) {
|
| 481 |
vval(VIEW) = "X";
|
| 482 |
vdef(VIEW)++;
|
| 483 |
}
|
| 484 |
if (!vdef(DETAIL)) {
|
| 485 |
vval(DETAIL) = "M";
|
| 486 |
vdef(DETAIL)++;
|
| 487 |
}
|
| 488 |
if (!vdef(PENUMBRAS)) {
|
| 489 |
vval(PENUMBRAS) = "F";
|
| 490 |
vdef(PENUMBRAS)++;
|
| 491 |
}
|
| 492 |
if (!vdef(VARIABILITY)) {
|
| 493 |
vval(VARIABILITY) = "L";
|
| 494 |
vdef(VARIABILITY)++;
|
| 495 |
}
|
| 496 |
}
|
| 497 |
|
| 498 |
|
| 499 |
printvals() /* print variable values */
|
| 500 |
{
|
| 501 |
register int i, j;
|
| 502 |
|
| 503 |
for (i = 0; i < NVARS; i++)
|
| 504 |
for (j = 0; j < vdef(i); j++)
|
| 505 |
printf("%s= %s\n", vnam(i), nvalue(vv+i, j));
|
| 506 |
fflush(stdout);
|
| 507 |
}
|
| 508 |
|
| 509 |
|
| 510 |
oconv() /* run oconv if necessary */
|
| 511 |
{
|
| 512 |
char combuf[512], ocopts[64];
|
| 513 |
|
| 514 |
if (octreedate >= scenedate) /* check dates */
|
| 515 |
return;
|
| 516 |
/* build command */
|
| 517 |
oconvopts(ocopts);
|
| 518 |
if (vdef(MATERIAL))
|
| 519 |
sprintf(combuf, "oconv%s %s %s > %s", ocopts,
|
| 520 |
vval(MATERIAL), vval(SCENE), vval(OCTREE));
|
| 521 |
else
|
| 522 |
sprintf(combuf, "oconv%s %s > %s", ocopts,
|
| 523 |
vval(SCENE), vval(OCTREE));
|
| 524 |
|
| 525 |
if (runcom(combuf)) { /* run it */
|
| 526 |
fprintf(stderr, "%s: error generating octree\n\t%s removed\n",
|
| 527 |
progname, vval(OCTREE));
|
| 528 |
unlink(vval(OCTREE));
|
| 529 |
exit(1);
|
| 530 |
}
|
| 531 |
octreedate = time(0);
|
| 532 |
}
|
| 533 |
|
| 534 |
|
| 535 |
char *
|
| 536 |
addarg(op, arg) /* add argument and advance pointer */
|
| 537 |
register char *op, *arg;
|
| 538 |
{
|
| 539 |
*op = ' ';
|
| 540 |
while (*++op = *arg++)
|
| 541 |
;
|
| 542 |
return(op);
|
| 543 |
}
|
| 544 |
|
| 545 |
|
| 546 |
oconvopts(oo) /* get oconv options */
|
| 547 |
register char *oo;
|
| 548 |
{
|
| 549 |
/* BEWARE: This may be called via setdefaults(), so no assumptions */
|
| 550 |
|
| 551 |
*oo = '\0';
|
| 552 |
if (vdef(OCONV))
|
| 553 |
addarg(oo, vval(OCONV));
|
| 554 |
}
|
| 555 |
|
| 556 |
|
| 557 |
double
|
| 558 |
ambval() /* compute ambient value */
|
| 559 |
{
|
| 560 |
if (vdef(EXPOSURE)) {
|
| 561 |
if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-')
|
| 562 |
return(.5/pow(2.,atof(vval(EXPOSURE))));
|
| 563 |
if (isdigit(vval(EXPOSURE)[0]) || vval(EXPOSURE)[0] == '.')
|
| 564 |
return(.5/atof(vval(EXPOSURE)));
|
| 565 |
badvalue(EXPOSURE);
|
| 566 |
}
|
| 567 |
if (vlet(ZONE) == 'E')
|
| 568 |
return(10.);
|
| 569 |
if (vlet(ZONE) == 'I')
|
| 570 |
return(.01);
|
| 571 |
badvalue(ZONE);
|
| 572 |
}
|
| 573 |
|
| 574 |
|
| 575 |
lowqopts(op) /* low quality rendering options */
|
| 576 |
register char *op;
|
| 577 |
{
|
| 578 |
double d, org[3], siz[3];
|
| 579 |
|
| 580 |
*op = '\0';
|
| 581 |
if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0],
|
| 582 |
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
|
| 583 |
badvalue(ZONE);
|
| 584 |
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
|
| 585 |
getoctcube(org, &d);
|
| 586 |
d *= 3./(siz[0]+siz[1]+siz[2]);
|
| 587 |
switch (vscale(DETAIL)) {
|
| 588 |
case LOW:
|
| 589 |
op = addarg(op, "-ps 16 -dp 16");
|
| 590 |
sprintf(op, " -ar %d", (int)(4*d));
|
| 591 |
op += strlen(op);
|
| 592 |
break;
|
| 593 |
case MEDIUM:
|
| 594 |
op = addarg(op, "-ps 8 -dp 32");
|
| 595 |
sprintf(op, " -ar %d", (int)(8*d));
|
| 596 |
op += strlen(op);
|
| 597 |
break;
|
| 598 |
case HIGH:
|
| 599 |
op = addarg(op, "-ps 4 -dp 64");
|
| 600 |
sprintf(op, " -ar %d", (int)(16*d));
|
| 601 |
op += strlen(op);
|
| 602 |
break;
|
| 603 |
}
|
| 604 |
op = addarg(op, "-pt .16");
|
| 605 |
if (vbool(PENUMBRAS))
|
| 606 |
op = addarg(op, "-ds .4");
|
| 607 |
else
|
| 608 |
op = addarg(op, "-ds 0");
|
| 609 |
op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .7");
|
| 610 |
if (vdef(AMBFILE)) {
|
| 611 |
sprintf(op, " -af %s", vval(AMBFILE));
|
| 612 |
op += strlen(op);
|
| 613 |
} else
|
| 614 |
overture = 0;
|
| 615 |
switch (vscale(VARIABILITY)) {
|
| 616 |
case LOW:
|
| 617 |
op = addarg(op, "-aa .4 -ad 32");
|
| 618 |
break;
|
| 619 |
case MEDIUM:
|
| 620 |
op = addarg(op, "-aa .3 -ad 64");
|
| 621 |
break;
|
| 622 |
case HIGH:
|
| 623 |
op = addarg(op, "-aa .25 -ad 128");
|
| 624 |
break;
|
| 625 |
}
|
| 626 |
op = addarg(op, "-as 0");
|
| 627 |
d = ambval();
|
| 628 |
sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
|
| 629 |
op += strlen(op);
|
| 630 |
op = addarg(op, "-lr 3 -lw .02");
|
| 631 |
if (vdef(RENDER))
|
| 632 |
op = addarg(op, vval(RENDER));
|
| 633 |
}
|
| 634 |
|
| 635 |
|
| 636 |
medqopts(op) /* medium quality rendering options */
|
| 637 |
register char *op;
|
| 638 |
{
|
| 639 |
double d, org[3], siz[3];
|
| 640 |
|
| 641 |
*op = '\0';
|
| 642 |
if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0],
|
| 643 |
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
|
| 644 |
badvalue(ZONE);
|
| 645 |
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
|
| 646 |
getoctcube(org, &d);
|
| 647 |
d *= 3./(siz[0]+siz[1]+siz[2]);
|
| 648 |
switch (vscale(DETAIL)) {
|
| 649 |
case LOW:
|
| 650 |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8");
|
| 651 |
op = addarg(op, "-dp 64");
|
| 652 |
sprintf(op, " -ar %d", (int)(8*d));
|
| 653 |
op += strlen(op);
|
| 654 |
break;
|
| 655 |
case MEDIUM:
|
| 656 |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6");
|
| 657 |
op = addarg(op, "-dp 128");
|
| 658 |
sprintf(op, " -ar %d", (int)(16*d));
|
| 659 |
op += strlen(op);
|
| 660 |
break;
|
| 661 |
case HIGH:
|
| 662 |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4");
|
| 663 |
op = addarg(op, "-dp 256");
|
| 664 |
sprintf(op, " -ar %d", (int)(32*d));
|
| 665 |
op += strlen(op);
|
| 666 |
break;
|
| 667 |
}
|
| 668 |
op = addarg(op, "-pt .08");
|
| 669 |
if (vbool(PENUMBRAS))
|
| 670 |
op = addarg(op, "-ds .2 -dj .35");
|
| 671 |
else
|
| 672 |
op = addarg(op, "-ds .3");
|
| 673 |
op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .15");
|
| 674 |
if (overture = vint(INDIRECT)) {
|
| 675 |
sprintf(op, " -ab %d", overture);
|
| 676 |
op += strlen(op);
|
| 677 |
}
|
| 678 |
if (vdef(AMBFILE)) {
|
| 679 |
sprintf(op, " -af %s", vval(AMBFILE));
|
| 680 |
op += strlen(op);
|
| 681 |
} else
|
| 682 |
overture = 0;
|
| 683 |
switch (vscale(VARIABILITY)) {
|
| 684 |
case LOW:
|
| 685 |
op = addarg(op, "-aa .25 -ad 128 -as 0");
|
| 686 |
break;
|
| 687 |
case MEDIUM:
|
| 688 |
op = addarg(op, "-aa .2 -ad 300 -as 64");
|
| 689 |
break;
|
| 690 |
case HIGH:
|
| 691 |
op = addarg(op, "-aa .15 -ad 500 -as 128");
|
| 692 |
break;
|
| 693 |
}
|
| 694 |
d = ambval();
|
| 695 |
sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
|
| 696 |
op += strlen(op);
|
| 697 |
op = addarg(op, "-lr 6 -lw .002");
|
| 698 |
if (vdef(RENDER))
|
| 699 |
op = addarg(op, vval(RENDER));
|
| 700 |
}
|
| 701 |
|
| 702 |
|
| 703 |
hiqopts(op) /* high quality rendering options */
|
| 704 |
register char *op;
|
| 705 |
{
|
| 706 |
double d, org[3], siz[3];
|
| 707 |
|
| 708 |
*op = '\0';
|
| 709 |
if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0],
|
| 710 |
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
|
| 711 |
badvalue(ZONE);
|
| 712 |
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
|
| 713 |
getoctcube(org, &d);
|
| 714 |
d *= 3./(siz[0]+siz[1]+siz[2]);
|
| 715 |
switch (vscale(DETAIL)) {
|
| 716 |
case LOW:
|
| 717 |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8");
|
| 718 |
op = addarg(op, "-dp 256");
|
| 719 |
sprintf(op, " -ar %d", (int)(16*d));
|
| 720 |
op += strlen(op);
|
| 721 |
break;
|
| 722 |
case MEDIUM:
|
| 723 |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5");
|
| 724 |
op = addarg(op, "-dp 512");
|
| 725 |
sprintf(op, " -ar %d", (int)(32*d));
|
| 726 |
op += strlen(op);
|
| 727 |
break;
|
| 728 |
case HIGH:
|
| 729 |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3");
|
| 730 |
op = addarg(op, "-dp 1024");
|
| 731 |
sprintf(op, " -ar %d", (int)(64*d));
|
| 732 |
op += strlen(op);
|
| 733 |
break;
|
| 734 |
}
|
| 735 |
op = addarg(op, "-pt .04");
|
| 736 |
if (vbool(PENUMBRAS))
|
| 737 |
op = addarg(op, "-ds .1 -dj .7");
|
| 738 |
else
|
| 739 |
op = addarg(op, "-ds .2");
|
| 740 |
op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .03");
|
| 741 |
sprintf(op, " -ab %d", overture=vint(INDIRECT)+1);
|
| 742 |
op += strlen(op);
|
| 743 |
if (vdef(AMBFILE)) {
|
| 744 |
sprintf(op, " -af %s", vval(AMBFILE));
|
| 745 |
op += strlen(op);
|
| 746 |
} else
|
| 747 |
overture = 0;
|
| 748 |
switch (vscale(VARIABILITY)) {
|
| 749 |
case LOW:
|
| 750 |
op = addarg(op, "-aa .15 -ad 200 -as 0");
|
| 751 |
break;
|
| 752 |
case MEDIUM:
|
| 753 |
op = addarg(op, "-aa .125 -ad 512 -as 128");
|
| 754 |
break;
|
| 755 |
case HIGH:
|
| 756 |
op = addarg(op, "-aa .08 -ad 850 -as 256");
|
| 757 |
break;
|
| 758 |
}
|
| 759 |
d = ambval();
|
| 760 |
sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
|
| 761 |
op += strlen(op);
|
| 762 |
op = addarg(op, "-lr 12 -lw .0005");
|
| 763 |
if (vdef(RENDER))
|
| 764 |
op = addarg(op, vval(RENDER));
|
| 765 |
}
|
| 766 |
|
| 767 |
|
| 768 |
xferopts(ro) /* transfer options if indicated */
|
| 769 |
char *ro;
|
| 770 |
{
|
| 771 |
int fd, n;
|
| 772 |
|
| 773 |
n = strlen(ro);
|
| 774 |
if (n < 2)
|
| 775 |
return;
|
| 776 |
if (vdef(OPTFILE)) {
|
| 777 |
if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1)
|
| 778 |
syserr(vval(OPTFILE));
|
| 779 |
if (write(fd, ro+1, n-1) != n-1)
|
| 780 |
syserr(vval(OPTFILE));
|
| 781 |
write(fd, "\n", 1);
|
| 782 |
close(fd);
|
| 783 |
sprintf(ro, " \"^%s\"", vval(OPTFILE));
|
| 784 |
}
|
| 785 |
#ifdef MSDOS
|
| 786 |
else if (n > 50) {
|
| 787 |
register char *evp = bmalloc(n+6);
|
| 788 |
if (evp == NULL)
|
| 789 |
syserr(progname);
|
| 790 |
strcpy(evp, "ROPT=");
|
| 791 |
strcat(evp, ro);
|
| 792 |
if (putenv(evp) != 0) {
|
| 793 |
fprintf(stderr, "%s: out of environment space\n",
|
| 794 |
progname);
|
| 795 |
exit(1);
|
| 796 |
}
|
| 797 |
strcpy(ro, " $ROPT");
|
| 798 |
}
|
| 799 |
#endif
|
| 800 |
}
|
| 801 |
|
| 802 |
|
| 803 |
pfiltopts(po) /* get pfilt options */
|
| 804 |
register char *po;
|
| 805 |
{
|
| 806 |
*po = '\0';
|
| 807 |
if (vdef(EXPOSURE)) {
|
| 808 |
po = addarg(po, "-1 -e");
|
| 809 |
po = addarg(po, vval(EXPOSURE));
|
| 810 |
}
|
| 811 |
if (vscale(QUALITY) == HIGH)
|
| 812 |
po = addarg(po, "-r .65");
|
| 813 |
if (vdef(PFILT))
|
| 814 |
po = addarg(po, vval(PFILT));
|
| 815 |
}
|
| 816 |
|
| 817 |
|
| 818 |
matchword(s1, s2) /* match white-delimited words */
|
| 819 |
register char *s1, *s2;
|
| 820 |
{
|
| 821 |
while (isspace(*s1)) s1++;
|
| 822 |
while (isspace(*s2)) s2++;
|
| 823 |
while (*s1 && !isspace(*s1))
|
| 824 |
if (*s1++ != *s2++)
|
| 825 |
return(0);
|
| 826 |
return(!*s2 || isspace(*s2));
|
| 827 |
}
|
| 828 |
|
| 829 |
|
| 830 |
char *
|
| 831 |
specview(vs) /* get proper view spec from vs */
|
| 832 |
register char *vs;
|
| 833 |
{
|
| 834 |
static char vup[7][12] = {"-vu 0 0 -1","-vu 0 -1 0","-vu -1 0 0",
|
| 835 |
"-vu 0 0 1", "-vu 1 0 0","-vu 0 1 0","-vu 0 0 1"};
|
| 836 |
static char viewopts[128];
|
| 837 |
register char *cp;
|
| 838 |
int xpos, ypos, zpos, viewtype, upax;
|
| 839 |
register int i;
|
| 840 |
double cent[3], dim[3], mult, d;
|
| 841 |
|
| 842 |
if (vs == NULL || *vs == '-')
|
| 843 |
return(vs);
|
| 844 |
upax = 0; /* get the up vector */
|
| 845 |
if (vdef(UP)) {
|
| 846 |
if (vval(UP)[0] == '-' || vval(UP)[0] == '+')
|
| 847 |
upax = 1-'X'+UPPER(vval(UP)[1]);
|
| 848 |
else
|
| 849 |
upax = 1-'X'+vlet(UP);
|
| 850 |
if (upax < 1 | upax > 3)
|
| 851 |
badvalue(UP);
|
| 852 |
if (vval(UP)[0] == '-')
|
| 853 |
upax = -upax;
|
| 854 |
}
|
| 855 |
/* check standard view names */
|
| 856 |
xpos = ypos = zpos = 0;
|
| 857 |
if (*vs == 'X') {
|
| 858 |
xpos = 1; vs++;
|
| 859 |
} else if (*vs == 'x') {
|
| 860 |
xpos = -1; vs++;
|
| 861 |
}
|
| 862 |
if (*vs == 'Y') {
|
| 863 |
ypos = 1; vs++;
|
| 864 |
} else if (*vs == 'y') {
|
| 865 |
ypos = -1; vs++;
|
| 866 |
}
|
| 867 |
if (*vs == 'Z') {
|
| 868 |
zpos = 1; vs++;
|
| 869 |
} else if (*vs == 'z') {
|
| 870 |
zpos = -1; vs++;
|
| 871 |
}
|
| 872 |
viewtype = 'v';
|
| 873 |
if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h')
|
| 874 |
viewtype = *vs++;
|
| 875 |
cp = viewopts;
|
| 876 |
if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) { /* got one! */
|
| 877 |
*cp++ = '-'; *cp++ = 'v'; *cp++ = 't'; *cp++ = viewtype;
|
| 878 |
if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf",
|
| 879 |
¢[0], &dim[0], ¢[1], &dim[1],
|
| 880 |
¢[2], &dim[2]) != 6)
|
| 881 |
badvalue(ZONE);
|
| 882 |
for (i = 0; i < 3; i++) {
|
| 883 |
dim[i] -= cent[i];
|
| 884 |
cent[i] += .5*dim[i];
|
| 885 |
}
|
| 886 |
mult = vlet(ZONE)=='E' ? 2. : .45 ;
|
| 887 |
sprintf(cp, " -vp %.2g %.2g %.2g -vd %.2g %.2g %.2g",
|
| 888 |
cent[0]+xpos*mult*dim[0],
|
| 889 |
cent[1]+ypos*mult*dim[1],
|
| 890 |
cent[2]+zpos*mult*dim[2],
|
| 891 |
-xpos*dim[0], -ypos*dim[1], -zpos*dim[2]);
|
| 892 |
cp += strlen(cp);
|
| 893 |
/* redirect up axis if necessary */
|
| 894 |
switch (upax) {
|
| 895 |
case 3: /* plus or minus Z axis */
|
| 896 |
case -3:
|
| 897 |
case 0:
|
| 898 |
if (!(xpos|ypos))
|
| 899 |
upax = 2;
|
| 900 |
break;
|
| 901 |
case 2: /* plus or minus Y axis */
|
| 902 |
case -2:
|
| 903 |
if (!(xpos|zpos))
|
| 904 |
upax = 1;
|
| 905 |
break;
|
| 906 |
case 1: /* plus or minus X axis */
|
| 907 |
case -1:
|
| 908 |
if (!(ypos|zpos))
|
| 909 |
upax = 3;
|
| 910 |
break;
|
| 911 |
}
|
| 912 |
cp = addarg(cp, vup[upax+3]);
|
| 913 |
switch (viewtype) {
|
| 914 |
case 'v':
|
| 915 |
cp = addarg(cp, "-vh 45 -vv 45");
|
| 916 |
break;
|
| 917 |
case 'l':
|
| 918 |
d = sqrt(dim[0]*dim[0]+dim[1]*dim[1]+dim[2]*dim[2]);
|
| 919 |
sprintf(cp, " -vh %.2g -vv %.2g", d, d);
|
| 920 |
cp += strlen(cp);
|
| 921 |
break;
|
| 922 |
case 'a':
|
| 923 |
case 'h':
|
| 924 |
cp = addarg(cp, "-vh 180 -vv 180");
|
| 925 |
break;
|
| 926 |
}
|
| 927 |
} else {
|
| 928 |
while (!isspace(*vs)) /* else skip id */
|
| 929 |
if (!*vs++)
|
| 930 |
return(NULL);
|
| 931 |
if (upax) { /* specify up vector */
|
| 932 |
strcpy(cp, vup[upax+3]);
|
| 933 |
cp += strlen(cp);
|
| 934 |
}
|
| 935 |
}
|
| 936 |
/* append any additional options */
|
| 937 |
strcpy(cp, vs);
|
| 938 |
return(viewopts);
|
| 939 |
}
|
| 940 |
|
| 941 |
|
| 942 |
char *
|
| 943 |
getview(n, vn) /* get view n, or NULL if none */
|
| 944 |
int n;
|
| 945 |
char *vn;
|
| 946 |
{
|
| 947 |
register char *mv;
|
| 948 |
|
| 949 |
if (viewselect != NULL) {
|
| 950 |
if (n) /* only do one */
|
| 951 |
return(NULL);
|
| 952 |
if (viewselect[0] == '-') { /* already specified */
|
| 953 |
if (vn != NULL) *vn = '\0';
|
| 954 |
return(viewselect);
|
| 955 |
}
|
| 956 |
if (vn != NULL) {
|
| 957 |
for (mv = viewselect; *mv && !isspace(*mv);
|
| 958 |
*vn++ = *mv++)
|
| 959 |
;
|
| 960 |
*vn = '\0';
|
| 961 |
}
|
| 962 |
/* check list */
|
| 963 |
while ((mv = nvalue(vv+VIEW, n++)) != NULL)
|
| 964 |
if (matchword(viewselect, mv))
|
| 965 |
return(specview(mv));
|
| 966 |
return(specview(viewselect)); /* standard view? */
|
| 967 |
}
|
| 968 |
if (vn != NULL && (mv = nvalue(vv+VIEW, n)) != NULL) {
|
| 969 |
if (*mv != '-')
|
| 970 |
while (*mv && !isspace(*mv))
|
| 971 |
*vn++ = *mv++;
|
| 972 |
*vn = '\0';
|
| 973 |
}
|
| 974 |
return(specview(nvalue(vv+VIEW, n))); /* use view n */
|
| 975 |
}
|
| 976 |
|
| 977 |
|
| 978 |
rview(opts) /* run rview with first view */
|
| 979 |
char *opts;
|
| 980 |
{
|
| 981 |
char combuf[512];
|
| 982 |
/* build command */
|
| 983 |
sprintf(combuf, "rview %s%s ", getview(0, NULL), opts);
|
| 984 |
if (rvdevice != NULL)
|
| 985 |
sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
|
| 986 |
strcat(combuf, vval(OCTREE));
|
| 987 |
if (runcom(combuf)) { /* run it */
|
| 988 |
fprintf(stderr, "%s: error running rview\n", progname);
|
| 989 |
exit(1);
|
| 990 |
}
|
| 991 |
}
|
| 992 |
|
| 993 |
|
| 994 |
rpict(opts) /* run rpict and pfilt for each view */
|
| 995 |
char *opts;
|
| 996 |
{
|
| 997 |
char combuf[1024];
|
| 998 |
char rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH+16], res[32];
|
| 999 |
char pfopts[128];
|
| 1000 |
char vs[32], *vw;
|
| 1001 |
int vn, mult;
|
| 1002 |
/* get pfilt options */
|
| 1003 |
pfiltopts(pfopts);
|
| 1004 |
/* get resolution, reporting */
|
| 1005 |
mult = vscale(QUALITY)+1;
|
| 1006 |
{
|
| 1007 |
int xres, yres;
|
| 1008 |
double aspect;
|
| 1009 |
int n;
|
| 1010 |
n = sscanf(vval(RESOLUTION), "%d %d %lf", &xres, &yres, &aspect);
|
| 1011 |
if (n == 3)
|
| 1012 |
sprintf(res, "-x %d -y %d -pa %.3f",
|
| 1013 |
mult*xres, mult*yres, aspect);
|
| 1014 |
else if (n) {
|
| 1015 |
if (n == 1) yres = xres;
|
| 1016 |
sprintf(res, "-x %d -y %d", mult*xres, mult*yres);
|
| 1017 |
} else
|
| 1018 |
badvalue(RESOLUTION);
|
| 1019 |
}
|
| 1020 |
rep[0] = '\0';
|
| 1021 |
if (vdef(REPORT)) {
|
| 1022 |
double minutes;
|
| 1023 |
int n;
|
| 1024 |
n = sscanf(vval(REPORT), "%lf %s", &minutes, rawfile);
|
| 1025 |
if (n == 2)
|
| 1026 |
sprintf(rep, " -t %d -e %s", (int)(minutes*60), rawfile);
|
| 1027 |
else if (n == 1)
|
| 1028 |
sprintf(rep, " -t %d", (int)(minutes*60));
|
| 1029 |
else
|
| 1030 |
badvalue(REPORT);
|
| 1031 |
}
|
| 1032 |
/* check date on ambient file */
|
| 1033 |
if (vdef(AMBFILE)) {
|
| 1034 |
long afdate = fdate(vval(AMBFILE));
|
| 1035 |
if (afdate >= 0 & octreedate > afdate)
|
| 1036 |
rmfile(vval(AMBFILE));
|
| 1037 |
}
|
| 1038 |
/* do each view */
|
| 1039 |
vn = 0;
|
| 1040 |
while ((vw = getview(vn++, vs)) != NULL) {
|
| 1041 |
if (!vs[0])
|
| 1042 |
sprintf(vs, "%d", vn);
|
| 1043 |
sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
|
| 1044 |
/* check date on picture */
|
| 1045 |
if (fdate(picfile) > octreedate)
|
| 1046 |
continue;
|
| 1047 |
/* build rpict command */
|
| 1048 |
sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
|
| 1049 |
if (fdate(rawfile) > octreedate) /* recover */
|
| 1050 |
sprintf(combuf, "rpict%s%s -ro %s %s",
|
| 1051 |
rep, opts, rawfile, vval(OCTREE));
|
| 1052 |
else {
|
| 1053 |
if (overture) { /* run overture calculation */
|
| 1054 |
sprintf(combuf,
|
| 1055 |
"rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
|
| 1056 |
rep, vw, opts,
|
| 1057 |
vval(OCTREE), overfile);
|
| 1058 |
if (runcom(combuf)) {
|
| 1059 |
fprintf(stderr,
|
| 1060 |
"%s: error in overture for view %s\n",
|
| 1061 |
progname, vs);
|
| 1062 |
exit(1);
|
| 1063 |
}
|
| 1064 |
#ifdef NIX
|
| 1065 |
rmfile(overfile);
|
| 1066 |
#endif
|
| 1067 |
}
|
| 1068 |
sprintf(combuf, "rpict%s %s %s%s %s > %s",
|
| 1069 |
rep, vw, res, opts,
|
| 1070 |
vval(OCTREE), rawfile);
|
| 1071 |
}
|
| 1072 |
if (runcom(combuf)) { /* run rpict */
|
| 1073 |
fprintf(stderr, "%s: error rendering view %s\n",
|
| 1074 |
progname, vs);
|
| 1075 |
exit(1);
|
| 1076 |
}
|
| 1077 |
/* build pfilt command */
|
| 1078 |
if (mult > 1)
|
| 1079 |
sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
|
| 1080 |
pfopts, mult, mult, rawfile, picfile);
|
| 1081 |
else
|
| 1082 |
sprintf(combuf, "pfilt%s %s > %s", pfopts,
|
| 1083 |
rawfile, picfile);
|
| 1084 |
if (runcom(combuf)) { /* run pfilt */
|
| 1085 |
fprintf(stderr,
|
| 1086 |
"%s: error filtering view %s\n\t%s removed\n",
|
| 1087 |
progname, vs, picfile);
|
| 1088 |
unlink(picfile);
|
| 1089 |
exit(1);
|
| 1090 |
}
|
| 1091 |
/* remove raw file */
|
| 1092 |
rmfile(rawfile);
|
| 1093 |
}
|
| 1094 |
}
|
| 1095 |
|
| 1096 |
|
| 1097 |
runcom(cs) /* run command */
|
| 1098 |
char *cs;
|
| 1099 |
{
|
| 1100 |
if (!silent) /* echo it */
|
| 1101 |
printf("\t%s\n", cs);
|
| 1102 |
if (noaction)
|
| 1103 |
return(0);
|
| 1104 |
fflush(stdout); /* flush output and pass to shell */
|
| 1105 |
return(system(cs));
|
| 1106 |
}
|
| 1107 |
|
| 1108 |
|
| 1109 |
rmfile(fn) /* remove a file */
|
| 1110 |
char *fn;
|
| 1111 |
{
|
| 1112 |
if (!silent)
|
| 1113 |
#ifdef MSDOS
|
| 1114 |
printf("\tdel %s\n", fn);
|
| 1115 |
#else
|
| 1116 |
printf("\trm -f %s\n", fn);
|
| 1117 |
#endif
|
| 1118 |
if (noaction)
|
| 1119 |
return(0);
|
| 1120 |
return(unlink(fn));
|
| 1121 |
}
|
| 1122 |
|
| 1123 |
|
| 1124 |
badvalue(vc) /* report bad variable value and exit */
|
| 1125 |
int vc;
|
| 1126 |
{
|
| 1127 |
fprintf(stderr, "%s: bad value for variable '%s'\n",
|
| 1128 |
progname, vnam(vc));
|
| 1129 |
exit(1);
|
| 1130 |
}
|
| 1131 |
|
| 1132 |
|
| 1133 |
syserr(s) /* report a system error and exit */
|
| 1134 |
char *s;
|
| 1135 |
{
|
| 1136 |
perror(s);
|
| 1137 |
exit(1);
|
| 1138 |
}
|