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.12 by greg, Thu Jun 6 20:21:10 2013 UTC vs.
Revision 2.20 by greg, Sat Aug 1 23:27:04 2015 UTC

# Line 86 | Line 86 | static const char RCSid[] = "$Id$";
86   #include <string.h>
87   #include <ctype.h>
88   #include "rtmath.h"
89 + #include "resolu.h"
90 + #include "platform.h"
91   #include "color.h"
92 + #include "resolu.h"
93  
94   char *progname;                                                         /* Program name */
95   char errmsg[128];                                                       /* Error message buffer */
# Line 292 | Line 295 | extern int     rh_init(void);
295   extern float *  resize_dmatrix(float *mtx_data, int nsteps, int npatch);
296   extern void     AddDirect(float *parr);
297  
298 +
299 + static const char *
300 + getfmtname(int fmt)
301 + {
302 +        switch (fmt) {
303 +        case 'a':
304 +                return("ascii");
305 +        case 'f':
306 +                return("float");
307 +        case 'd':
308 +                return("double");
309 +        }
310 +        return("unknown");
311 + }
312 +
313 +
314   int
315   main(int argc, char *argv[])
316   {
317          char    buf[256];
318 +        int     doheader = 1;           /* output header? */
319          double  rotation = 0;           /* site rotation (degrees) */
320          double  elevation;              /* site elevation (meters) */
321          int     dir_is_horiz;           /* direct is meas. on horizontal? */
322          float   *mtx_data = NULL;       /* our matrix data */
323          int     ntsteps = 0;            /* number of rows in matrix */
324 +        int     step_alloc = 0;
325          int     last_monthly = 0;       /* month of last report */
326          int     mo, da;                 /* month (1-12) and day (1-31) */
327          double  hr;                     /* hour (local standard time) */
# Line 320 | Line 341 | main(int argc, char *argv[])
341                  case 'v':                       /* verbose progress reports */
342                          verbose++;
343                          break;
344 +                case 'h':                       /* turn off header */
345 +                        doheader = 0;
346 +                        break;
347                  case 'o':                       /* output format */
348                          switch (argv[i][2]) {
349                          case 'f':
# Line 370 | Line 394 | main(int argc, char *argv[])
394                          break;
395                  case '5':                       /* 5-phase calculation */
396                          nsuns = 1;
397 <                        fixed_sun_sa = 6.797e-05;
397 >                        fixed_sun_sa = PI/360.*atof(argv[++i]);
398 >                        fixed_sun_sa *= fixed_sun_sa*PI;
399                          break;
400                  default:
401                          goto userr;
# Line 439 | Line 464 | main(int argc, char *argv[])
464                  double          sda, sta;
465                                          /* make space for next time step */
466                  mtx_offset = 3*nskypatch*ntsteps++;
467 <                mtx_data = resize_dmatrix(mtx_data, ntsteps, nskypatch);
467 >                if (ntsteps > step_alloc) {
468 >                        step_alloc += (step_alloc>>1) + ntsteps + 7;
469 >                        mtx_data = resize_dmatrix(mtx_data, step_alloc, nskypatch);
470 >                }
471                  if (dif <= 1e-4) {
472                          memset(mtx_data+mtx_offset, 0, sizeof(float)*3*nskypatch);
473                          continue;
# Line 478 | Line 506 | main(int argc, char *argv[])
506                          break;
507                  }
508                                          /* write out matrix */
509 +        if (outfmt != 'a')
510 +                SET_FILE_BINARY(stdout);
511   #ifdef getc_unlocked
512          flockfile(stdout);
513   #endif
514          if (verbose)
515                  fprintf(stderr, "%s: writing %smatrix with %d time steps...\n",
516                                  progname, outfmt=='a' ? "" : "binary ", ntsteps);
517 +        if (doheader) {
518 +                newheader("RADIANCE", stdout);
519 +                printargs(argc, argv, stdout);
520 +                printf("LATLONG= %.8f %.8f\n", RadToDeg(s_latitude),
521 +                                        -RadToDeg(s_longitude));
522 +                printf("NROWS=%d\n", nskypatch);
523 +                printf("NCOLS=%d\n", ntsteps);
524 +                printf("NCOMP=3\n");
525 +                fputformat((char *)getfmtname(outfmt), stdout);
526 +                putchar('\n');
527 +        }
528                                          /* patches are rows (outer sort) */
529          for (i = 0; i < nskypatch; i++) {
530                  mtx_offset = 3*i;
# Line 525 | Line 566 | main(int argc, char *argv[])
566                  fprintf(stderr, "%s: done.\n", progname);
567          exit(0);
568   userr:
569 <        fprintf(stderr, "Usage: %s [-v][-d|-s][-r deg][-m N][-g r g b][-c r g b][-o{f|d}][-O{0|1}] [tape.wea]\n",
569 >        fprintf(stderr, "Usage: %s [-v][-h][-d|-s][-r deg][-m N][-g r g b][-c r g b][-o{f|d}][-O{0|1}] [tape.wea]\n",
570                          progname);
571          exit(1);
572   fmterr:
# Line 622 | Line 663 | ComputeSky(float *parr)
663          /* Calculate relative horizontal illuminance */
664          norm_diff_illum = CalcRelHorzIllum(parr);
665  
666 +        /* Check for zero sky -- make uniform in that case */
667 +        if (norm_diff_illum <= FTINY) {
668 +                for (i = 1; i < nskypatch; i++)
669 +                        setcolor(parr+3*i, 1., 1., 1.);
670 +                norm_diff_illum = PI;
671 +        }
672          /* Normalization coefficient */
673          norm_diff_illum = diff_illum / norm_diff_illum;
674  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines