ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/bsdfview.pl
Revision: 2.1
Committed: Fri Aug 11 21:39:52 2017 UTC (6 years, 8 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Created bsdfview script and added man page for bsdf2rad

File Contents

# Content
1 #!/usr/bin/perl
2 # RCSid $Id: objview.pl,v 2.2 2016/08/19 17:51:23 greg Exp $
3 #
4 # Call bsdf2rad to render BSDF and start viewing it.
5 # Arguments are BSDF XML or SIR file(s)
6 #
7 use strict;
8 use warnings;
9 use File::Temp qw/ tempdir /;
10
11 my $td = tempdir( CLEANUP => 0 );
12 my $octree = "$td/bv$$.oct";
13 my $ambf = "$td/af$$.amb";
14 my $raddev = "x11"; # default output device. Overwrite with -o
15 my $qual = "Low";
16 my $vw = "def";
17
18 my $opts = ""; # Options common to rad
19 my $rendopts = "-w-"; # For render= line in rif file
20
21 while (@ARGV) {
22 $_ = $ARGV[0];
23 if ((m/^-s\b/) or (m/^-w/)) { # silent, no warnings
24 $opts .= " $_";
25 } elsif (m/^-v\b/) { # standard view
26 # Let rad do any error handling...
27 $vw = $ARGV[1];
28 shift @ARGV;
29 } elsif (m/^-[nN]\b/) { # No. of parallel processes
30 $opts .= ' -N ' . $ARGV[1];
31 shift @ARGV;
32 } elsif (m/^-o\b/) { # output device (rvu -devices)
33 $raddev = $ARGV[1];
34 shift @ARGV;
35 } elsif (m/^-q/) { # quality setting
36 $qual = $ARGV[1];
37 shift @ARGV;
38 } elsif ((m/^-V\b/) or (m/^-e\b/)) { # print view, explicate variables
39 # Think of those two as '-verbose'.
40 $opts .= " $_";
41 } elsif (m/^-\w/) {
42 die("bsdfview: Bad option: $_\n");
43 } else {
44 last;
45 }
46 shift @ARGV;
47 }
48
49 # We need at least one XML or SIR file
50 if ($#ARGV < 0) {
51 die("Missing input XML or SIR file(s)\n");
52 }
53
54 my @objects = @ARGV;
55
56 # Make this work under Windoze
57 if ( $^O =~ /MSWin32/ ) {
58 for my $i (0 .. $#objects) {
59 # rad doesn't like Windows-style backslashes.
60 $objects[$i] =~ s{\\}{/}g;
61 }
62 $octree =~ s{\\}{/}g;
63 $ambf =~ s{\\}{/}g;
64 $raddev = "qt";
65 }
66
67 my $name = $objects[0];
68 $name =~ s{.*/}{}; # remove leading path
69 $name =~ s{\.[^.]+$}{}; # remove file extension
70
71 my $rif = "$name.rif";
72
73 die("bsdfview: will not overwrite existing file '$rif'\n") if (-e $rif);
74
75 print "bsdfview: creating rad input file '$rif'\n";
76
77 my $scene = qq("!bsdf2rad @objects"); # let bsdf2rad do complaining
78
79 my $objects = join(' ', @objects);
80 open(FH, ">$rif") or
81 die("bsdfview: Can't write to temporary file $rif\n");
82 print FH <<EndOfRif;
83 scene= $scene
84 objects= $objects
85 ZONE= E -35 35 -20 15 -5 15
86 PICTURE= $name
87 RESOLU= 1024
88 EXPOSURE= 1
89 UP= +Z
90 OCTREE= $octree
91 oconv= -w -f
92 AMBF= $ambf
93 QUAL = $qual
94 render= $rendopts
95 view= def -vp 0 -50 50 -vd 0 50 -50 -vh 45 -vv 30
96 view= fr -vp 15 -30 30 -vd 0 30 -30
97 view= br -vp -15 -30 30 -vd 0 30 -30
98 view= ft -vta -vp 15 0 0 -vd 0 0 1 -vu 0 1 0 -vh 200 -vv 200
99 view= bt -vta -vp -15 0 0 -vd 0 0 1 -vu 0 1 0 -vh 200 -vv 200
100 view= pr -vtl -vp 0 0 20 -vd 0 0 -1 -vu 0 1 0 -vv 35 -vh 65
101 view= pt -vtl -vp 0 0 -10 -vd 0 0 1 -vu 0 1 0 -vv 35 -vh 65
102 EndOfRif
103 close(FH);
104
105 system "rad -o $raddev -v $vw $opts $rif";
106
107 #EOF