| author | Axel Jacobs <axel@jaloxa.eu> |
| Sat, 09 Apr 2011 17:55:16 +0100 | |
| changeset 0 | 0aa115157c9c |
| permissions | -rw-r--r-- |
|
0
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
1 |
#!/bin/csh -f |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
2 |
# RCSid: $Id: genbackg.csh,v 2.2 2008/08/25 04:50:32 greg Exp $ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
3 |
# |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
4 |
# Generate height field to surround a mesh with an irregular border |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
5 |
# |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
6 |
# 4/16/2002 Greg Ward |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
7 |
# |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
8 |
if ( $#argv < 3 ) goto userr |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
9 |
# Get arguments |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
10 |
set mat = $1 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
11 |
set nam = $2 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
12 |
set mesh = $3 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
13 |
# Get options |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
14 |
set smooth="" |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
15 |
set i = 4 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
16 |
while ( $i <= $#argv ) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
17 |
switch ($argv[$i]) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
18 |
case -c: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
19 |
@ i++ ; set a=$i |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
20 |
@ i++ ; set b=$i |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
21 |
@ i++ ; set c=$i |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
22 |
set c00=($argv[$a] $argv[$b] $argv[$c]) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
23 |
@ i++ ; set a=$i |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
24 |
@ i++ ; set b=$i |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
25 |
@ i++ ; set c=$i |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
26 |
set c01=($argv[$a] $argv[$b] $argv[$c]) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
27 |
@ i++ ; set a=$i |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
28 |
@ i++ ; set b=$i |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
29 |
@ i++ ; set c=$i |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
30 |
set c11=($argv[$a] $argv[$b] $argv[$c]) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
31 |
@ i++ ; set a=$i |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
32 |
@ i++ ; set b=$i |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
33 |
@ i++ ; set c=$i |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
34 |
set c10=($argv[$a] $argv[$b] $argv[$c]) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
35 |
unset a b c |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
36 |
breaksw |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
37 |
case -r: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
38 |
@ i++ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
39 |
set step = $argv[$i] |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
40 |
breaksw |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
41 |
case -b: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
42 |
@ i++ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
43 |
set bord = $argv[$i] |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
44 |
breaksw |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
45 |
case -s: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
46 |
set smooth="-s" |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
47 |
breaksw |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
48 |
default: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
49 |
goto userr |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
50 |
endsw |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
51 |
@ i++ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
52 |
end |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
53 |
# Get corner points |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
54 |
set lim=(`getbbox -h $mesh`) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
55 |
if (! $?bord ) then |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
56 |
set bord=`ev "($lim[2]-$lim[1]+$lim[4]-$lim[3])/20"` |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
57 |
endif |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
58 |
if (! $?c00 ) then |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
59 |
set c00=(`ev "$lim[1]-$bord" "$lim[3]-$bord" "($lim[5]+$lim[6])/2"`) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
60 |
set c01=(`ev "$lim[2]+$bord" "$lim[3]-$bord" "($lim[5]+$lim[6])/2"`) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
61 |
set c10=(`ev "$lim[1]-$bord" "$lim[4]+$bord" "($lim[5]+$lim[6])/2"`) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
62 |
set c11=(`ev "$lim[2]+$bord" "$lim[4]+$bord" "($lim[5]+$lim[6])/2"`) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
63 |
endif |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
64 |
# Get mesh resolution |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
65 |
if (! $?step ) then |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
66 |
set step=`ev "sqrt(($c11[1]-$c00[1])*($c11[1]-$c00[1])+($c11[2]-$c00[2])*($c11[2]-$c00[2]))/70"` |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
67 |
endif |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
68 |
set res=(`ev "ceil(sqrt(($c01[1]-$c00[1])*($c01[1]-$c00[1])+($c01[2]-$c00[2])*($c01[2]-$c00[2]))/$step)" "ceil(sqrt(($c10[1]-$c00[1])*($c10[1]-$c00[1])+($c10[2]-$c00[2])*($c10[2]-$c00[2]))/$step)"`) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
69 |
set edgef=`mktemp /tmp/edgerad.XXXXXX` |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
70 |
cat > $edgef << _EOF_ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
71 |
void sphere c00 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
72 |
0 0 4 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
73 |
$c00 .001 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
74 |
void sphere c01 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
75 |
0 0 4 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
76 |
$c01 .001 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
77 |
void sphere c10 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
78 |
0 0 4 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
79 |
$c10 .001 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
80 |
void sphere c11 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
81 |
0 0 4 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
82 |
$c11 .001 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
83 |
void cylinder ex0 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
84 |
0 0 7 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
85 |
$c00 $c10 .001 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
86 |
void cylinder ex1 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
87 |
0 0 7 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
88 |
$c01 $c11 .001 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
89 |
void cylinder ey0 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
90 |
0 0 7 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
91 |
$c00 $c01 .001 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
92 |
void cylinder ey1 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
93 |
0 0 7 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
94 |
$c10 $c11 .001 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
95 |
_EOF_ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
96 |
set meshcal=`mkdir /tmp/meshcal.XXXXXX` |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
97 |
cat > $meshcal << _EOF_ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
98 |
lerp(x,y0,y1):(1-x)*y0+x*y1; |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
99 |
and(a,b):if(a,b,-1); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
100 |
or(a,b):if(a,1,b); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
101 |
not(a):if(a,-1,1); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
102 |
max(a,b):if(a-b,a,b); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
103 |
min(a,b):if(a-b,b,a); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
104 |
EPS:1e-7; |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
105 |
XR:min(32,floor($res[1]/2)); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
106 |
YR:8; |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
107 |
eq(a,b):and(a-b+EPS,b-a+EPS); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
108 |
sumfun2x(f,y,x0,x1):if(x1-x0+EPS,f(x0,y)+sumfun2x(f,y,x0+1,x1),0); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
109 |
sumfun2(f,x0,x1,y0,y1):if(y1-y0+EPS, |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
110 |
sumfun2x(f,y0,x0,x1)+sumfun2(f,x0,x1,y0+1,y1), 0); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
111 |
xpos(xf,yf)=lerp(xf,lerp(yf,$c00[1],$c10[1]),lerp(yf,$c01[1],$c11[1])); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
112 |
ypos(xf,yf)=lerp(xf,lerp(yf,$c00[2],$c10[2]),lerp(yf,$c01[2],$c11[2])); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
113 |
onedge=or(or(eq(x,0),eq(x,xmax-1)),or(eq(y,0),eq(y,ymax-1))); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
114 |
z0:$lim[5]-$bord; |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
115 |
height(xo,yo)=z0+gi(1,xo,yo); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
116 |
maxwt(xo,yo):if(and(eq(xo,0),eq(yo,0)),100,1/(xo*xo+yo*yo)); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
117 |
wt(xo,yo)=if(height(xo,yo)-1e9, 0, maxwt(xo,yo)); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
118 |
wtv(xo,yo)=wt(xo,yo)*height(xo,yo); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
119 |
wts=sumfun2(wt,-XR,XR,-YR,YR); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
120 |
sum=sumfun2(wtv,-XR,XR,-YR,YR); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
121 |
inmesh=and(not(onedge),eq(sumfun2(wt,-1,1,-1,1),sumfun2(maxwt,-1,1,-1,1))); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
122 |
lo=if(inmesh,1e10,if(wts-EPS,sum/wts,($lim[5]+$lim[6])/2)); |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
123 |
_EOF_ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
124 |
# Generate height image |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
125 |
set meshoct=`/tmp/meshoct.XXXXXXX` |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
126 |
xform -m void $mesh | oconv - $edgef > $meshoct |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
127 |
set meshpic=`mktemp /tmp/meshpic.XXXXXX` |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
128 |
cnt $res[2] $res[1] \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
129 |
| rcalc -e 'sp=$2/'"($res[1]-1)" -e 'tp=1-$1/'"($res[2]-1)" \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
130 |
-f $meshcal -e "xp=xpos(sp,tp);yp=ypos(sp,tp)" \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
131 |
-e '$1=xp;$2=yp;$3=z0;$4=0;$5=0;$6=1' \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
132 |
| rtrace -w -faf -oL -x $res[1] -y $res[2] $meshoct \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
133 |
| pvalue -r -b -df > $meshpic |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
134 |
rm $edgef $meshoct |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
135 |
# Output mesh surround |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
136 |
cat << _EOF_ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
137 |
# $0 $argv[*] |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
138 |
# Corner points: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
139 |
# $c00 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
140 |
# $c01 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
141 |
# $c11 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
142 |
# $c10 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
143 |
_EOF_ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
144 |
pflip -v $meshpic \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
145 |
| pcomb -f $meshcal - \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
146 |
| pvalue -h -H -pG -d \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
147 |
| gensurf $mat $nam 'xpos(s,t)' 'ypos(s,t)' - \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
148 |
`ev $res[1]-1 $res[2]-1` \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
149 |
-e 'valid(xf,yf)=1e9-Z`SYS(xf,yf)' \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
150 |
-f $meshcal $smooth |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
151 |
rm $meshcal $meshpic |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
152 |
# All done -- exit |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
153 |
exit 0 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
154 |
# Usage error message |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
155 |
userr: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
156 |
echo Usage: $0 "mat name mesh_file [-c corners][-b bord_width][-r step_size][-s]" |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
157 |
exit 1 |