1 \NeedsTeXFormat{LaTeX2e}%
2 \def\PackageName{luamesh}%
3 \def\fileversion{v0.5}%
4 \def\filedate{2017/02/09}%
5 \ProvidesPackage{luamesh}[\filedate\space\fileversion]%
8 \RequirePackage{xkeyval,xcolor,ifthen}%
9 %% one global option: mp or tikz
11 %\define@key{luamesh.sty}{mp}[]{\luameshmptrue}%
12 %\define@key{luamesh.sty}{tikz}[]{\luameshmpfalse}%
14 %\RequirePackage{etoolbox} % pour robustifier les commandes
18 \RequirePackage{luamplib}%
20 \RequirePackage{tikz}%
24 \directlua{require("luamesh.lua")}%
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}
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}{%
45 \def\luameshval@bmi@bbox{none}%
47 \def\luameshval@bmi@bbox{bbox}%
51 \define@key{buildMeshInc}{scale}[1cm]{\def\luameshval@bmi@scale{#1}}%
53 \define@choicekey*{buildMeshInc}{print}[\val\nr]{none, points,dotpoints}{%
55 \def\luameshval@bmi@print{none}%
57 \def\luameshval@bmi@print{points}%
59 \def\luameshval@bmi@print{dotpoints}%
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}{%
67 \def\luameshval@bmi@mode{int}%
69 \def\luameshval@bmi@mode{ext}%
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}}%
77 \presetkeys{buildMeshInc}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
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
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")%
91 \else % we are using MP
92 \mplibcolor{\luameshmpcolor}{\luameshval@bmi@color}%
93 \mplibcolor{\luameshmpcolorBbox}{\luameshval@bmi@colorbbox}%
95 buildMeshMPBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bmi@mode","\luameshval@bmi@print","\luameshval@bmi@bbox","\luameshval@bmi@scale")%
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}{%
107 \def\luameshval@bm@bbox{none}%
109 \def\luameshval@bm@bbox{bbox}%
113 \define@key{buildMesh}{scale}[1cm]{\def\luameshval@bm@scale{#1}}%
115 \define@choicekey*{buildMesh}{print}[\val\nr]{none, points, dotpoints}{%
117 \def\luameshval@bm@print{none}%
119 \def\luameshval@bm@print{points}%
121 \def\luameshval@bm@print{dotpoints}%
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}{%
129 \def\luameshval@bm@mode{int}%
131 \def\luameshval@bm@mode{ext}%
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}}%
139 \presetkeys{buildMesh}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
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
149 buildMeshTikZBW("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","\luameshval@bm@scale","\luameshval@bm@color","\luameshval@bm@colorbbox")%
151 \else % we are using MP
152 \mplibcolor{\luameshmpcolor}{\luameshval@bm@color}%
153 \mplibcolor{\luameshmpcolorBbox}{\luameshval@bm@colorbbox}%
155 buildMeshMPBW("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","\luameshval@bm@scale")%
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}{%
167 \def\luameshval@bvi@bbox{none}%
169 \def\luameshval@bvi@bbox{bbox}%
173 \define@key{buildVoronoiInc}{scale}[1cm]{\def\luameshval@bvi@scale{#1}}%
175 \define@choicekey*{buildVoronoiInc}{print}[\val\nr]{none, points}{%
177 \def\luameshval@bvi@print{none}%
179 \def\luameshval@bvi@print{points}%
182 %% style dashed Delaunay
183 \define@choicekey*{buildVoronoiInc}{styleDelaunay}[\val\nr]{none, dashed}{%
185 \def\luameshval@bvi@styleDelaunay{none}%
187 \def\luameshval@bvi@styleDelaunay{dashed}%
190 %% style dashed Voronoi
191 \define@choicekey*{buildVoronoiInc}{styleVoronoi}[\val\nr]{none, dashed}{%
193 \def\luameshval@bvi@styleVoronoi{none}%
195 \def\luameshval@bvi@styleVoronoi{dashed}%
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}{%
205 \def\luameshval@bvi@mode{int}%
207 \def\luameshval@bvi@mode{ext}%
210 %% the mode for reading the points
211 \define@choicekey*{buildVoronoiInc}{delaunay}[\val\nr]{none, show}{%
213 \def\luameshval@bvi@delaunay{none}%
215 \def\luameshval@bvi@delaunay{show}%
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}}%
225 \presetkeys{buildVoronoiInc}{tikz=false,bbox=none,scale, meshpoint,circumpoint,mode=int,print=none,color,colorVoronoi,colorBbox,delaunay=none,styleDelaunay=none,styleVoronoi=none}{}%
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
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")%
240 \else % we are using MP
241 \mplibcolor{\luameshmpcolor}{\luameshval@bvi@color}%
242 \mplibcolor{\luameshmpcolorBbox}{\luameshval@bvi@colorbbox}%
243 \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@bvi@colorvoronoi}%
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")%
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}{%
257 \def\luameshval@bv@bbox{none}%
259 \def\luameshval@bv@bbox{bbox}%
263 \define@key{buildVoronoi}{scale}[1cm]{\def\luameshval@bv@scale{#1}}%
265 \define@choicekey*{buildVoronoi}{print}[\val\nr]{none, points}{%
267 \def\luameshval@bv@print{none}%
269 \def\luameshval@bv@print{points}%
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}{%
279 \def\luameshval@bv@mode{int}%
281 \def\luameshval@bv@mode{ext}%
284 %% style dashed Delaunay
285 \define@choicekey*{buildVoronoi}{styleDelaunay}[\val\nr]{none, dashed}{%
287 \def\luameshval@bv@styleDelaunay{none}%
289 \def\luameshval@bv@styleDelaunay{dashed}%
292 %% style dashed Voronoi
293 \define@choicekey*{buildVoronoi}{styleVoronoi}[\val\nr]{none, dashed}{%
295 \def\luameshval@bv@styleVoronoi{none}%
297 \def\luameshval@bv@styleVoronoi{dashed}%
300 %% the mode for reading the points
301 \define@choicekey*{buildVoronoi}{delaunay}[\val\nr]{none, show}{%
303 \def\luameshval@bv@delaunay{none}%
305 \def\luameshval@bv@delaunay{show}%
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}}%
315 \presetkeys{buildVoronoi}{tikz=false,bbox=none,scale,
316 meshpoint,circumpoint,mode=int,print=none,color,colorVoronoi,colorBbox,delaunay=none,styleDelaunay=none, styleVoronoi=none}{}%
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
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")%
329 \else % we are using MP
330 \mplibcolor{\luameshmpcolor}{\luameshval@bv@color}%
331 \mplibcolor{\luameshmpcolorBbox}{\luameshval@bv@colorbbox}%
332 \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@bv@colorVoronoi}%
334 buildVoronoiMPBW("#2","\luameshval@bv@mode","\luameshval@bv@print","\luameshval@bv@bbox","\luameshval@bv@scale","\luameshval@bv@delaunay","\luameshval@bv@styleDelaunay","\luameshval@bv@styleVoronoi")%
341 %%%%%%%%%%%%%%%%% the draw Points macro
342 %% plot the list of points given in argument
344 \define@boolkey{drawPoints}{tikz}[true]{}%
345 %% show the bounding box for delaunay
346 \define@choicekey*{drawPoints}{bbox}[\val\nr]{none, show}{%
348 \def\luameshval@tp@bbox{none}%
350 \def\luameshval@tp@bbox{bbox}%
354 \define@key{drawPoints}{scale}[1cm]{\def\luameshval@tp@scale{#1}}%
356 \define@choicekey*{drawPoints}{print}[\val\nr]{none, points}{%
358 \def\luameshval@tp@print{none}%
360 \def\luameshval@tp@print{points}%
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}{%
368 \def\luameshval@tp@mode{int}%
370 \def\luameshval@tp@mode{ext}%
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}}%
378 \presetkeys{drawPoints}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
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
388 printPointsTikZ("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale","\luameshval@tp@color","\luameshval@tp@colorbbox")%
390 \else % we are using MP
391 \mplibcolor{\luameshmpcolor}{\luameshval@tp@color}%
392 \mplibcolor{\luameshmpcolorBbox}{\luameshval@tp@colorbbox}%
394 printPointsMP("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale")%
401 %%%%%%%%%%%%%%%% the draw Points macro inc with callbacks
403 \define@boolkey{drawPointsInc}{tikz}[true]{}%
404 %% show the bounding box for delaunay
405 \define@choicekey*{drawPointsInc}{bbox}[\val\nr]{none, show}{%
407 \def\luameshval@tpi@bbox{none}%
409 \def\luameshval@tpi@bbox{bbox}%
413 \define@key{drawPointsInc}{scale}[1cm]{\def\luameshval@tpi@scale{#1}}%
415 \define@choicekey*{drawPointsInc}{print}[\val\nr]{none, points}{%
417 \def\luameshval@tpi@print{none}%
419 \def\luameshval@tpi@print{points}%
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}{%
427 \def\luameshval@tpi@mode{int}%
429 \def\luameshval@tpi@mode{ext}%
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}}%
439 \presetkeys{drawPointsInc}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
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
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")%
454 \else % we are using MP
455 \mplibcolor{\luameshmpcolor}{\luameshval@tpi@color}%
456 \mplibcolor{\luameshmpcolorBbox}{\luameshval@tpi@colorbbox}%
458 printPointsMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@tpi@mode","\luameshval@tpi@print","\luameshval@tpi@bbox","\luameshval@tpi@scale")%
463 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
464 %% the meshAddOnePointBW commande
466 \define@boolkey{MeshAddOneBW}{tikz}[true]{}%
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}{%
476 \def\luameshval@ap@step{badT}%
478 \def\luameshval@ap@step{cavity}%
480 \def\luameshval@ap@step{newT}%
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}}%
495 %% a complete picture or some code of the engine
496 \define@choicekey*{MeshAddOneBW}{mode}[\val\nr]{int, ext}{%
498 \def\luameshval@ap@mode{int}%
500 \def\luameshval@ap@mode{ext}%
503 \define@choicekey*{MeshAddOneBW}{bbox}[\val\nr]{none, show}{%
505 \def\luameshval@ap@bbox{none}%
507 \def\luameshval@ap@bbox{bbox}%
510 \presetkeys{MeshAddOneBW}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}%
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
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")%
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}
531 TeXOnePointMPBW("#2","#3","\luameshval@ap@step","\luameshval@ap@scale","\luameshval@ap@mode","\luameshval@ap@bbox")%
536 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
537 %%% the meshAddPointBWinc commande with callbacks
539 \define@boolkey{MeshAddOneBWinc}{tikz}[true]{}%
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}{%
549 \def\luameshval@api@step{badT}%
551 \def\luameshval@api@step{cavity}%
553 \def\luameshval@api@step{newT}%
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}}%
567 %% a complete picture or some code of the engine
568 \define@choicekey*{MeshAddOneBWinc}{mode}[\val\nr]{int, ext}{%
570 \def\luameshval@api@mode{int}%
572 \def\luameshval@api@mode{ext}%
575 \define@choicekey*{MeshAddOneBWinc}{bbox}[\val\nr]{none, show}{%
577 \def\luameshval@api@bbox{none}%
579 \def\luameshval@api@bbox{bbox}%
582 \presetkeys{MeshAddOneBWinc}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}%
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
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")%
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}
605 TeXOnePointMPBWinc("#2","#3","\luaescapestring{\unexpanded{#4}}","\luaescapestring{\unexpanded{#5}}","\luameshval@api@step","\luameshval@api@scale","\luameshval@api@mode","\luameshval@api@bbox")%
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]{}%
616 \define@key{drawGmshInc}{scale}[1cm]{\def\luameshvaldgi@scale{#1}}%
618 \define@choicekey*{drawGmshInc}{print}[\val\nr]{none, points}{%
620 \def\luameshvaldgi@print{none}%
622 \def\luameshvaldgi@print{points}%
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}}%
630 \presetkeys{drawGmshInc}{tikz=false,scale, meshpoint,print=none,color}{}%
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
641 drawGmshTikZinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshvaldgi@print","\luameshvaldgi@scale","\luameshvaldgi@color")%
643 \else % we are using MP
644 \mplibcolor{\luameshmpcolor}{\luameshvaldgi@color}%
646 drawGmshMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshvaldgi@print","\luameshvaldgi@scale")%
652 %%%%%%%%%%%%%%%% the drawGmshBW command
653 %% the code is complete and we don't have any callbacks
654 \define@boolkey{drawGmsh}{tikz}[true]{}%
656 \define@key{drawGmsh}{scale}[1cm]{\def\luameshvaldg@scale{#1}}%
658 \define@choicekey*{drawGmsh}{print}[\val\nr]{none, points}{%
660 \def\luameshvaldg@print{none}%
662 \def\luameshvaldg@print{points}%
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}}%
670 \presetkeys{drawGmsh}{tikz=false,scale, meshpoint,print=none,color}{}%
672 \newcommand{\drawGmsh}[2][]{%
673 % #1 : optionnal arguments
675 \setkeys{drawGmsh}{#1} %
676 \def\MeshPoint{\luameshvaldg@meshpoint}%
677 \ifKV@drawGmsh@tikz% if we are using tikz
679 drawGmshTikZ("#2","\luameshvaldg@print","\luameshvaldg@scale","\luameshvaldg@color")%
681 \else % we are using MP
682 \mplibcolor{\luameshmpcolor}{\luameshvaldg@color}%
684 drawGmshMP("#2","\luameshvaldg@print","\luameshvaldg@scale")%
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]{}%
694 \define@key{gmshVoronoiInc}{scale}[1cm]{\def\luameshval@gvi@scale{#1}}%
696 \define@choicekey*{gmshVoronoiInc}{print}[\val\nr]{none, points}{%
698 \def\luameshval@gvi@print{none}%
700 \def\luameshval@gvi@print{points}%
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}{%
710 \def\luameshval@gvi@delaunay{none}%
712 \def\luameshval@gvi@delaunay{show}%
715 %% style dashed Delaunay
716 \define@choicekey*{gmshVoronoiInc}{styleDelaunay}[\val\nr]{none, dashed}{%
718 \def\luameshval@gvi@styleDelaunay{none}%
720 \def\luameshval@gvi@styleDelaunay{dashed}%
723 %% style dashed Voronoi
724 \define@choicekey*{gmshVoronoiInc}{styleVoronoi}[\val\nr]{none, dashed}{%
726 \def\luameshval@gvi@styleVoronoi{none}%
728 \def\luameshval@gvi@styleVoronoi{dashed}%
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}}%
736 \presetkeys{gmshVoronoiInc}{tikz=false,scale,
737 meshpoint,circumpoint,print=none,color,colorVoronoi,delaunay=none,styleVoronoi=none, styleDelaunay=none}{}%
739 \newcommand*{\gmshVoronoiinc}[4][]{%
740 % #1 : optionnal arguments
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
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")%
751 \else % we are using MP
752 \mplibcolor{\luameshmpcolor}{\luameshval@gvi@color}%
753 \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@gvi@colorvoronoi}%
755 gmshVoronoiMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@gvi@print","\luameshval@gvi@scale","\luameshval@gvi@delaunay","\luameshval@gvi@styleDelaunay","\luameshval@gvi@styleVoronoi")%
761 %%%%%%%%%%%%%%%% the gmshVoronoiBW command
762 %% the code is complete and we don't have any callbacks
763 \define@boolkey{gmshVoronoi}{tikz}[true]{}%
765 \define@key{gmshVoronoi}{scale}[1cm]{\def\luameshval@gv@scale{#1}}%
767 \define@choicekey*{gmshVoronoi}{print}[\val\nr]{none, points}{%
769 \def\luameshval@gv@print{none}%
771 \def\luameshval@gv@print{points}%
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}{%
781 \def\luameshval@gv@delaunay{none}%
783 \def\luameshval@gv@delaunay{show}%
786 %% style dashed Delaunay
787 \define@choicekey*{gmshVoronoi}{styleDelaunay}[\val\nr]{none, dashed}{%
789 \def\luameshval@gv@styleDelaunay{none}%
791 \def\luameshval@gv@styleDelaunay{dashed}%
794 %% style dashed Voronoi
795 \define@choicekey*{gmshVoronoi}{styleVoronoi}[\val\nr]{none, dashed}{%
797 \def\luameshval@gv@styleVoronoi{none}%
799 \def\luameshval@gv@styleVoronoi{dashed}%
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}}%
807 \presetkeys{gmshVoronoi}{tikz=false,scale, meshpoint,circumpoint,print=none,color,colorVoronoi,delaunay=none,styleVoronoi=none, styleDelaunay=none}{}%
809 \newcommand{\gmshVoronoi}[2][]{%
810 % #1 : optionnal arguments
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
817 gmshVoronoiTikZ("#2","\luameshval@gv@print","\luameshval@gv@scale","\luameshval@gv@delaunay","\luameshval@gv@color","\luameshval@gv@colorVoronoi","\luameshval@gv@styleDelaunay","\luameshval@gv@styleVoronoi")%
819 \else % we are using MP
820 \mplibcolor{\luameshmpcolor}{\luameshval@gv@color}%
821 \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@gv@colorVoronoi}%
823 gmshVoronoiMP("#2","\luameshval@gv@print","\luameshval@gv@scale","\luameshval@gv@delaunay","\luameshval@gv@styleDelaunay","\luameshval@gv@styleVoronoi")%
831 %%%%%%%%%%%%%%%% the meshPolygon command
833 \define@boolkey{meshPolygon}{tikz}[true]{}%
836 \define@key{meshPolygon}{scale}[1cm]{\def\luameshval@mp@scale{#1}}%
838 \define@choicekey*{meshPolygon}{print}[\val\nr]{none, points,dotpoints}{%
840 \def\luameshval@mp@print{none}%
842 \def\luameshval@mp@print{points}%
844 \def\luameshval@mp@print{dotpoints}%
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}{%
854 \def\luameshval@mp@mode{int}%
856 \def\luameshval@mp@mode{ext}%
859 %% the mode for the generation of gridpoints
860 \define@choicekey*{meshPolygon}{gridpoints}[\val\nr]{rect, perturb}{%
862 \def\luameshval@mp@gridpoints{rect}%
864 \def\luameshval@mp@gridpoints{perturb}%
867 %% the different steps of the meshing
868 \define@choicekey*{meshPolygon}{step}[\val\nr]{polygon, grid, points, mesh}{%
870 \def\luameshval@mp@step{polygon}%
872 \def\luameshval@mp@step{grid}%
874 \def\luameshval@mp@step{points}%
876 \def\luameshval@mp@step{mesh}%
880 %% the name of the color of drawing
881 \define@key{meshPolygon}{color}[black]{\def\luameshval@mp@color{#1}}%
882 %% the name of the color of drawing Voronoi
883 \define@key{meshPolygon}{colorPolygon}[red]{\def\luameshval@mp@colorPolygon{#1}}%
884 %% the name of the color of drawing the bbox
886 \presetkeys{meshPolygon}{tikz=false,scale,mode=int,step=mesh,print=none,color,colorPolygon,h,meshpoint,gridpoints=rect}{}%
888 \newcommand{\meshPolygon}[2][]{%
889 % #1 : optionnal arguments
890 % #2 : the string containing the list of points
891 % (x1,y1);(x2,y2);... or the name file containing the points
892 \setkeys{meshPolygon}{#1} %
893 \def\MeshPoint{\luameshval@mp@meshpoint}%
894 \ifKV@meshPolygon@tikz% if we are using tikz
896 drawMeshPolygonTikZ("#2","\luameshval@mp@mode","\luameshval@mp@h","\luameshval@mp@step","\luameshval@mp@print","\luameshval@mp@scale","\luameshval@mp@color","\luameshval@mp@colorPolygon","\luameshval@mp@gridpoints")%
898 \else % we are using MP
899 \mplibcolor{\luameshmpcolor}{\luameshval@mp@color}%
900 \mplibcolor{\luameshmpcolorPoly}{\luameshval@mp@colorPolygon}%
902 drawMeshPolygonMP("#2","\luameshval@mp@mode","\luameshval@mp@h","\luameshval@mp@step","\luameshval@mp@print","\luameshval@mp@scale","\luameshval@mp@gridpoints")%
907 %%%%%%%%%%%%%%%% the meshPolygonInc command
909 \define@boolkey{meshPolygonInc}{tikz}[true]{}%
912 \define@key{meshPolygonInc}{scale}[1cm]{\def\luameshval@mpi@scale{#1}}%
914 \define@choicekey*{meshPolygonInc}{print}[\val\nr]{none, points,dotpoints}{%
916 \def\luameshval@mpi@print{none}%
918 \def\luameshval@mpi@print{points}%
920 \def\luameshval@mpi@print{dotpoints}%
923 %% the mode for the generation of gridpoints
924 \define@choicekey*{meshPolygonInc}{gridpoints}[\val\nr]{rect, perturb}{%
926 \def\luameshval@mpi@gridpoints{rect}%
928 \def\luameshval@mpi@gridpoints{perturb}%
931 %% the name of the point
932 \define@key{meshPolygonInc}{meshpoint}[P]{\def\luameshval@mpi@meshpoint{#1}}%
933 %% the grid parameter
934 \define@key{meshPolygonInc}{h}[0.2]{\def\luameshval@mpi@h{#1}}%
935 %% the mode for reading the points
936 \define@choicekey*{meshPolygonInc}{mode}[\val\nr]{int, ext}{%
938 \def\luameshval@mpi@mode{int}%
940 \def\luameshval@mpi@mode{ext}%
943 %% the different steps of the meshing
944 \define@choicekey*{meshPolygonInc}{step}[\val\nr]{polygon, grid, points, mesh}{%
946 \def\luameshval@mpi@step{polygon}%
948 \def\luameshval@mpi@step{grid}%
950 \def\luameshval@mpi@step{points}%
952 \def\luameshval@mpi@step{mesh}%
956 %% the name of the color of drawing
957 \define@key{meshPolygonInc}{color}[black]{\def\luameshval@mpi@color{#1}}%
958 %% the name of the color of drawing Voronoi
959 \define@key{meshPolygonInc}{colorPolygon}[red]{\def\luameshval@mpi@colorPolygon{#1}}%
960 %% the name of the color of drawing the bbox
962 \presetkeys{meshPolygonInc}{tikz=false,scale,mode=int,step=mesh,print=none,color,colorPolygon,h,meshpoint,gridpoints=rect}{}%
964 \newcommand{\meshPolygonInc}[4][]{%
965 % #1 : optionnal arguments
966 % #2 : the string containing the list of points
967 % (x1,y1);(x2,y2);... or the name file containing the points
968 % #3 : the code to place before the generated one
969 % #4 : the code to place after the generated one
970 \setkeys{meshPolygonInc}{#1} %
971 \def\MeshPoint{\luameshval@mpi@meshpoint}%
972 \ifKV@meshPolygonInc@tikz% if we are using tikz
974 drawMeshPolygonTikZinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@mpi@mode","\luameshval@mpi@h","\luameshval@mpi@step","\luameshval@mpi@print","\luameshval@mpi@scale","\luameshval@mpi@color","\luameshval@mpi@colorPolygon","\luameshval@mpi@gridpoints")%
976 \else % we are using MP
977 \mplibcolor{\luameshmpcolor}{\luameshval@mpi@color}%
978 \mplibcolor{\luameshmpcolorPoly}{\luameshval@mpi@colorPolygon}%
980 drawMeshPolygonMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@mpi@mode","\luameshval@mpi@h","\luameshval@mpi@step","\luameshval@mpi@print","\luameshval@mpi@scale","\luameshval@mpi@gridpoints")%