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.81 by schorsch, Mon Sep 12 14:40:13 2005 UTC vs.
Revision 2.91 by greg, Thu Dec 18 23:26:57 2008 UTC

# Line 47 | Line 47 | static const char      RCSid[] = "$Id$";
47   #define RENDER          17              /* rendering options */
48   #define REPORT          18              /* report frequency and errfile */
49   #define RESOLUTION      19              /* maximum picture resolution */
50 < #define SCENE           20              /* scene files */
51 < #define UP              21              /* view up (X, Y or Z) */
52 < #define VARIABILITY     22              /* level of light variability */
53 < #define VIEWS           23              /* view(s) for picture(s) */
54 < #define ZFILE           24              /* distance file root name */
55 < #define ZONE            25              /* simulation zone */
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 < int NVARS = 26;
59 > int NVARS = 28;
60  
61   VARIABLE        vv[] = {                /* variable-value pairs */
62          {"AMBFILE",     3,      0,      NULL,   onevalue},
# Line 77 | Line 79 | VARIABLE       vv[] = {                /* variable-value pairs */
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},
86          {"VARIABILITY", 3,      0,      NULL,   qualvalue},
# Line 112 | Line 116 | int    sayview = 0;            /* print view out */
116   char    *rvdevice = NULL;       /* rvu output device */
117   char    *viewselect = NULL;     /* specific view only */
118  
119 +                                /* command paths */
120 + char    c_oconv[256] = "oconv";
121 + char    c_mkillum[256] = "mkillum";
122 + char    c_rvu[256] = "rvu";
123 + char    c_rpict[256] = "rpict";
124 + char    c_pfilt[256] = "pfilt";
125 +
126   int     overture = 0;           /* overture calculation needed */
127  
128   int     children_running = 0;   /* set negative in children */
# Line 208 | Line 219 | main(
219                  goto userr;
220          rifname = argv[i];
221                                  /* check command-line options */
222 <        if ((nprocs > 1) & (viewselect != NULL))
222 >        if ((nprocs > 1) & (viewselect != NULL) & (rvdevice == NULL))
223                  nprocs = 1;
224                                  /* assign Radiance root file name */
225          rootname(radname, rifname);
# Line 480 | Line 491 | oconv(void)                            /* run oconv and mkillum if necessary *
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 */
# Line 510 | Line 521 | oconv(void)                            /* run oconv and mkillum if necessary *
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);
518 <                        else
519 <                                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",
# Line 537 | Line 550 | oconv(void)                            /* run oconv and mkillum if necessary *
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                          quit(1);
560                  }
561                                                  /* make octree1 (frozen) */
562                  if (octreedate)
563 <                        sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
564 <                                vval(OCTREE), illumtmp, oct1name);
563 >                        sprintf(combuf, "%s%s -f -i %s %s > %s", c_oconv,
564 >                                ocopts, vval(OCTREE), illumtmp, oct1name);
565                  else if (vdef(MATERIAL))
566 <                        sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
567 <                                vval(MATERIAL), illumtmp, oct1name);
566 >                        sprintf(combuf, "%s%s -f %s %s > %s", c_oconv,
567 >                                ocopts, vval(MATERIAL), illumtmp, oct1name);
568                  else
569 <                        sprintf(combuf, "oconv%s -f %s > %s", ocopts,
569 >                        sprintf(combuf, "%s%s -f %s > %s", c_oconv, ocopts,
570                                  illumtmp, oct1name);
571                  if (runcom(combuf)) {           /* run it */
572                          fprintf(stderr,
# Line 572 | Line 585 | oconv(void)                            /* run oconv and mkillum if necessary *
585  
586  
587   static char *
588 < addarg(                         /* add argument and advance pointer */
588 > addarg(                         /* append argument and advance pointer */
589   register char   *op,
590   register char   *arg
591   )
592   {
593 +        while (*op)
594 +                op++;
595          *op = ' ';
596          while ( (*++op = *arg++) )
597                  ;
# Line 593 | Line 608 | oconvopts(                             /* get oconv options */
608  
609          *oo = '\0';
610          if (vdef(OCONV))
611 <                addarg(oo, vval(OCONV));
611 >                if (vval(OCONV)[0] != '-') {
612 >                        atos(c_oconv, sizeof(c_oconv), vval(OCONV));
613 >                        oo = addarg(oo, sskip2(vval(OCONV), 1));
614 >                } else
615 >                        oo = addarg(oo, vval(OCONV));
616   }
617  
618  
# Line 604 | Line 623 | mkillumopts(                           /* get mkillum options */
623   {
624          /* BEWARE:  This may be called via setdefaults(), so no assumptions */
625  
626 <        if (nprocs > 1) {
626 >        if (nprocs > 1)
627                  sprintf(mo, " -n %d", nprocs);
628 <                while (*mo)
610 <                        mo++;
611 <        } else
628 >        else
629                  *mo = '\0';
630          if (vdef(MKILLUM))
631 <                addarg(mo, vval(MKILLUM));
631 >                if (vval(MKILLUM)[0] != '-') {
632 >                        atos(c_mkillum, sizeof(c_mkillum), vval(MKILLUM));
633 >                        mo = addarg(mo, sskip2(vval(MKILLUM), 1));
634 >                } else
635 >                        mo = addarg(mo, vval(MKILLUM));
636   }
637  
638  
# Line 667 | Line 688 | renderopts(                    /* set rendering options */
688                  hiqopts(op, po);
689                  break;
690          }
691 +        if (vdef(RENDER))
692 +                op = addarg(op, vval(RENDER));
693 +        if (rvdevice != NULL) {
694 +                if (vdef(RVU))
695 +                        if (vval(RVU)[0] != '-') {
696 +                                atos(c_rvu, sizeof(c_rvu), vval(RVU));
697 +                                po = addarg(po, sskip2(vval(RVU), 1));
698 +                        } else
699 +                                po = addarg(po, vval(RVU));
700 +        } else {
701 +                if (vdef(RPICT))
702 +                        if (vval(RPICT)[0] != '-') {
703 +                                atos(c_rpict, sizeof(c_rpict), vval(RPICT));
704 +                                po = addarg(po, sskip2(vval(RPICT), 1));
705 +                        } else
706 +                                po = addarg(po, vval(RPICT));
707 +        }
708   }
709  
710  
# Line 735 | Line 773 | lowqopts(                      /* low quality rendering options */
773          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
774          op += strlen(op);
775          op = addarg(op, "-lr 6 -lw .01");
738        if (vdef(RENDER))
739                op = addarg(op, vval(RENDER));
776   }
777  
778  
# Line 787 | Line 823 | medqopts(                      /* medium quality rendering options */
823          }
824          po = addarg(po, "-pt .08");
825          if (vbool(PENUMBRAS))
826 <                op = addarg(op, "-ds .2 -dj .5");
826 >                op = addarg(op, "-ds .2 -dj .9");
827          else
828                  op = addarg(op, "-ds .3");
829          op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
# Line 815 | Line 851 | medqopts(                      /* medium quality rendering options */
851          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
852          op += strlen(op);
853          op = addarg(op, "-lr 8 -lw .002");
818        if (vdef(RENDER))
819                op = addarg(op, vval(RENDER));
854   }
855  
856  
# Line 867 | Line 901 | hiqopts(                               /* high quality rendering options */
901          }
902          po = addarg(po, "-pt .04");
903          if (vbool(PENUMBRAS))
904 <                op = addarg(op, "-ds .1 -dj .65");
904 >                op = addarg(op, "-ds .1 -dj .9");
905          else
906                  op = addarg(op, "-ds .2");
907          op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
# Line 893 | Line 927 | hiqopts(                               /* high quality rendering options */
927          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
928          op += strlen(op);
929          op = addarg(op, "-lr 12 -lw .0005");
896        if (vdef(RENDER))
897                op = addarg(op, vval(RENDER));
930   }
931  
932  
# Line 950 | Line 982 | pfiltopts(                             /* get pfilt options */
982                  break;
983          }
984          if (vdef(PFILT))
985 <                po = addarg(po, vval(PFILT));
985 >                if (vval(PFILT)[0] != '-') {
986 >                        atos(c_pfilt, sizeof(c_pfilt), vval(PFILT));
987 >                        po = addarg(po, sskip2(vval(PFILT), 1));
988 >                } else
989 >                        po = addarg(po, vval(PFILT));
990   }
991  
992  
# Line 1012 | Line 1048 | specview(                              /* get proper view spec from vs */
1048          } else if (*vs == 'z') {
1049                  zpos = -1; vs++;
1050          }
1051 <        viewtype = 'v';
1052 <        if((*vs == 'v') | (*vs == 'l') | (*vs == 'a') | (*vs == 'h') | (*vs == 'c'))
1051 >        switch (*vs) {
1052 >        case VT_PER:
1053 >        case VT_PAR:
1054 >        case VT_ANG:
1055 >        case VT_HEM:
1056 >        case VT_PLS:
1057 >        case VT_CYL:
1058                  viewtype = *vs++;
1059 +                break;
1060 +        default:
1061 +                viewtype = VT_PER;
1062 +                break;
1063 +        }
1064          cp = viewopts;
1065          if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) {       /* got one! */
1066                  *cp++ = '-'; *cp++ = 'v'; *cp++ = 't'; *cp++ = viewtype;
# Line 1056 | Line 1102 | specview(                              /* get proper view spec from vs */
1102                  }
1103                  cp = addarg(cp, vup[upax+3]);
1104                  switch (viewtype) {
1105 <                case 'v':
1105 >                case VT_PER:
1106                          cp = addarg(cp, "-vh 45 -vv 45");
1107                          break;
1108 <                case 'l':
1108 >                case VT_PAR:
1109                          d = sqrt(dim[0]*dim[0]+dim[1]*dim[1]+dim[2]*dim[2]);
1110                          sprintf(cp, " -vh %.2g -vv %.2g", d, d);
1111                          cp += strlen(cp);
1112                          break;
1113 <                case 'a':
1114 <                case 'h':
1113 >                case VT_ANG:
1114 >                case VT_HEM:
1115 >                case VT_PLS:
1116                          cp = addarg(cp, "-vh 180 -vv 180");
1117                          break;
1118 <                case 'c':
1118 >                case VT_CYL:
1119                          cp = addarg(cp, "-vh 180 -vv 90");
1120                          break;
1121                  }
# Line 1185 | Line 1232 | rvu(                           /* run rvu with first view */
1232                  return;
1233          if (sayview)
1234                  myprintview(vw, stdout);
1235 <        sprintf(combuf, "rvu %s%s%s -R %s ", vw, po, opts, rifname);
1235 >        sprintf(combuf, "%s %s%s%s -R %s ", c_rvu, vw, opts, po, rifname);
1236 >        if (nprocs > 1)
1237 >                sprintf(combuf+strlen(combuf), "-n %d ", nprocs);
1238          if (rvdevice != NULL)
1239                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1240          if (vdef(EXPOSURE))
1241                  sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE));
1242          strcat(combuf, oct1name);
1243          if (runcom(combuf)) {           /* run it */
1244 <                fprintf(stderr, "%s: error running rvu\n", progname);
1244 >                fprintf(stderr, "%s: error running %s\n", progname, c_rvu);
1245                  quit(1);
1246          }
1247   }
# Line 1266 | Line 1315 | rpict(                         /* run rpict and pfilt for each view */
1315                          myprintview(vw, stdout);
1316                  if (!vs[0])
1317                          sprintf(vs, "%d", vn);
1318 <                sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1318 >                sprintf(picfile, "%s_%s.hdr", vval(PICTURE), vs);
1319                  if (vdef(ZFILE))
1320                          sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs);
1321                  else
# Line 1295 | Line 1344 | rpict(                         /* run rpict and pfilt for each view */
1344                  /* XXX Remember to call finish_process() */
1345                                                  /* build rpict command */
1346                  if (rfdt >= oct1date) {         /* recover */
1347 <                        sprintf(combuf, "rpict%s%s%s%s -ro %s %s",
1348 <                                rep, po, opts, zopt, rawfile, oct1name);
1347 >                        sprintf(combuf, "%s%s%s%s%s -ro %s %s", c_rpict,
1348 >                                rep, opts, po, zopt, rawfile, oct1name);
1349                          if (runcom(combuf))     /* run rpict */
1350                                  goto rperror;
1351                  } else {
1352                          if (overture) {         /* run overture calculation */
1353                                  sprintf(combuf,
1354 <                                "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1355 <                                                rep, vw, opts,
1354 >                                "%s%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1355 >                                                c_rpict, rep, vw, opts,
1356                                                  oct1name, overfile);
1357                                  if (runcom(combuf)) {
1358                                          fprintf(stderr,
# Line 1315 | Line 1364 | rpict(                         /* run rpict and pfilt for each view */
1364                                  rmfile(overfile);
1365   #endif
1366                          }
1367 <                        sprintf(combuf, "rpict%s %s %s%s%s%s %s > %s",
1368 <                                        rep, vw, res, po, opts,
1367 >                        sprintf(combuf, "%s%s %s %s%s%s%s %s > %s",
1368 >                                        c_rpict, rep, vw, res, opts, po,
1369                                          zopt, oct1name, rawfile);
1370                          if (pfile != NULL && inchild()) {
1371                                                  /* rpict persistent mode */
1372 <                                if (!silent) {
1372 >                                if (!silent)
1373                                          printf("\t%s\n", combuf);
1325                                        fflush(stdout);
1326                                }
1327                                sprintf(combuf, "rpict%s %s %s%s%s %s > %s",
1328                                                rep, rppopt, res, po, opts,
1329                                                oct1name, rawfile);
1374                                  fflush(stdout);
1375 +                                sprintf(combuf, "%s%s %s %s%s%s %s > %s",
1376 +                                                c_rpict, rep, rppopt, res, opts,
1377 +                                                po, oct1name, rawfile);
1378                                  fp = popen(combuf, "w");
1379                                  if (fp == NULL)
1380                                          goto rperror;
# Line 1342 | Line 1389 | rpict(                         /* run rpict and pfilt for each view */
1389                  if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) {
1390                                                  /* build pfilt command */
1391                          if (mult > 1)
1392 <                                sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
1393 <                                        pfopts, mult, mult, rawfile, picfile);
1392 >                                sprintf(combuf, "%s%s -x /%d -y /%d %s > %s",
1393 >                                        c_pfilt, pfopts, mult, mult,
1394 >                                        rawfile, picfile);
1395                          else
1396 <                                sprintf(combuf, "pfilt%s %s > %s", pfopts,
1397 <                                                rawfile, picfile);
1396 >                                sprintf(combuf, "%s%s %s > %s", c_pfilt,
1397 >                                        pfopts, rawfile, picfile);
1398                          if (runcom(combuf)) {   /* run pfilt */
1399                                  fprintf(stderr,
1400                                  "%s: error filtering view %s\n\t%s removed\n",
# Line 1357 | Line 1405 | rpict(                         /* run rpict and pfilt for each view */
1405                  }
1406                                                  /* remove/rename raw file */
1407                  if (vdef(RAWFILE)) {
1408 <                        sprintf(combuf, "%s_%s.pic", vval(RAWFILE), vs);
1408 >                        sprintf(combuf, "%s_%s.hdr", vval(RAWFILE), vs);
1409                          mvfile(rawfile, combuf);
1410                  } else
1411                          rmfile(rawfile);
# Line 1408 | Line 1456 | runcom(                        /* run command */
1456                  printf("\t%s\n", cs);
1457          if (!nprocs)
1458                  return(0);
1459 <        fflush(stdout);         /* flush output and pass to shell */
1459 >        fflush(NULL);           /* flush output and pass to shell */
1460          return(system(cs));
1461   }
1462  
# Line 1455 | Line 1503 | next_process(void)                     /* fork the next process (max. np
1503          }
1504          if (children_running >= nprocs)
1505                  wait_process(0);        /* wait for someone to finish */
1506 <        fflush(stdout);
1506 >        fflush(NULL);                   /* flush output */
1507          child_pid = fork();             /* split process */
1508          if (child_pid == 0) {           /* we're the child */
1509                  children_running = -1;
# Line 1474 | Line 1522 | wait_process(                  /* wait for process(es) to finish */
1522          int     all
1523   )
1524   {
1525 <        int     ourstatus = 0;
1526 <        RT_PID  pid, status;
1525 >        int     ourstatus = 0, status;
1526 >        RT_PID  pid;
1527  
1528          if (all)
1529                  all = children_running;
# Line 1512 | Line 1560 | int    all;
1560   }
1561   int
1562   kill(pid, sig) /* win|unix_process.c should also wait and kill */
1563 < RT_PID pid, sig;
1563 > RT_PID pid;
1564 > int sig;
1565   {
1566          return 0;
1567   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines