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