ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/glare.csh
Revision: 1.7
Committed: Thu May 2 16:07:22 1991 UTC (32 years, 11 months ago) by greg
Content type: application/x-csh
Branch: MAIN
Changes since 1.6: +6 -0 lines
Log Message:
added BCD level to plots

File Contents

# User Rev Content
1 greg 1.1 #!/bin/csh -f
2     # SCCSid "$SunId$ LBL"
3     #
4     # Interactive program for calculating glare values
5     #
6     set fgargs=(-v)
7     set nofile="none"
8     set octree=$nofile
9     set picture=$nofile
10     if ($#argv >= 1) then
11     set glarefile=$argv[1]
12     else
13     set glarefile=$nofile
14     endif
15     set rtargs=
16     set view=
17     set threshold=300
18     set maxangle=0
19     set stepangle=10
20    
21     set gndxfile="glr$$.ndx"
22     set plotfile="glr$$.plt"
23     set tempfiles=($gndxfile $plotfile)
24    
25     alias readvar 'echo -n Enter \!:1 "[$\!:1]: ";set ans="$<";if("$ans" != "")set \!:1="$ans"'
26    
27     onintr quit
28    
29     cat <<_EOF_
30     This script provides a convenient interface to the glare calculation
31     and analysis programs. It works on a single output file from findglare,
32     which you must either create here or have created already before.
33     _EOF_
34     while ( $glarefile == $nofile )
35     echo ""
36     echo "Please specify a glare file, or use ^C to exit."
37     readvar glarefile
38     end
39     if ( ! -f $glarefile ) then
40     echo ""
41     echo -n "The glare file '$glarefile' doesn't exist -- shall we create it? "
42     if ("$<" =~ [nN]*) exit 0
43     cat <<_EOF_
44    
45     A glare file can be created from a wide-angle Radiance picture (preferably
46     a fisheye view), an octree, or both. Computing glare source locations
47     from a finished image is faster, but using an octree is more reliable
48     since all of the scene information is there. Whenever it is possible,
49     you should use both a picture and an octree to compute the glare file.
50    
51     You must also have a viewpoint and direction for the glare calculation.
52     If the viewpoint is not the same as the picture, an error will result.
53     If no view is specified, the view parameters are taken from the picture,
54     so the view specification is optional unless you are starting from an
55     octree.
56 greg 1.2
57 greg 1.1 _EOF_
58     readvar picture
59     readvar octree
60     readvar view
61     if ( $picture == $nofile && $octree == $nofile ) then
62     echo "You must specify a picture or an octree"
63     exit 1
64     endif
65 greg 1.6 if ( $picture == $nofile && "$view" == "" ) then
66     echo "You must give a view if there is no picture"
67     exit 1
68     endif
69 greg 1.1 if ( $picture != $nofile ) then
70     if ( ! -r $picture ) then
71     echo "Cannot read $picture"
72     exit 1
73     endif
74     set fgargs=($fgargs -p $picture -vf $picture)
75     endif
76     set fgargs=($fgargs $view)
77     if ( $octree != $nofile ) then
78     if ( ! -r $octree ) then
79     echo "Cannot read $octree"
80     exit 1
81     endif
82     cat <<_EOF_
83    
84     With an octree, you should give the same options for -av, -ab and
85     so forth as are used to render the scene. Please enter them below.
86    
87     _EOF_
88     readvar rtargs
89     set fgargs=($fgargs $rtargs $octree)
90     endif
91     echo ""
92     echo -n "Do you expect glare sources in the scene to be small? "
93     if ("$<" =~ [yY]) then
94     echo -n "Very small? "
95     if ("$<" =~ [yY]) then
96     set fgargs=(-r 400 $fgargs)
97     else
98 greg 1.3 set fgargs=(-r 250 $fgargs)
99 greg 1.1 endif
100 greg 1.4 echo -n "Are these sources relatively bright? "
101 greg 1.1 if ("$<" =~ [nN]*) then
102     set fgargs=(-c $fgargs)
103     endif
104     endif
105     cat <<_EOF_
106    
107     Glare sources are determined by a threshold level. Any part of the
108     view that is above this threshold is considered to be part of a glare
109     source. If you do not choose a threshold value, it will be set auto-
110     matically to 7 times the average field luminance (in candelas/sq.meter).
111    
112     _EOF_
113     echo -n "Do you wish to set the glare threshold manually? "
114     if ("$<" =~ [yY]) then
115     readvar threshold
116     set fgargs=(-t $threshold $fgargs)
117     endif
118     cat <<_EOF_
119    
120     It is often desirable to know how glare changes as a function of
121     viewing direction. If you like, you can compute glare for up
122     to 180 degrees to the left and right of the view center. Enter
123     the maximum angle that you would like to compute below.
124    
125     _EOF_
126     readvar maxangle
127     if ( $maxangle >= $stepangle ) then
128     set fgargs=(-ga $stepangle-$maxangle\:$stepangle $fgargs)
129     endif
130     echo ""
131     echo "Starting calculation..."
132     echo findglare $fgargs
133     findglare $fgargs > $glarefile
134     endif
135     if ($?DISPLAY && $picture != $nofile) then
136     echo ""
137     echo "Displaying glare sources in '$picture'..."
138 greg 1.2 xglaresrc $picture $glarefile >& /dev/null
139 greg 1.1 if ($status) then
140     x11image =+0+0 -g 2.6 $picture &
141     sleep 40
142     xglaresrc $picture $glarefile
143     endif
144     endif
145 greg 1.5 set ndxnam=("Guth Visual Comfort Probability" "Guth Disability Glare Ratio" "CIE Glare Index")
146     set ndxcom=("glarendx -t guth_vcp" "glarendx -t guth_dgr" "glarendx -t cie_cgi")
147 greg 1.7 set bcdlvl=(50 124 18.5)
148 greg 1.1 while ( 1 )
149     echo ""
150     echo " 0. Quit"
151     set i=1
152     while ($i <= $#ndxnam)
153     echo " $i. $ndxnam[$i]"
154     @ i++
155     end
156     echo ""
157     set choice=0
158     readvar choice
159     if ($choice < 1 || $choice > $#ndxcom) goto quit
160     $ndxcom[$choice] $glarefile > $gndxfile
161     echo ""
162     echo $ndxnam[$choice]
163     echo "Angle Value"
164     getinfo - < $gndxfile
165     echo ""
166     set save_file=$nofile
167     readvar save_file
168     if ($save_file != $nofile) then
169     cp -i $gndxfile $save_file
170     endif
171     if ( `getinfo - < $gndxfile | wc -l` > 4 ) then
172     echo ""
173     echo -n "Do you want to plot this data? "
174     if ( "$<" =~ [yY]* ) then
175     set subtitle="$view"
176     if ($picture != $nofile) then
177     set subtitle="$picture $subtitle"
178     else if ($octree != $nofile) then
179     set subtitle="$subtitle $octree"
180     endif
181 greg 1.2 if ( "$subtitle" == "" ) then
182     set subtitle="`getinfo < $glarefile | grep findglare`"
183     endif
184 greg 1.1 cat <<_EOF_ > $plotfile
185 greg 1.2 include=line.plt
186 greg 1.1 include=polar.plt
187     title="$ndxnam[$choice]"
188     subtitle="$subtitle"
189 greg 1.7 Bdata=
190     0 $bcdlvl[$choice]
191     360 $bcdlvl[$choice]
192     ;
193     Blabel="BCD level"
194 greg 1.1 Adata=
195     _EOF_
196     getinfo - < $gndxfile >> $plotfile
197     igraph $plotfile
198     endif
199     endif
200     end
201     quit:
202     rm -f $tempfiles
203     exit 0