ccb1863f0910dbf57eb9abb87a7b54104be39def
[delaunay.git] / luamesh.sty
1 \NeedsTeXFormat{LaTeX2e}%
2 \def\PackageName{luamesh}%
3 \def\fileversion{v0.1}%
4 \def\filedate{2016/11/20}%
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{dofile("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
39 %% engine of drawing
40 \newif\ifluameshengineMP%
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@bm@bbox{none}%
46   \or%
47   \def\luameshval@bm@bbox{bbox}%
48   \fi%
49 }%
50 %% the scale
51 \define@key{buildMeshInc}{scale}[1cm]{\def\luameshval@bm@scale{#1}}%
52 %% print ponits ?
53 \define@choicekey*{buildMeshInc}{print}[\val\nr]{none, points}{%
54   \ifcase\nr\relax%
55   \def\luameshval@bm@print{none}%
56   \or%
57   \def\luameshval@bm@print{points}%
58   \fi%
59 }%
60 %% the name of the point
61 \define@key{buildMeshInc}{meshpoint}[P]{\def\luameshval@bm@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@bm@mode{int}%
66   \or%
67   \def\luameshval@bm@mode{ext}%
68   \fi%
69 }%
70 %
71 %color
72 %% the name of the color of drawing
73 \define@key{buildMeshInc}{color}[black]{\def\luameshval@bm@color{#1}}%
74 %% the name of the color of drawing the bbox
75 \define@key{buildMeshInc}{colorBbox}[black]{\def\luameshval@bm@colorbbox{#1}}%
76 %
77 \presetkeys{buildMeshInc}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
78 %
79 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80 % the difinition BW Bowyer and Watson algo
81 \newcommand*{\buildMeshBWinc}[4][]{%
82   % #1 : the string containing the list of points
83   % (x1,y1);(x2,y2);... or the name file containing the points
84   \setkeys{buildMesh}{#1} %
85   \def\MeshPoint{\luameshval@bm@meshpoint}%
86   \ifKV@buildMesh@tikz% if we are using tikz
87   \directlua{%
88     buildMeshTikZ("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","full","\luameshval@bm@scale","\luameshval@bm@color")%
89   }%
90   \else % we are using MP
91   \mplibcolor{\luameshmpcolor}{\luameshval@bm@color}
92   \mplibcolor{\luameshmpcolorBbox}{\luameshval@bm@colorbbox}
93   \directlua{%
94     buildMeshMPBWinc("#2","#3","#4","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","\luameshval@bm@scale")%
95   }%
96   %
97   \fi%
98 }%
99 %
100 %%%%%%%%%%%%%%%% the buildMeshBW command
101 %% engine of drawing
102 \newif\ifluameshengineMP%
103 \define@boolkey{buildMesh}{tikz}[true]{}%
104 %% show the bounding box for delaunay
105 \define@choicekey*{buildMesh}{bbox}[\val\nr]{none, show}{%
106   \ifcase\nr\relax%
107   \def\luameshval@bm@bbox{none}%
108   \or%
109   \def\luameshval@bm@bbox{bbox}%
110   \fi%
111 }%
112 %% the scale
113 \define@key{buildMesh}{scale}[1cm]{\def\luameshval@bm@scale{#1}}%
114 %% print points
115 \define@choicekey*{buildMesh}{print}[\val\nr]{none, points}{%
116   \ifcase\nr\relax%
117   \def\luameshval@bm@print{none}%
118   \or%
119   \def\luameshval@bm@print{points}%
120   \fi%
121 }%
122 %% the name of the point
123 \define@key{buildMesh}{meshpoint}[P]{\def\luameshval@bm@meshpoint{#1}}%
124 %% the mode for reading the points
125 \define@choicekey*{buildMesh}{mode}[\val\nr]{int, ext}{%
126   \ifcase\nr\relax%
127   \def\luameshval@bm@mode{int}%
128   \or%
129   \def\luameshval@bm@mode{ext}%
130   \fi%
131 }%
132 %
133 % color
134 %% the name of the color of drawing
135 \define@key{buildMesh}{color}[black]{\def\luameshval@bm@color{#1}}%
136 %% the name of the color of drawing the bbox
137 \define@key{buildMesh}{colorBbox}[black]{\def\luameshval@bm@colorbbox{#1}}%
138 %
139 \presetkeys{buildMesh}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
140 %
141 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
142 % the difinition BW Bowyer and Watson algo
143 \newcommand{\buildMeshBW}[2][]{%
144   % #1 : the string containing the list of points
145   % (x1,y1);(x2,y2);... or the name file containing the points
146   \setkeys{buildMesh}{#1} %
147   \def\MeshPoint{\luameshval@bm@meshpoint}%
148   \ifKV@buildMesh@tikz% if we are using tikz
149   \directlua{%
150     buildMeshTikZ("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","full","\luameshval@bm@scale","\luameshval@bm@color")%
151   }%
152   \else % we are using MP
153   \mplibcolor{\luameshmpcolor}{\luameshval@bm@color}
154   \mplibcolor{\luameshmpcolorBbox}{\luameshval@bm@colorbbox}
155   \directlua{%
156     buildMeshMPBW("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","\luameshval@bm@scale")%
157   }%
158   %
159   \fi%
160 }%
161 %
162 %%%%%%%%%%%%%%%%% the trace Points macro
163 %% engine of drawing
164 \newif\ifluameshengineMP%
165 \define@boolkey{tracePoints}{tikz}[true]{}%
166 %% show the bounding box for delaunay
167 \define@choicekey*{tracePoints}{bbox}[\val\nr]{none, show}{%
168   \ifcase\nr\relax%
169   \def\luameshval@tp@bbox{none}%
170   \or%
171   \def\luameshval@tp@bbox{bbox}%
172   \fi%
173 }%
174 %% the scale
175 \define@key{tracePoints}{scale}[1cm]{\def\luameshval@tp@scale{#1}}%
176 %% print points
177 \define@choicekey*{tracePoints}{print}[\val\nr]{none, points}{%
178   \ifcase\nr\relax%
179   \def\luameshval@tp@print{none}%
180   \or%
181   \def\luameshval@tp@print{points}%
182   \fi%
183 }%
184 %% the name of the point
185 \define@key{tracePoints}{meshpoint}[P]{\def\luameshval@tp@meshpoint{#1}}%
186 %% the mode for reading the points
187 \define@choicekey*{tracePoints}{mode}[\val\nr]{int, ext}{%
188   \ifcase\nr\relax%
189   \def\luameshval@tp@mode{int}%
190   \or%
191   \def\luameshval@tp@mode{ext}%
192   \fi%
193 }%
194 %
195 % color
196 %% the name of the color of drawing
197 \define@key{tracePoints}{color}[black]{\def\luameshval@tp@color{#1}}%
198 %% the name of the color of drawing the bbox
199 \define@key{tracePoints}{colorBbox}[black]{\def\luameshval@tp@colorbbox{#1}}%
200 %
201 \presetkeys{tracePoints}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
202 %
203 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
204 % the difinition BW Bowyer and Watson algo
205 \newcommand{\tracePointsMesh}[2][]{%
206   % #1 : the string containing the list of points
207   % (x1,y1);(x2,y2);... or the name file containing the points
208   \setkeys{tracePoints}{#1} %
209   \def\MeshPoint{\luameshval@tp@meshpoint}%
210   \ifKV@buildMesh@tikz% if we are using tikz
211   \directlua{%
212     % buildMeshTikZ("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","full","\luameshval@tp@scale","\luameshval@tp@color")%
213   }%
214   \else % we are using MP
215   \mplibcolor{\luameshmpcolor}{\luameshval@tp@color}
216   \mplibcolor{\luameshmpcolorBbox}{\luameshval@tp@colorbbox}
217   \directlua{%
218     printPointsMP("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale")%
219   }%
220   %
221   \fi%
222 }%
223 %
224
225 %%%%%%%%%%%%%%%% the trace Points macro inc
226 %% engine of drawing
227 \newif\ifluameshengineMP%
228 \define@boolkey{tracePointsInc}{tikz}[true]{}%
229 %% show the bounding box for delaunay
230 \define@choicekey*{tracePointsInc}{bbox}[\val\nr]{none, show}{%
231   \ifcase\nr\relax%
232   \def\luameshval@tp@bbox{none}%
233   \or%
234   \def\luameshval@tp@bbox{bbox}%
235   \fi%
236 }%
237 %% the scale
238 \define@key{tracePointsInc}{scale}[1cm]{\def\luameshval@tp@scale{#1}}%
239 %% print points
240 \define@choicekey*{tracePointsInc}{print}[\val\nr]{none, points}{%
241   \ifcase\nr\relax%
242   \def\luameshval@tp@print{none}%
243   \or%
244   \def\luameshval@tp@print{points}%
245   \fi%
246 }%
247 %% the name of the point
248 \define@key{tracePointsInc}{meshpoint}[P]{\def\luameshval@tp@meshpoint{#1}}%
249 %% the mode for reading the points
250 \define@choicekey*{tracePointsInc}{mode}[\val\nr]{int, ext}{%
251   \ifcase\nr\relax%
252   \def\luameshval@tp@mode{int}%
253   \or%
254   \def\luameshval@tp@mode{ext}%
255   \fi%
256 }%
257 %
258 % color
259 %% the name of the color of drawing
260 \define@key{tracePointsInc}{color}[black]{\def\luameshval@tp@color{#1}}%
261 %% the name of the color of drawing the bbox
262 \define@key{tracePointsInc}{colorBbox}[black]{\def\luameshval@tp@colorbbox{#1}}%
263 %
264 \presetkeys{tracePointsInc}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
265 %
266 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
267 % the difinition BW Bowyer and Watson algo
268 \newcommand*{\tracePointsMeshinc}[4][]{%
269   % #1 : the string containing the list of points
270   % (x1,y1);(x2,y2);... or the name file containing the points
271   \setkeys{tracePointsInc}{#1} %
272   \def\MeshPoint{\luameshval@tp@meshpoint}%
273   \ifKV@tracePointsInc@tikz% if we are using tikz
274   \directlua{%
275     buildMeshTikZ("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","full","\luameshval@tp@sc%ale","\luameshval@tp@color")%
276   }%
277   \else % we are using MP
278   \mplibcolor{\luameshmpcolor}{\luameshval@tp@color}
279   \mplibcolor{\luameshmpcolorBbox}{\luameshval@tp@colorbbox}
280   \directlua{%
281     printPointsMPinc("#2","#3","#4","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale")%
282   }%
283   \fi%
284 }%
285 %
286 %
287 %%
288 %
289 %%the meshAddOnePointBW commande
290 %%engine of drawing
291 \newif\ifluameshengineMP%
292 \define@boolkey{MeshAddOne}{tikz}[true]{}%
293 %% the scale
294 \define@key{MeshAddOne}{scale}[1cm]{\def\luameshval@scale{#1}}%
295 %% the name of the points
296 \define@key{MeshAddOne}{meshpoint}[P]{\def\luameshval@meshpoint{#1}}%
297 %% the name of the new point
298 \define@key{MeshAddOne}{newpoint}[P]{\def\luameshval@newpoint{#1}}%
299 %% a complete picture or some code of the engine
300 \define@choicekey*{MeshAddOne}{step}[\val\nr]{badtriangles, cavity, newtriangles}{%
301   \ifcase\nr\relax%
302   \def\luameshval@step{badT}%
303   \or%
304   \def\luameshval@step{cavity}%
305   \or%
306   \def\luameshval@step{newT}%
307   \fi%
308 }%
309 % color
310 %% the color of drawing
311 \define@key{MeshAddOne}{color}[black]{\def\luameshval@color{#1}}%
312 %% the color of background of new element
313 \define@key{MeshAddOne}{colorBack}[black!20]{\def\luameshval@colorback{#1}}%
314 %% the color of new element
315 \define@key{MeshAddOne}{colorNew}[red]{\def\luameshval@colornew{#1}}%
316 %% the color of circoncircle
317 \define@key{MeshAddOne}{colorCircle}[green]{\def\luameshval@colorcircle{#1}}%
318 %% the name of the color of drawing the bbox
319 \define@key{MeshAddOne}{colorBbox}[black]{\def\luameshval@colorbbox{#1}}%
320 %
321 %% a complete picture or some code of the engine
322 \define@choicekey*{MeshAddOne}{mode}[\val\nr]{int, ext}{%
323   \ifcase\nr\relax%
324   \def\luameshval@mode{int}%
325   \or%
326   \def\luameshval@mode{ext}%
327   \fi%
328 }%
329 \define@choicekey*{MeshAddOne}{bbox}[\val\nr]{none, show}{%
330   \ifcase\nr\relax%
331   \def\luameshval@bbox{none}%
332   \or%
333   \def\luameshval@bbox{bbox}%
334   \fi%
335 }%
336 \presetkeys{MeshAddOne}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}%
337 %
338 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
339 % the difinition BW Bowyer and Watson algo
340 \newcommand*{\meshAddPointBW}[3][]{%
341   % #1 : the string containing the list of points
342   % (x1,y1);(x2,y2);... or the name file containing the points
343   \setkeys{MeshAddOne}{#1} %
344   \def\MeshPoint{\luameshval@meshpoint}%
345   \def\NewPoint{\luameshval@newpoint}%
346   \ifKV@MeshAddOne@tikz% if we are using tikz
347   \directlua{%
348     buildMeshTikZ("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@color")%
349   }%
350   \else % we are using MP
351   \mplibcolor{\luameshmpcolor}{\luameshval@color}
352   \mplibcolor{\luameshmpcolorBack}{\luameshval@colorback}
353   \mplibcolor{\luameshmpcolorNew}{\luameshval@colornew}
354   \mplibcolor{\luameshmpcolorCircle}{\luameshval@colorcircle}
355   \mplibcolor{\luameshmpcolorBbox}{\luameshval@colorbbox}
356   \directlua{%
357     TeXOnePointMPBW("#2","#3","\luameshval@step","\luameshval@scale","\luameshval@mode","\luameshval@bbox")%
358   }%
359   %
360   \fi%
361 }%
362 %%% the meshAddPointBWinc commande
363 %% engine of drawing
364 \newif\ifluameshengineMP%
365 \define@boolkey{MeshAddOneBWinc}{tikz}[true]{}%
366 %% the scale
367 \define@key{MeshAddOneBWinc}{scale}[1cm]{\def\luameshval@scale{#1}}%
368 %% the name of the points
369 \define@key{MeshAddOneBWinc}{meshpoint}[P]{\def\luameshval@meshpoint{#1}}%
370 %% the name of the new point
371 \define@key{MeshAddOneBWinc}{newpoint}[P]{\def\luameshval@newpoint{#1}}%
372 %% a complete picture or some code of the engine
373 \define@choicekey*{MeshAddOneBWinc}{step}[\val\nr]{badtriangles, cavity, newtriangles}{%
374   \ifcase\nr\relax%
375   \def\luameshval@step{badT}%
376   \or%
377   \def\luameshval@step{cavity}%
378   \or%
379   \def\luameshval@step{newT}%
380   \fi%
381 }%
382 % color
383 %% the color of drawing
384 \define@key{MeshAddOneBWinc}{color}[black]{\def\luameshval@color{#1}}%
385 %% the color of background of new element
386 \define@key{MeshAddOneBWinc}{colorBack}[black!20]{\def\luameshval@colorback{#1}}%
387 %% the color of new element
388 \define@key{MeshAddOneBWinc}{colorNew}[red]{\def\luameshval@colornew{#1}}%
389 %% the color of circoncircle
390 \define@key{MeshAddOneBWinc}{colorCircle}[green]{\def\luameshval@colorcircle{#1}}%
391 \define@key{MeshAddOneBWinc}{colorBbox}[black]{\def\luameshval@colorbbox{#1}}%
392 %
393 %% a complete picture or some code of the engine
394 \define@choicekey*{MeshAddOneBWinc}{mode}[\val\nr]{int, ext}{%
395   \ifcase\nr\relax%
396   \def\luameshval@mode{int}%
397   \or%
398   \def\luameshval@mode{ext}%
399   \fi%
400 }%
401 \define@choicekey*{MeshAddOneBWinc}{bbox}[\val\nr]{none, show}{%
402   \ifcase\nr\relax%
403   \def\luameshval@bbox{none}%
404   \or%
405   \def\luameshval@bbox{bbox}%
406   \fi%
407 }%
408 \presetkeys{MeshAddOneBWinc}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}%
409 %
410 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
411 % the difinition BW embedded code between the 2 last arguments
412 \newcommand*{\meshAddPointBWinc}[5][]{%
413   % #1 : the string containing the list of points
414   % (x1,y1);(x2,y2);... or the name file containing the points
415   \setkeys{MeshAddOneBWinc}{#1} %
416   \def\MeshPoint{\luameshval@meshpoint}%
417   \def\NewPoint{\luameshval@newpoint}%
418   \ifKV@MeshAddOne@tikz% if we are using tikz
419   \directlua{%
420     buildMeshTikZ("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@color")%
421   }%
422   \else % we are using MP
423   \mplibcolor{\luameshmpcolor}{\luameshval@color}
424   \mplibcolor{\luameshmpcolorBack}{\luameshval@colorback}
425   \mplibcolor{\luameshmpcolorNew}{\luameshval@colornew}
426   \mplibcolor{\luameshmpcolorCircle}{\luameshval@colorcircle}
427   \mplibcolor{\luameshmpcolorBbox}{\luameshval@colorbbox}
428   \directlua{%
429     TeXOnePointMPBWinc("#2","#3","#4","#5","\luameshval@step","\luameshval@scale","\luameshval@mode","\luameshval@bbox")%
430   }%
431   %
432   \fi%
433 }%
434 %

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.