13 |
|
} |
14 |
|
my $td = mkdtemp("/tmp/genBSDF.XXXXXX"); |
15 |
|
chomp $td; |
16 |
+ |
my @savedARGV = @ARGV; |
17 |
|
my $tensortree = 0; |
18 |
|
my $ttlog2 = 4; |
19 |
|
my $nsamp = 1000; |
99 |
|
print |
100 |
|
'<?xml version="1.0" encoding="UTF-8"?> |
101 |
|
<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"> |
102 |
< |
<WindowElementType>System</WindowElementType> |
102 |
> |
'; |
103 |
> |
print "<!-- File produced by: genBSDF @savedARGV -->\n"; |
104 |
> |
print |
105 |
> |
'<WindowElementType>System</WindowElementType> |
106 |
|
<Optical> |
107 |
|
<Layer> |
108 |
|
<Material> |
143 |
|
</WindowElement> |
144 |
|
'; |
145 |
|
# Clean up temporary files and exit |
146 |
< |
if ( $persistfile ) { |
143 |
< |
open(PFI, "< $persistfile"); |
146 |
> |
if ( $persistfile && open(PFI, "< $persistfile") ) { |
147 |
|
while (<PFI>) { |
148 |
|
s/^[^ ]* //; |
149 |
|
kill('ALRM', $_); |
151 |
|
} |
152 |
|
close PFI; |
153 |
|
} |
154 |
< |
system "rm -rf $td"; |
155 |
< |
exit 0; |
154 |
> |
exec("rm -rf $td"); |
155 |
> |
|
156 |
|
#-------------- End of main program segment --------------# |
157 |
|
|
158 |
|
#++++++++++++++ Tensor tree BSDF generation ++++++++++++++# |
207 |
|
out_square_y = (out_square_b + 1)/2; |
208 |
|
'; |
209 |
|
# Announce ourselves in XML output |
210 |
< |
print " <DataDefinition>\n"; |
211 |
< |
print " <IncidentDataStructure>TensorTree$tensortree</IncidentDataStructure>\n"; |
212 |
< |
print " </DataDefinition>\n"; |
210 |
> |
print "\t<DataDefinition>\n"; |
211 |
> |
print "\t\t<IncidentDataStructure>TensorTree$tensortree</IncidentDataStructure>\n"; |
212 |
> |
print "\t</DataDefinition>\n"; |
213 |
|
# Fork parallel rtcontrib processes to compute each side |
214 |
|
if ( $doback ) { |
215 |
|
for (my $proc = 0; $proc < $nproc; $proc++) { |
252 |
|
"| rcalc -e 'r1=rand(($pn+.8681)*recno-.673892)' " . |
253 |
|
"-e 'r2=rand(($pn-5.37138)*recno+67.1737811)' " . |
254 |
|
"-e 'r3=rand(($pn+3.17603772)*recno+83.766771)' " . |
255 |
< |
"-e 'Dx=1-($pbeg+\$1+r1)/$ns;Dy:0;Dz=sqrt(1-Dx*Dx)' " . |
255 |
> |
"-e 'Dx=1-2*($pbeg+\$1+r1)/$ns;Dy:0;Dz=sqrt(1-Dx*Dx)' " . |
256 |
|
"-e 'xp=(\$3+r2)*(($dim[1]-$dim[0])/$nx)+$dim[0]' " . |
257 |
|
"-e 'yp=(\$2+r3)*(($dim[3]-$dim[2])/$ny)+$dim[2]' " . |
258 |
|
"-e 'zp=$dim[5-$forw]' -e 'myDz=Dz*($forw*2-1)' " . |
319 |
|
<SourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum> |
320 |
|
<DetectorSpectrum>ASTM E308 1931 Y.dsp</DetectorSpectrum> |
321 |
|
<WavelengthDataBlock> |
322 |
< |
<WavelengthDataDirection>Reflection $side</WavelengthDataDirection> |
323 |
< |
<AngleBasis>LBNL/Shirley-Chiu</AngleBasis> |
322 |
> |
'; |
323 |
> |
print "\t\t\t<WavelengthDataDirection>Reflection $side</WavelengthDataDirection>\n"; |
324 |
> |
print |
325 |
> |
' <AngleBasis>LBNL/Shirley-Chiu</AngleBasis> |
326 |
|
<ScatteringDataType>BRDF</ScatteringDataType> |
327 |
|
<ScatteringData> |
328 |
|
'; |
402 |
|
"-o '$td/%s.flt' -m $fmodnm -m $bmodnm $octree"; |
403 |
|
my $rccmd = "rcalc -e '$tcal' " . |
404 |
|
"-e 'mod(n,d):n-floor(n/d)*d' -e 'Kbin=mod(recno-.999,$ndiv)' " . |
405 |
< |
q{-if3 -e '$1=(0.265*$1+0.670*$2+0.065*$3)/KprojOmega'}; |
405 |
> |
q{-if3 -e 'oval=(0.265*$1+0.670*$2+0.065*$3)/KprojOmega' } . |
406 |
> |
q[-o '${ oval },']; |
407 |
|
if ( $doforw ) { |
408 |
|
$cmd = "cnt $ndiv $ny $nx | rcalc -of -e '$tcal' " . |
409 |
|
"-e 'xp=(\$3+rand(.12*recno+288))*(($dim[1]-$dim[0])/$nx)+$dim[0]' " . |