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

Comparing ray/src/common/testBSDF.c (file contents):
Revision 1.1 by greg, Fri Jun 5 17:55:18 2015 UTC vs.
Revision 1.5 by greg, Wed Feb 3 18:33:18 2016 UTC

# Line 20 | Line 20 | Usage(const char *prog)
20   {
21          printf("Usage: %s [bsdf_directory]\n", prog);
22          printf("Input commands:\n");
23 <        printf("  l bsdf.xml\t\t\t Load (make active) given BSDF input file\n");
24 <        printf("  q theta_i phi_i theta_o phi_o\t Query BSDF for given path\n");
23 >        printf("  L bsdf.xml\t\t\t Load (make active) given BSDF input file\n");
24 >        printf("  q theta_i phi_i theta_o phi_o\t Query BSDF for given path (CIE-XYZ)\n");
25          printf("  s N theta phi\t\t\t Generate N ray directions at given incidence\n");
26          printf("  h theta phi\t\t\t Report hemispherical total at given incidence\n");
27          printf("  r theta phi\t\t\t Report hemispherical reflection at given incidence\n");
# Line 45 | Line 45 | vec_from_deg(FVECT v, double theta, double phi)
45   int
46   main(int argc, char *argv[])
47   {
48 <        const char      *directory = "";
48 >        const char      *directory = NULL;
49          char            inp[512], path[512];
50          const SDData    *bsdf = NULL;
51  
# Line 56 | Line 56 | main(int argc, char *argv[])
56          if (argc == 2)
57                  directory = argv[1];
58          
59 <        SDretainSet = SDretainBSDFs;            /* keep BSDFs loaded */
59 >        SDretainSet = SDretainBSDFs;            /* keep BSDFs in memory */
60  
61                                                  /* loop on command */
62          while (fgets(inp, sizeof(inp), stdin) != NULL) {
# Line 70 | Line 70 | main(int argc, char *argv[])
70                  
71                  while (isspace(*cp)) cp++;
72  
73 <                switch (*cp) {
74 <                case 'l':
73 >                switch (toupper(*cp)) {
74                  case 'L':                       /* load/activate BSDF input */
75                          cp2 = cp = sskip2(cp, 1);
76                          if (!*cp)
77                                  break;
78                          while (*cp) cp++;
79                          while (isspace(*--cp)) *cp = '\0';
80 <                        if (directory[0])
80 >                        if (directory)
81                                  sprintf(path, "%s/%s", directory, cp2);
82                          else
83                                  strcpy(path, cp2);
84 +                        if (bsdf)
85 +                                SDfreeCache(bsdf);
86                          bsdf = SDcacheFile(path);
87                          continue;
87                case 'q':
88                  case 'Q':                       /* query BSDF value */
89                          if (bsdf == NULL)
90                                  goto noBSDFerr;
# Line 92 | Line 92 | main(int argc, char *argv[])
92                                  break;
93                          vec_from_deg(vin, atof(sskip2(cp,1)), atof(sskip2(cp,2)));
94                          vec_from_deg(vout, atof(sskip2(cp,3)), atof(sskip2(cp,4)));
95 <                        if (!SDreportError(SDevalBSDF(&val, vout, vin, bsdf), stderr))
96 <                                printf("%.3e\n", val.cieY);
95 >                        if (!SDreportError(SDevalBSDF(&val, vout, vin, bsdf), stderr)) {
96 >                                c_ccvt(&val.spec, C_CSXY);
97 >                                printf("%.3e %.3e %.3e\n",
98 >                                                val.spec.cx/val.spec.cy*val.cieY,
99 >                                                val.cieY,
100 >                                                (1.-val.spec.cx-val.spec.cy)/
101 >                                                val.spec.cy*val.cieY);
102 >                        }
103                          continue;
98                case 's':
104                  case 'S':                       /* sample BSDF */
105                          if (bsdf == NULL)
106                                  goto noBSDFerr;
# Line 111 | Line 116 | main(int argc, char *argv[])
116                                  printf("%.8f %.8f %.8f\n", vin[0], vin[1], vin[2]);
117                          }
118                          continue;
114                case 'h':
119                  case 'H':                       /* hemispherical totals */
116                case 'r':
120                  case 'R':
118                case 't':
121                  case 'T':
122                          if (bsdf == NULL)
123                                  goto noBSDFerr;
124                          if (!*sskip2(cp,2))
125                                  break;
126                          if (tolower(*cp) == 'r')
127 <                                sflags ^= SDsampT;
127 >                                sflags &= ~SDsampT;
128                          else if (tolower(*cp) == 't')
129 <                                sflags ^= SDsampR;
129 >                                sflags &= ~SDsampR;
130                          vec_from_deg(vin, atof(sskip2(cp,1)), atof(sskip2(cp,2)));
131                          printf("%.4e\n", SDdirectHemi(vin, sflags, bsdf));
132                          continue;
133 <                case 'a':
132 <                case 'A':                       /* resolution in degrees */
133 >                case 'A':                       /* resolution in proj. steradians */
134                          if (bsdf == NULL)
135                                  goto noBSDFerr;
136                          if (!*sskip2(cp,2))
# Line 149 | Line 150 | main(int argc, char *argv[])
150                  Usage(argv[0]);
151                  continue;
152   noBSDFerr:
153 <                fprintf(stderr, "%s: need to use 'l' command to load BSDF\n", argv[0]);
153 >                fprintf(stderr, "%s: need to use 'L' command to load BSDF\n", argv[0]);
154          }
155          return 0;
156   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines