| 24 |  | my $doforw = 0; | 
| 25 |  | my $doback = 1; | 
| 26 |  | my $pctcull = 90; | 
| 27 | < | my $gunit = "Meter"; | 
| 27 | > | my $gunit = "meter"; | 
| 28 |  | my @dim; | 
| 29 |  | # Get options | 
| 30 |  | while ($#ARGV >= 0) { | 
| 108 |  | print "<!-- File produced by: genBSDF @savedARGV -->\n"; | 
| 109 |  | print | 
| 110 |  | '<WindowElementType>System</WindowElementType> | 
| 111 | + | <FileType>BSDF</FileType> | 
| 112 |  | <Optical> | 
| 113 |  | <Layer> | 
| 114 |  | <Material> | 
| 118 |  | printf "\t\t<Thickness unit=\"$gunit\">%.3f</Thickness>\n", $dim[5] - $dim[4]; | 
| 119 |  | printf "\t\t<Width unit=\"$gunit\">%.3f</Width>\n", $dim[1] - $dim[0]; | 
| 120 |  | printf "\t\t<Height unit=\"$gunit\">%.3f</Height>\n", $dim[3] - $dim[2]; | 
| 121 | < | print "\t\t<DeviceType>Integral</DeviceType>\n"; | 
| 121 | > | print "\t\t<DeviceType>Other</DeviceType>\n"; | 
| 122 | > | print " </Material>\n"; | 
| 123 |  | # Output MGF description if requested | 
| 124 |  | if ( $geout ) { | 
| 125 | < | print "\t\t<Geometry format=\"MGF\" unit=\"$gunit\">\n"; | 
| 125 | > | print "\t<Geometry format=\"MGF\">\n"; | 
| 126 | > | print "<MGFblock unit=\"$gunit\">\n"; | 
| 127 |  | printf "xf -t %.6f %.6f 0\n", -($dim[0]+$dim[1])/2, -($dim[2]+$dim[3])/2; | 
| 128 |  | open(MGFSCN, "< $mgfscn"); | 
| 129 |  | while (<MGFSCN>) { print $_; } | 
| 130 |  | close MGFSCN; | 
| 131 |  | print "xf\n"; | 
| 132 | < | print "\t\t</Geometry>\n"; | 
| 132 | > | print "\t\t</MGFblock>\n"; | 
| 133 | > | print "\t</Geometry>\n"; | 
| 134 |  | } | 
| 131 | – | print " </Material>\n"; | 
| 135 |  | # Set up surface sampling | 
| 136 |  | my $nx = int(sqrt($nsamp*($dim[1]-$dim[0])/($dim[3]-$dim[2])) + .5); | 
| 137 |  | my $ny = int($nsamp/$nx + .5); | 
| 200 |  | print "\t\t<IncidentDataStructure>TensorTree$tensortree</IncidentDataStructure>\n"; | 
| 201 |  | print "\t</DataDefinition>\n"; | 
| 202 |  |  | 
| 203 | < | # Start rtcontrib processes for compute each side | 
| 203 | > | # Start rcontrib processes for compute each side | 
| 204 |  | do_tree_rtcontrib(0) if ( $doback ); | 
| 205 |  | do_tree_rtcontrib(1) if ( $doforw ); | 
| 206 |  |  | 
| 207 |  | }       # end of sub do_tree_bsdf() | 
| 208 |  |  | 
| 209 | < | # Run rtcontrib process in background to generate tensor tree samples | 
| 209 | > | # Run rcontrib process to generate tensor tree samples | 
| 210 |  | sub do_tree_rtcontrib { | 
| 211 |  | my $forw = shift; | 
| 212 |  | my $matargs = "-m $bmodnm"; | 
| 213 | < | if ( !$forw || !$doback ) { $matargs .= " -m $fmodnm"; } | 
| 213 | > | if ( !$forw || !$doback || $tensortree==3 ) { $matargs .= " -m $fmodnm"; } | 
| 214 |  | my $cmd = "rcontrib $rtargs -h -ff -fo -n $nproc -c $nsamp " . | 
| 215 |  | "-e '$disk2sq' -bn '$ns*$ns' " . | 
| 216 |  | "-b '$ns*floor(out_square_x*$ns)+floor(out_square_y*$ns)' " . | 
| 248 |  | "| $cmd"; | 
| 249 |  | } | 
| 250 |  | # print STDERR "Starting: $cmd\n"; | 
| 251 | < | system "$cmd" || die "Failure running rtcontrib"; | 
| 251 | > | system "$cmd" || die "Failure running rcontrib"; | 
| 252 |  | ttree_out($forw); | 
| 253 |  | }       # end of do_tree_rtcontrib() | 
| 254 |  |  | 
| 257 |  | my $forw = shift; | 
| 258 |  | my $side = ("Back","Front")[$forw]; | 
| 259 |  | my $cmd; | 
| 260 | < | # Only output one transmitted distribution, preferring backwards | 
| 261 | < | if ( !$forw || !$doback ) { | 
| 260 | > | # Only output one transmitted anisotropic distribution, preferring backwards | 
| 261 | > | if ( !$forw || !$doback || $tensortree==3 ) { | 
| 262 |  | print | 
| 263 |  | '       <WavelengthData> | 
| 264 |  | <LayerNumber>System</LayerNumber> | 
| 266 |  | <SourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum> | 
| 267 |  | <DetectorSpectrum>ASTM E308 1931 Y.dsp</DetectorSpectrum> | 
| 268 |  | <WavelengthDataBlock> | 
| 269 | < | <WavelengthDataDirection>Transmission</WavelengthDataDirection> | 
| 270 | < | <AngleBasis>LBNL/Shirley-Chiu</AngleBasis> | 
| 269 | > | '; | 
| 270 | > | print "\t\t\t<WavelengthDataDirection>Transmission $side</WavelengthDataDirection>\n"; | 
| 271 | > | print | 
| 272 | > | '                       <AngleBasis>LBNL/Shirley-Chiu</AngleBasis> | 
| 273 |  | <ScatteringDataType>BTDF</ScatteringDataType> | 
| 274 |  | <ScatteringData> | 
| 275 |  | '; | 
| 306 |  | print "\t\t\t<WavelengthDataDirection>Reflection $side</WavelengthDataDirection>\n"; | 
| 307 |  | print | 
| 308 |  | '                       <AngleBasis>LBNL/Shirley-Chiu</AngleBasis> | 
| 309 | < | <ScatteringDataType>BRDF</ScatteringDataType> | 
| 309 | > | <ScatteringDataType>BTDF</ScatteringDataType> | 
| 310 |  | <ScatteringData> | 
| 311 |  | '; | 
| 312 |  | $cmd = "rcalc -if3 -e 'Omega:PI/($ns*$ns)' " . | 
| 384 |  | kbin = kbin2(Acos(abs(Dz)),Atan2(Dy,Dx)); | 
| 385 |  | '; | 
| 386 |  | my $ndiv = 145; | 
| 387 | < | # Compute scattering data using rtcontrib | 
| 387 | > | # Compute scattering data using rcontrib | 
| 388 |  | my @tfarr; | 
| 389 |  | my @rfarr; | 
| 390 |  | my @tbarr; | 
| 407 |  | system "$cmd" || die "Failure running: $cmd\n"; | 
| 408 |  | @tfarr = `$rccmd $td/$fmodnm.flt`; | 
| 409 |  | die "Failure running: $rccmd $td/$fmodnm.flt\n" if ( $? ); | 
| 410 | + | chomp(@tfarr); | 
| 411 |  | @rfarr = `$rccmd $td/$bmodnm.flt`; | 
| 412 |  | die "Failure running: $rccmd $td/$bmodnm.flt\n" if ( $? ); | 
| 413 | + | chomp(@rfarr); | 
| 414 |  | } | 
| 415 |  | if ( $doback ) { | 
| 416 |  | $cmd = "cnt $ndiv $ny $nx | rcalc -of -e '$tcal' " . | 
| 543 |  | <WavelengthDataDirection>Reflection Front</WavelengthDataDirection> | 
| 544 |  | <ColumnAngleBasis>LBNL/Klems Full</ColumnAngleBasis> | 
| 545 |  | <RowAngleBasis>LBNL/Klems Full</RowAngleBasis> | 
| 546 | < | <ScatteringDataType>BRDF</ScatteringDataType> | 
| 546 | > | <ScatteringDataType>BTDF</ScatteringDataType> | 
| 547 |  | <ScatteringData> | 
| 548 |  | '; | 
| 549 |  | # Output front reflection (transposed order) | 
| 593 |  | <WavelengthDataDirection>Reflection Back</WavelengthDataDirection> | 
| 594 |  | <ColumnAngleBasis>LBNL/Klems Full</ColumnAngleBasis> | 
| 595 |  | <RowAngleBasis>LBNL/Klems Full</RowAngleBasis> | 
| 596 | < | <ScatteringDataType>BRDF</ScatteringDataType> | 
| 596 | > | <ScatteringDataType>BTDF</ScatteringDataType> | 
| 597 |  | <ScatteringData> | 
| 598 |  | '; | 
| 599 |  | # Output back reflection (transposed order) |