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.30 by greg, Thu Nov 7 23:15:07 2019 UTC

# Line 85 | Line 85 | static const char RCSid[] = "$Id$";
85   #include <stdlib.h>
86   #include <string.h>
87   #include <ctype.h>
88 + #include "platform.h"
89   #include "rtmath.h"
90   #include "rtio.h"
90 #include "resolu.h"
91 #include "platform.h"
91   #include "color.h"
92 < #include "resolu.h"
92 > #include "sun.h"
93  
94   char *progname;                                                         /* Program name */
95   char errmsg[128];                                                       /* Error message buffer */
# Line 255 | Line 254 | static const ModelCoeff DirectLumEff[8] =
254   #define NSUNPATCH       4               /* max. # patches to spread sun into */
255   #endif
256  
258 extern int jdate(int month, int day);
259 extern double stadj(int  jd);
260 extern double sdec(int  jd);
261 extern double salt(double sd, double st);
262 extern double sazi(double sd, double st);
263                                        /* sun calculation constants */
264 extern double  s_latitude;
265 extern double  s_longitude;
266 extern double  s_meridian;
267
257   int             nsuns = NSUNPATCH;      /* number of sun patches to use */
258   double          fixed_sun_sa = -1;      /* fixed solid angle per sun? */
259  
# Line 321 | Line 310 | main(int argc, char *argv[])
310          double  elevation;              /* site elevation (meters) */
311          int     dir_is_horiz;           /* direct is meas. on horizontal? */
312          float   *mtx_data = NULL;       /* our matrix data */
324        int     ntsteps = 0;            /* number of time steps */
313          int     avgSky = 0;             /* compute average sky r.t. matrix? */
314 <        int     nrows = 0;              /* number of rows in matrix */
315 <        int     rows_alloc = 0;         /* number of allocated rows */
314 >        int     ntsteps = 0;            /* number of time steps */
315 >        int     tstorage = 0;           /* number of allocated time steps */
316 >        int     nstored = 0;            /* number of time steps in matrix */
317          int     last_monthly = 0;       /* month of last report */
318          int     inconsistent = 0;       /* inconsistent options set? */
319          int     mo, da;                 /* month (1-12) and day (1-31) */
# Line 480 | Line 469 | main(int argc, char *argv[])
469          s_longitude = DegToRad(s_longitude);
470          s_meridian = DegToRad(s_meridian);
471                                          /* initial allocation */
472 <        mtx_data = resize_dmatrix(mtx_data, rows_alloc=2, nskypatch);
472 >        mtx_data = resize_dmatrix(mtx_data, tstorage=2, nskypatch);
473                                          /* process each time step in tape */
474          while (scanf("%d %d %lf %lf %lf\n", &mo, &da, &hr, &dir, &dif) == 5) {
475                  double          sda, sta;
476  
477 <                mtx_offset = 3*nskypatch*nrows;
478 <                nrows += !avgSky | !nrows;
477 >                mtx_offset = 3*nskypatch*nstored;
478 >                nstored += !avgSky | !nstored;
479                                          /* make space for next row */
480 <                if (nrows > rows_alloc) {
481 <                        rows_alloc += (rows_alloc>>1) + nrows + 7;
482 <                        mtx_data = resize_dmatrix(mtx_data, rows_alloc, nskypatch);
480 >                if (nstored > tstorage) {
481 >                        tstorage += (tstorage>>1) + nstored + 7;
482 >                        mtx_data = resize_dmatrix(mtx_data, tstorage, nskypatch);
483                  }
484                  ntsteps++;              /* keep count of time steps */
485                  if (dif <= 1e-4) {
486 <                        if (!avgSky | !nrows)
486 >                        if (!avgSky | !mtx_offset)
487                                  memset(mtx_data+mtx_offset, 0, sizeof(float)*3*nskypatch);
488                          continue;
489                  }
# Line 549 | Line 538 | main(int argc, char *argv[])
538   #endif
539          if (verbose)
540                  fprintf(stderr, "%s: writing %smatrix with %d time steps...\n",
541 <                                progname, outfmt=='a' ? "" : "binary ", nrows);
541 >                                progname, outfmt=='a' ? "" : "binary ", nstored);
542          if (doheader) {
543                  newheader("RADIANCE", stdout);
544                  printargs(argc, argv, stdout);
545                  printf("LATLONG= %.8f %.8f\n", RadToDeg(s_latitude),
546                                          -RadToDeg(s_longitude));
547                  printf("NROWS=%d\n", nskypatch);
548 <                printf("NCOLS=%d\n", nrows);
548 >                printf("NCOLS=%d\n", nstored);
549                  printf("NCOMP=3\n");
550 +                if ((outfmt == 'f') | (outfmt == 'd'))
551 +                        fputendian(stdout);
552                  fputformat((char *)getfmtname(outfmt), stdout);
553                  putchar('\n');
554          }
# Line 566 | Line 557 | main(int argc, char *argv[])
557                  mtx_offset = 3*i;
558                  switch (outfmt) {
559                  case 'a':
560 <                        for (j = 0; j < nrows; j++) {
560 >                        for (j = 0; j < nstored; j++) {
561                                  printf("%.3g %.3g %.3g\n", mtx_data[mtx_offset],
562                                                  mtx_data[mtx_offset+1],
563                                                  mtx_data[mtx_offset+2]);
564                                  mtx_offset += 3*nskypatch;
565                          }
566 <                        if (nrows > 1)
566 >                        if (nstored > 1)
567                                  fputc('\n', stdout);
568                          break;
569                  case 'f':
570 <                        for (j = 0; j < nrows; j++) {
570 >                        for (j = 0; j < nstored; j++) {
571                                  putbinary(mtx_data+mtx_offset, sizeof(float), 3,
572                                                  stdout);
573                                  mtx_offset += 3*nskypatch;
574                          }
575                          break;
576                  case 'd':
577 <                        for (j = 0; j < nrows; j++) {
577 >                        for (j = 0; j < nstored; j++) {
578                                  double  ment[3];
579                                  ment[0] = mtx_data[mtx_offset];
580                                  ment[1] = mtx_data[mtx_offset+1];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines