| 1 |
< |
/* Copyright (c) 1993 Regents of the University of California */ |
| 1 |
> |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
| 4 |
> |
static char SCCSid[] = "$SunId$ SGI"; |
| 5 |
|
#endif |
| 6 |
|
|
| 7 |
|
/* |
| 9 |
|
*/ |
| 10 |
|
|
| 11 |
|
#include "standard.h" |
| 12 |
+ |
#include "view.h" |
| 13 |
|
#include "paths.h" |
| 14 |
+ |
#include "vars.h" |
| 15 |
|
#include <ctype.h> |
| 16 |
+ |
#include <sys/types.h> |
| 17 |
|
|
| 18 |
< |
|
| 19 |
< |
typedef struct { |
| 20 |
< |
char *name; /* variable name */ |
| 21 |
< |
short nick; /* # characters required for nickname */ |
| 22 |
< |
short nass; /* # assignments made */ |
| 23 |
< |
char *value; /* assigned value(s) */ |
| 24 |
< |
int (*fixval)(); /* assignment checking function */ |
| 25 |
< |
} VARIABLE; |
| 26 |
< |
|
| 27 |
< |
int onevalue(), catvalues(); |
| 28 |
< |
|
| 29 |
< |
/* variables */ |
| 30 |
< |
#define OBJECT 0 /* object files */ |
| 31 |
< |
#define SCENE 1 /* scene files */ |
| 32 |
< |
#define MATERIAL 2 /* material files */ |
| 33 |
< |
#define RENDER 3 /* rendering options */ |
| 34 |
< |
#define OCONV 4 /* oconv options */ |
| 35 |
< |
#define PFILT 5 /* pfilt options */ |
| 36 |
< |
#define VIEW 6 /* view(s) for picture(s) */ |
| 37 |
< |
#define ZONE 7 /* simulation zone */ |
| 38 |
< |
#define QUALITY 8 /* desired rendering quality */ |
| 39 |
< |
#define OCTREE 9 /* octree file name */ |
| 40 |
< |
#define PICTURE 10 /* picture file name */ |
| 41 |
< |
#define AMBFILE 11 /* ambient file name */ |
| 42 |
< |
#define OPTFILE 12 /* rendering options file */ |
| 43 |
< |
#define EXPOSURE 13 /* picture exposure setting */ |
| 44 |
< |
#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 */ |
| 18 |
> |
/* variables (alphabetical by name) */ |
| 19 |
> |
#define AMBFILE 0 /* ambient file name */ |
| 20 |
> |
#define DETAIL 1 /* level of scene detail */ |
| 21 |
> |
#define EXPOSURE 2 /* picture exposure setting */ |
| 22 |
> |
#define EYESEP 3 /* interocular distance */ |
| 23 |
> |
#define ILLUM 4 /* mkillum input files */ |
| 24 |
> |
#define INDIRECT 5 /* indirection in lighting */ |
| 25 |
> |
#define MATERIAL 6 /* material files */ |
| 26 |
> |
#define MKILLUM 7 /* mkillum options */ |
| 27 |
> |
#define OBJECT 8 /* object files */ |
| 28 |
> |
#define OCONV 9 /* oconv options */ |
| 29 |
> |
#define OCTREE 10 /* octree file name */ |
| 30 |
> |
#define OPTFILE 11 /* rendering options file */ |
| 31 |
> |
#define PENUMBRAS 12 /* shadow penumbras are desired */ |
| 32 |
> |
#define PFILT 13 /* pfilt options */ |
| 33 |
> |
#define PICTURE 14 /* picture file root name */ |
| 34 |
> |
#define QUALITY 15 /* desired rendering quality */ |
| 35 |
> |
#define RAWFILE 16 /* raw picture file root name */ |
| 36 |
> |
#define RENDER 17 /* rendering options */ |
| 37 |
> |
#define REPORT 18 /* report frequency and errfile */ |
| 38 |
> |
#define RESOLUTION 19 /* maximum picture resolution */ |
| 39 |
> |
#define SCENE 20 /* scene files */ |
| 40 |
> |
#define UP 21 /* view up (X, Y or Z) */ |
| 41 |
> |
#define VARIABILITY 22 /* level of light variability */ |
| 42 |
> |
#define VIEWS 23 /* view(s) for picture(s) */ |
| 43 |
> |
#define ZFILE 24 /* distance file root name */ |
| 44 |
> |
#define ZONE 25 /* simulation zone */ |
| 45 |
|
/* total number of variables */ |
| 46 |
< |
#define NVARS 21 |
| 46 |
> |
int NVARS = 26; |
| 47 |
|
|
| 48 |
< |
VARIABLE vv[NVARS] = { /* variable-value pairs */ |
| 49 |
< |
{"objects", 3, 0, NULL, catvalues}, |
| 50 |
< |
{"scene", 3, 0, NULL, catvalues}, |
| 48 |
> |
VARIABLE vv[] = { /* variable-value pairs */ |
| 49 |
> |
{"AMBFILE", 3, 0, NULL, onevalue}, |
| 50 |
> |
{"DETAIL", 3, 0, NULL, qualvalue}, |
| 51 |
> |
{"EXPOSURE", 3, 0, NULL, fltvalue}, |
| 52 |
> |
{"EYESEP", 3, 0, NULL, fltvalue}, |
| 53 |
> |
{"illum", 3, 0, NULL, catvalues}, |
| 54 |
> |
{"INDIRECT", 3, 0, NULL, intvalue}, |
| 55 |
|
{"materials", 3, 0, NULL, catvalues}, |
| 56 |
< |
{"render", 3, 0, NULL, catvalues}, |
| 56 |
> |
{"mkillum", 3, 0, NULL, catvalues}, |
| 57 |
> |
{"objects", 3, 0, NULL, catvalues}, |
| 58 |
|
{"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}, |
| 59 |
|
{"OCTREE", 3, 0, NULL, onevalue}, |
| 62 |
– |
{"PICTURE", 3, 0, NULL, onevalue}, |
| 63 |
– |
{"AMBFILE", 3, 0, NULL, onevalue}, |
| 60 |
|
{"OPTFILE", 3, 0, NULL, onevalue}, |
| 61 |
< |
{"EXPOSURE", 3, 0, NULL, onevalue}, |
| 61 |
> |
{"PENUMBRAS", 3, 0, NULL, boolvalue}, |
| 62 |
> |
{"pfilt", 2, 0, NULL, catvalues}, |
| 63 |
> |
{"PICTURE", 3, 0, NULL, onevalue}, |
| 64 |
> |
{"QUALITY", 3, 0, NULL, qualvalue}, |
| 65 |
> |
{"RAWFILE", 3, 0, NULL, onevalue}, |
| 66 |
> |
{"render", 3, 0, NULL, catvalues}, |
| 67 |
> |
{"REPORT", 3, 0, NULL, onevalue}, |
| 68 |
|
{"RESOLUTION", 3, 0, NULL, onevalue}, |
| 69 |
+ |
{"scene", 3, 0, NULL, catvalues}, |
| 70 |
|
{"UP", 2, 0, NULL, onevalue}, |
| 71 |
< |
{"INDIRECT", 3, 0, NULL, onevalue}, |
| 72 |
< |
{"DETAIL", 3, 0, NULL, onevalue}, |
| 73 |
< |
{"PENUMBRAS", 3, 0, NULL, onevalue}, |
| 74 |
< |
{"VARIABILITY", 3, 0, NULL, onevalue}, |
| 72 |
< |
{"REPORT", 3, 0, NULL, onevalue}, |
| 71 |
> |
{"VARIABILITY", 3, 0, NULL, qualvalue}, |
| 72 |
> |
{"view", 2, 0, NULL, NULL}, |
| 73 |
> |
{"ZFILE", 2, 0, NULL, onevalue}, |
| 74 |
> |
{"ZONE", 2, 0, NULL, onevalue}, |
| 75 |
|
}; |
| 76 |
|
|
| 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 |
– |
|
| 77 |
|
/* overture calculation file */ |
| 78 |
|
#ifdef NIX |
| 79 |
< |
char overfile[] = "overture.raw"; |
| 79 |
> |
char overfile[] = "overture.unf"; |
| 80 |
|
#else |
| 81 |
|
char overfile[] = "/dev/null"; |
| 82 |
|
#endif |
| 83 |
|
|
| 84 |
< |
extern long fdate(), time(); |
| 84 |
> |
extern time_t fdate(), time(); |
| 85 |
|
|
| 86 |
< |
long scenedate; /* date of latest scene or object file */ |
| 87 |
< |
long octreedate; /* date of octree */ |
| 86 |
> |
time_t scenedate; /* date of latest scene or object file */ |
| 87 |
> |
time_t octreedate; /* date of octree */ |
| 88 |
> |
time_t matdate; /* date of latest material file */ |
| 89 |
> |
time_t illumdate; /* date of last illum file */ |
| 90 |
|
|
| 91 |
+ |
char *oct0name; /* name of pre-mkillum octree */ |
| 92 |
+ |
time_t oct0date; /* date of pre-mkillum octree */ |
| 93 |
+ |
char *oct1name; /* name of post-mkillum octree */ |
| 94 |
+ |
time_t oct1date; /* date of post-mkillum octree (>= matdate) */ |
| 95 |
+ |
|
| 96 |
+ |
int nowarn = 0; /* no warnings */ |
| 97 |
|
int explicate = 0; /* explicate variables */ |
| 98 |
|
int silent = 0; /* do work silently */ |
| 99 |
+ |
int touchonly = 0; /* touch files only */ |
| 100 |
|
int noaction = 0; /* don't do anything */ |
| 101 |
+ |
int sayview = 0; /* print view out */ |
| 102 |
|
char *rvdevice = NULL; /* rview output device */ |
| 103 |
|
char *viewselect = NULL; /* specific view only */ |
| 104 |
|
|
| 105 |
|
int overture = 0; /* overture calculation needed */ |
| 106 |
|
|
| 107 |
|
char *progname; /* global argv[0] */ |
| 108 |
+ |
char *rifname; /* global rad input file name */ |
| 109 |
|
|
| 110 |
|
char radname[MAXPATH]; /* root Radiance file name */ |
| 111 |
|
|
| 115 |
|
char *argv[]; |
| 116 |
|
{ |
| 117 |
|
char ropts[512]; |
| 118 |
+ |
char popts[64]; |
| 119 |
|
int i; |
| 120 |
|
|
| 121 |
|
progname = argv[0]; |
| 128 |
|
case 'n': |
| 129 |
|
noaction++; |
| 130 |
|
break; |
| 131 |
+ |
case 't': |
| 132 |
+ |
touchonly++; |
| 133 |
+ |
break; |
| 134 |
|
case 'e': |
| 135 |
|
explicate++; |
| 136 |
|
break; |
| 137 |
|
case 'o': |
| 138 |
|
rvdevice = argv[++i]; |
| 139 |
|
break; |
| 140 |
+ |
case 'V': |
| 141 |
+ |
sayview++; |
| 142 |
+ |
break; |
| 143 |
|
case 'v': |
| 144 |
|
viewselect = argv[++i]; |
| 145 |
|
break; |
| 146 |
+ |
case 'w': |
| 147 |
+ |
nowarn++; |
| 148 |
+ |
break; |
| 149 |
|
default: |
| 150 |
|
goto userr; |
| 151 |
|
} |
| 152 |
|
if (i >= argc) |
| 153 |
|
goto userr; |
| 154 |
+ |
rifname = argv[i]; |
| 155 |
|
/* assign Radiance root file name */ |
| 156 |
< |
rootname(radname, argv[i]); |
| 156 |
> |
rootname(radname, rifname); |
| 157 |
|
/* load variable values */ |
| 158 |
< |
load(argv[i]); |
| 158 |
> |
loadvars(rifname); |
| 159 |
|
/* get any additional assignments */ |
| 160 |
|
for (i++; i < argc; i++) |
| 161 |
< |
setvariable(argv[i]); |
| 161 |
> |
if (setvariable(argv[i], matchvar) < 0) { |
| 162 |
> |
fprintf(stderr, "%s: unknown variable: %s\n", |
| 163 |
> |
progname, argv[i]); |
| 164 |
> |
quit(1); |
| 165 |
> |
} |
| 166 |
|
/* check assignments */ |
| 167 |
|
checkvalues(); |
| 168 |
|
/* check files and dates */ |
| 171 |
|
setdefaults(); |
| 172 |
|
/* print all values if requested */ |
| 173 |
|
if (explicate) |
| 174 |
< |
printvals(); |
| 175 |
< |
/* build octree */ |
| 174 |
> |
printvars(stdout); |
| 175 |
> |
/* build octree (and run mkillum) */ |
| 176 |
|
oconv(); |
| 177 |
|
/* check date on ambient file */ |
| 178 |
|
checkambfile(); |
| 179 |
|
/* run simulation */ |
| 180 |
< |
renderopts(ropts); |
| 180 |
> |
renderopts(ropts, popts); |
| 181 |
|
xferopts(ropts); |
| 182 |
|
if (rvdevice != NULL) |
| 183 |
< |
rview(ropts); |
| 183 |
> |
rview(ropts, popts); |
| 184 |
|
else |
| 185 |
< |
rpict(ropts); |
| 186 |
< |
exit(0); |
| 185 |
> |
rpict(ropts, popts); |
| 186 |
> |
quit(0); |
| 187 |
|
userr: |
| 188 |
|
fprintf(stderr, |
| 189 |
< |
"Usage: %s [-s][-n][-e][-v view][-o dev] rfile [VAR=value ..]\n", |
| 189 |
> |
"Usage: %s [-w][-s][-n][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n", |
| 190 |
|
progname); |
| 191 |
< |
exit(1); |
| 191 |
> |
quit(1); |
| 192 |
|
} |
| 193 |
|
|
| 194 |
|
|
| 207 |
|
} |
| 208 |
|
|
| 209 |
|
|
| 210 |
< |
load(rfname) /* load Radiance simulation file */ |
| 205 |
< |
char *rfname; |
| 206 |
< |
{ |
| 207 |
< |
FILE *fp; |
| 208 |
< |
char buf[512]; |
| 209 |
< |
register char *cp; |
| 210 |
< |
|
| 211 |
< |
if (rfname == NULL) |
| 212 |
< |
fp = stdin; |
| 213 |
< |
else if ((fp = fopen(rfname, "r")) == NULL) |
| 214 |
< |
syserr(rfname); |
| 215 |
< |
while (fgetline(buf, sizeof(buf), fp) != NULL) { |
| 216 |
< |
for (cp = buf; *cp; cp++) { |
| 217 |
< |
switch (*cp) { |
| 218 |
< |
case '\\': |
| 219 |
< |
case '\n': |
| 220 |
< |
*cp = ' '; |
| 221 |
< |
continue; |
| 222 |
< |
case '#': |
| 223 |
< |
*cp = '\0'; |
| 224 |
< |
break; |
| 225 |
< |
default: |
| 226 |
< |
continue; |
| 227 |
< |
} |
| 228 |
< |
break; |
| 229 |
< |
} |
| 230 |
< |
setvariable(buf); |
| 231 |
< |
} |
| 232 |
< |
fclose(fp); |
| 233 |
< |
} |
| 234 |
< |
|
| 235 |
< |
|
| 236 |
< |
setvariable(ass) /* assign variable according to string */ |
| 237 |
< |
register char *ass; |
| 238 |
< |
{ |
| 239 |
< |
char varname[32]; |
| 240 |
< |
register char *cp; |
| 241 |
< |
register VARIABLE *vp; |
| 242 |
< |
register int i; |
| 243 |
< |
int n; |
| 244 |
< |
|
| 245 |
< |
while (isspace(*ass)) /* skip leading space */ |
| 246 |
< |
ass++; |
| 247 |
< |
cp = varname; /* extract name */ |
| 248 |
< |
while (cp < varname+sizeof(varname)-1 |
| 249 |
< |
&& *ass && !isspace(*ass) && *ass != '=') |
| 250 |
< |
*cp++ = *ass++; |
| 251 |
< |
*cp = '\0'; |
| 252 |
< |
if (!varname[0]) |
| 253 |
< |
return; /* no variable name! */ |
| 254 |
< |
/* trim value */ |
| 255 |
< |
while (isspace(*ass) || *ass == '=') |
| 256 |
< |
ass++; |
| 257 |
< |
cp = ass + strlen(ass); |
| 258 |
< |
do |
| 259 |
< |
*cp-- = '\0'; |
| 260 |
< |
while (cp >= ass && isspace(*cp)); |
| 261 |
< |
n = cp - ass + 1; |
| 262 |
< |
if (!n) { |
| 263 |
< |
fprintf(stderr, "%s: warning - missing value for variable '%s'\n", |
| 264 |
< |
progname, varname); |
| 265 |
< |
return; |
| 266 |
< |
} |
| 267 |
< |
/* match variable from list */ |
| 268 |
< |
vp = matchvar(varname); |
| 269 |
< |
if (vp == NULL) { |
| 270 |
< |
fprintf(stderr, "%s: unknown variable '%s'\n", |
| 271 |
< |
progname, varname); |
| 272 |
< |
exit(1); |
| 273 |
< |
} |
| 274 |
< |
/* assign new value */ |
| 275 |
< |
if (i = vp->nass) { |
| 276 |
< |
cp = vp->value; |
| 277 |
< |
while (i--) |
| 278 |
< |
while (*cp++) |
| 279 |
< |
; |
| 280 |
< |
i = cp - vp->value; |
| 281 |
< |
vp->value = realloc(vp->value, i+n+1); |
| 282 |
< |
} else |
| 283 |
< |
vp->value = malloc(n+1); |
| 284 |
< |
if (vp->value == NULL) |
| 285 |
< |
syserr(progname); |
| 286 |
< |
strcpy(vp->value+i, ass); |
| 287 |
< |
vp->nass++; |
| 288 |
< |
} |
| 289 |
< |
|
| 290 |
< |
|
| 291 |
< |
VARIABLE * |
| 292 |
< |
matchvar(nam) /* match a variable by its name */ |
| 293 |
< |
char *nam; |
| 294 |
< |
{ |
| 295 |
< |
int n = strlen(nam); |
| 296 |
< |
register int i; |
| 297 |
< |
|
| 298 |
< |
for (i = 0; i < NVARS; i++) |
| 299 |
< |
if (n >= vv[i].nick && !strncmp(nam, vv[i].name, n)) |
| 300 |
< |
return(vv+i); |
| 301 |
< |
return(NULL); |
| 302 |
< |
} |
| 303 |
< |
|
| 304 |
< |
|
| 305 |
< |
char * |
| 306 |
< |
nvalue(vp, n) /* return nth variable value */ |
| 307 |
< |
VARIABLE *vp; |
| 308 |
< |
register int n; |
| 309 |
< |
{ |
| 310 |
< |
register char *cp; |
| 311 |
< |
|
| 312 |
< |
if (vp == NULL || n < 0 || n >= vp->nass) |
| 313 |
< |
return(NULL); |
| 314 |
< |
cp = vp->value; |
| 315 |
< |
while (n--) |
| 316 |
< |
while (*cp++) |
| 317 |
< |
; |
| 318 |
< |
return(cp); |
| 319 |
< |
} |
| 320 |
< |
|
| 321 |
< |
|
| 322 |
< |
int |
| 323 |
< |
vscale(vc) /* return scale for variable vc */ |
| 324 |
< |
int vc; |
| 325 |
< |
{ |
| 326 |
< |
switch(vlet(vc)) { |
| 327 |
< |
case 'H': |
| 328 |
< |
return(HIGH); |
| 329 |
< |
case 'M': |
| 330 |
< |
return(MEDIUM); |
| 331 |
< |
case 'L': |
| 332 |
< |
return(LOW); |
| 333 |
< |
} |
| 334 |
< |
badvalue(vc); |
| 335 |
< |
} |
| 336 |
< |
|
| 337 |
< |
|
| 338 |
< |
checkvalues() /* check assignments */ |
| 339 |
< |
{ |
| 340 |
< |
register int i; |
| 341 |
< |
|
| 342 |
< |
for (i = 0; i < NVARS; i++) |
| 343 |
< |
if (vv[i].fixval != NULL) |
| 344 |
< |
(*vv[i].fixval)(vv+i); |
| 345 |
< |
} |
| 346 |
< |
|
| 347 |
< |
|
| 348 |
< |
onevalue(vp) /* only one assignment for this variable */ |
| 349 |
< |
register VARIABLE *vp; |
| 350 |
< |
{ |
| 351 |
< |
if (vp->nass < 2) |
| 352 |
< |
return; |
| 353 |
< |
fprintf(stderr, "%s: warning - multiple assignment of variable '%s'\n", |
| 354 |
< |
progname, vp->name); |
| 355 |
< |
do |
| 356 |
< |
vp->value += strlen(vp->value)+1; |
| 357 |
< |
while (--vp->nass > 1); |
| 358 |
< |
} |
| 359 |
< |
|
| 360 |
< |
|
| 361 |
< |
catvalues(vp) /* concatenate variable values */ |
| 362 |
< |
register VARIABLE *vp; |
| 363 |
< |
{ |
| 364 |
< |
register char *cp; |
| 365 |
< |
|
| 366 |
< |
if (vp->nass < 2) |
| 367 |
< |
return; |
| 368 |
< |
for (cp = vp->value; vp->nass > 1; vp->nass--) { |
| 369 |
< |
while (*cp) |
| 370 |
< |
cp++; |
| 371 |
< |
*cp++ = ' '; |
| 372 |
< |
} |
| 373 |
< |
} |
| 374 |
< |
|
| 375 |
< |
|
| 376 |
< |
long |
| 210 |
> |
time_t |
| 211 |
|
checklast(fnames) /* check files and find most recent */ |
| 212 |
|
register char *fnames; |
| 213 |
|
{ |
| 214 |
|
char thisfile[MAXPATH]; |
| 215 |
< |
long thisdate, lastdate = -1; |
| 215 |
> |
time_t thisdate, lastdate = 0; |
| 216 |
|
register char *cp; |
| 217 |
|
|
| 218 |
+ |
if (fnames == NULL) |
| 219 |
+ |
return(0); |
| 220 |
|
while (*fnames) { |
| 221 |
|
while (isspace(*fnames)) fnames++; |
| 222 |
|
cp = thisfile; |
| 223 |
|
while (*fnames && !isspace(*fnames)) |
| 224 |
|
*cp++ = *fnames++; |
| 225 |
|
*cp = '\0'; |
| 226 |
< |
if ((thisdate = fdate(thisfile)) < 0) |
| 226 |
> |
if (!(thisdate = fdate(thisfile))) |
| 227 |
|
syserr(thisfile); |
| 228 |
|
if (thisdate > lastdate) |
| 229 |
|
lastdate = thisdate; |
| 232 |
|
} |
| 233 |
|
|
| 234 |
|
|
| 235 |
+ |
char * |
| 236 |
+ |
newfname(orig, pred) /* create modified file name */ |
| 237 |
+ |
char *orig; |
| 238 |
+ |
int pred; |
| 239 |
+ |
{ |
| 240 |
+ |
extern char *rindex(); |
| 241 |
+ |
register char *cp; |
| 242 |
+ |
register int n; |
| 243 |
+ |
int suffix; |
| 244 |
+ |
|
| 245 |
+ |
n = 0; cp = orig; suffix = -1; /* suffix position, length */ |
| 246 |
+ |
while (*cp) { |
| 247 |
+ |
if (*cp == '.') suffix = n; |
| 248 |
+ |
else if (ISDIRSEP(*cp)) suffix = -1; |
| 249 |
+ |
cp++; n++; |
| 250 |
+ |
} |
| 251 |
+ |
if (suffix == -1) suffix = n; |
| 252 |
+ |
if ((cp = bmalloc(n+2)) == NULL) |
| 253 |
+ |
syserr(progname); |
| 254 |
+ |
strncpy(cp, orig, suffix); |
| 255 |
+ |
cp[suffix] = pred; /* root name + pred + suffix */ |
| 256 |
+ |
strcpy(cp+suffix+1, orig+suffix); |
| 257 |
+ |
return(cp); |
| 258 |
+ |
} |
| 259 |
+ |
|
| 260 |
+ |
|
| 261 |
|
checkfiles() /* check for existence and modified times */ |
| 262 |
|
{ |
| 263 |
< |
char *cp; |
| 402 |
< |
long objdate; |
| 263 |
> |
time_t objdate; |
| 264 |
|
|
| 265 |
|
if (!vdef(OCTREE)) { |
| 266 |
< |
if ((cp = bmalloc(strlen(radname)+5)) == NULL) |
| 266 |
> |
if ((vval(OCTREE) = bmalloc(strlen(radname)+5)) == NULL) |
| 267 |
|
syserr(progname); |
| 268 |
< |
sprintf(cp, "%s.oct", radname); |
| 408 |
< |
vval(OCTREE) = cp; |
| 268 |
> |
sprintf(vval(OCTREE), "%s.oct", radname); |
| 269 |
|
vdef(OCTREE)++; |
| 270 |
|
} |
| 271 |
|
octreedate = fdate(vval(OCTREE)); |
| 272 |
< |
scenedate = -1; |
| 273 |
< |
if (vdef(SCENE)) { |
| 274 |
< |
scenedate = checklast(vval(SCENE)); |
| 275 |
< |
if (vdef(OBJECT)) { |
| 276 |
< |
objdate = checklast(vval(OBJECT)); |
| 277 |
< |
if (objdate > scenedate) |
| 278 |
< |
scenedate = objdate; |
| 279 |
< |
} |
| 272 |
> |
if (vdef(ILLUM)) { /* illum requires secondary octrees */ |
| 273 |
> |
oct0name = newfname(vval(OCTREE), '0'); |
| 274 |
> |
oct1name = newfname(vval(OCTREE), '1'); |
| 275 |
> |
oct0date = fdate(oct0name); |
| 276 |
> |
oct1date = fdate(oct1name); |
| 277 |
> |
} else |
| 278 |
> |
oct0name = oct1name = vval(OCTREE); |
| 279 |
> |
if ((scenedate = checklast(vval(SCENE))) && |
| 280 |
> |
(objdate = checklast(vval(OBJECT))) > scenedate) |
| 281 |
> |
scenedate = objdate; |
| 282 |
> |
illumdate = checklast(vval(ILLUM)); |
| 283 |
> |
if (!octreedate & !scenedate & !illumdate) { |
| 284 |
> |
fprintf(stderr, "%s: need '%s' or '%s' or '%s'\n", progname, |
| 285 |
> |
vnam(OCTREE), vnam(SCENE), vnam(ILLUM)); |
| 286 |
> |
quit(1); |
| 287 |
|
} |
| 288 |
< |
if (octreedate < 0 & scenedate < 0) { |
| 422 |
< |
fprintf(stderr, "%s: need '%s' or '%s'\n", progname, |
| 423 |
< |
vnam(OCTREE), vnam(SCENE)); |
| 424 |
< |
exit(1); |
| 425 |
< |
} |
| 288 |
> |
matdate = checklast(vval(MATERIAL)); |
| 289 |
|
} |
| 290 |
|
|
| 291 |
|
|
| 294 |
|
{ |
| 295 |
|
extern FILE *popen(); |
| 296 |
|
static double oorg[3], osiz = 0.; |
| 297 |
< |
char buf[MAXPATH+16]; |
| 297 |
> |
double min[3], max[3]; |
| 298 |
> |
char buf[1024]; |
| 299 |
|
FILE *fp; |
| 300 |
+ |
register int i; |
| 301 |
|
|
| 302 |
< |
if (osiz <= FTINY) { |
| 303 |
< |
oconv(); /* does nothing if done already */ |
| 304 |
< |
sprintf(buf, "getinfo -d < %s", vval(OCTREE)); |
| 305 |
< |
if ((fp = popen(buf, "r")) == NULL) |
| 306 |
< |
syserr("getinfo"); |
| 307 |
< |
if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1], |
| 308 |
< |
&oorg[2], &osiz) != 4) { |
| 309 |
< |
fprintf(stderr, |
| 302 |
> |
if (osiz <= FTINY) |
| 303 |
> |
if (noaction && fdate(oct1name) < |
| 304 |
> |
(scenedate>illumdate?scenedate:illumdate)) { |
| 305 |
> |
/* run getbbox */ |
| 306 |
> |
sprintf(buf, "getbbox -w -h %s", |
| 307 |
> |
vdef(SCENE) ? vval(SCENE) : vval(ILLUM)); |
| 308 |
> |
if ((fp = popen(buf, "r")) == NULL) |
| 309 |
> |
syserr("getbbox"); |
| 310 |
> |
if (fscanf(fp, "%lf %lf %lf %lf %lf %lf", |
| 311 |
> |
&min[0], &max[0], &min[1], &max[1], |
| 312 |
> |
&min[2], &max[2]) != 6) { |
| 313 |
> |
fprintf(stderr, |
| 314 |
> |
"%s: error reading bounding box from getbbox\n", |
| 315 |
> |
progname); |
| 316 |
> |
quit(1); |
| 317 |
> |
} |
| 318 |
> |
for (i = 0; i < 3; i++) |
| 319 |
> |
if (max[i] - min[i] > osiz) |
| 320 |
> |
osiz = max[i] - min[i]; |
| 321 |
> |
for (i = 0; i < 3; i++) |
| 322 |
> |
oorg[i] = (max[i]+min[i]-osiz)*.5; |
| 323 |
> |
pclose(fp); |
| 324 |
> |
} else { /* from octree */ |
| 325 |
> |
oconv(); /* does nothing if done already */ |
| 326 |
> |
sprintf(buf, "getinfo -d < %s", oct1name); |
| 327 |
> |
if ((fp = popen(buf, "r")) == NULL) |
| 328 |
> |
syserr("getinfo"); |
| 329 |
> |
if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1], |
| 330 |
> |
&oorg[2], &osiz) != 4) { |
| 331 |
> |
fprintf(stderr, |
| 332 |
|
"%s: error reading bounding cube from getinfo\n", |
| 333 |
< |
progname); |
| 334 |
< |
exit(1); |
| 333 |
> |
progname); |
| 334 |
> |
quit(1); |
| 335 |
> |
} |
| 336 |
> |
pclose(fp); |
| 337 |
|
} |
| 449 |
– |
pclose(fp); |
| 450 |
– |
} |
| 338 |
|
org[0] = oorg[0]; org[1] = oorg[1]; org[2] = oorg[2]; *sizp = osiz; |
| 339 |
|
} |
| 340 |
|
|
| 367 |
|
vval(PICTURE) = radname; |
| 368 |
|
vdef(PICTURE)++; |
| 369 |
|
} |
| 370 |
< |
if (!vdef(VIEW)) { |
| 371 |
< |
vval(VIEW) = "X"; |
| 372 |
< |
vdef(VIEW)++; |
| 370 |
> |
if (!vdef(VIEWS)) { |
| 371 |
> |
vval(VIEWS) = "X"; |
| 372 |
> |
vdef(VIEWS)++; |
| 373 |
|
} |
| 374 |
|
if (!vdef(DETAIL)) { |
| 375 |
|
vval(DETAIL) = "M"; |
| 386 |
|
} |
| 387 |
|
|
| 388 |
|
|
| 389 |
< |
printvals() /* print variable values */ |
| 389 |
> |
oconv() /* run oconv and mkillum if necessary */ |
| 390 |
|
{ |
| 391 |
< |
register int i, j; |
| 391 |
> |
static char illumtmp[] = "ilXXXXXX"; |
| 392 |
> |
char combuf[1024], ocopts[64], mkopts[64]; |
| 393 |
|
|
| 394 |
< |
for (i = 0; i < NVARS; i++) |
| 395 |
< |
for (j = 0; j < vdef(i); j++) |
| 396 |
< |
printf("%s= %s\n", vnam(i), nvalue(vv+i, j)); |
| 397 |
< |
fflush(stdout); |
| 398 |
< |
} |
| 399 |
< |
|
| 400 |
< |
|
| 401 |
< |
oconv() /* run oconv if necessary */ |
| 402 |
< |
{ |
| 403 |
< |
char combuf[512], ocopts[64]; |
| 404 |
< |
|
| 405 |
< |
if (octreedate >= scenedate) /* check dates */ |
| 394 |
> |
oconvopts(ocopts); /* get options */ |
| 395 |
> |
if (octreedate < scenedate) { /* check date on original octree */ |
| 396 |
> |
if (touchonly && octreedate) |
| 397 |
> |
touch(vval(OCTREE)); |
| 398 |
> |
else { /* build command */ |
| 399 |
> |
if (vdef(MATERIAL)) |
| 400 |
> |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
| 401 |
> |
vval(MATERIAL), vval(SCENE), |
| 402 |
> |
vval(OCTREE)); |
| 403 |
> |
else |
| 404 |
> |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
| 405 |
> |
vval(SCENE), vval(OCTREE)); |
| 406 |
> |
|
| 407 |
> |
if (runcom(combuf)) { /* run it */ |
| 408 |
> |
fprintf(stderr, |
| 409 |
> |
"%s: error generating octree\n\t%s removed\n", |
| 410 |
> |
progname, vval(OCTREE)); |
| 411 |
> |
unlink(vval(OCTREE)); |
| 412 |
> |
quit(1); |
| 413 |
> |
} |
| 414 |
> |
} |
| 415 |
> |
octreedate = time((time_t *)NULL); |
| 416 |
> |
if (octreedate < scenedate) /* in case clock is off */ |
| 417 |
> |
octreedate = scenedate; |
| 418 |
> |
} |
| 419 |
> |
if (oct1name == vval(OCTREE)) /* no mkillum? */ |
| 420 |
> |
oct1date = octreedate > matdate ? octreedate : matdate; |
| 421 |
> |
if (oct1date >= octreedate & oct1date >= matdate |
| 422 |
> |
& oct1date >= illumdate) /* all done */ |
| 423 |
|
return; |
| 424 |
< |
/* build command */ |
| 425 |
< |
oconvopts(ocopts); |
| 426 |
< |
if (vdef(MATERIAL)) |
| 427 |
< |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
| 428 |
< |
vval(MATERIAL), vval(SCENE), vval(OCTREE)); |
| 429 |
< |
else |
| 430 |
< |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
| 431 |
< |
vval(SCENE), vval(OCTREE)); |
| 432 |
< |
|
| 433 |
< |
if (runcom(combuf)) { /* run it */ |
| 434 |
< |
fprintf(stderr, "%s: error generating octree\n\t%s removed\n", |
| 435 |
< |
progname, vval(OCTREE)); |
| 436 |
< |
unlink(vval(OCTREE)); |
| 437 |
< |
exit(1); |
| 424 |
> |
/* make octree0 */ |
| 425 |
> |
if (oct0date < scenedate | oct0date < illumdate) { |
| 426 |
> |
if (touchonly && oct0date) |
| 427 |
> |
touch(oct0name); |
| 428 |
> |
else { /* build command */ |
| 429 |
> |
if (octreedate) |
| 430 |
> |
sprintf(combuf, "oconv%s -i %s %s > %s", ocopts, |
| 431 |
> |
vval(OCTREE), vval(ILLUM), oct0name); |
| 432 |
> |
else if (vdef(MATERIAL)) |
| 433 |
> |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
| 434 |
> |
vval(MATERIAL), vval(ILLUM), oct0name); |
| 435 |
> |
else |
| 436 |
> |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
| 437 |
> |
vval(ILLUM), oct0name); |
| 438 |
> |
if (runcom(combuf)) { /* run it */ |
| 439 |
> |
fprintf(stderr, |
| 440 |
> |
"%s: error generating octree\n\t%s removed\n", |
| 441 |
> |
progname, oct0name); |
| 442 |
> |
unlink(oct0name); |
| 443 |
> |
quit(1); |
| 444 |
> |
} |
| 445 |
> |
} |
| 446 |
> |
oct0date = time((time_t *)NULL); |
| 447 |
> |
if (oct0date < octreedate) /* in case clock is off */ |
| 448 |
> |
oct0date = octreedate; |
| 449 |
> |
if (oct0date < illumdate) /* ditto */ |
| 450 |
> |
oct0date = illumdate; |
| 451 |
> |
} |
| 452 |
> |
if (touchonly && oct1date) |
| 453 |
> |
touch(oct1name); |
| 454 |
> |
else { |
| 455 |
> |
mkillumopts(mkopts); /* build mkillum command */ |
| 456 |
> |
mktemp(illumtmp); |
| 457 |
> |
sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts, |
| 458 |
> |
oct0name, vval(ILLUM), illumtmp); |
| 459 |
> |
if (runcom(combuf)) { /* run it */ |
| 460 |
> |
fprintf(stderr, "%s: error running mkillum\n", |
| 461 |
> |
progname); |
| 462 |
> |
unlink(illumtmp); |
| 463 |
> |
quit(1); |
| 464 |
> |
} |
| 465 |
> |
/* make octree1 (frozen) */ |
| 466 |
> |
if (octreedate) |
| 467 |
> |
sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts, |
| 468 |
> |
vval(OCTREE), illumtmp, oct1name); |
| 469 |
> |
else if (vdef(MATERIAL)) |
| 470 |
> |
sprintf(combuf, "oconv%s -f %s %s > %s", ocopts, |
| 471 |
> |
vval(MATERIAL), illumtmp, oct1name); |
| 472 |
> |
else |
| 473 |
> |
sprintf(combuf, "oconv%s -f %s > %s", ocopts, |
| 474 |
> |
illumtmp, oct1name); |
| 475 |
> |
if (runcom(combuf)) { /* run it */ |
| 476 |
> |
fprintf(stderr, |
| 477 |
> |
"%s: error generating octree\n\t%s removed\n", |
| 478 |
> |
progname, oct1name); |
| 479 |
> |
unlink(oct1name); |
| 480 |
> |
unlink(illumtmp); |
| 481 |
> |
quit(1); |
| 482 |
> |
} |
| 483 |
> |
rmfile(illumtmp); |
| 484 |
|
} |
| 485 |
< |
octreedate = time(0); |
| 485 |
> |
oct1date = time((time_t *)NULL); |
| 486 |
> |
if (oct1date < oct0date) /* in case clock is off */ |
| 487 |
> |
oct1date = oct0date; |
| 488 |
|
} |
| 489 |
|
|
| 490 |
|
|
| 510 |
|
} |
| 511 |
|
|
| 512 |
|
|
| 513 |
+ |
mkillumopts(mo) /* get mkillum options */ |
| 514 |
+ |
register char *mo; |
| 515 |
+ |
{ |
| 516 |
+ |
/* BEWARE: This may be called via setdefaults(), so no assumptions */ |
| 517 |
+ |
|
| 518 |
+ |
*mo = '\0'; |
| 519 |
+ |
if (vdef(MKILLUM)) |
| 520 |
+ |
addarg(mo, vval(MKILLUM)); |
| 521 |
+ |
} |
| 522 |
+ |
|
| 523 |
+ |
|
| 524 |
|
checkambfile() /* check date on ambient file */ |
| 525 |
|
{ |
| 526 |
< |
long afdate; |
| 526 |
> |
time_t afdate; |
| 527 |
|
|
| 528 |
< |
if (vdef(AMBFILE)) { |
| 529 |
< |
afdate = fdate(vval(AMBFILE)); |
| 530 |
< |
if (afdate >= 0 & octreedate > afdate) |
| 528 |
> |
if (!vdef(AMBFILE)) |
| 529 |
> |
return; |
| 530 |
> |
if (!(afdate = fdate(vval(AMBFILE)))) |
| 531 |
> |
return; |
| 532 |
> |
if (oct1date > afdate) |
| 533 |
> |
if (touchonly) |
| 534 |
> |
touch(vval(AMBFILE)); |
| 535 |
> |
else |
| 536 |
|
rmfile(vval(AMBFILE)); |
| 568 |
– |
} |
| 537 |
|
} |
| 538 |
|
|
| 539 |
|
|
| 542 |
|
{ |
| 543 |
|
if (vdef(EXPOSURE)) { |
| 544 |
|
if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-') |
| 545 |
< |
return(.5/pow(2.,atof(vval(EXPOSURE)))); |
| 546 |
< |
if (isdigit(vval(EXPOSURE)[0]) || vval(EXPOSURE)[0] == '.') |
| 579 |
< |
return(.5/atof(vval(EXPOSURE))); |
| 580 |
< |
badvalue(EXPOSURE); |
| 545 |
> |
return(.5/pow(2.,vflt(EXPOSURE))); |
| 546 |
> |
return(.5/vflt(EXPOSURE)); |
| 547 |
|
} |
| 548 |
|
if (vlet(ZONE) == 'E') |
| 549 |
|
return(10.); |
| 553 |
|
} |
| 554 |
|
|
| 555 |
|
|
| 556 |
< |
lowqopts(op) /* low quality rendering options */ |
| 556 |
> |
renderopts(op, po) /* set rendering options */ |
| 557 |
> |
char *op, *po; |
| 558 |
> |
{ |
| 559 |
> |
switch(vscale(QUALITY)) { |
| 560 |
> |
case LOW: |
| 561 |
> |
lowqopts(op, po); |
| 562 |
> |
break; |
| 563 |
> |
case MEDIUM: |
| 564 |
> |
medqopts(op, po); |
| 565 |
> |
break; |
| 566 |
> |
case HIGH: |
| 567 |
> |
hiqopts(op, po); |
| 568 |
> |
break; |
| 569 |
> |
} |
| 570 |
> |
} |
| 571 |
> |
|
| 572 |
> |
|
| 573 |
> |
lowqopts(op, po) /* low quality rendering options */ |
| 574 |
|
register char *op; |
| 575 |
+ |
char *po; |
| 576 |
|
{ |
| 577 |
|
double d, org[3], siz[3]; |
| 578 |
|
|
| 579 |
|
*op = '\0'; |
| 580 |
+ |
*po = '\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 |
+ |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
| 586 |
+ |
badvalue(ZONE); |
| 587 |
|
getoctcube(org, &d); |
| 588 |
|
d *= 3./(siz[0]+siz[1]+siz[2]); |
| 589 |
|
switch (vscale(DETAIL)) { |
| 590 |
|
case LOW: |
| 591 |
< |
op = addarg(op, "-ps 16 -dp 16"); |
| 591 |
> |
po = addarg(po, "-ps 16"); |
| 592 |
> |
op = addarg(op, "-dp 64"); |
| 593 |
|
sprintf(op, " -ar %d", (int)(4*d)); |
| 594 |
|
op += strlen(op); |
| 595 |
|
break; |
| 596 |
|
case MEDIUM: |
| 597 |
< |
op = addarg(op, "-ps 8 -dp 32"); |
| 597 |
> |
po = addarg(po, "-ps 8"); |
| 598 |
> |
op = addarg(op, "-dp 128"); |
| 599 |
|
sprintf(op, " -ar %d", (int)(8*d)); |
| 600 |
|
op += strlen(op); |
| 601 |
|
break; |
| 602 |
|
case HIGH: |
| 603 |
< |
op = addarg(op, "-ps 4 -dp 64"); |
| 603 |
> |
po = addarg(po, "-ps 4"); |
| 604 |
> |
op = addarg(op, "-dp 256"); |
| 605 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
| 606 |
|
op += strlen(op); |
| 607 |
|
break; |
| 608 |
|
} |
| 609 |
< |
op = addarg(op, "-pt .16"); |
| 609 |
> |
po = addarg(po, "-pt .16"); |
| 610 |
|
if (vbool(PENUMBRAS)) |
| 611 |
|
op = addarg(op, "-ds .4"); |
| 612 |
|
else |
| 613 |
|
op = addarg(op, "-ds 0"); |
| 614 |
< |
op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .7"); |
| 614 |
> |
op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5"); |
| 615 |
|
if (vdef(AMBFILE)) { |
| 616 |
|
sprintf(op, " -af %s", vval(AMBFILE)); |
| 617 |
|
op += strlen(op); |
| 619 |
|
overture = 0; |
| 620 |
|
switch (vscale(VARIABILITY)) { |
| 621 |
|
case LOW: |
| 622 |
< |
op = addarg(op, "-aa .4 -ad 32"); |
| 622 |
> |
op = addarg(op, "-aa .4 -ad 64"); |
| 623 |
|
break; |
| 624 |
|
case MEDIUM: |
| 625 |
< |
op = addarg(op, "-aa .3 -ad 64"); |
| 625 |
> |
op = addarg(op, "-aa .3 -ad 128"); |
| 626 |
|
break; |
| 627 |
|
case HIGH: |
| 628 |
< |
op = addarg(op, "-aa .25 -ad 128"); |
| 628 |
> |
op = addarg(op, "-aa .25 -ad 256"); |
| 629 |
|
break; |
| 630 |
|
} |
| 631 |
|
op = addarg(op, "-as 0"); |
| 638 |
|
} |
| 639 |
|
|
| 640 |
|
|
| 641 |
< |
medqopts(op) /* medium quality rendering options */ |
| 641 |
> |
medqopts(op, po) /* medium quality rendering options */ |
| 642 |
|
register char *op; |
| 643 |
+ |
char *po; |
| 644 |
|
{ |
| 645 |
< |
double d, org[3], siz[3]; |
| 645 |
> |
double d, org[3], siz[3], asz; |
| 646 |
|
|
| 647 |
|
*op = '\0'; |
| 648 |
+ |
*po = '\0'; |
| 649 |
|
if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0], |
| 650 |
|
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) |
| 651 |
|
badvalue(ZONE); |
| 652 |
|
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; |
| 653 |
+ |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
| 654 |
+ |
badvalue(ZONE); |
| 655 |
|
getoctcube(org, &d); |
| 656 |
< |
d *= 3./(siz[0]+siz[1]+siz[2]); |
| 656 |
> |
asz = (siz[0]+siz[1]+siz[2])/3.; |
| 657 |
> |
d /= asz; |
| 658 |
|
switch (vscale(DETAIL)) { |
| 659 |
|
case LOW: |
| 660 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8"); |
| 661 |
< |
op = addarg(op, "-dp 64"); |
| 660 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8"); |
| 661 |
> |
op = addarg(op, "-dp 256"); |
| 662 |
|
sprintf(op, " -ar %d", (int)(8*d)); |
| 663 |
|
op += strlen(op); |
| 664 |
+ |
sprintf(op, " -ms %.2g", asz/20.); |
| 665 |
+ |
op += strlen(op); |
| 666 |
|
break; |
| 667 |
|
case MEDIUM: |
| 668 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6"); |
| 669 |
< |
op = addarg(op, "-dp 128"); |
| 668 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6"); |
| 669 |
> |
op = addarg(op, "-dp 512"); |
| 670 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
| 671 |
|
op += strlen(op); |
| 672 |
+ |
sprintf(op, " -ms %.2g", asz/40.); |
| 673 |
+ |
op += strlen(op); |
| 674 |
|
break; |
| 675 |
|
case HIGH: |
| 676 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4"); |
| 677 |
< |
op = addarg(op, "-dp 256"); |
| 676 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4"); |
| 677 |
> |
op = addarg(op, "-dp 1024"); |
| 678 |
|
sprintf(op, " -ar %d", (int)(32*d)); |
| 679 |
|
op += strlen(op); |
| 680 |
+ |
sprintf(op, " -ms %.2g", asz/80.); |
| 681 |
+ |
op += strlen(op); |
| 682 |
|
break; |
| 683 |
|
} |
| 684 |
< |
op = addarg(op, "-pt .08"); |
| 684 |
> |
po = addarg(po, "-pt .08"); |
| 685 |
|
if (vbool(PENUMBRAS)) |
| 686 |
< |
op = addarg(op, "-ds .2 -dj .35"); |
| 686 |
> |
op = addarg(op, "-ds .2 -dj .5"); |
| 687 |
|
else |
| 688 |
|
op = addarg(op, "-ds .3"); |
| 689 |
< |
op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .15"); |
| 689 |
> |
op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1"); |
| 690 |
|
if (overture = vint(INDIRECT)) { |
| 691 |
|
sprintf(op, " -ab %d", overture); |
| 692 |
|
op += strlen(op); |
| 698 |
|
overture = 0; |
| 699 |
|
switch (vscale(VARIABILITY)) { |
| 700 |
|
case LOW: |
| 701 |
< |
op = addarg(op, "-aa .25 -ad 128 -as 0"); |
| 701 |
> |
op = addarg(op, "-aa .25 -ad 196 -as 0"); |
| 702 |
|
break; |
| 703 |
|
case MEDIUM: |
| 704 |
< |
op = addarg(op, "-aa .2 -ad 300 -as 64"); |
| 704 |
> |
op = addarg(op, "-aa .2 -ad 400 -as 64"); |
| 705 |
|
break; |
| 706 |
|
case HIGH: |
| 707 |
< |
op = addarg(op, "-aa .15 -ad 500 -as 128"); |
| 707 |
> |
op = addarg(op, "-aa .15 -ad 768 -as 196"); |
| 708 |
|
break; |
| 709 |
|
} |
| 710 |
|
d = ambval(); |
| 716 |
|
} |
| 717 |
|
|
| 718 |
|
|
| 719 |
< |
hiqopts(op) /* high quality rendering options */ |
| 719 |
> |
hiqopts(op, po) /* high quality rendering options */ |
| 720 |
|
register char *op; |
| 721 |
+ |
char *po; |
| 722 |
|
{ |
| 723 |
< |
double d, org[3], siz[3]; |
| 723 |
> |
double d, org[3], siz[3], asz; |
| 724 |
|
|
| 725 |
|
*op = '\0'; |
| 726 |
+ |
*po = '\0'; |
| 727 |
|
if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0], |
| 728 |
|
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) |
| 729 |
|
badvalue(ZONE); |
| 730 |
|
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; |
| 731 |
+ |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
| 732 |
+ |
badvalue(ZONE); |
| 733 |
|
getoctcube(org, &d); |
| 734 |
< |
d *= 3./(siz[0]+siz[1]+siz[2]); |
| 734 |
> |
asz = (siz[0]+siz[1]+siz[2])/3.; |
| 735 |
> |
d /= asz; |
| 736 |
|
switch (vscale(DETAIL)) { |
| 737 |
|
case LOW: |
| 738 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8"); |
| 739 |
< |
op = addarg(op, "-dp 256"); |
| 738 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8"); |
| 739 |
> |
op = addarg(op, "-dp 1024"); |
| 740 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
| 741 |
|
op += strlen(op); |
| 742 |
+ |
sprintf(op, " -ms %.2g", asz/40.); |
| 743 |
+ |
op += strlen(op); |
| 744 |
|
break; |
| 745 |
|
case MEDIUM: |
| 746 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5"); |
| 747 |
< |
op = addarg(op, "-dp 512"); |
| 746 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5"); |
| 747 |
> |
op = addarg(op, "-dp 2048"); |
| 748 |
|
sprintf(op, " -ar %d", (int)(32*d)); |
| 749 |
|
op += strlen(op); |
| 750 |
+ |
sprintf(op, " -ms %.2g", asz/80.); |
| 751 |
+ |
op += strlen(op); |
| 752 |
|
break; |
| 753 |
|
case HIGH: |
| 754 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3"); |
| 755 |
< |
op = addarg(op, "-dp 1024"); |
| 754 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3"); |
| 755 |
> |
op = addarg(op, "-dp 4096"); |
| 756 |
|
sprintf(op, " -ar %d", (int)(64*d)); |
| 757 |
|
op += strlen(op); |
| 758 |
+ |
sprintf(op, " -ms %.2g", asz/160.); |
| 759 |
+ |
op += strlen(op); |
| 760 |
|
break; |
| 761 |
|
} |
| 762 |
< |
op = addarg(op, "-pt .04"); |
| 762 |
> |
po = addarg(po, "-pt .04"); |
| 763 |
|
if (vbool(PENUMBRAS)) |
| 764 |
< |
op = addarg(op, "-ds .1 -dj .7"); |
| 764 |
> |
op = addarg(op, "-ds .1 -dj .65"); |
| 765 |
|
else |
| 766 |
|
op = addarg(op, "-ds .2"); |
| 767 |
< |
op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .03"); |
| 767 |
> |
op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01"); |
| 768 |
|
sprintf(op, " -ab %d", overture=vint(INDIRECT)+1); |
| 769 |
|
op += strlen(op); |
| 770 |
|
if (vdef(AMBFILE)) { |
| 774 |
|
overture = 0; |
| 775 |
|
switch (vscale(VARIABILITY)) { |
| 776 |
|
case LOW: |
| 777 |
< |
op = addarg(op, "-aa .15 -ad 200 -as 0"); |
| 777 |
> |
op = addarg(op, "-aa .15 -ad 256 -as 0"); |
| 778 |
|
break; |
| 779 |
|
case MEDIUM: |
| 780 |
< |
op = addarg(op, "-aa .125 -ad 512 -as 128"); |
| 780 |
> |
op = addarg(op, "-aa .125 -ad 512 -as 256"); |
| 781 |
|
break; |
| 782 |
|
case HIGH: |
| 783 |
< |
op = addarg(op, "-aa .08 -ad 850 -as 256"); |
| 783 |
> |
op = addarg(op, "-aa .08 -ad 1024 -as 512"); |
| 784 |
|
break; |
| 785 |
|
} |
| 786 |
|
d = ambval(); |
| 796 |
|
char *ro; |
| 797 |
|
{ |
| 798 |
|
int fd, n; |
| 799 |
+ |
register char *cp; |
| 800 |
|
|
| 801 |
|
n = strlen(ro); |
| 802 |
|
if (n < 2) |
| 803 |
|
return; |
| 804 |
|
if (vdef(OPTFILE)) { |
| 805 |
< |
if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) |
| 805 |
> |
for (cp = ro; cp[1]; cp++) |
| 806 |
> |
if (isspace(cp[1]) && (cp[2] == '@' || |
| 807 |
> |
(cp[2] == '-' && isalpha(cp[3])))) |
| 808 |
> |
*cp = '\n'; |
| 809 |
> |
else |
| 810 |
> |
*cp = cp[1]; |
| 811 |
> |
*cp = '\n'; |
| 812 |
> |
fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666); |
| 813 |
> |
if (fd < 0 || write(fd, ro, n) != n || close(fd) < 0) |
| 814 |
|
syserr(vval(OPTFILE)); |
| 815 |
< |
if (write(fd, ro+1, n-1) != n-1) |
| 795 |
< |
syserr(vval(OPTFILE)); |
| 796 |
< |
write(fd, "\n", 1); |
| 797 |
< |
close(fd); |
| 798 |
< |
sprintf(ro, " \"^%s\"", vval(OPTFILE)); |
| 815 |
> |
sprintf(ro, " @%s", vval(OPTFILE)); |
| 816 |
|
} |
| 817 |
|
#ifdef MSDOS |
| 818 |
|
else if (n > 50) { |
| 831 |
|
po = addarg(po, "-1 -e"); |
| 832 |
|
po = addarg(po, vval(EXPOSURE)); |
| 833 |
|
} |
| 834 |
< |
if (vscale(QUALITY) == HIGH) |
| 835 |
< |
po = addarg(po, "-r .65"); |
| 834 |
> |
switch (vscale(QUALITY)) { |
| 835 |
> |
case MEDIUM: |
| 836 |
> |
po = addarg(po, "-r 1"); |
| 837 |
> |
break; |
| 838 |
> |
case HIGH: |
| 839 |
> |
po = addarg(po, "-m .25"); |
| 840 |
> |
break; |
| 841 |
> |
} |
| 842 |
|
if (vdef(PFILT)) |
| 843 |
|
po = addarg(po, vval(PFILT)); |
| 844 |
|
} |
| 868 |
|
register int i; |
| 869 |
|
double cent[3], dim[3], mult, d; |
| 870 |
|
|
| 871 |
< |
if (*vs == '-') |
| 871 |
> |
if (vs == NULL || *vs == '-') |
| 872 |
|
return(vs); |
| 873 |
|
upax = 0; /* get the up vector */ |
| 874 |
|
if (vdef(UP)) { |
| 899 |
|
zpos = -1; vs++; |
| 900 |
|
} |
| 901 |
|
viewtype = 'v'; |
| 902 |
< |
if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h') |
| 902 |
> |
if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h' | *vs == 'c') |
| 903 |
|
viewtype = *vs++; |
| 904 |
|
cp = viewopts; |
| 905 |
|
if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) { /* got one! */ |
| 910 |
|
badvalue(ZONE); |
| 911 |
|
for (i = 0; i < 3; i++) { |
| 912 |
|
dim[i] -= cent[i]; |
| 913 |
+ |
if (dim[i] <= FTINY) |
| 914 |
+ |
badvalue(ZONE); |
| 915 |
|
cent[i] += .5*dim[i]; |
| 916 |
|
} |
| 917 |
|
mult = vlet(ZONE)=='E' ? 2. : .45 ; |
| 954 |
|
case 'h': |
| 955 |
|
cp = addarg(cp, "-vh 180 -vv 180"); |
| 956 |
|
break; |
| 957 |
+ |
case 'c': |
| 958 |
+ |
cp = addarg(cp, "-vh 180 -vv 90"); |
| 959 |
+ |
break; |
| 960 |
|
} |
| 961 |
|
} else { |
| 962 |
|
while (!isspace(*vs)) /* else skip id */ |
| 967 |
|
cp += strlen(cp); |
| 968 |
|
} |
| 969 |
|
} |
| 970 |
< |
strcpy(cp, vs); /* append any additional options */ |
| 970 |
> |
if (cp == viewopts) /* append any additional options */ |
| 971 |
> |
vs++; /* skip prefixed space if unneeded */ |
| 972 |
> |
strcpy(cp, vs); |
| 973 |
|
#ifdef MSDOS |
| 974 |
|
if (strlen(viewopts) > 40) { |
| 975 |
|
setenv("VIEW", viewopts); |
| 985 |
|
int n; |
| 986 |
|
char *vn; /* returned view name */ |
| 987 |
|
{ |
| 988 |
< |
register char *mv = NULL; |
| 988 |
> |
register char *mv; |
| 989 |
|
|
| 990 |
|
if (viewselect != NULL) { /* command-line selected */ |
| 991 |
|
if (n) /* only do one */ |
| 1000 |
|
; |
| 1001 |
|
*vn = '\0'; |
| 1002 |
|
} |
| 1003 |
+ |
/* view number? */ |
| 1004 |
+ |
if (isint(viewselect)) |
| 1005 |
+ |
return(specview(nvalue(VIEWS, atoi(viewselect)-1))); |
| 1006 |
|
/* check list */ |
| 1007 |
< |
while ((mv = nvalue(vv+VIEW, n++)) != NULL) |
| 1007 |
> |
while ((mv = nvalue(VIEWS, n++)) != NULL) |
| 1008 |
|
if (matchword(viewselect, mv)) |
| 1009 |
|
return(specview(mv)); |
| 1010 |
|
return(specview(viewselect)); /* standard view? */ |
| 1011 |
|
} |
| 1012 |
< |
mv = nvalue(vv+VIEW, n); /* use view n */ |
| 1012 |
> |
mv = nvalue(VIEWS, n); /* use view n */ |
| 1013 |
|
if (vn != NULL & mv != NULL) { |
| 1014 |
< |
if (*mv != '-') |
| 1015 |
< |
while (*mv && !isspace(*mv)) |
| 1016 |
< |
*vn++ = *mv++; |
| 1014 |
> |
register char *mv2 = mv; |
| 1015 |
> |
if (*mv2 != '-') |
| 1016 |
> |
while (*mv2 && !isspace(*mv2)) |
| 1017 |
> |
*vn++ = *mv2++; |
| 1018 |
|
*vn = '\0'; |
| 1019 |
|
} |
| 1020 |
|
return(specview(mv)); |
| 1021 |
|
} |
| 1022 |
|
|
| 1023 |
|
|
| 1024 |
< |
rview(opts) /* run rview with first view */ |
| 1025 |
< |
char *opts; |
| 1024 |
> |
printview(vopts) /* print out selected view */ |
| 1025 |
> |
register char *vopts; |
| 1026 |
|
{ |
| 1027 |
+ |
extern char *strstr(), *atos(), *getenv(); |
| 1028 |
+ |
VIEW vwr; |
| 1029 |
+ |
char buf[128]; |
| 1030 |
+ |
register char *cp; |
| 1031 |
+ |
again: |
| 1032 |
+ |
if (vopts == NULL) |
| 1033 |
+ |
return(-1); |
| 1034 |
+ |
#ifdef MSDOS |
| 1035 |
+ |
if (vopts[0] == '$') { |
| 1036 |
+ |
vopts = getenv(vopts+1); |
| 1037 |
+ |
goto again; |
| 1038 |
+ |
} |
| 1039 |
+ |
#endif |
| 1040 |
+ |
copystruct(&vwr, &stdview); |
| 1041 |
+ |
cp = vopts; /* get -vf files first */ |
| 1042 |
+ |
while ((cp = strstr(cp, "-vf ")) != NULL && |
| 1043 |
+ |
*atos(buf, sizeof(buf), cp += 4)) |
| 1044 |
+ |
viewfile(buf, &vwr, NULL); |
| 1045 |
+ |
sscanview(&vwr, vopts); /* get the rest */ |
| 1046 |
+ |
fputs(VIEWSTR, stdout); |
| 1047 |
+ |
fprintview(&vwr, stdout); /* print full spec. */ |
| 1048 |
+ |
fputc('\n', stdout); |
| 1049 |
+ |
return(0); |
| 1050 |
+ |
} |
| 1051 |
+ |
|
| 1052 |
+ |
|
| 1053 |
+ |
rview(opts, po) /* run rview with first view */ |
| 1054 |
+ |
char *opts, *po; |
| 1055 |
+ |
{ |
| 1056 |
+ |
char *vw; |
| 1057 |
|
char combuf[512]; |
| 1058 |
|
/* build command */ |
| 1059 |
< |
sprintf(combuf, "rview %s%s ", getview(0, NULL), opts); |
| 1059 |
> |
if (touchonly || (vw = getview(0, NULL)) == NULL) |
| 1060 |
> |
return; |
| 1061 |
> |
if (sayview) |
| 1062 |
> |
printview(vw); |
| 1063 |
> |
sprintf(combuf, "rview %s%s%s -R %s ", vw, po, opts, rifname); |
| 1064 |
|
if (rvdevice != NULL) |
| 1065 |
|
sprintf(combuf+strlen(combuf), "-o %s ", rvdevice); |
| 1066 |
< |
strcat(combuf, vval(OCTREE)); |
| 1066 |
> |
if (vdef(EXPOSURE)) |
| 1067 |
> |
sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE)); |
| 1068 |
> |
strcat(combuf, oct1name); |
| 1069 |
|
if (runcom(combuf)) { /* run it */ |
| 1070 |
|
fprintf(stderr, "%s: error running rview\n", progname); |
| 1071 |
< |
exit(1); |
| 1071 |
> |
quit(1); |
| 1072 |
|
} |
| 1073 |
|
} |
| 1074 |
|
|
| 1075 |
|
|
| 1076 |
< |
rpict(opts) /* run rpict and pfilt for each view */ |
| 1077 |
< |
char *opts; |
| 1076 |
> |
rpict(opts, po) /* run rpict and pfilt for each view */ |
| 1077 |
> |
char *opts, *po; |
| 1078 |
|
{ |
| 1079 |
|
char combuf[1024]; |
| 1080 |
< |
char rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH+16], res[32]; |
| 1080 |
> |
char rawfile[MAXPATH], picfile[MAXPATH]; |
| 1081 |
> |
char zopt[MAXPATH+4], rep[MAXPATH+16], res[32]; |
| 1082 |
|
char pfopts[128]; |
| 1083 |
|
char vs[32], *vw; |
| 1084 |
|
int vn, mult; |
| 1085 |
+ |
time_t rfdt, pfdt; |
| 1086 |
|
/* get pfilt options */ |
| 1087 |
|
pfiltopts(pfopts); |
| 1088 |
|
/* get resolution, reporting */ |
| 1089 |
< |
mult = vscale(QUALITY)+1; |
| 1089 |
> |
switch (vscale(QUALITY)) { |
| 1090 |
> |
case LOW: |
| 1091 |
> |
mult = 1; |
| 1092 |
> |
break; |
| 1093 |
> |
case MEDIUM: |
| 1094 |
> |
mult = 2; |
| 1095 |
> |
break; |
| 1096 |
> |
case HIGH: |
| 1097 |
> |
mult = 3; |
| 1098 |
> |
break; |
| 1099 |
> |
} |
| 1100 |
|
{ |
| 1101 |
|
int xres, yres; |
| 1102 |
|
double aspect; |
| 1126 |
|
/* do each view */ |
| 1127 |
|
vn = 0; |
| 1128 |
|
while ((vw = getview(vn++, vs)) != NULL) { |
| 1129 |
+ |
if (sayview) |
| 1130 |
+ |
printview(vw); |
| 1131 |
|
if (!vs[0]) |
| 1132 |
|
sprintf(vs, "%d", vn); |
| 1133 |
|
sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs); |
| 1134 |
+ |
if (vdef(ZFILE)) |
| 1135 |
+ |
sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs); |
| 1136 |
+ |
else |
| 1137 |
+ |
zopt[0] = '\0'; |
| 1138 |
|
/* check date on picture */ |
| 1139 |
< |
if (fdate(picfile) > octreedate) |
| 1139 |
> |
pfdt = fdate(picfile); |
| 1140 |
> |
if (pfdt >= oct1date) |
| 1141 |
|
continue; |
| 1142 |
+ |
/* get raw file name */ |
| 1143 |
+ |
sprintf(rawfile, "%s_%s.unf", |
| 1144 |
+ |
vdef(RAWFILE) ? vval(RAWFILE) : vval(PICTURE), vs); |
| 1145 |
+ |
rfdt = fdate(rawfile); |
| 1146 |
+ |
if (touchonly) { /* update times only */ |
| 1147 |
+ |
if (rfdt) { |
| 1148 |
+ |
if (rfdt < oct1date) |
| 1149 |
+ |
touch(rawfile); |
| 1150 |
+ |
} else if (pfdt && pfdt < oct1date) |
| 1151 |
+ |
touch(picfile); |
| 1152 |
+ |
continue; |
| 1153 |
+ |
} |
| 1154 |
|
/* build rpict command */ |
| 1155 |
< |
sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs); |
| 1156 |
< |
if (fdate(rawfile) > octreedate) /* recover */ |
| 1157 |
< |
sprintf(combuf, "rpict%s%s -ro %s %s", |
| 1057 |
< |
rep, opts, rawfile, vval(OCTREE)); |
| 1155 |
> |
if (rfdt >= oct1date) /* recover */ |
| 1156 |
> |
sprintf(combuf, "rpict%s%s%s%s -ro %s %s", |
| 1157 |
> |
rep, po, opts, zopt, rawfile, oct1name); |
| 1158 |
|
else { |
| 1159 |
|
if (overture) { /* run overture calculation */ |
| 1160 |
|
sprintf(combuf, |
| 1161 |
|
"rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s", |
| 1162 |
|
rep, vw, opts, |
| 1163 |
< |
vval(OCTREE), overfile); |
| 1163 |
> |
oct1name, overfile); |
| 1164 |
|
if (runcom(combuf)) { |
| 1165 |
|
fprintf(stderr, |
| 1166 |
|
"%s: error in overture for view %s\n", |
| 1167 |
|
progname, vs); |
| 1168 |
< |
exit(1); |
| 1168 |
> |
quit(1); |
| 1169 |
|
} |
| 1170 |
|
#ifdef NIX |
| 1171 |
|
rmfile(overfile); |
| 1172 |
|
#endif |
| 1173 |
|
} |
| 1174 |
< |
sprintf(combuf, "rpict%s %s %s%s %s > %s", |
| 1175 |
< |
rep, vw, res, opts, |
| 1176 |
< |
vval(OCTREE), rawfile); |
| 1174 |
> |
sprintf(combuf, "rpict%s %s %s%s%s%s %s > %s", |
| 1175 |
> |
rep, vw, res, po, opts, zopt, |
| 1176 |
> |
oct1name, rawfile); |
| 1177 |
|
} |
| 1178 |
|
if (runcom(combuf)) { /* run rpict */ |
| 1179 |
|
fprintf(stderr, "%s: error rendering view %s\n", |
| 1180 |
|
progname, vs); |
| 1181 |
< |
exit(1); |
| 1181 |
> |
quit(1); |
| 1182 |
|
} |
| 1183 |
+ |
if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) { |
| 1184 |
|
/* build pfilt command */ |
| 1185 |
< |
if (mult > 1) |
| 1186 |
< |
sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s", |
| 1185 |
> |
if (mult > 1) |
| 1186 |
> |
sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s", |
| 1187 |
|
pfopts, mult, mult, rawfile, picfile); |
| 1188 |
< |
else |
| 1189 |
< |
sprintf(combuf, "pfilt%s %s > %s", pfopts, |
| 1190 |
< |
rawfile, picfile); |
| 1191 |
< |
if (runcom(combuf)) { /* run pfilt */ |
| 1192 |
< |
fprintf(stderr, |
| 1193 |
< |
"%s: error filtering view %s\n\t%s removed\n", |
| 1194 |
< |
progname, vs, picfile); |
| 1195 |
< |
unlink(picfile); |
| 1196 |
< |
exit(1); |
| 1188 |
> |
else |
| 1189 |
> |
sprintf(combuf, "pfilt%s %s > %s", pfopts, |
| 1190 |
> |
rawfile, picfile); |
| 1191 |
> |
if (runcom(combuf)) { /* run pfilt */ |
| 1192 |
> |
fprintf(stderr, |
| 1193 |
> |
"%s: error filtering view %s\n\t%s removed\n", |
| 1194 |
> |
progname, vs, picfile); |
| 1195 |
> |
unlink(picfile); |
| 1196 |
> |
quit(1); |
| 1197 |
> |
} |
| 1198 |
|
} |
| 1199 |
< |
/* remove raw file */ |
| 1200 |
< |
rmfile(rawfile); |
| 1199 |
> |
/* remove/rename raw file */ |
| 1200 |
> |
if (vdef(RAWFILE)) { |
| 1201 |
> |
sprintf(combuf, "%s_%s.pic", vval(RAWFILE), vs); |
| 1202 |
> |
mvfile(rawfile, combuf); |
| 1203 |
> |
} else |
| 1204 |
> |
rmfile(rawfile); |
| 1205 |
|
} |
| 1206 |
|
} |
| 1207 |
|
|
| 1208 |
|
|
| 1209 |
+ |
touch(fn) /* update a file */ |
| 1210 |
+ |
char *fn; |
| 1211 |
+ |
{ |
| 1212 |
+ |
if (!silent) |
| 1213 |
+ |
printf("\ttouch %s\n", fn); |
| 1214 |
+ |
if (noaction) |
| 1215 |
+ |
return(0); |
| 1216 |
+ |
#ifdef notused |
| 1217 |
+ |
if (access(fn, F_OK) == -1) /* create it */ |
| 1218 |
+ |
if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1) |
| 1219 |
+ |
return(-1); |
| 1220 |
+ |
#endif |
| 1221 |
+ |
return(setfdate(fn, time((time_t *)NULL))); |
| 1222 |
+ |
} |
| 1223 |
+ |
|
| 1224 |
+ |
|
| 1225 |
|
runcom(cs) /* run command */ |
| 1226 |
|
char *cs; |
| 1227 |
|
{ |
| 1249 |
|
} |
| 1250 |
|
|
| 1251 |
|
|
| 1252 |
+ |
mvfile(fold, fnew) /* move a file */ |
| 1253 |
+ |
char *fold, *fnew; |
| 1254 |
+ |
{ |
| 1255 |
+ |
if (!silent) |
| 1256 |
|
#ifdef MSDOS |
| 1257 |
+ |
printf("\trename %s %s\n", fold, fnew); |
| 1258 |
+ |
#else |
| 1259 |
+ |
printf("\tmv %s %s\n", fold, fnew); |
| 1260 |
+ |
#endif |
| 1261 |
+ |
if (noaction) |
| 1262 |
+ |
return(0); |
| 1263 |
+ |
return(rename(fold, fnew)); |
| 1264 |
+ |
} |
| 1265 |
+ |
|
| 1266 |
+ |
|
| 1267 |
+ |
#ifdef MSDOS |
| 1268 |
|
setenv(vname, value) /* set an environment variable */ |
| 1269 |
|
char *vname, *value; |
| 1270 |
|
{ |
| 1276 |
|
sprintf(evp, "%s=%s", vname, value); |
| 1277 |
|
if (putenv(evp) != 0) { |
| 1278 |
|
fprintf(stderr, "%s: out of environment space\n", progname); |
| 1279 |
< |
exit(1); |
| 1279 |
> |
quit(1); |
| 1280 |
|
} |
| 1281 |
|
if (!silent) |
| 1282 |
|
printf("set %s\n", evp); |
| 1289 |
|
{ |
| 1290 |
|
fprintf(stderr, "%s: bad value for variable '%s'\n", |
| 1291 |
|
progname, vnam(vc)); |
| 1292 |
< |
exit(1); |
| 1292 |
> |
quit(1); |
| 1293 |
|
} |
| 1294 |
|
|
| 1295 |
|
|
| 1297 |
|
char *s; |
| 1298 |
|
{ |
| 1299 |
|
perror(s); |
| 1300 |
< |
exit(1); |
| 1300 |
> |
quit(1); |
| 1301 |
> |
} |
| 1302 |
> |
|
| 1303 |
> |
|
| 1304 |
> |
quit(ec) /* exit program */ |
| 1305 |
> |
int ec; |
| 1306 |
> |
{ |
| 1307 |
> |
exit(ec); |
| 1308 |
|
} |