ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/optics2rad.csh
Revision: 2.3
Committed: Mon Aug 25 04:50:31 2008 UTC (16 years, 3 months ago) by greg
Content type: application/x-csh
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad4R2P2, rad5R0, rad5R1, rad4R2, rad4R1, rad4R0, rad4R2P1, rad5R3, HEAD
Changes since 2.2: +11 -9 lines
Log Message:
Made temporary files safe from malicious attackers

File Contents

# User Rev Content
1 greg 2.1 #!/bin/csh -f
2 greg 2.3 # RCSid $Id: optics2rad.csh,v 2.2 2006/05/19 21:33:12 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 greg 2.3 set optf=`mktemp /tmp/optfmt.XXXXXXX`
11     cat > $optf << '_EOF_'
12 greg 2.1 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 greg 2.2 sed -e '/^[^#]/d' -e '/^$/d' $*
38 greg 2.1
39 greg 2.3 set outf=`mktemp /tmp/outfmt.XXXXXX`
40     cat > $outf << '_EOF_'
41 greg 2.1
42     void glass $(name)
43     0
44     0
45     3 ${Rtn} ${Gtn} ${Btn}
46     '_EOF_'
47    
48 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)' \
49 greg 2.1 -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 greg 2.3 -i $optf -o $outf $*
54 greg 2.1
55 greg 2.3 cat > $outf << '_EOF_'
56 greg 2.1
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 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)' \
70 greg 2.1 -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 greg 2.3 -i $optf -o $outf $*
75 greg 2.1
76 greg 2.3 cat > $outf << '_EOF_'
77 greg 2.1
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 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)' \
91 greg 2.1 -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 greg 2.3 -i $optf -o $outf $*
96 greg 2.1
97 greg 2.3 rm -f $optf $outf