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.17 by greg, Sun Oct 26 17:35:53 2014 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines