| 8 |
|
use strict; |
| 9 |
|
use File::Temp qw/ :mktemp /; |
| 10 |
|
sub userror { |
| 11 |
< |
print STDERR "Usage: genBSDF [-n Nproc][-c Nsamp][-t{3|4} Nlog2][-r \"ropts\"][-dim xmin xmax ymin ymax zmin zmax][{+|-}f][{+|-}b][{+|-}mgf][{+|-}geom] [input ..]\n"; |
| 11 |
> |
print STDERR "Usage: genBSDF [-n Nproc][-c Nsamp][-t{3|4} Nlog2][-r \"ropts\"][-dim xmin xmax ymin ymax zmin zmax][{+|-}f][{+|-}b][{+|-}mgf][{+|-}geom units] [input ..]\n"; |
| 12 |
|
exit 1; |
| 13 |
|
} |
| 14 |
|
my $td = mkdtemp("/tmp/genBSDF.XXXXXX"); |
| 23 |
|
my $nproc = 1; |
| 24 |
|
my $doforw = 0; |
| 25 |
|
my $doback = 1; |
| 26 |
+ |
my $pctcull = 95; |
| 27 |
|
my $gunit = "Meter"; |
| 28 |
|
my @dim; |
| 29 |
|
# Get options |
| 44 |
|
$doforw = ("$ARGV[0]" =~ /^\+/); |
| 45 |
|
} elsif ("$ARGV[0]" =~ /^[-+]b/) { |
| 46 |
|
$doback = ("$ARGV[0]" =~ /^\+/); |
| 47 |
+ |
} elsif ("$ARGV[0]" eq "-t") { |
| 48 |
+ |
$pctcull = $ARGV[1]; |
| 49 |
+ |
shift @ARGV; |
| 50 |
|
} elsif ("$ARGV[0]" =~ /^-t[34]$/) { |
| 51 |
|
$tensortree = substr($ARGV[0], 2, 1); |
| 52 |
|
$ttlog2 = $ARGV[1]; |
| 338 |
|
system "rcalc -if3 -e 'Omega:PI/($ns*$ns)' " . |
| 339 |
|
q{-e '$1=(0.265*$1+0.670*$2+0.065*$3)/Omega' -of } . |
| 340 |
|
"$td/" . ($bmodnm,$fmodnm)[$forw] . "_???.flt " . |
| 341 |
< |
"| rttree_reduce -h -ff -r $tensortree -g $ttlog2"; |
| 341 |
> |
"| rttree_reduce -a -h -ff -t $pctcull -r $tensortree -g $ttlog2"; |
| 342 |
|
die "Failure running rttree_reduce" if ( $? ); |
| 343 |
|
print |
| 344 |
|
' </ScatteringData> |
| 364 |
|
system "rcalc -if3 -e 'Omega:PI/($ns*$ns)' " . |
| 365 |
|
q{-e '$1=(0.265*$1+0.670*$2+0.065*$3)/Omega' -of } . |
| 366 |
|
"$td/" . ($fmodnm,$bmodnm)[$forw] . "_???.flt " . |
| 367 |
< |
"| rttree_reduce -h -ff -r $tensortree -g $ttlog2"; |
| 367 |
> |
"| rttree_reduce -a -h -ff -t $pctcull -r $tensortree -g $ttlog2"; |
| 368 |
|
die "Failure running rttree_reduce" if ( $? ); |
| 369 |
|
print |
| 370 |
|
' </ScatteringData> |
| 437 |
|
"-o '$td/%s.flt' -m $fmodnm -m $bmodnm $octree"; |
| 438 |
|
my $rccmd = "rcalc -e '$tcal' " . |
| 439 |
|
"-e 'mod(n,d):n-floor(n/d)*d' -e 'Kbin=mod(recno-.999,$ndiv)' " . |
| 440 |
< |
q{-if3 -e 'oval=(0.265*$1+0.670*$2+0.065*$3)/KprojOmega' } . |
| 437 |
< |
q[-o '${ oval },']; |
| 440 |
> |
q{-if3 -e '$1=(0.265*$1+0.670*$2+0.065*$3)/KprojOmega' }; |
| 441 |
|
if ( $doforw ) { |
| 442 |
|
$cmd = "cnt $ndiv $ny $nx | rcalc -of -e '$tcal' " . |
| 443 |
|
"-e 'xp=(\$3+rand(.12*recno+288))*(($dim[1]-$dim[0])/$nx)+$dim[0]' " . |
| 564 |
|
# Output front transmission (transposed order) |
| 565 |
|
for (my $od = 0; $od < $ndiv; $od++) { |
| 566 |
|
for (my $id = 0; $id < $ndiv; $id++) { |
| 567 |
< |
print $tfarr[$ndiv*$id + $od]; |
| 567 |
> |
print $tfarr[$ndiv*$id + $od], ",\n"; |
| 568 |
|
} |
| 569 |
|
print "\n"; |
| 570 |
|
} |
| 584 |
|
<ScatteringDataType>BRDF</ScatteringDataType> |
| 585 |
|
<ScatteringData> |
| 586 |
|
'; |
| 587 |
< |
# Output front reflection (transposed order) |
| 587 |
> |
# Output front reflection (reciprocity averaging) |
| 588 |
|
for (my $od = 0; $od < $ndiv; $od++) { |
| 589 |
|
for (my $id = 0; $id < $ndiv; $id++) { |
| 590 |
< |
print $rfarr[$ndiv*$id + $od]; |
| 590 |
> |
print .5*($rfarr[$ndiv*$id + $od] + $rfarr[$ndiv*$od + $id]), ",\n"; |
| 591 |
|
} |
| 592 |
|
print "\n"; |
| 593 |
|
} |
| 614 |
|
# Output back transmission (transposed order) |
| 615 |
|
for (my $od = 0; $od < $ndiv; $od++) { |
| 616 |
|
for (my $id = 0; $id < $ndiv; $id++) { |
| 617 |
< |
print $tbarr[$ndiv*$id + $od]; |
| 617 |
> |
print $tbarr[$ndiv*$id + $od], ",\n"; |
| 618 |
|
} |
| 619 |
|
print "\n"; |
| 620 |
|
} |
| 634 |
|
<ScatteringDataType>BRDF</ScatteringDataType> |
| 635 |
|
<ScatteringData> |
| 636 |
|
'; |
| 637 |
< |
# Output back reflection (transposed order) |
| 637 |
> |
# Output back reflection (reciprocity averaging) |
| 638 |
|
for (my $od = 0; $od < $ndiv; $od++) { |
| 639 |
|
for (my $id = 0; $id < $ndiv; $id++) { |
| 640 |
< |
print $rbarr[$ndiv*$id + $od]; |
| 640 |
> |
print .5*($rbarr[$ndiv*$id + $od] + $rbarr[$ndiv*$od + $id]), ",\n"; |
| 641 |
|
} |
| 642 |
|
print "\n"; |
| 643 |
|
} |