ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/genBSDF.pl
(Generate patch)

Comparing ray/src/util/genBSDF.pl (file contents):
Revision 2.2 by greg, Fri Sep 3 23:53:50 2010 UTC vs.
Revision 2.3 by greg, Thu Sep 9 06:02:16 2010 UTC

# Line 7 | Line 7
7   #
8   use strict;
9   sub userror {
10 <        print STDERR "Usage: genBSDF [-n Nproc][-c Nsamp][-dim xmin xmax ymin ymax zmin zmax][{+|-}mgf][{+|-}geom] [input ..]";
10 >        print STDERR "Usage: genBSDF [-n Nproc][-c Nsamp][-dim xmin xmax ymin ymax zmin zmax][{+|-}mgf][{+|-}geom] [input ..]\n";
11          exit 1;
12   }
13   my $td = `mktemp -d /tmp/genBSDF.XXXXXX`;
# Line 121 | Line 121 | my $ndiv = 145;
121   my $nx = int(sqrt($nsamp*($dim[1]-$dim[0])/($dim[3]-$dim[2])) + .5);
122   my $ny = int($nsamp/$nx + .5);
123   $nsamp = $nx * $ny;
124 + # Compute scattering data using rtcontrib
125 + my $cmd = "cnt $ndiv $ny $nx | rcalc -of -e '$tcal' " .
126 +        "-e 'xp=(\$3+rand(.35*recno-15))*(($dim[1]-$dim[0])/$nx)+$dim[0]' " .
127 +        "-e 'yp=(\$2+rand(.86*recno+11))*(($dim[3]-$dim[2])/$ny)+$dim[2]' " .
128 +        "-e 'zp:$dim[4]-1e-5' " .
129 +        q{-e 'Kbin=$1;x1=rand(1.21*recno+2.75);x2=rand(-3.55*recno-7.57)' } .
130 +        q{-e '$1=xp;$2=yp;$3=zp;$4=Dx;$5=Dy;$6=Dz' } .
131 +        "| rtcontrib -h -ff -n $nproc -c $nsamp -e '$kcal' -b kbin -bn $ndiv " .
132 +        "-m $modnm -w -ab 5 -ad 700 -lw 3e-6 $octree " .
133 +        "| rcalc -e 'x1:.5;x2:.5;$tcal' -e 'Kbin=floor((recno-1)/$ndiv)' " .
134 +        q{-if3 -e '$1=(0.265*$1+0.670*$2+0.065*$3)/(Komega*Dz)'};
135 + my @darr = `$cmd`;
136 + die "Failure running: $cmd\n" if ( $? );
137   # Output XML prologue
138   print
139   '<?xml version="1.0" encoding="UTF-8"?>
# Line 235 | Line 248 | print '                        </Material>
248                          <ScatteringDataType>BTDF</ScatteringDataType>
249                          <ScatteringData>
250   ';
251 < # Compute actual scattering data using rtcontrib
252 < system "cnt $ndiv $ny $nx | rcalc -of -e '$tcal' " .
253 <        "-e 'xp=(\$3+rand(.35*recno-15))*(($dim[1]-$dim[0])/$nx)+$dim[0]' " .
254 <        "-e 'yp=(\$2+rand(.86*recno+11))*(($dim[3]-$dim[2])/$ny)+$dim[2]' " .
255 <        "-e 'zp:$dim[4]-1e-5' " .
256 <        q{-e 'Kbin=$1;x1=rand(1.21*recno+2.75);x2=rand(-3.55*recno-7.57)' } .
257 <        q{-e '$1=xp;$2=yp;$3=zp;$4=Dx;$5=Dy;$6=Dz' } .
245 <        "| rtcontrib -h -ff -n $nproc -c $nsamp -e '$kcal' -b kbin -bn $ndiv " .
246 <        "-m $modnm -w -ab 5 -ad 700 -lw 3e-6 $octree " .
247 <        "| rcalc -e 'x1:.5;x2:.5;$tcal' -e 'Kbin=floor((recno-1)/$ndiv)' " .
248 <        q{-if3 -e '$1=(0.265*$1+0.670*$2+0.065*$3)/(Komega*Dz)'};
251 > # Output computed data (transposed order)
252 > for (my $od = 0; $od < $ndiv; $od++) {
253 >        for (my $id = 0; $id < $ndiv; $id++) {
254 >                print $darr[$ndiv*$id + $od];
255 >        }
256 >        print "\n";
257 > }
258   # Output XML epilogue
259   print
260   '               </ScatteringData>

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines