ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/optics2rad.csh
Revision: 2.2
Committed: Fri May 19 21:33:12 2006 UTC (17 years, 10 months ago) by greg
Content type: application/x-csh
Branch: MAIN
CVS Tags: rad3R8, rad3R9
Changes since 2.1: +5 -4 lines
Log Message:
Preserve comments and ignore DOS carriage returns

File Contents

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