| 1 | 
– | 
/* Copyright (c) 1994 Regents of the University of California */ | 
| 2 | 
– | 
 | 
| 1 | 
  | 
#ifndef lint | 
| 2 | 
< | 
static char SCCSid[] = "$SunId$ LBL"; | 
| 2 | 
> | 
static const char       RCSid[] = "$Id$"; | 
| 3 | 
  | 
#endif | 
| 6 | 
– | 
 | 
| 4 | 
  | 
/* | 
| 5 | 
  | 
 * Executive program for oconv, rpict and pfilt | 
| 6 | 
  | 
 */ | 
| 7 | 
  | 
 | 
| 8 | 
  | 
#include "standard.h" | 
| 9 | 
< | 
#include "paths.h" | 
| 9 | 
> | 
 | 
| 10 | 
  | 
#include <ctype.h> | 
| 11 | 
< | 
#include <sys/types.h> | 
| 11 | 
> | 
#include <time.h> | 
| 12 | 
  | 
 | 
| 13 | 
+ | 
#include "platform.h" | 
| 14 | 
+ | 
#include "rtprocess.h" | 
| 15 | 
+ | 
#include "view.h" | 
| 16 | 
+ | 
#include "paths.h" | 
| 17 | 
+ | 
#include "vars.h" | 
| 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; | 
| 19 | 
> | 
#ifdef _WIN32 | 
| 20 | 
> | 
  #define DELCMD "del" | 
| 21 | 
> | 
  #define RENAMECMD "rename" | 
| 22 | 
> | 
#else | 
| 23 | 
> | 
  #define DELCMD "rm -f" | 
| 24 | 
> | 
  #define RENAMECMD "mv" | 
| 25 | 
> | 
  #include <sys/types.h> | 
| 26 | 
> | 
  #include <sys/wait.h> | 
| 27 | 
> | 
#endif | 
| 28 | 
  | 
 | 
| 29 | 
< | 
int     onevalue(), catvalues(), boolvalue(), | 
| 30 | 
< | 
        qualvalue(), fltvalue(), intvalue(); | 
| 31 | 
< | 
 | 
| 32 | 
< | 
                                /* variables */ | 
| 33 | 
< | 
#define OBJECT          0               /* object files */ | 
| 34 | 
< | 
#define SCENE           1               /* scene files */ | 
| 35 | 
< | 
#define MATERIAL        2               /* material files */ | 
| 36 | 
< | 
#define ILLUM           3               /* mkillum input files */ | 
| 37 | 
< | 
#define MKILLUM         4               /* mkillum options */ | 
| 38 | 
< | 
#define RENDER          5               /* rendering options */ | 
| 39 | 
< | 
#define OCONV           6               /* oconv options */ | 
| 40 | 
< | 
#define PFILT           7               /* pfilt options */ | 
| 41 | 
< | 
#define VIEW            8               /* view(s) for picture(s) */ | 
| 42 | 
< | 
#define ZONE            9               /* simulation zone */ | 
| 43 | 
< | 
#define QUALITY         10              /* desired rendering quality */ | 
| 44 | 
< | 
#define OCTREE          11              /* octree file name */ | 
| 45 | 
< | 
#define PICTURE         12              /* picture file name */ | 
| 46 | 
< | 
#define AMBFILE         13              /* ambient file name */ | 
| 47 | 
< | 
#define OPTFILE         14              /* rendering options file */ | 
| 48 | 
< | 
#define EXPOSURE        15              /* picture exposure setting */ | 
| 49 | 
< | 
#define RESOLUTION      16              /* maximum picture resolution */ | 
| 50 | 
< | 
#define UP              17              /* view up (X, Y or Z) */ | 
| 51 | 
< | 
#define INDIRECT        18              /* indirection in lighting */ | 
| 52 | 
< | 
#define DETAIL          19              /* level of scene detail */ | 
| 53 | 
< | 
#define PENUMBRAS       20              /* shadow penumbras are desired */ | 
| 54 | 
< | 
#define VARIABILITY     21              /* level of light variability */ | 
| 55 | 
< | 
#define REPORT          22              /* report frequency and errfile */ | 
| 56 | 
< | 
#define RAWSAVE         23              /* save raw picture file */ | 
| 29 | 
> | 
                                /* variables (alphabetical by name) */ | 
| 30 | 
> | 
#define AMBFILE         0               /* ambient file name */ | 
| 31 | 
> | 
#define DETAIL          1               /* level of scene detail */ | 
| 32 | 
> | 
#define EXPOSURE        2               /* picture exposure setting */ | 
| 33 | 
> | 
#define EYESEP          3               /* interocular distance */ | 
| 34 | 
> | 
#define ILLUM           4               /* mkillum input files */ | 
| 35 | 
> | 
#define INDIRECT        5               /* indirection in lighting */ | 
| 36 | 
> | 
#define MATERIAL        6               /* material files */ | 
| 37 | 
> | 
#define MKILLUM         7               /* mkillum options */ | 
| 38 | 
> | 
#define OBJECT          8               /* object files */ | 
| 39 | 
> | 
#define OCONV           9               /* oconv options */ | 
| 40 | 
> | 
#define OCTREE          10              /* octree file name */ | 
| 41 | 
> | 
#define OPTFILE         11              /* rendering options file */ | 
| 42 | 
> | 
#define PENUMBRAS       12              /* shadow penumbras are desired */ | 
| 43 | 
> | 
#define PFILT           13              /* pfilt options */ | 
| 44 | 
> | 
#define PICTURE         14              /* picture file root name */ | 
| 45 | 
> | 
#define QUALITY         15              /* desired rendering quality */ | 
| 46 | 
> | 
#define RAWFILE         16              /* raw picture file root name */ | 
| 47 | 
> | 
#define RENDER          17              /* rendering options */ | 
| 48 | 
> | 
#define REPORT          18              /* report frequency and errfile */ | 
| 49 | 
> | 
#define RESOLUTION      19              /* maximum picture resolution */ | 
| 50 | 
> | 
#define RPICT           20              /* rpict parameters */ | 
| 51 | 
> | 
#define RVU             21              /* rvu parameters */ | 
| 52 | 
> | 
#define SCENE           22              /* scene files */ | 
| 53 | 
> | 
#define UP              23              /* view up (X, Y or Z) */ | 
| 54 | 
> | 
#define VARIABILITY     24              /* level of light variability */ | 
| 55 | 
> | 
#define VIEWS           25              /* view(s) for picture(s) */ | 
| 56 | 
> | 
#define ZFILE           26              /* distance file root name */ | 
| 57 | 
> | 
#define ZONE            27              /* simulation zone */ | 
| 58 | 
  | 
                                /* total number of variables */ | 
| 59 | 
< | 
#define NVARS           24 | 
| 59 | 
> | 
int NVARS = 28; | 
| 60 | 
  | 
 | 
| 61 | 
< | 
VARIABLE        vv[NVARS] = {           /* variable-value pairs */ | 
| 62 | 
< | 
        {"objects",     3,      0,      NULL,   catvalues}, | 
| 63 | 
< | 
        {"scene",       3,      0,      NULL,   catvalues}, | 
| 64 | 
< | 
        {"materials",   3,      0,      NULL,   catvalues}, | 
| 61 | 
> | 
VARIABLE        vv[] = {                /* variable-value pairs */ | 
| 62 | 
> | 
        {"AMBFILE",     3,      0,      NULL,   onevalue}, | 
| 63 | 
> | 
        {"DETAIL",      3,      0,      NULL,   qualvalue}, | 
| 64 | 
> | 
        {"EXPOSURE",    3,      0,      NULL,   fltvalue}, | 
| 65 | 
> | 
        {"EYESEP",      3,      0,      NULL,   fltvalue}, | 
| 66 | 
  | 
        {"illum",       3,      0,      NULL,   catvalues}, | 
| 67 | 
+ | 
        {"INDIRECT",    3,      0,      NULL,   intvalue}, | 
| 68 | 
+ | 
        {"materials",   3,      0,      NULL,   catvalues}, | 
| 69 | 
  | 
        {"mkillum",     3,      0,      NULL,   catvalues}, | 
| 70 | 
< | 
        {"render",      3,      0,      NULL,   catvalues}, | 
| 70 | 
> | 
        {"objects",     3,      0,      NULL,   catvalues}, | 
| 71 | 
  | 
        {"oconv",       3,      0,      NULL,   catvalues}, | 
| 64 | 
– | 
        {"pfilt",       2,      0,      NULL,   catvalues}, | 
| 65 | 
– | 
        {"view",        2,      0,      NULL,   NULL}, | 
| 66 | 
– | 
        {"ZONE",        2,      0,      NULL,   onevalue}, | 
| 67 | 
– | 
        {"QUALITY",     3,      0,      NULL,   qualvalue}, | 
| 72 | 
  | 
        {"OCTREE",      3,      0,      NULL,   onevalue}, | 
| 69 | 
– | 
        {"PICTURE",     3,      0,      NULL,   onevalue}, | 
| 70 | 
– | 
        {"AMBFILE",     3,      0,      NULL,   onevalue}, | 
| 73 | 
  | 
        {"OPTFILE",     3,      0,      NULL,   onevalue}, | 
| 74 | 
< | 
        {"EXPOSURE",    3,      0,      NULL,   fltvalue}, | 
| 74 | 
> | 
        {"PENUMBRAS",   3,      0,      NULL,   boolvalue}, | 
| 75 | 
> | 
        {"pfilt",       2,      0,      NULL,   catvalues}, | 
| 76 | 
> | 
        {"PICTURE",     3,      0,      NULL,   onevalue}, | 
| 77 | 
> | 
        {"QUALITY",     3,      0,      NULL,   qualvalue}, | 
| 78 | 
> | 
        {"RAWFILE",     3,      0,      NULL,   onevalue}, | 
| 79 | 
> | 
        {"render",      3,      0,      NULL,   catvalues}, | 
| 80 | 
> | 
        {"REPORT",      3,      0,      NULL,   onevalue}, | 
| 81 | 
  | 
        {"RESOLUTION",  3,      0,      NULL,   onevalue}, | 
| 82 | 
+ | 
        {"rpict",       3,      0,      NULL,   catvalues}, | 
| 83 | 
+ | 
        {"rvu",         3,      0,      NULL,   catvalues}, | 
| 84 | 
+ | 
        {"scene",       3,      0,      NULL,   catvalues}, | 
| 85 | 
  | 
        {"UP",          2,      0,      NULL,   onevalue}, | 
| 75 | 
– | 
        {"INDIRECT",    3,      0,      NULL,   intvalue}, | 
| 76 | 
– | 
        {"DETAIL",      3,      0,      NULL,   qualvalue}, | 
| 77 | 
– | 
        {"PENUMBRAS",   3,      0,      NULL,   boolvalue}, | 
| 86 | 
  | 
        {"VARIABILITY", 3,      0,      NULL,   qualvalue}, | 
| 87 | 
< | 
        {"REPORT",      3,      0,      NULL,   onevalue}, | 
| 88 | 
< | 
        {"RAWSAVE",     3,      0,      NULL,   boolvalue}, | 
| 87 | 
> | 
        {"view",        2,      0,      NULL,   NULL}, | 
| 88 | 
> | 
        {"ZFILE",       2,      0,      NULL,   onevalue}, | 
| 89 | 
> | 
        {"ZONE",        2,      0,      NULL,   onevalue}, | 
| 90 | 
  | 
}; | 
| 91 | 
  | 
 | 
| 83 | 
– | 
VARIABLE        *matchvar(); | 
| 84 | 
– | 
char    *nvalue(); | 
| 85 | 
– | 
 | 
| 86 | 
– | 
#define UPPER(c)        ((c)&~0x20)     /* ASCII trick */ | 
| 87 | 
– | 
 | 
| 88 | 
– | 
#define vnam(vc)        (vv[vc].name) | 
| 89 | 
– | 
#define vdef(vc)        (vv[vc].nass) | 
| 90 | 
– | 
#define vval(vc)        (vv[vc].value) | 
| 91 | 
– | 
#define vint(vc)        atoi(vval(vc)) | 
| 92 | 
– | 
#define vlet(vc)        UPPER(vval(vc)[0]) | 
| 93 | 
– | 
#define vscale          vlet | 
| 94 | 
– | 
#define vbool(vc)       (vlet(vc)=='T') | 
| 95 | 
– | 
 | 
| 96 | 
– | 
#define HIGH            'H' | 
| 97 | 
– | 
#define MEDIUM          'M' | 
| 98 | 
– | 
#define LOW             'L' | 
| 99 | 
– | 
 | 
| 92 | 
  | 
                                /* overture calculation file */ | 
| 93 | 
< | 
#ifdef NIX | 
| 94 | 
< | 
char    overfile[] = "overture.raw"; | 
| 93 | 
> | 
#ifdef NULL_DEVICE | 
| 94 | 
> | 
char    overfile[] = NULL_DEVICE; | 
| 95 | 
  | 
#else | 
| 96 | 
< | 
char    overfile[] = "/dev/null"; | 
| 96 | 
> | 
char    overfile[] = "overture.unf"; | 
| 97 | 
  | 
#endif | 
| 98 | 
  | 
 | 
| 107 | 
– | 
extern time_t   fdate(), time(); | 
| 99 | 
  | 
 | 
| 100 | 
  | 
time_t  scenedate;              /* date of latest scene or object file */ | 
| 101 | 
  | 
time_t  octreedate;             /* date of octree */ | 
| 111 | 
  | 
int     explicate = 0;          /* explicate variables */ | 
| 112 | 
  | 
int     silent = 0;             /* do work silently */ | 
| 113 | 
  | 
int     touchonly = 0;          /* touch files only */ | 
| 114 | 
< | 
int     noaction = 0;           /* don't do anything */ | 
| 114 | 
> | 
int     nprocs = 1;             /* maximum executing processes */ | 
| 115 | 
  | 
int     sayview = 0;            /* print view out */ | 
| 116 | 
< | 
char    *rvdevice = NULL;       /* rview output device */ | 
| 116 | 
> | 
char    *rvdevice = NULL;       /* rvu output device */ | 
| 117 | 
  | 
char    *viewselect = NULL;     /* specific view only */ | 
| 118 | 
  | 
 | 
| 119 | 
+ | 
#define DEF_RPICT_PATH  "rpict"         /* default rpict path */ | 
| 120 | 
+ | 
 | 
| 121 | 
+ | 
                                /* command paths */ | 
| 122 | 
+ | 
char    c_oconv[256] = "oconv"; | 
| 123 | 
+ | 
char    c_mkillum[256] = "mkillum"; | 
| 124 | 
+ | 
char    c_rvu[256] = "rvu"; | 
| 125 | 
+ | 
char    c_rpict[256] = DEF_RPICT_PATH; | 
| 126 | 
+ | 
char    c_rpiece[] = "rpiece"; | 
| 127 | 
+ | 
char    c_pfilt[256] = "pfilt"; | 
| 128 | 
+ | 
 | 
| 129 | 
  | 
int     overture = 0;           /* overture calculation needed */ | 
| 130 | 
  | 
 | 
| 131 | 
+ | 
int     children_running = 0;   /* set negative in children */ | 
| 132 | 
+ | 
 | 
| 133 | 
  | 
char    *progname;              /* global argv[0] */ | 
| 134 | 
  | 
char    *rifname;               /* global rad input file name */ | 
| 135 | 
  | 
 | 
| 136 | 
< | 
char    radname[MAXPATH];       /* root Radiance file name */ | 
| 136 | 
> | 
char    radname[PATH_MAX];      /* root Radiance file name */ | 
| 137 | 
  | 
 | 
| 138 | 
+ | 
#define inchild()       (children_running < 0) | 
| 139 | 
  | 
 | 
| 140 | 
< | 
main(argc, argv) | 
| 141 | 
< | 
int     argc; | 
| 142 | 
< | 
char    *argv[]; | 
| 140 | 
> | 
static void rootname(char       *rn, char       *fn); | 
| 141 | 
> | 
static time_t checklast(char    *fnames); | 
| 142 | 
> | 
static char * newfname(char     *orig, int      pred); | 
| 143 | 
> | 
static void checkfiles(void); | 
| 144 | 
> | 
static void getoctcube(double   org[3], double  *sizp); | 
| 145 | 
> | 
static void setdefaults(void); | 
| 146 | 
> | 
static void oconv(void); | 
| 147 | 
> | 
static char * addarg(char       *op, char       *arg); | 
| 148 | 
> | 
static void oconvopts(char      *oo); | 
| 149 | 
> | 
static void mkillumopts(char    *mo); | 
| 150 | 
> | 
static void checkambfile(void); | 
| 151 | 
> | 
static double ambval(void); | 
| 152 | 
> | 
static void renderopts(char     *op, char       *po); | 
| 153 | 
> | 
static void lowqopts(char       *op, char       *po); | 
| 154 | 
> | 
static void medqopts(char       *op, char       *po); | 
| 155 | 
> | 
static void hiqopts(char        *op, char       *po); | 
| 156 | 
> | 
static void xferopts(char       *ro); | 
| 157 | 
> | 
static void pfiltopts(char      *po); | 
| 158 | 
> | 
static int matchword(char       *s1, char       *s2); | 
| 159 | 
> | 
static char * specview(char     *vs); | 
| 160 | 
> | 
static char * getview(int       n, char *vn); | 
| 161 | 
> | 
static int myprintview(char     *vopts, FILE    *fp); | 
| 162 | 
> | 
static void rvu(char    *opts, char     *po); | 
| 163 | 
> | 
static void rpict(char  *opts, char     *po); | 
| 164 | 
> | 
static int touch(char   *fn); | 
| 165 | 
> | 
static int runcom(char  *cs); | 
| 166 | 
> | 
static int rmfile(char  *fn); | 
| 167 | 
> | 
static int mvfile(char  *fold, char     *fnew); | 
| 168 | 
> | 
static int next_process(int     reserve); | 
| 169 | 
> | 
static void wait_process(int    all); | 
| 170 | 
> | 
static void finish_process(void); | 
| 171 | 
> | 
static void badvalue(int        vc); | 
| 172 | 
> | 
static void syserr(char *s); | 
| 173 | 
> | 
 | 
| 174 | 
> | 
 | 
| 175 | 
> | 
int | 
| 176 | 
> | 
main( | 
| 177 | 
> | 
        int     argc, | 
| 178 | 
> | 
        char    *argv[] | 
| 179 | 
> | 
) | 
| 180 | 
  | 
{ | 
| 181 | 
  | 
        char    ropts[512]; | 
| 182 | 
  | 
        char    popts[64]; | 
| 190 | 
  | 
                        silent++; | 
| 191 | 
  | 
                        break; | 
| 192 | 
  | 
                case 'n': | 
| 193 | 
< | 
                        noaction++; | 
| 193 | 
> | 
                        nprocs = 0; | 
| 194 | 
  | 
                        break; | 
| 195 | 
+ | 
                case 'N': | 
| 196 | 
+ | 
                        nprocs = atoi(argv[++i]); | 
| 197 | 
+ | 
                        if (nprocs < 0) | 
| 198 | 
+ | 
                                nprocs = 0; | 
| 199 | 
+ | 
                        break; | 
| 200 | 
  | 
                case 't': | 
| 201 | 
  | 
                        touchonly++; | 
| 202 | 
  | 
                        break; | 
| 224 | 
  | 
                                /* assign Radiance root file name */ | 
| 225 | 
  | 
        rootname(radname, rifname); | 
| 226 | 
  | 
                                /* load variable values */ | 
| 227 | 
< | 
        load(rifname); | 
| 227 | 
> | 
        loadvars(rifname); | 
| 228 | 
  | 
                                /* get any additional assignments */ | 
| 229 | 
  | 
        for (i++; i < argc; i++) | 
| 230 | 
< | 
                setvariable(argv[i]); | 
| 230 | 
> | 
                if (setvariable(argv[i], matchvar) < 0) { | 
| 231 | 
> | 
                        fprintf(stderr, "%s: unknown variable: %s\n", | 
| 232 | 
> | 
                                        progname, argv[i]); | 
| 233 | 
> | 
                        quit(1); | 
| 234 | 
> | 
                } | 
| 235 | 
  | 
                                /* check assignments */ | 
| 236 | 
  | 
        checkvalues(); | 
| 237 | 
  | 
                                /* check files and dates */ | 
| 240 | 
  | 
        setdefaults(); | 
| 241 | 
  | 
                                /* print all values if requested */ | 
| 242 | 
  | 
        if (explicate) | 
| 243 | 
< | 
                printvals(); | 
| 243 | 
> | 
                printvars(stdout); | 
| 244 | 
  | 
                                /* build octree (and run mkillum) */ | 
| 245 | 
  | 
        oconv(); | 
| 246 | 
  | 
                                /* check date on ambient file */ | 
| 249 | 
  | 
        renderopts(ropts, popts); | 
| 250 | 
  | 
        xferopts(ropts); | 
| 251 | 
  | 
        if (rvdevice != NULL) | 
| 252 | 
< | 
                rview(ropts, popts); | 
| 252 | 
> | 
                rvu(ropts, popts); | 
| 253 | 
  | 
        else | 
| 254 | 
  | 
                rpict(ropts, popts); | 
| 255 | 
< | 
        exit(0); | 
| 255 | 
> | 
        quit(0); | 
| 256 | 
  | 
userr: | 
| 257 | 
  | 
        fprintf(stderr, | 
| 258 | 
< | 
"Usage: %s [-s][-n][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n", | 
| 258 | 
> | 
"Usage: %s [-w][-s][-n|-N npr][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n", | 
| 259 | 
  | 
                        progname); | 
| 260 | 
< | 
        exit(1); | 
| 260 | 
> | 
        quit(1); | 
| 261 | 
> | 
        return 1; /* pro forma return */ | 
| 262 | 
  | 
} | 
| 263 | 
  | 
 | 
| 264 | 
  | 
 | 
| 265 | 
< | 
rootname(rn, fn)                /* remove tail from end of fn */ | 
| 266 | 
< | 
register char   *rn, *fn; | 
| 265 | 
> | 
static void | 
| 266 | 
> | 
rootname(               /* remove tail from end of fn */ | 
| 267 | 
> | 
        register char   *rn, | 
| 268 | 
> | 
        register char   *fn | 
| 269 | 
> | 
) | 
| 270 | 
  | 
{ | 
| 271 | 
  | 
        char    *tp, *dp; | 
| 272 | 
  | 
 | 
| 273 | 
< | 
        for (tp = NULL, dp = rn; *rn = *fn++; rn++) | 
| 273 | 
> | 
        for (tp = NULL, dp = rn; (*rn = *fn++); rn++) | 
| 274 | 
  | 
                if (ISDIRSEP(*rn)) | 
| 275 | 
  | 
                        dp = rn; | 
| 276 | 
  | 
                else if (*rn == '.') | 
| 280 | 
  | 
} | 
| 281 | 
  | 
 | 
| 282 | 
  | 
 | 
| 283 | 
< | 
#define NOCHAR  127             /* constant for character to delete */ | 
| 284 | 
< | 
 | 
| 285 | 
< | 
 | 
| 286 | 
< | 
load(rfname)                    /* load Radiance simulation file */ | 
| 233 | 
< | 
char    *rfname; | 
| 283 | 
> | 
static time_t | 
| 284 | 
> | 
checklast(                      /* check files and find most recent */ | 
| 285 | 
> | 
        register char   *fnames | 
| 286 | 
> | 
) | 
| 287 | 
  | 
{ | 
| 288 | 
< | 
        FILE    *fp; | 
| 236 | 
< | 
        char    buf[512]; | 
| 237 | 
< | 
        register char   *cp; | 
| 238 | 
< | 
 | 
| 239 | 
< | 
        if (rfname == NULL) | 
| 240 | 
< | 
                fp = stdin; | 
| 241 | 
< | 
        else if ((fp = fopen(rfname, "r")) == NULL) | 
| 242 | 
< | 
                syserr(rfname); | 
| 243 | 
< | 
        while (fgetline(buf, sizeof(buf), fp) != NULL) { | 
| 244 | 
< | 
                for (cp = buf; *cp; cp++) { | 
| 245 | 
< | 
                        switch (*cp) { | 
| 246 | 
< | 
                        case '\\': | 
| 247 | 
< | 
                                *cp++ = NOCHAR; | 
| 248 | 
< | 
                                continue; | 
| 249 | 
< | 
                        case '#': | 
| 250 | 
< | 
                                *cp = '\0'; | 
| 251 | 
< | 
                                break; | 
| 252 | 
< | 
                        default: | 
| 253 | 
< | 
                                continue; | 
| 254 | 
< | 
                        } | 
| 255 | 
< | 
                        break; | 
| 256 | 
< | 
                } | 
| 257 | 
< | 
                setvariable(buf); | 
| 258 | 
< | 
        } | 
| 259 | 
< | 
        fclose(fp); | 
| 260 | 
< | 
} | 
| 261 | 
< | 
 | 
| 262 | 
< | 
 | 
| 263 | 
< | 
setvariable(ass)                /* assign variable according to string */ | 
| 264 | 
< | 
register char   *ass; | 
| 265 | 
< | 
{ | 
| 266 | 
< | 
        char    varname[32]; | 
| 267 | 
< | 
        int     n; | 
| 268 | 
< | 
        register char   *cp; | 
| 269 | 
< | 
        register VARIABLE       *vp; | 
| 270 | 
< | 
        register int    i; | 
| 271 | 
< | 
 | 
| 272 | 
< | 
        while (isspace(*ass))           /* skip leading space */ | 
| 273 | 
< | 
                ass++; | 
| 274 | 
< | 
        cp = varname;                   /* extract name */ | 
| 275 | 
< | 
        while (cp < varname+sizeof(varname)-1 | 
| 276 | 
< | 
                        && *ass && !isspace(*ass) && *ass != '=') | 
| 277 | 
< | 
                *cp++ = *ass++; | 
| 278 | 
< | 
        *cp = '\0'; | 
| 279 | 
< | 
        if (!varname[0]) | 
| 280 | 
< | 
                return;         /* no variable name! */ | 
| 281 | 
< | 
                                        /* trim value */ | 
| 282 | 
< | 
        while (isspace(*ass) || *ass == '=') | 
| 283 | 
< | 
                ass++; | 
| 284 | 
< | 
        for (n = strlen(ass); n > 0; n--) | 
| 285 | 
< | 
                if (!isspace(ass[n-1])) | 
| 286 | 
< | 
                        break; | 
| 287 | 
< | 
        if (!n && !nowarn) { | 
| 288 | 
< | 
                fprintf(stderr, "%s: warning - missing value for variable '%s'\n", | 
| 289 | 
< | 
                                progname, varname); | 
| 290 | 
< | 
                return; | 
| 291 | 
< | 
        } | 
| 292 | 
< | 
                                        /* match variable from list */ | 
| 293 | 
< | 
        vp = matchvar(varname); | 
| 294 | 
< | 
        if (vp == NULL) { | 
| 295 | 
< | 
                fprintf(stderr, "%s: unknown variable '%s'\n", | 
| 296 | 
< | 
                                progname, varname); | 
| 297 | 
< | 
                exit(1); | 
| 298 | 
< | 
        } | 
| 299 | 
< | 
                                        /* assign new value */ | 
| 300 | 
< | 
        if (i = vp->nass) { | 
| 301 | 
< | 
                cp = vp->value; | 
| 302 | 
< | 
                while (i--) | 
| 303 | 
< | 
                        while (*cp++) | 
| 304 | 
< | 
                                ; | 
| 305 | 
< | 
                i = cp - vp->value; | 
| 306 | 
< | 
                vp->value = realloc(vp->value, i+n+1); | 
| 307 | 
< | 
        } else | 
| 308 | 
< | 
                vp->value = malloc(n+1); | 
| 309 | 
< | 
        if (vp->value == NULL) | 
| 310 | 
< | 
                syserr(progname); | 
| 311 | 
< | 
        cp = vp->value+i;               /* copy value, squeezing spaces */ | 
| 312 | 
< | 
        *cp = *ass; | 
| 313 | 
< | 
        for (i = 1; i <= n; i++) { | 
| 314 | 
< | 
                if (ass[i] == NOCHAR) | 
| 315 | 
< | 
                        continue; | 
| 316 | 
< | 
                if (isspace(*cp)) | 
| 317 | 
< | 
                        while (isspace(ass[i])) | 
| 318 | 
< | 
                                i++; | 
| 319 | 
< | 
                *++cp = ass[i]; | 
| 320 | 
< | 
        } | 
| 321 | 
< | 
        if (isspace(*cp))               /* remove trailing space */ | 
| 322 | 
< | 
                *cp = '\0'; | 
| 323 | 
< | 
        vp->nass++; | 
| 324 | 
< | 
} | 
| 325 | 
< | 
 | 
| 326 | 
< | 
 | 
| 327 | 
< | 
VARIABLE * | 
| 328 | 
< | 
matchvar(nam)                   /* match a variable by its name */ | 
| 329 | 
< | 
char    *nam; | 
| 330 | 
< | 
{ | 
| 331 | 
< | 
        int     n = strlen(nam); | 
| 332 | 
< | 
        register int    i; | 
| 333 | 
< | 
 | 
| 334 | 
< | 
        for (i = 0; i < NVARS; i++) | 
| 335 | 
< | 
                if (n >= vv[i].nick && !strncmp(nam, vv[i].name, n)) | 
| 336 | 
< | 
                        return(vv+i); | 
| 337 | 
< | 
        return(NULL); | 
| 338 | 
< | 
} | 
| 339 | 
< | 
 | 
| 340 | 
< | 
 | 
| 341 | 
< | 
char * | 
| 342 | 
< | 
nvalue(vp, n)                   /* return nth variable value */ | 
| 343 | 
< | 
VARIABLE        *vp; | 
| 344 | 
< | 
register int    n; | 
| 345 | 
< | 
{ | 
| 346 | 
< | 
        register char   *cp; | 
| 347 | 
< | 
 | 
| 348 | 
< | 
        if (vp == NULL | n < 0 | n >= vp->nass) | 
| 349 | 
< | 
                return(NULL); | 
| 350 | 
< | 
        cp = vp->value; | 
| 351 | 
< | 
        while (n--) | 
| 352 | 
< | 
                while (*cp++) | 
| 353 | 
< | 
                        ; | 
| 354 | 
< | 
        return(cp); | 
| 355 | 
< | 
} | 
| 356 | 
< | 
 | 
| 357 | 
< | 
 | 
| 358 | 
< | 
checkvalues()                   /* check assignments */ | 
| 359 | 
< | 
{ | 
| 360 | 
< | 
        register int    i; | 
| 361 | 
< | 
 | 
| 362 | 
< | 
        for (i = 0; i < NVARS; i++) | 
| 363 | 
< | 
                if (vv[i].fixval != NULL) | 
| 364 | 
< | 
                        (*vv[i].fixval)(vv+i); | 
| 365 | 
< | 
} | 
| 366 | 
< | 
 | 
| 367 | 
< | 
 | 
| 368 | 
< | 
onevalue(vp)                    /* only one assignment for this variable */ | 
| 369 | 
< | 
register VARIABLE       *vp; | 
| 370 | 
< | 
{ | 
| 371 | 
< | 
        if (vp->nass < 2) | 
| 372 | 
< | 
                return; | 
| 373 | 
< | 
        if (!nowarn) | 
| 374 | 
< | 
                fprintf(stderr, | 
| 375 | 
< | 
                "%s: warning - multiple assignment of variable '%s'\n", | 
| 376 | 
< | 
                        progname, vp->name); | 
| 377 | 
< | 
        do | 
| 378 | 
< | 
                vp->value += strlen(vp->value)+1; | 
| 379 | 
< | 
        while (--vp->nass > 1); | 
| 380 | 
< | 
} | 
| 381 | 
< | 
 | 
| 382 | 
< | 
 | 
| 383 | 
< | 
catvalues(vp)                   /* concatenate variable values */ | 
| 384 | 
< | 
register VARIABLE       *vp; | 
| 385 | 
< | 
{ | 
| 386 | 
< | 
        register char   *cp; | 
| 387 | 
< | 
 | 
| 388 | 
< | 
        if (vp->nass < 2) | 
| 389 | 
< | 
                return; | 
| 390 | 
< | 
        for (cp = vp->value; vp->nass > 1; vp->nass--) { | 
| 391 | 
< | 
                while (*cp) | 
| 392 | 
< | 
                        cp++; | 
| 393 | 
< | 
                *cp++ = ' '; | 
| 394 | 
< | 
        } | 
| 395 | 
< | 
} | 
| 396 | 
< | 
 | 
| 397 | 
< | 
 | 
| 398 | 
< | 
int | 
| 399 | 
< | 
badmatch(tv, cv)                /* case insensitive truncated comparison */ | 
| 400 | 
< | 
register char   *tv, *cv; | 
| 401 | 
< | 
{ | 
| 402 | 
< | 
        if (!*tv) return(1);            /* null string cannot match */ | 
| 403 | 
< | 
        do | 
| 404 | 
< | 
                if (UPPER(*tv) != *cv++) | 
| 405 | 
< | 
                        return(1); | 
| 406 | 
< | 
        while (*++tv); | 
| 407 | 
< | 
        return(0);              /* OK */ | 
| 408 | 
< | 
} | 
| 409 | 
< | 
 | 
| 410 | 
< | 
 | 
| 411 | 
< | 
boolvalue(vp)                   /* check boolean for legal values */ | 
| 412 | 
< | 
register VARIABLE       *vp; | 
| 413 | 
< | 
{ | 
| 414 | 
< | 
        if (!vp->nass) return; | 
| 415 | 
< | 
        onevalue(vp); | 
| 416 | 
< | 
        switch (UPPER(vp->value[0])) { | 
| 417 | 
< | 
        case 'T': | 
| 418 | 
< | 
                if (badmatch(vp->value, "TRUE")) break; | 
| 419 | 
< | 
                return; | 
| 420 | 
< | 
        case 'F': | 
| 421 | 
< | 
                if (badmatch(vp->value, "FALSE")) break; | 
| 422 | 
< | 
                return; | 
| 423 | 
< | 
        } | 
| 424 | 
< | 
        fprintf(stderr, "%s: illegal value for boolean variable '%s'\n", | 
| 425 | 
< | 
                        progname, vp->name); | 
| 426 | 
< | 
        exit(1); | 
| 427 | 
< | 
} | 
| 428 | 
< | 
 | 
| 429 | 
< | 
 | 
| 430 | 
< | 
qualvalue(vp)                   /* check qualitative var. for legal values */ | 
| 431 | 
< | 
register VARIABLE       *vp; | 
| 432 | 
< | 
{ | 
| 433 | 
< | 
        if (!vp->nass) return; | 
| 434 | 
< | 
        onevalue(vp); | 
| 435 | 
< | 
        switch (UPPER(vp->value[0])) { | 
| 436 | 
< | 
        case 'L': | 
| 437 | 
< | 
                if (badmatch(vp->value, "LOW")) break; | 
| 438 | 
< | 
                return; | 
| 439 | 
< | 
        case 'M': | 
| 440 | 
< | 
                if (badmatch(vp->value, "MEDIUM")) break; | 
| 441 | 
< | 
                return; | 
| 442 | 
< | 
        case 'H': | 
| 443 | 
< | 
                if (badmatch(vp->value, "HIGH")) break; | 
| 444 | 
< | 
                return; | 
| 445 | 
< | 
        } | 
| 446 | 
< | 
        fprintf(stderr, "%s: illegal value for qualitative variable '%s'\n", | 
| 447 | 
< | 
                        progname, vp->name); | 
| 448 | 
< | 
        exit(1); | 
| 449 | 
< | 
} | 
| 450 | 
< | 
 | 
| 451 | 
< | 
 | 
| 452 | 
< | 
intvalue(vp)                    /* check integer variable for legal values */ | 
| 453 | 
< | 
register VARIABLE       *vp; | 
| 454 | 
< | 
{ | 
| 455 | 
< | 
        if (!vp->nass) return; | 
| 456 | 
< | 
        onevalue(vp); | 
| 457 | 
< | 
        if (isint(vp->value)) return; | 
| 458 | 
< | 
        fprintf(stderr, "%s: illegal value for integer variable '%s'\n", | 
| 459 | 
< | 
                        progname, vp->name); | 
| 460 | 
< | 
        exit(1); | 
| 461 | 
< | 
} | 
| 462 | 
< | 
 | 
| 463 | 
< | 
 | 
| 464 | 
< | 
fltvalue(vp)                    /* check float variable for legal values */ | 
| 465 | 
< | 
register VARIABLE       *vp; | 
| 466 | 
< | 
{ | 
| 467 | 
< | 
        if (!vp->nass) return; | 
| 468 | 
< | 
        onevalue(vp); | 
| 469 | 
< | 
        if (isflt(vp->value)) return; | 
| 470 | 
< | 
        fprintf(stderr, "%s: illegal value for real variable '%s'\n", | 
| 471 | 
< | 
                        progname, vp->name); | 
| 472 | 
< | 
        exit(1); | 
| 473 | 
< | 
} | 
| 474 | 
< | 
 | 
| 475 | 
< | 
 | 
| 476 | 
< | 
time_t | 
| 477 | 
< | 
checklast(fnames)                       /* check files and find most recent */ | 
| 478 | 
< | 
register char   *fnames; | 
| 479 | 
< | 
{ | 
| 480 | 
< | 
        char    thisfile[MAXPATH]; | 
| 288 | 
> | 
        char    thisfile[PATH_MAX]; | 
| 289 | 
  | 
        time_t  thisdate, lastdate = 0; | 
| 482 | 
– | 
        register char   *cp; | 
| 290 | 
  | 
 | 
| 291 | 
  | 
        if (fnames == NULL) | 
| 292 | 
  | 
                return(0); | 
| 293 | 
< | 
        while (*fnames) { | 
| 294 | 
< | 
                while (isspace(*fnames)) fnames++; | 
| 295 | 
< | 
                cp = thisfile; | 
| 296 | 
< | 
                while (*fnames && !isspace(*fnames)) | 
| 297 | 
< | 
                        *cp++ = *fnames++; | 
| 298 | 
< | 
                *cp = '\0'; | 
| 293 | 
> | 
        while ((fnames = nextword(thisfile, PATH_MAX, fnames)) != NULL) { | 
| 294 | 
> | 
                if (thisfile[0] == '!' || | 
| 295 | 
> | 
                                (thisfile[0] == '\\' && thisfile[1] == '!')) { | 
| 296 | 
> | 
                        if (!lastdate) | 
| 297 | 
> | 
                                lastdate = 1; | 
| 298 | 
> | 
                        continue; | 
| 299 | 
> | 
                } | 
| 300 | 
  | 
                if (!(thisdate = fdate(thisfile))) | 
| 301 | 
  | 
                        syserr(thisfile); | 
| 302 | 
  | 
                if (thisdate > lastdate) | 
| 306 | 
  | 
} | 
| 307 | 
  | 
 | 
| 308 | 
  | 
 | 
| 309 | 
< | 
char * | 
| 310 | 
< | 
newfname(orig, pred)            /* create modified file name */ | 
| 311 | 
< | 
char    *orig; | 
| 312 | 
< | 
int     pred; | 
| 309 | 
> | 
static char * | 
| 310 | 
> | 
newfname(               /* create modified file name */ | 
| 311 | 
> | 
        char    *orig, | 
| 312 | 
> | 
        int     pred | 
| 313 | 
> | 
) | 
| 314 | 
  | 
{ | 
| 506 | 
– | 
        extern char     *rindex(); | 
| 315 | 
  | 
        register char   *cp; | 
| 316 | 
  | 
        register int    n; | 
| 317 | 
  | 
        int     suffix; | 
| 332 | 
  | 
} | 
| 333 | 
  | 
 | 
| 334 | 
  | 
 | 
| 335 | 
< | 
checkfiles()                    /* check for existence and modified times */ | 
| 335 | 
> | 
static void | 
| 336 | 
> | 
checkfiles(void)                        /* check for existence and modified times */ | 
| 337 | 
  | 
{ | 
| 338 | 
  | 
        time_t  objdate; | 
| 339 | 
  | 
 | 
| 342 | 
  | 
                        syserr(progname); | 
| 343 | 
  | 
                sprintf(vval(OCTREE), "%s.oct", radname); | 
| 344 | 
  | 
                vdef(OCTREE)++; | 
| 345 | 
+ | 
        } else if (vval(OCTREE)[0] == '!') { | 
| 346 | 
+ | 
                fprintf(stderr, "%s: illegal '%s' specification\n", | 
| 347 | 
+ | 
                                progname, vnam(OCTREE)); | 
| 348 | 
+ | 
                quit(1); | 
| 349 | 
  | 
        } | 
| 350 | 
  | 
        octreedate = fdate(vval(OCTREE)); | 
| 351 | 
  | 
        if (vdef(ILLUM)) {              /* illum requires secondary octrees */ | 
| 362 | 
  | 
        if (!octreedate & !scenedate & !illumdate) { | 
| 363 | 
  | 
                fprintf(stderr, "%s: need '%s' or '%s' or '%s'\n", progname, | 
| 364 | 
  | 
                                vnam(OCTREE), vnam(SCENE), vnam(ILLUM)); | 
| 365 | 
< | 
                exit(1); | 
| 365 | 
> | 
                quit(1); | 
| 366 | 
  | 
        } | 
| 367 | 
  | 
        matdate = checklast(vval(MATERIAL)); | 
| 368 | 
  | 
}        | 
| 369 | 
  | 
 | 
| 370 | 
  | 
 | 
| 371 | 
< | 
getoctcube(org, sizp)           /* get octree bounding cube */ | 
| 372 | 
< | 
double  org[3], *sizp; | 
| 371 | 
> | 
static void | 
| 372 | 
> | 
getoctcube(             /* get octree bounding cube */ | 
| 373 | 
> | 
        double  org[3], | 
| 374 | 
> | 
        double  *sizp | 
| 375 | 
> | 
) | 
| 376 | 
  | 
{ | 
| 561 | 
– | 
        extern FILE     *popen(); | 
| 377 | 
  | 
        static double   oorg[3], osiz = 0.; | 
| 378 | 
  | 
        double  min[3], max[3]; | 
| 379 | 
< | 
        char    buf[512]; | 
| 379 | 
> | 
        char    buf[1024]; | 
| 380 | 
  | 
        FILE    *fp; | 
| 381 | 
  | 
        register int    i; | 
| 382 | 
  | 
 | 
| 383 | 
< | 
        if (osiz <= FTINY) | 
| 384 | 
< | 
                if (noaction && fdate(oct1name) < | 
| 383 | 
> | 
        if (osiz <= FTINY) { | 
| 384 | 
> | 
                if (!nprocs && fdate(oct1name) < | 
| 385 | 
  | 
                                (scenedate>illumdate?scenedate:illumdate)) { | 
| 386 | 
  | 
                                                        /* run getbbox */ | 
| 387 | 
  | 
                        sprintf(buf, "getbbox -w -h %s", | 
| 394 | 
  | 
                                fprintf(stderr, | 
| 395 | 
  | 
                        "%s: error reading bounding box from getbbox\n", | 
| 396 | 
  | 
                                                progname); | 
| 397 | 
< | 
                                exit(1); | 
| 397 | 
> | 
                                quit(1); | 
| 398 | 
  | 
                        } | 
| 399 | 
  | 
                        for (i = 0; i < 3; i++) | 
| 400 | 
  | 
                                if (max[i] - min[i] > osiz) | 
| 412 | 
  | 
                                fprintf(stderr, | 
| 413 | 
  | 
                        "%s: error reading bounding cube from getinfo\n", | 
| 414 | 
  | 
                                                progname); | 
| 415 | 
< | 
                                exit(1); | 
| 415 | 
> | 
                                quit(1); | 
| 416 | 
  | 
                        } | 
| 417 | 
  | 
                        pclose(fp); | 
| 418 | 
  | 
                } | 
| 419 | 
+ | 
        } | 
| 420 | 
  | 
        org[0] = oorg[0]; org[1] = oorg[1]; org[2] = oorg[2]; *sizp = osiz; | 
| 421 | 
  | 
} | 
| 422 | 
  | 
 | 
| 423 | 
  | 
 | 
| 424 | 
< | 
setdefaults()                   /* set default values for unassigned var's */ | 
| 424 | 
> | 
static void | 
| 425 | 
> | 
setdefaults(void)                       /* set default values for unassigned var's */ | 
| 426 | 
  | 
{ | 
| 427 | 
< | 
        double  org[3], size; | 
| 427 | 
> | 
        double  org[3], lim[3], size; | 
| 428 | 
  | 
        char    buf[128]; | 
| 429 | 
  | 
 | 
| 430 | 
  | 
        if (!vdef(ZONE)) { | 
| 434 | 
  | 
                vval(ZONE) = savqstr(buf); | 
| 435 | 
  | 
                vdef(ZONE)++; | 
| 436 | 
  | 
        } | 
| 437 | 
+ | 
        if (!vdef(EYESEP)) { | 
| 438 | 
+ | 
                if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", | 
| 439 | 
+ | 
                                &org[0], &lim[0], &org[1], &lim[1], | 
| 440 | 
+ | 
                                &org[2], &lim[2]) != 6) | 
| 441 | 
+ | 
                        badvalue(ZONE); | 
| 442 | 
+ | 
                sprintf(buf, "%f", | 
| 443 | 
+ | 
                        0.01*(lim[0]-org[0]+lim[1]-org[1]+lim[2]-org[2])); | 
| 444 | 
+ | 
                vval(EYESEP) = savqstr(buf); | 
| 445 | 
+ | 
                vdef(EYESEP)++; | 
| 446 | 
+ | 
        } | 
| 447 | 
  | 
        if (!vdef(INDIRECT)) { | 
| 448 | 
  | 
                vval(INDIRECT) = "0"; | 
| 449 | 
  | 
                vdef(INDIRECT)++; | 
| 460 | 
  | 
                vval(PICTURE) = radname; | 
| 461 | 
  | 
                vdef(PICTURE)++; | 
| 462 | 
  | 
        } | 
| 463 | 
< | 
        if (!vdef(VIEW)) { | 
| 464 | 
< | 
                vval(VIEW) = "X"; | 
| 465 | 
< | 
                vdef(VIEW)++; | 
| 463 | 
> | 
        if (!vdef(VIEWS)) { | 
| 464 | 
> | 
                vval(VIEWS) = "X"; | 
| 465 | 
> | 
                vdef(VIEWS)++; | 
| 466 | 
  | 
        } | 
| 467 | 
  | 
        if (!vdef(DETAIL)) { | 
| 468 | 
  | 
                vval(DETAIL) = "M"; | 
| 476 | 
  | 
                vval(VARIABILITY) = "L"; | 
| 477 | 
  | 
                vdef(VARIABILITY)++; | 
| 478 | 
  | 
        } | 
| 652 | 
– | 
        if (!vdef(RAWSAVE)) { | 
| 653 | 
– | 
                vval(RAWSAVE) = "F"; | 
| 654 | 
– | 
                vdef(RAWSAVE)++; | 
| 655 | 
– | 
        } | 
| 479 | 
  | 
} | 
| 480 | 
  | 
 | 
| 481 | 
  | 
 | 
| 482 | 
< | 
printvals()                     /* print variable values */ | 
| 482 | 
> | 
static void | 
| 483 | 
> | 
oconv(void)                             /* run oconv and mkillum if necessary */ | 
| 484 | 
  | 
{ | 
| 661 | 
– | 
        int     i, j, clipline; | 
| 662 | 
– | 
        register char   *cp; | 
| 663 | 
– | 
        register int    k; | 
| 664 | 
– | 
 | 
| 665 | 
– | 
        for (i = 0; i < NVARS; i++)             /* print each variable */ | 
| 666 | 
– | 
            for (j = 0; j < vdef(i); j++) {     /* print each assignment */ | 
| 667 | 
– | 
                fputs(vnam(i), stdout); | 
| 668 | 
– | 
                fputs("= ", stdout); | 
| 669 | 
– | 
                k = clipline = ( vv[i].fixval == catvalues ? 64 : 320 ) | 
| 670 | 
– | 
                                - strlen(vnam(i)) ; | 
| 671 | 
– | 
                cp = nvalue(vv+i, j); | 
| 672 | 
– | 
                while (*cp) { | 
| 673 | 
– | 
                    putchar(*cp++); | 
| 674 | 
– | 
                    if (--k <= 0) {             /* line too long */ | 
| 675 | 
– | 
                        while (*cp && !isspace(*cp)) | 
| 676 | 
– | 
                            putchar(*cp++);     /* finish this word */ | 
| 677 | 
– | 
                        if (*cp) {              /* start new line */ | 
| 678 | 
– | 
                            putchar('\n'); | 
| 679 | 
– | 
                            fputs(vnam(i), stdout); | 
| 680 | 
– | 
                            putchar('='); | 
| 681 | 
– | 
                            k = clipline; | 
| 682 | 
– | 
                        } | 
| 683 | 
– | 
                    } | 
| 684 | 
– | 
                } | 
| 685 | 
– | 
                putchar('\n'); | 
| 686 | 
– | 
            } | 
| 687 | 
– | 
        fflush(stdout); | 
| 688 | 
– | 
} | 
| 689 | 
– | 
 | 
| 690 | 
– | 
 | 
| 691 | 
– | 
oconv()                         /* run oconv and mkillum if necessary */ | 
| 692 | 
– | 
{ | 
| 485 | 
  | 
        static char     illumtmp[] = "ilXXXXXX"; | 
| 486 | 
< | 
        char    combuf[512], ocopts[64], mkopts[64]; | 
| 486 | 
> | 
        char    combuf[PATH_MAX], ocopts[64], mkopts[1024]; | 
| 487 | 
  | 
 | 
| 488 | 
  | 
        oconvopts(ocopts);              /* get options */ | 
| 489 | 
  | 
        if (octreedate < scenedate) {   /* check date on original octree */ | 
| 491 | 
  | 
                        touch(vval(OCTREE)); | 
| 492 | 
  | 
                else {                          /* build command */ | 
| 493 | 
  | 
                        if (vdef(MATERIAL)) | 
| 494 | 
< | 
                                sprintf(combuf, "oconv%s %s %s > %s", ocopts, | 
| 495 | 
< | 
                                                vval(MATERIAL), vval(SCENE), | 
| 496 | 
< | 
                                                vval(OCTREE)); | 
| 494 | 
> | 
                                sprintf(combuf, "%s%s %s %s > %s", c_oconv, | 
| 495 | 
> | 
                                                ocopts, vval(MATERIAL), | 
| 496 | 
> | 
                                                vval(SCENE), vval(OCTREE)); | 
| 497 | 
  | 
                        else | 
| 498 | 
< | 
                                sprintf(combuf, "oconv%s %s > %s", ocopts, | 
| 498 | 
> | 
                                sprintf(combuf, "%s%s %s > %s", c_oconv, ocopts, | 
| 499 | 
  | 
                                                vval(SCENE), vval(OCTREE)); | 
| 500 | 
  | 
                         | 
| 501 | 
  | 
                        if (runcom(combuf)) {           /* run it */ | 
| 503 | 
  | 
                                "%s: error generating octree\n\t%s removed\n", | 
| 504 | 
  | 
                                                progname, vval(OCTREE)); | 
| 505 | 
  | 
                                unlink(vval(OCTREE)); | 
| 506 | 
< | 
                                exit(1); | 
| 506 | 
> | 
                                quit(1); | 
| 507 | 
  | 
                        } | 
| 508 | 
  | 
                } | 
| 509 | 
  | 
                octreedate = time((time_t *)NULL); | 
| 512 | 
  | 
        } | 
| 513 | 
  | 
        if (oct1name == vval(OCTREE))           /* no mkillum? */ | 
| 514 | 
  | 
                oct1date = octreedate > matdate ? octreedate : matdate; | 
| 515 | 
< | 
        if (oct1date >= octreedate & oct1date >= matdate | 
| 516 | 
< | 
                        & oct1date >= illumdate)        /* all done */ | 
| 515 | 
> | 
        if ((oct1date >= octreedate) & (oct1date >= matdate) | 
| 516 | 
> | 
                        & (oct1date >= illumdate))      /* all done */ | 
| 517 | 
  | 
                return; | 
| 518 | 
  | 
                                                /* make octree0 */ | 
| 519 | 
< | 
        if (oct0date < scenedate | oct0date < illumdate) { | 
| 519 | 
> | 
        if ((oct0date < scenedate) | (oct0date < illumdate)) { | 
| 520 | 
  | 
                if (touchonly && oct0date) | 
| 521 | 
  | 
                        touch(oct0name); | 
| 522 | 
  | 
                else {                          /* build command */ | 
| 523 | 
  | 
                        if (octreedate) | 
| 524 | 
< | 
                                sprintf(combuf, "oconv%s -i %s %s > %s", ocopts, | 
| 525 | 
< | 
                                        vval(OCTREE), vval(ILLUM), oct0name); | 
| 524 | 
> | 
                                sprintf(combuf, "%s%s -i %s %s > %s", c_oconv, | 
| 525 | 
> | 
                                        ocopts, vval(OCTREE), | 
| 526 | 
> | 
                                        vval(ILLUM), oct0name); | 
| 527 | 
  | 
                        else if (vdef(MATERIAL)) | 
| 528 | 
< | 
                                sprintf(combuf, "oconv%s %s %s > %s", ocopts, | 
| 529 | 
< | 
                                        vval(MATERIAL), vval(ILLUM), oct0name); | 
| 737 | 
< | 
                        else | 
| 738 | 
< | 
                                sprintf(combuf, "oconv%s %s > %s", ocopts, | 
| 528 | 
> | 
                                sprintf(combuf, "%s%s %s %s > %s", c_oconv, | 
| 529 | 
> | 
                                        ocopts, vval(MATERIAL), | 
| 530 | 
  | 
                                        vval(ILLUM), oct0name); | 
| 531 | 
+ | 
                        else | 
| 532 | 
+ | 
                                sprintf(combuf, "%s%s %s > %s", c_oconv, | 
| 533 | 
+ | 
                                        ocopts, vval(ILLUM), oct0name); | 
| 534 | 
  | 
                        if (runcom(combuf)) {           /* run it */ | 
| 535 | 
  | 
                                fprintf(stderr, | 
| 536 | 
  | 
                                "%s: error generating octree\n\t%s removed\n", | 
| 537 | 
  | 
                                                progname, oct0name); | 
| 538 | 
  | 
                                unlink(oct0name); | 
| 539 | 
< | 
                                exit(1); | 
| 539 | 
> | 
                                quit(1); | 
| 540 | 
  | 
                        } | 
| 541 | 
  | 
                } | 
| 542 | 
  | 
                oct0date = time((time_t *)NULL); | 
| 550 | 
  | 
        else { | 
| 551 | 
  | 
                mkillumopts(mkopts);            /* build mkillum command */ | 
| 552 | 
  | 
                mktemp(illumtmp); | 
| 553 | 
< | 
                sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts, | 
| 553 | 
> | 
                sprintf(combuf, "%s%s %s \"<\" %s > %s", c_mkillum, mkopts, | 
| 554 | 
  | 
                                oct0name, vval(ILLUM), illumtmp); | 
| 555 | 
  | 
                if (runcom(combuf)) {                   /* run it */ | 
| 556 | 
< | 
                        fprintf(stderr, "%s: error running mkillum\n", | 
| 557 | 
< | 
                                        progname); | 
| 556 | 
> | 
                        fprintf(stderr, "%s: error running %s\n", | 
| 557 | 
> | 
                                        progname, c_mkillum); | 
| 558 | 
  | 
                        unlink(illumtmp); | 
| 559 | 
< | 
                        exit(1); | 
| 559 | 
> | 
                        quit(1); | 
| 560 | 
  | 
                } | 
| 561 | 
+ | 
                rmfile(oct0name); | 
| 562 | 
  | 
                                                /* make octree1 (frozen) */ | 
| 563 | 
  | 
                if (octreedate) | 
| 564 | 
< | 
                        sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts, | 
| 565 | 
< | 
                                vval(OCTREE), illumtmp, oct1name); | 
| 564 | 
> | 
                        sprintf(combuf, "%s%s -f -i %s %s > %s", c_oconv, | 
| 565 | 
> | 
                                ocopts, vval(OCTREE), illumtmp, oct1name); | 
| 566 | 
  | 
                else if (vdef(MATERIAL)) | 
| 567 | 
< | 
                        sprintf(combuf, "oconv%s -f %s %s > %s", ocopts, | 
| 568 | 
< | 
                                vval(MATERIAL), illumtmp, oct1name); | 
| 567 | 
> | 
                        sprintf(combuf, "%s%s -f %s %s > %s", c_oconv, | 
| 568 | 
> | 
                                ocopts, vval(MATERIAL), illumtmp, oct1name); | 
| 569 | 
  | 
                else | 
| 570 | 
< | 
                        sprintf(combuf, "oconv%s -f %s > %s", ocopts, | 
| 570 | 
> | 
                        sprintf(combuf, "%s%s -f %s > %s", c_oconv, ocopts, | 
| 571 | 
  | 
                                illumtmp, oct1name); | 
| 572 | 
  | 
                if (runcom(combuf)) {           /* run it */ | 
| 573 | 
  | 
                        fprintf(stderr, | 
| 574 | 
  | 
                                "%s: error generating octree\n\t%s removed\n", | 
| 575 | 
  | 
                                        progname, oct1name); | 
| 576 | 
  | 
                        unlink(oct1name); | 
| 577 | 
< | 
                        exit(1); | 
| 577 | 
> | 
                        unlink(illumtmp); | 
| 578 | 
> | 
                        quit(1); | 
| 579 | 
  | 
                } | 
| 580 | 
  | 
                rmfile(illumtmp); | 
| 581 | 
  | 
        } | 
| 585 | 
  | 
} | 
| 586 | 
  | 
 | 
| 587 | 
  | 
 | 
| 588 | 
< | 
char * | 
| 589 | 
< | 
addarg(op, arg)                         /* add argument and advance pointer */ | 
| 590 | 
< | 
register char   *op, *arg; | 
| 588 | 
> | 
static char * | 
| 589 | 
> | 
addarg(                         /* append argument and advance pointer */ | 
| 590 | 
> | 
register char   *op, | 
| 591 | 
> | 
register char   *arg | 
| 592 | 
> | 
) | 
| 593 | 
  | 
{ | 
| 594 | 
+ | 
        while (*op) | 
| 595 | 
+ | 
                op++; | 
| 596 | 
  | 
        *op = ' '; | 
| 597 | 
< | 
        while (*++op = *arg++) | 
| 597 | 
> | 
        while ( (*++op = *arg++) ) | 
| 598 | 
  | 
                ; | 
| 599 | 
  | 
        return(op); | 
| 600 | 
  | 
} | 
| 601 | 
  | 
 | 
| 602 | 
  | 
 | 
| 603 | 
< | 
oconvopts(oo)                           /* get oconv options */ | 
| 604 | 
< | 
register char   *oo; | 
| 603 | 
> | 
static void | 
| 604 | 
> | 
oconvopts(                              /* get oconv options */ | 
| 605 | 
> | 
        register char   *oo | 
| 606 | 
> | 
) | 
| 607 | 
  | 
{ | 
| 608 | 
  | 
        /* BEWARE:  This may be called via setdefaults(), so no assumptions */ | 
| 609 | 
  | 
 | 
| 610 | 
  | 
        *oo = '\0'; | 
| 611 | 
  | 
        if (vdef(OCONV)) | 
| 612 | 
< | 
                addarg(oo, vval(OCONV)); | 
| 612 | 
> | 
                if (vval(OCONV)[0] != '-') { | 
| 613 | 
> | 
                        atos(c_oconv, sizeof(c_oconv), vval(OCONV)); | 
| 614 | 
> | 
                        oo = addarg(oo, sskip2(vval(OCONV), 1)); | 
| 615 | 
> | 
                } else | 
| 616 | 
> | 
                        oo = addarg(oo, vval(OCONV)); | 
| 617 | 
  | 
} | 
| 618 | 
  | 
 | 
| 619 | 
  | 
 | 
| 620 | 
< | 
mkillumopts(mo)                         /* get mkillum options */ | 
| 621 | 
< | 
register char   *mo; | 
| 620 | 
> | 
static void | 
| 621 | 
> | 
mkillumopts(                            /* get mkillum options */ | 
| 622 | 
> | 
        char    *mo | 
| 623 | 
> | 
) | 
| 624 | 
  | 
{ | 
| 625 | 
  | 
        /* BEWARE:  This may be called via setdefaults(), so no assumptions */ | 
| 626 | 
  | 
 | 
| 627 | 
< | 
        *mo = '\0'; | 
| 627 | 
> | 
        if (nprocs > 1) | 
| 628 | 
> | 
                sprintf(mo, " -n %d", nprocs); | 
| 629 | 
> | 
        else | 
| 630 | 
> | 
                *mo = '\0'; | 
| 631 | 
  | 
        if (vdef(MKILLUM)) | 
| 632 | 
< | 
                addarg(mo, vval(MKILLUM)); | 
| 632 | 
> | 
                if (vval(MKILLUM)[0] != '-') { | 
| 633 | 
> | 
                        atos(c_mkillum, sizeof(c_mkillum), vval(MKILLUM)); | 
| 634 | 
> | 
                        mo = addarg(mo, sskip2(vval(MKILLUM), 1)); | 
| 635 | 
> | 
                } else | 
| 636 | 
> | 
                        mo = addarg(mo, vval(MKILLUM)); | 
| 637 | 
  | 
} | 
| 638 | 
  | 
 | 
| 639 | 
  | 
 | 
| 640 | 
< | 
checkambfile()                  /* check date on ambient file */ | 
| 640 | 
> | 
static void | 
| 641 | 
> | 
checkambfile(void)                      /* check date on ambient file */ | 
| 642 | 
  | 
{ | 
| 643 | 
  | 
        time_t  afdate; | 
| 644 | 
  | 
 | 
| 646 | 
  | 
                return; | 
| 647 | 
  | 
        if (!(afdate = fdate(vval(AMBFILE)))) | 
| 648 | 
  | 
                return; | 
| 649 | 
< | 
        if (oct1date > afdate) | 
| 649 | 
> | 
        if (oct1date > afdate) { | 
| 650 | 
  | 
                if (touchonly) | 
| 651 | 
  | 
                        touch(vval(AMBFILE)); | 
| 652 | 
  | 
                else | 
| 653 | 
  | 
                        rmfile(vval(AMBFILE)); | 
| 654 | 
+ | 
        } | 
| 655 | 
  | 
} | 
| 656 | 
  | 
 | 
| 657 | 
  | 
 | 
| 658 | 
< | 
double | 
| 659 | 
< | 
ambval()                                /* compute ambient value */ | 
| 658 | 
> | 
static double | 
| 659 | 
> | 
ambval(void)                            /* compute ambient value */ | 
| 660 | 
  | 
{ | 
| 661 | 
  | 
        if (vdef(EXPOSURE)) { | 
| 662 | 
  | 
                if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-') | 
| 663 | 
< | 
                        return(.5/pow(2.,atof(vval(EXPOSURE)))); | 
| 664 | 
< | 
                return(.5/atof(vval(EXPOSURE))); | 
| 663 | 
> | 
                        return(.5/pow(2.,vflt(EXPOSURE))); | 
| 664 | 
> | 
                return(.5/vflt(EXPOSURE)); | 
| 665 | 
  | 
        } | 
| 666 | 
  | 
        if (vlet(ZONE) == 'E') | 
| 667 | 
  | 
                return(10.); | 
| 668 | 
  | 
        if (vlet(ZONE) == 'I') | 
| 669 | 
  | 
                return(.01); | 
| 670 | 
  | 
        badvalue(ZONE); | 
| 671 | 
+ | 
        return 0; /* pro forma return */ | 
| 672 | 
  | 
} | 
| 673 | 
  | 
 | 
| 674 | 
  | 
 | 
| 675 | 
< | 
renderopts(op, po)                      /* set rendering options */ | 
| 676 | 
< | 
char    *op, *po; | 
| 675 | 
> | 
static void | 
| 676 | 
> | 
renderopts(                     /* set rendering options */ | 
| 677 | 
> | 
        char    *op, | 
| 678 | 
> | 
        char    *po | 
| 679 | 
> | 
) | 
| 680 | 
  | 
{ | 
| 681 | 
  | 
        switch(vscale(QUALITY)) { | 
| 682 | 
  | 
        case LOW: | 
| 689 | 
  | 
                hiqopts(op, po); | 
| 690 | 
  | 
                break; | 
| 691 | 
  | 
        } | 
| 692 | 
+ | 
        if (vdef(RENDER)) | 
| 693 | 
+ | 
                op = addarg(op, vval(RENDER)); | 
| 694 | 
+ | 
        if (rvdevice != NULL) { | 
| 695 | 
+ | 
                if (vdef(RVU)) | 
| 696 | 
+ | 
                        if (vval(RVU)[0] != '-') { | 
| 697 | 
+ | 
                                atos(c_rvu, sizeof(c_rvu), vval(RVU)); | 
| 698 | 
+ | 
                                po = addarg(po, sskip2(vval(RVU), 1)); | 
| 699 | 
+ | 
                        } else | 
| 700 | 
+ | 
                                po = addarg(po, vval(RVU)); | 
| 701 | 
+ | 
        } else { | 
| 702 | 
+ | 
                if (vdef(RPICT)) | 
| 703 | 
+ | 
                        if (vval(RPICT)[0] != '-') { | 
| 704 | 
+ | 
                                atos(c_rpict, sizeof(c_rpict), vval(RPICT)); | 
| 705 | 
+ | 
                                po = addarg(po, sskip2(vval(RPICT), 1)); | 
| 706 | 
+ | 
                        } else | 
| 707 | 
+ | 
                                po = addarg(po, vval(RPICT)); | 
| 708 | 
+ | 
        } | 
| 709 | 
  | 
} | 
| 710 | 
  | 
 | 
| 711 | 
  | 
 | 
| 712 | 
< | 
lowqopts(op, po)                        /* low quality rendering options */ | 
| 713 | 
< | 
register char   *op; | 
| 714 | 
< | 
char    *po; | 
| 712 | 
> | 
static void | 
| 713 | 
> | 
lowqopts(                       /* low quality rendering options */ | 
| 714 | 
> | 
        register char   *op, | 
| 715 | 
> | 
        char    *po | 
| 716 | 
> | 
) | 
| 717 | 
  | 
{ | 
| 718 | 
  | 
        double  d, org[3], siz[3]; | 
| 719 | 
  | 
 | 
| 723 | 
  | 
                        &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) | 
| 724 | 
  | 
                badvalue(ZONE); | 
| 725 | 
  | 
        siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; | 
| 726 | 
< | 
        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) | 
| 726 | 
> | 
        if ((siz[0] <= FTINY) | (siz[1] <= FTINY) | (siz[2] <= FTINY)) | 
| 727 | 
  | 
                badvalue(ZONE); | 
| 728 | 
  | 
        getoctcube(org, &d); | 
| 729 | 
  | 
        d *= 3./(siz[0]+siz[1]+siz[2]); | 
| 731 | 
  | 
        case LOW: | 
| 732 | 
  | 
                po = addarg(po, "-ps 16"); | 
| 733 | 
  | 
                op = addarg(op, "-dp 64"); | 
| 734 | 
< | 
                sprintf(op, " -ar %d", (int)(4*d)); | 
| 734 | 
> | 
                sprintf(op, " -ar %d", (int)(8*d)); | 
| 735 | 
  | 
                op += strlen(op); | 
| 736 | 
  | 
                break; | 
| 737 | 
  | 
        case MEDIUM: | 
| 738 | 
  | 
                po = addarg(po, "-ps 8"); | 
| 739 | 
  | 
                op = addarg(op, "-dp 128"); | 
| 740 | 
< | 
                sprintf(op, " -ar %d", (int)(8*d)); | 
| 740 | 
> | 
                sprintf(op, " -ar %d", (int)(16*d)); | 
| 741 | 
  | 
                op += strlen(op); | 
| 742 | 
  | 
                break; | 
| 743 | 
  | 
        case HIGH: | 
| 744 | 
  | 
                po = addarg(po, "-ps 4"); | 
| 745 | 
  | 
                op = addarg(op, "-dp 256"); | 
| 746 | 
< | 
                sprintf(op, " -ar %d", (int)(16*d)); | 
| 746 | 
> | 
                sprintf(op, " -ar %d", (int)(32*d)); | 
| 747 | 
  | 
                op += strlen(op); | 
| 748 | 
  | 
                break; | 
| 749 | 
  | 
        } | 
| 752 | 
  | 
                op = addarg(op, "-ds .4"); | 
| 753 | 
  | 
        else | 
| 754 | 
  | 
                op = addarg(op, "-ds 0"); | 
| 755 | 
< | 
        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5"); | 
| 755 | 
> | 
        op = addarg(op, "-dt .2 -dc .25 -dr 0 -ss 0 -st .5"); | 
| 756 | 
  | 
        if (vdef(AMBFILE)) { | 
| 757 | 
  | 
                sprintf(op, " -af %s", vval(AMBFILE)); | 
| 758 | 
  | 
                op += strlen(op); | 
| 760 | 
  | 
                overture = 0; | 
| 761 | 
  | 
        switch (vscale(VARIABILITY)) { | 
| 762 | 
  | 
        case LOW: | 
| 763 | 
< | 
                op = addarg(op, "-aa .4 -ad 64"); | 
| 763 | 
> | 
                op = addarg(op, "-aa .3 -ad 256"); | 
| 764 | 
  | 
                break; | 
| 765 | 
  | 
        case MEDIUM: | 
| 766 | 
< | 
                op = addarg(op, "-aa .3 -ad 128"); | 
| 766 | 
> | 
                op = addarg(op, "-aa .25 -ad 512"); | 
| 767 | 
  | 
                break; | 
| 768 | 
  | 
        case HIGH: | 
| 769 | 
< | 
                op = addarg(op, "-aa .25 -ad 256"); | 
| 769 | 
> | 
                op = addarg(op, "-aa .2 -ad 1024"); | 
| 770 | 
  | 
                break; | 
| 771 | 
  | 
        } | 
| 772 | 
  | 
        op = addarg(op, "-as 0"); | 
| 773 | 
  | 
        d = ambval(); | 
| 774 | 
  | 
        sprintf(op, " -av %.2g %.2g %.2g", d, d, d); | 
| 775 | 
  | 
        op += strlen(op); | 
| 776 | 
< | 
        op = addarg(op, "-lr 3 -lw .02"); | 
| 937 | 
< | 
        if (vdef(RENDER)) | 
| 938 | 
< | 
                op = addarg(op, vval(RENDER)); | 
| 776 | 
> | 
        op = addarg(op, "-lr 6 -lw .003"); | 
| 777 | 
  | 
} | 
| 778 | 
  | 
 | 
| 779 | 
  | 
 | 
| 780 | 
< | 
medqopts(op, po)                        /* medium quality rendering options */ | 
| 781 | 
< | 
register char   *op; | 
| 782 | 
< | 
char    *po; | 
| 780 | 
> | 
static void | 
| 781 | 
> | 
medqopts(                       /* medium quality rendering options */ | 
| 782 | 
> | 
        register char   *op, | 
| 783 | 
> | 
        char    *po | 
| 784 | 
> | 
) | 
| 785 | 
  | 
{ | 
| 786 | 
< | 
        double  d, org[3], siz[3]; | 
| 786 | 
> | 
        double  d, org[3], siz[3], asz; | 
| 787 | 
  | 
 | 
| 788 | 
  | 
        *op = '\0'; | 
| 789 | 
  | 
        *po = '\0'; | 
| 791 | 
  | 
                        &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) | 
| 792 | 
  | 
                badvalue(ZONE); | 
| 793 | 
  | 
        siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; | 
| 794 | 
< | 
        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) | 
| 794 | 
> | 
        if ((siz[0] <= FTINY) | (siz[1] <= FTINY) | (siz[2] <= FTINY)) | 
| 795 | 
  | 
                badvalue(ZONE); | 
| 796 | 
  | 
        getoctcube(org, &d); | 
| 797 | 
< | 
        d *= 3./(siz[0]+siz[1]+siz[2]); | 
| 797 | 
> | 
        asz = (siz[0]+siz[1]+siz[2])/3.; | 
| 798 | 
> | 
        d /= asz; | 
| 799 | 
  | 
        switch (vscale(DETAIL)) { | 
| 800 | 
  | 
        case LOW: | 
| 801 | 
  | 
                po = addarg(po, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8"); | 
| 802 | 
  | 
                op = addarg(op, "-dp 256"); | 
| 803 | 
< | 
                sprintf(op, " -ar %d", (int)(8*d)); | 
| 803 | 
> | 
                sprintf(op, " -ar %d", (int)(16*d)); | 
| 804 | 
  | 
                op += strlen(op); | 
| 805 | 
+ | 
                sprintf(op, " -ms %.2g", asz/20.); | 
| 806 | 
+ | 
                op += strlen(op); | 
| 807 | 
  | 
                break; | 
| 808 | 
  | 
        case MEDIUM: | 
| 809 | 
  | 
                po = addarg(po, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6"); | 
| 810 | 
  | 
                op = addarg(op, "-dp 512"); | 
| 811 | 
< | 
                sprintf(op, " -ar %d", (int)(16*d)); | 
| 811 | 
> | 
                sprintf(op, " -ar %d", (int)(32*d)); | 
| 812 | 
  | 
                op += strlen(op); | 
| 813 | 
+ | 
                sprintf(op, " -ms %.2g", asz/40.); | 
| 814 | 
+ | 
                op += strlen(op); | 
| 815 | 
  | 
                break; | 
| 816 | 
  | 
        case HIGH: | 
| 817 | 
  | 
                po = addarg(po, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4"); | 
| 818 | 
  | 
                op = addarg(op, "-dp 1024"); | 
| 819 | 
< | 
                sprintf(op, " -ar %d", (int)(32*d)); | 
| 819 | 
> | 
                sprintf(op, " -ar %d", (int)(64*d)); | 
| 820 | 
  | 
                op += strlen(op); | 
| 821 | 
+ | 
                sprintf(op, " -ms %.2g", asz/80.); | 
| 822 | 
+ | 
                op += strlen(op); | 
| 823 | 
  | 
                break; | 
| 824 | 
  | 
        } | 
| 825 | 
  | 
        po = addarg(po, "-pt .08"); | 
| 826 | 
  | 
        if (vbool(PENUMBRAS)) | 
| 827 | 
< | 
                op = addarg(op, "-ds .2 -dj .5"); | 
| 827 | 
> | 
                op = addarg(op, "-ds .2 -dj .9"); | 
| 828 | 
  | 
        else | 
| 829 | 
  | 
                op = addarg(op, "-ds .3"); | 
| 830 | 
< | 
        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1"); | 
| 831 | 
< | 
        if (overture = vint(INDIRECT)) { | 
| 830 | 
> | 
        op = addarg(op, "-dt .1 -dc .5 -dr 1 -ss 1 -st .1"); | 
| 831 | 
> | 
        if ( (overture = vint(INDIRECT)) ) { | 
| 832 | 
  | 
                sprintf(op, " -ab %d", overture); | 
| 833 | 
  | 
                op += strlen(op); | 
| 834 | 
  | 
        } | 
| 839 | 
  | 
                overture = 0; | 
| 840 | 
  | 
        switch (vscale(VARIABILITY)) { | 
| 841 | 
  | 
        case LOW: | 
| 842 | 
< | 
                op = addarg(op, "-aa .25 -ad 196 -as 0"); | 
| 842 | 
> | 
                op = addarg(op, "-aa .2 -ad 329 -as 42"); | 
| 843 | 
  | 
                break; | 
| 844 | 
  | 
        case MEDIUM: | 
| 845 | 
< | 
                op = addarg(op, "-aa .2 -ad 400 -as 64"); | 
| 845 | 
> | 
                op = addarg(op, "-aa .15 -ad 800 -as 128"); | 
| 846 | 
  | 
                break; | 
| 847 | 
  | 
        case HIGH: | 
| 848 | 
< | 
                op = addarg(op, "-aa .15 -ad 768 -as 196"); | 
| 848 | 
> | 
                op = addarg(op, "-aa .1 -ad 1536 -as 392"); | 
| 849 | 
  | 
                break; | 
| 850 | 
  | 
        } | 
| 851 | 
  | 
        d = ambval(); | 
| 852 | 
  | 
        sprintf(op, " -av %.2g %.2g %.2g", d, d, d); | 
| 853 | 
  | 
        op += strlen(op); | 
| 854 | 
< | 
        op = addarg(op, "-lr 6 -lw .002"); | 
| 1008 | 
< | 
        if (vdef(RENDER)) | 
| 1009 | 
< | 
                op = addarg(op, vval(RENDER)); | 
| 854 | 
> | 
        op = addarg(op, "-lr 8 -lw 1e-4"); | 
| 855 | 
  | 
} | 
| 856 | 
  | 
 | 
| 857 | 
  | 
 | 
| 858 | 
< | 
hiqopts(op, po)                         /* high quality rendering options */ | 
| 859 | 
< | 
register char   *op; | 
| 860 | 
< | 
char    *po; | 
| 858 | 
> | 
static void | 
| 859 | 
> | 
hiqopts(                                /* high quality rendering options */ | 
| 860 | 
> | 
        register char   *op, | 
| 861 | 
> | 
        char    *po | 
| 862 | 
> | 
) | 
| 863 | 
  | 
{ | 
| 864 | 
< | 
        double  d, org[3], siz[3]; | 
| 864 | 
> | 
        double  d, org[3], siz[3], asz; | 
| 865 | 
  | 
 | 
| 866 | 
  | 
        *op = '\0'; | 
| 867 | 
  | 
        *po = '\0'; | 
| 869 | 
  | 
                        &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) | 
| 870 | 
  | 
                badvalue(ZONE); | 
| 871 | 
  | 
        siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; | 
| 872 | 
< | 
        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) | 
| 872 | 
> | 
        if ((siz[0] <= FTINY) | (siz[1] <= FTINY) | (siz[2] <= FTINY)) | 
| 873 | 
  | 
                badvalue(ZONE); | 
| 874 | 
  | 
        getoctcube(org, &d); | 
| 875 | 
< | 
        d *= 3./(siz[0]+siz[1]+siz[2]); | 
| 875 | 
> | 
        asz = (siz[0]+siz[1]+siz[2])/3.; | 
| 876 | 
> | 
        d /= asz; | 
| 877 | 
  | 
        switch (vscale(DETAIL)) { | 
| 878 | 
  | 
        case LOW: | 
| 879 | 
  | 
                po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8"); | 
| 880 | 
  | 
                op = addarg(op, "-dp 1024"); | 
| 881 | 
< | 
                sprintf(op, " -ar %d", (int)(16*d)); | 
| 881 | 
> | 
                sprintf(op, " -ar %d", (int)(32*d)); | 
| 882 | 
  | 
                op += strlen(op); | 
| 883 | 
+ | 
                sprintf(op, " -ms %.2g", asz/40.); | 
| 884 | 
+ | 
                op += strlen(op); | 
| 885 | 
  | 
                break; | 
| 886 | 
  | 
        case MEDIUM: | 
| 887 | 
  | 
                po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5"); | 
| 888 | 
  | 
                op = addarg(op, "-dp 2048"); | 
| 889 | 
< | 
                sprintf(op, " -ar %d", (int)(32*d)); | 
| 889 | 
> | 
                sprintf(op, " -ar %d", (int)(64*d)); | 
| 890 | 
  | 
                op += strlen(op); | 
| 891 | 
+ | 
                sprintf(op, " -ms %.2g", asz/80.); | 
| 892 | 
+ | 
                op += strlen(op); | 
| 893 | 
  | 
                break; | 
| 894 | 
  | 
        case HIGH: | 
| 895 | 
  | 
                po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3"); | 
| 896 | 
  | 
                op = addarg(op, "-dp 4096"); | 
| 897 | 
< | 
                sprintf(op, " -ar %d", (int)(64*d)); | 
| 897 | 
> | 
                sprintf(op, " -ar %d", (int)(128*d)); | 
| 898 | 
  | 
                op += strlen(op); | 
| 899 | 
+ | 
                sprintf(op, " -ms %.2g", asz/160.); | 
| 900 | 
+ | 
                op += strlen(op); | 
| 901 | 
  | 
                break; | 
| 902 | 
  | 
        } | 
| 903 | 
  | 
        po = addarg(po, "-pt .04"); | 
| 904 | 
  | 
        if (vbool(PENUMBRAS)) | 
| 905 | 
< | 
                op = addarg(op, "-ds .1 -dj .65"); | 
| 905 | 
> | 
                op = addarg(op, "-ds .1 -dj .9"); | 
| 906 | 
  | 
        else | 
| 907 | 
  | 
                op = addarg(op, "-ds .2"); | 
| 908 | 
< | 
        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01"); | 
| 908 | 
> | 
        op = addarg(op, "-dt .05 -dc .75 -dr 3 -ss 16 -st .01"); | 
| 909 | 
  | 
        sprintf(op, " -ab %d", overture=vint(INDIRECT)+1); | 
| 910 | 
  | 
        op += strlen(op); | 
| 911 | 
  | 
        if (vdef(AMBFILE)) { | 
| 915 | 
  | 
                overture = 0; | 
| 916 | 
  | 
        switch (vscale(VARIABILITY)) { | 
| 917 | 
  | 
        case LOW: | 
| 918 | 
< | 
                op = addarg(op, "-aa .15 -ad 256 -as 0"); | 
| 918 | 
> | 
                op = addarg(op, "-aa .125 -ad 512 -as 64"); | 
| 919 | 
  | 
                break; | 
| 920 | 
  | 
        case MEDIUM: | 
| 921 | 
< | 
                op = addarg(op, "-aa .125 -ad 512 -as 256"); | 
| 921 | 
> | 
                op = addarg(op, "-aa .1 -ad 1536 -as 768"); | 
| 922 | 
  | 
                break; | 
| 923 | 
  | 
        case HIGH: | 
| 924 | 
< | 
                op = addarg(op, "-aa .08 -ad 1024 -as 512"); | 
| 924 | 
> | 
                op = addarg(op, "-aa .075 -ad 4096 -as 2048"); | 
| 925 | 
  | 
                break; | 
| 926 | 
  | 
        } | 
| 927 | 
  | 
        d = ambval(); | 
| 928 | 
  | 
        sprintf(op, " -av %.2g %.2g %.2g", d, d, d); | 
| 929 | 
  | 
        op += strlen(op); | 
| 930 | 
< | 
        op = addarg(op, "-lr 12 -lw .0005"); | 
| 1077 | 
< | 
        if (vdef(RENDER)) | 
| 1078 | 
< | 
                op = addarg(op, vval(RENDER)); | 
| 930 | 
> | 
        op = addarg(op, "-lr 12 -lw 1e-5"); | 
| 931 | 
  | 
} | 
| 932 | 
  | 
 | 
| 933 | 
  | 
 | 
| 934 | 
< | 
xferopts(ro)                            /* transfer options if indicated */ | 
| 935 | 
< | 
char    *ro; | 
| 934 | 
> | 
static void | 
| 935 | 
> | 
xferopts(                               /* transfer options if indicated */ | 
| 936 | 
> | 
        char    *ro | 
| 937 | 
> | 
) | 
| 938 | 
  | 
{ | 
| 939 | 
  | 
        int     fd, n; | 
| 940 | 
  | 
        register char   *cp; | 
| 944 | 
  | 
                return; | 
| 945 | 
  | 
        if (vdef(OPTFILE)) { | 
| 946 | 
  | 
                for (cp = ro; cp[1]; cp++) | 
| 947 | 
< | 
                        if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3])) | 
| 947 | 
> | 
                        if (isspace(cp[1]) && (cp[2] == '@' || | 
| 948 | 
> | 
                                        (cp[2] == '-' && isalpha(cp[3])))) | 
| 949 | 
  | 
                                *cp = '\n'; | 
| 950 | 
  | 
                        else | 
| 951 | 
  | 
                                *cp = cp[1]; | 
| 955 | 
  | 
                        syserr(vval(OPTFILE)); | 
| 956 | 
  | 
                sprintf(ro, " @%s", vval(OPTFILE)); | 
| 957 | 
  | 
        } | 
| 958 | 
< | 
#ifdef MSDOS | 
| 958 | 
> | 
#ifdef _WIN32 | 
| 959 | 
  | 
        else if (n > 50) { | 
| 960 | 
  | 
                setenv("ROPT", ro+1); | 
| 961 | 
  | 
                strcpy(ro, " $ROPT"); | 
| 964 | 
  | 
} | 
| 965 | 
  | 
 | 
| 966 | 
  | 
 | 
| 967 | 
< | 
pfiltopts(po)                           /* get pfilt options */ | 
| 968 | 
< | 
register char   *po; | 
| 967 | 
> | 
static void | 
| 968 | 
> | 
pfiltopts(                              /* get pfilt options */ | 
| 969 | 
> | 
        register char   *po | 
| 970 | 
> | 
) | 
| 971 | 
  | 
{ | 
| 972 | 
  | 
        *po = '\0'; | 
| 973 | 
  | 
        if (vdef(EXPOSURE)) { | 
| 976 | 
  | 
        } | 
| 977 | 
  | 
        switch (vscale(QUALITY)) { | 
| 978 | 
  | 
        case MEDIUM: | 
| 979 | 
< | 
                po = addarg(po, "-r 1"); | 
| 979 | 
> | 
                po = addarg(po, "-r .6"); | 
| 980 | 
  | 
                break; | 
| 981 | 
  | 
        case HIGH: | 
| 982 | 
  | 
                po = addarg(po, "-m .25"); | 
| 983 | 
  | 
                break; | 
| 984 | 
  | 
        } | 
| 985 | 
  | 
        if (vdef(PFILT)) | 
| 986 | 
< | 
                po = addarg(po, vval(PFILT)); | 
| 986 | 
> | 
                if (vval(PFILT)[0] != '-') { | 
| 987 | 
> | 
                        atos(c_pfilt, sizeof(c_pfilt), vval(PFILT)); | 
| 988 | 
> | 
                        po = addarg(po, sskip2(vval(PFILT), 1)); | 
| 989 | 
> | 
                } else | 
| 990 | 
> | 
                        po = addarg(po, vval(PFILT)); | 
| 991 | 
  | 
} | 
| 992 | 
  | 
 | 
| 993 | 
  | 
 | 
| 994 | 
< | 
matchword(s1, s2)                       /* match white-delimited words */ | 
| 995 | 
< | 
register char   *s1, *s2; | 
| 994 | 
> | 
static int | 
| 995 | 
> | 
matchword(                      /* match white-delimited words */ | 
| 996 | 
> | 
        register char   *s1, | 
| 997 | 
> | 
        register char   *s2 | 
| 998 | 
> | 
) | 
| 999 | 
  | 
{ | 
| 1000 | 
  | 
        while (isspace(*s1)) s1++; | 
| 1001 | 
  | 
        while (isspace(*s2)) s2++; | 
| 1006 | 
  | 
} | 
| 1007 | 
  | 
 | 
| 1008 | 
  | 
 | 
| 1009 | 
< | 
char * | 
| 1010 | 
< | 
specview(vs)                            /* get proper view spec from vs */ | 
| 1011 | 
< | 
register char   *vs; | 
| 1009 | 
> | 
static char * | 
| 1010 | 
> | 
specview(                               /* get proper view spec from vs */ | 
| 1011 | 
> | 
        register char   *vs | 
| 1012 | 
> | 
) | 
| 1013 | 
  | 
{ | 
| 1014 | 
  | 
        static char     vup[7][12] = {"-vu 0 0 -1","-vu 0 -1 0","-vu -1 0 0", | 
| 1015 | 
  | 
                        "-vu 0 0 1", "-vu 1 0 0","-vu 0 1 0","-vu 0 0 1"}; | 
| 1027 | 
  | 
                        upax = 1-'X'+UPPER(vval(UP)[1]); | 
| 1028 | 
  | 
                else | 
| 1029 | 
  | 
                        upax = 1-'X'+vlet(UP); | 
| 1030 | 
< | 
                if (upax < 1 | upax > 3) | 
| 1030 | 
> | 
                if ((upax < 1) | (upax > 3)) | 
| 1031 | 
  | 
                        badvalue(UP); | 
| 1032 | 
  | 
                if (vval(UP)[0] == '-') | 
| 1033 | 
  | 
                        upax = -upax; | 
| 1049 | 
  | 
        } else if (*vs == 'z') { | 
| 1050 | 
  | 
                zpos = -1; vs++; | 
| 1051 | 
  | 
        } | 
| 1052 | 
< | 
        viewtype = 'v'; | 
| 1053 | 
< | 
        if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h' | *vs == 'c') | 
| 1052 | 
> | 
        switch (*vs) { | 
| 1053 | 
> | 
        case VT_PER: | 
| 1054 | 
> | 
        case VT_PAR: | 
| 1055 | 
> | 
        case VT_ANG: | 
| 1056 | 
> | 
        case VT_HEM: | 
| 1057 | 
> | 
        case VT_PLS: | 
| 1058 | 
> | 
        case VT_CYL: | 
| 1059 | 
  | 
                viewtype = *vs++; | 
| 1060 | 
+ | 
                break; | 
| 1061 | 
+ | 
        default: | 
| 1062 | 
+ | 
                viewtype = VT_PER; | 
| 1063 | 
+ | 
                break; | 
| 1064 | 
+ | 
        } | 
| 1065 | 
  | 
        cp = viewopts; | 
| 1066 | 
  | 
        if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) {       /* got one! */ | 
| 1067 | 
  | 
                *cp++ = '-'; *cp++ = 'v'; *cp++ = 't'; *cp++ = viewtype; | 
| 1103 | 
  | 
                } | 
| 1104 | 
  | 
                cp = addarg(cp, vup[upax+3]); | 
| 1105 | 
  | 
                switch (viewtype) { | 
| 1106 | 
< | 
                case 'v': | 
| 1106 | 
> | 
                case VT_PER: | 
| 1107 | 
  | 
                        cp = addarg(cp, "-vh 45 -vv 45"); | 
| 1108 | 
  | 
                        break; | 
| 1109 | 
< | 
                case 'l': | 
| 1109 | 
> | 
                case VT_PAR: | 
| 1110 | 
  | 
                        d = sqrt(dim[0]*dim[0]+dim[1]*dim[1]+dim[2]*dim[2]); | 
| 1111 | 
  | 
                        sprintf(cp, " -vh %.2g -vv %.2g", d, d); | 
| 1112 | 
  | 
                        cp += strlen(cp); | 
| 1113 | 
  | 
                        break; | 
| 1114 | 
< | 
                case 'a': | 
| 1115 | 
< | 
                case 'h': | 
| 1114 | 
> | 
                case VT_ANG: | 
| 1115 | 
> | 
                case VT_HEM: | 
| 1116 | 
> | 
                case VT_PLS: | 
| 1117 | 
  | 
                        cp = addarg(cp, "-vh 180 -vv 180"); | 
| 1118 | 
  | 
                        break; | 
| 1119 | 
< | 
                case 'c': | 
| 1119 | 
> | 
                case VT_CYL: | 
| 1120 | 
  | 
                        cp = addarg(cp, "-vh 180 -vv 90"); | 
| 1121 | 
  | 
                        break; | 
| 1122 | 
  | 
                } | 
| 1124 | 
  | 
                while (!isspace(*vs))           /* else skip id */ | 
| 1125 | 
  | 
                        if (!*vs++) | 
| 1126 | 
  | 
                                return(NULL); | 
| 1127 | 
< | 
                if (upax) {                     /* specify up vector */ | 
| 1127 | 
> | 
                if (upax) {                     /* prepend up vector */ | 
| 1128 | 
  | 
                        strcpy(cp, vup[upax+3]); | 
| 1129 | 
  | 
                        cp += strlen(cp); | 
| 1130 | 
  | 
                } | 
| 1132 | 
  | 
        if (cp == viewopts)             /* append any additional options */ | 
| 1133 | 
  | 
                vs++;           /* skip prefixed space if unneeded */ | 
| 1134 | 
  | 
        strcpy(cp, vs); | 
| 1135 | 
< | 
#ifdef MSDOS | 
| 1135 | 
> | 
#ifdef _WIN32 | 
| 1136 | 
  | 
        if (strlen(viewopts) > 40) { | 
| 1137 | 
  | 
                setenv("VIEW", viewopts); | 
| 1138 | 
  | 
                return("$VIEW"); | 
| 1142 | 
  | 
} | 
| 1143 | 
  | 
 | 
| 1144 | 
  | 
 | 
| 1145 | 
< | 
char * | 
| 1146 | 
< | 
getview(n, vn)                          /* get view n, or NULL if none */ | 
| 1147 | 
< | 
int     n; | 
| 1148 | 
< | 
char    *vn;            /* returned view name */ | 
| 1145 | 
> | 
static char * | 
| 1146 | 
> | 
getview(                                /* get view n, or NULL if none */ | 
| 1147 | 
> | 
        int     n, | 
| 1148 | 
> | 
        char    *vn             /* returned view name */ | 
| 1149 | 
> | 
) | 
| 1150 | 
  | 
{ | 
| 1151 | 
  | 
        register char   *mv; | 
| 1152 | 
  | 
 | 
| 1153 | 
  | 
        if (viewselect != NULL) {               /* command-line selected */ | 
| 1154 | 
  | 
                if (n)                          /* only do one */ | 
| 1155 | 
  | 
                        return(NULL); | 
| 1156 | 
+ | 
                                         | 
| 1157 | 
+ | 
                if (isint(viewselect)) {        /* view number? */ | 
| 1158 | 
+ | 
                        n = atoi(viewselect)-1; | 
| 1159 | 
+ | 
                        goto numview; | 
| 1160 | 
+ | 
                } | 
| 1161 | 
  | 
                if (viewselect[0] == '-') {     /* already specified */ | 
| 1162 | 
< | 
                        if (vn != NULL) *vn = '\0'; | 
| 1162 | 
> | 
                        if (vn != NULL) | 
| 1163 | 
> | 
                                strcpy(vn, "0"); | 
| 1164 | 
  | 
                        return(viewselect); | 
| 1165 | 
  | 
                } | 
| 1166 | 
  | 
                if (vn != NULL) { | 
| 1169 | 
  | 
                                ; | 
| 1170 | 
  | 
                        *vn = '\0'; | 
| 1171 | 
  | 
                } | 
| 1289 | 
– | 
                                                /* view number? */ | 
| 1290 | 
– | 
                if (isint(viewselect)) | 
| 1291 | 
– | 
                        return(specview(nvalue(vv+VIEW, atoi(viewselect)-1))); | 
| 1172 | 
  | 
                                                /* check list */ | 
| 1173 | 
< | 
                while ((mv = nvalue(vv+VIEW, n++)) != NULL) | 
| 1173 | 
> | 
                while ((mv = nvalue(VIEWS, n++)) != NULL) | 
| 1174 | 
  | 
                        if (matchword(viewselect, mv)) | 
| 1175 | 
  | 
                                return(specview(mv)); | 
| 1176 | 
+ | 
 | 
| 1177 | 
  | 
                return(specview(viewselect));   /* standard view? */ | 
| 1178 | 
  | 
        } | 
| 1179 | 
< | 
        mv = nvalue(vv+VIEW, n);                /* use view n */ | 
| 1180 | 
< | 
        if (vn != NULL & mv != NULL) { | 
| 1181 | 
< | 
                register char   *mv2 = mv; | 
| 1182 | 
< | 
                if (*mv2 != '-') | 
| 1179 | 
> | 
numview: | 
| 1180 | 
> | 
        mv = nvalue(VIEWS, n);          /* use view n */ | 
| 1181 | 
> | 
        if ((vn != NULL) & (mv != NULL)) | 
| 1182 | 
> | 
                if (*mv != '-') { | 
| 1183 | 
> | 
                        register char   *mv2 = mv; | 
| 1184 | 
  | 
                        while (*mv2 && !isspace(*mv2)) | 
| 1185 | 
  | 
                                *vn++ = *mv2++; | 
| 1186 | 
< | 
                *vn = '\0'; | 
| 1187 | 
< | 
        } | 
| 1186 | 
> | 
                        *vn = '\0'; | 
| 1187 | 
> | 
                } else | 
| 1188 | 
> | 
                        sprintf(vn, "%d", n+1); | 
| 1189 | 
> | 
 | 
| 1190 | 
  | 
        return(specview(mv)); | 
| 1191 | 
  | 
} | 
| 1192 | 
  | 
 | 
| 1193 | 
  | 
 | 
| 1194 | 
< | 
printview(vopts)                        /* print out selected view */ | 
| 1195 | 
< | 
register char   *vopts; | 
| 1194 | 
> | 
static int | 
| 1195 | 
> | 
myprintview(                    /* print out selected view */ | 
| 1196 | 
> | 
        register char   *vopts, | 
| 1197 | 
> | 
        FILE    *fp | 
| 1198 | 
> | 
) | 
| 1199 | 
  | 
{ | 
| 1200 | 
< | 
        extern char     *atos(), *getenv(); | 
| 1201 | 
< | 
        char    buf[256]; | 
| 1315 | 
< | 
        FILE    *fp; | 
| 1200 | 
> | 
        VIEW    vwr; | 
| 1201 | 
> | 
        char    buf[128]; | 
| 1202 | 
  | 
        register char   *cp; | 
| 1203 | 
< | 
 | 
| 1203 | 
> | 
#ifdef _WIN32 | 
| 1204 | 
> | 
/* XXX Should we allow something like this for all platforms? */ | 
| 1205 | 
> | 
/* XXX Or is it still required at all? */ | 
| 1206 | 
> | 
again: | 
| 1207 | 
> | 
#endif | 
| 1208 | 
  | 
        if (vopts == NULL) | 
| 1209 | 
  | 
                return(-1); | 
| 1210 | 
< | 
        fputs("VIEW=", stdout); | 
| 1211 | 
< | 
        do { | 
| 1212 | 
< | 
                if (matchword(vopts, "-vf")) {          /* expand view file */ | 
| 1213 | 
< | 
                        vopts = sskip(vopts); | 
| 1214 | 
< | 
                        if (!*atos(buf, sizeof(buf), vopts)) | 
| 1325 | 
< | 
                                return(-1); | 
| 1326 | 
< | 
                        if ((fp = fopen(buf, "r")) == NULL) | 
| 1327 | 
< | 
                                return(-1); | 
| 1328 | 
< | 
                        for (buf[sizeof(buf)-2] = '\n'; | 
| 1329 | 
< | 
                                        fgets(buf, sizeof(buf), fp) != NULL && | 
| 1330 | 
< | 
                                                buf[0] != '\n'; | 
| 1331 | 
< | 
                                        buf[sizeof(buf)-2] = '\n') { | 
| 1332 | 
< | 
                                if (buf[sizeof(buf)-2] != '\n') { | 
| 1333 | 
< | 
                                        ungetc(buf[sizeof(buf)-2], fp); | 
| 1334 | 
< | 
                                        buf[sizeof(buf)-2] = '\0'; | 
| 1335 | 
< | 
                                } | 
| 1336 | 
< | 
                                if (matchword(buf, "VIEW=") || | 
| 1337 | 
< | 
                                                matchword(buf, "rview")) { | 
| 1338 | 
< | 
                                        for (cp = sskip(buf); *cp && *cp != '\n'; cp++) | 
| 1339 | 
< | 
                                                putchar(*cp); | 
| 1340 | 
< | 
                                } | 
| 1341 | 
< | 
                        } | 
| 1342 | 
< | 
                        fclose(fp); | 
| 1343 | 
< | 
                        vopts = sskip(vopts); | 
| 1344 | 
< | 
                } else { | 
| 1345 | 
< | 
                        while (isspace(*vopts)) | 
| 1346 | 
< | 
                                vopts++; | 
| 1347 | 
< | 
                        putchar(' '); | 
| 1348 | 
< | 
#ifdef MSDOS | 
| 1349 | 
< | 
                        if (*vopts == '$') {            /* expand env. var. */ | 
| 1350 | 
< | 
                                if (!*atos(buf, sizeof(buf), vopts+1)) | 
| 1351 | 
< | 
                                        return(-1); | 
| 1352 | 
< | 
                                if ((cp = getenv(buf)) == NULL) | 
| 1353 | 
< | 
                                        return(-1); | 
| 1354 | 
< | 
                                fputs(cp, stdout); | 
| 1355 | 
< | 
                                vopts = sskip(vopts); | 
| 1356 | 
< | 
                        } else | 
| 1210 | 
> | 
#ifdef _WIN32 | 
| 1211 | 
> | 
        if (vopts[0] == '$') { | 
| 1212 | 
> | 
                vopts = getenv(vopts+1); | 
| 1213 | 
> | 
                goto again; | 
| 1214 | 
> | 
        } | 
| 1215 | 
  | 
#endif | 
| 1216 | 
< | 
                                while (*vopts && !isspace(*vopts)) | 
| 1217 | 
< | 
                                        putchar(*vopts++); | 
| 1218 | 
< | 
                } | 
| 1219 | 
< | 
        } while (*vopts++); | 
| 1220 | 
< | 
        putchar('\n'); | 
| 1216 | 
> | 
        vwr = stdview; | 
| 1217 | 
> | 
        sscanview(&vwr, cp=vopts);              /* set initial options */ | 
| 1218 | 
> | 
        while ((cp = strstr(cp, "-vf ")) != NULL && | 
| 1219 | 
> | 
                        *atos(buf, sizeof(buf), cp += 4)) { | 
| 1220 | 
> | 
                viewfile(buf, &vwr, NULL);      /* load -vf file */ | 
| 1221 | 
> | 
                sscanview(&vwr, cp);            /* reset tail */ | 
| 1222 | 
> | 
        } | 
| 1223 | 
> | 
        fputs(VIEWSTR, fp); | 
| 1224 | 
> | 
        fprintview(&vwr, fp);                   /* print full spec. */ | 
| 1225 | 
> | 
        fputc('\n', fp); | 
| 1226 | 
  | 
        return(0); | 
| 1227 | 
  | 
} | 
| 1228 | 
  | 
 | 
| 1229 | 
  | 
 | 
| 1230 | 
< | 
rview(opts, po)                         /* run rview with first view */ | 
| 1231 | 
< | 
char    *opts, *po; | 
| 1230 | 
> | 
static void | 
| 1231 | 
> | 
rvu(                            /* run rvu with first view */ | 
| 1232 | 
> | 
        char    *opts, | 
| 1233 | 
> | 
        char    *po | 
| 1234 | 
> | 
) | 
| 1235 | 
  | 
{ | 
| 1236 | 
  | 
        char    *vw; | 
| 1237 | 
< | 
        char    combuf[512]; | 
| 1237 | 
> | 
        char    combuf[PATH_MAX]; | 
| 1238 | 
  | 
                                        /* build command */ | 
| 1239 | 
  | 
        if (touchonly || (vw = getview(0, NULL)) == NULL) | 
| 1240 | 
  | 
                return; | 
| 1241 | 
  | 
        if (sayview) | 
| 1242 | 
< | 
                printview(vw); | 
| 1243 | 
< | 
        sprintf(combuf, "rview %s%s%s -R %s ", vw, po, opts, rifname); | 
| 1242 | 
> | 
                myprintview(vw, stdout); | 
| 1243 | 
> | 
        sprintf(combuf, "%s %s%s%s -R %s ", c_rvu, vw, opts, po, rifname); | 
| 1244 | 
> | 
        if (nprocs > 1) | 
| 1245 | 
> | 
                sprintf(combuf+strlen(combuf), "-n %d ", nprocs); | 
| 1246 | 
  | 
        if (rvdevice != NULL) | 
| 1247 | 
  | 
                sprintf(combuf+strlen(combuf), "-o %s ", rvdevice); | 
| 1248 | 
  | 
        if (vdef(EXPOSURE)) | 
| 1249 | 
  | 
                sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE)); | 
| 1250 | 
  | 
        strcat(combuf, oct1name); | 
| 1251 | 
  | 
        if (runcom(combuf)) {           /* run it */ | 
| 1252 | 
< | 
                fprintf(stderr, "%s: error running rview\n", progname); | 
| 1253 | 
< | 
                exit(1); | 
| 1252 | 
> | 
                fprintf(stderr, "%s: error running %s\n", progname, c_rvu); | 
| 1253 | 
> | 
                quit(1); | 
| 1254 | 
  | 
        } | 
| 1255 | 
  | 
} | 
| 1256 | 
  | 
 | 
