| 1 |
greg |
2.1 |
#!/usr/bin/perl -w
|
| 2 |
greg |
2.3 |
# RCSid $Id: rtpict.pl,v 2.2 2018/03/20 01:38:27 greg Exp $
|
| 3 |
greg |
2.1 |
#
|
| 4 |
|
|
# Run rtrace in parallel mode to simulate rpict -n option
|
| 5 |
|
|
#
|
| 6 |
|
|
# G. Ward
|
| 7 |
|
|
#
|
| 8 |
|
|
use strict;
|
| 9 |
|
|
# we'll call rpict if this is not overridden
|
| 10 |
|
|
my $nprocs = 1;
|
| 11 |
|
|
# rtrace options and the associated number of arguments
|
| 12 |
|
|
my %rtraceC = ("-dt",1, "-dc",1, "-dj",1, "-ds",1, "-dr",1, "-dp",1,
|
| 13 |
|
|
"-ss",1, "-st",1, "-e",1, "-am",1,
|
| 14 |
|
|
"-ab",1, "-af",1, "-ai",1, "-aI",1, "-ae",1, "-aE",1,
|
| 15 |
|
|
"-av",3, "-aw",1, "-aa",1, "-ar",1, "-ad",1, "-as",1,
|
| 16 |
|
|
"-me",3, "-ma",3, "-mg",1, "-ms",1, "-lr",1, "-lw",1);
|
| 17 |
|
|
# boolean rtrace options
|
| 18 |
|
|
my @boolO = ("-w", "-bv", "-dv", "-i", "-u");
|
| 19 |
|
|
# view options and the associated number of arguments
|
| 20 |
greg |
2.2 |
my %vwraysC = ("-vf",1, "-vtv",0, "-vtl",0, "-vth",0, "-vta",0, "-vts",0, "-vtc",0,
|
| 21 |
greg |
2.1 |
"-x",1, "-y",1, "-vp",3, "-vd",3, "-vu",3, "-vh",1, "-vv",1,
|
| 22 |
greg |
2.2 |
"-vo",1, "-va",1, "-vs",1, "-vl",1, "-pa",1, "-pj",1, "-pd",1);
|
| 23 |
|
|
# options we need to silently ignore
|
| 24 |
|
|
my %ignoreC = ("-t",1, "-ps",1, "-pt",1, "-pm",1);
|
| 25 |
greg |
2.1 |
# Starting options for rtrace (rpict values)
|
| 26 |
|
|
my @rtraceA = split(' ', "rtrace -ffc -u- -dt .05 -dc .5 -ds .25 -dr 1 -aa .2 -ar 64 -ad 512 -as 128 -lr 7 -lw 1e-03");
|
| 27 |
|
|
my @vwraysA = ("vwrays", "-ff", "-pj", ".67");
|
| 28 |
|
|
my @vwrightA = ("vwright", "-vtv");
|
| 29 |
|
|
my @rpictA = ("rpict");
|
| 30 |
|
|
my $outpic;
|
| 31 |
|
|
OPTION: # sort through options
|
| 32 |
|
|
while ($#ARGV >= 0 && "$ARGV[0]" =~ /^[-\@]/) {
|
| 33 |
|
|
# Check for file inclusion
|
| 34 |
|
|
if ("$ARGV[0]" =~ /^\@/) {
|
| 35 |
greg |
2.2 |
open my $handle, '<', substr($ARGV[0], 1);
|
| 36 |
greg |
2.1 |
shift @ARGV;
|
| 37 |
|
|
chomp(my @args = <$handle>);
|
| 38 |
|
|
close $handle;
|
| 39 |
|
|
unshift @ARGV, split(/\s+/, "@args");
|
| 40 |
|
|
next OPTION;
|
| 41 |
|
|
}
|
| 42 |
|
|
# Check booleans
|
| 43 |
|
|
for my $boopt (@boolO) {
|
| 44 |
greg |
2.2 |
if ("$ARGV[0]" =~ ('^' . $boopt . '[-+01tfynTFYN]$')) {
|
| 45 |
|
|
push @rtraceA, $ARGV[0];
|
| 46 |
greg |
2.1 |
push @rpictA, shift(@ARGV);
|
| 47 |
|
|
next OPTION;
|
| 48 |
|
|
}
|
| 49 |
|
|
}
|
| 50 |
|
|
# Check view options
|
| 51 |
|
|
if (defined $vwraysC{$ARGV[0]}) {
|
| 52 |
greg |
2.2 |
push @vwraysA, $ARGV[0];
|
| 53 |
greg |
2.1 |
my $isvopt = ("$ARGV[0]" =~ /^-v/);
|
| 54 |
greg |
2.2 |
push(@vwrightA, $ARGV[0]) if ($isvopt);
|
| 55 |
greg |
2.1 |
push @rpictA, shift(@ARGV);
|
| 56 |
greg |
2.2 |
for (my $i = $vwraysC{$rpictA[-1]}; $i-- > 0; ) {
|
| 57 |
|
|
push @vwraysA, $ARGV[0];
|
| 58 |
|
|
push(@vwrightA, $ARGV[0]) if ($isvopt);
|
| 59 |
greg |
2.1 |
push @rpictA, shift(@ARGV);
|
| 60 |
|
|
}
|
| 61 |
|
|
next OPTION;
|
| 62 |
|
|
}
|
| 63 |
|
|
# Check rtrace options
|
| 64 |
|
|
if (defined $rtraceC{$ARGV[0]}) {
|
| 65 |
greg |
2.2 |
push @rtraceA, $ARGV[0];
|
| 66 |
greg |
2.1 |
push @rpictA, shift(@ARGV);
|
| 67 |
greg |
2.2 |
for (my $i = $rtraceC{$rpictA[-1]}; $i-- > 0; ) {
|
| 68 |
|
|
push @rtraceA, $ARGV[0];
|
| 69 |
greg |
2.1 |
push @rpictA, shift(@ARGV);
|
| 70 |
|
|
}
|
| 71 |
|
|
next OPTION;
|
| 72 |
|
|
}
|
| 73 |
greg |
2.2 |
# Check options to ignore
|
| 74 |
|
|
if (defined $ignoreC{$ARGV[0]}) {
|
| 75 |
|
|
push @rpictA, shift(@ARGV);
|
| 76 |
|
|
for (my $i = $ignoreC{$rpictA[-1]}; $i-- > 0; ) {
|
| 77 |
|
|
push @rpictA, shift(@ARGV);
|
| 78 |
|
|
}
|
| 79 |
greg |
2.1 |
next OPTION;
|
| 80 |
|
|
}
|
| 81 |
|
|
# Check for output file or number of processes
|
| 82 |
|
|
if ("$ARGV[0]" eq "-o") {
|
| 83 |
|
|
shift @ARGV;
|
| 84 |
|
|
$outpic = shift(@ARGV);
|
| 85 |
|
|
} elsif ("$ARGV[0]" eq "-n") {
|
| 86 |
|
|
shift @ARGV;
|
| 87 |
|
|
$nprocs = shift(@ARGV);
|
| 88 |
|
|
} else {
|
| 89 |
greg |
2.2 |
die "Unsupported option: " . $ARGV[0] . "\n";
|
| 90 |
greg |
2.1 |
}
|
| 91 |
|
|
}
|
| 92 |
|
|
die "Number of processes must be positive" if ($nprocs <= 0);
|
| 93 |
|
|
if ($outpic) { # redirect output?
|
| 94 |
|
|
open STDOUT, '>', "$outpic";
|
| 95 |
|
|
}
|
| 96 |
|
|
if ($nprocs == 1) { # may as well run rpict?
|
| 97 |
greg |
2.2 |
push(@rpictA, $ARGV[0]) if ($#ARGV == 0);
|
| 98 |
greg |
2.1 |
exec @rpictA ;
|
| 99 |
|
|
}
|
| 100 |
|
|
die "Need single octree argument\n" if ($#ARGV != 0);
|
| 101 |
|
|
push @rtraceA, (`@vwraysA -d`);
|
| 102 |
|
|
chomp $rtraceA[-1];
|
| 103 |
|
|
push @rtraceA, ("-n", "$nprocs");
|
| 104 |
greg |
2.2 |
push @rtraceA, $ARGV[0];
|
| 105 |
greg |
2.1 |
my @view = (`@vwrightA 0`);
|
| 106 |
greg |
2.3 |
exec qq{@vwraysA | @rtraceA | getinfo -a "VIEW=@view"};
|