File: pichi

package info (click to toggle)
mcl 1%3A14-137-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 10,704 kB
  • ctags: 5,125
  • sloc: ansic: 53,217; sh: 4,448; perl: 3,967; makefile: 422
file content (205 lines) | stat: -rwxr-xr-x 4,356 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#!/bin/bash

#  (C) Copyright 2007 Stijn van Dongen
 #
#  This file is part of MCL.  You can redistribute and/or modify MCL under the
#  terms of the GNU General Public License; either version 3 of the License or
#  (at your option) any later version.  You should have received a copy of the
#  GPL along with MCL, in the file COPYING.

# pichi -n "001 002 003 004 005 006" -i "9 7 6 5 4 3" -S 20 -X 100 -Y 100 -p llx=90 -p lly=90 -p urx=510 -p ury=510 -o t -p edge=3edge -t falkner.tab -c falkner.coords -b falkner

set -e
stem=mcl
base=""
fnout=t.ps
defopts=""
X=0
Y=0
scale=10
rot=0
fnmci=""
fntab=""
fncoords=""
clus=""

color=("1 0.3 0"   "1 0.5 0"   "1 0.6 0"   "1 0.7 0"   "1 0.8 0"   "1 0.9 0"   "1 1 0")


while getopts :s:b:t:c:o:f:c:n:m:i:X:Y:S:R:p:h opt
do
    case "$opt" in
    h)
      cat <<EOU
__[-b <base>   Expect <base>.coords <base>.tab <base>.mci
  [-s <stem>   Expect <stem>.3 <stem>.5 ...

 _[-f <fname>  Use (_f_lat) clustering in fname
| [-m <fname>  Use matrix in <fname>
|_[-c <fname>  coordinate file name
  [-t <fname>     tab file name

-n <n1 n2 n3>  3 5 7 et cetera    
-i <i1 i2 i3>  In the range 0..9
-o <fname>     Write to <fname>
-p key=val     clm ps -set parameters
-R num         rotate num degrees
-X <num>       x translate
-Y <num>       y translate
-S <num>       scale factor
EOU
      exit
      ;;
    b)
      base=$OPTARG
      ;;
    n)
      nums=($OPTARG)
      ;;
    f)
      clus=$OPTARG
      ;;
    t)
      fntab=$OPTARG
      ;;
    c)
      fncoords=$OPTARG
      ;;
    m)
      fnmci=$OPTARG
      ;;
    i)
      inward=($OPTARG)
      ;;
    s)
      stem=$OPTARG
      ;;
    o)
      fnout=$OPTARG
      ;;
    R)
      rot=$OPTARG
      ;;
    S)
      scale=$OPTARG
      ;;
    p)
      defopts="$defopts -def $OPTARG"
      ;;
    X)
      X=$OPTARG
      ;;
    Y)
      Y=$OPTARG
      ;;
    :) echo "Flag $OPTARG needs argument"
        exit 1;;
    ?) echo "Flag $OPTARG unknown"
        exit 1;;
   esac
done


if test ! "$fncoords"; then
   fncoords=$base.coords
fi
if test ! "$fnmci"; then
   fnmci=$base.mci
fi
if test ! "$fntab"; then
   fntab=$base.tab
fi


clm ps $defopts -coords $fncoords -def edge=edge \
            -node-grey 0 -imx $fnmci --header -o $base.header

clm ps $defopts -coords $fncoords -def edge=edge \
            -node-grey 0 -imx $fnmci -o $base.include


if test "$clus"; then

   mcxdump -imx $clus --no-values --tabr=$fntab --dump-rlines    \
      | perl -pe 'print "\n";'                                   \
      | clmsnare --close --stroke --fncoords=$fncoords           \
            --inward=0.5 > $base.body

   echo "$X $Y translate" >> $base.header
   echo "$scale $scale scale" >> $base.header
   cat $base.header $base.include $base.body > $fnout
   exit 0
fi


for ((i=0;i<${#nums[*]};i++)); do
   n=${nums[$i]}
   j=${inward[$i]}
   c=${color[$i]}

   colorname=fill_lev$i''color

   echo "/$colorname [$c] def" >> $base.header
   echo "/fill_lev$i {" >> $base.header

   mcxdump -imx $stem.$n --no-values --tabr=$fntab --dump-rlines \
      | perl -pe 'print "\n";'                                   \
      | clmsnare --close --fill --fillcolor=$colorname           \
            --fncoords=$fncoords --inward=0.$j >> $base.header

   echo "} def" >> $base.header
done


for ((i=0;i<${#nums[*]};i++)); do
   n=${nums[$i]}
   j=${inward[$i]}
   c=${color[$i]}

   echo "/stroke_lev$i {" >> $base.header

   mcxdump -imx $stem.$n --no-values --tabr=$fntab --dump-rlines \
      | perl -pe 'print "\n";'                                   \
      | clmsnare --close --stroke --fncoords=$fncoords           \
            --inward=0.$j >> $base.header

   echo "} def" >> $base.header
done



fnthis=$fnout.b.ps
cat $base.header > $fnthis

echo "$X $Y translate" >> $fnthis
echo "$scale $scale scale" >> $fnthis


cat $base.include >> $fnthis
echo showpage >> $fnthis

for ((i=0;i<${#nums[*]};i++)); do

   fnthis=$fnout.$i.ps
   cat $base.header > $fnthis

   echo "$X $Y translate" >> $fnthis
   echo "$scale $scale scale" >> $fnthis

   for ((j=$i;j>=0;j--)); do
      echo fill_lev$j >> $fnthis
   done

   cat $base.include >> $fnthis

   for ((j=$i;j>=0;j--)); do
      echo stroke_lev$j >> $fnthis
   done

   echo showpage >> $fnthis
done

for ((i=0;i<${#nums[*]};i++)); do
   convert -rotate $rot $fnout.$i.ps $fnout.$i.png
done