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

Comparing ray/src/cv/bsdfquery.c (file contents):
Revision 2.7 by greg, Thu Aug 18 00:52:48 2016 UTC vs.
Revision 2.12 by greg, Fri Mar 26 22:01:44 2021 UTC

# Line 5 | Line 5 | static const char RCSid[] = "$Id$";
5   *  Query values from the given BSDF (scattering interpolant or XML repres.)
6   *  Input query is incident and exiting vectors directed away from surface.
7   *  We normalize.  Output is a BSDF value for the vector pair.
8 + *  A zero length in or out vector is ignored, causing output to be flushed.
9   *  It is wise to sort the input directions to keep identical ones together
10   *  when using a scattering interpolant representation.
11   */
12  
13   #define _USE_MATH_DEFINES
13 #include <stdio.h>
14 #include <string.h>
14   #include <stdlib.h>
15   #include "rtmath.h"
16   #include "rtio.h"
# Line 25 | Line 24 | readIOdir(FVECT idir, FVECT odir, FILE *fp, int fmt)
24   {
25          double  dvec[6];
26          float   fvec[6];
27 <
27 > tryagain:
28          switch (fmt) {
29          case 'a':
30                  if (fscanf(fp, FVFORMAT, &idir[0], &idir[1], &idir[2]) != 3 ||
# Line 46 | Line 45 | readIOdir(FVECT idir, FVECT odir, FILE *fp, int fmt)
45                  break;
46          }
47          if ((normalize(idir) == 0) | (normalize(odir) == 0)) {
48 <                fprintf(stderr, "%s: zero input vector!\n", progname);
49 <                return(0);
48 >                fflush(stdout);         /* desired side-effect? */
49 >                goto tryagain;
50          }
51          return(1);
52   }
# Line 56 | Line 55 | readIOdir(FVECT idir, FVECT odir, FILE *fp, int fmt)
55   int
56   main(int argc, char *argv[])
57   {
58 +        int     unbuffered = 0;
59          int     repXYZ = 0;
60          int     inpXML = -1;
61          int     inpfmt = 'a';
# Line 69 | Line 69 | main(int argc, char *argv[])
69          progname = argv[0];
70          while (argc > 2 && argv[1][0] == '-') {
71                  switch (argv[1][1]) {
72 +                case 'u':                       /* unbuffered output */
73 +                        unbuffered = 1;
74 +                        break;
75                  case 'c':                       /* color output */
76                          repXYZ = 1;
77                          break;
# Line 135 | Line 138 | main(int argc, char *argv[])
138                          if (SDreportError(eval_rbfcol(&sval, rbf, odir), stderr))
139                                  return(1);
140                  }
138                if (repXYZ)                     /* ensure we have CIE (x,y) */
139                        c_ccvt(&sval.spec, C_CSXY);
141  
142                  switch (outfmt) {               /* write to stdout */
143                  case 'a':
# Line 173 | Line 174 | main(int argc, char *argv[])
174                          }
175                          break;
176                  }
177 +                if (unbuffered)
178 +                        fflush(stdout);
179          }
180          /* if (rbf != NULL) free(rbf); */
181          return(0);
182   userr:
183 <        fprintf(stderr, "Usage: %s [-c][-fio] bsdf.{sir|xml}\n", progname);
183 >        fprintf(stderr, "Usage: %s [-u][-c][-fio] bsdf.{sir|xml}\n", progname);
184          return(1);
185   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines