orig/optics2rad.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: optics2rad.csh,v 2.3 2008/08/25 04:50:31 greg Exp $
axel@0
     3
#
axel@0
     4
# Convert Optics 5 output to correct Radiance input
axel@0
     5
#
axel@0
     6
if ($#argv < 1) then
axel@0
     7
	echo "Usage: $0 optics.mat .."
axel@0
     8
	exit 1
axel@0
     9
endif
axel@0
    10
set optf=`mktemp /tmp/optfmt.XXXXXXX`
axel@0
    11
cat > $optf << '_EOF_'
axel@0
    12
void glass $(name)_glass
axel@0
    13
0
axel@0
    14
0
axel@0
    15
3 ${Rtn} ${Gtn} ${Btn}
axel@0
    16
axel@0
    17
void BRTDfunc $(name)_front
axel@0
    18
10
axel@0
    19
	${fRrho} ${fGrho} ${fBrho}
axel@0
    20
	${Rtau} ${Gtau} ${Btau}
axel@0
    21
     0 0 0
axel@0
    22
     .
axel@0
    23
0
axel@0
    24
9 0 0 0 0 0 0 0 0 0
axel@0
    25
axel@0
    26
void BRTDfunc $(name)_back
axel@0
    27
10
axel@0
    28
	${bRrho} ${bGrho} ${bBrho}
axel@0
    29
	${Rtau} ${Gtau} ${Btau}
axel@0
    30
     0 0 0
axel@0
    31
     .
axel@0
    32
0
axel@0
    33
9 0 0 0 0 0 0 0 0 0
axel@0
    34
'_EOF_'
axel@0
    35
axel@0
    36
echo "# Output generated by $0 from $*"
axel@0
    37
sed -e '/^[^#]/d' -e '/^$/d' $*
axel@0
    38
axel@0
    39
set outf=`mktemp /tmp/outfmt.XXXXXX`
axel@0
    40
cat > $outf << '_EOF_'
axel@0
    41
axel@0
    42
void glass $(name)
axel@0
    43
0
axel@0
    44
0
axel@0
    45
3 ${Rtn} ${Gtn} ${Btn}
axel@0
    46
'_EOF_'
axel@0
    47
axel@0
    48
rcalc -l -e 'abs(x):if(x,x,-x);and(a,b):if(a,b,a);not(x):if(x,-1,1)' \
axel@0
    49
	-e 'lum(r,g,b):.265*r+.670*g+.065*b' \
axel@0
    50
	-e 'trans=lum(Rtau,Gtau,Btau)' \
axel@0
    51
	-e 'rfront=lum(fRrho,fGrho,fBrho);rback=lum(bRrho,bGrho,bBrho)' \
axel@0
    52
	-e 'cond=0.005-abs(rfront-rback)' \
axel@0
    53
	-i $optf -o $outf $*
axel@0
    54
axel@0
    55
cat > $outf << '_EOF_'
axel@0
    56
axel@0
    57
void BRTDfunc $(name)
axel@0
    58
10
axel@0
    59
	rR_clear rG_clear rB_clear
axel@0
    60
	${Rtau}*tR_clear ${Gtau}*tG_clear ${Btau}*tB_clear
axel@0
    61
     0 0 0
axel@0
    62
     window.cal
axel@0
    63
0
axel@0
    64
15 0 0 0 0 0 0 0 0 0
axel@0
    65
	${fRrho} ${fGrho} ${fBrho}
axel@0
    66
	${bRrho} ${bGrho} ${bBrho}
axel@0
    67
'_EOF_'
axel@0
    68
axel@0
    69
rcalc -l -e 'abs(x):if(x,x,-x);and(a,b):if(a,b,a);not(x):if(x,-1,1)' \
axel@0
    70
	-e 'lum(r,g,b):.265*r+.670*g+.065*b' \
axel@0
    71
	-e 'trans=lum(Rtau,Gtau,Btau)' \
axel@0
    72
	-e 'rfront=lum(fRrho,fGrho,fBrho);rback=lum(bRrho,bGrho,bBrho)' \
axel@0
    73
	-e 'cond=and(trans-.645, not(0.005-abs(rfront-rback)))' \
axel@0
    74
	-i $optf -o $outf $*
axel@0
    75
axel@0
    76
cat > $outf << '_EOF_'
axel@0
    77
axel@0
    78
void BRTDfunc $(name)
axel@0
    79
10
axel@0
    80
	rR_bronze rG_bronze rB_bronze
axel@0
    81
	${Rtau}*tR_bronze ${Gtau}*tG_bronze ${Btau}*tB_bronze
axel@0
    82
     0 0 0
axel@0
    83
     window.cal
axel@0
    84
0
axel@0
    85
15 0 0 0 0 0 0 0 0 0
axel@0
    86
	${fRrho} ${fGrho} ${fBrho}
axel@0
    87
	${bRrho} ${bGrho} ${bBrho}
axel@0
    88
'_EOF_'
axel@0
    89
axel@0
    90
rcalc -l -e 'abs(x):if(x,x,-x);and(a,b):if(a,b,a);not(x):if(x,-1,1)' \
axel@0
    91
	-e 'lum(r,g,b):.265*r+.670*g+.065*b' \
axel@0
    92
	-e 'trans=lum(Rtau,Gtau,Btau)' \
axel@0
    93
	-e 'rfront=lum(fRrho,fGrho,fBrho);rback=lum(bRrho,bGrho,bBrho)' \
axel@0
    94
	-e 'cond=and(not(trans-.645), not(0.005-abs(rfront-rback)))' \
axel@0
    95
	-i $optf -o $outf $*
axel@0
    96
axel@0
    97
rm -f $optf $outf