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.69 by greg, Fri Sep 16 22:42:42 2016 UTC vs.
Revision 2.70 by greg, Mon Sep 19 16:20:08 2016 UTC

# Line 275 | Line 275 | exec $rmtmp;
275   # Function to determine if next phase should be skipped or recovered
276   sub do_phase {
277          $curphase++;
278 <        if (defined $recovery) {
279 <                if ($recovery > $curphase) { return 0; }
280 <                if ($recovery == $curphase) { return -1; }
278 >        if ( defined $recovery ) {
279 >                if ( $recovery > $curphase ) { return 0; }
280 >                if ( $recovery == $curphase ) { return -1; }
281          }
282          print MYPH "$curphase\n";
283          return 1;
284   }
285  
286 + # Check if we are in active phase (not skipping parts)
287 + sub active_phase {
288 +        if ( defined $recovery ) {
289 +                if ( $recovery > $curphase ) { return 0; }
290 +                if ( $recovery == $curphase ) { return -1; }
291 +        }
292 +        return 1;
293 + }
294 +
295 + # Function to run program and check output if in active phase
296 + sub run_check {
297 +        if ( !active_phase() ) { return; }
298 +        my $cmd = shift;
299 +        # print STDERR "Running: $cmd\n";
300 +        system $cmd;
301 +        die "Failure running: $cmd\n" if ( $? );
302 + }
303 +
304   #++++++++++++++ Tensor tree BSDF generation ++++++++++++++#
305   sub do_tree_bsdf {
306  
# Line 295 | Line 313 | sub do_tree_bsdf {
313   # Call rfluxmtx and process tensor tree BSDF for the given direction
314   sub do_ttree_dir {
315          my $forw = shift;
316 <        my $r = do_phase();
317 <        if (!$r) { return; }
300 <        $r = ($r < 0) ? " -r" : "";
316 >        my $dop = do_phase();
317 >        my $r = ($dop < 0) ? " -r" : "";
318          my $cmd;
319          if ( $tensortree == 3 ) {
320                  # Isotropic BSDF
# Line 336 | Line 353 | sub do_ttree_dir {
353                          $cmd = "$rfluxmtx$r -h -ff $sender $receivers -i $octree";
354                  }
355          }
356 <        # print STDERR "Starting: $cmd\n";
340 <        system $cmd;
341 <        die "Failure running rfluxmtx" if ( $? );
356 >        run_check $cmd;
357          ttree_out($forw);
358   }       # end of do_ttree_dir()
359  
# Line 421 | Line 436 | sub ttree_comp {
436                          $cmd .= " -of $src " .
437                                          "| rttree_reduce$avg -h -ff -t $pcull -r $tensortree -g $ttlog2";
438                  }
439 <                # print STDERR "Running: $cmd\n";
425 <                system "$cmd > $dest";
426 <                die "Failure running rttree_reduce" if ( $? );
439 >                run_check "$cmd > $dest";
440          } else {
441                  if ($windoz) {
442                          $cmd = "rcollate -ho -oc 1 $src | " . $cmd ;
443                  } else {
444                          $cmd .= " $src";
445                  }
446 <                open(DATOUT, "> $dest");
447 <                print DATOUT "{\n";
448 <                close DATOUT;
449 <                # print STDERR "Running: $cmd\n";
450 <                system "$cmd >> $dest";
451 <                die "Failure running rcalc" if ( $? );
452 <                open(DATOUT, ">> $dest");
453 <                for (my $i = ($tensortree==3)*$ns*$ns*$ns/2; $i-- > 0; ) {
454 <                        print DATOUT "0\n";
446 >                if ( active_phase() ) {
447 >                        open(DATOUT, "> $dest");
448 >                        print DATOUT "{\n";
449 >                        close DATOUT;
450 >                        # print STDERR "Running: $cmd\n";
451 >                        system "$cmd >> $dest";
452 >                        die "Failure running rcalc" if ( $? );
453 >                        open(DATOUT, ">> $dest");
454 >                        for (my $i = ($tensortree==3)*$ns*$ns*$ns/2; $i-- > 0; ) {
455 >                                print DATOUT "0\n";
456 >                        }
457 >                        print DATOUT "}\n";
458 >                        close DATOUT;
459                  }
443                print DATOUT "}\n";
444                close DATOUT;
460          }
461          if ( "$spec" ne "$curspec" ) {
462                  $wrapper .= " -s $spec";
# Line 464 | Line 479 | sub do_matrix_bsdf {
479   # Call rfluxmtx and process tensor tree BSDF for the given direction
480   sub do_matrix_dir {
481          my $forw = shift;
482 <        my $r = do_phase();
483 <        if (!$r) { return; }
469 <        $r = ($r < 0) ? " -r" : "";
470 <        my $cmd;
482 >        my $dop = do_phase();
483 >        my $r = ($dop < 0) ? " -r" : "";
484          my $sender = ($bsender,$fsender)[$forw];
485 <        $cmd = "$rfluxmtx$r -fd $sender $receivers -i $octree";
473 <        # print STDERR "Starting: $cmd\n";
474 <        system $cmd;
475 <        die "Failure running rfluxmtx" if ( $? );
485 >        run_check "$rfluxmtx$r -fd $sender $receivers -i $octree";
486          matrix_out($forw);
487   }       # end of do_matrix_dir()
488  
# Line 517 | Line 527 | sub matrix_comp {
527                  $cmd .= " -c 0.0241 0.1229 0.8530";
528          }
529          $cmd .= " $src | rcollate -ho -oc 145";
530 <        # print STDERR "Running: $cmd\n";
521 <        system "$cmd > $dest";
522 <        die "Failure running rmtxop" if ( $? );
530 >        run_check "$cmd > $dest";
531          if ( "$spec" ne "$curspec" ) {
532                  $wrapper .= " -s $spec";
533                  $curspec = $spec;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines