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 |
greg |
1.11 |
set fgargs=($fgargs -p $picture) |
75 |
|
|
if ( "$view" != "" ) then |
76 |
|
|
set view=(-vf $picture $view) |
77 |
|
|
endif |
78 |
greg |
1.1 |
endif |
79 |
|
|
set fgargs=($fgargs $view) |
80 |
|
|
if ( $octree != $nofile ) then |
81 |
|
|
if ( ! -r $octree ) then |
82 |
|
|
echo "Cannot read $octree" |
83 |
|
|
exit 1 |
84 |
|
|
endif |
85 |
|
|
cat <<_EOF_ |
86 |
|
|
|
87 |
|
|
With an octree, you should give the same options for -av, -ab and |
88 |
|
|
so forth as are used to render the scene. Please enter them below. |
89 |
|
|
|
90 |
|
|
_EOF_ |
91 |
greg |
1.10 |
if ($picture != $nofile) then |
92 |
|
|
echo "These are the parameters from the picture:" |
93 |
|
|
getinfo $picture |
94 |
|
|
endif |
95 |
greg |
1.1 |
readvar rtargs |
96 |
|
|
set fgargs=($fgargs $rtargs $octree) |
97 |
|
|
endif |
98 |
|
|
echo "" |
99 |
|
|
echo -n "Do you expect glare sources in the scene to be small? " |
100 |
|
|
if ("$<" =~ [yY]) then |
101 |
|
|
echo -n "Very small? " |
102 |
|
|
if ("$<" =~ [yY]) then |
103 |
|
|
set fgargs=(-r 400 $fgargs) |
104 |
|
|
else |
105 |
greg |
1.3 |
set fgargs=(-r 250 $fgargs) |
106 |
greg |
1.1 |
endif |
107 |
greg |
1.4 |
echo -n "Are these sources relatively bright? " |
108 |
greg |
1.1 |
if ("$<" =~ [nN]*) then |
109 |
|
|
set fgargs=(-c $fgargs) |
110 |
|
|
endif |
111 |
|
|
endif |
112 |
|
|
cat <<_EOF_ |
113 |
|
|
|
114 |
|
|
Glare sources are determined by a threshold level. Any part of the |
115 |
|
|
view that is above this threshold is considered to be part of a glare |
116 |
|
|
source. If you do not choose a threshold value, it will be set auto- |
117 |
|
|
matically to 7 times the average field luminance (in candelas/sq.meter). |
118 |
|
|
|
119 |
|
|
_EOF_ |
120 |
|
|
echo -n "Do you wish to set the glare threshold manually? " |
121 |
|
|
if ("$<" =~ [yY]) then |
122 |
|
|
readvar threshold |
123 |
|
|
set fgargs=(-t $threshold $fgargs) |
124 |
|
|
endif |
125 |
|
|
cat <<_EOF_ |
126 |
|
|
|
127 |
|
|
It is often desirable to know how glare changes as a function of |
128 |
|
|
viewing direction. If you like, you can compute glare for up |
129 |
|
|
to 180 degrees to the left and right of the view center. Enter |
130 |
|
|
the maximum angle that you would like to compute below. |
131 |
|
|
|
132 |
|
|
_EOF_ |
133 |
|
|
readvar maxangle |
134 |
|
|
if ( $maxangle >= $stepangle ) then |
135 |
|
|
set fgargs=(-ga $stepangle-$maxangle\:$stepangle $fgargs) |
136 |
|
|
endif |
137 |
|
|
echo "" |
138 |
|
|
echo "Starting calculation..." |
139 |
|
|
echo findglare $fgargs |
140 |
|
|
findglare $fgargs > $glarefile |
141 |
greg |
1.11 |
if ($status) then |
142 |
|
|
echo "Uh-oh. Something went wrong with findglare\!" |
143 |
|
|
rm $glarefile |
144 |
|
|
exit 1 |
145 |
|
|
endif |
146 |
greg |
1.1 |
endif |
147 |
|
|
if ($?DISPLAY && $picture != $nofile) then |
148 |
|
|
echo "" |
149 |
|
|
echo "Displaying glare sources in '$picture'..." |
150 |
greg |
1.9 |
xglaresrc $picture $glarefile |
151 |
greg |
1.1 |
endif |
152 |
greg |
1.5 |
set ndxnam=("Guth Visual Comfort Probability" "Guth Disability Glare Ratio" "CIE Glare Index") |
153 |
|
|
set ndxcom=("glarendx -t guth_vcp" "glarendx -t guth_dgr" "glarendx -t cie_cgi") |
154 |
greg |
1.7 |
set bcdlvl=(50 124 18.5) |
155 |
greg |
1.1 |
while ( 1 ) |
156 |
|
|
echo "" |
157 |
|
|
echo " 0. Quit" |
158 |
|
|
set i=1 |
159 |
|
|
while ($i <= $#ndxnam) |
160 |
|
|
echo " $i. $ndxnam[$i]" |
161 |
|
|
@ i++ |
162 |
|
|
end |
163 |
|
|
echo "" |
164 |
|
|
set choice=0 |
165 |
|
|
readvar choice |
166 |
|
|
if ($choice < 1 || $choice > $#ndxcom) goto quit |
167 |
|
|
$ndxcom[$choice] $glarefile > $gndxfile |
168 |
|
|
echo "" |
169 |
|
|
echo $ndxnam[$choice] |
170 |
|
|
echo "Angle Value" |
171 |
|
|
getinfo - < $gndxfile |
172 |
|
|
echo "" |
173 |
|
|
set save_file=$nofile |
174 |
|
|
readvar save_file |
175 |
|
|
if ($save_file != $nofile) then |
176 |
|
|
cp -i $gndxfile $save_file |
177 |
|
|
endif |
178 |
|
|
if ( `getinfo - < $gndxfile | wc -l` > 4 ) then |
179 |
|
|
echo "" |
180 |
|
|
echo -n "Do you want to plot this data? " |
181 |
|
|
if ( "$<" =~ [yY]* ) then |
182 |
|
|
set subtitle="$view" |
183 |
|
|
if ($picture != $nofile) then |
184 |
|
|
set subtitle="$picture $subtitle" |
185 |
|
|
else if ($octree != $nofile) then |
186 |
|
|
set subtitle="$subtitle $octree" |
187 |
|
|
endif |
188 |
greg |
1.2 |
if ( "$subtitle" == "" ) then |
189 |
|
|
set subtitle="`getinfo < $glarefile | grep findglare`" |
190 |
|
|
endif |
191 |
greg |
1.1 |
cat <<_EOF_ > $plotfile |
192 |
greg |
1.2 |
include=line.plt |
193 |
greg |
1.1 |
include=polar.plt |
194 |
|
|
title="$ndxnam[$choice]" |
195 |
|
|
subtitle="$subtitle" |
196 |
greg |
1.7 |
Bdata= |
197 |
|
|
0 $bcdlvl[$choice] |
198 |
|
|
360 $bcdlvl[$choice] |
199 |
|
|
; |
200 |
|
|
Blabel="BCD level" |
201 |
greg |
1.1 |
Adata= |
202 |
|
|
_EOF_ |
203 |
|
|
getinfo - < $gndxfile >> $plotfile |
204 |
|
|
igraph $plotfile |
205 |
|
|
endif |
206 |
|
|
endif |
207 |
|
|
end |
208 |
|
|
quit: |
209 |
|
|
rm -f $tempfiles |
210 |
|
|
exit 0 |