17 |
|
# boolean rtrace options |
18 |
|
my @boolO = ("-w", "-bv", "-dv", "-i", "-u"); |
19 |
|
# view options and the associated number of arguments |
20 |
< |
my %vwraysC = ("-vtv",0, "-vtl",0, "-vth",0, "-vta",0, "-vts",0, "-vtc",0, |
20 |
> |
my %vwraysC = ("-vf",1, "-vtv",0, "-vtl",0, "-vth",0, "-vta",0, "-vts",0, "-vtc",0, |
21 |
|
"-x",1, "-y",1, "-vp",3, "-vd",3, "-vu",3, "-vh",1, "-vv",1, |
22 |
< |
"-vo",1, "-va",1, "-vs",1, "-vl",1, "-pa",1, "-pj",1); |
22 |
> |
"-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 |
|
# 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"); |
26 |
> |
my @rtraceA = split(' ', "rtrace -u- -dt .05 -dc .5 -ds .25 -dr 1 " . |
27 |
> |
"-aa .2 -ar 64 -ad 512 -as 128 -lr 7 -lw 1e-03"); |
28 |
|
my @vwraysA = ("vwrays", "-ff", "-pj", ".67"); |
29 |
|
my @vwrightA = ("vwright", "-vtv"); |
30 |
|
my @rpictA = ("rpict"); |
31 |
|
my $outpic; |
32 |
+ |
my $outzbf; |
33 |
|
OPTION: # sort through options |
34 |
|
while ($#ARGV >= 0 && "$ARGV[0]" =~ /^[-\@]/) { |
35 |
|
# Check for file inclusion |
36 |
|
if ("$ARGV[0]" =~ /^\@/) { |
37 |
< |
open my $handle, '<', substr("$ARGV[0]", 1); |
37 |
> |
open my $handle, '<', substr($ARGV[0], 1); |
38 |
|
shift @ARGV; |
39 |
|
chomp(my @args = <$handle>); |
40 |
|
close $handle; |
43 |
|
} |
44 |
|
# Check booleans |
45 |
|
for my $boopt (@boolO) { |
46 |
< |
if ("$ARGV[0]" =~ /"^" . $boopt . "[-+01tfynTFYN]$"/) { |
47 |
< |
push @rtraceA, "$ARGV[0]"; |
46 |
> |
if ("$ARGV[0]" =~ ('^' . $boopt . '[-+01tfynTFYN]$')) { |
47 |
> |
push @rtraceA, $ARGV[0]; |
48 |
|
push @rpictA, shift(@ARGV); |
49 |
|
next OPTION; |
50 |
|
} |
51 |
|
} |
52 |
|
# Check view options |
53 |
|
if (defined $vwraysC{$ARGV[0]}) { |
54 |
< |
push @vwraysA, "$ARGV[0]"; |
54 |
> |
push @vwraysA, $ARGV[0]; |
55 |
|
my $isvopt = ("$ARGV[0]" =~ /^-v/); |
56 |
< |
push(@vwrightA, "$ARGV[0]") if ($isvopt); |
56 |
> |
push(@vwrightA, $ARGV[0]) if ($isvopt); |
57 |
|
push @rpictA, shift(@ARGV); |
58 |
< |
for (my $i = $vwraysC{$vwraysA[-1]}; $i-- > 0; ) { |
59 |
< |
push @vwraysA, "$ARGV[0]"; |
60 |
< |
push(@vwrightA, "$ARGV[0]") if ($isvopt); |
58 |
> |
for (my $i = $vwraysC{$rpictA[-1]}; $i-- > 0; ) { |
59 |
> |
push @vwraysA, $ARGV[0]; |
60 |
> |
push(@vwrightA, $ARGV[0]) if ($isvopt); |
61 |
|
push @rpictA, shift(@ARGV); |
62 |
|
} |
63 |
|
next OPTION; |
64 |
|
} |
65 |
|
# Check rtrace options |
66 |
|
if (defined $rtraceC{$ARGV[0]}) { |
67 |
< |
push @rtraceA, "$ARGV[0]"; |
67 |
> |
push @rtraceA, $ARGV[0]; |
68 |
|
push @rpictA, shift(@ARGV); |
69 |
< |
for (my $i = $rtraceC{$rtraceA[-1]}; $i-- > 0; ) { |
70 |
< |
push @rtraceA, "$ARGV[0]"; |
69 |
> |
for (my $i = $rtraceC{$rpictA[-1]}; $i-- > 0; ) { |
70 |
> |
push @rtraceA, $ARGV[0]; |
71 |
|
push @rpictA, shift(@ARGV); |
72 |
|
} |
73 |
|
next OPTION; |
74 |
|
} |
75 |
< |
# Check for pixel sampling option |
76 |
< |
if ("$ARGV[0]" eq "-ps") { |
77 |
< |
shift @ARGV; |
78 |
< |
die "We only support -ps 1\n" if (shift(@ARGV) > 1); |
75 |
> |
# Check options to ignore |
76 |
> |
if (defined $ignoreC{$ARGV[0]}) { |
77 |
> |
push @rpictA, shift(@ARGV); |
78 |
> |
for (my $i = $ignoreC{$rpictA[-1]}; $i-- > 0; ) { |
79 |
> |
push @rpictA, shift(@ARGV); |
80 |
> |
} |
81 |
|
next OPTION; |
82 |
|
} |
83 |
|
# Check for output file or number of processes |
84 |
|
if ("$ARGV[0]" eq "-o") { |
85 |
|
shift @ARGV; |
86 |
|
$outpic = shift(@ARGV); |
87 |
+ |
} elsif ("$ARGV[0]" eq "-z") { |
88 |
+ |
push @rpictA, shift(@ARGV); |
89 |
+ |
$outzbf = $ARGV[0]; |
90 |
+ |
push @rpictA, shift(@ARGV); |
91 |
|
} elsif ("$ARGV[0]" eq "-n") { |
92 |
|
shift @ARGV; |
93 |
|
$nprocs = shift(@ARGV); |
94 |
|
} else { |
95 |
< |
die "Unsupported option: " . "$ARGV[0]" . "\n"; |
95 |
> |
die "Unsupported option: " . $ARGV[0] . "\n"; |
96 |
|
} |
97 |
|
} |
98 |
|
die "Number of processes must be positive" if ($nprocs <= 0); |
99 |
< |
if ($outpic) { # redirect output? |
99 |
> |
if (defined $outpic) { # redirect output? |
100 |
> |
die "File '$outpic' already exists\n" if (-e $outpic); |
101 |
|
open STDOUT, '>', "$outpic"; |
102 |
|
} |
103 |
|
if ($nprocs == 1) { # may as well run rpict? |
104 |
< |
push(@rpictA, "$ARGV[0]") if ($#ARGV == 0); |
104 |
> |
push(@rpictA, $ARGV[0]) if ($#ARGV == 0); |
105 |
|
exec @rpictA ; |
106 |
|
} |
96 |
– |
die "Need single octree argument\n" if ($#ARGV != 0); |
97 |
– |
push @rtraceA, (`@vwraysA -d`); |
98 |
– |
chomp $rtraceA[-1]; |
107 |
|
push @rtraceA, ("-n", "$nprocs"); |
108 |
< |
push @rtraceA, "$ARGV[0]"; |
109 |
< |
my @view = (`@vwrightA 0`); |
110 |
< |
exec "@vwraysA | @rtraceA | getinfo -a 'VIEW=@view'"; |
108 |
> |
die "Need single octree argument\n" if ($#ARGV != 0); |
109 |
> |
my $oct = $ARGV[0]; |
110 |
> |
my $view = `@vwrightA 0`; |
111 |
> |
my @res = split(/\s/, `@vwraysA -d`); |
112 |
> |
if (defined $outzbf) { # generating depth buffer? |
113 |
> |
my $tres = "/tmp/rtp$$"; |
114 |
> |
system "@vwraysA | @rtraceA -fff -ovl $res[4] $oct > $tres" || exit 1; |
115 |
> |
system( q{getinfo -c rcalc -if4 -of -e '$1=$1;$2=$2;$3=$3' < } . |
116 |
> |
"$tres | pvalue -r -df -Y $res[3] +X $res[1] | " . |
117 |
> |
"getinfo -a 'VIEW=$view'" ); |
118 |
> |
system( "getinfo - < $tres | rcalc -if4 -of > $outzbf" . q{ -e '$1=$4'} ); |
119 |
> |
unlink $tres; |
120 |
> |
exit; |
121 |
> |
} |
122 |
> |
# no depth buffer, so simpler |
123 |
> |
exec "@vwraysA | @rtraceA -ffc @res $oct | getinfo -a 'VIEW=$view'"; |