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.105 by greg, Fri Feb 25 06:51:51 2011 UTC vs.
Revision 2.111 by greg, Sun Oct 26 17:35:53 2014 UTC

# 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 264 | Line 265 | userr:
265  
266   static void
267   rootname(               /* remove tail from end of fn */
268 <        register char   *rn,
269 <        register char   *fn
268 >        char    *rn,
269 >        char    *fn
270   )
271   {
272          char    *tp, *dp;
# Line 282 | Line 283 | rootname(              /* remove tail from end of fn */
283  
284   static time_t
285   checklast(                      /* check files and find most recent */
286 <        register char   *fnames
286 >        char    *fnames
287   )
288   {
289          char    thisfile[PATH_MAX];
# Line 312 | Line 313 | newfname(              /* create modified file name */
313          int     pred
314   )
315   {
316 <        register char   *cp;
317 <        register int    n;
316 >        char    *cp;
317 >        int     n;
318          int     suffix;
319  
320          n = 0; cp = orig; suffix = -1;          /* suffix position, length */
# Line 378 | Line 379 | getoctcube(            /* get octree bounding cube */
379          double  min[3], max[3];
380          char    buf[1024];
381          FILE    *fp;
382 <        register int    i;
382 >        int     i;
383  
384          if (osiz <= FTINY) {
385                  if (!nprocs && fdate(oct1name) <
# Line 558 | Line 559 | oconv(void)                            /* run oconv and mkillum if necessary *
559                          unlink(illumtmp);
560                          quit(1);
561                  }
562 +                rmfile(oct0name);
563                                                  /* make octree1 (frozen) */
564                  if (octreedate)
565                          sprintf(combuf, "%s%s -f -i %s %s > %s", c_oconv,
# Line 586 | Line 588 | oconv(void)                            /* run oconv and mkillum if necessary *
588  
589   static char *
590   addarg(                         /* append argument and advance pointer */
591 < register char   *op,
592 < register char   *arg
591 > char    *op,
592 > char    *arg
593   )
594   {
595          while (*op)
# Line 601 | Line 603 | register char  *arg
603  
604   static void
605   oconvopts(                              /* get oconv options */
606 <        register char   *oo
606 >        char    *oo
607   )
608   {
609          /* BEWARE:  This may be called via setdefaults(), so no assumptions */
# Line 710 | Line 712 | renderopts(                    /* set rendering options */
712  
713   static void
714   lowqopts(                       /* low quality rendering options */
715 <        register char   *op,
715 >        char    *op,
716          char    *po
717   )
718   {
# Line 778 | Line 780 | lowqopts(                      /* low quality rendering options */
780  
781   static void
782   medqopts(                       /* medium quality rendering options */
783 <        register char   *op,
783 >        char    *op,
784          char    *po
785   )
786   {
# Line 856 | Line 858 | medqopts(                      /* medium quality rendering options */
858  
859   static void
860   hiqopts(                                /* high quality rendering options */
861 <        register char   *op,
861 >        char    *op,
862          char    *po
863   )
864   {
# Line 930 | Line 932 | hiqopts(                               /* high quality rendering options */
932   }
933  
934  
935 + #ifdef _WIN32
936   static void
937 + setenv(                 /* set an environment variable */
938 +        char    *vname,
939 +        char    *value
940 + )
941 + {
942 +        char    *evp;
943 +
944 +        evp = bmalloc(strlen(vname)+strlen(value)+2);
945 +        if (evp == NULL)
946 +                syserr(progname);
947 +        sprintf(evp, "%s=%s", vname, value);
948 +        if (putenv(evp) != 0) {
949 +                fprintf(stderr, "%s: out of environment space\n", progname);
950 +                quit(1);
951 +        }
952 +        if (!silent)
953 +                printf("set %s\n", evp);
954 + }
955 + #endif
956 +
957 +
958 + static void
959   xferopts(                               /* transfer options if indicated */
960          char    *ro
961   )
962   {
963          int     fd, n;
964 <        register char   *cp;
964 >        char    *cp;
965          
966          n = strlen(ro);
967          if (n < 2)
# Line 965 | Line 990 | xferopts(                              /* transfer options if indicated */
990  
991   static void
992   pfiltopts(                              /* get pfilt options */
993 <        register char   *po
993 >        char    *po
994   )
995   {
996          *po = '\0';
# Line 992 | Line 1017 | pfiltopts(                             /* get pfilt options */
1017  
1018   static int
1019   matchword(                      /* match white-delimited words */
1020 <        register char   *s1,
1021 <        register char   *s2
1020 >        char    *s1,
1021 >        char    *s2
1022   )
1023   {
1024          while (isspace(*s1)) s1++;
# Line 1007 | Line 1032 | matchword(                     /* match white-delimited words */
1032  
1033   static char *
1034   specview(                               /* get proper view spec from vs */
1035 <        register char   *vs
1035 >        char    *vs
1036   )
1037   {
1038          static char     vup[7][12] = {"-vu 0 0 -1","-vu 0 -1 0","-vu -1 0 0",
1039                          "-vu 0 0 1", "-vu 1 0 0","-vu 0 1 0","-vu 0 0 1"};
1040          static char     viewopts[128];
1041 <        register char   *cp;
1041 >        char    *cp;
1042          int     xpos, ypos, zpos, viewtype, upax;
1043 <        register int    i;
1043 >        int     i;
1044          double  cent[3], dim[3], mult, d;
1045  
1046          if (vs == NULL || *vs == '-')
# Line 1075 | Line 1100 | specview(                              /* get proper view spec from vs */
1100                          cent[i] += .5*dim[i];
1101                  }
1102                  mult = vlet(ZONE)=='E' ? 2. : .45 ;
1103 <                sprintf(cp, " -vp %.2g %.2g %.2g -vd %.2g %.2g %.2g",
1103 >                sprintf(cp, " -vp %.3g %.3g %.3g -vd %.3g %.3g %.3g",
1104                                  cent[0]+xpos*mult*dim[0],
1105                                  cent[1]+ypos*mult*dim[1],
1106                                  cent[2]+zpos*mult*dim[2],
# Line 1107 | Line 1132 | specview(                              /* get proper view spec from vs */
1132                          break;
1133                  case VT_PAR:
1134                          d = sqrt(dim[0]*dim[0]+dim[1]*dim[1]+dim[2]*dim[2]);
1135 <                        sprintf(cp, " -vh %.2g -vv %.2g", d, d);
1135 >                        sprintf(cp, " -vh %.3g -vv %.3g", d, d);
1136                          cp += strlen(cp);
1137                          break;
1138                  case VT_ANG:
# Line 1147 | Line 1172 | getview(                               /* get view n, or NULL if none */
1172          char    *vn             /* returned view name */
1173   )
1174   {
1175 <        register char   *mv;
1175 >        char    *mv;
1176  
1177          if (viewselect != NULL) {               /* command-line selected */
1178                  if (n)                          /* only do one */
# Line 1179 | Line 1204 | numview:
1204          mv = nvalue(VIEWS, n);          /* use view n */
1205          if ((vn != NULL) & (mv != NULL))
1206                  if (*mv != '-') {
1207 <                        register char   *mv2 = mv;
1207 >                        char    *mv2 = mv;
1208                          while (*mv2 && !isspace(*mv2))
1209                                  *vn++ = *mv2++;
1210                          *vn = '\0';
# Line 1192 | Line 1217 | numview:
1217  
1218   static int
1219   myprintview(                    /* print out selected view */
1220 <        register char   *vopts,
1220 >        char    *vopts,
1221          FILE    *fp
1222   )
1223   {
1224          VIEW    vwr;
1225          char    buf[128];
1226 <        register char   *cp;
1226 >        char    *cp;
1227   #ifdef _WIN32
1228   /* XXX Should we allow something like this for all platforms? */
1229   /* XXX Or is it still required at all? */
# Line 1254 | Line 1279 | rvu(                           /* run rvu with first view */
1279   }
1280  
1281  
1282 + static int
1283 + syncf_done(                     /* check if an rpiece sync file is complete */
1284 +        char *sfname
1285 + )
1286 + {
1287 +        FILE    *fp = fopen(sfname, "r");
1288 +        int     todo = 1;
1289 +        int     x, y;
1290 +
1291 +        if (fp == NULL)
1292 +                return(0);
1293 +        if (fscanf(fp, "%d %d", &x, &y) != 2)
1294 +                goto checked;
1295 +        todo = x*y;             /* total number of tiles */
1296 +        if (fscanf(fp, "%d %d", &x, &y) != 2 || (x != 0) | (y != 0))
1297 +                goto checked;
1298 +                                /* XXX assume no redundant tiles */
1299 +        while (fscanf(fp, "%d %d", &x, &y) == 2)
1300 +                if (!--todo)
1301 +                        break;
1302 + checked:
1303 +        fclose(fp);
1304 +        return(!todo);
1305 + }
1306 +
1307 +
1308   static void
1309   rpict(                          /* run rpict and pfilt for each view */
1310          char    *opts,
# Line 1361 | Line 1412 | rpict(                         /* run rpict and pfilt for each view */
1412                                  int     xdiv = 8+nprocs/3, ydiv = 8+nprocs/3;
1413                                  if (rfdt >= oct1date) {
1414                                          fprintf(stderr,
1415 <                "%s: partial output not created with rpiece\n", rawfile);
1415 >                "%s: partial output not created with %s\n", rawfile, c_rpiece);
1416                                          quit(1);
1417                                  }
1418                                  if (rfdt) {     /* start fresh */
# Line 1450 | Line 1501 | rpict(                         /* run rpict and pfilt for each view */
1501                  if (do_rpiece) {                /* need to finish raw, first */
1502                          finish_process();
1503                          wait_process(1);
1504 <                        /* XXX should check sync file to see if really done? */
1504 >                        if (!syncf_done(sfile)) {
1505 >                                fprintf(stderr,
1506 >                        "%s: %s did not complete rendering of view %s\n",
1507 >                                                progname, c_rpiece, vs);
1508 >                                quit(1);
1509 >                        }
1510                  }
1511                  if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) {
1512                                                  /* build pfilt command */
# Line 1647 | Line 1703 | finish_process(void)                   /* exit a child process */
1703                  return;                 /* in parent -- noop */
1704          exit(0);
1705   }
1650
1651 #ifdef _WIN32
1652 setenv(vname, value)            /* set an environment variable */
1653 char    *vname, *value;
1654 {
1655        register char   *evp;
1656
1657        evp = bmalloc(strlen(vname)+strlen(value)+2);
1658        if (evp == NULL)
1659                syserr(progname);
1660        sprintf(evp, "%s=%s", vname, value);
1661        if (putenv(evp) != 0) {
1662                fprintf(stderr, "%s: out of environment space\n", progname);
1663                quit(1);
1664        }
1665        if (!silent)
1666                printf("set %s\n", evp);
1667 }
1668 #endif
1706  
1707  
1708   static void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines