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

Comparing ray/src/cv/bsdf2ttree.c (file contents):
Revision 2.5 by greg, Fri Nov 9 02:16:29 2012 UTC vs.
Revision 2.9 by greg, Thu Nov 22 06:07:17 2012 UTC

# Line 16 | Line 16 | static const char RCSid[] = "$Id$";
16                                  /* global argv[0] */
17   char                    *progname;
18                                  /* percentage to cull (<0 to turn off) */
19 < int                     pctcull = 90;
19 > double                  pctcull = 90.;
20                                  /* sampling order */
21   int                     samp_order = 6;
22  
# Line 32 | Line 32 | interp_isotropic()
32          float           bsdf;
33   #if DEBUG
34          fprintf(stderr, "Writing isotropic order %d ", samp_order);
35 <        if (pctcull >= 0) fprintf(stderr, "data with %d%% culling\n", pctcull);
35 >        if (pctcull >= 0) fprintf(stderr, "data with %.1f%% culling\n", pctcull);
36          else fputs("raw data\n", stderr);
37   #endif
38          if (pctcull >= 0) {                     /* begin output */
39 <                sprintf(cmd, "rttree_reduce -h -a -ff -r 3 -t %d -g %d",
39 >                sprintf(cmd, "rttree_reduce -h -a -ff -r 3 -t %f -g %d",
40                                  pctcull, samp_order);
41                  fflush(stdout);
42                  ofp = popen(cmd, "w");
# Line 94 | Line 94 | interp_anisotropic()
94          float           bsdf;
95   #if DEBUG
96          fprintf(stderr, "Writing anisotropic order %d ", samp_order);
97 <        if (pctcull >= 0) fprintf(stderr, "data with %d%% culling\n", pctcull);
97 >        if (pctcull >= 0) fprintf(stderr, "data with %.1f%% culling\n", pctcull);
98          else fputs("raw data\n", stderr);
99   #endif
100          if (pctcull >= 0) {                     /* begin output */
101 <                sprintf(cmd, "rttree_reduce -h -a -ff -r 4 -t %d -g %d",
101 >                sprintf(cmd, "rttree_reduce -h -a -ff -r 4 -t %f -g %d",
102                                  pctcull, samp_order);
103                  fflush(stdout);
104                  ofp = popen(cmd, "w");
# Line 145 | Line 145 | interp_anisotropic()
145   static void
146   xml_prologue(int ac, char *av[])
147   {
148        static const char       *prologue0[] = {
149 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
150 "<WindowElement xmlns=\"http://windows.lbl.gov\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://windows.lbl.gov/BSDF-v1.4.xsd\">",
151                                NULL};
152        static const char       *prologue1[] = {
153 "<WindowElementType>System</WindowElementType>",
154 "<FileType>BSDF</FileType>",
155 "<Optical>",
156 "<Layer>",
157 "\t<Material>",
158 "\t\t<Name>Name</Name>",
159 "\t\t<Manufacturer>Manufacturer</Manufacturer>",
160 "\t\t<DeviceType>Other</DeviceType>",
161 "\t</Material>",
162                                NULL};
163        static const char       *prologue2[] = {
164 "\t<WavelengthData>",
165 "\t\t<LayerNumber>System</LayerNumber>",
166 "\t\t<Wavelength unit=\"Integral\">Visible</Wavelength>",
167 "\t\t<SourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum>",
168 "\t\t<DetectorSpectrum>ASTM E308 1931 Y.dsp</DetectorSpectrum>",
169 "\t\t<WavelengthDataBlock>",
170 "\t\t\t<AngleBasis>LBNL/Shirley-Chiu</AngleBasis>",
171 "\t\t\t<ScatteringDataType>BTDF</ScatteringDataType>",
172                                NULL};
148          static const char       *bsdf_type[4] = {
149 <                                        "Reflection Back",
175 <                                        "Transmission Back",
149 >                                        "Reflection Front",
150                                          "Transmission Front",
151 <                                        "Reflection Front"
151 >                                        "Transmission Back",
152 >                                        "Reflection Back"
153                                  };
179        int                     i;
154  
155 <        for (i = 0; prologue0[i] != NULL; i++)
156 <                puts(prologue0[i]);
155 >        puts("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
156 >        puts("<WindowElement xmlns=\"http://windows.lbl.gov\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://windows.lbl.gov/BSDF-v1.4.xsd\">");
157          fputs("<!-- File produced by:", stdout);
158          while (ac-- > 0) {
159                  fputc(' ', stdout);
160                  fputs(*av++, stdout);
161          }
162          puts(" -->");
163 <        for (i = 0; prologue1[i] != NULL; i++)
164 <                puts(prologue1[i]);
163 >        puts("<WindowElementType>System</WindowElementType>");
164 >        puts("<FileType>BSDF</FileType>");
165 >        puts("<Optical>");
166 >        puts("<Layer>");
167 >        puts("\t<Material>");
168 >        puts("\t\t<Name>Name</Name>");
169 >        puts("\t\t<Manufacturer>Manufacturer</Manufacturer>");
170 >        puts("\t\t<DeviceType>Other</DeviceType>");
171 >        puts("\t</Material>");
172          puts("\t<DataDefinition>");
173          printf("\t\t<IncidentDataStructure>TensorTree%c</IncidentDataStructure>\n",
174                          single_plane_incident ? '3' : '4');
175          puts("\t</DataDefinition>");
176 <        for (i = 0; prologue2[i] != NULL; i++)
177 <                puts(prologue2[i]);
176 >        puts("\t<WavelengthData>");
177 >        puts("\t\t<LayerNumber>System</LayerNumber>");
178 >        puts("\t\t<Wavelength unit=\"Integral\">Visible</Wavelength>");
179 >        puts("\t\t<SourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum>");
180 >        puts("\t\t<DetectorSpectrum>ASTM E308 1931 Y.dsp</DetectorSpectrum>");
181 >        puts("\t\t<WavelengthDataBlock>");
182          printf("\t\t\t<WavelengthDataDirection>%s</WavelengthDataDirection>\n",
183 <                bsdf_type[(input_orient>0)<<1 | (output_orient>0)]);
183 >                        bsdf_type[(input_orient>0)<<1 | (output_orient>0)]);
184 >        puts("\t\t\t<AngleBasis>LBNL/Shirley-Chiu</AngleBasis>");
185 >        puts("\t\t\t<ScatteringDataType>BTDF</ScatteringDataType>");
186          puts("\t\t\t<ScatteringData>");
187   }
188  
# Line 203 | Line 190 | xml_prologue(int ac, char *av[])
190   static void
191   xml_epilogue(void)
192   {
193 <        static const char       *epilogue[] = {
194 < "\t\t\t</ScatteringData>",
195 < "\t\t</WavelengthDataBlock>",
196 < "\t</WavelengthData>",
197 < "</Layer>",
198 < "</Optical>",
212 < "</WindowElement>",
213 <                                NULL};
214 <        int                     i;
215 <
216 <        for (i = 0; epilogue[i] != NULL; i++)
217 <                puts(epilogue[i]);
193 >        puts("\t\t\t</ScatteringData>");
194 >        puts("\t\t</WavelengthDataBlock>");
195 >        puts("\t</WavelengthData>");
196 >        puts("</Layer>");
197 >        puts("</Optical>");
198 >        puts("</WindowElement>");
199   }
200  
201   /* Read in BSDF and interpolate as tensor tree representation */
# Line 228 | Line 209 | main(int argc, char *argv[])
209          for (i = 1; i < argc-1 && argv[i][0] == '-'; i++)
210                  switch (argv[i][1]) {           /* get option */
211                  case 't':
212 <                        pctcull = atoi(argv[++i]);
212 >                        pctcull = atof(argv[++i]);
213                          break;
214                  case 'g':
215                          samp_order = atoi(argv[++i]);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines