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.27 by greg, Tue Jun 25 00:09:45 2019 UTC vs.
Revision 2.28 by greg, Tue Jun 25 17:06:36 2019 UTC

# Line 321 | Line 321 | main(int argc, char *argv[])
321          double  elevation;              /* site elevation (meters) */
322          int     dir_is_horiz;           /* direct is meas. on horizontal? */
323          float   *mtx_data = NULL;       /* our matrix data */
324        int     ntsteps = 0;            /* number of time steps */
324          int     avgSky = 0;             /* compute average sky r.t. matrix? */
325 <        int     nrows = 0;              /* number of rows in matrix */
326 <        int     rows_alloc = 0;         /* number of allocated rows */
325 >        int     ntsteps = 0;            /* number of time steps */
326 >        int     tstorage = 0;           /* number of allocated time steps */
327 >        int     nstored = 0;            /* number of time steps in matrix */
328          int     last_monthly = 0;       /* month of last report */
329          int     inconsistent = 0;       /* inconsistent options set? */
330          int     mo, da;                 /* month (1-12) and day (1-31) */
# Line 480 | Line 480 | main(int argc, char *argv[])
480          s_longitude = DegToRad(s_longitude);
481          s_meridian = DegToRad(s_meridian);
482                                          /* initial allocation */
483 <        mtx_data = resize_dmatrix(mtx_data, rows_alloc=2, nskypatch);
483 >        mtx_data = resize_dmatrix(mtx_data, tstorage=2, nskypatch);
484                                          /* process each time step in tape */
485          while (scanf("%d %d %lf %lf %lf\n", &mo, &da, &hr, &dir, &dif) == 5) {
486                  double          sda, sta;
487  
488 <                mtx_offset = 3*nskypatch*nrows;
489 <                nrows += !avgSky | !nrows;
488 >                mtx_offset = 3*nskypatch*nstored;
489 >                nstored += !avgSky | !nstored;
490                                          /* make space for next row */
491 <                if (nrows > rows_alloc) {
492 <                        rows_alloc += (rows_alloc>>1) + nrows + 7;
493 <                        mtx_data = resize_dmatrix(mtx_data, rows_alloc, nskypatch);
491 >                if (nstored > tstorage) {
492 >                        tstorage += (tstorage>>1) + nstored + 7;
493 >                        mtx_data = resize_dmatrix(mtx_data, tstorage, nskypatch);
494                  }
495                  ntsteps++;              /* keep count of time steps */
496                  if (dif <= 1e-4) {
497 <                        if (!avgSky | !nrows)
497 >                        if (!avgSky | !mtx_offset)
498                                  memset(mtx_data+mtx_offset, 0, sizeof(float)*3*nskypatch);
499                          continue;
500                  }
# Line 549 | Line 549 | main(int argc, char *argv[])
549   #endif
550          if (verbose)
551                  fprintf(stderr, "%s: writing %smatrix with %d time steps...\n",
552 <                                progname, outfmt=='a' ? "" : "binary ", nrows);
552 >                                progname, outfmt=='a' ? "" : "binary ", nstored);
553          if (doheader) {
554                  newheader("RADIANCE", stdout);
555                  printargs(argc, argv, stdout);
556                  printf("LATLONG= %.8f %.8f\n", RadToDeg(s_latitude),
557                                          -RadToDeg(s_longitude));
558                  printf("NROWS=%d\n", nskypatch);
559 <                printf("NCOLS=%d\n", nrows);
559 >                printf("NCOLS=%d\n", nstored);
560                  printf("NCOMP=3\n");
561                  fputformat((char *)getfmtname(outfmt), stdout);
562                  putchar('\n');
# Line 566 | Line 566 | main(int argc, char *argv[])
566                  mtx_offset = 3*i;
567                  switch (outfmt) {
568                  case 'a':
569 <                        for (j = 0; j < nrows; j++) {
569 >                        for (j = 0; j < nstored; j++) {
570                                  printf("%.3g %.3g %.3g\n", mtx_data[mtx_offset],
571                                                  mtx_data[mtx_offset+1],
572                                                  mtx_data[mtx_offset+2]);
573                                  mtx_offset += 3*nskypatch;
574                          }
575 <                        if (nrows > 1)
575 >                        if (nstored > 1)
576                                  fputc('\n', stdout);
577                          break;
578                  case 'f':
579 <                        for (j = 0; j < nrows; j++) {
579 >                        for (j = 0; j < nstored; j++) {
580                                  putbinary(mtx_data+mtx_offset, sizeof(float), 3,
581                                                  stdout);
582                                  mtx_offset += 3*nskypatch;
583                          }
584                          break;
585                  case 'd':
586 <                        for (j = 0; j < nrows; j++) {
586 >                        for (j = 0; j < nstored; j++) {
587                                  double  ment[3];
588                                  ment[0] = mtx_data[mtx_offset];
589                                  ment[1] = mtx_data[mtx_offset+1];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines