Mise à jour index.md et passage version 0.2
[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}{%
54   \ifcase\nr\relax%
55   \def\luameshval@bmi@print{none}%
56   \or%
57   \def\luameshval@bmi@print{points}%
58   \fi%
59 }%
60 %% the name of the point
61 \define@key{buildMeshInc}{meshpoint}[P]{\def\luameshval@bmi@meshpoint{#1}}%
62 %% the mode for reading the points
63 \define@choicekey*{buildMeshInc}{mode}[\val\nr]{int, ext}{%
64   \ifcase\nr\relax%
65   \def\luameshval@bmi@mode{int}%
66   \or%
67   \def\luameshval@bmi@mode{ext}%
68   \fi%
69 }%
70 %% the name of the color of drawing
71 \define@key{buildMeshInc}{color}[black]{\def\luameshval@bmi@color{#1}}%
72 %% the name of the color of drawing the bbox
73 \define@key{buildMeshInc}{colorBbox}[black]{\def\luameshval@bmi@colorbbox{#1}}%
74 %
75 \presetkeys{buildMeshInc}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
76 %
77 \newcommand*{\buildMeshBWinc}[4][]{%
78   % #1 : optionnal arguments
79   % #2 : the string containing the list of points
80   %      (x1,y1);(x2,y2);... or the name file containing the points
81   % #3 : the code to place before the generated one
82   % #4 : the code to place after the generated one
83   \setkeys{buildMeshInc}{#1} %
84   \def\MeshPoint{\luameshval@bmi@meshpoint}%
85   \ifKV@buildMeshInc@tikz% if we are using tikz
86   \directlua{%
87     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")%
88   }%
89   \else % we are using MP
90   \mplibcolor{\luameshmpcolor}{\luameshval@bmi@color}%
91   \mplibcolor{\luameshmpcolorBbox}{\luameshval@bmi@colorbbox}%
92   \directlua{%
93     buildMeshMPBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bmi@mode","\luameshval@bmi@print","\luameshval@bmi@bbox","\luameshval@bmi@scale")%
94   }%
95   %
96   \fi%
97 }%
98 %
99 %%%%%%%%%%%%%%%% the buildMeshBW command
100 %% the code is complete and we don't have any callbacks
101 \define@boolkey{buildMesh}{tikz}[true]{}%
102 %% show the bounding box for delaunay
103 \define@choicekey*{buildMesh}{bbox}[\val\nr]{none, show}{%
104   \ifcase\nr\relax%
105   \def\luameshval@bm@bbox{none}%
106   \or%
107   \def\luameshval@bm@bbox{bbox}%
108   \fi%
109 }%
110 %% the scale
111 \define@key{buildMesh}{scale}[1cm]{\def\luameshval@bm@scale{#1}}%
112 %% print points
113 \define@choicekey*{buildMesh}{print}[\val\nr]{none, points}{%
114   \ifcase\nr\relax%
115   \def\luameshval@bm@print{none}%
116   \or%
117   \def\luameshval@bm@print{points}%
118   \fi%
119 }%
120 %% the name of the point
121 \define@key{buildMesh}{meshpoint}[P]{\def\luameshval@bm@meshpoint{#1}}%
122 %% the mode for reading the points
123 \define@choicekey*{buildMesh}{mode}[\val\nr]{int, ext}{%
124   \ifcase\nr\relax%
125   \def\luameshval@bm@mode{int}%
126   \or%
127   \def\luameshval@bm@mode{ext}%
128   \fi%
129 }%
130 %% the name of the color of drawing
131 \define@key{buildMesh}{color}[black]{\def\luameshval@bm@color{#1}}%
132 %% the name of the color of drawing the bbox
133 \define@key{buildMesh}{colorBbox}[black]{\def\luameshval@bm@colorbbox{#1}}%
134 %
135 \presetkeys{buildMesh}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
136 %
137 \newcommand{\buildMeshBW}[2][]{%
138   % #1 : optionnal arguments
139   % #2 : the string containing the list of points
140   % (x1,y1);(x2,y2);... or the name file containing the points
141   \setkeys{buildMesh}{#1} %
142   \def\MeshPoint{\luameshval@bm@meshpoint}%
143   \ifKV@buildMesh@tikz% if we are using tikz
144   \directlua{%
145     buildMeshTikZBW("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","\luameshval@bm@scale","\luameshval@bm@color","\luameshval@bm@colorbbox")%
146   }%
147   \else % we are using MP
148   \mplibcolor{\luameshmpcolor}{\luameshval@bm@color}%
149   \mplibcolor{\luameshmpcolorBbox}{\luameshval@bm@colorbbox}%
150   \directlua{%
151     buildMeshMPBW("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","\luameshval@bm@scale")%
152   }%
153   %
154   \fi%
155 }%
156 %%%%%%%%%%%%%%%% the buildVoronoi command
157 %% the user can write code (tikz or MP)
158 %% before and after the generated code
159 \define@boolkey{buildVoronoiInc}{tikz}[true]{}%
160 %% show the bounding box for delaunay
161 \define@choicekey*{buildVoronoiInc}{bbox}[\val\nr]{none, show}{%
162   \ifcase\nr\relax%
163   \def\luameshval@bvi@bbox{none}%
164   \or%
165   \def\luameshval@bvi@bbox{bbox}%
166   \fi%
167 }%
168 %% the scale
169 \define@key{buildVoronoiInc}{scale}[1cm]{\def\luameshval@bvi@scale{#1}}%
170 %% print ponits ?
171 \define@choicekey*{buildVoronoiInc}{print}[\val\nr]{none, points}{%
172   \ifcase\nr\relax%
173   \def\luameshval@bvi@print{none}%
174   \or%
175   \def\luameshval@bvi@print{points}%
176   \fi%
177 }%
178 %% the name of the point
179 \define@key{buildVoronoiInc}{meshpoint}[P]{\def\luameshval@bvi@meshpoint{#1}}%
180 %% the name of the circum point
181 \define@key{buildVoronoiInc}{circumpoint}[P]{\def\luameshval@bvi@circumpoint{#1}}%
182 %% the mode for reading the points
183 \define@choicekey*{buildVoronoiInc}{mode}[\val\nr]{int, ext}{%
184   \ifcase\nr\relax%
185   \def\luameshval@bvi@mode{int}%
186   \or%
187   \def\luameshval@bvi@mode{ext}%
188   \fi%
189 }%
190 %% the mode for reading the points
191 \define@choicekey*{buildVoronoiInc}{delaunay}[\val\nr]{none, show}{%
192   \ifcase\nr\relax%
193   \def\luameshval@bvi@delaunay{none}%
194   \or%
195   \def\luameshval@bvi@delaunay{show}%
196   \fi%
197 }%
198 %% the name of the color of drawing
199 \define@key{buildVoronoiInc}{color}[black]{\def\luameshval@bvi@color{#1}}%
200 %% the name of the color of drawing Voronoi
201 \define@key{buildVoronoiInc}{colorVoronoi}[red]{\def\luameshval@bvi@colorvoronoi{#1}}%
202 %% the name of the color of drawing the bbox
203 \define@key{buildVoronoiInc}{colorBbox}[black]{\def\luameshval@bvi@colorbbox{#1}}%
204 %
205 \presetkeys{buildVoronoiInc}{tikz=false,bbox=none,scale, meshpoint,circumpoint,mode=int,print=none,color,colorVoronoi,colorBbox,delaunay=none}{}%
206 %
207 \newcommand*{\buildVoronoiBWinc}[4][]{%
208   % #1 : optionnal arguments
209   % #2 : the string containing the list of points
210   % (x1,y1);(x2,y2);... or the name file containing the points
211   % #3 : the code to place before the generated one
212   % #4 : the code to place after the generated one
213   \setkeys{buildVoronoiInc}{#1} %
214   \def\MeshPoint{\luameshval@bvi@meshpoint}%
215   \def\CircumPoint{\luameshval@bvi@circumpoint}%
216   \ifKV@buildVoronoiInc@tikz% if we are using tikz
217   \directlua{%
218     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")%
219   }%
220   \else % we are using MP
221   \mplibcolor{\luameshmpcolor}{\luameshval@bvi@color}%
222   \mplibcolor{\luameshmpcolorBbox}{\luameshval@bvi@colorbbox}%
223   \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@bvi@colorvoronoi}%
224   \directlua{%
225     buildVoronoiMPBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bvi@mode","\luameshval@bvi@print","\luameshval@bvi@bbox","\luameshval@bvi@scale","\luameshval@bvi@delaunay")%
226   }%
227   %
228   \fi%
229 }%
230 %
231 %%%%%%%%%%%%%%%% the buildVoronoiBW command
232 %% the code is complete and we don't have any callbacks
233 \define@boolkey{buildVoronoi}{tikz}[true]{}%
234 %% show the bounding box for delaunay
235 \define@choicekey*{buildVoronoi}{bbox}[\val\nr]{none, show}{%
236   \ifcase\nr\relax%
237   \def\luameshval@bv@bbox{none}%
238   \or%
239   \def\luameshval@bv@bbox{bbox}%
240   \fi%
241 }%
242 %% the scale
243 \define@key{buildVoronoi}{scale}[1cm]{\def\luameshval@bv@scale{#1}}%
244 %% print points
245 \define@choicekey*{buildVoronoi}{print}[\val\nr]{none, points}{%
246   \ifcase\nr\relax%
247   \def\luameshval@bv@print{none}%
248   \or%
249   \def\luameshval@bv@print{points}%
250   \fi%
251 }%
252 %% the name of the point
253 \define@key{buildVoronoi}{meshpoint}[P]{\def\luameshval@bv@meshpoint{#1}}%
254 %% the name of the circum point
255 \define@key{buildVoronoi}{circumpoint}[P]{\def\luameshval@bv@circumpoint{#1}}%
256 %% the mode for reading the points
257 \define@choicekey*{buildVoronoi}{mode}[\val\nr]{int, ext}{%
258   \ifcase\nr\relax%
259   \def\luameshval@bv@mode{int}%
260   \or%
261   \def\luameshval@bv@mode{ext}%
262   \fi%
263 }%
264 %% the mode for reading the points
265 \define@choicekey*{buildVoronoi}{delaunay}[\val\nr]{none, show}{%
266   \ifcase\nr\relax%
267   \def\luameshval@bv@delaunay{none}%
268   \or%
269   \def\luameshval@bv@delaunay{show}%
270   \fi%
271 }%
272 %% the name of the color of drawing
273 \define@key{buildVoronoi}{color}[black]{\def\luameshval@bv@color{#1}}%
274 %% the name of the color of drawing Voronoi
275 \define@key{buildVoronoi}{colorVoronoi}[red]{\def\luameshval@bv@colorVoronoi{#1}}%
276 %% the name of the color of drawing the bbox
277 \define@key{buildVoronoi}{colorBbox}[black]{\def\luameshval@bv@colorbbox{#1}}%
278 %
279 \presetkeys{buildVoronoi}{tikz=false,bbox=none,scale, meshpoint,circumpoint,mode=int,print=none,color,colorVoronoi,colorBbox,delaunay=none}{}%
280 %
281 \newcommand{\buildVoronoiBW}[2][]{%
282   % #1 : optionnal arguments
283   % #2 : the string containing the list of points
284   % (x1,y1);(x2,y2);... or the name file containing the points
285   \setkeys{buildVoronoi}{#1} %
286   \def\MeshPoint{\luameshval@bv@meshpoint}%
287   \def\CircumPoint{\luameshval@bv@circumpoint}%
288   \ifKV@buildVoronoi@tikz% if we are using tikz
289   \directlua{%
290     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")%
291   }%
292   \else % we are using MP
293   \mplibcolor{\luameshmpcolor}{\luameshval@bv@color}%
294   \mplibcolor{\luameshmpcolorBbox}{\luameshval@bv@colorbbox}%
295   \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@bv@colorVoronoi}%
296   \directlua{%
297     buildVoronoiMPBW("#2","\luameshval@bv@mode","\luameshval@bv@print","\luameshval@bv@bbox","\luameshval@bv@scale","\luameshval@bv@delaunay")%
298   }%
299   %
300   \fi%
301 }%
302 %
303 %
304 %%%%%%%%%%%%%%%%% the draw Points macro
305 %% plot the list of points given in argument
306 % the engine
307 \define@boolkey{drawPoints}{tikz}[true]{}%
308 %% show the bounding box for delaunay
309 \define@choicekey*{drawPoints}{bbox}[\val\nr]{none, show}{%
310   \ifcase\nr\relax%
311   \def\luameshval@tp@bbox{none}%
312   \or%
313   \def\luameshval@tp@bbox{bbox}%
314   \fi%
315 }%
316 %% the scale
317 \define@key{drawPoints}{scale}[1cm]{\def\luameshval@tp@scale{#1}}%
318 %% print points
319 \define@choicekey*{drawPoints}{print}[\val\nr]{none, points}{%
320   \ifcase\nr\relax%
321   \def\luameshval@tp@print{none}%
322   \or%
323   \def\luameshval@tp@print{points}%
324   \fi%
325 }%
326 %% the name of the point
327 \define@key{drawPoints}{meshpoint}[P]{\def\luameshval@tp@meshpoint{#1}}%
328 %% the mode for reading the points
329 \define@choicekey*{drawPoints}{mode}[\val\nr]{int, ext}{%
330   \ifcase\nr\relax%
331   \def\luameshval@tp@mode{int}%
332   \or%
333   \def\luameshval@tp@mode{ext}%
334   \fi%
335 }%
336 %% the name of the color of drawing
337 \define@key{drawPoints}{color}[black]{\def\luameshval@tp@color{#1}}%
338 %% the name of the color of drawing the bbox
339 \define@key{drawPoints}{colorBbox}[black]{\def\luameshval@tp@colorbbox{#1}}%
340 %
341 \presetkeys{drawPoints}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
342 %
343 \newcommand{\drawPointsMesh}[2][]{%
344   % #1 : optionnal arguments
345   % #2 : the string containing the list of points
346   % (x1,y1);(x2,y2);... or the name file containing the points
347   \setkeys{drawPoints}{#1} %
348   \def\MeshPoint{\luameshval@tp@meshpoint}%
349   \ifKV@drawPoints@tikz% if we are using tikz
350   \directlua{%
351     printPointsTikZ("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale","\luameshval@tp@color","\luameshval@tp@colorbbox")%
352   }%
353   \else % we are using MP
354   \mplibcolor{\luameshmpcolor}{\luameshval@tp@color}%
355   \mplibcolor{\luameshmpcolorBbox}{\luameshval@tp@colorbbox}%
356   \directlua{%
357     printPointsMP("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale")%
358   }%
359   %
360   \fi%
361 }%
362 %
363
364 %%%%%%%%%%%%%%%% the draw Points macro inc with callbacks
365 %% engine of drawing
366 \define@boolkey{drawPointsInc}{tikz}[true]{}%
367 %% show the bounding box for delaunay
368 \define@choicekey*{drawPointsInc}{bbox}[\val\nr]{none, show}{%
369   \ifcase\nr\relax%
370   \def\luameshval@tpi@bbox{none}%
371   \or%
372   \def\luameshval@tpi@bbox{bbox}%
373   \fi%
374 }%
375 %% the scale
376 \define@key{drawPointsInc}{scale}[1cm]{\def\luameshval@tpi@scale{#1}}%
377 %% print points
378 \define@choicekey*{drawPointsInc}{print}[\val\nr]{none, points}{%
379   \ifcase\nr\relax%
380   \def\luameshval@tpi@print{none}%
381   \or%
382   \def\luameshval@tpi@print{points}%
383   \fi%
384 }%
385 %% the name of the point
386 \define@key{drawPointsInc}{meshpoint}[P]{\def\luameshval@tpi@meshpoint{#1}}%
387 %% the mode for reading the points
388 \define@choicekey*{drawPointsInc}{mode}[\val\nr]{int, ext}{%
389   \ifcase\nr\relax%
390   \def\luameshval@tpi@mode{int}%
391   \or%
392   \def\luameshval@tpi@mode{ext}%
393   \fi%
394 }%
395 %
396 % color
397 %% the name of the color of drawing
398 \define@key{drawPointsInc}{color}[black]{\def\luameshval@tpi@color{#1}}%
399 %% the name of the color of drawing the bbox
400 \define@key{drawPointsInc}{colorBbox}[black]{\def\luameshval@tpi@colorbbox{#1}}%
401 %
402 \presetkeys{drawPointsInc}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
403 %
404 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
405 \newcommand*{\drawPointsMeshinc}[4][]{%
406   % #1 : optionnal arguments
407   % #2 : the string containing the list of points
408   % (x1,y1);(x2,y2);... or the name file containing the points
409   % #3 : the code to place before the generated one
410   % #4 : the code to place after the generated one
411   \setkeys{drawPointsInc}{#1} %
412   \def\MeshPoint{\luameshval@tpi@meshpoint}%
413   \ifKV@drawPointsInc@tikz% if we are using tikz
414   \directlua{%
415     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")%
416   }%
417   \else % we are using MP
418   \mplibcolor{\luameshmpcolor}{\luameshval@tpi@color}%
419   \mplibcolor{\luameshmpcolorBbox}{\luameshval@tpi@colorbbox}%
420   \directlua{%
421     printPointsMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@tpi@mode","\luameshval@tpi@print","\luameshval@tpi@bbox","\luameshval@tpi@scale")%
422   }%
423   \fi%
424 }%
425 %
426 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
427 %% the meshAddOnePointBW commande
428 %%engine of draiwng
429 \define@boolkey{MeshAddOneBW}{tikz}[true]{}%
430 %% the scale
431 \define@key{MeshAddOneBW}{scale}[1cm]{\def\luameshval@ap@scale{#1}}%
432 %% the name of the points
433 \define@key{MeshAddOneBW}{meshpoint}[P]{\def\luameshval@ap@meshpoint{#1}}%
434 %% the name of the new point
435 \define@key{MeshAddOneBW}{newpoint}[P]{\def\luameshval@ap@newpoint{#1}}%
436 %% a complete picture or some code of the engine
437 \define@choicekey*{MeshAddOneBW}{step}[\val\nr]{badtriangles, cavity, newtriangles}{%
438   \ifcase\nr\relax%
439   \def\luameshval@ap@step{badT}%
440   \or%
441   \def\luameshval@ap@step{cavity}%
442   \or%
443   \def\luameshval@ap@step{newT}%
444   \fi%
445 }%
446 % color
447 %% the color of drawing
448 \define@key{MeshAddOneBW}{color}[black]{\def\luameshval@ap@color{#1}}%
449 %% the color of background of new element
450 \define@key{MeshAddOneBW}{colorBack}[black!20]{\def\luameshval@ap@colorback{#1}}%
451 %% the color of new element
452 \define@key{MeshAddOneBW}{colorNew}[red]{\def\luameshval@ap@colornew{#1}}%
453 %% the color of circoncircle
454 \define@key{MeshAddOneBW}{colorCircle}[green]{\def\luameshval@ap@colorcircle{#1}}%
455 %% the name of the color of drawing the bbox
456 \define@key{MeshAddOneBW}{colorBbox}[black]{\def\luameshval@ap@colorbbox{#1}}%
457 %
458 %% a complete picture or some code of the engine
459 \define@choicekey*{MeshAddOneBW}{mode}[\val\nr]{int, ext}{%
460   \ifcase\nr\relax%
461   \def\luameshval@ap@mode{int}%
462   \or%
463   \def\luameshval@ap@mode{ext}%
464   \fi%
465 }%
466 \define@choicekey*{MeshAddOneBW}{bbox}[\val\nr]{none, show}{%
467   \ifcase\nr\relax%
468   \def\luameshval@ap@bbox{none}%
469   \or%
470   \def\luameshval@ap@bbox{bbox}%
471   \fi%
472 }%
473 \presetkeys{MeshAddOneBW}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}%
474 %
475 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
476 \newcommand*{\meshAddPointBW}[3][]{%
477   % #1 : optionnal arguments
478   % #2 : the string containing the list of points
479   % (x1,y1);(x2,y2);... or the name file containing the points
480   \setkeys{MeshAddOneBW}{#1} %
481   \def\MeshPoint{\luameshval@ap@meshpoint}%
482   \def\NewPoint{\luameshval@ap@newpoint}%
483   \ifKV@MeshAddOneBW@tikz% if we are using tikz
484   \directlua{%
485     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")%
486   }%
487   \else % we are using MP
488   \mplibcolor{\luameshmpcolor}{\luameshval@ap@color}
489   \mplibcolor{\luameshmpcolorBack}{\luameshval@ap@colorback}
490   \mplibcolor{\luameshmpcolorNew}{\luameshval@ap@colornew}
491   \mplibcolor{\luameshmpcolorCircle}{\luameshval@ap@colorcircle}
492   \mplibcolor{\luameshmpcolorBbox}{\luameshval@ap@colorbbox}
493   \directlua{%
494     TeXOnePointMPBW("#2","#3","\luameshval@ap@step","\luameshval@ap@scale","\luameshval@ap@mode","\luameshval@ap@bbox")%
495   }%
496   %
497   \fi%
498 }%
499 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
500 %%% the meshAddPointBWinc commande with callbacks
501 %% engine of drawing
502 \define@boolkey{MeshAddOneBWinc}{tikz}[true]{}%
503 %% the scale
504 \define@key{MeshAddOneBWinc}{scale}[1cm]{\def\luameshval@api@scale{#1}}%
505 %% the name of the points
506 \define@key{MeshAddOneBWinc}{meshpoint}[P]{\def\luameshval@api@meshpoint{#1}}%
507 %% the name of the new point
508 \define@key{MeshAddOneBWinc}{newpoint}[P]{\def\luameshval@api@newpoint{#1}}%
509 %% a complete picture or some code of the engine
510 \define@choicekey*{MeshAddOneBWinc}{step}[\val\nr]{badtriangles, cavity, newtriangles}{%
511   \ifcase\nr\relax%
512   \def\luameshval@api@step{badT}%
513   \or%
514   \def\luameshval@api@step{cavity}%
515   \or%
516   \def\luameshval@api@step{newT}%
517   \fi%
518 }%
519 % color
520 %% the color of drawing
521 \define@key{MeshAddOneBWinc}{color}[black]{\def\luameshval@api@color{#1}}%
522 %% the color of background of new element
523 \define@key{MeshAddOneBWinc}{colorBack}[black!20]{\def\luameshval@api@colorback{#1}}%
524 %% the color of new element
525 \define@key{MeshAddOneBWinc}{colorNew}[red]{\def\luameshval@api@colornew{#1}}%
526 %% the color of circoncircle
527 \define@key{MeshAddOneBWinc}{colorCircle}[green]{\def\luameshval@api@colorcircle{#1}}%
528 \define@key{MeshAddOneBWinc}{colorBbox}[black]{\def\luameshval@api@colorbbox{#1}}%
529 %
530 %% a complete picture or some code of the engine
531 \define@choicekey*{MeshAddOneBWinc}{mode}[\val\nr]{int, ext}{%
532   \ifcase\nr\relax%
533   \def\luameshval@api@mode{int}%
534   \or%
535   \def\luameshval@api@mode{ext}%
536   \fi%
537 }%
538 \define@choicekey*{MeshAddOneBWinc}{bbox}[\val\nr]{none, show}{%
539   \ifcase\nr\relax%
540   \def\luameshval@api@bbox{none}%
541   \or%
542   \def\luameshval@api@bbox{bbox}%
543   \fi%
544 }%
545 \presetkeys{MeshAddOneBWinc}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}%
546 %
547 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
548 \newcommand*{\meshAddPointBWinc}[5][]{%
549   % #1 : optionnal arguments
550   % #2 : the string containing the list of points
551   % (x1,y1);(x2,y2);... or the name file containing the points
552   % #3 : the code to place before the generated one
553   % #4 : the code to place after the generated one
554   \setkeys{MeshAddOneBWinc}{#1} %
555   \def\MeshPoint{\luameshval@api@meshpoint}%
556   \def\NewPoint{\luameshval@api@newpoint}%
557   \ifKV@MeshAddOneBWinc@tikz% if we are using tikz
558   \directlua{%
559     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")%
560   }%
561   \else % we are using MP
562   \mplibcolor{\luameshmpcolor}{\luameshval@api@color}
563   \mplibcolor{\luameshmpcolorBack}{\luameshval@api@colorback}
564   \mplibcolor{\luameshmpcolorNew}{\luameshval@api@colornew}
565   \mplibcolor{\luameshmpcolorCircle}{\luameshval@api@colorcircle}
566   \mplibcolor{\luameshmpcolorBbox}{\luameshval@api@colorbbox}
567   \directlua{%
568     TeXOnePointMPBWinc("#2","#3","\luaescapestring{\unexpanded{#4}}","\luaescapestring{\unexpanded{#5}}","\luameshval@api@step","\luameshval@api@scale","\luameshval@api@mode","\luameshval@api@bbox")%
569   }%
570   %
571   \fi%
572 }%
573 %
574 %%%%%%%%%%%%%%%% the drawGmsh command inc
575 %% the user can write code (tikz or MP)
576 %% before and after the generated code
577 \define@boolkey{drawGmshInc}{tikz}[true]{}%
578 %% the scale
579 \define@key{drawGmshInc}{scale}[1cm]{\def\luameshvaldgi@scale{#1}}%
580 %% print ponits ?
581 \define@choicekey*{drawGmshInc}{print}[\val\nr]{none, points}{%
582   \ifcase\nr\relax%
583   \def\luameshvaldgi@print{none}%
584   \or%
585   \def\luameshvaldgi@print{points}%
586   \fi%
587 }%
588 %% the name of the point
589 \define@key{drawGmshInc}{meshpoint}[P]{\def\luameshvaldgi@meshpoint{#1}}%
590 %% the name of the color of drawing
591 \define@key{drawGmshInc}{color}[black]{\def\luameshvaldgi@color{#1}}%
592 %
593 \presetkeys{drawGmshInc}{tikz=false,scale, meshpoint,print=none,color}{}%
594 %
595 \newcommand*{\drawGmshinc}[4][]{%
596   % #1 : optionnal arguments
597   % #2 : the string containing the gmsh file
598   % #3 : the code to place before the generated one
599   % #4 : the code to place after the generated one
600   \setkeys{drawGmshInc}{#1} %
601   \def\MeshPoint{\luameshvaldgi@meshpoint}%
602   \ifKV@drawGmshInc@tikz% if we are using tikz
603   \directlua{%
604     drawGmshTikZinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshvaldgi@print","\luameshvaldgi@scale","\luameshvaldgi@color")%
605   }%
606   \else % we are using MP
607   \mplibcolor{\luameshmpcolor}{\luameshvaldgi@color}%
608   \directlua{%
609     drawGmshMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshvaldgi@print","\luameshvaldgi@scale")%
610   }%
611   %
612   \fi%
613 }%
614 %
615 %%%%%%%%%%%%%%%% the drawGmshBW command
616 %% the code is complete and we don't have any callbacks
617 \define@boolkey{drawGmsh}{tikz}[true]{}%
618 %% the scale
619 \define@key{drawGmsh}{scale}[1cm]{\def\luameshvaldg@scale{#1}}%
620 %% print points
621 \define@choicekey*{drawGmsh}{print}[\val\nr]{none, points}{%
622   \ifcase\nr\relax%
623   \def\luameshvaldg@print{none}%
624   \or%
625   \def\luameshvaldg@print{points}%
626   \fi%
627 }%
628 %% the name of the point
629 \define@key{drawGmsh}{meshpoint}[P]{\def\luameshvaldg@meshpoint{#1}}%
630 %% the name of the color of drawing
631 \define@key{drawGmsh}{color}[black]{\def\luameshvaldg@color{#1}}%
632 %
633 \presetkeys{drawGmsh}{tikz=false,scale, meshpoint,print=none,color}{}%
634 %
635 \newcommand{\drawGmsh}[2][]{%
636   % #1 : optionnal arguments
637   % #2 : the gmsh file
638   \setkeys{drawGmsh}{#1} %
639   \def\MeshPoint{\luameshvaldg@meshpoint}%
640   \ifKV@drawGmsh@tikz% if we are using tikz
641   \directlua{%
642     drawGmshTikZ("#2","\luameshvaldg@print","\luameshvaldg@scale","\luameshvaldg@color")%
643   }%
644   \else % we are using MP
645   \mplibcolor{\luameshmpcolor}{\luameshvaldg@color}%
646   \directlua{%
647     drawGmshMP("#2","\luameshvaldg@print","\luameshvaldg@scale")%
648   }%
649   %
650   \fi%
651 }%
652 %%%%%%%%%%%%%%%% the gmshVoronoi command
653 %% the user can write code (tikz or MP)
654 %% before and after the generated code
655 \define@boolkey{gmshVoronoiInc}{tikz}[true]{}%
656 %% the scale
657 \define@key{gmshVoronoiInc}{scale}[1cm]{\def\luameshval@gvi@scale{#1}}%
658 %% print ponits ?
659 \define@choicekey*{gmshVoronoiInc}{print}[\val\nr]{none, points}{%
660   \ifcase\nr\relax%
661   \def\luameshval@gvi@print{none}%
662   \or%
663   \def\luameshval@gvi@print{points}%
664   \fi%
665 }%
666 %% the name of the point
667 \define@key{gmshVoronoiInc}{meshpoint}[P]{\def\luameshval@gvi@meshpoint{#1}}%
668 %% the name of the circum point
669 \define@key{gmshVoronoiInc}{circumpoint}[P]{\def\luameshval@gvi@circumpoint{#1}}%
670 %% the mode for reading the points
671 \define@choicekey*{gmshVoronoiInc}{delaunay}[\val\nr]{none, show}{%
672   \ifcase\nr\relax%
673   \def\luameshval@gvi@delaunay{none}%
674   \or%
675   \def\luameshval@gvi@delaunay{show}%
676   \fi%
677 }%
678 %% the name of the color of drawing
679 \define@key{gmshVoronoiInc}{color}[black]{\def\luameshval@gvi@color{#1}}%
680 %% the name of the color of drawing Voronoi
681 \define@key{gmshVoronoiInc}{colorVoronoi}[red]{\def\luameshval@gvi@colorvoronoi{#1}}%
682 %
683 \presetkeys{gmshVoronoiInc}{tikz=false,scale, meshpoint,circumpoint,print=none,color,colorVoronoi,delaunay=none}{}%
684 %
685 \newcommand*{\gmshVoronoiBWinc}[4][]{%
686   % #1 : optionnal arguments
687   % #2 : the gmsh file
688   % #3 : the code to place before the generated one
689   % #4 : the code to place after the generated one
690   \setkeys{gmshVoronoiInc}{#1} %
691   \def\MeshPoint{\luameshval@gvi@meshpoint}%
692   \def\CircumPoint{\luameshval@gvi@circumpoint}%
693   \ifKV@gmshVoronoiInc@tikz% if we are using tikz
694   \directlua{%
695     gmshVoronoiTikZinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@gvi@print","\luameshval@gvi@scale","\luameshval@gvi@delaunay","\luameshval@gvi@color","\luameshval@gvi@colorvoronoi")%
696   }%
697   \else % we are using MP
698   \mplibcolor{\luameshmpcolor}{\luameshval@gvi@color}%
699   \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@gvi@colorvoronoi}%
700   \directlua{%
701     gmshVoronoiMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@gvi@print","\luameshval@gvi@scale","\luameshval@gvi@delaunay")%
702   }%
703   %
704   \fi%
705 }%
706 %
707 %%%%%%%%%%%%%%%% the gmshVoronoiBW command
708 %% the code is complete and we don't have any callbacks
709 \define@boolkey{gmshVoronoi}{tikz}[true]{}%
710 %% the scale
711 \define@key{gmshVoronoi}{scale}[1cm]{\def\luameshval@gv@scale{#1}}%
712 %% print points
713 \define@choicekey*{gmshVoronoi}{print}[\val\nr]{none, points}{%
714   \ifcase\nr\relax%
715   \def\luameshval@gv@print{none}%
716   \or%
717   \def\luameshval@gv@print{points}%
718   \fi%
719 }%
720 %% the name of the point
721 \define@key{gmshVoronoi}{meshpoint}[P]{\def\luameshval@gv@meshpoint{#1}}%
722 %% the name of the circum point
723 \define@key{gmshVoronoi}{circumpoint}[P]{\def\luameshval@gv@circumpoint{#1}}%
724 %% the mode for reading the points
725 \define@choicekey*{gmshVoronoi}{delaunay}[\val\nr]{none, show}{%
726   \ifcase\nr\relax%
727   \def\luameshval@gv@delaunay{none}%
728   \or%
729   \def\luameshval@gv@delaunay{show}%
730   \fi%
731 }%
732 %% the name of the color of drawing
733 \define@key{gmshVoronoi}{color}[black]{\def\luameshval@gv@color{#1}}%
734 %% the name of the color of drawing Voronoi
735 \define@key{gmshVoronoi}{colorVoronoi}[red]{\def\luameshval@gv@colorVoronoi{#1}}%
736 %
737 \presetkeys{gmshVoronoi}{tikz=false,scale, meshpoint,circumpoint,print=none,color,colorVoronoi,delaunay=none}{}%
738 %
739 \newcommand{\gmshVoronoi}[2][]{%
740   % #1 : optionnal arguments
741   % #2 : the gmsh file
742   \setkeys{gmshVoronoi}{#1} %
743   \def\MeshPoint{\luameshval@gv@meshpoint}%
744   \def\CircumPoint{\luameshval@gv@circumpoint}%
745   \ifKV@gmshVoronoi@tikz% if we are using tikz
746   \directlua{%
747     gmshVoronoiTikZ("#2","\luameshval@gv@print","\luameshval@gv@scale","\luameshval@gv@delaunay","\luameshval@gv@color","\luameshval@gv@colorVoronoi")%
748   }%
749   \else % we are using MP
750   \mplibcolor{\luameshmpcolor}{\luameshval@gv@color}%
751   \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@gv@colorVoronoi}%
752   \directlua{%
753     gmshVoronoiMP("#2","\luameshval@gv@print","\luameshval@gv@scale","\luameshval@gv@delaunay")%
754   }%
755   %
756   \fi%
757 }%

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.