1 \NeedsTeXFormat{LaTeX2e}%
2 \def\PackageName{luamesh}%
3 \def\fileversion{v0.1}%
4 \def\filedate{2016/11/20}%
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{dofile("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
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}{%
45 \def\luameshval@bm@bbox{none}%
47 \def\luameshval@bm@bbox{bbox}%
51 \define@key{buildMeshInc}{scale}[1cm]{\def\luameshval@bm@scale{#1}}%
53 \define@choicekey*{buildMeshInc}{print}[\val\nr]{none, points}{%
55 \def\luameshval@bm@print{none}%
57 \def\luameshval@bm@print{points}%
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}{%
65 \def\luameshval@bm@mode{int}%
67 \def\luameshval@bm@mode{ext}%
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}}%
77 \presetkeys{buildMeshInc}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}%
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
88 buildMeshTikZ("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","full","\luameshval@bm@scale","\luameshval@bm@color")%
90 \else % we are using MP
91 \mplibcolor{\luameshmpcolor}{\luameshval@bm@color}
92 \mplibcolor{\luameshmpcolorBbox}{\luameshval@bm@colorbbox}
94 buildMeshMPBWinc("#2","#3","#4","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","\luameshval@bm@scale")%
100 %%%%%%%%%%%%%%%% the buildMeshBW command
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}{%
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}{%
117 \def\luameshval@bm@print{none}%
119 \def\luameshval@bm@print{points}%
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}{%
127 \def\luameshval@bm@mode{int}%
129 \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 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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
150 buildMeshTikZ("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","full","\luameshval@bm@scale","\luameshval@bm@color")%
152 \else % we are using MP
153 \mplibcolor{\luameshmpcolor}{\luameshval@bm@color}
154 \mplibcolor{\luameshmpcolorBbox}{\luameshval@bm@colorbbox}
156 buildMeshMPBW("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","\luameshval@bm@scale")%
166 %%the meshAddOnePointBW commande
168 \newif\ifluameshengineMP%
169 \define@boolkey{MeshAddOne}{tikz}[true]{}%
171 \define@key{MeshAddOne}{scale}[1cm]{\def\luameshval@scale{#1}}%
172 %% the name of the points
173 \define@key{MeshAddOne}{meshpoint}[P]{\def\luameshval@meshpoint{#1}}%
174 %% the name of the new point
175 \define@key{MeshAddOne}{newpoint}[P]{\def\luameshval@newpoint{#1}}%
176 %% a complete picture or some code of the engine
177 \define@choicekey*{MeshAddOne}{step}[\val\nr]{badtriangles, cavity, newtriangles}{%
179 \def\luameshval@step{badT}%
181 \def\luameshval@step{cavity}%
183 \def\luameshval@step{newT}%
187 %% the color of drawing
188 \define@key{MeshAddOne}{color}[black]{\def\luameshval@color{#1}}%
189 %% the color of background of new element
190 \define@key{MeshAddOne}{colorBack}[black!20]{\def\luameshval@colorback{#1}}%
191 %% the color of new element
192 \define@key{MeshAddOne}{colorNew}[red]{\def\luameshval@colornew{#1}}%
193 %% the color of circoncircle
194 \define@key{MeshAddOne}{colorCircle}[green]{\def\luameshval@colorcircle{#1}}%
195 %% the name of the color of drawing the bbox
196 \define@key{MeshAddOne}{colorBbox}[black]{\def\luameshval@colorbbox{#1}}%
198 %% a complete picture or some code of the engine
199 \define@choicekey*{MeshAddOne}{mode}[\val\nr]{int, ext}{%
201 \def\luameshval@mode{int}%
203 \def\luameshval@mode{ext}%
206 \define@choicekey*{MeshAddOne}{bbox}[\val\nr]{none, show}{%
208 \def\luameshval@bbox{none}%
210 \def\luameshval@bbox{bbox}%
213 \presetkeys{MeshAddOne}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}%
215 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
216 % the difinition BW Bowyer and Watson algo
217 \newcommand*{\meshAddPointBW}[3][]{%
218 % #1 : the string containing the list of points
219 % (x1,y1);(x2,y2);... or the name file containing the points
220 \setkeys{MeshAddOne}{#1} %
221 \def\MeshPoint{\luameshval@meshpoint}%
222 \def\NewPoint{\luameshval@newpoint}%
223 \ifKV@MeshAddOne@tikz% if we are using tikz
225 buildMeshTikZ("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@color")%
227 \else % we are using MP
228 \mplibcolor{\luameshmpcolor}{\luameshval@color}
229 \mplibcolor{\luameshmpcolorBack}{\luameshval@colorback}
230 \mplibcolor{\luameshmpcolorNew}{\luameshval@colornew}
231 \mplibcolor{\luameshmpcolorCircle}{\luameshval@colorcircle}
232 \mplibcolor{\luameshmpcolorBbox}{\luameshval@colorbbox}
234 TeXOnePointMPBW("#2","#3","\luameshval@step","\luameshval@scale","\luameshval@mode","\luameshval@bbox")%
239 %%% the meshAddPointBWinc commande
241 \newif\ifluameshengineMP%
242 \define@boolkey{MeshAddOneBWinc}{tikz}[true]{}%
244 \define@key{MeshAddOneBWinc}{scale}[1cm]{\def\luameshval@scale{#1}}%
245 %% the name of the points
246 \define@key{MeshAddOneBWinc}{meshpoint}[P]{\def\luameshval@meshpoint{#1}}%
247 %% the name of the new point
248 \define@key{MeshAddOneBWinc}{newpoint}[P]{\def\luameshval@newpoint{#1}}%
249 %% a complete picture or some code of the engine
250 \define@choicekey*{MeshAddOneBWinc}{step}[\val\nr]{badtriangles, cavity, newtriangles}{%
252 \def\luameshval@step{badT}%
254 \def\luameshval@step{cavity}%
256 \def\luameshval@step{newT}%
260 %% the color of drawing
261 \define@key{MeshAddOneBWinc}{color}[black]{\def\luameshval@color{#1}}%
262 %% the color of background of new element
263 \define@key{MeshAddOneBWinc}{colorBack}[black!20]{\def\luameshval@colorback{#1}}%
264 %% the color of new element
265 \define@key{MeshAddOneBWinc}{colorNew}[red]{\def\luameshval@colornew{#1}}%
266 %% the color of circoncircle
267 \define@key{MeshAddOneBWinc}{colorCircle}[green]{\def\luameshval@colorcircle{#1}}%
268 \define@key{MeshAddOneBWinc}{colorBbox}[black]{\def\luameshval@colorbbox{#1}}%
270 %% a complete picture or some code of the engine
271 \define@choicekey*{MeshAddOneBWinc}{mode}[\val\nr]{int, ext}{%
273 \def\luameshval@mode{int}%
275 \def\luameshval@mode{ext}%
278 \define@choicekey*{MeshAddOneBWinc}{bbox}[\val\nr]{none, show}{%
280 \def\luameshval@bbox{none}%
282 \def\luameshval@bbox{bbox}%
285 \presetkeys{MeshAddOneBWinc}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}%
287 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
288 % the difinition BW embedded code between the 2 last arguments
289 \newcommand*{\meshAddPointBWinc}[5][]{%
290 % #1 : the string containing the list of points
291 % (x1,y1);(x2,y2);... or the name file containing the points
292 \setkeys{MeshAddOneBWinc}{#1} %
293 \def\MeshPoint{\luameshval@meshpoint}%
294 \def\NewPoint{\luameshval@newpoint}%
295 \ifKV@MeshAddOne@tikz% if we are using tikz
297 buildMeshTikZ("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@color")%
299 \else % we are using MP
300 \mplibcolor{\luameshmpcolor}{\luameshval@color}
301 \mplibcolor{\luameshmpcolorBack}{\luameshval@colorback}
302 \mplibcolor{\luameshmpcolorNew}{\luameshval@colornew}
303 \mplibcolor{\luameshmpcolorCircle}{\luameshval@colorcircle}
304 \mplibcolor{\luameshmpcolorBbox}{\luameshval@colorbbox}
306 TeXOnePointMPBWinc("#2","#3","#4","#5","\luameshval@step","\luameshval@scale","\luameshval@mode","\luameshval@bbox")%