--- ray/src/util/wrapBSDF.c 2016/02/03 00:22:55 2.19 +++ ray/src/util/wrapBSDF.c 2016/10/14 00:54:22 2.21 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: wrapBSDF.c,v 2.19 2016/02/03 00:22:55 greg Exp $"; +static const char RCSid[] = "$Id: wrapBSDF.c,v 2.21 2016/10/14 00:54:22 greg Exp $"; #endif /* * Wrap BSDF data in valid WINDOW XML file @@ -7,6 +7,7 @@ static const char RCSid[] = "$Id: wrapBSDF.c,v 2.19 20 * G. Ward February 2015 */ +#include "platform.h" #include #include "rtio.h" #include "paths.h" @@ -165,7 +166,8 @@ input2str(const char *inpspec) fprintf(stderr, "%s: cannot open\n", inpspec); return ""; } -#ifndef _WIN32 /* XXX somehow broken on Windows */ +#if !defined(_WIN32) && !defined(_WIN64) + /* XXX somehow broken on Windows */ len = lseek(fd, 0L, SEEK_END); if (len > 0) { lseek(fd, 0L, SEEK_SET); @@ -393,9 +395,7 @@ determine_angle_basis(const char *fn, ezxml_t wtl) static int filter_klems_matrix(FILE *fp) { -#define MAX_COLUMNS 145 const char *bn = klems_basis_name[angle_basis]; - float col_corr[MAX_COLUMNS]; int i, j, n = nabases; /* get angle basis */ while (n-- > 0) @@ -403,15 +403,9 @@ filter_klems_matrix(FILE *fp) break; if (n < 0) return 0; - if (abase_list[n].nangles > MAX_COLUMNS) { - fputs("Internal error - too many Klems columns!\n", stderr); - return 0; - } - /* get correction factors */ - for (j = abase_list[n].nangles; j--; ) - col_corr[j] = 1.f / io_getohm(j, &abase_list[n]); /* read/correct/write matrix */ for (i = 0; i < abase_list[n].nangles; i++) { + const double corr = 1./io_getohm(i, &abase_list[n]); for (j = 0; j < abase_list[n].nangles; j++) { double d; if (fscanf(fp, "%lf", &d) != 1) @@ -420,7 +414,7 @@ filter_klems_matrix(FILE *fp) fputs("Negative BSDF data!\n", stderr); return 0; } - printf(" %.3e", d*col_corr[j]*(d > 0)); + printf(" %.3e", d*corr*(d > 0)); } fputc('\n', stdout); } @@ -430,7 +424,6 @@ filter_klems_matrix(FILE *fp) return 0; } return 1; /* all is good */ -#undef MAX_COLUMNS } /* Write out BSDF data block with surrounding tags */