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.110 by greg, Wed Dec 4 20:07:07 2013 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines