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.14 by greg, Sat Jun 7 05:09:45 2025 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"
17   #include "bsdfrep.h"
18  
20 char    *progname;
21
19   /* Read in a vector pair */
20   static int
21   readIOdir(FVECT idir, FVECT odir, FILE *fp, int fmt)
22   {
23          double  dvec[6];
24          float   fvec[6];
25 <
25 > tryagain:
26          switch (fmt) {
27          case 'a':
28                  if (fscanf(fp, FVFORMAT, &idir[0], &idir[1], &idir[2]) != 3 ||
# Line 46 | Line 43 | readIOdir(FVECT idir, FVECT odir, FILE *fp, int fmt)
43                  break;
44          }
45          if ((normalize(idir) == 0) | (normalize(odir) == 0)) {
46 <                fprintf(stderr, "%s: zero input vector!\n", progname);
47 <                return(0);
46 >                fflush(stdout);         /* desired side-effect? */
47 >                goto tryagain;
48          }
49          return(1);
50   }
# Line 56 | Line 53 | readIOdir(FVECT idir, FVECT odir, FILE *fp, int fmt)
53   int
54   main(int argc, char *argv[])
55   {
56 +        int     unbuffered = 0;
57          int     repXYZ = 0;
58          int     inpXML = -1;
59          int     inpfmt = 'a';
# Line 65 | Line 63 | main(int argc, char *argv[])
63          SDData  myBSDF;
64          FVECT   idir, odir;
65          int     n;
66 +                                                /* set global progname */
67 +        fixargv0(argv[0]);
68                                                  /* check arguments */
69        progname = argv[0];
69          while (argc > 2 && argv[1][0] == '-') {
70                  switch (argv[1][1]) {
71 +                case 'u':                       /* unbuffered output */
72 +                        unbuffered = 1;
73 +                        break;
74                  case 'c':                       /* color output */
75                          repXYZ = 1;
76                          break;
# Line 135 | Line 137 | main(int argc, char *argv[])
137                          if (SDreportError(eval_rbfcol(&sval, rbf, odir), stderr))
138                                  return(1);
139                  }
138                if (repXYZ)                     /* ensure we have CIE (x,y) */
139                        c_ccvt(&sval.spec, C_CSXY);
140  
141                  switch (outfmt) {               /* write to stdout */
142                  case 'a':
# Line 173 | Line 173 | main(int argc, char *argv[])
173                          }
174                          break;
175                  }
176 +                if (unbuffered)
177 +                        fflush(stdout);
178          }
179          /* if (rbf != NULL) free(rbf); */
180          return(0);
181   userr:
182 <        fprintf(stderr, "Usage: %s [-c][-fio] bsdf.{sir|xml}\n", progname);
182 >        fprintf(stderr, "Usage: %s [-u][-c][-fio] bsdf.{sir|xml}\n", progname);
183          return(1);
184   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines