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

Comparing ray/src/gen/gendaymtx.c (file contents):
Revision 2.33 by greg, Mon Jan 6 21:22:46 2020 UTC vs.
Revision 2.34 by greg, Tue Jan 7 01:42:30 2020 UTC

# Line 307 | Line 307 | main(int argc, char *argv[])
307          double  rotation = 0;           /* site rotation (degrees) */
308          double  elevation;              /* site elevation (meters) */
309          int     dir_is_horiz;           /* direct is meas. on horizontal? */
310 +        FILE    *sunsfp = NULL;         /* output file for individual suns */
311          float   *mtx_data = NULL;       /* our matrix data */
312          int     avgSky = 0;             /* compute average sky r.t. matrix? */
313          int     ntsteps = 0;            /* number of time steps */
# Line 367 | Line 368 | main(int argc, char *argv[])
368                          skycolor[1] = atof(argv[++i]);
369                          skycolor[2] = atof(argv[++i]);
370                          break;
371 +                case 'n':                       /* no matrix output */
372 +                        avgSky = -1;
373 +                        rhsubdiv = 1;
374 +                        /* fall through */
375                  case 'd':                       /* solar (direct) only */
376                          skycolor[0] = skycolor[1] = skycolor[2] = 0;
377                          grefl[0] = grefl[1] = grefl[2] = 0;
378                          break;
379 +                case 'D':                       /* output suns to file */
380 +                        sunsfp = fopen(argv[++i], "w");
381 +                        if (!sunsfp) {
382 +                                fprintf(stderr, "%s: cannot open '%s' for output\n",
383 +                                                argv[0], argv[i]);
384 +                                exit(1);
385 +                        }
386 +                        fixed_sun_sa = PI/360.*0.533;
387 +                        fixed_sun_sa *= PI*fixed_sun_sa;
388 +                        break;
389                  case 's':                       /* sky only (no direct) */
390                          suncolor[0] = suncolor[1] = suncolor[2] = 0;
391                          break;
# Line 473 | Line 488 | main(int argc, char *argv[])
488                                  memset(mtx_data+mtx_offset, 0, sizeof(float)*3*nskypatch);
489                          continue;
490                  }
476                if (verbose && mo != last_monthly)
477                        fprintf(stderr, "%s: stepping through month %d...\n",
478                                                progname, last_monthly=mo);
491                                          /* compute solar position */
492                  julian_date = jdate(mo, da);
493                  sda = sdec(julian_date);
# Line 494 | Line 506 | main(int argc, char *argv[])
506                  }
507                                          /* compute sky patch values */
508                  ComputeSky(mtx_data+mtx_offset);
509 +                                        /* output sun if indicated */
510 +                if (sunsfp && (altitude > 0) & (dir_illum > 1e-4)) {
511 +                        double  srad = dir_illum/(WHTEFFICACY * fixed_sun_sa);
512 +                        FVECT   sv;
513 +                        vector(sv, altitude, azimuth);
514 +                        fprintf(sunsfp, "\nvoid light solar%d\n0\n0\n", ntsteps);
515 +                        fprintf(sunsfp, "3 %.3e %.3e %.3e\n", srad*suncolor[0],
516 +                                        srad*suncolor[1], srad*suncolor[2]);
517 +                        fprintf(sunsfp, "\nsolar%d source sun%d\n0\n0\n", ntsteps, ntsteps);
518 +                        fprintf(sunsfp, "4 %.6f %.6f %.6f 0.533\n", sv[0], sv[1], sv[2]);
519 +                }
520 +                if (avgSky < 0)         /* no matrix? */
521 +                        continue;
522 +
523                  AddDirect(mtx_data+mtx_offset);
524                                          /* update cumulative sky? */
525                  for (i = 3*nskypatch*(avgSky&(ntsteps>1)); i--; )
526                          mtx_data[i] += mtx_data[mtx_offset+i];
527 +                                        /* monthly reporting */
528 +                if (verbose && mo != last_monthly)
529 +                        fprintf(stderr, "%s: stepping through month %d...\n",
530 +                                                progname, last_monthly=mo);
531          }
532 +        if (!ntsteps) {
533 +                fprintf(stderr, "%s: no valid time steps on input\n", progname);
534 +                exit(1);
535 +        }
536                                          /* check for junk at end */
537          while ((i = fgetc(stdin)) != EOF)
538                  if (!isspace(i)) {
# Line 509 | Line 543 | main(int argc, char *argv[])
543                          fputs(buf, stderr); fputc('\n', stderr);
544                          break;
545                  }
546 <        if (!ntsteps) {
547 <                fprintf(stderr, "%s: no valid time steps on input\n", progname);
548 <                exit(1);
549 <        }
546 >
547 >        if (avgSky < 0)                 /* no matrix output? */
548 >                goto alldone;
549 >
550          dif = 1./(double)ntsteps;       /* average sky? */
551          for (i = 3*nskypatch*(avgSky&(ntsteps>1)); i--; )
552                  mtx_data[i] *= dif;
# Line 573 | Line 607 | main(int argc, char *argv[])
607                  if (ferror(stdout))
608                          goto writerr;
609          }
610 <        if (fflush(stdout) == EOF)
610 > alldone:
611 >        if (fflush(NULL) == EOF)
612                  goto writerr;
613          if (verbose)
614                  fprintf(stderr, "%s: done.\n", progname);
615          exit(0);
616   userr:
617 <        fprintf(stderr, "Usage: %s [-v][-h][-A][-d|-s][-r deg][-m N][-g r g b][-c r g b][-o{f|d}][-O{0|1}] [tape.wea]\n",
617 >        fprintf(stderr, "Usage: %s [-v][-h][-A][-d|-s|-n][-D file][-r deg][-m N][-g r g b][-c r g b][-o{f|d}][-O{0|1}] [tape.wea]\n",
618                          progname);
619          exit(1);
620   fmterr:
621 <        fprintf(stderr, "%s: input weather tape format error\n", progname);
621 >        fprintf(stderr, "%s: weather tape format error in header\n", progname);
622          exit(1);
623   writerr:
624          fprintf(stderr, "%s: write error on output\n", progname);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines