13 |
|
exit 1; |
14 |
|
} |
15 |
|
my ($td,$radscn,$mgfscn,$octree,$fsender,$bsender,$receivers,$facedat,$behinddat,$rmtmp); |
16 |
< |
my ($tf,$rf,$tb,$rb,$tfx,$rfx,$tbx,$rbx,$tfz,$rfz,$tbz,$rbz,$cph,$sav); |
16 |
> |
my ($tf,$rf,$tb,$rb,$tfx,$rfx,$tbx,$rbx,$tfz,$rfz,$tbz,$rbz,$cph); |
17 |
|
my ($curphase, $recovery); |
18 |
|
if ($#ARGV == 1 && "$ARGV[0]" =~ /^-rec/) { |
19 |
|
$td = $ARGV[1]; |
155 |
|
die "Must have at least one of +forward or +backward\n" if (!$doforw && !$doback); |
156 |
|
$wrapper .= $tensortree ? " -a t$tensortree" : " -a kf -c"; |
157 |
|
$wrapper .= " -u $gunit"; |
158 |
< |
if (!defined $recovery) { |
158 |
> |
if ( !defined $recovery ) { |
159 |
|
# Issue warning for unhandled reciprocity case |
160 |
|
print STDERR "Warning: recommend both +forward and +backward with -t3\n" if |
161 |
|
($tensortree==3 && !($doforw && $doback)); |
162 |
< |
# Get scene description and dimensions |
162 |
> |
# Get scene description |
163 |
|
if ( $mgfin ) { |
164 |
|
system "mgf2rad @ARGV > $radscn"; |
165 |
|
die "Could not load MGF input\n" if ( $? ); |
168 |
|
die "Could not load Radiance input\n" if ( $? ); |
169 |
|
} |
170 |
|
} |
171 |
< |
if ($#dim != 5) { |
171 |
> |
if ( $#dim != 5 ) { |
172 |
|
@dim = split ' ', `getbbox -h $radscn`; |
173 |
|
} |
174 |
< |
die "Device entirely inside room!\n" if ($dim[4] >= 0); |
175 |
< |
if ($dim[5] > 1e-5) { |
174 |
> |
die "Device entirely inside room!\n" if ( $dim[4] >= 0 ); |
175 |
> |
if ( $dim[5] > 1e-5 ) { |
176 |
|
print STDERR "Warning: Device extends into room\n"; |
177 |
< |
} elsif ($dim[5]*$dim[5] > .01*($dim[1]-$dim[0])*($dim[3]-$dim[2])) { |
177 |
> |
} elsif ( $dim[5]*$dim[5] > .01*($dim[1]-$dim[0])*($dim[3]-$dim[2]) ) { |
178 |
|
print STDERR "Warning: Device far behind Z==0 plane\n"; |
179 |
|
} |
180 |
|
# Assume Zmax==0 to derive thickness so pkgBSDF will work |
181 |
|
$wrapper .= ' -f "t=' . (-$dim[4]) . ';w=' . ($dim[1] - $dim[0]) . |
182 |
|
';h=' . ($dim[3] - $dim[2]) . '"'; |
183 |
+ |
$wrapper .= " -g $mgfscn" if ( $geout ); |
184 |
|
# Calculate CIE (u',v') from Radiance RGB: |
185 |
|
my $CIEuv = 'Xi=.5141*Ri+.3239*Gi+.1620*Bi;' . |
186 |
|
'Yi=.2651*Ri+.6701*Gi+.0648*Bi;' . |
193 |
|
my $ny = int($nsamp/$nx + 1); |
194 |
|
$nsamp = $nx * $ny; |
195 |
|
$rfluxmtx .= " -n $nproc -c $nsamp"; |
196 |
< |
if (!defined $recovery) { |
196 |
> |
if ( !defined $recovery ) { |
197 |
|
open(MYAVH, "> $td/savedARGV.txt"); |
198 |
|
foreach (@savedARGV) { |
199 |
|
print MYAVH "$_\n"; |
215 |
|
open(MGFSCN, ">> $mgfscn"); |
216 |
|
print MGFSCN "xf\n"; |
217 |
|
close MGFSCN; |
217 |
– |
$wrapper .= " -g $mgfscn"; |
218 |
|
} |
219 |
|
# Create receiver & sender surfaces (rectangular) |
220 |
|
open(RADSCN, "> $receivers"); |
248 |
|
} |
249 |
|
print STDERR "Recover using: $0 -recover $td\n"; |
250 |
|
} |
251 |
+ |
# Open unbuffered progress file |
252 |
|
open(MYPH, ">> $td/phase.txt"); |
253 |
< |
{ # unbuffer output to MYPH |
253 |
> |
{ |
254 |
|
my $ofh = select MYPH; |
255 |
|
$| = 1; |
256 |
|
select $ofh; |
257 |
|
} |
258 |
|
$curphase = 0; |
258 |
– |
# Function to determine if next phase should be skipped or recovered |
259 |
– |
sub do_phase { |
260 |
– |
$curphase++; |
261 |
– |
if (defined $recovery) { |
262 |
– |
if ($recovery == $curphase) { return -1; } |
263 |
– |
if ($recovery > $curphase) { return 0; } |
264 |
– |
} |
265 |
– |
print MYPH "$curphase\n"; |
266 |
– |
return 1; |
267 |
– |
} |
259 |
|
# Create data segments (all the work happens here) |
260 |
|
if ( $tensortree ) { |
261 |
|
do_tree_bsdf(); |
263 |
|
do_matrix_bsdf(); |
264 |
|
} |
265 |
|
# Output XML |
266 |
< |
print STDERR "Running: $wrapper\n"; |
266 |
> |
# print STDERR "Running: $wrapper\n"; |
267 |
|
system "$wrapper -C \"Created by: genBSDF @savedARGV\""; |
268 |
|
die "Could not wrap BSDF data\n" if ( $? ); |
269 |
|
# Clean up temporary files and exit |
270 |
|
exec $rmtmp; |
271 |
|
|
272 |
< |
#-------------- End of main program segment --------------# |
272 |
> |
#============== End of main program segment ==============# |
273 |
|
|
274 |
+ |
# Function to determine if next phase should be skipped or recovered |
275 |
+ |
sub do_phase { |
276 |
+ |
$curphase++; |
277 |
+ |
if (defined $recovery) { |
278 |
+ |
if ($recovery > $curphase) { return 0; } |
279 |
+ |
if ($recovery == $curphase) { return -1; } |
280 |
+ |
} |
281 |
+ |
print MYPH "$curphase\n"; |
282 |
+ |
return 1; |
283 |
+ |
} |
284 |
+ |
|
285 |
|
#++++++++++++++ Tensor tree BSDF generation ++++++++++++++# |
286 |
|
sub do_tree_bsdf { |
287 |
|
|
335 |
|
$cmd = "$rfluxmtx$r -h -ff $sender $receivers -i $octree"; |
336 |
|
} |
337 |
|
} |
338 |
< |
print STDERR "Starting: $cmd\n"; |
338 |
> |
# print STDERR "Starting: $cmd\n"; |
339 |
|
system $cmd; |
340 |
|
die "Failure running rfluxmtx" if ( $? ); |
341 |
|
ttree_out($forw); |
420 |
|
$cmd .= " -of $src " . |
421 |
|
"| rttree_reduce$avg -h -ff -t $pcull -r $tensortree -g $ttlog2"; |
422 |
|
} |
423 |
< |
print STDERR "Running: $cmd\n"; |
423 |
> |
# print STDERR "Running: $cmd\n"; |
424 |
|
system "$cmd > $dest"; |
425 |
|
die "Failure running rttree_reduce" if ( $? ); |
426 |
|
} else { |
432 |
|
open(DATOUT, "> $dest"); |
433 |
|
print DATOUT "{\n"; |
434 |
|
close DATOUT; |
435 |
< |
print STDERR "Running: $cmd\n"; |
435 |
> |
# print STDERR "Running: $cmd\n"; |
436 |
|
system "$cmd >> $dest"; |
437 |
|
die "Failure running rcalc" if ( $? ); |
438 |
|
open(DATOUT, ">> $dest"); |
469 |
|
my $cmd; |
470 |
|
my $sender = ($bsender,$fsender)[$forw]; |
471 |
|
$cmd = "$rfluxmtx$r -fd $sender $receivers -i $octree"; |
472 |
< |
print STDERR "Starting: $cmd\n"; |
472 |
> |
# print STDERR "Starting: $cmd\n"; |
473 |
|
system $cmd; |
474 |
|
die "Failure running rfluxmtx" if ( $? ); |
475 |
|
matrix_out($forw); |
516 |
|
$cmd .= " -c 0.0241 0.1229 0.8530"; |
517 |
|
} |
518 |
|
$cmd .= " $src | rcollate -ho -oc 145"; |
519 |
< |
print STDERR "Running: $cmd\n"; |
519 |
> |
# print STDERR "Running: $cmd\n"; |
520 |
|
system "$cmd > $dest"; |
521 |
|
die "Failure running rmtxop" if ( $? ); |
522 |
|
if ( "$spec" ne "$curspec" ) { |