9d7c06bcc7c7985372b9150eccb251a06584cddf
[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 %% style dashed Delaunay
179 \define@choicekey*{buildVoronoiInc}{styleDelaunay}[\val\nr]{none, dashed}{%
180   \ifcase\nr\relax%
181   \def\luameshval@bvi@styleDelaunay{none}%
182   \or%
183   \def\luameshval@bvi@styleDelaunay{dashed}%
184   \fi%
185 }%
186 %% style dashed Voronoi
187 \define@choicekey*{buildVoronoiInc}{styleVoronoi}[\val\nr]{none, dashed}{%
188   \ifcase\nr\relax%
189   \def\luameshval@bvi@styleVoronoi{none}%
190   \or%
191   \def\luameshval@bvi@styleVoronoi{dashed}%
192   \fi%
193 }%
194 %% the name of the point
195 \define@key{buildVoronoiInc}{meshpoint}[P]{\def\luameshval@bvi@meshpoint{#1}}%
196 %% the name of the circum point
197 \define@key{buildVoronoiInc}{circumpoint}[P]{\def\luameshval@bvi@circumpoint{#1}}%
198 %% the mode for reading the points
199 \define@choicekey*{buildVoronoiInc}{mode}[\val\nr]{int, ext}{%
200   \ifcase\nr\relax%
201   \def\luameshval@bvi@mode{int}%
202   \or%
203   \def\luameshval@bvi@mode{ext}%
204   \fi%
205 }%
206 %% the mode for reading the points
207 \define@choicekey*{buildVoronoiInc}{delaunay}[\val\nr]{none, show}{%
208   \ifcase\nr\relax%
209   \def\luameshval@bvi@delaunay{none}%
210   \or%
211   \def\luameshval@bvi@delaunay{show}%
212   \fi%
213 }%
214 %% the name of the color of drawing
215 \define@key{buildVoronoiInc}{color}[black]{\def\luameshval@bvi@color{#1}}%
216 %% the name of the color of drawing Voronoi
217 \define@key{buildVoronoiInc}{colorVoronoi}[red]{\def\luameshval@bvi@colorvoronoi{#1}}%
218 %% the name of the color of drawing the bbox
219 \define@key{buildVoronoiInc}{colorBbox}[black]{\def\luameshval@bvi@colorbbox{#1}}%
220 %
221 \presetkeys{buildVoronoiInc}{tikz=false,bbox=none,scale, meshpoint,circumpoint,mode=int,print=none,color,colorVoronoi,colorBbox,delaunay=none,styleDelaunay=none,styleVoronoi=none}{}%
222 %
223 \newcommand*{\buildVoronoiBWinc}[4][]{%
224   % #1 : optionnal arguments
225   % #2 : the string containing the list of points
226   % (x1,y1);(x2,y2);... or the name file containing the points
227   % #3 : the code to place before the generated one
228   % #4 : the code to place after the generated one
229   \setkeys{buildVoronoiInc}{#1} %
230   \def\MeshPoint{\luameshval@bvi@meshpoint}%
231   \def\CircumPoint{\luameshval@bvi@circumpoint}%
232   \ifKV@buildVoronoiInc@tikz% if we are using tikz
233   \directlua{%
234     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")%
235   }%
236   \else % we are using MP
237   \mplibcolor{\luameshmpcolor}{\luameshval@bvi@color}%
238   \mplibcolor{\luameshmpcolorBbox}{\luameshval@bvi@colorbbox}%
239   \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@bvi@colorvoronoi}%
240   \directlua{%
241     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")%
242   }%
243   %
244   \fi%
245 }%
246 %
247 %%%%%%%%%%%%%%%% the buildVoronoiBW command
248 %% the code is complete and we don't have any callbacks
249 \define@boolkey{buildVoronoi}{tikz}[true]{}%
250 %% show the bounding box for delaunay
251 \define@choicekey*{buildVoronoi}{bbox}[\val\nr]{none, show}{%
252   \ifcase\nr\relax%
253   \def\luameshval@bv@bbox{none}%
254   \or%
255   \def\luameshval@bv@bbox{bbox}%
256   \fi%
257 }%
258 %% the scale
259 \define@key{buildVoronoi}{scale}[1cm]{\def\luameshval@bv@scale{#1}}%
260 %% print points
261 \define@choicekey*{buildVoronoi}{print}[\val\nr]{none, points}{%
262   \ifcase\nr\relax%
263   \def\luameshval@bv@print{none}%
264   \or%
265   \def\luameshval@bv@print{points}%
266   \fi%
267 }%
268 %% the name of the point
269 \define@key{buildVoronoi}{meshpoint}[P]{\def\luameshval@bv@meshpoint{#1}}%
270 %% the name of the circum point
271 \define@key{buildVoronoi}{circumpoint}[P]{\def\luameshval@bv@circumpoint{#1}}%
272 %% the mode for reading the points
273 \define@choicekey*{buildVoronoi}{mode}[\val\nr]{int, ext}{%
274   \ifcase\nr\relax%
275   \def\luameshval@bv@mode{int}%
276   \or%
277   \def\luameshval@bv@mode{ext}%
278   \fi%
279 }%
280 %% style dashed Delaunay
281 \define@choicekey*{buildVoronoi}{styleDelaunay}[\val\nr]{none, dashed}{%
282   \ifcase\nr\relax%
283   \def\luameshval@bv@styleDelaunay{none}%
284   \or%
285   \def\luameshval@bv@styleDelaunay{dashed}%
286   \fi%
287 }%
288 %% style dashed Voronoi
289 \define@choicekey*{buildVoronoi}{styleVoronoi}[\val\nr]{none, dashed}{%
290   \ifcase\nr\relax%
291   \def\luameshval@bv@styleVoronoi{none}%
292   \or%
293   \def\luameshval@bv@styleVoronoi{dashed}%
294   \fi%
295 }%
296 %% the mode for reading the points
297 \define@choicekey*{buildVoronoi}{delaunay}[\val\nr]{none, show}{%
298   \ifcase\nr\relax%
299   \def\luameshval@bv@delaunay{none}%
300   \or%
301   \def\luameshval@bv@delaunay{show}%
302   \fi%
303 }%
304 %% the name of the color of drawing
305 \define@key{buildVoronoi}{color}[black]{\def\luameshval@bv@color{#1}}%
306 %% the name of the color of drawing Voronoi
307 \define@key{buildVoronoi}{colorVoronoi}[red]{\def\luameshval@bv@colorVoronoi{#1}}%
308 %% the name of the color of drawing the bbox
309 \define@key{buildVoronoi}{colorBbox}[black]{\def\luameshval@bv@colorbbox{#1}}%
310 %
311 \presetkeys{buildVoronoi}{tikz=false,bbox=none,scale,
312   meshpoint,circumpoint,mode=int,print=none,color,colorVoronoi,colorBbox,delaunay=none,styleDelaunay=none, styleVoronoi=none}{}%
313 %
314 \newcommand{\buildVoronoiBW}[2][]{%
315   % #1 : optionnal arguments
316   % #2 : the string containing the list of points
317   % (x1,y1);(x2,y2);... or the name file containing the points
318   \setkeys{buildVoronoi}{#1} %
319   \def\MeshPoint{\luameshval@bv@meshpoint}%
320   \def\CircumPoint{\luameshval@bv@circumpoint}%
321   \ifKV@buildVoronoi@tikz% if we are using tikz
322   \directlua{%
323     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")%
324   }%
325   \else % we are using MP
326   \mplibcolor{\luameshmpcolor}{\luameshval@bv@color}%
327   \mplibcolor{\luameshmpcolorBbox}{\luameshval@bv@colorbbox}%
328   \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@bv@colorVoronoi}%
329   \directlua{%
330     buildVoronoiMPBW("#2","\luameshval@bv@mode","\luameshval@bv@print","\luameshval@bv@bbox","\luameshval@bv@scale","\luameshval@bv@delaunay","\luameshval@bv@styleDelaunay","\luameshval@bv@styleVoronoi")%
331   }%
332   %
333   \fi%
334 }%
335 %
336 %
337 %%%%%%%%%%%%%%%%% the draw Points macro
338 %% plot the list of points given in argument
339 % the engine
340 \define@boolkey{drawPoints}{tikz}[true]{}%
341 %% show the bounding box for delaunay
342 \define@choicekey*{drawPoints}{bbox}[\val\nr]{none, show}{%
343   \ifcase\nr\relax%
344   \def\luameshval@tp@bbox{none}%
345   \or%
346   \def\luameshval@tp@bbox{bbox}%
347   \fi%
348 }%
349 %% the scale
350 \define@key{drawPoints}{scale}[1cm]{\def\luameshval@tp@scale{#1}}%
351 %% print points
352 \define@choicekey*{drawPoints}{print}[\val\nr]{none, points}{%
353   \ifcase\nr\relax%
354   \def\luameshval@tp@print{none}%
355   \or%
356   \def\luameshval@tp@print{points}%
357   \fi%
358 }%
359 %% the name of the point
360 \define@key{drawPoints}{meshpoint}[P]{\def\luameshval@tp@meshpoint{#1}}%
361 %% the mode for reading the points
362 \define@choicekey*{drawPoints}{mode}[\val\nr]{int, ext}{%
363   \ifcase\nr\relax%
364   \def\luameshval@tp@mode{int}%
365   \or%
366   \def\luameshval@tp@mode{ext}%
367   \fi%
368 }%
369 %% the name of the color of drawing
370 \define@key{drawPoints}{color}[black]{\def\luameshval@tp@color{#1}}%
371 %% the name of the color of drawing the bbox
372 \define@key{drawPoints}{colorBbox}[black]{\def\luameshval@tp@colorbbox{#1}}%
373 %
374 \presetkeys{drawPoints}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
375 %
376 \newcommand{\drawPointsMesh}[2][]{%
377   % #1 : optionnal arguments
378   % #2 : the string containing the list of points
379   % (x1,y1);(x2,y2);... or the name file containing the points
380   \setkeys{drawPoints}{#1} %
381   \def\MeshPoint{\luameshval@tp@meshpoint}%
382   \ifKV@drawPoints@tikz% if we are using tikz
383   \directlua{%
384     printPointsTikZ("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale","\luameshval@tp@color","\luameshval@tp@colorbbox")%
385   }%
386   \else % we are using MP
387   \mplibcolor{\luameshmpcolor}{\luameshval@tp@color}%
388   \mplibcolor{\luameshmpcolorBbox}{\luameshval@tp@colorbbox}%
389   \directlua{%
390     printPointsMP("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale")%
391   }%
392   %
393   \fi%
394 }%
395 %
396
397 %%%%%%%%%%%%%%%% the draw Points macro inc with callbacks
398 %% engine of drawing
399 \define@boolkey{drawPointsInc}{tikz}[true]{}%
400 %% show the bounding box for delaunay
401 \define@choicekey*{drawPointsInc}{bbox}[\val\nr]{none, show}{%
402   \ifcase\nr\relax%
403   \def\luameshval@tpi@bbox{none}%
404   \or%
405   \def\luameshval@tpi@bbox{bbox}%
406   \fi%
407 }%
408 %% the scale
409 \define@key{drawPointsInc}{scale}[1cm]{\def\luameshval@tpi@scale{#1}}%
410 %% print points
411 \define@choicekey*{drawPointsInc}{print}[\val\nr]{none, points}{%
412   \ifcase\nr\relax%
413   \def\luameshval@tpi@print{none}%
414   \or%
415   \def\luameshval@tpi@print{points}%
416   \fi%
417 }%
418 %% the name of the point
419 \define@key{drawPointsInc}{meshpoint}[P]{\def\luameshval@tpi@meshpoint{#1}}%
420 %% the mode for reading the points
421 \define@choicekey*{drawPointsInc}{mode}[\val\nr]{int, ext}{%
422   \ifcase\nr\relax%
423   \def\luameshval@tpi@mode{int}%
424   \or%
425   \def\luameshval@tpi@mode{ext}%
426   \fi%
427 }%
428 %
429 % color
430 %% the name of the color of drawing
431 \define@key{drawPointsInc}{color}[black]{\def\luameshval@tpi@color{#1}}%
432 %% the name of the color of drawing the bbox
433 \define@key{drawPointsInc}{colorBbox}[black]{\def\luameshval@tpi@colorbbox{#1}}%
434 %
435 \presetkeys{drawPointsInc}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
436 %
437 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
438 \newcommand*{\drawPointsMeshinc}[4][]{%
439   % #1 : optionnal arguments
440   % #2 : the string containing the list of points
441   % (x1,y1);(x2,y2);... or the name file containing the points
442   % #3 : the code to place before the generated one
443   % #4 : the code to place after the generated one
444   \setkeys{drawPointsInc}{#1} %
445   \def\MeshPoint{\luameshval@tpi@meshpoint}%
446   \ifKV@drawPointsInc@tikz% if we are using tikz
447   \directlua{%
448     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")%
449   }%
450   \else % we are using MP
451   \mplibcolor{\luameshmpcolor}{\luameshval@tpi@color}%
452   \mplibcolor{\luameshmpcolorBbox}{\luameshval@tpi@colorbbox}%
453   \directlua{%
454     printPointsMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@tpi@mode","\luameshval@tpi@print","\luameshval@tpi@bbox","\luameshval@tpi@scale")%
455   }%
456   \fi%
457 }%
458 %
459 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
460 %% the meshAddOnePointBW commande
461 %%engine of draiwng
462 \define@boolkey{MeshAddOneBW}{tikz}[true]{}%
463 %% the scale
464 \define@key{MeshAddOneBW}{scale}[1cm]{\def\luameshval@ap@scale{#1}}%
465 %% the name of the points
466 \define@key{MeshAddOneBW}{meshpoint}[P]{\def\luameshval@ap@meshpoint{#1}}%
467 %% the name of the new point
468 \define@key{MeshAddOneBW}{newpoint}[P]{\def\luameshval@ap@newpoint{#1}}%
469 %% a complete picture or some code of the engine
470 \define@choicekey*{MeshAddOneBW}{step}[\val\nr]{badtriangles, cavity, newtriangles}{%
471   \ifcase\nr\relax%
472   \def\luameshval@ap@step{badT}%
473   \or%
474   \def\luameshval@ap@step{cavity}%
475   \or%
476   \def\luameshval@ap@step{newT}%
477   \fi%
478 }%
479 % color
480 %% the color of drawing
481 \define@key{MeshAddOneBW}{color}[black]{\def\luameshval@ap@color{#1}}%
482 %% the color of background of new element
483 \define@key{MeshAddOneBW}{colorBack}[black!20]{\def\luameshval@ap@colorback{#1}}%
484 %% the color of new element
485 \define@key{MeshAddOneBW}{colorNew}[red]{\def\luameshval@ap@colornew{#1}}%
486 %% the color of circoncircle
487 \define@key{MeshAddOneBW}{colorCircle}[green]{\def\luameshval@ap@colorcircle{#1}}%
488 %% the name of the color of drawing the bbox
489 \define@key{MeshAddOneBW}{colorBbox}[black]{\def\luameshval@ap@colorbbox{#1}}%
490 %
491 %% a complete picture or some code of the engine
492 \define@choicekey*{MeshAddOneBW}{mode}[\val\nr]{int, ext}{%
493   \ifcase\nr\relax%
494   \def\luameshval@ap@mode{int}%
495   \or%
496   \def\luameshval@ap@mode{ext}%
497   \fi%
498 }%
499 \define@choicekey*{MeshAddOneBW}{bbox}[\val\nr]{none, show}{%
500   \ifcase\nr\relax%
501   \def\luameshval@ap@bbox{none}%
502   \or%
503   \def\luameshval@ap@bbox{bbox}%
504   \fi%
505 }%
506 \presetkeys{MeshAddOneBW}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}%
507 %
508 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
509 \newcommand*{\meshAddPointBW}[3][]{%
510   % #1 : optionnal arguments
511   % #2 : the string containing the list of points
512   % (x1,y1);(x2,y2);... or the name file containing the points
513   \setkeys{MeshAddOneBW}{#1} %
514   \def\MeshPoint{\luameshval@ap@meshpoint}%
515   \def\NewPoint{\luameshval@ap@newpoint}%
516   \ifKV@MeshAddOneBW@tikz% if we are using tikz
517   \directlua{%
518     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")%
519   }%
520   \else % we are using MP
521   \mplibcolor{\luameshmpcolor}{\luameshval@ap@color}
522   \mplibcolor{\luameshmpcolorBack}{\luameshval@ap@colorback}
523   \mplibcolor{\luameshmpcolorNew}{\luameshval@ap@colornew}
524   \mplibcolor{\luameshmpcolorCircle}{\luameshval@ap@colorcircle}
525   \mplibcolor{\luameshmpcolorBbox}{\luameshval@ap@colorbbox}
526   \directlua{%
527     TeXOnePointMPBW("#2","#3","\luameshval@ap@step","\luameshval@ap@scale","\luameshval@ap@mode","\luameshval@ap@bbox")%
528   }%
529   %
530   \fi%
531 }%
532 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
533 %%% the meshAddPointBWinc commande with callbacks
534 %% engine of drawing
535 \define@boolkey{MeshAddOneBWinc}{tikz}[true]{}%
536 %% the scale
537 \define@key{MeshAddOneBWinc}{scale}[1cm]{\def\luameshval@api@scale{#1}}%
538 %% the name of the points
539 \define@key{MeshAddOneBWinc}{meshpoint}[P]{\def\luameshval@api@meshpoint{#1}}%
540 %% the name of the new point
541 \define@key{MeshAddOneBWinc}{newpoint}[P]{\def\luameshval@api@newpoint{#1}}%
542 %% a complete picture or some code of the engine
543 \define@choicekey*{MeshAddOneBWinc}{step}[\val\nr]{badtriangles, cavity, newtriangles}{%
544   \ifcase\nr\relax%
545   \def\luameshval@api@step{badT}%
546   \or%
547   \def\luameshval@api@step{cavity}%
548   \or%
549   \def\luameshval@api@step{newT}%
550   \fi%
551 }%
552 % color
553 %% the color of drawing
554 \define@key{MeshAddOneBWinc}{color}[black]{\def\luameshval@api@color{#1}}%
555 %% the color of background of new element
556 \define@key{MeshAddOneBWinc}{colorBack}[black!20]{\def\luameshval@api@colorback{#1}}%
557 %% the color of new element
558 \define@key{MeshAddOneBWinc}{colorNew}[red]{\def\luameshval@api@colornew{#1}}%
559 %% the color of circoncircle
560 \define@key{MeshAddOneBWinc}{colorCircle}[green]{\def\luameshval@api@colorcircle{#1}}%
561 \define@key{MeshAddOneBWinc}{colorBbox}[black]{\def\luameshval@api@colorbbox{#1}}%
562 %
563 %% a complete picture or some code of the engine
564 \define@choicekey*{MeshAddOneBWinc}{mode}[\val\nr]{int, ext}{%
565   \ifcase\nr\relax%
566   \def\luameshval@api@mode{int}%
567   \or%
568   \def\luameshval@api@mode{ext}%
569   \fi%
570 }%
571 \define@choicekey*{MeshAddOneBWinc}{bbox}[\val\nr]{none, show}{%
572   \ifcase\nr\relax%
573   \def\luameshval@api@bbox{none}%
574   \or%
575   \def\luameshval@api@bbox{bbox}%
576   \fi%
577 }%
578 \presetkeys{MeshAddOneBWinc}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}%
579 %
580 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
581 \newcommand*{\meshAddPointBWinc}[5][]{%
582   % #1 : optionnal arguments
583   % #2 : the string containing the list of points
584   % (x1,y1);(x2,y2);... or the name file containing the points
585   % #3 : the code to place before the generated one
586   % #4 : the code to place after the generated one
587   \setkeys{MeshAddOneBWinc}{#1} %
588   \def\MeshPoint{\luameshval@api@meshpoint}%
589   \def\NewPoint{\luameshval@api@newpoint}%
590   \ifKV@MeshAddOneBWinc@tikz% if we are using tikz
591   \directlua{%
592     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")%
593   }%
594   \else % we are using MP
595   \mplibcolor{\luameshmpcolor}{\luameshval@api@color}
596   \mplibcolor{\luameshmpcolorBack}{\luameshval@api@colorback}
597   \mplibcolor{\luameshmpcolorNew}{\luameshval@api@colornew}
598   \mplibcolor{\luameshmpcolorCircle}{\luameshval@api@colorcircle}
599   \mplibcolor{\luameshmpcolorBbox}{\luameshval@api@colorbbox}
600   \directlua{%
601     TeXOnePointMPBWinc("#2","#3","\luaescapestring{\unexpanded{#4}}","\luaescapestring{\unexpanded{#5}}","\luameshval@api@step","\luameshval@api@scale","\luameshval@api@mode","\luameshval@api@bbox")%
602   }%
603   %
604   \fi%
605 }%
606 %
607 %%%%%%%%%%%%%%%% the drawGmsh command inc
608 %% the user can write code (tikz or MP)
609 %% before and after the generated code
610 \define@boolkey{drawGmshInc}{tikz}[true]{}%
611 %% the scale
612 \define@key{drawGmshInc}{scale}[1cm]{\def\luameshvaldgi@scale{#1}}%
613 %% print ponits ?
614 \define@choicekey*{drawGmshInc}{print}[\val\nr]{none, points}{%
615   \ifcase\nr\relax%
616   \def\luameshvaldgi@print{none}%
617   \or%
618   \def\luameshvaldgi@print{points}%
619   \fi%
620 }%
621 %% the name of the point
622 \define@key{drawGmshInc}{meshpoint}[P]{\def\luameshvaldgi@meshpoint{#1}}%
623 %% the name of the color of drawing
624 \define@key{drawGmshInc}{color}[black]{\def\luameshvaldgi@color{#1}}%
625 %
626 \presetkeys{drawGmshInc}{tikz=false,scale, meshpoint,print=none,color}{}%
627 %
628 \newcommand*{\drawGmshinc}[4][]{%
629   % #1 : optionnal arguments
630   % #2 : the string containing the gmsh file
631   % #3 : the code to place before the generated one
632   % #4 : the code to place after the generated one
633   \setkeys{drawGmshInc}{#1} %
634   \def\MeshPoint{\luameshvaldgi@meshpoint}%
635   \ifKV@drawGmshInc@tikz% if we are using tikz
636   \directlua{%
637     drawGmshTikZinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshvaldgi@print","\luameshvaldgi@scale","\luameshvaldgi@color")%
638   }%
639   \else % we are using MP
640   \mplibcolor{\luameshmpcolor}{\luameshvaldgi@color}%
641   \directlua{%
642     drawGmshMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshvaldgi@print","\luameshvaldgi@scale")%
643   }%
644   %
645   \fi%
646 }%
647 %
648 %%%%%%%%%%%%%%%% the drawGmshBW command
649 %% the code is complete and we don't have any callbacks
650 \define@boolkey{drawGmsh}{tikz}[true]{}%
651 %% the scale
652 \define@key{drawGmsh}{scale}[1cm]{\def\luameshvaldg@scale{#1}}%
653 %% print points
654 \define@choicekey*{drawGmsh}{print}[\val\nr]{none, points}{%
655   \ifcase\nr\relax%
656   \def\luameshvaldg@print{none}%
657   \or%
658   \def\luameshvaldg@print{points}%
659   \fi%
660 }%
661 %% the name of the point
662 \define@key{drawGmsh}{meshpoint}[P]{\def\luameshvaldg@meshpoint{#1}}%
663 %% the name of the color of drawing
664 \define@key{drawGmsh}{color}[black]{\def\luameshvaldg@color{#1}}%
665 %
666 \presetkeys{drawGmsh}{tikz=false,scale, meshpoint,print=none,color}{}%
667 %
668 \newcommand{\drawGmsh}[2][]{%
669   % #1 : optionnal arguments
670   % #2 : the gmsh file
671   \setkeys{drawGmsh}{#1} %
672   \def\MeshPoint{\luameshvaldg@meshpoint}%
673   \ifKV@drawGmsh@tikz% if we are using tikz
674   \directlua{%
675     drawGmshTikZ("#2","\luameshvaldg@print","\luameshvaldg@scale","\luameshvaldg@color")%
676   }%
677   \else % we are using MP
678   \mplibcolor{\luameshmpcolor}{\luameshvaldg@color}%
679   \directlua{%
680     drawGmshMP("#2","\luameshvaldg@print","\luameshvaldg@scale")%
681   }%
682   %
683   \fi%
684 }%
685 %%%%%%%%%%%%%%%% the gmshVoronoi command
686 %% the user can write code (tikz or MP)
687 %% before and after the generated code
688 \define@boolkey{gmshVoronoiInc}{tikz}[true]{}%
689 %% the scale
690 \define@key{gmshVoronoiInc}{scale}[1cm]{\def\luameshval@gvi@scale{#1}}%
691 %% print ponits ?
692 \define@choicekey*{gmshVoronoiInc}{print}[\val\nr]{none, points}{%
693   \ifcase\nr\relax%
694   \def\luameshval@gvi@print{none}%
695   \or%
696   \def\luameshval@gvi@print{points}%
697   \fi%
698 }%
699 %% the name of the point
700 \define@key{gmshVoronoiInc}{meshpoint}[P]{\def\luameshval@gvi@meshpoint{#1}}%
701 %% the name of the circum point
702 \define@key{gmshVoronoiInc}{circumpoint}[P]{\def\luameshval@gvi@circumpoint{#1}}%
703 %% the mode for reading the points
704 \define@choicekey*{gmshVoronoiInc}{delaunay}[\val\nr]{none, show}{%
705   \ifcase\nr\relax%
706   \def\luameshval@gvi@delaunay{none}%
707   \or%
708   \def\luameshval@gvi@delaunay{show}%
709   \fi%
710 }%
711 %% style dashed Delaunay
712 \define@choicekey*{gmshVoronoiInc}{styleDelaunay}[\val\nr]{none, dashed}{%
713   \ifcase\nr\relax%
714   \def\luameshval@gvi@styleDelaunay{none}%
715   \or%
716   \def\luameshval@gvi@styleDelaunay{dashed}%
717   \fi%
718 }%
719 %% style dashed Voronoi
720 \define@choicekey*{gmshVoronoiInc}{styleVoronoi}[\val\nr]{none, dashed}{%
721   \ifcase\nr\relax%
722   \def\luameshval@gvi@styleVoronoi{none}%
723   \or%
724   \def\luameshval@gvi@styleVoronoi{dashed}%
725   \fi%
726 }%
727 %% the name of the color of drawing
728 \define@key{gmshVoronoiInc}{color}[black]{\def\luameshval@gvi@color{#1}}%
729 %% the name of the color of drawing Voronoi
730 \define@key{gmshVoronoiInc}{colorVoronoi}[red]{\def\luameshval@gvi@colorvoronoi{#1}}%
731 %
732 \presetkeys{gmshVoronoiInc}{tikz=false,scale,
733   meshpoint,circumpoint,print=none,color,colorVoronoi,delaunay=none,styleVoronoi=none, styleDelaunay=none}{}%
734 %
735 \newcommand*{\gmshVoronoiinc}[4][]{%
736   % #1 : optionnal arguments
737   % #2 : the gmsh file
738   % #3 : the code to place before the generated one
739   % #4 : the code to place after the generated one
740   \setkeys{gmshVoronoiInc}{#1} %
741   \def\MeshPoint{\luameshval@gvi@meshpoint}%
742   \def\CircumPoint{\luameshval@gvi@circumpoint}%
743   \ifKV@gmshVoronoiInc@tikz% if we are using tikz
744   \directlua{%
745     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")%
746   }%
747   \else % we are using MP
748   \mplibcolor{\luameshmpcolor}{\luameshval@gvi@color}%
749   \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@gvi@colorvoronoi}%
750   \directlua{%
751     gmshVoronoiMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@gvi@print","\luameshval@gvi@scale","\luameshval@gvi@delaunay","\luameshval@gvi@styleDelaunay","\luameshval@gvi@styleVoronoi")%
752   }%
753   %
754   \fi%
755 }%
756 %
757 %%%%%%%%%%%%%%%% the gmshVoronoiBW command
758 %% the code is complete and we don't have any callbacks
759 \define@boolkey{gmshVoronoi}{tikz}[true]{}%
760 %% the scale
761 \define@key{gmshVoronoi}{scale}[1cm]{\def\luameshval@gv@scale{#1}}%
762 %% print points
763 \define@choicekey*{gmshVoronoi}{print}[\val\nr]{none, points}{%
764   \ifcase\nr\relax%
765   \def\luameshval@gv@print{none}%
766   \or%
767   \def\luameshval@gv@print{points}%
768   \fi%
769 }%
770 %% the name of the point
771 \define@key{gmshVoronoi}{meshpoint}[P]{\def\luameshval@gv@meshpoint{#1}}%
772 %% the name of the circum point
773 \define@key{gmshVoronoi}{circumpoint}[P]{\def\luameshval@gv@circumpoint{#1}}%
774 %% the mode for reading the points
775 \define@choicekey*{gmshVoronoi}{delaunay}[\val\nr]{none, show}{%
776   \ifcase\nr\relax%
777   \def\luameshval@gv@delaunay{none}%
778   \or%
779   \def\luameshval@gv@delaunay{show}%
780   \fi%
781 }%
782 %% style dashed Delaunay
783 \define@choicekey*{gmshVoronoi}{styleDelaunay}[\val\nr]{none, dashed}{%
784   \ifcase\nr\relax%
785   \def\luameshval@gv@styleDelaunay{none}%
786   \or%
787   \def\luameshval@gv@styleDelaunay{dashed}%
788   \fi%
789 }%
790 %% style dashed Voronoi
791 \define@choicekey*{gmshVoronoi}{styleVoronoi}[\val\nr]{none, dashed}{%
792   \ifcase\nr\relax%
793   \def\luameshval@gv@styleVoronoi{none}%
794   \or%
795   \def\luameshval@gv@styleVoronoi{dashed}%
796   \fi%
797 }%
798 %% the name of the color of drawing
799 \define@key{gmshVoronoi}{color}[black]{\def\luameshval@gv@color{#1}}%
800 %% the name of the color of drawing Voronoi
801 \define@key{gmshVoronoi}{colorVoronoi}[red]{\def\luameshval@gv@colorVoronoi{#1}}%
802 %
803 \presetkeys{gmshVoronoi}{tikz=false,scale, meshpoint,circumpoint,print=none,color,colorVoronoi,delaunay=none,styleVoronoi=none, styleDelaunay=none}{}%
804 %
805 \newcommand{\gmshVoronoi}[2][]{%
806   % #1 : optionnal arguments
807   % #2 : the gmsh file
808   \setkeys{gmshVoronoi}{#1} %
809   \def\MeshPoint{\luameshval@gv@meshpoint}%
810   \def\CircumPoint{\luameshval@gv@circumpoint}%
811   \ifKV@gmshVoronoi@tikz% if we are using tikz
812   \directlua{%
813     gmshVoronoiTikZ("#2","\luameshval@gv@print","\luameshval@gv@scale","\luameshval@gv@delaunay","\luameshval@gv@color","\luameshval@gv@colorVoronoi","\luameshval@gv@styleDelaunay","\luameshval@gv@styleVoronoi")%
814   }%
815   \else % we are using MP
816   \mplibcolor{\luameshmpcolor}{\luameshval@gv@color}%
817   \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@gv@colorVoronoi}%
818   \directlua{%
819     gmshVoronoiMP("#2","\luameshval@gv@print","\luameshval@gv@scale","\luameshval@gv@delaunay","\luameshval@gv@styleDelaunay","\luameshval@gv@styleVoronoi")%
820   }%
821   %
822   \fi%
823 }%

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.