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