| 1257 | 
  | 
 | 
| 1258 | 
< | 
rpict(opts, po)                         /* run rpict and pfilt for each view */ | 
| 1259 | 
< | 
char    *opts, *po; | 
| 1258 | 
> | 
static int | 
| 1259 | 
> | 
syncf_done(                     /* check if an rpiece sync file is complete */ | 
| 1260 | 
> | 
        char *sfname | 
| 1261 | 
> | 
) | 
| 1262 | 
  | 
{ | 
| 1263 | 
< | 
        char    combuf[1024]; | 
| 1264 | 
< | 
        char    rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH+16], res[32]; | 
| 1263 | 
> | 
        FILE    *fp = fopen(sfname, "r"); | 
| 1264 | 
> | 
        int     todo = 1; | 
| 1265 | 
> | 
        int     x, y; | 
| 1266 | 
> | 
 | 
| 1267 | 
> | 
        if (fp == NULL) | 
| 1268 | 
> | 
                return(0); | 
| 1269 | 
> | 
        if (fscanf(fp, "%d %d", &x, &y) != 2) | 
| 1270 | 
> | 
                goto checked; | 
| 1271 | 
> | 
        todo = x*y;             /* total number of tiles */ | 
| 1272 | 
> | 
        if (fscanf(fp, "%d %d", &x, &y) != 2 || (x != 0) | (y != 0)) | 
| 1273 | 
> | 
                goto checked; | 
| 1274 | 
> | 
                                /* XXX assume no redundant tiles */ | 
| 1275 | 
> | 
        while (fscanf(fp, "%d %d", &x, &y) == 2) | 
| 1276 | 
> | 
                if (!--todo) | 
| 1277 | 
> | 
                        break; | 
| 1278 | 
> | 
checked: | 
| 1279 | 
> | 
        fclose(fp); | 
| 1280 | 
> | 
        return(!todo); | 
| 1281 | 
> | 
} | 
| 1282 | 
> | 
 | 
| 1283 | 
> | 
 | 
| 1284 | 
> | 
static void | 
| 1285 | 
> | 
rpict(                          /* run rpict and pfilt for each view */ | 
| 1286 | 
> | 
        char    *opts, | 
| 1287 | 
> | 
        char    *po | 
| 1288 | 
> | 
) | 
| 1289 | 
> | 
{ | 
| 1290 | 
> | 
#define do_rpiece       (sfile[0]!='\0') | 
| 1291 | 
> | 
        char    combuf[5*PATH_MAX+512]; | 
| 1292 | 
> | 
        char    rawfile[PATH_MAX], picfile[PATH_MAX]; | 
| 1293 | 
> | 
        char    zopt[PATH_MAX+4], rep[PATH_MAX+16], res[32]; | 
| 1294 | 
> | 
        char    rppopt[32], sfile[PATH_MAX], *pfile = NULL; | 
| 1295 | 
  | 
        char    pfopts[128]; | 
| 1296 | 
  | 
        char    vs[32], *vw; | 
| 1297 | 
  | 
        int     vn, mult; | 
| 1298 | 
+ | 
        FILE    *fp; | 
| 1299 | 
  | 
        time_t  rfdt, pfdt; | 
| 1300 | 
+ | 
        int     xres, yres; | 
| 1301 | 
+ | 
        double  aspect; | 
| 1302 | 
+ | 
        int     n; | 
| 1303 | 
  | 
                                        /* get pfilt options */ | 
| 1304 | 
  | 
        pfiltopts(pfopts); | 
| 1305 | 
  | 
                                        /* get resolution, reporting */ | 
| 1314 | 
  | 
                mult = 3; | 
| 1315 | 
  | 
                break; | 
| 1316 | 
  | 
        } | 
