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 |
_EOF_ |
57 |
readvar picture |
58 |
readvar octree |
59 |
readvar view |
60 |
if ( $picture == $nofile && $octree == $nofile ) then |
61 |
echo "You must specify a picture or an octree" |
62 |
exit 1 |
63 |
endif |
64 |
if ( $picture != $nofile ) then |
65 |
if ( ! -r $picture ) then |
66 |
echo "Cannot read $picture" |
67 |
exit 1 |
68 |
endif |
69 |
set fgargs=($fgargs -p $picture -vf $picture) |
70 |
endif |
71 |
set fgargs=($fgargs $view) |
72 |
if ( $octree != $nofile ) then |
73 |
if ( ! -r $octree ) then |
74 |
echo "Cannot read $octree" |
75 |
exit 1 |
76 |
endif |
77 |
cat <<_EOF_ |
78 |
|
79 |
With an octree, you should give the same options for -av, -ab and |
80 |
so forth as are used to render the scene. Please enter them below. |
81 |
|
82 |
_EOF_ |
83 |
readvar rtargs |
84 |
set fgargs=($fgargs $rtargs $octree) |
85 |
endif |
86 |
echo "" |
87 |
echo -n "Do you expect glare sources in the scene to be small? " |
88 |
if ("$<" =~ [yY]) then |
89 |
echo -n "Very small? " |
90 |
if ("$<" =~ [yY]) then |
91 |
set fgargs=(-r 400 $fgargs) |
92 |
else |
93 |
set fgargs=(-r 200 $fgargs) |
94 |
endif |
95 |
echo -n "Are these sources very bright? " |
96 |
if ("$<" =~ [nN]*) then |
97 |
set fgargs=(-c $fgargs) |
98 |
endif |
99 |
endif |
100 |
cat <<_EOF_ |
101 |
|
102 |
Glare sources are determined by a threshold level. Any part of the |
103 |
view that is above this threshold is considered to be part of a glare |
104 |
source. If you do not choose a threshold value, it will be set auto- |
105 |
matically to 7 times the average field luminance (in candelas/sq.meter). |
106 |
|
107 |
_EOF_ |
108 |
echo -n "Do you wish to set the glare threshold manually? " |
109 |
if ("$<" =~ [yY]) then |
110 |
readvar threshold |
111 |
set fgargs=(-t $threshold $fgargs) |
112 |
endif |
113 |
cat <<_EOF_ |
114 |
|
115 |
It is often desirable to know how glare changes as a function of |
116 |
viewing direction. If you like, you can compute glare for up |
117 |
to 180 degrees to the left and right of the view center. Enter |
118 |
the maximum angle that you would like to compute below. |
119 |
|
120 |
_EOF_ |
121 |
readvar maxangle |
122 |
if ( $maxangle >= $stepangle ) then |
123 |
set fgargs=(-ga $stepangle-$maxangle\:$stepangle $fgargs) |
124 |
endif |
125 |
echo "" |
126 |
echo "Starting calculation..." |
127 |
echo findglare $fgargs |
128 |
findglare $fgargs > $glarefile |
129 |
endif |
130 |
if ($?DISPLAY && $picture != $nofile) then |
131 |
echo "" |
132 |
echo "Displaying glare sources in '$picture'..." |
133 |
xglaresrc $picture $glarefile |
134 |
if ($status) then |
135 |
x11image =+0+0 -g 2.6 $picture & |
136 |
sleep 40 |
137 |
xglaresrc $picture $glarefile |
138 |
endif |
139 |
endif |
140 |
set ndxnam=("Guth Visual Comfort Probability" "Guth Disability Glare Ratio") |
141 |
set ndxcom=(guth_vcp guth_dgr) |
142 |
while ( 1 ) |
143 |
echo "" |
144 |
echo " 0. Quit" |
145 |
set i=1 |
146 |
while ($i <= $#ndxnam) |
147 |
echo " $i. $ndxnam[$i]" |
148 |
@ i++ |
149 |
end |
150 |
echo "" |
151 |
set choice=0 |
152 |
readvar choice |
153 |
if ($choice < 1 || $choice > $#ndxcom) goto quit |
154 |
$ndxcom[$choice] $glarefile > $gndxfile |
155 |
echo "" |
156 |
echo $ndxnam[$choice] |
157 |
echo "Angle Value" |
158 |
getinfo - < $gndxfile |
159 |
echo "" |
160 |
set save_file=$nofile |
161 |
readvar save_file |
162 |
if ($save_file != $nofile) then |
163 |
cp -i $gndxfile $save_file |
164 |
endif |
165 |
if ( `getinfo - < $gndxfile | wc -l` > 4 ) then |
166 |
echo "" |
167 |
echo -n "Do you want to plot this data? " |
168 |
if ( "$<" =~ [yY]* ) then |
169 |
set subtitle="$view" |
170 |
if ($picture != $nofile) then |
171 |
set subtitle="$picture $subtitle" |
172 |
else if ($octree != $nofile) then |
173 |
set subtitle="$subtitle $octree" |
174 |
endif |
175 |
cat <<_EOF_ > $plotfile |
176 |
include=polar.plt |
177 |
title="$ndxnam[$choice]" |
178 |
subtitle="$subtitle" |
179 |
Adata= |
180 |
_EOF_ |
181 |
getinfo - < $gndxfile >> $plotfile |
182 |
igraph $plotfile |
183 |
endif |
184 |
endif |
185 |
end |
186 |
quit: |
187 |
rm -f $tempfiles |
188 |
exit 0 |