ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/ra_pfm.csh
Revision: 2.3
Committed: Thu Dec 30 18:33:50 2004 UTC (19 years, 4 months ago) by greg
Content type: application/x-csh
Branch: MAIN
Changes since 2.2: +47 -12 lines
Log Message:
More improvements and bug fixes

File Contents

# User Rev Content
1 greg 2.1 #!/bin/csh -f
2 greg 2.3 # RCSid $Id: ra_pfm.csh,v 2.2 2004/12/25 04:14:25 greg Exp $
3 greg 2.1 #
4     # Convert to/from Poskanzer Float Map image format using pvalue
5     #
6     if (`uname -p` == powerpc) then
7 greg 2.3 set machend=big
8 greg 2.1 else
9 greg 2.3 set machend=little
10 greg 2.1 endif
11     while ($#argv > 0)
12     if ("$argv[1]" == "-r") then
13     set reverse
14 greg 2.3 else if (! $?inp) then
15     set inp="$argv[1]"
16     else if (! $?out) then
17     set out="$argv[1]"
18 greg 2.1 else
19 greg 2.3 goto userr
20 greg 2.1 endif
21     shift argv
22     end
23     if ($?reverse) then
24     if (! $?inp) then
25     goto userr
26     endif
27 greg 2.3 set opt=""
28 greg 2.1 set hl="`head -3 $inp:q`"
29 greg 2.3 if ("$hl[1]" == "Pf") then
30     set opt=($opt -b)
31     else if ("$hl[1]" != "PF") then
32 greg 2.1 echo "Input not a Poskanzer Float Map"
33     exit 1
34     endif
35 greg 2.3 if (`ev "if($hl[3],1,0)"`) then
36     set filend=big
37     else
38     set filend=little
39     endif
40     if ($filend != $machend) then
41     set opt=($opt -dF)
42     else
43     set opt=($opt -df)
44     endif
45 greg 2.1 set res=($hl[2])
46 greg 2.3 if ($?out) then
47     tail +4 $inp:q | pvalue -r -h $opt -y $res[2] +x $res[1] > $out:q
48     else
49     tail +4 $inp:q | pvalue -r -h $opt -y $res[2] +x $res[1]
50     endif
51 greg 2.1 exit $status
52     endif
53     if (! $?inp) then
54     goto userr
55     endif
56     set res=(`getinfo -d < $inp:q`)
57 greg 2.3 if ($?out) then
58     ( echo PF ; echo $res[4] $res[2] ) > $out:q
59     if ($machend == little) then
60     echo "-1.000000" >> $out:q
61     else
62     echo "1.000000" >> $out:q
63     endif
64     pvalue -h -H -df $inp:q >> $out:q
65     else
66     echo PF
67     echo $res[4] $res[2]
68     if ($machend == little) then
69     echo "-1.000000"
70     else
71     echo "1.000000"
72     endif
73     pvalue -h -H -df $inp:q
74     endif
75 greg 2.1 exit $status
76     userr:
77 greg 2.3 echo "Usage: $0 input.pfm [output.hdr]"
78     echo " or: $0 -r input.hdr [output.pfm]"
79 greg 2.1 exit 1