meshPolygon avec TikZ et ajout dotpoints comme option à tracePoints(TikZ et MP)
[delaunay.git] / luamesh.sty
1 \NeedsTeXFormat{LaTeX2e}%
2 \def\PackageName{luamesh}%
3 \def\fileversion{v0.2}%
4 \def\filedate{2016/11/29}%
5 \ProvidesPackage{luamesh}[\filedate\space\fileversion]%
6 %
7 % package to load
8 \RequirePackage{xkeyval,xcolor,ifthen}%
9 %% one global option: mp or tikz
10 %\newif\ifluameshmp%
11 %\define@key{luamesh.sty}{mp}[]{\luameshmptrue}%
12 %\define@key{luamesh.sty}{tikz}[]{\luameshmpfalse}%
13 %
14 %\RequirePackage{etoolbox} % pour robustifier les commandes
15 %
16 %
17 %\ifluameshmp%
18    \RequirePackage{luamplib}%
19 %\else%
20    \RequirePackage{tikz}%
21 %\fi%
22 %
23 % load the lua code
24 \directlua{require("luamesh.lua")}%
25 %
26 %%
27 % for tikz (default value)
28 % default color for the plot of a global mesh
29 \definecolor{TeXCluaMeshTikZ}{rgb}{0.,0.,0.}
30 % default color for a new element
31 \definecolor{TeXCluaMeshNewTikZ}{rgb}{0.5,0.1,0.1}
32 % defaut color for the background of new element
33 \definecolor{TeXCluaMeshBackTikZ}{rgb}{0.99,0.85,0.85}
34 % default color for circoncircle
35 \definecolor{TeXCluaMeshCircleTikZ}{rgb}{0.1,0.6,0.1}
36 %%
37 %
38 %%%%%%%%%%%%%%%% the buildMesh command inc
39 %% the user can write code (tikz or MP)
40 %% before and after the generated code
41 \define@boolkey{buildMeshInc}{tikz}[true]{}%
42 %% show the bounding box for delaunay
43 \define@choicekey*{buildMeshInc}{bbox}[\val\nr]{none, show}{%
44   \ifcase\nr\relax%
45   \def\luameshval@bmi@bbox{none}%
46   \or%
47   \def\luameshval@bmi@bbox{bbox}%
48   \fi%
49 }%
50 %% the scale
51 \define@key{buildMeshInc}{scale}[1cm]{\def\luameshval@bmi@scale{#1}}%
52 %% print ponits ?
53 \define@choicekey*{buildMeshInc}{print}[\val\nr]{none, points,dotpoints}{%
54   \ifcase\nr\relax%
55   \def\luameshval@bmi@print{none}%
56   \or%
57   \def\luameshval@bmi@print{points}%
58   \or%
59   \def\luameshval@bmi@print{dotpoints}%
60   \fi%
61 }%
62 %% the name of the point
63 \define@key{buildMeshInc}{meshpoint}[P]{\def\luameshval@bmi@meshpoint{#1}}%
64 %% the mode for reading the points
65 \define@choicekey*{buildMeshInc}{mode}[\val\nr]{int, ext}{%
66   \ifcase\nr\relax%
67   \def\luameshval@bmi@mode{int}%
68   \or%
69   \def\luameshval@bmi@mode{ext}%
70   \fi%
71 }%
72 %% the name of the color of drawing
73 \define@key{buildMeshInc}{color}[black]{\def\luameshval@bmi@color{#1}}%
74 %% the name of the color of drawing the bbox
75 \define@key{buildMeshInc}{colorBbox}[black]{\def\luameshval@bmi@colorbbox{#1}}%
76 %
77 \presetkeys{buildMeshInc}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
78 %
79 \newcommand*{\buildMeshBWinc}[4][]{%
80   % #1 : optionnal arguments
81   % #2 : the string containing the list of points
82   %      (x1,y1);(x2,y2);... or the name file containing the points
83   % #3 : the code to place before the generated one
84   % #4 : the code to place after the generated one
85   \setkeys{buildMeshInc}{#1} %
86   \def\MeshPoint{\luameshval@bmi@meshpoint}%
87   \ifKV@buildMeshInc@tikz% if we are using tikz
88   \directlua{%
89     buildMeshTikZBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bmi@mode","\luameshval@bmi@print","\luameshval@bmi@bbox","\luameshval@bmi@scale","\luameshval@bmi@color","\luameshval@bmi@colorbbox")%
90   }%
91   \else % we are using MP
92   \mplibcolor{\luameshmpcolor}{\luameshval@bmi@color}%
93   \mplibcolor{\luameshmpcolorBbox}{\luameshval@bmi@colorbbox}%
94   \directlua{%
95     buildMeshMPBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bmi@mode","\luameshval@bmi@print","\luameshval@bmi@bbox","\luameshval@bmi@scale")%
96   }%
97   %
98   \fi%
99 }%
100 %
101 %%%%%%%%%%%%%%%% the buildMeshBW command
102 %% the code is complete and we don't have any callbacks
103 \define@boolkey{buildMesh}{tikz}[true]{}%
104 %% show the bounding box for delaunay
105 \define@choicekey*{buildMesh}{bbox}[\val\nr]{none, show}{%
106   \ifcase\nr\relax%
107   \def\luameshval@bm@bbox{none}%
108   \or%
109   \def\luameshval@bm@bbox{bbox}%
110   \fi%
111 }%
112 %% the scale
113 \define@key{buildMesh}{scale}[1cm]{\def\luameshval@bm@scale{#1}}%
114 %% print points
115 \define@choicekey*{buildMesh}{print}[\val\nr]{none, points, dotpoints}{%
116   \ifcase\nr\relax%
117   \def\luameshval@bm@print{none}%
118   \or%
119   \def\luameshval@bm@print{points}%
120   \or%
121   \def\luameshval@bm@print{dotpoints}%
122   \fi%
123 }%
124 %% the name of the point
125 \define@key{buildMesh}{meshpoint}[P]{\def\luameshval@bm@meshpoint{#1}}%
126 %% the mode for reading the points
127 \define@choicekey*{buildMesh}{mode}[\val\nr]{int, ext}{%
128   \ifcase\nr\relax%
129   \def\luameshval@bm@mode{int}%
130   \or%
131   \def\luameshval@bm@mode{ext}%
132   \fi%
133 }%
134 %% the name of the color of drawing
135 \define@key{buildMesh}{color}[black]{\def\luameshval@bm@color{#1}}%
136 %% the name of the color of drawing the bbox
137 \define@key{buildMesh}{colorBbox}[black]{\def\luameshval@bm@colorbbox{#1}}%
138 %
139 \presetkeys{buildMesh}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
140 %
141 \newcommand{\buildMeshBW}[2][]{%
142   % #1 : optionnal arguments
143   % #2 : the string containing the list of points
144   % (x1,y1);(x2,y2);... or the name file containing the points
145   \setkeys{buildMesh}{#1} %
146   \def\MeshPoint{\luameshval@bm@meshpoint}%
147   \ifKV@buildMesh@tikz% if we are using tikz
148   \directlua{%
149     buildMeshTikZBW("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","\luameshval@bm@scale","\luameshval@bm@color","\luameshval@bm@colorbbox")%
150   }%
151   \else % we are using MP
152   \mplibcolor{\luameshmpcolor}{\luameshval@bm@color}%
153   \mplibcolor{\luameshmpcolorBbox}{\luameshval@bm@colorbbox}%
154   \directlua{%
155     buildMeshMPBW("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","\luameshval@bm@scale")%
156   }%
157   %
158   \fi%
159 }%
160 %%%%%%%%%%%%%%%% the buildVoronoi command
161 %% the user can write code (tikz or MP)
162 %% before and after the generated code
163 \define@boolkey{buildVoronoiInc}{tikz}[true]{}%
164 %% show the bounding box for delaunay
165 \define@choicekey*{buildVoronoiInc}{bbox}[\val\nr]{none, show}{%
166   \ifcase\nr\relax%
167   \def\luameshval@bvi@bbox{none}%
168   \or%
169   \def\luameshval@bvi@bbox{bbox}%
170   \fi%
171 }%
172 %% the scale
173 \define@key{buildVoronoiInc}{scale}[1cm]{\def\luameshval@bvi@scale{#1}}%
174 %% print ponits ?
175 \define@choicekey*{buildVoronoiInc}{print}[\val\nr]{none, points}{%
176   \ifcase\nr\relax%
177   \def\luameshval@bvi@print{none}%
178   \or%
179   \def\luameshval@bvi@print{points}%
180   \fi%
181 }%
182 %% style dashed Delaunay
183 \define@choicekey*{buildVoronoiInc}{styleDelaunay}[\val\nr]{none, dashed}{%
184   \ifcase\nr\relax%
185   \def\luameshval@bvi@styleDelaunay{none}%
186   \or%
187   \def\luameshval@bvi@styleDelaunay{dashed}%
188   \fi%
189 }%
190 %% style dashed Voronoi
191 \define@choicekey*{buildVoronoiInc}{styleVoronoi}[\val\nr]{none, dashed}{%
192   \ifcase\nr\relax%
193   \def\luameshval@bvi@styleVoronoi{none}%
194   \or%
195   \def\luameshval@bvi@styleVoronoi{dashed}%
196   \fi%
197 }%
198 %% the name of the point
199 \define@key{buildVoronoiInc}{meshpoint}[P]{\def\luameshval@bvi@meshpoint{#1}}%
200 %% the name of the circum point
201 \define@key{buildVoronoiInc}{circumpoint}[P]{\def\luameshval@bvi@circumpoint{#1}}%
202 %% the mode for reading the points
203 \define@choicekey*{buildVoronoiInc}{mode}[\val\nr]{int, ext}{%
204   \ifcase\nr\relax%
205   \def\luameshval@bvi@mode{int}%
206   \or%
207   \def\luameshval@bvi@mode{ext}%
208   \fi%
209 }%
210 %% the mode for reading the points
211 \define@choicekey*{buildVoronoiInc}{delaunay}[\val\nr]{none, show}{%
212   \ifcase\nr\relax%
213   \def\luameshval@bvi@delaunay{none}%
214   \or%
215   \def\luameshval@bvi@delaunay{show}%
216   \fi%
217 }%
218 %% the name of the color of drawing
219 \define@key{buildVoronoiInc}{color}[black]{\def\luameshval@bvi@color{#1}}%
220 %% the name of the color of drawing Voronoi
221 \define@key{buildVoronoiInc}{colorVoronoi}[red]{\def\luameshval@bvi@colorvoronoi{#1}}%
222 %% the name of the color of drawing the bbox
223 \define@key{buildVoronoiInc}{colorBbox}[black]{\def\luameshval@bvi@colorbbox{#1}}%
224 %
225 \presetkeys{buildVoronoiInc}{tikz=false,bbox=none,scale, meshpoint,circumpoint,mode=int,print=none,color,colorVoronoi,colorBbox,delaunay=none,styleDelaunay=none,styleVoronoi=none}{}%
226 %
227 \newcommand*{\buildVoronoiBWinc}[4][]{%
228   % #1 : optionnal arguments
229   % #2 : the string containing the list of points
230   % (x1,y1);(x2,y2);... or the name file containing the points
231   % #3 : the code to place before the generated one
232   % #4 : the code to place after the generated one
233   \setkeys{buildVoronoiInc}{#1} %
234   \def\MeshPoint{\luameshval@bvi@meshpoint}%
235   \def\CircumPoint{\luameshval@bvi@circumpoint}%
236   \ifKV@buildVoronoiInc@tikz% if we are using tikz
237   \directlua{%
238     buildVoronoiTikZBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bvi@mode","\luameshval@bvi@print","\luameshval@bvi@bbox","\luameshval@bvi@scale","\luameshval@bvi@delaunay","\luameshval@bvi@color","\luameshval@bvi@colorbbox","\luameshval@bvi@colorvoronoi","\luameshval@bvi@styleDelaunay","\luameshval@bvi@styleVoronoi")%
239   }%
240   \else % we are using MP
241   \mplibcolor{\luameshmpcolor}{\luameshval@bvi@color}%
242   \mplibcolor{\luameshmpcolorBbox}{\luameshval@bvi@colorbbox}%
243   \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@bvi@colorvoronoi}%
244   \directlua{%
245     buildVoronoiMPBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bvi@mode","\luameshval@bvi@print","\luameshval@bvi@bbox","\luameshval@bvi@scale","\luameshval@bvi@delaunay","\luameshval@bvi@styleDelaunay","\luameshval@bvi@styleVoronoi")%
246   }%
247   %
248   \fi%
249 }%
250 %
251 %%%%%%%%%%%%%%%% the buildVoronoiBW command
252 %% the code is complete and we don't have any callbacks
253 \define@boolkey{buildVoronoi}{tikz}[true]{}%
254 %% show the bounding box for delaunay
255 \define@choicekey*{buildVoronoi}{bbox}[\val\nr]{none, show}{%
256   \ifcase\nr\relax%
257   \def\luameshval@bv@bbox{none}%
258   \or%
259   \def\luameshval@bv@bbox{bbox}%
260   \fi%
261 }%
262 %% the scale
263 \define@key{buildVoronoi}{scale}[1cm]{\def\luameshval@bv@scale{#1}}%
264 %% print points
265 \define@choicekey*{buildVoronoi}{print}[\val\nr]{none, points}{%
266   \ifcase\nr\relax%
267   \def\luameshval@bv@print{none}%
268   \or%
269   \def\luameshval@bv@print{points}%
270   \fi%
271 }%
272 %% the name of the point
273 \define@key{buildVoronoi}{meshpoint}[P]{\def\luameshval@bv@meshpoint{#1}}%
274 %% the name of the circum point
275 \define@key{buildVoronoi}{circumpoint}[P]{\def\luameshval@bv@circumpoint{#1}}%
276 %% the mode for reading the points
277 \define@choicekey*{buildVoronoi}{mode}[\val\nr]{int, ext}{%
278   \ifcase\nr\relax%
279   \def\luameshval@bv@mode{int}%
280   \or%
281   \def\luameshval@bv@mode{ext}%
282   \fi%
283 }%
284 %% style dashed Delaunay
285 \define@choicekey*{buildVoronoi}{styleDelaunay}[\val\nr]{none, dashed}{%
286   \ifcase\nr\relax%
287   \def\luameshval@bv@styleDelaunay{none}%
288   \or%
289   \def\luameshval@bv@styleDelaunay{dashed}%
290   \fi%
291 }%
292 %% style dashed Voronoi
293 \define@choicekey*{buildVoronoi}{styleVoronoi}[\val\nr]{none, dashed}{%
294   \ifcase\nr\relax%
295   \def\luameshval@bv@styleVoronoi{none}%
296   \or%
297   \def\luameshval@bv@styleVoronoi{dashed}%
298   \fi%
299 }%
300 %% the mode for reading the points
301 \define@choicekey*{buildVoronoi}{delaunay}[\val\nr]{none, show}{%
302   \ifcase\nr\relax%
303   \def\luameshval@bv@delaunay{none}%
304   \or%
305   \def\luameshval@bv@delaunay{show}%
306   \fi%
307 }%
308 %% the name of the color of drawing
309 \define@key{buildVoronoi}{color}[black]{\def\luameshval@bv@color{#1}}%
310 %% the name of the color of drawing Voronoi
311 \define@key{buildVoronoi}{colorVoronoi}[red]{\def\luameshval@bv@colorVoronoi{#1}}%
312 %% the name of the color of drawing the bbox
313 \define@key{buildVoronoi}{colorBbox}[black]{\def\luameshval@bv@colorbbox{#1}}%
314 %
315 \presetkeys{buildVoronoi}{tikz=false,bbox=none,scale,
316   meshpoint,circumpoint,mode=int,print=none,color,colorVoronoi,colorBbox,delaunay=none,styleDelaunay=none, styleVoronoi=none}{}%
317 %
318 \newcommand{\buildVoronoiBW}[2][]{%
319   % #1 : optionnal arguments
320   % #2 : the string containing the list of points
321   % (x1,y1);(x2,y2);... or the name file containing the points
322   \setkeys{buildVoronoi}{#1} %
323   \def\MeshPoint{\luameshval@bv@meshpoint}%
324   \def\CircumPoint{\luameshval@bv@circumpoint}%
325   \ifKV@buildVoronoi@tikz% if we are using tikz
326   \directlua{%
327     buildVoronoiTikZBW("#2","\luameshval@bv@mode","\luameshval@bv@print","\luameshval@bv@bbox","\luameshval@bv@scale","\luameshval@bv@delaunay","\luameshval@bv@color","\luameshval@bv@colorbbox","\luameshval@bv@colorVoronoi","\luameshval@bv@styleDelaunay","\luameshval@bv@styleVoronoi")%
328   }%
329   \else % we are using MP
330   \mplibcolor{\luameshmpcolor}{\luameshval@bv@color}%
331   \mplibcolor{\luameshmpcolorBbox}{\luameshval@bv@colorbbox}%
332   \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@bv@colorVoronoi}%
333   \directlua{%
334     buildVoronoiMPBW("#2","\luameshval@bv@mode","\luameshval@bv@print","\luameshval@bv@bbox","\luameshval@bv@scale","\luameshval@bv@delaunay","\luameshval@bv@styleDelaunay","\luameshval@bv@styleVoronoi")%
335   }%
336   %
337   \fi%
338 }%
339 %
340 %
341 %%%%%%%%%%%%%%%%% the draw Points macro
342 %% plot the list of points given in argument
343 % the engine
344 \define@boolkey{drawPoints}{tikz}[true]{}%
345 %% show the bounding box for delaunay
346 \define@choicekey*{drawPoints}{bbox}[\val\nr]{none, show}{%
347   \ifcase\nr\relax%
348   \def\luameshval@tp@bbox{none}%
349   \or%
350   \def\luameshval@tp@bbox{bbox}%
351   \fi%
352 }%
353 %% the scale
354 \define@key{drawPoints}{scale}[1cm]{\def\luameshval@tp@scale{#1}}%
355 %% print points
356 \define@choicekey*{drawPoints}{print}[\val\nr]{none, points}{%
357   \ifcase\nr\relax%
358   \def\luameshval@tp@print{none}%
359   \or%
360   \def\luameshval@tp@print{points}%
361   \fi%
362 }%
363 %% the name of the point
364 \define@key{drawPoints}{meshpoint}[P]{\def\luameshval@tp@meshpoint{#1}}%
365 %% the mode for reading the points
366 \define@choicekey*{drawPoints}{mode}[\val\nr]{int, ext}{%
367   \ifcase\nr\relax%
368   \def\luameshval@tp@mode{int}%
369   \or%
370   \def\luameshval@tp@mode{ext}%
371   \fi%
372 }%
373 %% the name of the color of drawing
374 \define@key{drawPoints}{color}[black]{\def\luameshval@tp@color{#1}}%
375 %% the name of the color of drawing the bbox
376 \define@key{drawPoints}{colorBbox}[black]{\def\luameshval@tp@colorbbox{#1}}%
377 %
378 \presetkeys{drawPoints}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
379 %
380 \newcommand{\drawPointsMesh}[2][]{%
381   % #1 : optionnal arguments
382   % #2 : the string containing the list of points
383   % (x1,y1);(x2,y2);... or the name file containing the points
384   \setkeys{drawPoints}{#1} %
385   \def\MeshPoint{\luameshval@tp@meshpoint}%
386   \ifKV@drawPoints@tikz% if we are using tikz
387   \directlua{%
388     printPointsTikZ("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale","\luameshval@tp@color","\luameshval@tp@colorbbox")%
389   }%
390   \else % we are using MP
391   \mplibcolor{\luameshmpcolor}{\luameshval@tp@color}%
392   \mplibcolor{\luameshmpcolorBbox}{\luameshval@tp@colorbbox}%
393   \directlua{%
394     printPointsMP("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale")%
395   }%
396   %
397   \fi%
398 }%
399 %
400
401 %%%%%%%%%%%%%%%% the draw Points macro inc with callbacks
402 %% engine of drawing
403 \define@boolkey{drawPointsInc}{tikz}[true]{}%
404 %% show the bounding box for delaunay
405 \define@choicekey*{drawPointsInc}{bbox}[\val\nr]{none, show}{%
406   \ifcase\nr\relax%
407   \def\luameshval@tpi@bbox{none}%
408   \or%
409   \def\luameshval@tpi@bbox{bbox}%
410   \fi%
411 }%
412 %% the scale
413 \define@key{drawPointsInc}{scale}[1cm]{\def\luameshval@tpi@scale{#1}}%
414 %% print points
415 \define@choicekey*{drawPointsInc}{print}[\val\nr]{none, points}{%
416   \ifcase\nr\relax%
417   \def\luameshval@tpi@print{none}%
418   \or%
419   \def\luameshval@tpi@print{points}%
420   \fi%
421 }%
422 %% the name of the point
423 \define@key{drawPointsInc}{meshpoint}[P]{\def\luameshval@tpi@meshpoint{#1}}%
424 %% the mode for reading the points
425 \define@choicekey*{drawPointsInc}{mode}[\val\nr]{int, ext}{%
426   \ifcase\nr\relax%
427   \def\luameshval@tpi@mode{int}%
428   \or%
429   \def\luameshval@tpi@mode{ext}%
430   \fi%
431 }%
432 %
433 % color
434 %% the name of the color of drawing
435 \define@key{drawPointsInc}{color}[black]{\def\luameshval@tpi@color{#1}}%
436 %% the name of the color of drawing the bbox
437 \define@key{drawPointsInc}{colorBbox}[black]{\def\luameshval@tpi@colorbbox{#1}}%
438 %
439 \presetkeys{drawPointsInc}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
440 %
441 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
442 \newcommand*{\drawPointsMeshinc}[4][]{%
443   % #1 : optionnal arguments
444   % #2 : the string containing the list of points
445   % (x1,y1);(x2,y2);... or the name file containing the points
446   % #3 : the code to place before the generated one
447   % #4 : the code to place after the generated one
448   \setkeys{drawPointsInc}{#1} %
449   \def\MeshPoint{\luameshval@tpi@meshpoint}%
450   \ifKV@drawPointsInc@tikz% if we are using tikz
451   \directlua{%
452     printPointsTikZinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@tpi@mode","\luameshval@tpi@print","\luameshval@tpi@bbox","\luameshval@tpi@scale","\luameshval@tpi@color","\luameshval@tpi@colorbbox")%
453   }%
454   \else % we are using MP
455   \mplibcolor{\luameshmpcolor}{\luameshval@tpi@color}%
456   \mplibcolor{\luameshmpcolorBbox}{\luameshval@tpi@colorbbox}%
457   \directlua{%
458     printPointsMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@tpi@mode","\luameshval@tpi@print","\luameshval@tpi@bbox","\luameshval@tpi@scale")%
459   }%
460   \fi%
461 }%
462 %
463 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
464 %% the meshAddOnePointBW commande
465 %%engine of draiwng
466 \define@boolkey{MeshAddOneBW}{tikz}[true]{}%
467 %% the scale
468 \define@key{MeshAddOneBW}{scale}[1cm]{\def\luameshval@ap@scale{#1}}%
469 %% the name of the points
470 \define@key{MeshAddOneBW}{meshpoint}[P]{\def\luameshval@ap@meshpoint{#1}}%
471 %% the name of the new point
472 \define@key{MeshAddOneBW}{newpoint}[P]{\def\luameshval@ap@newpoint{#1}}%
473 %% a complete picture or some code of the engine
474 \define@choicekey*{MeshAddOneBW}{step}[\val\nr]{badtriangles, cavity, newtriangles}{%
475   \ifcase\nr\relax%
476   \def\luameshval@ap@step{badT}%
477   \or%
478   \def\luameshval@ap@step{cavity}%
479   \or%
480   \def\luameshval@ap@step{newT}%
481   \fi%
482 }%
483 % color
484 %% the color of drawing
485 \define@key{MeshAddOneBW}{color}[black]{\def\luameshval@ap@color{#1}}%
486 %% the color of background of new element
487 \define@key{MeshAddOneBW}{colorBack}[black!20]{\def\luameshval@ap@colorback{#1}}%
488 %% the color of new element
489 \define@key{MeshAddOneBW}{colorNew}[red]{\def\luameshval@ap@colornew{#1}}%
490 %% the color of circoncircle
491 \define@key{MeshAddOneBW}{colorCircle}[green]{\def\luameshval@ap@colorcircle{#1}}%
492 %% the name of the color of drawing the bbox
493 \define@key{MeshAddOneBW}{colorBbox}[black]{\def\luameshval@ap@colorbbox{#1}}%
494 %
495 %% a complete picture or some code of the engine
496 \define@choicekey*{MeshAddOneBW}{mode}[\val\nr]{int, ext}{%
497   \ifcase\nr\relax%
498   \def\luameshval@ap@mode{int}%
499   \or%
500   \def\luameshval@ap@mode{ext}%
501   \fi%
502 }%
503 \define@choicekey*{MeshAddOneBW}{bbox}[\val\nr]{none, show}{%
504   \ifcase\nr\relax%
505   \def\luameshval@ap@bbox{none}%
506   \or%
507   \def\luameshval@ap@bbox{bbox}%
508   \fi%
509 }%
510 \presetkeys{MeshAddOneBW}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}%
511 %
512 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
513 \newcommand*{\meshAddPointBW}[3][]{%
514   % #1 : optionnal arguments
515   % #2 : the string containing the list of points
516   % (x1,y1);(x2,y2);... or the name file containing the points
517   \setkeys{MeshAddOneBW}{#1} %
518   \def\MeshPoint{\luameshval@ap@meshpoint}%
519   \def\NewPoint{\luameshval@ap@newpoint}%
520   \ifKV@MeshAddOneBW@tikz% if we are using tikz
521   \directlua{%
522     TeXOnePointTikZBW("#2","#3","\luameshval@ap@step","\luameshval@ap@scale","\luameshval@ap@mode","\luameshval@ap@bbox","\luameshval@ap@color","\luameshval@ap@colorback","\luameshval@ap@colornew","\luameshval@ap@colorcircle","\luameshval@ap@colorbbox")%
523   }%
524   \else % we are using MP
525   \mplibcolor{\luameshmpcolor}{\luameshval@ap@color}
526   \mplibcolor{\luameshmpcolorBack}{\luameshval@ap@colorback}
527   \mplibcolor{\luameshmpcolorNew}{\luameshval@ap@colornew}
528   \mplibcolor{\luameshmpcolorCircle}{\luameshval@ap@colorcircle}
529   \mplibcolor{\luameshmpcolorBbox}{\luameshval@ap@colorbbox}
530   \directlua{%
531     TeXOnePointMPBW("#2","#3","\luameshval@ap@step","\luameshval@ap@scale","\luameshval@ap@mode","\luameshval@ap@bbox")%
532   }%
533   %
534   \fi%
535 }%
536 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
537 %%% the meshAddPointBWinc commande with callbacks
538 %% engine of drawing
539 \define@boolkey{MeshAddOneBWinc}{tikz}[true]{}%
540 %% the scale
541 \define@key{MeshAddOneBWinc}{scale}[1cm]{\def\luameshval@api@scale{#1}}%
542 %% the name of the points
543 \define@key{MeshAddOneBWinc}{meshpoint}[P]{\def\luameshval@api@meshpoint{#1}}%
544 %% the name of the new point
545 \define@key{MeshAddOneBWinc}{newpoint}[P]{\def\luameshval@api@newpoint{#1}}%
546 %% a complete picture or some code of the engine
547 \define@choicekey*{MeshAddOneBWinc}{step}[\val\nr]{badtriangles, cavity, newtriangles}{%
548   \ifcase\nr\relax%
549   \def\luameshval@api@step{badT}%
550   \or%
551   \def\luameshval@api@step{cavity}%
552   \or%
553   \def\luameshval@api@step{newT}%
554   \fi%
555 }%
556 % color
557 %% the color of drawing
558 \define@key{MeshAddOneBWinc}{color}[black]{\def\luameshval@api@color{#1}}%
559 %% the color of background of new element
560 \define@key{MeshAddOneBWinc}{colorBack}[black!20]{\def\luameshval@api@colorback{#1}}%
561 %% the color of new element
562 \define@key{MeshAddOneBWinc}{colorNew}[red]{\def\luameshval@api@colornew{#1}}%
563 %% the color of circoncircle
564 \define@key{MeshAddOneBWinc}{colorCircle}[green]{\def\luameshval@api@colorcircle{#1}}%
565 \define@key{MeshAddOneBWinc}{colorBbox}[black]{\def\luameshval@api@colorbbox{#1}}%
566 %
567 %% a complete picture or some code of the engine
568 \define@choicekey*{MeshAddOneBWinc}{mode}[\val\nr]{int, ext}{%
569   \ifcase\nr\relax%
570   \def\luameshval@api@mode{int}%
571   \or%
572   \def\luameshval@api@mode{ext}%
573   \fi%
574 }%
575 \define@choicekey*{MeshAddOneBWinc}{bbox}[\val\nr]{none, show}{%
576   \ifcase\nr\relax%
577   \def\luameshval@api@bbox{none}%
578   \or%
579   \def\luameshval@api@bbox{bbox}%
580   \fi%
581 }%
582 \presetkeys{MeshAddOneBWinc}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}%
583 %
584 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
585 \newcommand*{\meshAddPointBWinc}[5][]{%
586   % #1 : optionnal arguments
587   % #2 : the string containing the list of points
588   % (x1,y1);(x2,y2);... or the name file containing the points
589   % #3 : the code to place before the generated one
590   % #4 : the code to place after the generated one
591   \setkeys{MeshAddOneBWinc}{#1} %
592   \def\MeshPoint{\luameshval@api@meshpoint}%
593   \def\NewPoint{\luameshval@api@newpoint}%
594   \ifKV@MeshAddOneBWinc@tikz% if we are using tikz
595   \directlua{%
596     TeXOnePointTikZBWinc("#2","#3","\luaescapestring{\unexpanded{#4}}","\luaescapestring{\unexpanded{#5}}","\luameshval@ap@step","\luameshval@ap@scale","\luameshval@ap@mode","\luameshval@ap@bbox","\luameshval@ap@color","\luameshval@ap@colorback","\luameshval@ap@colornew","\luameshval@ap@colorcircle","\luameshval@ap@colorbbox")%
597   }%
598   \else % we are using MP
599   \mplibcolor{\luameshmpcolor}{\luameshval@api@color}
600   \mplibcolor{\luameshmpcolorBack}{\luameshval@api@colorback}
601   \mplibcolor{\luameshmpcolorNew}{\luameshval@api@colornew}
602   \mplibcolor{\luameshmpcolorCircle}{\luameshval@api@colorcircle}
603   \mplibcolor{\luameshmpcolorBbox}{\luameshval@api@colorbbox}
604   \directlua{%
605     TeXOnePointMPBWinc("#2","#3","\luaescapestring{\unexpanded{#4}}","\luaescapestring{\unexpanded{#5}}","\luameshval@api@step","\luameshval@api@scale","\luameshval@api@mode","\luameshval@api@bbox")%
606   }%
607   %
608   \fi%
609 }%
610 %
611 %%%%%%%%%%%%%%%% the drawGmsh command inc
612 %% the user can write code (tikz or MP)
613 %% before and after the generated code
614 \define@boolkey{drawGmshInc}{tikz}[true]{}%
615 %% the scale
616 \define@key{drawGmshInc}{scale}[1cm]{\def\luameshvaldgi@scale{#1}}%
617 %% print ponits ?
618 \define@choicekey*{drawGmshInc}{print}[\val\nr]{none, points}{%
619   \ifcase\nr\relax%
620   \def\luameshvaldgi@print{none}%
621   \or%
622   \def\luameshvaldgi@print{points}%
623   \fi%
624 }%
625 %% the name of the point
626 \define@key{drawGmshInc}{meshpoint}[P]{\def\luameshvaldgi@meshpoint{#1}}%
627 %% the name of the color of drawing
628 \define@key{drawGmshInc}{color}[black]{\def\luameshvaldgi@color{#1}}%
629 %
630 \presetkeys{drawGmshInc}{tikz=false,scale, meshpoint,print=none,color}{}%
631 %
632 \newcommand*{\drawGmshinc}[4][]{%
633   % #1 : optionnal arguments
634   % #2 : the string containing the gmsh file
635   % #3 : the code to place before the generated one
636   % #4 : the code to place after the generated one
637   \setkeys{drawGmshInc}{#1} %
638   \def\MeshPoint{\luameshvaldgi@meshpoint}%
639   \ifKV@drawGmshInc@tikz% if we are using tikz
640   \directlua{%
641     drawGmshTikZinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshvaldgi@print","\luameshvaldgi@scale","\luameshvaldgi@color")%
642   }%
643   \else % we are using MP
644   \mplibcolor{\luameshmpcolor}{\luameshvaldgi@color}%
645   \directlua{%
646     drawGmshMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshvaldgi@print","\luameshvaldgi@scale")%
647   }%
648   %
649   \fi%
650 }%
651 %
652 %%%%%%%%%%%%%%%% the drawGmshBW command
653 %% the code is complete and we don't have any callbacks
654 \define@boolkey{drawGmsh}{tikz}[true]{}%
655 %% the scale
656 \define@key{drawGmsh}{scale}[1cm]{\def\luameshvaldg@scale{#1}}%
657 %% print points
658 \define@choicekey*{drawGmsh}{print}[\val\nr]{none, points}{%
659   \ifcase\nr\relax%
660   \def\luameshvaldg@print{none}%
661   \or%
662   \def\luameshvaldg@print{points}%
663   \fi%
664 }%
665 %% the name of the point
666 \define@key{drawGmsh}{meshpoint}[P]{\def\luameshvaldg@meshpoint{#1}}%
667 %% the name of the color of drawing
668 \define@key{drawGmsh}{color}[black]{\def\luameshvaldg@color{#1}}%
669 %
670 \presetkeys{drawGmsh}{tikz=false,scale, meshpoint,print=none,color}{}%
671 %
672 \newcommand{\drawGmsh}[2][]{%
673   % #1 : optionnal arguments
674   % #2 : the gmsh file
675   \setkeys{drawGmsh}{#1} %
676   \def\MeshPoint{\luameshvaldg@meshpoint}%
677   \ifKV@drawGmsh@tikz% if we are using tikz
678   \directlua{%
679     drawGmshTikZ("#2","\luameshvaldg@print","\luameshvaldg@scale","\luameshvaldg@color")%
680   }%
681   \else % we are using MP
682   \mplibcolor{\luameshmpcolor}{\luameshvaldg@color}%
683   \directlua{%
684     drawGmshMP("#2","\luameshvaldg@print","\luameshvaldg@scale")%
685   }%
686   %
687   \fi%
688 }%
689 %%%%%%%%%%%%%%%% the gmshVoronoi command
690 %% the user can write code (tikz or MP)
691 %% before and after the generated code
692 \define@boolkey{gmshVoronoiInc}{tikz}[true]{}%
693 %% the scale
694 \define@key{gmshVoronoiInc}{scale}[1cm]{\def\luameshval@gvi@scale{#1}}%
695 %% print ponits ?
696 \define@choicekey*{gmshVoronoiInc}{print}[\val\nr]{none, points}{%
697   \ifcase\nr\relax%
698   \def\luameshval@gvi@print{none}%
699   \or%
700   \def\luameshval@gvi@print{points}%
701   \fi%
702 }%
703 %% the name of the point
704 \define@key{gmshVoronoiInc}{meshpoint}[P]{\def\luameshval@gvi@meshpoint{#1}}%
705 %% the name of the circum point
706 \define@key{gmshVoronoiInc}{circumpoint}[P]{\def\luameshval@gvi@circumpoint{#1}}%
707 %% the mode for reading the points
708 \define@choicekey*{gmshVoronoiInc}{delaunay}[\val\nr]{none, show}{%
709   \ifcase\nr\relax%
710   \def\luameshval@gvi@delaunay{none}%
711   \or%
712   \def\luameshval@gvi@delaunay{show}%
713   \fi%
714 }%
715 %% style dashed Delaunay
716 \define@choicekey*{gmshVoronoiInc}{styleDelaunay}[\val\nr]{none, dashed}{%
717   \ifcase\nr\relax%
718   \def\luameshval@gvi@styleDelaunay{none}%
719   \or%
720   \def\luameshval@gvi@styleDelaunay{dashed}%
721   \fi%
722 }%
723 %% style dashed Voronoi
724 \define@choicekey*{gmshVoronoiInc}{styleVoronoi}[\val\nr]{none, dashed}{%
725   \ifcase\nr\relax%
726   \def\luameshval@gvi@styleVoronoi{none}%
727   \or%
728   \def\luameshval@gvi@styleVoronoi{dashed}%
729   \fi%
730 }%
731 %% the name of the color of drawing
732 \define@key{gmshVoronoiInc}{color}[black]{\def\luameshval@gvi@color{#1}}%
733 %% the name of the color of drawing Voronoi
734 \define@key{gmshVoronoiInc}{colorVoronoi}[red]{\def\luameshval@gvi@colorvoronoi{#1}}%
735 %
736 \presetkeys{gmshVoronoiInc}{tikz=false,scale,
737   meshpoint,circumpoint,print=none,color,colorVoronoi,delaunay=none,styleVoronoi=none, styleDelaunay=none}{}%
738 %
739 \newcommand*{\gmshVoronoiinc}[4][]{%
740   % #1 : optionnal arguments
741   % #2 : the gmsh file
742   % #3 : the code to place before the generated one
743   % #4 : the code to place after the generated one
744   \setkeys{gmshVoronoiInc}{#1} %
745   \def\MeshPoint{\luameshval@gvi@meshpoint}%
746   \def\CircumPoint{\luameshval@gvi@circumpoint}%
747   \ifKV@gmshVoronoiInc@tikz% if we are using tikz
748   \directlua{%
749     gmshVoronoiTikZinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@gvi@print","\luameshval@gvi@scale","\luameshval@gvi@delaunay","\luameshval@gvi@color","\luameshval@gvi@colorvoronoi","\luameshval@gvi@styleDelaunay","\luameshval@gvi@styleVoronoi")%
750   }%
751   \else % we are using MP
752   \mplibcolor{\luameshmpcolor}{\luameshval@gvi@color}%
753   \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@gvi@colorvoronoi}%
754   \directlua{%
755     gmshVoronoiMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@gvi@print","\luameshval@gvi@scale","\luameshval@gvi@delaunay","\luameshval@gvi@styleDelaunay","\luameshval@gvi@styleVoronoi")%
756   }%
757   %
758   \fi%
759 }%
760 %
761 %%%%%%%%%%%%%%%% the gmshVoronoiBW command
762 %% the code is complete and we don't have any callbacks
763 \define@boolkey{gmshVoronoi}{tikz}[true]{}%
764 %% the scale
765 \define@key{gmshVoronoi}{scale}[1cm]{\def\luameshval@gv@scale{#1}}%
766 %% print points
767 \define@choicekey*{gmshVoronoi}{print}[\val\nr]{none, points}{%
768   \ifcase\nr\relax%
769   \def\luameshval@gv@print{none}%
770   \or%
771   \def\luameshval@gv@print{points}%
772   \fi%
773 }%
774 %% the name of the point
775 \define@key{gmshVoronoi}{meshpoint}[P]{\def\luameshval@gv@meshpoint{#1}}%
776 %% the name of the circum point
777 \define@key{gmshVoronoi}{circumpoint}[P]{\def\luameshval@gv@circumpoint{#1}}%
778 %% the mode for reading the points
779 \define@choicekey*{gmshVoronoi}{delaunay}[\val\nr]{none, show}{%
780   \ifcase\nr\relax%
781   \def\luameshval@gv@delaunay{none}%
782   \or%
783   \def\luameshval@gv@delaunay{show}%
784   \fi%
785 }%
786 %% style dashed Delaunay
787 \define@choicekey*{gmshVoronoi}{styleDelaunay}[\val\nr]{none, dashed}{%
788   \ifcase\nr\relax%
789   \def\luameshval@gv@styleDelaunay{none}%
790   \or%
791   \def\luameshval@gv@styleDelaunay{dashed}%
792   \fi%
793 }%
794 %% style dashed Voronoi
795 \define@choicekey*{gmshVoronoi}{styleVoronoi}[\val\nr]{none, dashed}{%
796   \ifcase\nr\relax%
797   \def\luameshval@gv@styleVoronoi{none}%
798   \or%
799   \def\luameshval@gv@styleVoronoi{dashed}%
800   \fi%
801 }%
802 %% the name of the color of drawing
803 \define@key{gmshVoronoi}{color}[black]{\def\luameshval@gv@color{#1}}%
804 %% the name of the color of drawing Voronoi
805 \define@key{gmshVoronoi}{colorVoronoi}[red]{\def\luameshval@gv@colorVoronoi{#1}}%
806 %
807 \presetkeys{gmshVoronoi}{tikz=false,scale, meshpoint,circumpoint,print=none,color,colorVoronoi,delaunay=none,styleVoronoi=none, styleDelaunay=none}{}%
808 %
809 \newcommand{\gmshVoronoi}[2][]{%
810   % #1 : optionnal arguments
811   % #2 : the gmsh file
812   \setkeys{gmshVoronoi}{#1} %
813   \def\MeshPoint{\luameshval@gv@meshpoint}%
814   \def\CircumPoint{\luameshval@gv@circumpoint}%
815   \ifKV@gmshVoronoi@tikz% if we are using tikz
816   \directlua{%
817     gmshVoronoiTikZ("#2","\luameshval@gv@print","\luameshval@gv@scale","\luameshval@gv@delaunay","\luameshval@gv@color","\luameshval@gv@colorVoronoi","\luameshval@gv@styleDelaunay","\luameshval@gv@styleVoronoi")%
818   }%
819   \else % we are using MP
820   \mplibcolor{\luameshmpcolor}{\luameshval@gv@color}%
821   \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@gv@colorVoronoi}%
822   \directlua{%
823     gmshVoronoiMP("#2","\luameshval@gv@print","\luameshval@gv@scale","\luameshval@gv@delaunay","\luameshval@gv@styleDelaunay","\luameshval@gv@styleVoronoi")%
824   }%
825   %
826   \fi%
827 }%
828 %
829 %
830 %
831 %%%%%%%%%%%%%%%% the meshPolygon command
832 %%
833 \define@boolkey{meshPolygon}{tikz}[true]{}%
834
835 %% the scale
836 \define@key{meshPolygon}{scale}[1cm]{\def\luameshval@mp@scale{#1}}%
837 %% print points
838 \define@choicekey*{meshPolygon}{print}[\val\nr]{none, points,dotpoints}{%
839   \ifcase\nr\relax%
840   \def\luameshval@mp@print{none}%
841   \or%
842   \def\luameshval@mp@print{points}%
843   \or%
844   \def\luameshval@mp@print{dotpoints}%
845   \fi%
846 }%
847 %% the name of the point
848 \define@key{meshPolygon}{meshpoint}[P]{\def\luameshval@mp@meshpoint{#1}}%
849 %% the grid parameter
850 \define@key{meshPolygon}{h}[0.2]{\def\luameshval@mp@h{#1}}%
851 %% the mode for reading the points
852 \define@choicekey*{meshPolygon}{mode}[\val\nr]{int, ext}{%
853   \ifcase\nr\relax%
854   \def\luameshval@mp@mode{int}%
855   \or%
856   \def\luameshval@mp@mode{ext}%
857   \fi%
858 }%
859 %% the different steps of the  meshing
860 \define@choicekey*{meshPolygon}{step}[\val\nr]{polygon, grid, points, mesh}{%
861   \ifcase\nr\relax%
862   \def\luameshval@mp@step{polygon}%
863   \or%
864   \def\luameshval@mp@step{grid}%
865   \or%
866   \def\luameshval@mp@step{points}%
867   \or%
868   \def\luameshval@mp@step{mesh}%
869   \fi%
870 }%
871
872 %% the name of the color of drawing
873 \define@key{meshPolygon}{color}[black]{\def\luameshval@mp@color{#1}}%
874 %% the name of the color of drawing Voronoi
875 \define@key{meshPolygon}{colorPolygon}[red]{\def\luameshval@mp@colorPolygon{#1}}%
876 %% the name of the color of drawing the bbox
877 %
878 \presetkeys{meshPolygon}{tikz=false,scale,mode=int,step=mesh,print=none,color,colorPolygon,h,meshpoint}{}%
879 %
880 \newcommand{\meshPolygon}[2][]{%
881   % #1 : optionnal arguments
882   % #2 : the string containing the list of points
883   % (x1,y1);(x2,y2);... or the name file containing the points
884   \setkeys{meshPolygon}{#1} %
885   \def\MeshPoint{\luameshval@mp@meshpoint}%
886   \ifKV@meshPolygon@tikz% if we are using tikz
887   \directlua{%
888     drawMeshPolygonTikZ("#2","\luameshval@mp@mode","\luameshval@mp@h","\luameshval@mp@step","\luameshval@mp@print","\luameshval@mp@scale","\luameshval@mp@color","\luameshval@mp@colorPolygon")%
889   }%
890   \else % we are using MP
891   \mplibcolor{\luameshmpcolor}{\luameshval@mp@color}%
892   \mplibcolor{\luameshmpcolorPoly}{\luameshval@mp@colorPolygon}%
893   \directlua{%
894     drawMeshPolygonMP("#2","\luameshval@mp@mode","\luameshval@mp@h","\luameshval@mp@step","\luameshval@mp@print","\luameshval@mp@scale")%
895   }%
896   %
897   \fi%
898 }%

Licence Creative Commons Les fichiers de Syracuse sont mis à disposition (sauf mention contraire) selon les termes de la
Licence Creative Commons Attribution - Pas d’Utilisation Commerciale - Partage dans les Mêmes Conditions 4.0 International.