--- ray/src/cv/checkBSDF.c 2021/12/17 20:51:55 2.3 +++ ray/src/cv/checkBSDF.c 2022/08/12 23:55:00 2.9 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: checkBSDF.c,v 2.3 2021/12/17 20:51:55 greg Exp $"; +static const char RCSid[] = "$Id: checkBSDF.c,v 2.9 2022/08/12 23:55:00 greg Exp $"; #endif /* * checkBSDF.c @@ -29,7 +29,7 @@ typedef struct { const SimpleStats SSinit = {FHUGE, -FHUGE, .0, 0}; /* relative difference formula */ -#define rdiff(a,b) ((a)>(b) ? ((a)-(b))/(a) : ((b)-(a))/(b)) +#define rdiff(a,b) ((a)>(b) ? ((a)-(b))/((a)+FTINY) : ((b)-(a))/((b)+FTINY)) /* Figure out BSDF type (and optionally determine if in color) */ const char * @@ -80,15 +80,22 @@ getBSDFtype(const SDData *bsdf, int *flags) void detailComponent(const char *nm, const SDValue *lamb, const SDSpectralDF *df) { - printf("%s\t%4.1f %4.1f %4.1f\t\t", nm, + double Lamb = 0; + + fputs(nm, stdout); + if (lamb->spec.flags) { + printf("\t%4.1f %4.1f %4.1f\t\t", 100.*lamb->cieY*lamb->spec.cx/lamb->spec.cy, 100.*lamb->cieY, 100.*lamb->cieY*(1.f - lamb->spec.cx - lamb->spec.cy)/lamb->spec.cy); + Lamb = lamb->cieY; + } else + fputs("\t 0 0 0\t\t", stdout); if (df) - printf("%5.1f%%\t\t%.2f deg\n", 100.*df->maxHemi, + printf("%5.1f%%\t\t%.2f deg\n", 100.*(Lamb+df->maxHemi), sqrt(df->minProjSA/M_PI)*(360./M_PI)); else - puts("0%\t\t180"); + printf("%5.1f%%\t\t180 deg", Lamb); } /* Add a value to stats */ @@ -222,7 +229,7 @@ checkReciprocity(const char *nm, const int side1, cons return; } nothing2do: - printf("%s\t0\t0\t0\n", nm); + printf("%s\t 0\t 0\t 0\n", nm); } /* Report on the given BSDF XML file */ @@ -236,7 +243,7 @@ checkXML(char *fname) puts("====================================================="); printf("File: '%s'\n", fname); SDclearBSDF(&myBSDF, fname); - pth = getpath(fname, getrlibpath(), R_OK); + pth = getpath(fname, getrlibpath(), 0); if (!pth) { fprintf(stderr, "Cannot find file '%s'\n", fname); return 0; @@ -250,14 +257,14 @@ checkXML(char *fname) printf("Type: %s\n", getBSDFtype(&myBSDF, &flags)); printf("Color: %d\n", (flags & F_IN_COLOR) != 0); printf("Has Geometry: %d\n", (myBSDF.mgf != NULL)); - puts("Component\tLambertian XYZ %\tMax. Dir\tMin. Angle"); - detailComponent("Internal Refl", &myBSDF.rLambFront, myBSDF.rf); - detailComponent("External Refl", &myBSDF.rLambBack, myBSDF.rb); + puts("Component\tLambertian XYZ (%)\tMax. Tot. Dir\tMin. Angle"); + detailComponent("Interior Refl", &myBSDF.rLambFront, myBSDF.rf); + detailComponent("Exterior Refl", &myBSDF.rLambBack, myBSDF.rb); detailComponent("Int->Ext Trans", &myBSDF.tLambFront, myBSDF.tf); detailComponent("Ext->Int Trans", &myBSDF.tLambBack, myBSDF.tb); puts("Component\tReciprocity Error (min avg max %)"); - checkReciprocity("Front Refl", 1, 1, &myBSDF, flags); - checkReciprocity("Back Refl", -1, -1, &myBSDF, flags); + checkReciprocity("Interior Refl", 1, 1, &myBSDF, flags); + checkReciprocity("Exterior Refl", -1, -1, &myBSDF, flags); checkReciprocity("Transmission", -1, 1, &myBSDF, flags); SDfreeBSDF(&myBSDF); return 1;