--- ray/src/gen/gendaymtx.c 2015/09/02 22:52:04 2.21 +++ ray/src/gen/gendaymtx.c 2016/08/20 15:42:38 2.25 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: gendaymtx.c,v 2.21 2015/09/02 22:52:04 greg Exp $"; +static const char RCSid[] = "$Id: gendaymtx.c,v 2.25 2016/08/20 15:42:38 greg Exp $"; #endif /* * gendaymtx.c @@ -86,6 +86,7 @@ static const char RCSid[] = "$Id: gendaymtx.c,v 2.21 2 #include #include #include "rtmath.h" +#include "rtio.h" #include "resolu.h" #include "platform.h" #include "color.h" @@ -323,6 +324,7 @@ main(int argc, char *argv[]) int ntsteps = 0; /* number of rows in matrix */ int step_alloc = 0; int last_monthly = 0; /* month of last report */ + int inconsistent = 0; /* inconsistent options set? */ int mo, da; /* month (1-12) and day (1-31) */ double hr; /* hour (local standard time) */ double dir, dif; /* direct and diffuse values */ @@ -373,19 +375,24 @@ main(int argc, char *argv[]) rhsubdiv = atoi(argv[++i]); break; case 'c': /* sky color */ + inconsistent |= (skycolor[1] <= 1e-4); skycolor[0] = atof(argv[++i]); skycolor[1] = atof(argv[++i]); skycolor[2] = atof(argv[++i]); break; case 'd': /* solar (direct) only */ skycolor[0] = skycolor[1] = skycolor[2] = 0; - if (suncolor[1] <= 1e-4) + if (suncolor[1] <= 1e-4) { + inconsistent = 1; suncolor[0] = suncolor[1] = suncolor[2] = 1; + } break; case 's': /* sky only (no direct) */ suncolor[0] = suncolor[1] = suncolor[2] = 0; - if (skycolor[1] <= 1e-4) + if (skycolor[1] <= 1e-4) { + inconsistent = 1; skycolor[0] = skycolor[1] = skycolor[2] = 1; + } break; case 'r': /* rotate distribution */ if (argv[i][2] && argv[i][2] != 'z') @@ -407,6 +414,9 @@ main(int argc, char *argv[]) } if (i < argc-1) goto userr; + if (inconsistent) + fprintf(stderr, "%s: WARNING: inconsistent -s, -d, -c options!\n", + progname); if (i == argc-1 && freopen(argv[i], "r", stdin) == NULL) { fprintf(stderr, "%s: cannot open '%s' for input\n", progname, argv[i]); @@ -546,7 +556,7 @@ main(int argc, char *argv[]) break; case 'f': for (j = 0; j < ntsteps; j++) { - fwrite(mtx_data+mtx_offset, sizeof(float), 3, + putbinary(mtx_data+mtx_offset, sizeof(float), 3, stdout); mtx_offset += 3*nskypatch; } @@ -557,7 +567,7 @@ main(int argc, char *argv[]) ment[0] = mtx_data[mtx_offset]; ment[1] = mtx_data[mtx_offset+1]; ment[2] = mtx_data[mtx_offset+2]; - fwrite(ment, sizeof(double), 3, stdout); + putbinary(ment, sizeof(double), 3, stdout); mtx_offset += 3*nskypatch; } break;