| 1317 | 
< | 
        { | 
| 1318 | 
< | 
                int     xres, yres; | 
| 1319 | 
< | 
                double  aspect; | 
| 1320 | 
< | 
                int     n; | 
| 1321 | 
< | 
                n = sscanf(vval(RESOLUTION), "%d %d %lf", &xres, &yres, &aspect); | 
| 1322 | 
< | 
                if (n == 3) | 
| 1323 | 
< | 
                        sprintf(res, "-x %d -y %d -pa %.3f", | 
| 1324 | 
< | 
                                        mult*xres, mult*yres, aspect); | 
| 1325 | 
< | 
                else if (n) { | 
| 1326 | 
< | 
                        if (n == 1) yres = xres; | 
| 1423 | 
< | 
                        sprintf(res, "-x %d -y %d", mult*xres, mult*yres); | 
| 1424 | 
< | 
                } else | 
| 1425 | 
< | 
                        badvalue(RESOLUTION); | 
| 1426 | 
< | 
        } | 
| 1317 | 
> | 
        n = sscanf(vval(RESOLUTION), "%d %d %lf", &xres, &yres, &aspect); | 
| 1318 | 
> | 
        if (n == 3) | 
| 1319 | 
> | 
                sprintf(res, "-x %d -y %d -pa %.3f", | 
| 1320 | 
> | 
                                mult*xres, mult*yres, aspect); | 
| 1321 | 
> | 
        else if (n) { | 
| 1322 | 
> | 
                aspect = 1.; | 
| 1323 | 
> | 
                if (n == 1) yres = xres; | 
| 1324 | 
> | 
                sprintf(res, "-x %d -y %d", mult*xres, mult*yres); | 
| 1325 | 
> | 
        } else | 
| 1326 | 
> | 
                badvalue(RESOLUTION); | 
| 1327 | 
  | 
        rep[0] = '\0'; | 
| 1328 | 
  | 
        if (vdef(REPORT)) { | 
| 1329 | 
  | 
                double  minutes; | 
| 1430 | 
– | 
                int     n; | 
| 1330 | 
  | 
                n = sscanf(vval(REPORT), "%lf %s", &minutes, rawfile); | 
| 1331 | 
  | 
                if (n == 2) | 
| 1332 | 
  | 
                        sprintf(rep, " -t %d -e %s", (int)(minutes*60), rawfile); | 
| 1335 | 
  | 
                else | 
| 1336 | 
  | 
                        badvalue(REPORT); | 
| 1337 | 
  | 
        } | 
| 1338 | 
< | 
                                        /* do each view */ | 
| 1339 | 
< | 
        vn = 0; | 
| 1338 | 
> | 
                                        /* set up parallel rendering */ | 
