ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rad.c
(Generate patch)

Comparing ray/src/util/rad.c (file contents):
Revision 2.106 by greg, Wed Aug 24 05:54:42 2011 UTC vs.
Revision 2.135 by greg, Sat Jun 7 05:09:46 2025 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines