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.5 by greg, Wed Feb 3 18:33:18 2016 UTC vs.
Revision 1.6 by greg, Thu Feb 2 00:27:55 2017 UTC

# Line 21 | Line 21 | Usage(const char *prog)
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("  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 N theta phi\t\t\t Generate N ray directions at given incidence\n");
28          printf("  h theta phi\t\t\t Report hemispherical total at given incidence\n");
# Line 42 | Line 44 | vec_from_deg(FVECT v, double theta, double phi)
44          v[2] = cos(theta);
45   }
46  
47 + static void
48 + printXYZ(const char *intro, const SDValue *vp)
49 + {
50 +        printf("%s%.3e %.3e %.3e\n", intro,
51 +                        vp->spec.cx/vp->spec.cy*vp->cieY,
52 +                        vp->cieY,
53 +                        (1.-vp->spec.cx-vp->spec.cy)/
54 +                        vp->spec.cy*vp->cieY);
55 + }
56 +
57   int
58   main(int argc, char *argv[])
59   {
# Line 85 | Line 97 | main(int argc, char *argv[])
97                                  SDfreeCache(bsdf);
98                          bsdf = SDcacheFile(path);
99                          continue;
100 +                case 'I':                       /* report general info. */
101 +                        if (bsdf == NULL)
102 +                                goto noBSDFerr;
103 +                        printf("Material: '%s'\n", bsdf->matn);
104 +                        printf("Manufacturer: '%s'\n", bsdf->makr);
105 +                        printf("Has geometry: %s\n", bsdf->mgf!=NULL ? "yes" : "no");
106 +                        printf("Width, Height, Thickness (m): %.4e, %.4e, %.4e\n",
107 +                                        bsdf->dim[0], bsdf->dim[1], bsdf->dim[2]);
108 +                        continue;
109 +                case 'C':                       /* report constant values */
110 +                        if (bsdf == NULL)
111 +                                goto noBSDFerr;
112 +                        if (bsdf->rf != NULL)
113 +                                printf("Peak front hemispherical reflectance: %.3e\n",
114 +                                                bsdf->rLambFront.cieY +
115 +                                                bsdf->rf->maxHemi);
116 +                        if (bsdf->rb != NULL)
117 +                                printf("Peak back hemispherical reflectance: %.3e\n",
118 +                                                bsdf->rLambBack.cieY +
119 +                                                bsdf->rb->maxHemi);
120 +                        if (bsdf->tf != NULL)
121 +                                printf("Peak front hemispherical transmittance: %.3e\n",
122 +                                                bsdf->tLamb.cieY + bsdf->tf->maxHemi);
123 +                        if (bsdf->tb != NULL)
124 +                                printf("Peak back hemispherical transmittance: %.3e\n",
125 +                                                bsdf->tLamb.cieY + bsdf->tb->maxHemi);
126 +                        printXYZ("Diffuse Front Reflectance: ", &bsdf->rLambFront);
127 +                        printXYZ("Diffuse Back Reflectance: ", &bsdf->rLambBack);
128 +                        printXYZ("Diffuse Transmittance: ", &bsdf->tLamb);
129 +                        continue;
130                  case 'Q':                       /* query BSDF value */
131                          if (bsdf == NULL)
132                                  goto noBSDFerr;
# Line 92 | Line 134 | main(int argc, char *argv[])
134                                  break;
135                          vec_from_deg(vin, atof(sskip2(cp,1)), atof(sskip2(cp,2)));
136                          vec_from_deg(vout, atof(sskip2(cp,3)), atof(sskip2(cp,4)));
137 <                        if (!SDreportError(SDevalBSDF(&val, vout, vin, bsdf), stderr)) {
138 <                                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 <                        }
137 >                        if (!SDreportError(SDevalBSDF(&val, vout, vin, bsdf), stderr))
138 >                                printXYZ("", &val);
139                          continue;
140                  case 'S':                       /* sample BSDF */
141                          if (bsdf == NULL)
# Line 150 | Line 186 | main(int argc, char *argv[])
186                  Usage(argv[0]);
187                  continue;
188   noBSDFerr:
189 <                fprintf(stderr, "%s: need to use 'L' command to load BSDF\n", argv[0]);
189 >                fprintf(stderr, "%s: First, use 'L' command to load BSDF\n", argv[0]);
190          }
191          return 0;
192   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines