| 9 |
|
|
| 10 |
|
#include <ctype.h> |
| 11 |
|
#include <time.h> |
| 12 |
+ |
#include <signal.h> |
| 13 |
|
|
| 14 |
|
#include "platform.h" |
| 15 |
|
#include "rtprocess.h" |
| 17 |
|
#include "paths.h" |
| 18 |
|
#include "vars.h" |
| 19 |
|
|
| 20 |
< |
#ifdef _WIN32 |
| 20 |
> |
#if defined(_WIN32) || defined(_WIN64) |
| 21 |
|
#define DELCMD "del" |
| 22 |
|
#define RENAMECMD "rename" |
| 23 |
|
#else |
| 25 |
|
#define RENAMECMD "mv" |
| 26 |
|
#include <sys/types.h> |
| 27 |
|
#include <sys/wait.h> |
| 28 |
+ |
#include <signal.h> |
| 29 |
|
#endif |
| 30 |
|
|
| 31 |
|
/* variables (alphabetical by name) */ |
| 37 |
|
#define INDIRECT 5 /* indirection in lighting */ |
| 38 |
|
#define MATERIAL 6 /* material files */ |
| 39 |
|
#define MKILLUM 7 /* mkillum options */ |
| 40 |
< |
#define OBJECT 8 /* object files */ |
| 41 |
< |
#define OCONV 9 /* oconv options */ |
| 42 |
< |
#define OCTREE 10 /* octree file name */ |
| 43 |
< |
#define OPTFILE 11 /* rendering options file */ |
| 44 |
< |
#define PENUMBRAS 12 /* shadow penumbras are desired */ |
| 45 |
< |
#define PFILT 13 /* pfilt options */ |
| 46 |
< |
#define PICTURE 14 /* picture file root name */ |
| 47 |
< |
#define QUALITY 15 /* desired rendering quality */ |
| 48 |
< |
#define RAWFILE 16 /* raw picture file root name */ |
| 49 |
< |
#define RENDER 17 /* rendering options */ |
| 50 |
< |
#define REPORT 18 /* report frequency and errfile */ |
| 51 |
< |
#define RESOLUTION 19 /* maximum picture resolution */ |
| 52 |
< |
#define RPICT 20 /* rpict parameters */ |
| 53 |
< |
#define RVU 21 /* rvu parameters */ |
| 54 |
< |
#define SCENE 22 /* scene files */ |
| 55 |
< |
#define UP 23 /* view up (X, Y or Z) */ |
| 56 |
< |
#define VARIABILITY 24 /* level of light variability */ |
| 57 |
< |
#define VIEWS 25 /* view(s) for picture(s) */ |
| 58 |
< |
#define ZFILE 26 /* distance file root name */ |
| 59 |
< |
#define ZONE 27 /* simulation zone */ |
| 40 |
> |
#define MKPMAP 8 /* mkpmap options */ |
| 41 |
> |
#define OBJECT 9 /* object files */ |
| 42 |
> |
#define OCONV 10 /* oconv options */ |
| 43 |
> |
#define OCTREE 11 /* octree file name */ |
| 44 |
> |
#define OPTFILE 12 /* rendering options file */ |
| 45 |
> |
#define PCMAP 13 /* caustic photon map */ |
| 46 |
> |
#define PENUMBRAS 14 /* shadow penumbras are desired */ |
| 47 |
> |
#define PFILT 15 /* pfilt options */ |
| 48 |
> |
#define PGMAP 16 /* global photon map */ |
| 49 |
> |
#define PICTURE 17 /* picture file root name */ |
| 50 |
> |
#define QUALITY 18 /* desired rendering quality */ |
| 51 |
> |
#define RAWFILE 19 /* raw picture file root name */ |
| 52 |
> |
#define RENDER 20 /* rendering options */ |
| 53 |
> |
#define REPORT 21 /* report frequency and errfile */ |
| 54 |
> |
#define RESOLUTION 22 /* maximum picture resolution */ |
| 55 |
> |
#define RPICT 23 /* rpict parameters */ |
| 56 |
> |
#define RVU 24 /* rvu parameters */ |
| 57 |
> |
#define SCENE 25 /* scene files */ |
| 58 |
> |
#define UP 26 /* view up (X, Y or Z) */ |
| 59 |
> |
#define VARIABILITY 27 /* level of light variability */ |
| 60 |
> |
#define VIEWS 28 /* view(s) for picture(s) */ |
| 61 |
> |
#define ZFILE 29 /* distance file root name */ |
| 62 |
> |
#define ZONE 30 /* simulation zone */ |
| 63 |
|
/* total number of variables */ |
| 64 |
< |
int NVARS = 28; |
| 64 |
> |
int NVARS = 31; |
| 65 |
|
|
| 66 |
|
VARIABLE vv[] = { /* variable-value pairs */ |
| 67 |
< |
{"AMBFILE", 3, 0, NULL, onevalue}, |
| 67 |
> |
{"AMBFILE", 3, 0, NULL, strvalue}, |
| 68 |
|
{"DETAIL", 3, 0, NULL, qualvalue}, |
| 69 |
|
{"EXPOSURE", 3, 0, NULL, fltvalue}, |
| 70 |
|
{"EYESEP", 3, 0, NULL, fltvalue}, |
| 72 |
|
{"INDIRECT", 3, 0, NULL, intvalue}, |
| 73 |
|
{"materials", 3, 0, NULL, catvalues}, |
| 74 |
|
{"mkillum", 3, 0, NULL, catvalues}, |
| 75 |
+ |
{"mkpmap", 3, 0, NULL, catvalues}, |
| 76 |
|
{"objects", 3, 0, NULL, catvalues}, |
| 77 |
|
{"oconv", 3, 0, NULL, catvalues}, |
| 78 |
< |
{"OCTREE", 3, 0, NULL, onevalue}, |
| 79 |
< |
{"OPTFILE", 3, 0, NULL, onevalue}, |
| 78 |
> |
{"OCTREE", 3, 0, NULL, strvalue}, |
| 79 |
> |
{"OPTFILE", 3, 0, NULL, strvalue}, |
| 80 |
> |
{"PCMAP", 2, 0, NULL, strvalue}, |
| 81 |
|
{"PENUMBRAS", 3, 0, NULL, boolvalue}, |
| 82 |
|
{"pfilt", 2, 0, NULL, catvalues}, |
| 83 |
< |
{"PICTURE", 3, 0, NULL, onevalue}, |
| 83 |
> |
{"PGMAP", 2, 0, NULL, strvalue}, |
| 84 |
> |
{"PICTURE", 3, 0, NULL, strvalue}, |
| 85 |
|
{"QUALITY", 3, 0, NULL, qualvalue}, |
| 86 |
< |
{"RAWFILE", 3, 0, NULL, onevalue}, |
| 86 |
> |
{"RAWFILE", 3, 0, NULL, strvalue}, |
| 87 |
|
{"render", 3, 0, NULL, catvalues}, |
| 88 |
|
{"REPORT", 3, 0, NULL, onevalue}, |
| 89 |
|
{"RESOLUTION", 3, 0, NULL, onevalue}, |
| 93 |
|
{"UP", 2, 0, NULL, onevalue}, |
| 94 |
|
{"VARIABILITY", 3, 0, NULL, qualvalue}, |
| 95 |
|
{"view", 2, 0, NULL, NULL}, |
| 96 |
< |
{"ZFILE", 2, 0, NULL, onevalue}, |
| 96 |
> |
{"ZFILE", 2, 0, NULL, strvalue}, |
| 97 |
|
{"ZONE", 2, 0, NULL, onevalue}, |
| 98 |
|
}; |
| 99 |
|
|
| 115 |
|
char *oct1name; /* name of post-mkillum octree */ |
| 116 |
|
time_t oct1date; /* date of post-mkillum octree (>= matdate) */ |
| 117 |
|
|
| 118 |
+ |
char *pgmapname; /* name of global photon map */ |
| 119 |
+ |
time_t pgmapdate; /* date of global photon map (>= oct1date) */ |
| 120 |
+ |
char *pcmapname; /* name of caustic photon map */ |
| 121 |
+ |
time_t pcmapdate; /* date of caustic photon map (>= oct1date) */ |
| 122 |
+ |
|
| 123 |
|
int nowarn = 0; /* no warnings */ |
| 124 |
|
int explicate = 0; /* explicate variables */ |
| 125 |
|
int silent = 0; /* do work silently */ |
| 134 |
|
/* command paths */ |
| 135 |
|
char c_oconv[256] = "oconv"; |
| 136 |
|
char c_mkillum[256] = "mkillum"; |
| 137 |
+ |
char c_mkpmap[256] = "mkpmap"; |
| 138 |
|
char c_rvu[256] = "rvu"; |
| 139 |
|
char c_rpict[256] = DEF_RPICT_PATH; |
| 140 |
|
char c_rpiece[] = "rpiece"; |
| 158 |
|
static void getoctcube(double org[3], double *sizp); |
| 159 |
|
static void setdefaults(void); |
| 160 |
|
static void oconv(void); |
| 161 |
+ |
static void mkpmap(void); |
| 162 |
|
static char * addarg(char *op, char *arg); |
| 163 |
|
static void oconvopts(char *oo); |
| 164 |
|
static void mkillumopts(char *mo); |
| 165 |
+ |
static void mkpmapopts(char *mo); |
| 166 |
|
static void checkambfile(void); |
| 167 |
|
static double ambval(void); |
| 168 |
|
static void renderopts(char *op, char *po); |
| 242 |
|
/* load variable values */ |
| 243 |
|
loadvars(rifname); |
| 244 |
|
/* get any additional assignments */ |
| 245 |
< |
for (i++; i < argc; i++) |
| 246 |
< |
if (setvariable(argv[i], matchvar) < 0) { |
| 247 |
< |
fprintf(stderr, "%s: unknown variable: %s\n", |
| 245 |
> |
for (i++; i < argc; i++) { |
| 246 |
> |
int rv = setvariable(argv[i], matchvar); |
| 247 |
> |
if (rv < 0) { |
| 248 |
> |
fprintf(stderr, "%s: unknown setting: %s\n", |
| 249 |
|
progname, argv[i]); |
| 250 |
|
quit(1); |
| 251 |
|
} |
| 252 |
+ |
if (!rv) |
| 253 |
+ |
fprintf(stderr, |
| 254 |
+ |
"%s: bad variable assignment: %s (ignored)\n", |
| 255 |
+ |
progname, argv[i]); |
| 256 |
+ |
} |
| 257 |
|
/* check assignments */ |
| 258 |
|
checkvalues(); |
| 259 |
|
/* check files and dates */ |
| 265 |
|
printvars(stdout); |
| 266 |
|
/* build octree (and run mkillum) */ |
| 267 |
|
oconv(); |
| 268 |
+ |
/* run mkpmap if indicated */ |
| 269 |
+ |
mkpmap(); |
| 270 |
|
/* check date on ambient file */ |
| 271 |
|
checkambfile(); |
| 272 |
|
/* run simulation */ |
| 288 |
|
|
| 289 |
|
static void |
| 290 |
|
rootname( /* remove tail from end of fn */ |
| 291 |
< |
register char *rn, |
| 292 |
< |
register char *fn |
| 291 |
> |
char *rn, |
| 292 |
> |
char *fn |
| 293 |
|
) |
| 294 |
|
{ |
| 295 |
|
char *tp, *dp; |
| 306 |
|
|
| 307 |
|
static time_t |
| 308 |
|
checklast( /* check files and find most recent */ |
| 309 |
< |
register char *fnames |
| 309 |
> |
char *fnames |
| 310 |
|
) |
| 311 |
|
{ |
| 312 |
|
char thisfile[PATH_MAX]; |
| 336 |
|
int pred |
| 337 |
|
) |
| 338 |
|
{ |
| 339 |
< |
register char *cp; |
| 340 |
< |
register int n; |
| 339 |
> |
char *cp; |
| 340 |
> |
int n; |
| 341 |
|
int suffix; |
| 342 |
|
|
| 343 |
|
n = 0; cp = orig; suffix = -1; /* suffix position, length */ |
| 359 |
|
static void |
| 360 |
|
checkfiles(void) /* check for existence and modified times */ |
| 361 |
|
{ |
| 362 |
+ |
char fntemp[256]; |
| 363 |
|
time_t objdate; |
| 364 |
|
|
| 365 |
|
if (!vdef(OCTREE)) { |
| 389 |
|
vnam(OCTREE), vnam(SCENE), vnam(ILLUM)); |
| 390 |
|
quit(1); |
| 391 |
|
} |
| 392 |
+ |
if (vdef(PGMAP)) { |
| 393 |
+ |
if (!*sskip2(vval(PGMAP),1)) { |
| 394 |
+ |
fprintf(stderr, "%s: '%s' missing # photons argument\n", |
| 395 |
+ |
progname, vnam(PGMAP)); |
| 396 |
+ |
quit(1); |
| 397 |
+ |
} |
| 398 |
+ |
atos(fntemp, sizeof(fntemp), vval(PGMAP)); |
| 399 |
+ |
pgmapname = savqstr(fntemp); |
| 400 |
+ |
pgmapdate = fdate(pgmapname); |
| 401 |
+ |
} |
| 402 |
+ |
if (vdef(PCMAP)) { |
| 403 |
+ |
if (!*sskip2(vval(PCMAP),1)) { |
| 404 |
+ |
fprintf(stderr, "%s: '%s' missing # photons argument\n", |
| 405 |
+ |
progname, vnam(PCMAP)); |
| 406 |
+ |
quit(1); |
| 407 |
+ |
} |
| 408 |
+ |
atos(fntemp, sizeof(fntemp), vval(PCMAP)); |
| 409 |
+ |
pcmapname = savqstr(fntemp); |
| 410 |
+ |
pcmapdate = fdate(pcmapname); |
| 411 |
+ |
} |
| 412 |
|
matdate = checklast(vval(MATERIAL)); |
| 413 |
|
} |
| 414 |
|
|
| 423 |
|
double min[3], max[3]; |
| 424 |
|
char buf[1024]; |
| 425 |
|
FILE *fp; |
| 426 |
< |
register int i; |
| 426 |
> |
int i; |
| 427 |
|
|
| 428 |
|
if (osiz <= FTINY) { |
| 429 |
|
if (!nprocs && fdate(oct1name) < |
| 562 |
|
return; |
| 563 |
|
/* make octree0 */ |
| 564 |
|
if ((oct0date < scenedate) | (oct0date < illumdate)) { |
| 565 |
< |
if (touchonly && oct0date) |
| 566 |
< |
touch(oct0name); |
| 567 |
< |
else { /* build command */ |
| 565 |
> |
if (touchonly && (oct0date || oct1date)) { |
| 566 |
> |
if (oct0date) |
| 567 |
> |
touch(oct0name); |
| 568 |
> |
} else { /* build command */ |
| 569 |
|
if (octreedate) |
| 570 |
|
sprintf(combuf, "%s%s -i %s %s > %s", c_oconv, |
| 571 |
|
ocopts, vval(OCTREE), |
| 590 |
|
oct0date = octreedate; |
| 591 |
|
if (oct0date < illumdate) /* ditto */ |
| 592 |
|
oct0date = illumdate; |
| 593 |
< |
} |
| 593 |
> |
} |
| 594 |
|
if (touchonly && oct1date) |
| 595 |
|
touch(oct1name); |
| 596 |
|
else { |
| 631 |
|
} |
| 632 |
|
|
| 633 |
|
|
| 634 |
+ |
static void |
| 635 |
+ |
mkpmap(void) /* run mkpmap if indicated */ |
| 636 |
+ |
{ |
| 637 |
+ |
char combuf[2048], *cp; |
| 638 |
+ |
time_t tnow; |
| 639 |
+ |
/* nothing to do? */ |
| 640 |
+ |
if ((pgmapname == NULL) | (pgmapdate >= oct1date) && |
| 641 |
+ |
(pcmapname == NULL) | (pcmapdate >= oct1date)) |
| 642 |
+ |
return; |
| 643 |
+ |
/* just update existing file dates? */ |
| 644 |
+ |
if (touchonly && (pgmapname == NULL) | (pgmapdate > 0) && |
| 645 |
+ |
(pcmapname == NULL) | (pcmapdate > 0)) { |
| 646 |
+ |
if (pgmapname != NULL) |
| 647 |
+ |
touch(pgmapname); |
| 648 |
+ |
if (pcmapname != NULL) |
| 649 |
+ |
touch(pcmapname); |
| 650 |
+ |
} else { /* else need to (re)run pkpmap */ |
| 651 |
+ |
strcpy(combuf, c_mkpmap); |
| 652 |
+ |
for (cp = combuf; *cp; cp++) |
| 653 |
+ |
; |
| 654 |
+ |
mkpmapopts(cp); |
| 655 |
+ |
/* force file overwrite */ |
| 656 |
+ |
cp = addarg(cp, "-fo+"); |
| 657 |
+ |
if (vdef(REPORT)) { |
| 658 |
+ |
char errfile[256]; |
| 659 |
+ |
int n; |
| 660 |
+ |
double minutes; |
| 661 |
+ |
n = sscanf(vval(REPORT), "%lf %s", &minutes, errfile); |
| 662 |
+ |
if (n == 2) |
| 663 |
+ |
sprintf(cp, " -t %d -e %s", (int)(minutes*60), errfile); |
| 664 |
+ |
else if (n == 1) |
| 665 |
+ |
sprintf(cp, " -t %d", (int)(minutes*60)); |
| 666 |
+ |
else |
| 667 |
+ |
badvalue(REPORT); |
| 668 |
+ |
} |
| 669 |
+ |
if (pgmapname != NULL && pgmapdate < oct1date) { |
| 670 |
+ |
cp = addarg(cp, "-apg"); |
| 671 |
+ |
addarg(cp, vval(PGMAP)); |
| 672 |
+ |
cp = sskip(sskip(cp)); /* remove any bandwidth */ |
| 673 |
+ |
*cp = '\0'; |
| 674 |
+ |
} |
| 675 |
+ |
if (pcmapname != NULL && pcmapdate < oct1date) { |
| 676 |
+ |
cp = addarg(cp, "-apc"); |
| 677 |
+ |
addarg(cp, vval(PCMAP)); |
| 678 |
+ |
cp = sskip(sskip(cp)); /* remove any bandwidth */ |
| 679 |
+ |
*cp = '\0'; |
| 680 |
+ |
} |
| 681 |
+ |
cp = addarg(cp, oct1name); |
| 682 |
+ |
if (runcom(combuf)) { |
| 683 |
+ |
fprintf(stderr, "%s: error running %s\n", |
| 684 |
+ |
progname, c_mkpmap); |
| 685 |
+ |
if (pgmapname != NULL && pgmapdate < oct1date) |
| 686 |
+ |
unlink(pgmapname); |
| 687 |
+ |
if (pcmapname != NULL && pcmapdate < oct1date) |
| 688 |
+ |
unlink(pcmapname); |
| 689 |
+ |
quit(1); |
| 690 |
+ |
} |
| 691 |
+ |
} |
| 692 |
+ |
tnow = time((time_t *)NULL); |
| 693 |
+ |
if (pgmapname != NULL) |
| 694 |
+ |
pgmapdate = tnow; |
| 695 |
+ |
if (pcmapname != NULL) |
| 696 |
+ |
pcmapdate = tnow; |
| 697 |
+ |
oct1date = tnow; /* trigger ambient file removal if needed */ |
| 698 |
+ |
} |
| 699 |
+ |
|
| 700 |
+ |
|
| 701 |
|
static char * |
| 702 |
|
addarg( /* append argument and advance pointer */ |
| 703 |
< |
register char *op, |
| 704 |
< |
register char *arg |
| 703 |
> |
char *op, |
| 704 |
> |
char *arg |
| 705 |
|
) |
| 706 |
|
{ |
| 707 |
|
while (*op) |
| 715 |
|
|
| 716 |
|
static void |
| 717 |
|
oconvopts( /* get oconv options */ |
| 718 |
< |
register char *oo |
| 718 |
> |
char *oo |
| 719 |
|
) |
| 720 |
|
{ |
| 721 |
|
/* BEWARE: This may be called via setdefaults(), so no assumptions */ |
| 722 |
|
|
| 723 |
|
*oo = '\0'; |
| 724 |
< |
if (vdef(OCONV)) |
| 725 |
< |
if (vval(OCONV)[0] != '-') { |
| 726 |
< |
atos(c_oconv, sizeof(c_oconv), vval(OCONV)); |
| 727 |
< |
oo = addarg(oo, sskip2(vval(OCONV), 1)); |
| 728 |
< |
} else |
| 729 |
< |
oo = addarg(oo, vval(OCONV)); |
| 724 |
> |
if (!vdef(OCONV)) |
| 725 |
> |
return; |
| 726 |
> |
if (vval(OCONV)[0] != '-') { |
| 727 |
> |
atos(c_oconv, sizeof(c_oconv), vval(OCONV)); |
| 728 |
> |
oo = addarg(oo, sskip2(vval(OCONV), 1)); |
| 729 |
> |
} else |
| 730 |
> |
oo = addarg(oo, vval(OCONV)); |
| 731 |
|
} |
| 732 |
|
|
| 733 |
|
|
| 742 |
|
sprintf(mo, " -n %d", nprocs); |
| 743 |
|
else |
| 744 |
|
*mo = '\0'; |
| 745 |
< |
if (vdef(MKILLUM)) |
| 746 |
< |
if (vval(MKILLUM)[0] != '-') { |
| 747 |
< |
atos(c_mkillum, sizeof(c_mkillum), vval(MKILLUM)); |
| 748 |
< |
mo = addarg(mo, sskip2(vval(MKILLUM), 1)); |
| 749 |
< |
} else |
| 750 |
< |
mo = addarg(mo, vval(MKILLUM)); |
| 745 |
> |
if (!vdef(MKILLUM)) |
| 746 |
> |
return; |
| 747 |
> |
if (vval(MKILLUM)[0] != '-') { |
| 748 |
> |
atos(c_mkillum, sizeof(c_mkillum), vval(MKILLUM)); |
| 749 |
> |
mo = addarg(mo, sskip2(vval(MKILLUM), 1)); |
| 750 |
> |
} else |
| 751 |
> |
mo = addarg(mo, vval(MKILLUM)); |
| 752 |
|
} |
| 753 |
|
|
| 754 |
|
|
| 755 |
|
static void |
| 756 |
+ |
mkpmapopts( /* get mkpmap options */ |
| 757 |
+ |
char *mo |
| 758 |
+ |
) |
| 759 |
+ |
{ |
| 760 |
+ |
/* BEWARE: This may be called via setdefaults(), so no assumptions */ |
| 761 |
+ |
|
| 762 |
+ |
if (nprocs > 1) |
| 763 |
+ |
sprintf(mo, " -n %d", nprocs); |
| 764 |
+ |
else |
| 765 |
+ |
*mo = '\0'; |
| 766 |
+ |
if (!vdef(MKPMAP)) |
| 767 |
+ |
return; |
| 768 |
+ |
if (vval(MKPMAP)[0] != '-') { |
| 769 |
+ |
atos(c_mkpmap, sizeof(c_mkpmap), vval(MKPMAP)); |
| 770 |
+ |
mo = addarg(mo, sskip2(vval(MKPMAP), 1)); |
| 771 |
+ |
} else |
| 772 |
+ |
mo = addarg(mo, vval(MKPMAP)); |
| 773 |
+ |
} |
| 774 |
+ |
|
| 775 |
+ |
|
| 776 |
+ |
static void |
| 777 |
|
checkambfile(void) /* check date on ambient file */ |
| 778 |
|
{ |
| 779 |
|
time_t afdate; |
| 796 |
|
{ |
| 797 |
|
if (vdef(EXPOSURE)) { |
| 798 |
|
if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-') |
| 799 |
< |
return(.5/pow(2.,vflt(EXPOSURE))); |
| 800 |
< |
return(.5/vflt(EXPOSURE)); |
| 799 |
> |
return(.18/pow(2.,vflt(EXPOSURE))); |
| 800 |
> |
return(.18/vflt(EXPOSURE)); |
| 801 |
|
} |
| 802 |
|
if (vlet(ZONE) == 'E') |
| 803 |
|
return(10.); |
| 814 |
|
char *po |
| 815 |
|
) |
| 816 |
|
{ |
| 817 |
+ |
char pmapf[256], *bw; |
| 818 |
+ |
|
| 819 |
+ |
if (vdef(PGMAP)) { |
| 820 |
+ |
*op = '\0'; |
| 821 |
+ |
bw = sskip2(vval(PGMAP), 2); |
| 822 |
+ |
atos(pmapf, sizeof(pmapf), vval(PGMAP)); |
| 823 |
+ |
op = addarg(addarg(op, "-ap"), pmapf); |
| 824 |
+ |
if (atoi(bw) > 0) op = addarg(op, bw); |
| 825 |
+ |
} |
| 826 |
|
switch(vscale(QUALITY)) { |
| 827 |
|
case LOW: |
| 828 |
|
lowqopts(op, po); |
| 834 |
|
hiqopts(op, po); |
| 835 |
|
break; |
| 836 |
|
} |
| 837 |
< |
if (vdef(RENDER)) |
| 837 |
> |
if (vdef(PCMAP)) { |
| 838 |
> |
bw = sskip2(vval(PCMAP), 2); |
| 839 |
> |
atos(pmapf, sizeof(pmapf), vval(PCMAP)); |
| 840 |
> |
op = addarg(addarg(op, "-ap"), pmapf); |
| 841 |
> |
if (atoi(bw) > 0) op = addarg(op, bw); |
| 842 |
> |
} |
| 843 |
> |
if (vdef(RENDER)) { |
| 844 |
|
op = addarg(op, vval(RENDER)); |
| 845 |
+ |
bw = strstr(vval(RENDER), "-aa "); |
| 846 |
+ |
if (bw != NULL && atof(bw+4) <= FTINY) |
| 847 |
+ |
overture = 0; |
| 848 |
+ |
} |
| 849 |
|
if (rvdevice != NULL) { |
| 850 |
< |
if (vdef(RVU)) |
| 850 |
> |
if (vdef(RVU)) { |
| 851 |
|
if (vval(RVU)[0] != '-') { |
| 852 |
|
atos(c_rvu, sizeof(c_rvu), vval(RVU)); |
| 853 |
|
po = addarg(po, sskip2(vval(RVU), 1)); |
| 854 |
|
} else |
| 855 |
|
po = addarg(po, vval(RVU)); |
| 856 |
+ |
} |
| 857 |
|
} else { |
| 858 |
< |
if (vdef(RPICT)) |
| 858 |
> |
if (vdef(RPICT)) { |
| 859 |
|
if (vval(RPICT)[0] != '-') { |
| 860 |
|
atos(c_rpict, sizeof(c_rpict), vval(RPICT)); |
| 861 |
|
po = addarg(po, sskip2(vval(RPICT), 1)); |
| 862 |
|
} else |
| 863 |
|
po = addarg(po, vval(RPICT)); |
| 864 |
+ |
} |
| 865 |
|
} |
| 866 |
|
} |
| 867 |
|
|
| 868 |
|
|
| 869 |
|
static void |
| 870 |
|
lowqopts( /* low quality rendering options */ |
| 871 |
< |
register char *op, |
| 871 |
> |
char *op, |
| 872 |
|
char *po |
| 873 |
|
) |
| 874 |
|
{ |
| 930 |
|
d = ambval(); |
| 931 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
| 932 |
|
op += strlen(op); |
| 933 |
< |
op = addarg(op, "-lr 6 -lw .003"); |
| 933 |
> |
op = addarg(op, "-lr 6 -lw .001"); |
| 934 |
|
} |
| 935 |
|
|
| 936 |
|
|
| 937 |
|
static void |
| 938 |
|
medqopts( /* medium quality rendering options */ |
| 939 |
< |
register char *op, |
| 939 |
> |
char *op, |
| 940 |
|
char *po |
| 941 |
|
) |
| 942 |
|
{ |
| 1014 |
|
|
| 1015 |
|
static void |
| 1016 |
|
hiqopts( /* high quality rendering options */ |
| 1017 |
< |
register char *op, |
| 1017 |
> |
char *op, |
| 1018 |
|
char *po |
| 1019 |
|
) |
| 1020 |
|
{ |
| 1084 |
|
d = ambval(); |
| 1085 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
| 1086 |
|
op += strlen(op); |
| 1087 |
< |
op = addarg(op, "-lr 12 -lw 1e-5"); |
| 1087 |
> |
op = addarg(op, "-lr 12 -lw 5e-6"); |
| 1088 |
|
} |
| 1089 |
|
|
| 1090 |
|
|
| 1091 |
+ |
#if defined(_WIN32) || defined(_WIN64) |
| 1092 |
|
static void |
| 1093 |
+ |
setenv( /* set an environment variable */ |
| 1094 |
+ |
char *vname, |
| 1095 |
+ |
char *value |
| 1096 |
+ |
) |
| 1097 |
+ |
{ |
| 1098 |
+ |
char *evp; |
| 1099 |
+ |
|
| 1100 |
+ |
evp = bmalloc(strlen(vname)+strlen(value)+2); |
| 1101 |
+ |
if (evp == NULL) |
| 1102 |
+ |
syserr(progname); |
| 1103 |
+ |
sprintf(evp, "%s=%s", vname, value); |
| 1104 |
+ |
if (putenv(evp) != 0) { |
| 1105 |
+ |
fprintf(stderr, "%s: out of environment space\n", progname); |
| 1106 |
+ |
quit(1); |
| 1107 |
+ |
} |
| 1108 |
+ |
if (!silent) |
| 1109 |
+ |
printf("set %s\n", evp); |
| 1110 |
+ |
} |
| 1111 |
+ |
#endif |
| 1112 |
+ |
|
| 1113 |
+ |
|
| 1114 |
+ |
static void |
| 1115 |
|
xferopts( /* transfer options if indicated */ |
| 1116 |
|
char *ro |
| 1117 |
|
) |
| 1118 |
|
{ |
| 1119 |
|
int fd, n; |
| 1120 |
< |
register char *cp; |
| 1120 |
> |
char *cp; |
| 1121 |
|
|
| 1122 |
|
n = strlen(ro); |
| 1123 |
|
if (n < 2) |
| 1135 |
|
syserr(vval(OPTFILE)); |
| 1136 |
|
sprintf(ro, " @%s", vval(OPTFILE)); |
| 1137 |
|
} |
| 1138 |
< |
#ifdef _WIN32 |
| 1138 |
> |
#if defined(_WIN32) || defined(_WIN64) |
| 1139 |
|
else if (n > 50) { |
| 1140 |
|
setenv("ROPT", ro+1); |
| 1141 |
|
strcpy(ro, " $ROPT"); |
| 1146 |
|
|
| 1147 |
|
static void |
| 1148 |
|
pfiltopts( /* get pfilt options */ |
| 1149 |
< |
register char *po |
| 1149 |
> |
char *po |
| 1150 |
|
) |
| 1151 |
|
{ |
| 1152 |
|
*po = '\0'; |
| 1162 |
|
po = addarg(po, "-m .25"); |
| 1163 |
|
break; |
| 1164 |
|
} |
| 1165 |
< |
if (vdef(PFILT)) |
| 1165 |
> |
if (vdef(PFILT)) { |
| 1166 |
|
if (vval(PFILT)[0] != '-') { |
| 1167 |
|
atos(c_pfilt, sizeof(c_pfilt), vval(PFILT)); |
| 1168 |
|
po = addarg(po, sskip2(vval(PFILT), 1)); |
| 1169 |
|
} else |
| 1170 |
|
po = addarg(po, vval(PFILT)); |
| 1171 |
+ |
} |
| 1172 |
|
} |
| 1173 |
|
|
| 1174 |
|
|
| 1175 |
|
static int |
| 1176 |
|
matchword( /* match white-delimited words */ |
| 1177 |
< |
register char *s1, |
| 1178 |
< |
register char *s2 |
| 1177 |
> |
char *s1, |
| 1178 |
> |
char *s2 |
| 1179 |
|
) |
| 1180 |
|
{ |
| 1181 |
|
while (isspace(*s1)) s1++; |
| 1189 |
|
|
| 1190 |
|
static char * |
| 1191 |
|
specview( /* get proper view spec from vs */ |
| 1192 |
< |
register char *vs |
| 1192 |
> |
char *vs |
| 1193 |
|
) |
| 1194 |
|
{ |
| 1195 |
|
static char vup[7][12] = {"-vu 0 0 -1","-vu 0 -1 0","-vu -1 0 0", |
| 1196 |
|
"-vu 0 0 1", "-vu 1 0 0","-vu 0 1 0","-vu 0 0 1"}; |
| 1197 |
|
static char viewopts[128]; |
| 1198 |
< |
register char *cp; |
| 1198 |
> |
char *cp; |
| 1199 |
|
int xpos, ypos, zpos, viewtype, upax; |
| 1200 |
< |
register int i; |
| 1200 |
> |
int i; |
| 1201 |
|
double cent[3], dim[3], mult, d; |
| 1202 |
|
|
| 1203 |
|
if (vs == NULL || *vs == '-') |
| 1257 |
|
cent[i] += .5*dim[i]; |
| 1258 |
|
} |
| 1259 |
|
mult = vlet(ZONE)=='E' ? 2. : .45 ; |
| 1260 |
< |
sprintf(cp, " -vp %.2g %.2g %.2g -vd %.2g %.2g %.2g", |
| 1260 |
> |
sprintf(cp, " -vp %.3g %.3g %.3g -vd %.3g %.3g %.3g", |
| 1261 |
|
cent[0]+xpos*mult*dim[0], |
| 1262 |
|
cent[1]+ypos*mult*dim[1], |
| 1263 |
|
cent[2]+zpos*mult*dim[2], |
| 1289 |
|
break; |
| 1290 |
|
case VT_PAR: |
| 1291 |
|
d = sqrt(dim[0]*dim[0]+dim[1]*dim[1]+dim[2]*dim[2]); |
| 1292 |
< |
sprintf(cp, " -vh %.2g -vv %.2g", d, d); |
| 1292 |
> |
sprintf(cp, " -vh %.3g -vv %.3g", d, d); |
| 1293 |
|
cp += strlen(cp); |
| 1294 |
|
break; |
| 1295 |
|
case VT_ANG: |
| 1313 |
|
if (cp == viewopts) /* append any additional options */ |
| 1314 |
|
vs++; /* skip prefixed space if unneeded */ |
| 1315 |
|
strcpy(cp, vs); |
| 1316 |
< |
#ifdef _WIN32 |
| 1316 |
> |
#if defined(_WIN32) || defined(_WIN64) |
| 1317 |
|
if (strlen(viewopts) > 40) { |
| 1318 |
|
setenv("VIEW", viewopts); |
| 1319 |
|
return("$VIEW"); |
| 1329 |
|
char *vn /* returned view name */ |
| 1330 |
|
) |
| 1331 |
|
{ |
| 1332 |
< |
register char *mv; |
| 1332 |
> |
char *mv; |
| 1333 |
|
|
| 1334 |
|
if (viewselect != NULL) { /* command-line selected */ |
| 1335 |
|
if (n) /* only do one */ |
| 1359 |
|
} |
| 1360 |
|
numview: |
| 1361 |
|
mv = nvalue(VIEWS, n); /* use view n */ |
| 1362 |
< |
if ((vn != NULL) & (mv != NULL)) |
| 1362 |
> |
if ((vn != NULL) & (mv != NULL)) { |
| 1363 |
|
if (*mv != '-') { |
| 1364 |
< |
register char *mv2 = mv; |
| 1364 |
> |
char *mv2 = mv; |
| 1365 |
|
while (*mv2 && !isspace(*mv2)) |
| 1366 |
|
*vn++ = *mv2++; |
| 1367 |
|
*vn = '\0'; |
| 1368 |
|
} else |
| 1369 |
|
sprintf(vn, "%d", n+1); |
| 1370 |
< |
|
| 1370 |
> |
} |
| 1371 |
|
return(specview(mv)); |
| 1372 |
|
} |
| 1373 |
|
|
| 1374 |
|
|
| 1375 |
|
static int |
| 1376 |
|
myprintview( /* print out selected view */ |
| 1377 |
< |
register char *vopts, |
| 1377 |
> |
char *vopts, |
| 1378 |
|
FILE *fp |
| 1379 |
|
) |
| 1380 |
|
{ |
| 1381 |
|
VIEW vwr; |
| 1382 |
|
char buf[128]; |
| 1383 |
< |
register char *cp; |
| 1384 |
< |
#ifdef _WIN32 |
| 1383 |
> |
char *cp; |
| 1384 |
> |
#if defined(_WIN32) || defined(_WIN64) |
| 1385 |
|
/* XXX Should we allow something like this for all platforms? */ |
| 1386 |
|
/* XXX Or is it still required at all? */ |
| 1387 |
|
again: |
| 1388 |
|
#endif |
| 1389 |
|
if (vopts == NULL) |
| 1390 |
|
return(-1); |
| 1391 |
< |
#ifdef _WIN32 |
| 1391 |
> |
#if defined(_WIN32) || defined(_WIN64) |
| 1392 |
|
if (vopts[0] == '$') { |
| 1393 |
|
vopts = getenv(vopts+1); |
| 1394 |
|
goto again; |
| 1535 |
|
fprintf(stderr, "%s: cannot create\n", pfile); |
| 1536 |
|
quit(1); |
| 1537 |
|
} |
| 1538 |
+ |
pfile[-5] = '\0'; |
| 1539 |
|
pfile = NULL; |
| 1540 |
|
} |
| 1541 |
|
} |
| 1613 |
|
} else { |
| 1614 |
|
if (overture) { /* run overture calculation */ |
| 1615 |
|
sprintf(combuf, |
| 1616 |
< |
"%s%s %s%s -x 64 -y 64 -ps 1 %s > %s", |
| 1617 |
< |
c_rpict, rep, vw, opts, |
| 1616 |
> |
"%s%s %s%s%s -x 64 -y 64 -ps 1 %s > %s", |
| 1617 |
> |
c_rpict, rep, vw, opts, po, |
| 1618 |
|
oct1name, overfile); |
| 1619 |
|
if (!do_rpiece || !next_process(0)) { |
| 1620 |
|
if (runcom(combuf)) { |
| 1861 |
|
return; /* in parent -- noop */ |
| 1862 |
|
exit(0); |
| 1863 |
|
} |
| 1682 |
– |
|
| 1683 |
– |
#ifdef _WIN32 |
| 1684 |
– |
setenv(vname, value) /* set an environment variable */ |
| 1685 |
– |
char *vname, *value; |
| 1686 |
– |
{ |
| 1687 |
– |
register char *evp; |
| 1688 |
– |
|
| 1689 |
– |
evp = bmalloc(strlen(vname)+strlen(value)+2); |
| 1690 |
– |
if (evp == NULL) |
| 1691 |
– |
syserr(progname); |
| 1692 |
– |
sprintf(evp, "%s=%s", vname, value); |
| 1693 |
– |
if (putenv(evp) != 0) { |
| 1694 |
– |
fprintf(stderr, "%s: out of environment space\n", progname); |
| 1695 |
– |
quit(1); |
| 1696 |
– |
} |
| 1697 |
– |
if (!silent) |
| 1698 |
– |
printf("set %s\n", evp); |
| 1699 |
– |
} |
| 1700 |
– |
#endif |
| 1864 |
|
|
| 1865 |
|
|
| 1866 |
|
static void |