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.13 by greg, Tue Jun 3 21:31:51 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 "paths.h"
18   #include "bsdfrep.h"
19  
20 char    *progname;
21
20   /* Read in a vector pair */
21   static int
22   readIOdir(FVECT idir, FVECT odir, FILE *fp, int fmt)
23   {
24          double  dvec[6];
25          float   fvec[6];
26 <
26 > tryagain:
27          switch (fmt) {
28          case 'a':
29                  if (fscanf(fp, FVFORMAT, &idir[0], &idir[1], &idir[2]) != 3 ||
# Line 46 | Line 44 | readIOdir(FVECT idir, FVECT odir, FILE *fp, int fmt)
44                  break;
45          }
46          if ((normalize(idir) == 0) | (normalize(odir) == 0)) {
47 <                fprintf(stderr, "%s: zero input vector!\n", progname);
48 <                return(0);
47 >                fflush(stdout);         /* desired side-effect? */
48 >                goto tryagain;
49          }
50          return(1);
51   }
# Line 56 | Line 54 | readIOdir(FVECT idir, FVECT odir, FILE *fp, int fmt)
54   int
55   main(int argc, char *argv[])
56   {
57 +        int     unbuffered = 0;
58          int     repXYZ = 0;
59          int     inpXML = -1;
60          int     inpfmt = 'a';
# Line 65 | Line 64 | main(int argc, char *argv[])
64          SDData  myBSDF;
65          FVECT   idir, odir;
66          int     n;
67 +                                                /* set global progname */
68 +        fixargv0(argv[0]);
69                                                  /* check arguments */
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