| 1339 | 
> | 
        sfile[0] = '\0'; | 
| 1340 | 
> | 
        if ((nprocs > 1) & !touchonly & !vdef(ZFILE) && | 
| 1341 | 
> | 
                                        getview(0, vs) != NULL) { | 
| 1342 | 
> | 
                if (!strcmp(c_rpict, DEF_RPICT_PATH) && | 
| 1343 | 
> | 
                                getview(1, NULL) == NULL) { | 
| 1344 | 
> | 
                        sprintf(sfile, "%s_%s_rpsync.txt",  | 
| 1345 | 
> | 
                                vdef(RAWFILE) ? vval(RAWFILE) : vval(PICTURE), | 
| 1346 | 
> | 
                                        vs); | 
| 1347 | 
> | 
                        strcpy(rppopt, "-PP pfXXXXXX"); | 
| 1348 | 
> | 
                } else { | 
| 1349 | 
> | 
                        strcpy(rppopt, "-S 1 -PP pfXXXXXX"); | 
| 1350 | 
> | 
                } | 
| 1351 | 
> | 
                pfile = rppopt + strlen(rppopt) - 8; | 
| 1352 | 
> | 
                if (mktemp(pfile) == NULL) { | 
| 1353 | 
> | 
                        if (do_rpiece) { | 
| 1354 | 
> | 
                                fprintf(stderr, "%s: cannot create\n", pfile); | 
| 1355 | 
> | 
                                quit(1); | 
| 1356 | 
> | 
                        } | 
| 1357 | 
> | 
                        pfile = NULL; | 
| 1358 | 
> | 
                } | 
| 1359 | 
> | 
        } | 
| 1360 | 
> | 
        vn = 0;                                 /* do each view */ | 
| 1361 | 
  | 
        while ((vw = getview(vn++, vs)) != NULL) { | 
| 1362 | 
  | 
                if (sayview) | 
| 1363 | 
< | 
                        printview(vw); | 
| 1364 | 
< | 
                if (!vs[0]) | 
| 1365 | 
< | 
                        sprintf(vs, "%d", vn); | 
| 1366 | 
< | 
                sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs); | 
| 1363 | 
> | 
                        myprintview(vw, stdout); | 
| 1364 | 
> | 
                sprintf(picfile, "%s_%s.hdr", vval(PICTURE), vs); | 
| 1365 | 
> | 
                if (vdef(ZFILE)) | 
| 1366 | 
> | 
                        sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs); | 
| 1367 | 
> | 
                else | 
| 1368 | 
> | 
                        zopt[0] = '\0'; | 
| 1369 | 
  | 
                                                /* check date on picture */ | 
| 1370 | 
  | 
                pfdt = fdate(picfile); | 
| 1371 | 
  | 
                if (pfdt >= oct1date) | 
| 1372 | 
  | 
                        continue; | 
| 1373 | 
  | 
                                                /* get raw file name */ | 
| 1374 | 
< | 
                sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs); | 
| 1374 | 
> | 
                sprintf(rawfile, "%s_%s.unf", | 
| 1375 | 
> | 
                        vdef(RAWFILE) ? vval(RAWFILE) : vval(PICTURE), vs); | 
| 1376 | 
  | 
                rfdt = fdate(rawfile); | 
| 1377 | 
  | 
                if (touchonly) {                /* update times only */ | 
| 1378 | 
  | 
                        if (rfdt) { | 
| 1382 | 
  | 
                                touch(picfile); | 
| 1383 | 
  | 
                        continue; | 
| 1384 | 
  | 
                } | 
| 1385 | 
+ | 
                                                /* parallel running? */ | 
| 1386 | 
+ | 
                if (do_rpiece) { | 
| 1387 | 
+ | 
                        if (rfdt < oct1date || !fdate(sfile)) { | 
| 1388 | 
+ | 
                                int     xdiv = 8+nprocs/3, ydiv = 8+nprocs/3; | 
| 1389 | 
+ | 
                                if (rfdt >= oct1date) { | 
| 1390 | 
+ | 
                                        fprintf(stderr, | 
| 1391 | 
+ | 
                "%s: partial output not created with %s\n", rawfile, c_rpiece); | 
| 1392 | 
+ | 
                                        quit(1); | 
| 1393 | 
+ | 
                                } | 
| 1394 | 
+ | 
                                if (rfdt) {     /* start fresh */ | 
| 1395 | 
+ | 
                                        rmfile(rawfile); | 
| 1396 | 
+ | 
                                        rfdt = 0; | 
| 1397 | 
+ | 
                                } | 
| 1398 | 
+ | 
                                if (!silent) | 
| 1399 | 
+ | 
                                        printf("\techo %d %d > %s\n", | 
| 1400 | 
+ | 
                                                        xdiv, ydiv, sfile); | 
| 1401 | 
+ | 
                                if ((fp = fopen(sfile, "w")) == NULL) { | 
| 1402 | 
+ | 
                                        fprintf(stderr, "%s: cannot create\n", | 
| 1403 | 
+ | 
                                                        sfile); | 
| 1404 | 
+ | 
                                        quit(1); | 
| 1405 | 
+ | 
                                } | 
| 1406 | 
+ | 
                                fprintf(fp, "%d %d\n", xdiv, ydiv); | 
| 1407 | 
+ | 
                                fclose(fp); | 
| 1408 | 
+ | 
                        } | 
| 1409 | 
+ | 
                } else if (next_process(0)) { | 
| 1410 | 
+ | 
                        if (pfile != NULL) | 
| 1411 | 
+ | 
                                sleep(10); | 
| 1412 | 
+ | 
                        continue; | 
| 1413 | 
+ | 
                } else if (!inchild()) | 
| 1414 | 
+ | 
                        pfile = NULL; | 
| 1415 | 
+ | 
                /* XXX Remember to call finish_process() */ | 
| 1416 | 
  | 
                                                /* build rpict command */ | 
| 1417 | 
< | 
                if (rfdt >= oct1date)           /* recover */ | 
| 1418 | 
< | 
                        sprintf(combuf, "rpict%s%s%s -ro %s %s", | 
| 1419 | 
< | 
                                        rep, po, opts, rawfile, oct1name); | 
| 1420 | 
< | 
                else { | 
| 1417 | 
> | 
                if (rfdt >= oct1date) {         /* already in progress */ | 
| 1418 | 
> | 
                        if (do_rpiece) { | 
| 1419 | 
> | 
                                sprintf(combuf, "%s -R %s %s%s %s %s%s%s -o %s %s", | 
| 1420 | 
> | 
                                                c_rpiece, sfile, rppopt, rep, vw, | 
| 1421 | 
> | 
                                                res, opts, po, rawfile, oct1name); | 
| 1422 | 
> | 
                                while (next_process(1)) { | 
| 1423 | 
> | 
                                        sleep(10); | 
| 1424 | 
> | 
                                        combuf[strlen(c_rpiece)+2] = 'F'; | 
| 1425 | 
> | 
                                } | 
| 1426 | 
> | 
                        } else | 
| 1427 | 
> | 
                                sprintf(combuf, "%s%s%s%s%s -ro %s %s", c_rpict, | 
| 1428 | 
> | 
                                        rep, opts, po, zopt, rawfile, oct1name); | 
| 1429 | 
> | 
                        if (runcom(combuf))     /* run rpict/rpiece */ | 
| 1430 | 
> | 
                                goto rperror; | 
| 1431 | 
> | 
                } else { | 
| 1432 | 
  | 
                        if (overture) {         /* run overture calculation */ | 
| 1433 | 
  | 
                                sprintf(combuf, | 
| 1434 | 
< | 
                                "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s", | 
| 1435 | 
< | 
                                                rep, vw, opts, | 
| 1434 | 
> | 
                                        "%s%s %s%s -x 64 -y 64 -ps 1 %s > %s", | 
| 1435 | 
> | 
                                                c_rpict, rep, vw, opts, | 
| 1436 | 
  | 
                                                oct1name, overfile); | 
| 1437 | 
< | 
                                if (runcom(combuf)) { | 
| 1438 | 
< | 
                                        fprintf(stderr, | 
| 1437 | 
> | 
                                if (!do_rpiece || !next_process(0)) { | 
| 1438 | 
> | 
                                        if (runcom(combuf)) { | 
| 1439 | 
> | 
                                                fprintf(stderr, | 
| 1440 | 
  | 
                                        "%s: error in overture for view %s\n", | 
| 1441 | 
< | 
                                                progname, vs); | 
| 1442 | 
< | 
                                        exit(1); | 
| 1443 | 
< | 
                                } | 
| 1444 | 
< | 
#ifdef NIX | 
| 1445 | 
< | 
                                rmfile(overfile); | 
| 1441 | 
> | 
                                                        progname, vs); | 
| 1442 | 
> | 
                                                quit(1); | 
| 1443 | 
> | 
                                        } | 
| 1444 | 
> | 
#ifndef NULL_DEVICE | 
| 1445 | 
> | 
                                        rmfile(overfile); | 
| 1446 | 
  | 
#endif | 
| 1447 | 
+ | 
                                } else if (do_rpiece) | 
| 1448 | 
+ | 
                                        sleep(20); | 
| 1449 | 
  | 
                        } | 
| 1450 | 
< | 
                        sprintf(combuf, "rpict%s %s %s%s%s %s > %s", | 
| 1451 | 
< | 
                                        rep, vw, res, po, opts, | 
| 1452 | 
< | 
                                oct1name, rawfile); | 
| 1450 | 
> | 
                        if (do_rpiece) { | 
| 1451 | 
> | 
                                sprintf(combuf, "%s -F %s %s%s %s %s%s%s -o %s %s", | 
| 1452 | 
> | 
                                                c_rpiece, sfile, rppopt, rep, vw, | 
| 1453 | 
> | 
                                                res, opts, po, rawfile, oct1name); | 
| 1454 | 
> | 
                                while (next_process(1)) | 
| 1455 | 
> | 
                                        sleep(10); | 
| 1456 | 
> | 
                        } else { | 
| 1457 | 
> | 
                                sprintf(combuf, "%s%s %s %s%s%s%s %s > %s", | 
| 1458 | 
> | 
                                                c_rpict, rep, vw, res, opts, po, | 
| 1459 | 
> | 
                                                zopt, oct1name, rawfile); | 
| 1460 | 
> | 
                        } | 
| 1461 | 
> | 
                        if ((pfile != NULL) & !do_rpiece) { | 
| 1462 | 
> | 
                                if (!silent) | 
| 1463 | 
> | 
                                        printf("\t%s\n", combuf); | 
| 1464 | 
> | 
                                fflush(stdout); | 
| 1465 | 
> | 
                                sprintf(combuf, "%s%s %s %s%s%s %s > %s", | 
| 1466 | 
> | 
                                                c_rpict, rep, rppopt, res, | 
| 1467 | 
> | 
                                                opts, po, oct1name, rawfile); | 
| 1468 | 
> | 
                                fp = popen(combuf, "w"); | 
| 1469 | 
> | 
                                if (fp == NULL) | 
| 1470 | 
> | 
                                        goto rperror; | 
| 1471 | 
> | 
                                myprintview(vw, fp); | 
| 1472 | 
> | 
                                if (pclose(fp)) | 
| 1473 | 
> | 
                                        goto rperror; | 
| 1474 | 
> | 
                        } else if (runcom(combuf)) | 
| 1475 | 
> | 
                                goto rperror; | 
| 1476 | 
  | 
                } | 
| 1477 | 
< | 
                if (runcom(combuf)) {           /* run rpict */ | 
| 1478 | 
< | 
                        fprintf(stderr, "%s: error rendering view %s\n", | 
| 1479 | 
< | 
                                        progname, vs); | 
| 1480 | 
< | 
                        exit(1); | 
| 1477 | 
> | 
                if (do_rpiece) {                /* need to finish raw, first */ | 
| 1478 | 
> | 
                        finish_process(); | 
| 1479 | 
> | 
                        wait_process(1); | 
| 1480 | 
> | 
                        if (!syncf_done(sfile)) { | 
| 1481 | 
> | 
                                fprintf(stderr, | 
| 1482 | 
> | 
                        "%s: %s did not complete rendering of view %s\n", | 
| 1483 | 
> | 
                                                progname, c_rpiece, vs); | 
| 1484 | 
> | 
                                quit(1); | 
| 1485 | 
> | 
                        } | 
| 1486 | 
  | 
                } | 
| 1487 | 
+ | 
                if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) { | 
| 1488 | 
  | 
                                                /* build pfilt command */ | 
| 1489 | 
< | 
                if (mult > 1) | 
| 1490 | 
< | 
                        sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s", | 
| 1491 | 
< | 
                                        pfopts, mult, mult, rawfile, picfile); | 
| 1492 | 
< | 
                else | 
| 1496 | 
< | 
                        sprintf(combuf, "pfilt%s %s > %s", pfopts, | 
| 1489 | 
> | 
                        if (do_rpiece) | 
| 1490 | 
> | 
                                sprintf(combuf, | 
| 1491 | 
> | 
                                        "%s%s -x %d -y %d -p %.3f %s > %s", | 
| 1492 | 
> | 
                                        c_pfilt, pfopts, xres, yres, aspect, | 
| 1493 | 
  | 
                                        rawfile, picfile); | 
| 1494 | 
< | 
                if (runcom(combuf)) {           /* run pfilt */ | 
| 1495 | 
< | 
                        fprintf(stderr, | 
| 1496 | 
< | 
                        "%s: error filtering view %s\n\t%s removed\n", | 
| 1497 | 
< | 
                                        progname, vs, picfile); | 
| 1498 | 
< | 
                        unlink(picfile); | 
| 1499 | 
< | 
                        exit(1); | 
| 1494 | 
> | 
                        else if (mult > 1) | 
| 1495 | 
> | 
                                sprintf(combuf, "%s%s -x /%d -y /%d %s > %s", | 
| 1496 | 
> | 
                                        c_pfilt, pfopts, mult, mult, | 
| 1497 | 
> | 
                                        rawfile, picfile); | 
| 1498 | 
> | 
                        else | 
| 1499 | 
> | 
                                sprintf(combuf, "%s%s %s > %s", c_pfilt, | 
| 1500 | 
> | 
                                        pfopts, rawfile, picfile); | 
| 1501 | 
> | 
                        if (runcom(combuf)) {   /* run pfilt */ | 
| 1502 | 
> | 
                                fprintf(stderr, | 
| 1503 | 
> | 
                                "%s: error filtering view %s\n\t%s removed\n", | 
| 1504 | 
> | 
                                                progname, vs, picfile); | 
| 1505 | 
> | 
                                unlink(picfile); | 
| 1506 | 
> | 
                                quit(1); | 
| 1507 | 
> | 
                        } | 
| 1508 | 
  | 
                } | 
| 1509 | 
  | 
                                                /* remove/rename raw file */ | 
| 1510 | 
< | 
                if (vbool(RAWSAVE)) { | 
| 1511 | 
< | 
                        sprintf(combuf, "%s_%s.rwp", vval(PICTURE), vs); | 
| 1510 | 
> | 
                if (vdef(RAWFILE)) { | 
| 1511 | 
> | 
                        sprintf(combuf, "%s_%s.hdr", vval(RAWFILE), vs); | 
| 1512 | 
  | 
                        mvfile(rawfile, combuf); | 
| 1513 | 
  | 
                } else | 
| 1514 | 
  | 
                        rmfile(rawfile); | 
| 1515 | 
+ | 
                if (do_rpiece)                  /* done with sync file */ | 
| 1516 | 
+ | 
                        rmfile(sfile); | 
| 1517 | 
+ | 
                else | 
| 1518 | 
+ | 
                        finish_process();       /* exit if child */ | 
| 1519 | 
  | 
        } | 
| 1520 | 
+ | 
        wait_process(1);                /* wait for children to finish */ | 
| 1521 | 
+ | 
        if (pfile != NULL) {            /* clean up persistent rpict */ | 
| 1522 | 
+ | 
                RT_PID  pid; | 
| 1523 | 
+ | 
                fp = fopen(pfile, "r"); | 
| 1524 | 
+ | 
                if (fp != NULL) { | 
| 1525 | 
+ | 
                        if (fscanf(fp, "%*s %d", &pid) != 1 || | 
| 1526 | 
+ | 
                                        kill(pid, 1) < 0) | 
| 1527 | 
+ | 
                                unlink(pfile); | 
| 1528 | 
+ | 
                        fclose(fp); | 
| 1529 | 
+ | 
                } | 
| 1530 | 
+ | 
        } | 
| 1531 | 
+ | 
        return; | 
| 1532 | 
+ | 
rperror: | 
| 1533 | 
+ | 
        fprintf(stderr, "%s: error rendering view %s\n", progname, vs); | 
| 1534 | 
+ | 
        quit(1); | 
| 1535 | 
+ | 
#undef do_rpiece | 
| 1536 | 
  | 
} | 
| 1537 | 
  | 
 | 
| 1538 | 
  | 
 | 
| 1539 | 
< | 
touch(fn)                       /* update a file */ | 
| 1540 | 
< | 
char    *fn; | 
| 1539 | 
> | 
static int | 
| 1540 | 
> | 
touch(                  /* update a file */ | 
| 1541 | 
> | 
        char    *fn | 
| 1542 | 
> | 
) | 
| 1543 | 
  | 
{ | 
| 1544 | 
  | 
        if (!silent) | 
| 1545 | 
  | 
                printf("\ttouch %s\n", fn); | 
| 1546 | 
< | 
        if (noaction) | 
| 1546 | 
> | 
        if (!nprocs) | 
| 1547 | 
  | 
                return(0); | 
| 1522 | 
– | 
#ifdef notused | 
| 1523 | 
– | 
        if (access(fn, F_OK) == -1)             /* create it */ | 
| 1524 | 
– | 
                if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1) | 
| 1525 | 
– | 
                        return(-1); | 
| 1526 | 
– | 
#endif | 
| 1548 | 
  | 
        return(setfdate(fn, time((time_t *)NULL))); | 
| 1549 | 
  | 
} | 
| 1550 | 
  | 
 | 
| 1551 | 
  | 
 | 
| 1552 | 
< | 
runcom(cs)                      /* run command */ | 
| 1553 | 
< | 
char    *cs; | 
| 1552 | 
> | 
static int | 
| 1553 | 
> | 
runcom(                 /* run command */ | 
| 1554 | 
> | 
        char    *cs | 
| 1555 | 
> | 
) | 
| 1556 | 
  | 
{ | 
| 1557 | 
  | 
        if (!silent)            /* echo it */ | 
| 1558 | 
  | 
                printf("\t%s\n", cs); | 
| 1559 | 
< | 
        if (noaction) | 
| 1559 | 
> | 
        if (!nprocs) | 
| 1560 | 
  | 
                return(0); | 
| 1561 | 
< | 
        fflush(stdout);         /* flush output and pass to shell */ | 
| 1561 | 
> | 
        fflush(NULL);           /* flush output and pass to shell */ | 
| 1562 | 
  | 
        return(system(cs)); | 
| 1563 | 
  | 
} | 
| 1564 | 
  | 
 | 
| 1565 | 
  | 
 | 
| 1566 | 
< | 
rmfile(fn)                      /* remove a file */ | 
| 1567 | 
< | 
char    *fn; | 
| 1566 | 
> | 
static int | 
| 1567 | 
> | 
rmfile(                 /* remove a file */ | 
| 1568 | 
> | 
        char    *fn | 
| 1569 | 
> | 
) | 
| 1570 | 
  | 
{ | 
| 1571 | 
  | 
        if (!silent) | 
| 1572 | 
< | 
#ifdef MSDOS | 
| 1573 | 
< | 
                printf("\tdel %s\n", fn); | 
| 1549 | 
< | 
#else | 
| 1550 | 
< | 
                printf("\trm -f %s\n", fn); | 
| 1551 | 
< | 
#endif | 
| 1552 | 
< | 
        if (noaction) | 
| 1572 | 
> | 
                printf("\t%s %s\n", DELCMD, fn); | 
| 1573 | 
> | 
        if (!nprocs) | 
| 1574 | 
  | 
                return(0); | 
| 1575 | 
  | 
        return(unlink(fn)); | 
| 1576 | 
  | 
} | 
| 1577 | 
  | 
 | 
| 1578 | 
  | 
 | 
| 1579 | 
< | 
mvfile(fold, fnew)              /* move a file */ | 
| 1580 | 
< | 
char    *fold, *fnew; | 
| 1579 | 
> | 
static int | 
| 1580 | 
> | 
mvfile(         /* move a file */ | 
| 1581 | 
> | 
        char    *fold, | 
| 1582 | 
> | 
        char    *fnew | 
| 1583 | 
> | 
) | 
| 1584 | 
  | 
{ | 
| 1585 | 
  | 
        if (!silent) | 
| 1586 | 
< | 
#ifdef MSDOS | 
| 1587 | 
< | 
                printf("\trename %s %s\n", fold, fnew); | 
| 1564 | 
< | 
#else | 
| 1565 | 
< | 
                printf("\tmv %s %s\n", fold, fnew); | 
| 1566 | 
< | 
#endif | 
| 1567 | 
< | 
        if (noaction) | 
| 1586 | 
> | 
                printf("\t%s %s %s\n", RENAMECMD, fold, fnew); | 
| 1587 | 
> | 
        if (!nprocs) | 
| 1588 | 
  | 
                return(0); | 
| 1589 | 
  | 
        return(rename(fold, fnew)); | 
| 1590 | 
  | 
} | 
| 1591 | 
  | 
 | 
| 1592 | 
  | 
 | 
| 1593 | 
< | 
#ifdef MSDOS | 
| 1593 | 
> | 
#ifdef RHAS_FORK_EXEC | 
| 1594 | 
> | 
static int | 
| 1595 | 
> | 
next_process(int reserve)               /* fork the next process */ | 
| 1596 | 
> | 
{ | 
| 1597 | 
> | 
        RT_PID  child_pid; | 
| 1598 | 
> | 
 | 
| 1599 | 
> | 
        if (nprocs <= 1) | 
| 1600 | 
> | 
                return(0);              /* it's us or no one */ | 
| 1601 | 
> | 
        if (inchild()) { | 
| 1602 | 
> | 
                fprintf(stderr, "%s: internal error 1 in next_process()\n", | 
| 1603 | 
> | 
                                progname); | 
| 1604 | 
> | 
                quit(1); | 
| 1605 | 
> | 
        } | 
| 1606 | 
> | 
        if (reserve > 0 && children_running >= nprocs-reserve) | 
| 1607 | 
> | 
                return(0);              /* caller holding back process(es) */ | 
| 1608 | 
> | 
        if (children_running >= nprocs) | 
| 1609 | 
> | 
                wait_process(0);        /* wait for someone to finish */ | 
| 1610 | 
> | 
        fflush(NULL);                   /* flush output */ | 
| 1611 | 
> | 
        child_pid = fork();             /* split process */ | 
| 1612 | 
> | 
        if (child_pid == 0) {           /* we're the child */ | 
| 1613 | 
> | 
                children_running = -1; | 
| 1614 | 
> | 
                nprocs = 1; | 
| 1615 | 
> | 
                return(0); | 
| 1616 | 
> | 
        } | 
| 1617 | 
> | 
        if (child_pid > 0) {            /* we're the parent */ | 
| 1618 | 
> | 
                ++children_running; | 
| 1619 | 
> | 
                return(1); | 
| 1620 | 
> | 
        } | 
| 1621 | 
> | 
        fprintf(stderr, "%s: warning -- fork() failed\n", progname); | 
| 1622 | 
> | 
        return(0); | 
| 1623 | 
> | 
} | 
| 1624 | 
> | 
 | 
| 1625 | 
> | 
static void | 
| 1626 | 
> | 
wait_process(                   /* wait for process(es) to finish */ | 
| 1627 | 
> | 
        int     all | 
| 1628 | 
> | 
) | 
| 1629 | 
> | 
{ | 
| 1630 | 
> | 
        int     ourstatus = 0, status; | 
| 1631 | 
> | 
        RT_PID  pid; | 
| 1632 | 
> | 
 | 
| 1633 | 
> | 
        if (all) | 
| 1634 | 
> | 
                all = children_running; | 
| 1635 | 
> | 
        else if (children_running > 0) | 
| 1636 | 
> | 
                all = 1; | 
| 1637 | 
> | 
        while (all-- > 0) { | 
| 1638 | 
> | 
                pid = wait(&status); | 
| 1639 | 
> | 
                if (pid < 0) | 
| 1640 | 
> | 
                        syserr(progname); | 
| 1641 | 
> | 
                status = status>>8 & 0xff; | 
| 1642 | 
> | 
                --children_running; | 
| 1643 | 
> | 
                if (status != 0) {      /* child's problem is our problem */ | 
| 1644 | 
> | 
                        if ((ourstatus == 0) & (children_running > 0)) | 
| 1645 | 
> | 
                                fprintf(stderr, "%s: waiting for remaining processes\n", | 
| 1646 | 
> | 
                                                progname); | 
| 1647 | 
> | 
                        ourstatus = status; | 
| 1648 | 
> | 
                        all = children_running; | 
| 1649 | 
> | 
                } | 
| 1650 | 
> | 
        } | 
| 1651 | 
> | 
        if (ourstatus != 0) | 
| 1652 | 
> | 
                quit(ourstatus);        /* bad status from child */ | 
| 1653 | 
> | 
} | 
| 1654 | 
> | 
#else   /* ! RHAS_FORK_EXEC */ | 
| 1655 | 
> | 
static int | 
| 1656 | 
> | 
next_process(int reserve) | 
| 1657 | 
> | 
{ | 
| 1658 | 
> | 
        return(0);                      /* cannot start new process */ | 
| 1659 | 
> | 
} | 
| 1660 | 
> | 
static void | 
| 1661 | 
> | 
wait_process(all) | 
| 1662 | 
> | 
int     all; | 
| 1663 | 
> | 
{ | 
| 1664 | 
> | 
        (void)all;                      /* no one to wait for */ | 
| 1665 | 
> | 
} | 
| 1666 | 
> | 
int | 
| 1667 | 
> | 
kill(pid, sig) /* win|unix_process.c should also wait and kill */ | 
| 1668 | 
> | 
RT_PID pid; | 
| 1669 | 
> | 
int sig; | 
| 1670 | 
> | 
{ | 
| 1671 | 
> | 
        return 0; | 
| 1672 | 
> | 
} | 
| 1673 | 
> | 
#endif  /* ! RHAS_FORK_EXEC */ | 
| 1674 | 
> | 
 | 
| 1675 | 
> | 
static void | 
| 1676 | 
> | 
finish_process(void)                    /* exit a child process */ | 
| 1677 | 
> | 
{ | 
| 1678 | 
> | 
        if (!inchild()) | 
| 1679 | 
> | 
                return;                 /* in parent -- noop */ | 
| 1680 | 
> | 
        exit(0); | 
| 1681 | 
> | 
} | 
| 1682 | 
> | 
 | 
| 1683 | 
> | 
#ifdef _WIN32 | 
| 1684 | 
  | 
setenv(vname, value)            /* set an environment variable */ | 
| 1685 | 
  | 
char    *vname, *value; | 
| 1686 | 
  | 
{ | 
| 1692 | 
  | 
        sprintf(evp, "%s=%s", vname, value); | 
| 1693 | 
  | 
        if (putenv(evp) != 0) { | 
| 1694 | 
  | 
                fprintf(stderr, "%s: out of environment space\n", progname); | 
| 1695 | 
< | 
                exit(1); | 
| 1695 | 
> | 
                quit(1); | 
| 1696 | 
  | 
        } | 
| 1697 | 
  | 
        if (!silent) | 
| 1698 | 
  | 
                printf("set %s\n", evp); | 
| 1700 | 
  | 
#endif | 
| 1701 | 
  | 
 | 
| 1702 | 
  | 
 | 
| 1703 | 
< | 
badvalue(vc)                    /* report bad variable value and exit */ | 
| 1704 | 
< | 
int     vc; | 
| 1703 | 
> | 
static void | 
| 1704 | 
> | 
badvalue(                       /* report bad variable value and exit */ | 
| 1705 | 
> | 
        int     vc | 
| 1706 | 
> | 
) | 
| 1707 | 
  | 
{ | 
| 1708 | 
  | 
        fprintf(stderr, "%s: bad value for variable '%s'\n", | 
| 1709 | 
  | 
                        progname, vnam(vc)); | 
| 1710 | 
< | 
        exit(1); | 
| 1710 | 
> | 
        quit(1); | 
| 1711 | 
  | 
} | 
| 1712 | 
  | 
 | 
| 1713 | 
  | 
 | 
| 1714 | 
< | 
syserr(s)                       /* report a system error and exit */ | 
| 1715 | 
< | 
char    *s; | 
| 1714 | 
> | 
static void | 
| 1715 | 
> | 
syserr(                 /* report a system error and exit */ | 
| 1716 | 
> | 
        char    *s | 
| 1717 | 
> | 
) | 
| 1718 | 
  | 
{ | 
| 1719 | 
  | 
        perror(s); | 
| 1720 | 
< | 
        exit(1); | 
| 1720 | 
> | 
        quit(1); | 
| 1721 | 
> | 
} | 
| 1722 | 
> | 
 | 
| 1723 | 
> | 
 | 
| 1724 | 
> | 
void | 
| 1725 | 
> | 
quit(ec)                        /* exit program */ | 
| 1726 | 
> | 
int     ec; | 
| 1727 | 
> | 
{ | 
| 1728 | 
> | 
        exit(ec); | 
| 1729 | 
  | 
} |