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.10 by greg, Fri Jul 25 17:03:06 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 395 | Line 401 | finish_receiver(void)
401                  fputs(": undefined normal for hemisphere sampling\n", stderr);
402                  exit(1);
403          }
404 <        if (normalize(curparams.vup) == 0)
404 >        if (normalize(curparams.vup) == 0) {
405                  if (fabs(curparams.nrm[2]) < .7)
406                          curparams.vup[2] = 1;
407                  else
408                          curparams.vup[1] = 1;
409 +        }
410 +                                        /* determine sample type/bin */
411          if (tolower(curparams.hemis[0]) == 'u' | curparams.hemis[0] == '1') {
412 <                CHECKARGC(2);
413 <                rcarg[nrcargs++] = "-b";
406 <                rcarg[nrcargs++] = "0";
412 >                binv = "0";             /* uniform sampling -- one bin */
413 >                uniform = 1;
414          } else if (tolower(curparams.hemis[0]) == 's' &&
415                                  tolower(curparams.hemis[1]) == 'c') {
416 <                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);
416 >                                        /* assign parameters */
417                  if (curparams.hsiz <= 1) {
418                          fputs(progname, stderr);
419                          fputs(": missing size for Shirley-Chiu sampling!\n", stderr);
420                          exit(1);
421                  }
422 +                calfn = shirchiufn; shirchiufn = NULL;
423 +                sprintf(sbuf, "SCdim=%d,rNx=%g,rNy=%g,rNz=%g,Ux=%g,Uy=%g,Uz=%g",
424 +                                curparams.hsiz,
425 +                        curparams.nrm[0], curparams.nrm[1], curparams.nrm[2],
426 +                        curparams.vup[0], curparams.vup[1], curparams.vup[2]);
427 +                params = savqstr(sbuf);
428 +                binv = "scbin";
429 +                nbins = "SCdim*SCdim";
430          } else if ((tolower(curparams.hemis[0]) == 'r') |
431                          (tolower(curparams.hemis[0]) == 't')) {
432 <                if (reinhfn != NULL) {
433 <                        CHECKARGC(2);
434 <                        rcarg[nrcargs++] = "-f";
435 <                        rcarg[nrcargs++] = reinhfn;
436 <                        reinhfn = NULL;
437 <                }
438 < fputs("Reinhart/Tregenza unimplemented...\n",stderr); exit(1);
432 >                calfn = reinhfn; reinhfn = NULL;
433 >                sprintf(sbuf, "MF=%d,rNx=%g,rNy=%g,rNz=%g,Ux=%g,Uy=%g,Uz=%g",
434 >                                curparams.hsiz,
435 >                        curparams.nrm[0], curparams.nrm[1], curparams.nrm[2],
436 >                        curparams.vup[0], curparams.vup[1], curparams.vup[2]);
437 >                params = savqstr(sbuf);
438 >                binv = "rbin";
439 >                nbins = "Nrbins";
440          } else if (tolower(curparams.hemis[0]) == 'k' &&
441                          !curparams.hemis[1] |
442                          (tolower(curparams.hemis[1]) == 'f') |
443                          (curparams.hemis[1] == '1')) {
444 <                if (kfullfn != NULL) {
445 <                        CHECKARGC(2);
446 <                        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";
444 >                calfn = kfullfn; kfullfn = NULL;
445 >                binf = "kbin";
446 >                nbins = "Nkbins";
447          } else if (tolower(curparams.hemis[0]) == 'k' &&
448                          (tolower(curparams.hemis[1]) == 'h') |
449                          (curparams.hemis[1] == '2')) {
450 <                if (khalffn != NULL) {
451 <                        CHECKARGC(2);
452 <                        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";
450 >                calfn = khalffn; khalffn = NULL;
451 >                binf = "khbin";
452 >                nbins = "Nkhbins";
453          } else if (tolower(curparams.hemis[0]) == 'k' &&
454                          (tolower(curparams.hemis[1]) == 'q') |
455                          (curparams.hemis[1] == '4')) {
456 <                if (kquarterfn != NULL) {
457 <                        CHECKARGC(2);
458 <                        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";
456 >                calfn = kquarterfn; kquarterfn = NULL;
457 >                binf = "kqbin";
458 >                nbins = "Nkqbins";
459          } else {
460                  fprintf(stderr, "%s: unrecognized hemisphere sampling: h=%s\n",
461                                  progname, curparams.hemis);
462                  exit(1);
463          }
464 <        CHECKARGC(2);                   /* modifier argument goes last */
464 >        if (!uniform & (curparams.slist->styp == ST_SOURCE)) {
465 >                SURF    *sp;
466 >                for (sp = curparams.slist; sp != NULL; sp = sp->next)
467 >                        if (fabs(sp->area - PI) > 1e-3) {
468 >                                fprintf(stderr, "%s: source '%s' must be 180-degrees\n",
469 >                                                progname, sp->sname);
470 >                                exit(1);
471 >                        }
472 >        }
473 >        if (calfn != NULL) {            /* add cal file if needed */
474 >                CHECKARGC(2);
475 >                rcarg[nrcargs++] = "-f";
476 >                rcarg[nrcargs++] = calfn;
477 >        }
478 >        if (params != NULL) {           /* parameters _after_ cal file */
479 >                CHECKARGC(2);
480 >                rcarg[nrcargs++] = "-p";
481 >                rcarg[nrcargs++] = params;
482 >        }
483 >        if (nbins != NULL) {            /* add #bins if set */
484 >                CHECKARGC(2);
485 >                rcarg[nrcargs++] = "-bn";
486 >                rcarg[nrcargs++] = nbins;
487 >        }
488 >        if (binv != NULL) {
489 >                CHECKARGC(2);           /* assign bin variable */
490 >                rcarg[nrcargs++] = "-b";
491 >                rcarg[nrcargs++] = binv;
492 >        } else if (binf != NULL) {
493 >                CHECKARGC(2);           /* assign bin function */
494 >                rcarg[nrcargs++] = "-b";
495 >                sprintf(sbuf, "%s(%g,%g,%g,%g,%g,%g)", binf,
496 >                        curparams.nrm[0], curparams.nrm[1], curparams.nrm[2],
497 >                        curparams.vup[0], curparams.vup[1], curparams.vup[2]);
498 >                rcarg[nrcargs++] = savqstr(sbuf);
499 >        }
500 >        CHECKARGC(2);                           /* modifier argument goes last */
501          rcarg[nrcargs++] = "-m";
502          rcarg[nrcargs++] = savqstr(curmod);
503   }
# Line 541 | Line 554 | ssamp_ring(FVECT orig, SURF *sp, double x)
554                  sp->priv = (void *)uva;
555          }
556          SDmultiSamp(samp2, 2, x);
557 <        samp2[0] = sp->farg[6] + sqrt(samp2[0]*sp->area*(1./PI));
557 >        samp2[0] = sqrt(samp2[0]*sp->area*(1./PI) + sp->farg[6]*sp->farg[6]);
558          samp2[1] *= 2.*PI;
559          uv[0] = samp2[0]*tcos(samp2[1]);
560          uv[1] = samp2[0]*tsin(samp2[1]);
# Line 594 | Line 607 | ssamp_poly(FVECT orig, SURF *sp, double x)
607                          }
608                          ptp->ntris = 0;
609                          v2l->p = (void *)ptp;
610 <                        if (!polyTriangulate(v2l, add_triangle))
610 >                        if (!polyTriangulate(v2l, add_triangle)) {
611 >                                fprintf(stderr,
612 >                                        "%s: cannot triangulate polygon '%s'\n",
613 >                                                progname, sp->sname);
614                                  return(0);
615 +                        }
616                          for (i = ptp->ntris; i--; ) {
617                                  int     a = ptp->tri[i].vndx[0];
618                                  int     b = ptp->tri[i].vndx[1];
# Line 644 | Line 661 | sample_origin(PARAMS *p, FVECT orig, const FVECT rdir,
661                                          /* special case for lone surface */
662          if (p->nsurfs == 1) {
663                  sp = p->slist;
664 <                if (DOT(sp->snrm, rdir) >= -FTINY)
665 <                        return(0);      /* behind surface! */
664 >                if (DOT(sp->snrm, rdir) >= -FTINY) {
665 >                        fprintf(stderr,
666 >                                "%s: internal - sample behind sender '%s'\n",
667 >                                        progname, sp->sname);
668 >                        return(0);
669 >                }
670                  return((*orig_in_surf[sp->styp])(orig, sp, x));
671          }
672          if (p->nsurfs > nall) {         /* (re)allocate surface area cache */
# Line 659 | Line 680 | sample_origin(PARAMS *p, FVECT orig, const FVECT rdir,
680                  projsa[i] = -DOT(sp->snrm, rdir) * sp->area;
681                  tarea += projsa[i] *= (double)(projsa[i] > FTINY);
682          }
683 <        if (tarea <= FTINY)             /* wrong side of sender? */
683 >        if (tarea <= FTINY) {           /* wrong side of sender? */
684 >                fputs(progname, stderr);
685 >                fputs(": internal - sample behind all sender elements!\n",
686 >                                stderr);
687                  return(0);
688 +        }
689          tarea *= x;                     /* get surface from list */
690          for (i = 0, sp = p->slist; tarea > projsa[i]; sp = sp->next)
691                  tarea -= projsa[i++];
# Line 733 | Line 758 | sample_reinhart(PARAMS *p, int b, FILE *fp)
758   #define T_NALT  7
759          static const int        tnaz[T_NALT] = {30, 30, 24, 24, 18, 12, 6};
760          const int               RowMax = T_NALT*p->hsiz + 1;
761 <        const double            RAH = (.25*PI)/(RowMax-.5);
761 >        const double            RAH = (.5*PI)/(RowMax-.5);
762   #define rnaz(r)                 (r >= RowMax-1 ? 1 : p->hsiz*tnaz[r/p->hsiz])
763          int                     n = sampcnt;
764          int                     row, col;
# Line 758 | Line 783 | sample_reinhart(PARAMS *p, int b, FILE *fp)
783                  SDmultiSamp(samp3, 3, (n+frandom())/sampcnt);
784                  alt = (row+samp3[1])*RAH;
785                  azi = (2.*PI)*(col+samp3[2]-.5)/rnaz(row);
786 <                duvw[2] = tcos(alt);    /* measured from horizon */
786 >                duvw[2] = cos(alt);     /* measured from horizon */
787                  duvw[0] = tcos(azi)*duvw[2];
788                  duvw[1] = tsin(azi)*duvw[2];
789                  duvw[2] = sqrt(1. - duvw[2]*duvw[2]);
# Line 848 | Line 873 | prepare_sampler(void)
873                  fputs(": undefined normal for sender sampling\n", stderr);
874                  return(-1);
875          }
876 <        if (normalize(curparams.vup) == 0)
876 >        if (normalize(curparams.vup) == 0) {
877                  if (fabs(curparams.nrm[2]) < .7)
878                          curparams.vup[2] = 1;
879                  else
880                          curparams.vup[1] = 1;
881 +        }
882          VCROSS(curparams.udir, curparams.vup, curparams.nrm);
883          if (normalize(curparams.udir) == 0) {
884                  fputs(progname, stderr);
# Line 976 | Line 1002 | add_surface(int st, const char *oname, FILE *fp)
1002          case ST_SOURCE:
1003                  if (snew->nfargs != 4)
1004                          goto badcount;
1005 <                VCOPY(snew->snrm, snew->farg);
1005 >                for (n = 3; n--; )      /* need to reverse "normal" */
1006 >                        snew->snrm[n] = -snew->farg[n];
1007                  if (normalize(snew->snrm) == 0)
1008                          goto badnorm;
1009 <                snew->area = 2.*PI*(1. - cos((PI/180./2.)*snew->farg[3]));
1009 >                snew->area = sin((PI/180./2.)*snew->farg[3]);
1010 >                snew->area *= PI*snew->area;
1011                  break;
1012          }
1013          if (snew->area <= FTINY) {
# Line 994 | Line 1022 | add_surface(int st, const char *oname, FILE *fp)
1022          curparams.nsurfs++;
1023          return;
1024   badcount:
1025 <        fprintf(stderr, "%s: bad argument count for surface '%s'\n",
1025 >        fprintf(stderr, "%s: bad argument count for surface element '%s'\n",
1026                          progname, oname);
1027          exit(1);
1028   badnorm:
1029 <        fprintf(stderr, "%s: bad orientation for surface '%s'\n",
1029 >        fprintf(stderr, "%s: bad orientation for surface element '%s'\n",
1030                          progname, oname);
1031          exit(1);
1032   }
# Line 1030 | Line 1058 | add_recv_object(FILE *fp)
1058                                  finish_receiver();
1059                                  clear_params(&curparams, 1);
1060                          }
1061 +                        parse_params(&curparams, newparams);
1062 +                        newparams[0] = '\0';
1063                          strcpy(curmod, thismod);
1064                  }
1065                  add_surface(st, oname, fp);     /* read & store surface */
1066                  return(1);
1067          }
1068                                          /* else skip arguments */
1069 <        if (!fscanf(fp, "%d", &n)) return;
1069 >        if (!fscanf(fp, "%d", &n)) return(0);
1070          while (n-- > 0) fscanf(fp, "%*s");
1071 <        if (!fscanf(fp, "%d", &n)) return;
1071 >        if (!fscanf(fp, "%d", &n)) return(0);
1072          while (n-- > 0) fscanf(fp, "%*d");
1073 <        if (!fscanf(fp, "%d", &n)) return;
1073 >        if (!fscanf(fp, "%d", &n)) return(0);
1074          while (n-- > 0) fscanf(fp, "%*f");
1075          return(0);
1076   }
# Line 1066 | Line 1096 | add_send_object(FILE *fp)
1096                          fputs(": cannot use source as a sender!\n", stderr);
1097                          return(-1);
1098                  }
1099 +                parse_params(&curparams, newparams);
1100 +                newparams[0] = '\0';
1101                  add_surface(st, oname, fp);     /* read & store surface */
1102                  return(0);
1103          }
1104                                          /* else skip arguments */
1105 <        if (!fscanf(fp, "%d", &n)) return;
1105 >        if (!fscanf(fp, "%d", &n)) return(0);
1106          while (n-- > 0) fscanf(fp, "%*s");
1107 <        if (!fscanf(fp, "%d", &n)) return;
1107 >        if (!fscanf(fp, "%d", &n)) return(0);
1108          while (n-- > 0) fscanf(fp, "%*d");
1109 <        if (!fscanf(fp, "%d", &n)) return;
1109 >        if (!fscanf(fp, "%d", &n)) return(0);
1110          while (n-- > 0) fscanf(fp, "%*f");
1111          return(0);
1112   }
# Line 1109 | Line 1141 | load_scene(const char *inspec, int (*ocb)(FILE *))
1141                          continue;
1142                  }
1143                  if (c == '#') {         /* parameters/comment */
1144 <                        if (fscanf(fp, "%s", inpbuf) == 1 &&
1144 >                        if ((c = getc(fp)) == EOF || ungetc(c,fp) == EOF)
1145 >                                break;
1146 >                        if (!isspace(c) && fscanf(fp, "%s", inpbuf) == 1 &&
1147                                          !strcmp(inpbuf, PARAMSTART)) {
1148                                  if (fgets(inpbuf, sizeof(inpbuf), fp) != NULL)
1149 <                                        parse_params(inpbuf);
1149 >                                        strcat(newparams, inpbuf);
1150                                  continue;
1151                          }
1152 <                        while ((c = getc(fp)) != EOF && c != '\n');
1152 >                        while ((c = getc(fp)) != EOF && c != '\n')
1153                                  ;       /* else skipping comment */
1154                          continue;
1155                  }
# Line 1139 | Line 1173 | int
1173   main(int argc, char *argv[])
1174   {
1175          char    fmtopt[6] = "-faa";     /* default output is ASCII */
1176 +        char    *xrs=NULL, *yrs=NULL, *ldopt=NULL;
1177 +        int     wantIrradiance = 0;
1178          char    *sendfn;
1179          char    sampcntbuf[32], nsbinbuf[32];
1180          FILE    *rcfp;
# Line 1163 | Line 1199 | main(int argc, char *argv[])
1199                          case 'f':
1200                          case 'd':
1201                          case 'c':
1202 <                                if (!(fmtopt[4] = argv[a][3]))
1203 <                                        fmtopt[4] = argv[a][2];
1204 <                                fmtopt[3] = argv[a][2];
1202 >                                if (!(fmtopt[3] = argv[a][3]))
1203 >                                        fmtopt[3] = argv[a][2];
1204 >                                fmtopt[2] = argv[a][2];
1205                                  na = 0;
1206                                  continue;       /* will pass later */
1207                          default:
1208                                  goto userr;
1209                          }
1210                          break;
1211 +                case 'x':               /* x-resolution */
1212 +                        xrs = argv[++a];
1213 +                        na = 0;
1214 +                        continue;
1215 +                case 'y':               /* y-resolution */
1216 +                        yrs = argv[++a];
1217 +                        na = 0;
1218 +                        continue;
1219                  case 'c':               /* number of samples */
1220 <                        sampcnt = atoi(argv[a+1]);
1220 >                        sampcnt = atoi(argv[++a]);
1221                          if (sampcnt <= 0)
1222                                  goto userr;
1223                          na = 0;         /* we re-add this later */
1224                          continue;
1225 +                case 'I':               /* only for pass-through mode */
1226 +                        wantIrradiance = 1;
1227 +                        na = 0;
1228 +                        continue;
1229                  case 'V':               /* options without arguments */
1230                  case 'w':
1231                  case 'u':
1232                  case 'i':
1233                  case 'h':
1234 +                case 'r':
1235                          break;
1236                  case 'n':               /* options with 1 argument */
1237                  case 's':
# Line 1193 | Line 1242 | main(int argc, char *argv[])
1242                          if (argv[a][2] != 'v') goto userr;
1243                          break;
1244                  case 'l':               /* special case */
1245 <                        if (argv[a][2] == 'd') goto userr;
1245 >                        if (argv[a][2] == 'd') {
1246 >                                ldopt = argv[a];
1247 >                                na = 0;
1248 >                                continue;
1249 >                        }
1250                          na = 2;
1251                          break;
1252                  case 'd':               /* special case */
# Line 1224 | Line 1277 | done_opts:
1277          if (sendfn[0] == '-') {         /* user wants pass-through mode? */
1278                  if (sendfn[1]) goto userr;
1279                  sendfn = NULL;
1280 +                if (wantIrradiance) {
1281 +                        CHECKARGC(1);
1282 +                        rcarg[nrcargs++] = "-I";
1283 +                }
1284 +                if (xrs) {
1285 +                        CHECKARGC(2);
1286 +                        rcarg[nrcargs++] = "-x";
1287 +                        rcarg[nrcargs++] = xrs;
1288 +                }
1289 +                if (yrs) {
1290 +                        CHECKARGC(2);
1291 +                        rcarg[nrcargs++] = "-y";
1292 +                        rcarg[nrcargs++] = yrs;
1293 +                }
1294 +                if (ldopt) {
1295 +                        CHECKARGC(1);
1296 +                        rcarg[nrcargs++] = ldopt;
1297 +                }
1298                  if (sampcnt <= 0) sampcnt = 1;
1299 <        } else {                        /* else FVECT determines input format */
1300 <                fmtopt[3] = (sizeof(RREAL)==sizeof(double)) ? 'd' : 'f';
1299 >        } else {                        /* else in sampling mode */
1300 >                if (wantIrradiance) {
1301 >                        fputs(progname, stderr);
1302 >                        fputs(": -I supported for pass-through only\n", stderr);
1303 >                        return(1);
1304 >                }
1305 >                fmtopt[2] = (sizeof(RREAL)==sizeof(double)) ? 'd' : 'f';
1306                  if (sampcnt <= 0) sampcnt = 10000;
1307          }
1308          sprintf(sampcntbuf, "%d", sampcnt);
# Line 1265 | Line 1341 | done_opts:
1341          if (verbose) {
1342                  fprintf(stderr, "%s: sampling %d directions", progname, nsbins);
1343                  if (curparams.nsurfs > 1)
1344 <                        fprintf(stderr, " (%d surfaces)\n", curparams.nsurfs);
1344 >                        fprintf(stderr, " (%d elements)\n", curparams.nsurfs);
1345                  else
1346                          fputc('\n', stderr);
1347          }
# Line 1276 | Line 1352 | done_opts:
1352   userr:
1353          if (a < argc-2)
1354                  fprintf(stderr, "%s: unsupported option '%s'", progname, argv[a]);
1355 <        fprintf(stderr, "Usage: %s [rcontrib options] sender.rad receiver.rad [system.rad ..]\n",
1355 >        fprintf(stderr, "Usage: %s [-v][rcontrib options] sender.rad receiver.rad [system.rad ..]\n",
1356                                  progname);
1357          return(1);
1358   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines