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

Comparing ray/src/util/rfluxmtx.c (file contents):
Revision 2.9 by greg, Fri Jul 25 16:58:20 2014 UTC vs.
Revision 2.15 by greg, Fri Aug 15 19:59:56 2014 UTC

# Line 11 | Line 11 | static const char RCSid[] = "$Id$";
11   #include <stdlib.h>
12   #include "rtio.h"
13   #include "rtmath.h"
14 + #include "rtprocess.h"
15   #include "bsdf.h"
16   #include "bsdf_m.h"
17   #include "random.h"
# Line 144 | Line 145 | surf_type(const char *otype)
145   static char *
146   oconv_command(int ac, char *av[])
147   {
148 <        static char     oconvbuf[2048] = "!oconv -f";
149 <        char            *cp = oconvbuf + 9;
150 <
148 >        static char     oconvbuf[2048] = "!oconv -f ";
149 >        char            *cp = oconvbuf + 10;
150 >        char            *recv = *av++;
151 >        
152 >        if (ac-- <= 0)
153 >                return(NULL);
154          while (ac-- > 0) {
155 +                strcpy(cp, *av++);
156 +                while (*cp) cp++;
157 +                *cp++ = ' ';
158                  if (cp >= oconvbuf+(sizeof(oconvbuf)-32)) {
159                          fputs(progname, stderr);
160                          fputs(": too many file arguments!\n", stderr);
161                          exit(1);
162                  }
156                *cp++ = ' ';
157                strcpy(cp, *av++);
158                while (*cp) cp++;
163          }
164 <        *cp = '\0';
164 >        strcpy(cp, recv);       /* receiver goes last */
165          return(oconvbuf);
166   }
167  
# Line 315 | Line 319 | parse_params(PARAMS *p, char *pargs)
319          int     nparams = 0;
320          int     i;
321  
322 <        for ( ; ; )
322 >        for ( ; ; ) {
323                  switch (*cp++) {
324                  case 'h':
325                          if (*cp++ != '=')
# Line 338 | Line 342 | parse_params(PARAMS *p, char *pargs)
342                                  break;
343                          if (!get_direction(p->vup, cp))
344                                  break;
345 +                        while (*cp && !isspace(*cp++))
346 +                                ;
347                          ++nparams;
348                          continue;
349                  case 'o':
# Line 356 | Line 362 | parse_params(PARAMS *p, char *pargs)
362                  case ' ':
363                  case '\t':
364                  case '\r':
359                case '\n':
365                          continue;
366 +                case '\n':
367                  case '\0':
368                          return(nparams);
369                  default:
370                          break;
371                  }
372 <        fprintf(stderr, "%s: bad parameter string '%s'\n", progname, pargs);
372 >                break;
373 >        }
374 >        fprintf(stderr, "%s: bad parameter string: %s", progname, pargs);
375          exit(1);
376          return(-1);     /* pro forma return */
377   }
# Line 401 | Line 409 | finish_receiver(void)
409                  fputs(": undefined normal for hemisphere sampling\n", stderr);
410                  exit(1);
411          }
412 <        if (normalize(curparams.vup) == 0)
412 >        if (normalize(curparams.vup) == 0) {
413                  if (fabs(curparams.nrm[2]) < .7)
414                          curparams.vup[2] = 1;
415                  else
416                          curparams.vup[1] = 1;
417 +        }
418                                          /* determine sample type/bin */
419          if (tolower(curparams.hemis[0]) == 'u' | curparams.hemis[0] == '1') {
420                  binv = "0";             /* uniform sampling -- one bin */
# Line 872 | Line 881 | prepare_sampler(void)
881                  fputs(": undefined normal for sender sampling\n", stderr);
882                  return(-1);
883          }
884 <        if (normalize(curparams.vup) == 0)
884 >        if (normalize(curparams.vup) == 0) {
885                  if (fabs(curparams.nrm[2]) < .7)
886                          curparams.vup[2] = 1;
887                  else
888                          curparams.vup[1] = 1;
889 +        }
890          VCROSS(curparams.udir, curparams.vup, curparams.nrm);
891          if (normalize(curparams.udir) == 0) {
892                  fputs(progname, stderr);
# Line 1066 | Line 1076 | add_recv_object(FILE *fp)
1076                                          /* else skip arguments */
1077          if (!fscanf(fp, "%d", &n)) return(0);
1078          while (n-- > 0) fscanf(fp, "%*s");
1079 <        if (!fscanf(fp, "%d", &n)) return;
1079 >        if (!fscanf(fp, "%d", &n)) return(0);
1080          while (n-- > 0) fscanf(fp, "%*d");
1081 <        if (!fscanf(fp, "%d", &n)) return;
1081 >        if (!fscanf(fp, "%d", &n)) return(0);
1082          while (n-- > 0) fscanf(fp, "%*f");
1083          return(0);
1084   }
# Line 1102 | Line 1112 | add_send_object(FILE *fp)
1112                                          /* else skip arguments */
1113          if (!fscanf(fp, "%d", &n)) return(0);
1114          while (n-- > 0) fscanf(fp, "%*s");
1115 <        if (!fscanf(fp, "%d", &n)) return;
1115 >        if (!fscanf(fp, "%d", &n)) return(0);
1116          while (n-- > 0) fscanf(fp, "%*d");
1117 <        if (!fscanf(fp, "%d", &n)) return;
1117 >        if (!fscanf(fp, "%d", &n)) return(0);
1118          while (n-- > 0) fscanf(fp, "%*f");
1119          return(0);
1120   }
# Line 1147 | Line 1157 | load_scene(const char *inspec, int (*ocb)(FILE *))
1157                                          strcat(newparams, inpbuf);
1158                                  continue;
1159                          }
1160 <                        while ((c = getc(fp)) != EOF && c != '\n');
1160 >                        while ((c = getc(fp)) != EOF && c != '\n')
1161                                  ;       /* else skipping comment */
1162                          continue;
1163                  }
# Line 1172 | Line 1182 | main(int argc, char *argv[])
1182   {
1183          char    fmtopt[6] = "-faa";     /* default output is ASCII */
1184          char    *xrs=NULL, *yrs=NULL, *ldopt=NULL;
1185 <        int     wantIrradiance = 0;
1185 >        char    *iropt = NULL;
1186          char    *sendfn;
1187          char    sampcntbuf[32], nsbinbuf[32];
1188          FILE    *rcfp;
# Line 1180 | Line 1190 | main(int argc, char *argv[])
1190          int     a, i;
1191                                          /* screen rcontrib options */
1192          progname = argv[0];
1193 <        for (a = 1; a < argc-2 && argv[a][0] == '-'; a++) {
1194 <                int     na = 1;         /* !! Keep consistent !! */
1195 <                switch (argv[a][1]) {
1193 >        for (a = 1; a < argc-2; a++) {
1194 >                int     na;
1195 >                                        /* check for argument expansion */
1196 >                while ((na = expandarg(&argc, &argv, a)) > 0)
1197 >                        ;
1198 >                if (na < 0) {
1199 >                        fprintf(stderr, "%s: cannot expand '%s'\n",
1200 >                                        progname, argv[a]);
1201 >                        return(1);
1202 >                }
1203 >                if (argv[a][0] != '-' || !argv[a][1])
1204 >                        break;
1205 >                na = 1;
1206 >                switch (argv[a][1]) {   /* !! Keep consistent !! */
1207                  case 'v':               /* verbose mode */
1208                          verbose = !verbose;
1209                          na = 0;
# Line 1221 | Line 1242 | main(int argc, char *argv[])
1242                          na = 0;         /* we re-add this later */
1243                          continue;
1244                  case 'I':               /* only for pass-through mode */
1245 <                        wantIrradiance = 1;
1245 >                case 'i':
1246 >                        iropt = argv[a];
1247                          na = 0;
1248                          continue;
1249                  case 'V':               /* options without arguments */
1250                  case 'w':
1251                  case 'u':
1230                case 'i':
1252                  case 'h':
1253                  case 'r':
1254                          break;
# Line 1257 | Line 1278 | main(int argc, char *argv[])
1278                          if (!argv[a][2]) goto userr;
1279                          na = (argv[a][2] == 'e') | (argv[a][2] == 'a') ? 4 : 2;
1280                          break;
1260                case '\0':              /* pass-through mode */
1261                        goto done_opts;
1281                  default:                /* anything else is verbotten */
1282                          goto userr;
1283                  }
# Line 1268 | Line 1287 | main(int argc, char *argv[])
1287                  while (--na)            /* + arguments if any */
1288                          rcarg[nrcargs++] = argv[++a];
1289          }
1271 done_opts:
1290          if (a > argc-2)
1291                  goto userr;             /* check at end of options */
1292          sendfn = argv[a++];             /* assign sender & receiver inputs */
1293          if (sendfn[0] == '-') {         /* user wants pass-through mode? */
1294                  if (sendfn[1]) goto userr;
1295                  sendfn = NULL;
1296 <                if (wantIrradiance) {
1296 >                if (iropt) {
1297                          CHECKARGC(1);
1298 <                        rcarg[nrcargs++] = "-I";
1298 >                        rcarg[nrcargs++] = iropt;
1299                  }
1300                  if (xrs) {
1301                          CHECKARGC(2);
# Line 1295 | Line 1313 | done_opts:
1313                  }
1314                  if (sampcnt <= 0) sampcnt = 1;
1315          } else {                        /* else in sampling mode */
1316 <                if (wantIrradiance) {
1316 >                if (iropt) {
1317                          fputs(progname, stderr);
1318 <                        fputs(": -I supported for pass-through only\n", stderr);
1318 >                        fputs(": -i, -I supported for pass-through only\n", stderr);
1319                          return(1);
1320                  }
1321                  fmtopt[2] = (sizeof(RREAL)==sizeof(double)) ? 'd' : 'f';
# Line 1350 | Line 1368 | done_opts:
1368   userr:
1369          if (a < argc-2)
1370                  fprintf(stderr, "%s: unsupported option '%s'", progname, argv[a]);
1371 <        fprintf(stderr, "Usage: %s [-v][rcontrib options] sender.rad receiver.rad [system.rad ..]\n",
1371 >        fprintf(stderr, "Usage: %s [-v][rcontrib options] sender.rad receiver.rad [-i system.oct] [system.rad ..]\n",
1372                                  progname);
1373          return(1);
1374   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines