Rev 18461 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
16886 | bpr | 1 | !if $wims_read_parm!=slib_header |
2 | !goto proc |
||
3 | !endif |
||
4 | slib_title=Conversion d'un dessin 2D codé dans la syntaxe off en canvasdraw |
||
5 | slib_author=Bernadette, Perrin-Riou |
||
6 | slib_parms=3\ |
||
7 | ,coordonnées des sommets : [coord,legende;...;coord,legende]\ |
||
8 | ,liste des faces: [nombre de sommets, liste des sommets,legende],...,[nombre de sommets, liste des sommets,legende]\ |
||
17189 | bpr | 9 | size=500,option (mots) : size= color=[couleur générale;numero d'une face, couleur;...] zoom vertex_legend face_legend pour afficher les légendes\ |
16886 | bpr | 10 | |
16944 | bpr | 11 | slib_out=dessin donné par un fichier de type presque off (en dimension 2),\ |
12 | (version préliminaire, la syntaxe peut changer). |
||
16886 | bpr | 13 | |
16944 | bpr | 14 | slib_comment=numérotation des sommets à partir de 0,\ |
15 | si une seule couleur, la même couleur pour toutes les faces.\ |
||
16 | la taille est prise pour la hauteur en pixels. |
||
16886 | bpr | 17 | |
16944 | bpr | 18 | |
16889 | bpr | 19 | ce n'est pas tout à fait off: rajouter un 0 pour avoir trois composantes dans les points |
20 | Il manque aussi la ligne sur le nombre de sommets faces aretes |
||
17189 | bpr | 21 | slib_example=[0,0,S1;1,1,S2;1,0,S3;2,1,S4],[[3,0,1,2,A1],[3,1,2,3,A2]], zoom vertex_legend size=200 color=[red;1,blue] html\ |
16944 | bpr | 22 | [0,0,V1;1,1,V2;1,0;2,1,V4],[[3,0,1,2,B1],[3,1,2,3]],face_legend html\ |
23 | [0,0,11;1,1,22;1,0,33;2,1,44],[[3,0,1,2,B1],[3,1,2,3]],vertex_legend=[2,A;3,B] html\ |
||
24 | [0,0,S1;1,1,S2;1,0,S3;2,1,S4],[[3,0,1,2,A1],[3,1,2,3,A2]]\ |
||
17224 | bpr | 25 | [0,0,S1;1,1,S2;1,0,S3;2,0,S4;1,-1,S5],[[3,0,1,2,A1],[3,1,2,3,A2],[3,0,2,4,A3],[3,3,2,4,A4]],html face_legend color=[red;2,green;3,blue]\ |
26 | [0,0,S1;1,1,S2;1,0,S3;2,0,S4;1,-1,S5],[[3,0,1,2,A1],[3,1,2,3,A2],[3,0,2,4,A3],[3,3,2,4,A4]],tikz face_legend color=[red;2,green;3,blue]\ |
||
27 | [-0.707,-0.408,7;0.707,-0.408,8;0.E-19,0.816,11;-1.93,0.299,3;-1.22,1.52,6;-1.93,-1.12,0;-3.35,0.299,2;-3.35,-1.12,1;-1.22,-2.34,4;5.42 E-20,-1.63,8;-1.36 E-19,2.23,10;-1.93,2.75,2;-0.707,3.46,5;-1.93,4.16,1;1.63 E-19,4.68,9;-1.22,5.39,4;2.17 E-19,6.09,8;1.41,4.68,10;1.41,6.09,11;-2.64,-2.34,4;-2.64,1.52,2;0.707,3.46,5],[[4,3,6,7,5],[4,5,8,9,0],[4,13,12,14,15],[4,11,4,10,12],[4,3,0,2,4],[4,16,14,17,18],[3,5,7,19],[3,13,11,12],[3,20,3,4],[3,3,5,0],[3,15,14,16],[3,21,17,14],[3,4,2,10],[3,0,1,2]], tikz face_legend\ |
||
28 | [-0.707,-0.408,7;0.707,-0.408,8;0.E-19,0.816,11;-1.93,0.299,3;-1.22,1.52,6;-1.93,-1.12,0;-3.35,0.299,2;-3.35,-1.12,1;-1.22,-2.34,4;5.42 E-20,-1.63,8;-1.36 E-19,2.23,10;-1.93,2.75,2;-0.707,3.46,5;-1.93,4.16,1;1.63 E-19,4.68,9;-1.22,5.39,4;2.17 E-19,6.09,8;1.41,4.68,10;1.41,6.09,11;-2.64,-2.34,4;-2.64,1.52,2;0.707,3.46,5],[[4,3,6,7,5],[4,5,8,9,0],[4,13,12,14,15],[4,11,4,10,12],[4,3,0,2,4],[4,16,14,17,18],[3,5,7,19],[3,13,11,12],[3,20,3,4],[3,3,5,0],[3,15,14,16],[3,21,17,14],[3,4,2,10],[3,0,1,2]], html face_legend\ |
||
16944 | bpr | 29 | [-0.707,-0.408,7;0.707,-0.408,8;0.E-19,0.816,11;-1.93,0.299,3;-1.22,1.52,6;-1.93,-1.12,0;-3.35,0.299,2;-3.35,-1.12,1;-1.22,-2.34,4;5.42 E-20,-1.63,8;-1.36 E-19,2.23,10;-1.93,2.75,2;-0.707,3.46,5;-1.93,4.16,1;1.63 E-19,4.68,9;-1.22,5.39,4;2.17 E-19,6.09,8;1.41,4.68,10;1.41,6.09,11;-2.64,-2.34,4;-2.64,1.52,2;0.707,3.46,5],[[4,3,6,7,5],[4,5,8,9,0],[4,13,12,14,15],[4,11,4,10,12],[4,3,0,2,4],[4,16,14,17,18],[3,5,7,19],[3,13,11,12],[3,20,3,4],[3,3,5,0],[3,15,14,16],[3,21,17,14],[3,4,2,10],[3,0,1,2]],color=[grey;2,red;7,blue] html\ |
17224 | bpr | 30 | [-0.707,-0.408,7;0.707,-0.408,8;0.E-19,0.816,11;-1.93,0.299,3;-1.22,1.52,6;-1.93,-1.12,0;-3.35,0.299,2;-3.35,-1.12,1;-1.22,-2.34,4;5.42 E-20,-1.63,8;-1.36 E-19,2.23,10;-1.93,2.75,2;-0.707,3.46,5;-1.93,4.16,1;1.63 E-19,4.68,9;-1.22,5.39,4;2.17 E-19,6.09,8;1.41,4.68,10;1.41,6.09,11;-2.64,-2.34,4;-2.64,1.52,2;0.707,3.46,5],[[4,3,6,7,5],[4,5,8,9,0],[4,13,12,14,15],[4,11,4,10,12],[4,3,0,2,4],[4,16,14,17,18],[3,5,7,19],[3,13,11,12],[3,20,3,4],[3,3,5,0],[3,15,14,16],[3,21,17,14],[3,4,2,10],[3,0,1,2]],color=[yellow;1 3 4 5 6,red] html\ |
31 | [-0.707,-0.408,7;0.707,-0.408,8;0.E-19,0.816,11;-1.93,0.299,3;-1.22,1.52,6;-1.93,-1.12,0;-3.35,0.299,2;-3.35,-1.12,1;-1.22,-2.34,4;5.42 E-20,-1.63,8;-1.36 E-19,2.23,10;-1.93,2.75,2;-0.707,3.46,5;-1.93,4.16,1;1.63 E-19,4.68,9;-1.22,5.39,4;2.17 E-19,6.09,8;1.41,4.68,10;1.41,6.09,11;-2.64,-2.34,4;-2.64,1.52,2;0.707,3.46,5],[[4,3,6,7,5],[4,5,8,9,0],[4,13,12,14,15],[4,11,4,10,12],[4,3,0,2,4],[4,16,14,17,18],[3,5,7,19],[3,13,11,12],[3,20,3,4],[3,3,5,0],[3,15,14,16],[3,21,17,14],[3,4,2,10],[3,0,1,2]],color=[yellow;1 3 4 5 6,red] tikz |
||
16944 | bpr | 32 | |
16886 | bpr | 33 | !exit |
34 | |||
35 | :proc |
||
36 | !set wims_multiexec=$wims_multiexec pari |
||
17224 | bpr | 37 | !reset slib_option_som slib_option_face slib_vertex_legend slib_face_legend slib_dessin slib_som slib_face slib_out |
38 | !reset slib_face_legend_tikz slib_dessin_tikz slib_vertex_legend_tikz |
||
16886 | bpr | 39 | !distribute items $wims_read_parm into slib_som, slib_face, slib_option |
40 | !distribute items 0,0,0,0 into slib_xrange1,slib_xrange2,slib_yrange1,slib_yrange2 |
||
41 | !set slib_size=!getopt size in $slib_option |
||
42 | !default slib_size=500 |
||
43 | !set slib_color=!getopt color in $slib_option |
||
44 | |||
45 | !set slib_som=!declosing $slib_som |
||
46 | !set slib_somcnt=!itemcnt $(slib_som[;1]) |
||
47 | !if vertex_legend isin $slib_option |
||
16912 | bpr | 48 | slib_option_som=all |
16886 | bpr | 49 | !endif |
17189 | bpr | 50 | !if zoom isin $slib_option |
51 | slib_zoom=zoom blue |
||
52 | !endif |
||
16912 | bpr | 53 | !set slib_tmp=!getopt vertex_legend in $slib_option |
16917 | bpr | 54 | !if $slib_tmp!=$empty and $slib_tmp!=vertex_legend |
16912 | bpr | 55 | slib_option_som=$slib_tmp |
56 | !reset sib_tmp |
||
57 | !endif |
||
16886 | bpr | 58 | !if face_legend isin $slib_option |
16917 | bpr | 59 | slib_option_face=all |
16886 | bpr | 60 | !endif |
16912 | bpr | 61 | !set slib_tmp=!getopt face_legend in $slib_option |
16917 | bpr | 62 | !if $slib_tmp!=$empty and $slib_tmp!=face_legend |
16912 | bpr | 63 | slib_option_face=$slib_tmp |
64 | !reset sib_tmp |
||
65 | !endif |
||
16886 | bpr | 66 | |
67 | !set slib_face=!declosing $slib_face |
||
68 | !set slib_facecnt=!itemcnt $(slib_face) |
||
16912 | bpr | 69 | |
16886 | bpr | 70 | !for slib_j=1 to $slib_somcnt |
71 | !set slib_xrange1=$[min($slib_xrange1,$(slib_som[$slib_j;1]))] |
||
72 | !set slib_xrange2=$[max($slib_xrange2,$(slib_som[$slib_j;1]))] |
||
73 | !set slib_yrange1=$[min($slib_yrange1,$(slib_som[$slib_j;2]))] |
||
74 | !set slib_yrange2=$[max($slib_yrange2,$(slib_som[$slib_j;2]))] |
||
16912 | bpr | 75 | !if $slib_option_som!=$empty |
16917 | bpr | 76 | !if $(slib_som[$slib_j;3])!=$empty and ($slib_j isitemof $(slib_option_som[;1]) or $slib_option_som=all) |
77 | !set slib_tmp=!select $slib_option_som where column 1 = $slib_j |
||
78 | !set slib_tmp=$(slib_tmp[2]) |
||
79 | !if $slib_tmp= |
||
80 | !set slib_tmp=$(slib_som[$slib_j;3]) |
||
81 | !endif |
||
16886 | bpr | 82 | !set slib_vertex_legend=!append line centered\ |
16917 | bpr | 83 | text black,$(slib_som[$slib_j;1,2]),large,$(slib_tmp)\ |
16886 | bpr | 84 | to $slib_vertex_legend |
17224 | bpr | 85 | !if tikz isin $slib_option |
17225 | bpr | 86 | !set slib_vertex_legend_tikz=!append line \node at ($(slib_som[$slib_j;1,2])) () {\($(slib_tmp)\)};\ |
17224 | bpr | 87 | to $slib_vertex_legend_tikz |
88 | !endif |
||
16917 | bpr | 89 | !reset slib_tmp |
16886 | bpr | 90 | !endif |
91 | !endif |
||
92 | !next |
||
18461 | bpr | 93 | !for slib_k=1 to $slib_facecnt |
17224 | bpr | 94 | !reset slib_coord slib_tmp_face |
18461 | bpr | 95 | !set slib_ff=!declosing $(slib_face[$slib_k]) |
96 | !for slib_t=2 to $(slib_ff[1])+1 |
||
97 | !set slib_coord=!append semicolon $(slib_som[$(slib_ff[$slib_t])+1;1,2]) to $slib_coord |
||
16886 | bpr | 98 | !next |
17224 | bpr | 99 | !if tikz iswordof $slib_option |
100 | !set slib_coord_tikz=!replace internal ; by ) -- ( in ($slib_coord;$(slib_coord[;1,2])) |
||
101 | !endif |
||
16886 | bpr | 102 | !set slib_coord=!replace internal ; by , in $slib_coord |
18461 | bpr | 103 | !if $slib_option_face!=$empty and ($slib_k isitemof $slib_option_face or $slib_option_face=all) |
16886 | bpr | 104 | !set slib_facemid=!exec pari v=[$slib_coord];[sum(j=1,#v/2,v[2*j-1]),sum(j=1,#v/2,v[2*j])]/#v*2 |
18461 | bpr | 105 | !if $(slib_ff[$(slib_ff[1])+2])!=$empty |
106 | !set slib_tmp_face=$(slib_ff[$(slib_ff[1])+2]) |
||
17224 | bpr | 107 | !endif |
18461 | bpr | 108 | !default slib_tmp_face=$slib_k |
17224 | bpr | 109 | !set slib_face_legend=!append line text black,$slib_facemid,large,$slib_tmp_face \ |
16886 | bpr | 110 | to $slib_face_legend |
17224 | bpr | 111 | !if tikz iswordof $slib_option |
112 | !set slib_face_legend_tikz=!append line \node at ($slib_facemid) () {$slib_tmp_face};\ |
||
113 | to $slib_face_legend_tikz |
||
114 | !endif |
||
16886 | bpr | 115 | !endif |
116 | !endif |
||
18461 | bpr | 117 | !set slib_tmp=!select $slib_color where $slib_k iswordof column 1 |
16886 | bpr | 118 | !if $slib_tmp=$empty |
119 | !set slib_tmp=$(slib_color[1;]) |
||
120 | !else |
||
121 | !set slib_tmp=$(slib_tmp[2]) |
||
122 | !endif |
||
123 | !set slib_dessin=!append line polygon black, $slib_coord,$(slib_coord[1,2])\ |
||
124 | to $slib_dessin |
||
16917 | bpr | 125 | !if $slib_tmp!=$empty |
16886 | bpr | 126 | !set slib_dessin=!append line fpolygon $slib_tmp, $slib_coord,$(slib_coord[1,2])\ |
127 | to $slib_dessin |
||
128 | !endif |
||
17224 | bpr | 129 | !if tikz iswordof $slib_option |
130 | !if $slib_tmp!=$empty |
||
131 | !set slib_dessin_tikz=!append line \draw[fill=$slib_tmp] $slib_coord_tikz; to $slib_dessin_tikz |
||
132 | !else |
||
18485 | bpr | 133 | !set slib_dessin_tikz=!append line \draw[line width=0.5mm] $slib_coord_tikz; to $slib_dessin_tikz |
17224 | bpr | 134 | !endif |
135 | !endif |
||
16886 | bpr | 136 | !next |
137 | !set slib_xrange1=$[$slib_xrange1-0.5] |
||
138 | !set slib_xrange2=$[$slib_xrange2+0.5] |
||
139 | !set slib_yrange1=$[$slib_yrange1-0.5] |
||
140 | !set slib_yrange2=$[$slib_yrange2+0.5] |
||
141 | |||
142 | !set slib_ratio=$[($slib_yrange2-$slib_yrange1)/($slib_xrange2-$slib_xrange1)] |
||
143 | !!!if $slib_ratio>1 |
||
144 | !!!set insdraw_size=$slib_size,$[rint($slib_size*$slib_ratio)] |
||
145 | !!!else |
||
146 | !set insdraw_size=$[rint($slib_size/$slib_ratio)],$slib_size |
||
147 | !!!endif |
||
17224 | bpr | 148 | !if tikz iswordof $slib_option |
149 | !set slib_tex=\begin{center}\ |
||
150 | \begin{tikzpicture}[scale=1]\ |
||
151 | $slib_dessin_tikz\ |
||
152 | $slib_face_legend_tikz\ |
||
153 | $slib_vertex_legend_tikz\ |
||
154 | \end{tikzpicture}\ |
||
155 | \end{center} |
||
156 | !set slib_out=$slib_out\ |
||
157 | $slib_tex |
||
158 | !else |
||
159 | slib_out=size $insdraw_size\ |
||
160 | xrange $slib_xrange1,$slib_xrange2\ |
||
161 | yrange $slib_yrange1,$slib_yrange2\ |
||
162 | $slib_dessin\ |
||
163 | fontsize 10\ |
||
164 | $slib_vertex_legend\ |
||
165 | $slib_face_legend |
||
166 | !if html iswordof $slib_option |
||
167 | slib_out=!exec canvasdraw $slib_out\ |
||
168 | $slib_zoom |
||
169 | !endif |
||
16912 | bpr | 170 | !endif |