1 |
greg |
2.1 |
#!/bin/csh -f |
2 |
greg |
2.4 |
# RCSid $Id: fieldcomb.csh,v 2.3 2005/09/02 14:43:43 greg Exp $ |
3 |
greg |
2.1 |
# |
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 |
greg |
2.3 |
# Written by Greg Ward for Iebele Abel in August 2005 |
12 |
greg |
2.1 |
# |
13 |
|
|
set spare_name=spare_fieldcomb_frame.pic |
14 |
greg |
2.3 |
set odd_first=0 |
15 |
|
|
while ($#argv > 1) |
16 |
|
|
switch ($argv[1]) |
17 |
|
|
case -r*: |
18 |
greg |
2.1 |
set remove_orig |
19 |
greg |
2.3 |
breaksw |
20 |
|
|
case -o*: |
21 |
|
|
set odd_first=1 |
22 |
|
|
breaksw |
23 |
|
|
case -e*: |
24 |
|
|
set odd_first=0 |
25 |
|
|
breaksw |
26 |
|
|
default: |
27 |
|
|
if ("$argv[1]" !~ -*) break |
28 |
|
|
echo "Unknown option: $argv[1]" |
29 |
|
|
exit 1 |
30 |
|
|
endsw |
31 |
|
|
shift argv |
32 |
|
|
end |
33 |
greg |
2.1 |
if ($#argv < 2) then |
34 |
greg |
2.3 |
echo "Usage: $0 [-e|-o][-r] field1.pic field2.pic .." |
35 |
greg |
2.1 |
exit 1 |
36 |
|
|
endif |
37 |
|
|
set f1=$argv[1]:q |
38 |
|
|
set ext=$f1:e |
39 |
|
|
set basenm="`echo $f1:q | sed 's/[0-9]*\.'$ext'//'`" |
40 |
|
|
set curfi=`echo $f1:q | sed 's/^[^1-9]*\(.[0-9]*\)\.'$ext'$/\1/'` |
41 |
|
|
set fields=($argv[*]:q) |
42 |
|
|
if (-r $spare_name) then |
43 |
|
|
set fields=($spare_name $fields:q) |
44 |
|
|
@ curfi-- |
45 |
|
|
endif |
46 |
|
|
@ curfr = $curfi / 2 |
47 |
|
|
set curfi=1 |
48 |
|
|
while ($curfi < $#fields) |
49 |
|
|
@ nextfi = $curfi + 1 |
50 |
greg |
2.4 |
if ($curfr < 10) then |
51 |
|
|
set fid=000$curfr |
52 |
|
|
else if ($curfr < 100) then |
53 |
|
|
set fid=00$curfr |
54 |
|
|
else if ($curfr < 1000) then |
55 |
|
|
set fid=0$curfr |
56 |
|
|
else |
57 |
|
|
set fid=$curfr |
58 |
|
|
endif |
59 |
greg |
2.2 |
pcomb -e 'ro=ri(fld); go=gi(fld); bo=bi(fld)' \ |
60 |
|
|
-e 'yd=yres-1-y; odd=.5*yd-floor(.5*yd)-.25' \ |
61 |
greg |
2.3 |
-e "fld=if(odd,2-$odd_first,1+$odd_first)" \ |
62 |
greg |
2.1 |
$fields[$curfi]:q $fields[$nextfi]:q \ |
63 |
greg |
2.4 |
> "${basenm}C$fid.$ext" |
64 |
greg |
2.1 |
if ($?remove_orig) rm $fields[$curfi]:q $fields[$nextfi]:q |
65 |
|
|
@ curfr++ |
66 |
|
|
@ curfi = $nextfi + 1 |
67 |
|
|
end |
68 |
|
|
rm -f $spare_name |
69 |
|
|
if ($curfi == $#fields) ln "${basenm}$curfi.$ext" $spare_name |