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.10 by greg, Tue Jun 11 16:09:40 2019 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   */
# Line 25 | Line 26 | readIOdir(FVECT idir, FVECT odir, FILE *fp, int fmt)
26   {
27          double  dvec[6];
28          float   fvec[6];
29 <
29 > tryagain:
30          switch (fmt) {
31          case 'a':
32                  if (fscanf(fp, FVFORMAT, &idir[0], &idir[1], &idir[2]) != 3 ||
# Line 46 | Line 47 | readIOdir(FVECT idir, FVECT odir, FILE *fp, int fmt)
47                  break;
48          }
49          if ((normalize(idir) == 0) | (normalize(odir) == 0)) {
50 <                fprintf(stderr, "%s: zero input vector!\n", progname);
51 <                return(0);
50 >                fflush(stdout);         /* desired side-effect? */
51 >                goto tryagain;
52          }
53          return(1);
54   }
# Line 56 | Line 57 | readIOdir(FVECT idir, FVECT odir, FILE *fp, int fmt)
57   int
58   main(int argc, char *argv[])
59   {
60 +        int     unbuffered = 0;
61          int     repXYZ = 0;
62          int     inpXML = -1;
63          int     inpfmt = 'a';
# Line 69 | Line 71 | main(int argc, char *argv[])
71          progname = argv[0];
72          while (argc > 2 && argv[1][0] == '-') {
73                  switch (argv[1][1]) {
74 +                case 'u':                       /* unbuffered output */\
75 +                        unbuffered = 1;
76 +                        break;
77                  case 'c':                       /* color output */
78                          repXYZ = 1;
79                          break;
# Line 135 | Line 140 | main(int argc, char *argv[])
140                          if (SDreportError(eval_rbfcol(&sval, rbf, odir), stderr))
141                                  return(1);
142                  }
138                if (repXYZ)                     /* ensure we have CIE (x,y) */
139                        c_ccvt(&sval.spec, C_CSXY);
143  
144                  switch (outfmt) {               /* write to stdout */
145                  case 'a':
# Line 173 | Line 176 | main(int argc, char *argv[])
176                          }
177                          break;
178                  }
179 +                if (unbuffered)
180 +                        fflush(stdout);
181          }
182          /* if (rbf != NULL) free(rbf); */
183          return(0);
184   userr:
185 <        fprintf(stderr, "Usage: %s [-c][-fio] bsdf.{sir|xml}\n", progname);
185 >        fprintf(stderr, "Usage: %s [-u][-c][-fio] bsdf.{sir|xml}\n", progname);
186          return(1);
187   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines