orig/genwindow.csh
author Axel Jacobs <axel@jaloxa.eu>
Mon, 14 Apr 2014 22:21:17 +0100
changeset 73 87fa3132a136
parent 0 0aa115157c9c
permissions -rw-r--r--
New IES test file with spaces in file name
axel@0
     1
#!/bin/csh -f
axel@0
     2
# RCSid: $Id: genwindow.csh,v 2.2 2003/02/22 02:07:23 greg Exp $
axel@0
     3
#
axel@0
     4
#  Generate source description for window with venetian blinds.
axel@0
     5
#
axel@0
     6
#	1/11/88		Greg Ward
axel@0
     7
#
axel@0
     8
#  Usage: genwindow shellfile
axel@0
     9
#
axel@0
    10
#  Takes as input the following shell variables from file $1:
axel@0
    11
#
axel@0
    12
#	worient		Window orientation (degrees from south)
axel@0
    13
#	wwidth		Window width
axel@0
    14
#	wheight		Window height
axel@0
    15
#	wtrans		Window transmission
axel@0
    16
#	bdepth		Blind depth
axel@0
    17
#	bspac		Blind vertical spacing
axel@0
    18
#	gap		Gap between blinds and window
axel@0
    19
#	brcurv		Blind curvature radius (negative upward, zero none)
axel@0
    20
#	bangle		Blind inclination (degrees from horizontal, up and out)
axel@0
    21
#	material	Blind material type (metal or plastic)
axel@0
    22
#	ucolor		Blind up side color ("red green blue")
axel@0
    23
#	uspec		Blind up side specularity (0 to 1)
axel@0
    24
#	urough		Blind up side roughness (0 to .2)
axel@0
    25
#	dcolor		Blind down side color (opt)
axel@0
    26
#	dspec		Blind down side specularity (opt)
axel@0
    27
#	drough		Blind down side roughness (opt)
axel@0
    28
#	lat		Site latitude (degrees)
axel@0
    29
#	long		Site longitude (degrees)
axel@0
    30
#	mer		Site standard meridian (degrees)
axel@0
    31
#	hour		Hour (standard 24hr time)
axel@0
    32
#	day		Day (of month)
axel@0
    33
#	month		Month (of year)
axel@0
    34
#	grefl		Ground plane reflectance
axel@0
    35
#	sky		Sky conditions (sunny, clear, cloudy)
axel@0
    36
#	nsources	Number of sources to divide window
axel@0
    37
#
axel@0
    38
#  Creates the following output files:
axel@0
    39
#
axel@0
    40
#	stdout		Window description for Radiance
axel@0
    41
#	$1.d$$		Window output distribution
axel@0
    42
#
axel@0
    43
axel@0
    44
