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.1 by greg, Sat Jul 19 01:19:49 2014 UTC vs.
Revision 2.9 by greg, Fri Jul 25 16:58:20 2014 UTC

# Line 23 | Line 23 | static const char RCSid[] = "$Id$";
23   #endif
24  
25   #ifdef _WIN32
26 < #define SPECIALS        " \t$*?"
26 > #define SPECIALS        " \t\"$*?"
27   #define QUOTCHAR        '"'
28   #else
29 < #define SPECIALS        " \t\n'\"()${}*?[]"
29 > #define SPECIALS        " \t\n'\"()${}*?[];|&"
30   #define QUOTCHAR        '\''
31   #define ALTQUOT         '"'
32   #endif
# Line 45 | Line 45 | const char     overflowerr[] = "%s: too many arguments!\n"
45   #define CHECKARGC(n)    if (nrcargs >= MAXRCARG-(n)) \
46          { fprintf(stderr, overflowerr, progname); exit(1); }
47  
48 < int             sampcnt = 0;            /* sample count (unset) */
48 > int             sampcnt = 0;            /* sample count (0==unset) */
49  
50 < char            *reinhfn = "reinhart.cal";
51 < char            *shirchufn = "disk2square.cal";
50 > char            *reinhfn = "reinhartb.cal";
51 > char            *shirchiufn = "disk2square.cal";
52   char            *kfullfn = "klems_full.cal";
53   char            *khalffn = "klems_half.cal";
54   char            *kquarterfn = "klems_quarter.cal";
55  
56 < #define PARAMSTART      "@rfluxmtx"     /* string indicating parameters */
56 >                                        /* string indicating parameters */
57 > const char      PARAMSTART[] = "@rfluxmtx";
58  
59                                  /* surface type IDs */
60   #define ST_NONE         0
# Line 66 | Line 67 | typedef struct surf_s {
67          void            *priv;          /* private data (malloc'ed) */
68          char            sname[32];      /* surface name */
69          FVECT           snrm;           /* surface normal */
70 <        double          area;           /* surface area (or solid angle) */
70 >        double          area;           /* surface area / proj. solid angle */
71          short           styp;           /* surface type */
72 <        short           nfargs;         /* number of arguments */
73 <        double          farg[1];        /* arguments (extends struct) */
72 >        short           nfargs;         /* number of real arguments */
73 >        double          farg[1];        /* real values (extends struct) */
74   } SURF;                         /* surface structure */
75  
76   typedef struct {
# Line 95 | Line 96 | typedef struct param_s {
96  
97   PARAMS          curparams;
98   char            curmod[128];
99 + char            newparams[1024];
100  
101   typedef int     SURFSAMP(FVECT, SURF *, double);
102  
# Line 108 | Line 110 | SURFSAMP       *orig_in_surf[4] = {
110   static void
111   clear_params(PARAMS *p, int reset_only)
112   {
111        curmod[0] = '\0';
113          while (p->slist != NULL) {
114                  SURF    *sdel = p->slist;
115                  p->slist = sdel->next;
# Line 123 | Line 124 | clear_params(PARAMS *p, int reset_only)
124                  p->outfn = NULL;
125                  return;
126          }
127 <        memset(p, 0, sizeof(curparams));
127 >        memset(p, 0, sizeof(PARAMS));
128   }
129  
130   /* Get surface type from name */
# Line 308 | Line 309 | nextchar:
309  
310   /* Parse program parameters (directives) */
311   static int
312 < parse_params(char *pargs)
312 > parse_params(PARAMS *p, char *pargs)
313   {
314          char    *cp = pargs;
315          int     nparams = 0;
# Line 319 | Line 320 | parse_params(char *pargs)
320                  case 'h':
321                          if (*cp++ != '=')
322                                  break;
323 <                        curparams.hsiz = 0;
323 >                        p->hsiz = 0;
324                          i = 0;
325                          while (*cp && !isspace(*cp)) {
326                                  if (isdigit(*cp))
327 <                                        curparams.hsiz = 10*curparams.hsiz +
328 <                                                                *cp - '0';
328 <                                curparams.hemis[i++] = *cp++;
327 >                                        p->hsiz = 10*p->hsiz + *cp - '0';
328 >                                p->hemis[i++] = *cp++;
329                          }
330                          if (!i)
331                                  break;
332 <                        curparams.hemis[i] = '\0';
333 <                        curparams.hsiz += !curparams.hsiz;
332 >                        p->hemis[i] = '\0';
333 >                        p->hsiz += !p->hsiz;
334                          ++nparams;
335                          continue;
336                  case 'u':
337                          if (*cp++ != '=')
338                                  break;
339 <                        if (!get_direction(curparams.vup, cp))
339 >                        if (!get_direction(p->vup, cp))
340                                  break;
341                          ++nparams;
342                          continue;
# Line 349 | Line 349 | parse_params(char *pargs)
349                          if (!i)
350                                  break;
351                          *--cp = '\0';
352 <                        curparams.outfn = savqstr(cp-i);
352 >                        p->outfn = savqstr(cp-i);
353                          *cp++ = ' ';
354                          ++nparams;
355                          continue;
# Line 372 | Line 372 | parse_params(char *pargs)
372   static void
373   finish_receiver(void)
374   {
375 <        char    binbuf[128];
375 >        char    sbuf[256];
376 >        int     uniform = 0;
377 >        char    *calfn = NULL;
378 >        char    *params = NULL;
379 >        char    *binv = NULL;
380 >        char    *binf = NULL;
381 >        char    *nbins = NULL;
382  
383          if (!curmod[0]) {
384                  fputs(progname, stderr);
# Line 384 | Line 390 | finish_receiver(void)
390                  rcarg[nrcargs++] = "-o";
391                  rcarg[nrcargs++] = curparams.outfn;
392          }
393 <                                        /* add bin specification */
393 >                                        /* check arguments */
394          if (!curparams.hemis[0]) {
395                  fputs(progname, stderr);
396                  fputs(": missing hemisphere sampling type!\n", stderr);
# Line 400 | Line 406 | finish_receiver(void)
406                          curparams.vup[2] = 1;
407                  else
408                          curparams.vup[1] = 1;
409 +                                        /* determine sample type/bin */
410          if (tolower(curparams.hemis[0]) == 'u' | curparams.hemis[0] == '1') {
411 <                CHECKARGC(2);
412 <                rcarg[nrcargs++] = "-b";
406 <                rcarg[nrcargs++] = "0";
411 >                binv = "0";             /* uniform sampling -- one bin */
412 >                uniform = 1;
413          } else if (tolower(curparams.hemis[0]) == 's' &&
414                                  tolower(curparams.hemis[1]) == 'c') {
415 <                if (shirchufn != NULL) {
410 <                        CHECKARGC(2);
411 <                        rcarg[nrcargs++] = "-f";
412 <                        rcarg[nrcargs++] = shirchufn;
413 <                        shirchufn = NULL;
414 <                }
415 < fputs("Shirley-Chiu unimplemented...\n",stderr); exit(1);
415 >                                        /* assign parameters */
416                  if (curparams.hsiz <= 1) {
417                          fputs(progname, stderr);
418                          fputs(": missing size for Shirley-Chiu sampling!\n", stderr);
419                          exit(1);
420                  }
421 +                calfn = shirchiufn; shirchiufn = NULL;
422 +                sprintf(sbuf, "SCdim=%d,rNx=%g,rNy=%g,rNz=%g,Ux=%g,Uy=%g,Uz=%g",
423 +                                curparams.hsiz,
424 +                        curparams.nrm[0], curparams.nrm[1], curparams.nrm[2],
425 +                        curparams.vup[0], curparams.vup[1], curparams.vup[2]);
426 +                params = savqstr(sbuf);
427 +                binv = "scbin";
428 +                nbins = "SCdim*SCdim";
429          } else if ((tolower(curparams.hemis[0]) == 'r') |
430                          (tolower(curparams.hemis[0]) == 't')) {
431 <                if (reinhfn != NULL) {
432 <                        CHECKARGC(2);
433 <                        rcarg[nrcargs++] = "-f";
434 <                        rcarg[nrcargs++] = reinhfn;
435 <                        reinhfn = NULL;
436 <                }
437 < fputs("Reinhart/Tregenza unimplemented...\n",stderr); exit(1);
431 >                calfn = reinhfn; reinhfn = NULL;
432 >                sprintf(sbuf, "MF=%d,rNx=%g,rNy=%g,rNz=%g,Ux=%g,Uy=%g,Uz=%g",
433 >                                curparams.hsiz,
434 >                        curparams.nrm[0], curparams.nrm[1], curparams.nrm[2],
435 >                        curparams.vup[0], curparams.vup[1], curparams.vup[2]);
436 >                params = savqstr(sbuf);
437 >                binv = "rbin";
438 >                nbins = "Nrbins";
439          } else if (tolower(curparams.hemis[0]) == 'k' &&
440                          !curparams.hemis[1] |
441                          (tolower(curparams.hemis[1]) == 'f') |
442                          (curparams.hemis[1] == '1')) {
443 <                if (kfullfn != NULL) {
444 <                        CHECKARGC(2);
445 <                        rcarg[nrcargs++] = "-f";
437 <                        rcarg[nrcargs++] = kfullfn;
438 <                        kfullfn = NULL;
439 <                }
440 <                CHECKARGC(4);
441 <                sprintf(binbuf, "kbin(%g,%g,%g,%g,%g,%g)",
442 <                        curparams.nrm[0], curparams.nrm[1], curparams.nrm[2],
443 <                        curparams.vup[0], curparams.vup[1], curparams.vup[2]);
444 <                rcarg[nrcargs++] = "-b";
445 <                rcarg[nrcargs++] = savqstr(binbuf);
446 <                rcarg[nrcargs++] = "-bn";
447 <                rcarg[nrcargs++] = "Nkbins";
443 >                calfn = kfullfn; kfullfn = NULL;
444 >                binf = "kbin";
445 >                nbins = "Nkbins";
446          } else if (tolower(curparams.hemis[0]) == 'k' &&
447                          (tolower(curparams.hemis[1]) == 'h') |
448                          (curparams.hemis[1] == '2')) {
449 <                if (khalffn != NULL) {
450 <                        CHECKARGC(2);
451 <                        rcarg[nrcargs++] = "-f";
454 <                        rcarg[nrcargs++] = khalffn;
455 <                        khalffn = NULL;
456 <                }
457 <                CHECKARGC(4);
458 <                sprintf(binbuf, "khbin(%g,%g,%g,%g,%g,%g)",
459 <                        curparams.nrm[0], curparams.nrm[1], curparams.nrm[2],
460 <                        curparams.vup[0], curparams.vup[1], curparams.vup[2]);
461 <                rcarg[nrcargs++] = "-b";
462 <                rcarg[nrcargs++] = savqstr(binbuf);
463 <                rcarg[nrcargs++] = "-bn";
464 <                rcarg[nrcargs++] = "Nkhbins";
449 >                calfn = khalffn; khalffn = NULL;
450 >                binf = "khbin";
451 >                nbins = "Nkhbins";
452          } else if (tolower(curparams.hemis[0]) == 'k' &&
453                          (tolower(curparams.hemis[1]) == 'q') |
454                          (curparams.hemis[1] == '4')) {
455 <                if (kquarterfn != NULL) {
456 <                        CHECKARGC(2);
457 <                        rcarg[nrcargs++] = "-f";
471 <                        rcarg[nrcargs++] = kquarterfn;
472 <                        kquarterfn = NULL;
473 <                }
474 <                CHECKARGC(4);
475 <                sprintf(binbuf, "kqbin(%g,%g,%g,%g,%g,%g)",
476 <                        curparams.nrm[0], curparams.nrm[1], curparams.nrm[2],
477 <                        curparams.vup[0], curparams.vup[1], curparams.vup[2]);
478 <                rcarg[nrcargs++] = "-b";
479 <                rcarg[nrcargs++] = savqstr(binbuf);
480 <                rcarg[nrcargs++] = "-bn";
481 <                rcarg[nrcargs++] = "Nkqbins";
455 >                calfn = kquarterfn; kquarterfn = NULL;
456 >                binf = "kqbin";
457 >                nbins = "Nkqbins";
458          } else {
459                  fprintf(stderr, "%s: unrecognized hemisphere sampling: h=%s\n",
460                                  progname, curparams.hemis);
461                  exit(1);
462          }
463 <        CHECKARGC(2);                   /* modifier argument goes last */
463 >        if (!uniform & (curparams.slist->styp == ST_SOURCE)) {
464 >                SURF    *sp;
465 >                for (sp = curparams.slist; sp != NULL; sp = sp->next)
466 >                        if (fabs(sp->area - PI) > 1e-3) {
467 >                                fprintf(stderr, "%s: source '%s' must be 180-degrees\n",
468 >                                                progname, sp->sname);
469 >                                exit(1);
470 >                        }
471 >        }
472 >        if (calfn != NULL) {            /* add cal file if needed */
473 >                CHECKARGC(2);
474 >                rcarg[nrcargs++] = "-f";
475 >                rcarg[nrcargs++] = calfn;
476 >        }
477 >        if (params != NULL) {           /* parameters _after_ cal file */
478 >                CHECKARGC(2);
479 >                rcarg[nrcargs++] = "-p";
480 >                rcarg[nrcargs++] = params;
481 >        }
482 >        if (nbins != NULL) {            /* add #bins if set */
483 >                CHECKARGC(2);
484 >                rcarg[nrcargs++] = "-bn";
485 >                rcarg[nrcargs++] = nbins;
486 >        }
487 >        if (binv != NULL) {
488 >                CHECKARGC(2);           /* assign bin variable */
489 >                rcarg[nrcargs++] = "-b";
490 >                rcarg[nrcargs++] = binv;
491 >        } else if (binf != NULL) {
492 >                CHECKARGC(2);           /* assign bin function */
493 >                rcarg[nrcargs++] = "-b";
494 >                sprintf(sbuf, "%s(%g,%g,%g,%g,%g,%g)", binf,
495 >                        curparams.nrm[0], curparams.nrm[1], curparams.nrm[2],
496 >                        curparams.vup[0], curparams.vup[1], curparams.vup[2]);
497 >                rcarg[nrcargs++] = savqstr(sbuf);
498 >        }
499 >        CHECKARGC(2);                           /* modifier argument goes last */
500          rcarg[nrcargs++] = "-m";
501          rcarg[nrcargs++] = savqstr(curmod);
502   }
# Line 541 | Line 553 | ssamp_ring(FVECT orig, SURF *sp, double x)
553                  sp->priv = (void *)uva;
554          }
555          SDmultiSamp(samp2, 2, x);
556 <        samp2[0] = sp->farg[6] + sqrt(samp2[0]*sp->area*(1./PI));
556 >        samp2[0] = sqrt(samp2[0]*sp->area*(1./PI) + sp->farg[6]*sp->farg[6]);
557          samp2[1] *= 2.*PI;
558          uv[0] = samp2[0]*tcos(samp2[1]);
559          uv[1] = samp2[0]*tsin(samp2[1]);
# Line 594 | Line 606 | ssamp_poly(FVECT orig, SURF *sp, double x)
606                          }
607                          ptp->ntris = 0;
608                          v2l->p = (void *)ptp;
609 <                        if (!polyTriangulate(v2l, add_triangle))
609 >                        if (!polyTriangulate(v2l, add_triangle)) {
610 >                                fprintf(stderr,
611 >                                        "%s: cannot triangulate polygon '%s'\n",
612 >                                                progname, sp->sname);
613                                  return(0);
614 +                        }
615                          for (i = ptp->ntris; i--; ) {
616                                  int     a = ptp->tri[i].vndx[0];
617                                  int     b = ptp->tri[i].vndx[1];
# Line 644 | Line 660 | sample_origin(PARAMS *p, FVECT orig, const FVECT rdir,
660                                          /* special case for lone surface */
661          if (p->nsurfs == 1) {
662                  sp = p->slist;
663 <                if (DOT(sp->snrm, rdir) >= -FTINY)
664 <                        return(0);      /* behind surface! */
663 >                if (DOT(sp->snrm, rdir) >= -FTINY) {
664 >                        fprintf(stderr,
665 >                                "%s: internal - sample behind sender '%s'\n",
666 >                                        progname, sp->sname);
667 >                        return(0);
668 >                }
669                  return((*orig_in_surf[sp->styp])(orig, sp, x));
670          }
671          if (p->nsurfs > nall) {         /* (re)allocate surface area cache */
# Line 659 | Line 679 | sample_origin(PARAMS *p, FVECT orig, const FVECT rdir,
679                  projsa[i] = -DOT(sp->snrm, rdir) * sp->area;
680                  tarea += projsa[i] *= (double)(projsa[i] > FTINY);
681          }
682 <        if (tarea <= FTINY)             /* wrong side of sender? */
682 >        if (tarea <= FTINY) {           /* wrong side of sender? */
683 >                fputs(progname, stderr);
684 >                fputs(": internal - sample behind all sender elements!\n",
685 >                                stderr);
686                  return(0);
687 +        }
688          tarea *= x;                     /* get surface from list */
689          for (i = 0, sp = p->slist; tarea > projsa[i]; sp = sp->next)
690                  tarea -= projsa[i++];
# Line 733 | Line 757 | sample_reinhart(PARAMS *p, int b, FILE *fp)
757   #define T_NALT  7
758          static const int        tnaz[T_NALT] = {30, 30, 24, 24, 18, 12, 6};
759          const int               RowMax = T_NALT*p->hsiz + 1;
760 <        const double            RAH = (.25*PI)/(RowMax-.5);
760 >        const double            RAH = (.5*PI)/(RowMax-.5);
761   #define rnaz(r)                 (r >= RowMax-1 ? 1 : p->hsiz*tnaz[r/p->hsiz])
762          int                     n = sampcnt;
763          int                     row, col;
# Line 758 | Line 782 | sample_reinhart(PARAMS *p, int b, FILE *fp)
782                  SDmultiSamp(samp3, 3, (n+frandom())/sampcnt);
783                  alt = (row+samp3[1])*RAH;
784                  azi = (2.*PI)*(col+samp3[2]-.5)/rnaz(row);
785 <                duvw[2] = tcos(alt);    /* measured from horizon */
785 >                duvw[2] = cos(alt);     /* measured from horizon */
786                  duvw[0] = tcos(azi)*duvw[2];
787                  duvw[1] = tsin(azi)*duvw[2];
788                  duvw[2] = sqrt(1. - duvw[2]*duvw[2]);
# Line 976 | Line 1000 | add_surface(int st, const char *oname, FILE *fp)
1000          case ST_SOURCE:
1001                  if (snew->nfargs != 4)
1002                          goto badcount;
1003 <                VCOPY(snew->snrm, snew->farg);
1003 >                for (n = 3; n--; )      /* need to reverse "normal" */
1004 >                        snew->snrm[n] = -snew->farg[n];
1005                  if (normalize(snew->snrm) == 0)
1006                          goto badnorm;
1007 <                snew->area = 2.*PI*(1. - cos((PI/180./2.)*snew->farg[3]));
1007 >                snew->area = sin((PI/180./2.)*snew->farg[3]);
1008 >                snew->area *= PI*snew->area;
1009                  break;
1010          }
1011          if (snew->area <= FTINY) {
# Line 994 | Line 1020 | add_surface(int st, const char *oname, FILE *fp)
1020          curparams.nsurfs++;
1021          return;
1022   badcount:
1023 <        fprintf(stderr, "%s: bad argument count for surface '%s'\n",
1023 >        fprintf(stderr, "%s: bad argument count for surface element '%s'\n",
1024                          progname, oname);
1025          exit(1);
1026   badnorm:
1027 <        fprintf(stderr, "%s: bad orientation for surface '%s'\n",
1027 >        fprintf(stderr, "%s: bad orientation for surface element '%s'\n",
1028                          progname, oname);
1029          exit(1);
1030   }
# Line 1030 | Line 1056 | add_recv_object(FILE *fp)
1056                                  finish_receiver();
1057                                  clear_params(&curparams, 1);
1058                          }
1059 +                        parse_params(&curparams, newparams);
1060 +                        newparams[0] = '\0';
1061                          strcpy(curmod, thismod);
1062                  }
1063                  add_surface(st, oname, fp);     /* read & store surface */
1064                  return(1);
1065          }
1066                                          /* else skip arguments */
1067 <        if (!fscanf(fp, "%d", &n)) return;
1067 >        if (!fscanf(fp, "%d", &n)) return(0);
1068          while (n-- > 0) fscanf(fp, "%*s");
1069          if (!fscanf(fp, "%d", &n)) return;
1070          while (n-- > 0) fscanf(fp, "%*d");
# Line 1066 | Line 1094 | add_send_object(FILE *fp)
1094                          fputs(": cannot use source as a sender!\n", stderr);
1095                          return(-1);
1096                  }
1097 +                parse_params(&curparams, newparams);
1098 +                newparams[0] = '\0';
1099                  add_surface(st, oname, fp);     /* read & store surface */
1100                  return(0);
1101          }
1102                                          /* else skip arguments */
1103 <        if (!fscanf(fp, "%d", &n)) return;
1103 >        if (!fscanf(fp, "%d", &n)) return(0);
1104          while (n-- > 0) fscanf(fp, "%*s");
1105          if (!fscanf(fp, "%d", &n)) return;
1106          while (n-- > 0) fscanf(fp, "%*d");
# Line 1109 | Line 1139 | load_scene(const char *inspec, int (*ocb)(FILE *))
1139                          continue;
1140                  }
1141                  if (c == '#') {         /* parameters/comment */
1142 <                        if (fscanf(fp, "%s", inpbuf) == 1 &&
1142 >                        if ((c = getc(fp)) == EOF || ungetc(c,fp) == EOF)
1143 >                                break;
1144 >                        if (!isspace(c) && fscanf(fp, "%s", inpbuf) == 1 &&
1145                                          !strcmp(inpbuf, PARAMSTART)) {
1146                                  if (fgets(inpbuf, sizeof(inpbuf), fp) != NULL)
1147 <                                        parse_params(inpbuf);
1147 >                                        strcat(newparams, inpbuf);
1148                                  continue;
1149                          }
1150                          while ((c = getc(fp)) != EOF && c != '\n');
# Line 1139 | Line 1171 | int
1171   main(int argc, char *argv[])
1172   {
1173          char    fmtopt[6] = "-faa";     /* default output is ASCII */
1174 +        char    *xrs=NULL, *yrs=NULL, *ldopt=NULL;
1175 +        int     wantIrradiance = 0;
1176          char    *sendfn;
1177          char    sampcntbuf[32], nsbinbuf[32];
1178          FILE    *rcfp;
# Line 1163 | Line 1197 | main(int argc, char *argv[])
1197                          case 'f':
1198                          case 'd':
1199                          case 'c':
1200 <                                if (!(fmtopt[4] = argv[a][3]))
1201 <                                        fmtopt[4] = argv[a][2];
1202 <                                fmtopt[3] = argv[a][2];
1200 >                                if (!(fmtopt[3] = argv[a][3]))
1201 >                                        fmtopt[3] = argv[a][2];
1202 >                                fmtopt[2] = argv[a][2];
1203                                  na = 0;
1204                                  continue;       /* will pass later */
1205                          default:
1206                                  goto userr;
1207                          }
1208                          break;
1209 +                case 'x':               /* x-resolution */
1210 +                        xrs = argv[++a];
1211 +                        na = 0;
1212 +                        continue;
1213 +                case 'y':               /* y-resolution */
1214 +                        yrs = argv[++a];
1215 +                        na = 0;
1216 +                        continue;
1217                  case 'c':               /* number of samples */
1218 <                        sampcnt = atoi(argv[a+1]);
1218 >                        sampcnt = atoi(argv[++a]);
1219                          if (sampcnt <= 0)
1220                                  goto userr;
1221                          na = 0;         /* we re-add this later */
1222                          continue;
1223 +                case 'I':               /* only for pass-through mode */
1224 +                        wantIrradiance = 1;
1225 +                        na = 0;
1226 +                        continue;
1227                  case 'V':               /* options without arguments */
1228                  case 'w':
1229                  case 'u':
1230                  case 'i':
1231                  case 'h':
1232 +                case 'r':
1233                          break;
1234                  case 'n':               /* options with 1 argument */
1235                  case 's':
# Line 1193 | Line 1240 | main(int argc, char *argv[])
1240                          if (argv[a][2] != 'v') goto userr;
1241                          break;
1242                  case 'l':               /* special case */
1243 <                        if (argv[a][2] == 'd') goto userr;
1243 >                        if (argv[a][2] == 'd') {
1244 >                                ldopt = argv[a];
1245 >                                na = 0;
1246 >                                continue;
1247 >                        }
1248                          na = 2;
1249                          break;
1250                  case 'd':               /* special case */
# Line 1224 | Line 1275 | done_opts:
1275          if (sendfn[0] == '-') {         /* user wants pass-through mode? */
1276                  if (sendfn[1]) goto userr;
1277                  sendfn = NULL;
1278 +                if (wantIrradiance) {
1279 +                        CHECKARGC(1);
1280 +                        rcarg[nrcargs++] = "-I";
1281 +                }
1282 +                if (xrs) {
1283 +                        CHECKARGC(2);
1284 +                        rcarg[nrcargs++] = "-x";
1285 +                        rcarg[nrcargs++] = xrs;
1286 +                }
1287 +                if (yrs) {
1288 +                        CHECKARGC(2);
1289 +                        rcarg[nrcargs++] = "-y";
1290 +                        rcarg[nrcargs++] = yrs;
1291 +                }
1292 +                if (ldopt) {
1293 +                        CHECKARGC(1);
1294 +                        rcarg[nrcargs++] = ldopt;
1295 +                }
1296                  if (sampcnt <= 0) sampcnt = 1;
1297 <        } else {                        /* else FVECT determines input format */
1298 <                fmtopt[3] = (sizeof(RREAL)==sizeof(double)) ? 'd' : 'f';
1297 >        } else {                        /* else in sampling mode */
1298 >                if (wantIrradiance) {
1299 >                        fputs(progname, stderr);
1300 >                        fputs(": -I supported for pass-through only\n", stderr);
1301 >                        return(1);
1302 >                }
1303 >                fmtopt[2] = (sizeof(RREAL)==sizeof(double)) ? 'd' : 'f';
1304                  if (sampcnt <= 0) sampcnt = 10000;
1305          }
1306          sprintf(sampcntbuf, "%d", sampcnt);
# Line 1265 | Line 1339 | done_opts:
1339          if (verbose) {
1340                  fprintf(stderr, "%s: sampling %d directions", progname, nsbins);
1341                  if (curparams.nsurfs > 1)
1342 <                        fprintf(stderr, " (%d surfaces)\n", curparams.nsurfs);
1342 >                        fprintf(stderr, " (%d elements)\n", curparams.nsurfs);
1343                  else
1344                          fputc('\n', stderr);
1345          }
# Line 1276 | Line 1350 | done_opts:
1350   userr:
1351          if (a < argc-2)
1352                  fprintf(stderr, "%s: unsupported option '%s'", progname, argv[a]);
1353 <        fprintf(stderr, "Usage: %s [rcontrib options] sender.rad receiver.rad [system.rad ..]\n",
1353 >        fprintf(stderr, "Usage: %s [-v][rcontrib options] sender.rad receiver.rad [system.rad ..]\n",
1354                                  progname);
1355          return(1);
1356   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines