--- ray/src/cv/bsdf2ttree.c 2012/11/09 02:16:29 2.5 +++ ray/src/cv/bsdf2ttree.c 2012/11/22 06:07:17 2.9 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: bsdf2ttree.c,v 2.5 2012/11/09 02:16:29 greg Exp $"; +static const char RCSid[] = "$Id: bsdf2ttree.c,v 2.9 2012/11/22 06:07:17 greg Exp $"; #endif /* * Load measured BSDF interpolant and write out as XML file with tensor tree. @@ -16,7 +16,7 @@ static const char RCSid[] = "$Id: bsdf2ttree.c,v 2.5 2 /* global argv[0] */ char *progname; /* percentage to cull (<0 to turn off) */ -int pctcull = 90; +double pctcull = 90.; /* sampling order */ int samp_order = 6; @@ -32,11 +32,11 @@ interp_isotropic() float bsdf; #if DEBUG fprintf(stderr, "Writing isotropic order %d ", samp_order); - if (pctcull >= 0) fprintf(stderr, "data with %d%% culling\n", pctcull); + if (pctcull >= 0) fprintf(stderr, "data with %.1f%% culling\n", pctcull); else fputs("raw data\n", stderr); #endif if (pctcull >= 0) { /* begin output */ - sprintf(cmd, "rttree_reduce -h -a -ff -r 3 -t %d -g %d", + sprintf(cmd, "rttree_reduce -h -a -ff -r 3 -t %f -g %d", pctcull, samp_order); fflush(stdout); ofp = popen(cmd, "w"); @@ -94,11 +94,11 @@ interp_anisotropic() float bsdf; #if DEBUG fprintf(stderr, "Writing anisotropic order %d ", samp_order); - if (pctcull >= 0) fprintf(stderr, "data with %d%% culling\n", pctcull); + if (pctcull >= 0) fprintf(stderr, "data with %.1f%% culling\n", pctcull); else fputs("raw data\n", stderr); #endif if (pctcull >= 0) { /* begin output */ - sprintf(cmd, "rttree_reduce -h -a -ff -r 4 -t %d -g %d", + sprintf(cmd, "rttree_reduce -h -a -ff -r 4 -t %f -g %d", pctcull, samp_order); fflush(stdout); ofp = popen(cmd, "w"); @@ -145,57 +145,44 @@ interp_anisotropic() static void xml_prologue(int ac, char *av[]) { - static const char *prologue0[] = { -"", -"", - NULL}; - static const char *prologue1[] = { -"System", -"BSDF", -"", -"", -"\t", -"\t\tName", -"\t\tManufacturer", -"\t\tOther", -"\t", - NULL}; - static const char *prologue2[] = { -"\t", -"\t\tSystem", -"\t\tVisible", -"\t\tCIE Illuminant D65 1nm.ssp", -"\t\tASTM E308 1931 Y.dsp", -"\t\t", -"\t\t\tLBNL/Shirley-Chiu", -"\t\t\tBTDF", - NULL}; static const char *bsdf_type[4] = { - "Reflection Back", - "Transmission Back", + "Reflection Front", "Transmission Front", - "Reflection Front" + "Transmission Back", + "Reflection Back" }; - int i; - for (i = 0; prologue0[i] != NULL; i++) - puts(prologue0[i]); + puts(""); + puts(""); fputs(""); - for (i = 0; prologue1[i] != NULL; i++) - puts(prologue1[i]); + puts("System"); + puts("BSDF"); + puts(""); + puts(""); + puts("\t"); + puts("\t\tName"); + puts("\t\tManufacturer"); + puts("\t\tOther"); + puts("\t"); puts("\t"); printf("\t\tTensorTree%c\n", single_plane_incident ? '3' : '4'); puts("\t"); - for (i = 0; prologue2[i] != NULL; i++) - puts(prologue2[i]); + puts("\t"); + puts("\t\tSystem"); + puts("\t\tVisible"); + puts("\t\tCIE Illuminant D65 1nm.ssp"); + puts("\t\tASTM E308 1931 Y.dsp"); + puts("\t\t"); printf("\t\t\t%s\n", - bsdf_type[(input_orient>0)<<1 | (output_orient>0)]); + bsdf_type[(input_orient>0)<<1 | (output_orient>0)]); + puts("\t\t\tLBNL/Shirley-Chiu"); + puts("\t\t\tBTDF"); puts("\t\t\t"); } @@ -203,18 +190,12 @@ xml_prologue(int ac, char *av[]) static void xml_epilogue(void) { - static const char *epilogue[] = { -"\t\t\t", -"\t\t", -"\t", -"", -"", -"", - NULL}; - int i; - - for (i = 0; epilogue[i] != NULL; i++) - puts(epilogue[i]); + puts("\t\t\t"); + puts("\t\t"); + puts("\t"); + puts(""); + puts(""); + puts(""); } /* Read in BSDF and interpolate as tensor tree representation */ @@ -228,7 +209,7 @@ main(int argc, char *argv[]) for (i = 1; i < argc-1 && argv[i][0] == '-'; i++) switch (argv[i][1]) { /* get option */ case 't': - pctcull = atoi(argv[++i]); + pctcull = atof(argv[++i]); break; case 'g': samp_order = atoi(argv[++i]);