if ( $#argv != 1 ) then
axel@0
    45
	echo Usage: $0 input
axel@0
    46
	exit 1
axel@0
    47
endif
axel@0
    48
axel@0
    49
#	Set input and output files
axel@0
    50
set input = $1
axel@0
    51
set distrib = $1.d$$
axel@0
    52
set tmpdir = /tmp
axel@0
    53
set descrip = $tmpdir/gw$$.des
axel@0
    54
set distoct = $tmpdir/gw$$.oct
axel@0
    55
set skydesc = $tmpdir/gw$$.sky
axel@0
    56
set remove = ( $distoct $skydesc $descrip )
axel@0
    57
set removerr = ( $remove $distrib )
axel@0
    58
onintr error
axel@0
    59
axel@0
    60
#	Set default values
axel@0
    61
set worient = 0.
axel@0
    62
set wtrans = ( .96 .96 .96 )
axel@0
    63
set bdepth = 0.025
axel@0
    64
set bspac = 0.0155
axel@0
    65
set gap = 0.
axel@0
    66
set brcurv = 0.
axel@0
    67
set bangle = 0.
axel@0
    68
set material = plastic
axel@0
    69
set ucolor = ( 0.5 0.5 0.5 ) 
axel@0
    70
set uspec = 0.
axel@0
    71
set urough = 0.05
axel@0
    72
set lat = 37.8
axel@0
    73
set long = 122
axel@0
    74
set mer = 120
axel@0
    75
set hour = 12
axel@0
    76
set day = 21
axel@0
    77
set month = 10
axel@0
    78
set grefl = .2
axel@0
    79
set sky = sunny
axel@0
    80
set nsources = 6
axel@0
    81
axel@0
    82
#	Get input
axel@0
    83
source $input
axel@0
    84
if ( $status ) goto error
axel@0
    85
axel@0
    86
#	Create window
axel@0
    87
cat > $descrip <<_EOF_
axel@0
    88
axel@0
    89
void glass clear_glass
axel@0
    90
0
axel@0
    91
0
axel@0
    92
3 $wtrans
axel@0
    93
axel@0
    94
clear_glass polygon window
axel@0
    95
0
axel@0
    96
0
axel@0
    97
12
axel@0
    98
	0	0	0
axel@0
    99
	0	0	$wheight
axel@0
   100
	$wwidth	0	$wheight
axel@0
   101
	$wwidth	0	0
axel@0
   102
axel@0
   103
void $material blind_upmat
axel@0
   104
0
axel@0
   105
0
axel@0
   106
5 $ucolor $uspec $urough
axel@0
   107
_EOF_
axel@0
   108
if ( $status ) goto error
axel@0
   109
axel@0
   110
#	Blinds
axel@0
   111
genblinds blind_upmat blind_up $bdepth $wwidth $wheight \
axel@0
   112
		`ev "ceil($wheight/$bspac)"` $bangle -r $brcurv \
axel@0
   113
	| xform -t $gap -$wwidth 1e-4 -rz 90 >> $descrip
axel@0
   114
if ( $status ) goto error
axel@0
   115
if ( $?dcolor ) then
axel@0
   116
	cat >> $descrip <<_EOF_
axel@0
   117
axel@0
   118
	void $material blind_dnmat
axel@0
   119
	0
axel@0
   120
	0
axel@0
   121
	5 $dcolor $dspec $drough
axel@0
   122
_EOF_
axel@0
   123
	genblinds blind_dnmat blind_down $bdepth $wwidth $wheight \
axel@0
   124
			`ev "ceil($wheight/$bspac)"` $bangle -r $brcurv \
axel@0
   125
		| xform -t $gap -$wwidth 0 -rz 90 >> $descrip
axel@0
   126
	if ( $status ) goto error
axel@0
   127
endif
axel@0
   128
axel@0
   129
#	Make sky
axel@0
   130
switch ($sky)
axel@0
   131
case sun*:
axel@0
   132
	set skysw = +s
axel@0
   133
	breaksw
axel@0
   134
case clear:
axel@0
   135
	set skysw = -s
axel@0
   136
	breaksw
axel@0
   137
case cloud*:
axel@0
   138
	set skysw = -c
axel@0
   139
	breaksw
axel@0
   140
endsw
axel@0
   141
dosky:
axel@0
   142
gensky $month $day $hour $skysw -a $lat -o $long -m $mer -g $grefl \
axel@0
   143
	| xform -rz `ev "-($worient)"` > $skydesc
axel@0
   144
if ( $skysw == +s ) then
axel@0
   145
	if ( `sed -n 13p $skydesc | rcalc -e '$1=if($3,-1,1)'` < 0 ) then
axel@0
   146
		set skysw = -s
axel@0
   147
		goto dosky
axel@0
   148
	endif
axel@0
   149
endif
axel@0
   150
cat >> $skydesc <<_EOF_
axel@0
   151
axel@0
   152
skyfunc glow skyglow
axel@0
   153
0
axel@0
   154
0
axel@0
   155
4 1 1 1 0
axel@0
   156
axel@0
   157
skyglow source sky
axel@0
   158
0
axel@0
   159
0
axel@0
   160
4 0 -1 0 180
axel@0
   161
_EOF_
axel@0
   162
axel@0
   163
#	Make distribution
axel@0
   164
oconv $skydesc $descrip > $distoct
axel@0
   165
if ( $status ) goto error
axel@0
   166
echo 2 5 85 9 0 340 18 > $distrib
axel@0
   167
makedist -h -d -x1 0 1 0 -x2 0 0 1 -x3 1 0 0 -alpha 5-85:10 -beta 0-340:20 \
axel@0
   168
		-tw $bspac -th $bspac -td `ev "2*($bdepth+$gap)"` \
axel@0
   169
		-tc `ev "$wwidth/2" "$bdepth+$gap" "$wheight/2"` \
axel@0
   170
		-ab 2 -aa .1 -ad 64 -as 64 \
axel@0
   171
		-x 16 -y 16 $distoct >> $distrib
axel@0
   172
if ( $status ) goto error
axel@0
   173
axel@0
   174
set wsgrid = (`ev "floor(sqrt($nsources*$wwidth/$wheight)+.5)" "floor(sqrt($nsources*$wheight/$wwidth)+.5)"`)
axel@0
   175
@ nsources = $wsgrid[1] * $wsgrid[2]
axel@0
   176
#	Print header
axel@0
   177
cat <<_EOF_
axel@0
   178
#
axel@0
   179
#  Window with venetian blinds
axel@0
   180
#  Created from $input `date`
axel@0
   181
#
axel@0
   182
#	Window orientation (degrees from south):	$worient
axel@0
   183
#	Window height:					$wheight
axel@0
   184
#	Window width:					$wwidth
axel@0
   185
#	Window transmission:				$wtrans
axel@0
   186
#	Blind depth:					$bdepth
axel@0
   187
#	Blind spacing:					$bspac
axel@0
   188
#	Gap to window:					$gap
axel@0
   189
#	Blind curvature radius:				$brcurv
axel@0
   190
#	Blind inclination (degrees altitude):		$bangle
axel@0
   191
#	Blind material:					$material
axel@0
   192
#	Up side color:					$ucolor
axel@0
   193
#	Up side specularity:				$uspec
axel@0
   194
#	Up side roughness:				$urough
axel@0
   195
_EOF_
axel@0
   196
if ( $?dcolor ) then
axel@0
   197
	cat <<_EOF_
axel@0
   198
#	Down side color:				$dcolor
axel@0
   199
#	Down side specularity:				$dspec
axel@0
   200
#	Down side roughness:				$drough
axel@0
   201
_EOF_
axel@0
   202
else
axel@0
   203
	echo \#\	Down side same as up
axel@0
   204
endif
axel@0
   205
cat <<_EOF_
axel@0
   206
#	Latitude (degrees):				$lat
axel@0
   207
#	Longitude (degrees):				$long
axel@0
   208
#	Standard Meridian (degrees):			$mer
axel@0
   209
#	Month Day Hour:					$month $day $hour
axel@0
   210
#	Ground plane reflectance:			$grefl
axel@0
   211
#	Sky condition:					$sky
axel@0
   212
#	Number of window sources:			$nsources
axel@0
   213
#
axel@0
   214
_EOF_
axel@0
   215
axel@0
   216
#	Send sources
axel@0
   217
xform -e -rz $worient <<_EOF_
axel@0
   218
axel@0
   219
void brightdata wdistrib
axel@0
   220
10 noop $distrib source.cal src_theta src_phi -rx 90 -ry -90 -mx
axel@0
   221
0
axel@0
   222
0
axel@0
   223
axel@0
   224
wdistrib illum willum
axel@0
   225
0
axel@0
   226
0
axel@0
   227
3 1 1 1
axel@0
   228
axel@0
   229
!gensurf willum wsource "$wwidth*t" $bdepth "$wheight*s" $wsgrid[2] $wsgrid[1]
axel@0
   230
_EOF_
axel@0
   231
if ( $status ) goto error
axel@0
   232
axel@0
   233
#	Send window
axel@0
   234
xform -rz $worient $descrip
axel@0
   235
if ( $status ) goto error
axel@0
   236
axel@0
   237
#	All done, print and exit
axel@0
   238
rm -f $remove
axel@0
   239
exit 0
axel@0
   240
axel@0
   241
#	Error exit
axel@0
   242
error:
axel@0
   243
	rm -f $removerr
axel@0
   244
	exit 1