ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/fieldcomb.csh
Revision: 2.7
Committed: Mon Nov 10 19:08:19 2008 UTC (15 years, 4 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.6: +3 -3 lines
Log Message:
Changed ".pic" extension to ".hdr" throughout

File Contents

# Content
1 #!/bin/csh -f
2 # RCSid $Id: fieldcomb.csh,v 2.6 2005/09/06 15:34:46 greg Exp $
3 #
4 # Combine alternate lines in full frames for field rendering
5 #
6 # Expects numbered frames on command line, as given by ranimate
7 #
8 # If an odd number of frames is provided, the spare frame at the
9 # end is linked to $spare_name for the next run
10 #
11 # Written by Greg Ward for Iebele Abel in August 2005
12 #
13 set spare_name=spare_fieldcomb_frame.hdr
14 set odd_first=0
15 while ($#argv > 1)
16 switch ($argv[1])
17 case -r*:
18 set remove_orig
19 breaksw
20 case -o*:
21 set odd_first=1
22 breaksw
23 case -e*:
24 set odd_first=0
25 breaksw
26 case -f*:
27 shift argv
28 set outfile="$argv[1]"
29 breaksw
30 default:
31 if ("$argv[1]" !~ -*) break
32 echo "Unknown option: $argv[1]"
33 exit 1
34 endsw
35 shift argv
36 end
37 if ($#argv < 2) then
38 echo "Usage: $0 [-e|-o][-r] [-f combined.hdr] field1.hdr field2.hdr .."
39 exit 1
40 endif
41 if ($?outfile && $#argv > 2) then
42 echo "Cannot use -f option with more than two input files"
43 exit 1
44 endif
45 set f1=$argv[1]:q
46 set ext=$f1:e
47 set basenm="`echo $f1:q | sed 's/[0-9]*\.'$ext'//'`"
48 set curfi=`echo $f1:q | sed 's/^[^1-9]*\(.[0-9]*\)\.'$ext'$/\1/'`
49 set fields=($argv[*]:q)
50 if (-r $spare_name) then
51 set fields=($spare_name $fields:q)
52 @ curfi--
53 endif
54 @ curfr = $curfi / 2
55 set curfi=1
56 while ($curfi < $#fields)
57 @ nextfi = $curfi + 1
58 if ($curfr < 10) then
59 set fid=000$curfr
60 else if ($curfr < 100) then
61 set fid=00$curfr
62 else if ($curfr < 1000) then
63 set fid=0$curfr
64 else
65 set fid=$curfr
66 endif
67 set outf="${basenm}C$fid.$ext"
68 if ($?outfile) then
69 set outf=$outfile:q
70 endif
71 pcomb -e 'ro=ri(fld); go=gi(fld); bo=bi(fld)' \
72 -e 'yd=yres-1-y; odd=.5*yd-floor(.5*yd)-.25' \
73 -e "fld=if(odd,2-$odd_first,1+$odd_first)" \
74 $fields[$curfi]:q $fields[$nextfi]:q \
75 > $outf:q
76 if ($?remove_orig) rm $fields[$curfi]:q $fields[$nextfi]:q
77 @ curfr++
78 @ curfi = $nextfi + 1
79 end
80 rm -f $spare_name
81 if ($curfi == $#fields) ln "${basenm}$curfi.$ext" $spare_name