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.6 by greg, Wed Jul 23 00:40:17 2014 UTC vs.
Revision 2.9 by greg, Fri Jul 25 16:58:20 2014 UTC

# Line 419 | Line 419 | finish_receiver(void)
419                          exit(1);
420                  }
421                  calfn = shirchiufn; shirchiufn = NULL;
422 <                sprintf(sbuf, "SCdim=%d,Nx=%g,Ny=%g,Nz=%g,Ux=%g,Uy=%g,Uz=%g",
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]);
# Line 429 | Line 429 | finish_receiver(void)
429          } else if ((tolower(curparams.hemis[0]) == 'r') |
430                          (tolower(curparams.hemis[0]) == 't')) {
431                  calfn = reinhfn; reinhfn = NULL;
432 <                sprintf(sbuf, "MF=%d,Nx=%g,Ny=%g,Nz=%g,Ux=%g,Uy=%g,Uz=%g",
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]);
# Line 606 | 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 656 | 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 671 | 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 745 | 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 770 | 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 988 | 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 = sin((PI/180./2.)*snew->farg[3]);
# Line 1007 | 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 1051 | Line 1064 | add_recv_object(FILE *fp)
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 1087 | Line 1100 | add_send_object(FILE *fp)
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 1159 | Line 1172 | 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 1206 | Line 1220 | main(int argc, char *argv[])
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':
# Line 1257 | 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";
# Line 1272 | Line 1294 | done_opts:
1294                          rcarg[nrcargs++] = ldopt;
1295                  }
1296                  if (sampcnt <= 0) sampcnt = 1;
1297 <        } else {                        /* else FVECT determines input format */
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          }
# Line 1312 | 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          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines