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

Comparing ray/src/util/wrapBSDF.c (file contents):
Revision 2.19 by greg, Wed Feb 3 00:22:55 2016 UTC vs.
Revision 2.23 by greg, Wed Apr 3 23:50:25 2019 UTC

# Line 7 | Line 7 | static const char RCSid[] = "$Id$";
7   *      G. Ward         February 2015
8   */
9  
10 + #include "platform.h"
11   #include <ctype.h>
12   #include "rtio.h"
13   #include "paths.h"
# Line 51 | Line 52 | struct s_fieldID {
52   } XMLfieldID[] = {
53          {"m", 0, 1, "Manufacturer"},
54          {"n", 0, 1, "Name"},
55 +        {"d", 0, 0, "DeviceType"},
56          {"c", 0, 0, "ThermalConductivity"},
57          {"ef", 0, 0, "EmissivityFront"},
58          {"eb", 0, 0, "EmissivityBack"},
# Line 62 | Line 64 | struct s_fieldID {
64          {"\0", 0, 0, NULL}      /* terminator */
65   };
66                                          /* field assignments */
67 < #define MAXASSIGN       12
67 > #define MAXASSIGN       16
68   const char      *field_assignment[MAXASSIGN];
69   int             nfield_assign = 0;
70   #define FASEP   ';'
# Line 120 | Line 122 | static char    basis_definition[][256] = {
122          "\t</DataDefinition>\n",
123   };
124  
125 + /* Check that the last-added data file is unique */
126 + static int
127 + check_new_data_file()
128 + {
129 +        int     i = ndataf;
130 +
131 +        while (i-- > 0)
132 +                if ((data_file[i].spectrum == data_file[ndataf].spectrum) &
133 +                                (data_file[i].type == data_file[ndataf].type)) {
134 +                        fprintf(stderr,
135 +                                "%s: warning - ignoring duplicate component\n",
136 +                                        data_file[ndataf].fname);
137 +                        return 0;
138 +                }
139 +        return 1;
140 + }
141 +
142   /* Copy data from file descriptor to stdout and close */
143   static int
144   copy_and_close(int fd)
# Line 165 | Line 184 | input2str(const char *inpspec)
184                          fprintf(stderr, "%s: cannot open\n", inpspec);
185                          return "";
186                  }
187 < #ifndef _WIN32                          /* XXX somehow broken on Windows */
187 > #if !defined(_WIN32) && !defined(_WIN64)
188 >                                /* XXX somehow broken on Windows */
189                  len = lseek(fd, 0L, SEEK_END);
190                  if (len > 0) {
191                          lseek(fd, 0L, SEEK_SET);
# Line 393 | Line 413 | determine_angle_basis(const char *fn, ezxml_t wtl)
413   static int
414   filter_klems_matrix(FILE *fp)
415   {
396 #define MAX_COLUMNS     145
416          const char      *bn = klems_basis_name[angle_basis];
398        float           col_corr[MAX_COLUMNS];
417          int             i, j, n = nabases;
418                                          /* get angle basis */
419          while (n-- > 0)
# Line 403 | Line 421 | filter_klems_matrix(FILE *fp)
421                          break;
422          if (n < 0)
423                  return 0;
406        if (abase_list[n].nangles > MAX_COLUMNS) {
407                fputs("Internal error - too many Klems columns!\n", stderr);
408                return 0;
409        }
410                                        /* get correction factors */
411        for (j = abase_list[n].nangles; j--; )
412                col_corr[j] = 1.f / io_getohm(j, &abase_list[n]);
424                                          /* read/correct/write matrix */
425          for (i = 0; i < abase_list[n].nangles; i++) {
426 +            const double        corr = 1./io_getohm(i, &abase_list[n]);
427              for (j = 0; j < abase_list[n].nangles; j++) {
428                  double  d;
429                  if (fscanf(fp, "%lf", &d) != 1)
# Line 420 | Line 432 | filter_klems_matrix(FILE *fp)
432                          fputs("Negative BSDF data!\n", stderr);
433                          return 0;
434                  }
435 <                printf(" %.3e", d*col_corr[j]*(d > 0));
435 >                printf(" %.3e", d*corr*(d > 0));
436              }
437              fputc('\n', stdout);
438          }
# Line 430 | Line 442 | filter_klems_matrix(FILE *fp)
442                          return 0;
443                  }
444          return 1;                       /* all is good */
433 #undef MAX_COLUMNS
445   }
446  
447   /* Write out BSDF data block with surrounding tags */
# Line 841 | Line 852 | main(int argc, char *argv[])
852                          }
853                          data_file[ndataf].fname = argv[i];
854                          data_file[ndataf].spectrum = cur_spectrum;
855 <                        ndataf++;
855 >                        ndataf += check_new_data_file();
856                          continue;
857                  case 'r':               /* reflection */
858                          if (i >= argc-1)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines