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.9 by greg, Thu Feb 2 04:46:38 2017 UTC vs.
Revision 1.14 by greg, Tue Jun 11 14:26:29 2019 UTC

# Line 24 | Line 24 | Usage(const char *prog)
24          printf("  i\t\t\t\t Report general information (metadata)\n");
25          printf("  c\t\t\t\t Report diffuse and specular components\n");
26          printf("  q theta_i phi_i theta_o phi_o\t Query BSDF for given path (CIE-XYZ)\n");
27 <        printf("  s[r|t][s|d] N theta phi\t\t\t Generate N ray directions & colors at given incidence\n");
28 <        printf("  h[s|d] theta phi\t\t\t Report hemispherical scatteromg at given incidence\n");
29 <        printf("  r[s|d] theta phi\t\t\t Report hemispherical reflection at given incidence\n");
30 <        printf("  t[s|d] theta phi\t\t\t Report hemispherical transmission at given incidence\n");
27 >        printf("  s[r|t][s|d] N theta phi\t Generate N ray directions & colors at given incidence\n");
28 >        printf("  h[s|d] theta phi\t\t Report hemispherical scattering at given incidence\n");
29 >        printf("  r[s|d] theta phi\t\t Report hemispherical reflection at given incidence\n");
30 >        printf("  t[s|d] theta phi\t\t Report hemispherical transmission at given incidence\n");
31          printf("  a theta phi [t2 p2]\t\t Report resolution (in proj. steradians) for given direction(s)\n");
32          printf("  ^D\t\t\t\t Quit program\n");
33   }
# Line 47 | Line 47 | vec_from_deg(FVECT v, double theta, double phi)
47   static void
48   printXYZ(const char *intro, const SDValue *vp)
49   {
50 +        if (vp->cieY <= 1e-9) {
51 +                printf("%s0 0 0\n", intro);
52 +                return;
53 +        }
54          printf("%s%.3e %.3e %.3e\n", intro,
55                          vp->spec.cx/vp->spec.cy*vp->cieY,
56                          vp->cieY,
# Line 104 | Line 108 | main(int argc, char *argv[])
108                          printf("Manufacturer: '%s'\n", bsdf->makr);
109                          printf("Width, Height, Thickness (m): %.4e, %.4e, %.4e\n",
110                                          bsdf->dim[0], bsdf->dim[1], bsdf->dim[2]);
111 <                        printf("Has geometry: %s\n", bsdf->mgf ? "yes" : "no");
112 <                        continue;
111 >                        if (bsdf->mgf)
112 >                                printf("Has geometry: %lu bytes\n",
113 >                                                (unsigned long)strlen(bsdf->mgf));
114 >                        else
115 >                                printf("Has geometry: no\n");
116 >                        break;
117                  case 'C':                       /* report constant values */
118                          if (!bsdf)
119                                  goto noBSDFerr;
# Line 126 | Line 134 | main(int argc, char *argv[])
134                          printXYZ("Diffuse Front Reflectance: ", &bsdf->rLambFront);
135                          printXYZ("Diffuse Back Reflectance: ", &bsdf->rLambBack);
136                          printXYZ("Diffuse Transmittance: ", &bsdf->tLamb);
137 <                        continue;
137 >                        break;
138                  case 'Q':                       /* query BSDF value */
139                          if (!bsdf)
140                                  goto noBSDFerr;
# Line 136 | Line 144 | main(int argc, char *argv[])
144                          vec_from_deg(vout, atof(sskip2(cp,3)), atof(sskip2(cp,4)));
145                          if (!SDreportError(SDevalBSDF(&val, vout, vin, bsdf), stderr))
146                                  printXYZ("", &val);
147 <                        continue;
147 >                        break;
148                  case 'S':                       /* sample BSDF */
149                          if (!bsdf)
150                                  goto noBSDFerr;
# Line 164 | Line 172 | main(int argc, char *argv[])
172                                  printf("%.8f %.8f %.8f ", vout[0], vout[1], vout[2]);
173                                  printXYZ("", &val);
174                          }
175 <                        continue;
175 >                        break;
176                  case 'H':                       /* hemispherical values */
177                  case 'R':
178                  case 'T':
# Line 182 | Line 190 | main(int argc, char *argv[])
190                                  sflags &= ~SDsampSp;
191                          vec_from_deg(vin, atof(sskip2(cp,1)), atof(sskip2(cp,2)));
192                          printf("%.4e\n", SDdirectHemi(vin, sflags, bsdf));
193 <                        continue;
193 >                        break;
194                  case 'A':                       /* resolution in proj. steradians */
195                          if (!bsdf)
196                                  goto noBSDFerr;
# Line 191 | Line 199 | main(int argc, char *argv[])
199                          vec_from_deg(vin, atof(sskip2(cp,1)), atof(sskip2(cp,2)));
200                          if (*sskip2(cp,4)) {
201                                  vec_from_deg(vout, atof(sskip2(cp,3)), atof(sskip2(cp,4)));
202 <                                if (SDreportError(SDsizeBSDF(proja, vin, vout,
202 >                                if (SDreportError(SDsizeBSDF(proja, vout, vin,
203                                                  SDqueryMin+SDqueryMax, bsdf), stderr))
204                                          continue;
205                          } else if (SDreportError(SDsizeBSDF(proja, vin, NULL,
206                                                  SDqueryMin+SDqueryMax, bsdf), stderr))
207                                          continue;
208                          printf("%.4e %.4e\n", proja[0], proja[1]);
209 <                        continue;
209 >                        break;
210 >                default:
211 >                        Usage(argv[0]);
212 >                        break;
213                  }
214 <                Usage(argv[0]);
214 >                fflush(stdout);                 /* in case we're on remote */
215                  continue;
216   noBSDFerr:
217                  fprintf(stderr, "%s: First, use 'L' command to load BSDF\n", argv[0]);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines