ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rtpict.pl
Revision: 2.1
Committed: Mon Mar 19 23:40:33 2018 UTC (6 years, 1 month ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Created rtpict script to run rtrace like rpict with -n option

File Contents

# Content
1 #!/usr/bin/perl -w
2 # RCSid $Id: genskyvec.pl,v 2.10 2016/12/12 17:40:07 greg Exp $
3 #
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 my %vwraysC = ("-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);
23 # Starting options for rtrace (rpict values)
24 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");
25 my @vwraysA = ("vwrays", "-ff", "-pj", ".67");
26 my @vwrightA = ("vwright", "-vtv");
27 my @rpictA = ("rpict");
28 my $outpic;
29 OPTION: # sort through options
30 while ($#ARGV >= 0 && "$ARGV[0]" =~ /^[-\@]/) {
31 # Check for file inclusion
32 if ("$ARGV[0]" =~ /^\@/) {
33 open my $handle, '<', substr("$ARGV[0]", 1);
34 shift @ARGV;
35 chomp(my @args = <$handle>);
36 close $handle;
37 unshift @ARGV, split(/\s+/, "@args");
38 next OPTION;
39 }
40 # Check booleans
41 for my $boopt (@boolO) {
42 if ("$ARGV[0]" =~ /"^" . $boopt . "[-+01tfynTFYN]$"/) {
43 push @rtraceA, "$ARGV[0]";
44 push @rpictA, shift(@ARGV);
45 next OPTION;
46 }
47 }
48 # Check view options
49 if (defined $vwraysC{$ARGV[0]}) {
50 push @vwraysA, "$ARGV[0]";
51 my $isvopt = ("$ARGV[0]" =~ /^-v/);
52 push(@vwrightA, "$ARGV[0]") if ($isvopt);
53 push @rpictA, shift(@ARGV);
54 for (my $i = $vwraysC{$vwraysA[-1]}; $i-- > 0; ) {
55 push @vwraysA, "$ARGV[0]";
56 push(@vwrightA, "$ARGV[0]") if ($isvopt);
57 push @rpictA, shift(@ARGV);
58 }
59 next OPTION;
60 }
61 # Check rtrace options
62 if (defined $rtraceC{$ARGV[0]}) {
63 push @rtraceA, "$ARGV[0]";
64 push @rpictA, shift(@ARGV);
65 for (my $i = $rtraceC{$rtraceA[-1]}; $i-- > 0; ) {
66 push @rtraceA, "$ARGV[0]";
67 push @rpictA, shift(@ARGV);
68 }
69 next OPTION;
70 }
71 # Check for pixel sampling option
72 if ("$ARGV[0]" eq "-ps") {
73 shift @ARGV;
74 die "We only support -ps 1\n" if (shift(@ARGV) > 1);
75 next OPTION;
76 }
77 # Check for output file or number of processes
78 if ("$ARGV[0]" eq "-o") {
79 shift @ARGV;
80 $outpic = shift(@ARGV);
81 } elsif ("$ARGV[0]" eq "-n") {
82 shift @ARGV;
83 $nprocs = shift(@ARGV);
84 } else {
85 die "Unsupported option: " . "$ARGV[0]" . "\n";
86 }
87 }
88 die "Number of processes must be positive" if ($nprocs <= 0);
89 if ($outpic) { # redirect output?
90 open STDOUT, '>', "$outpic";
91 }
92 if ($nprocs == 1) { # may as well run rpict?
93 push(@rpictA, "$ARGV[0]") if ($#ARGV == 0);
94 exec @rpictA ;
95 }
96 die "Need single octree argument\n" if ($#ARGV != 0);
97 push @rtraceA, (`@vwraysA -d`);
98 chomp $rtraceA[-1];
99 push @rtraceA, ("-n", "$nprocs");
100 push @rtraceA, "$ARGV[0]";
101 my @view = (`@vwrightA 0`);
102 exec "@vwraysA | @rtraceA | getinfo -a 'VIEW=@view'";