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{buildMesh}{tikz}[true]{}%
42 %% show the bounding box for delaunay
43 \define@choicekey*{buildMesh}{bbox}[\val\nr]{none, show}{%
45 \def\luameshval@bbox{none}%
47 \def\luameshval@bbox{bbox}%
51 \define@key{buildMesh}{scale}[1cm]{\def\luameshval@scale{#1}}%
53 \define@choicekey*{buildMesh}{print}[\val\nr]{none, points}{%
55 \def\luameshval@print{none}%
57 \def\luameshval@print{points}%
60 %% the name of the point
61 \define@key{buildMesh}{meshpoint}[P]{\def\luameshval@meshpoint{#1}}%
62 %% the mode for reading the points
63 \define@choicekey*{buildMesh}{mode}[\val\nr]{int, ext}{%
65 \def\luameshval@mode{int}%
67 \def\luameshval@mode{ext}%
71 %% a complete picture or some code of the engine
72 \define@choicekey*{buildMesh}{picture}[\val\nr]{full, embedded}{%
74 \def\luameshval@picture{full}%
76 \def\luameshval@picture{embedded}%
80 %% the name of the color of drawing
81 \define@key{buildMesh}{color}[black]{\def\luameshval@color{#1}}%
83 \presetkeys{buildMesh}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,picture=full,color}{}%
85 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86 % the difinition BW Bowyer and Watson algo
87 \newcommand{\buildMeshBW}[2][]{%
88 % #1 : the string containing the list of points
89 % (x1,y1);(x2,y2);... or the name file containing the points
90 \setkeys{buildMesh}{#1} %
91 \def\MeshPoint{\luameshval@meshpoint}%
92 \ifKV@buildMesh@tikz% if we are using tikz
94 buildMeshTikZ("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@color")%
96 \else % we are using MP
98 buildMeshMPBW("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@color")%
106 %%the meshAddOnePointBW commande
108 \newif\ifluameshengineMP%
109 \define@boolkey{MeshAddOne}{tikz}[true]{}%
111 \define@key{MeshAddOne}{scale}[1cm]{\def\luameshval@scale{#1}}%
112 %% the name of the points
113 \define@key{MeshAddOne}{meshpoint}[P]{\def\luameshval@meshpoint{#1}}%
114 %% the name of the new point
115 \define@key{MeshAddOne}{newpoint}[P]{\def\luameshval@newpoint{#1}}%
116 %% a complete picture or some code of the engine
117 \define@choicekey*{MeshAddOne}{step}[\val\nr]{badtriangles, cavity, newtriangles}{%
119 \def\luameshval@step{badT}%
121 \def\luameshval@step{cavity}%
123 \def\luameshval@step{newT}%
127 %% the color of drawing
128 \define@key{MeshAddOne}{color}[black]{\def\luameshval@color{#1}}%
129 %% the color of background of new element
130 \define@key{MeshAddOne}{colorBack}[black!20]{\def\luameshval@colorback{#1}}%
131 %% the color of new element
132 \define@key{MeshAddOne}{colorNew}[red]{\def\luameshval@colornew{#1}}%
133 %% the color of circoncircle
134 \define@key{MeshAddOne}{colorCircle}[green]{\def\luameshval@colorcircle{#1}}%
136 %% a complete picture or some code of the engine
137 \define@choicekey*{MeshAddOne}{mode}[\val\nr]{int, ext}{%
139 \def\luameshval@mode{int}%
141 \def\luameshval@mode{ext}%
144 \define@choicekey*{MeshAddOne}{bbox}[\val\nr]{none, show}{%
146 \def\luameshval@bbox{none}%
148 \def\luameshval@bbox{bbox}%
151 \presetkeys{MeshAddOne}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none}{}%
153 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
154 % the difinition BW Bowyer and Watson algo
155 \newcommand*{\meshAddPointBW}[3][]{%
156 % #1 : the string containing the list of points
157 % (x1,y1);(x2,y2);... or the name file containing the points
158 \setkeys{MeshAddOne}{#1} %
159 \def\MeshPoint{\luameshval@meshpoint}%
160 \def\NewPoint{\luameshval@newpoint}%
161 \ifKV@MeshAddOne@tikz% if we are using tikz
163 buildMeshTikZ("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@color")%
165 \else % we are using MP
166 \mplibcolor{\luameshmpcolor}{\luameshval@color}
167 \mplibcolor{\luameshmpcolorBack}{\luameshval@colorback}
168 \mplibcolor{\luameshmpcolorNew}{\luameshval@colornew}
169 \mplibcolor{\luameshmpcolorCircle}{\luameshval@colorcircle}
171 TeXOnePointMPBW("#2","#3","\luameshval@step","\luameshval@scale","\luameshval@mode","\luameshval@bbox")%
176 %%% the meshAddPointBWinc commande
178 \newif\ifluameshengineMP%
179 \define@boolkey{MeshAddOneBWinc}{tikz}[true]{}%
181 \define@key{MeshAddOneBWinc}{scale}[1cm]{\def\luameshval@scale{#1}}%
182 %% the name of the points
183 \define@key{MeshAddOneBWinc}{meshpoint}[P]{\def\luameshval@meshpoint{#1}}%
184 %% the name of the new point
185 \define@key{MeshAddOneBWinc}{newpoint}[P]{\def\luameshval@newpoint{#1}}%
186 %% a complete picture or some code of the engine
187 \define@choicekey*{MeshAddOneBWinc}{step}[\val\nr]{badtriangles, cavity, newtriangles}{%
189 \def\luameshval@step{badT}%
191 \def\luameshval@step{cavity}%
193 \def\luameshval@step{newT}%
197 %% the color of drawing
198 \define@key{MeshAddOneBWinc}{color}[black]{\def\luameshval@color{#1}}%
199 %% the color of background of new element
200 \define@key{MeshAddOneBWinc}{colorBack}[black!20]{\def\luameshval@colorback{#1}}%
201 %% the color of new element
202 \define@key{MeshAddOneBWinc}{colorNew}[red]{\def\luameshval@colornew{#1}}%
203 %% the color of circoncircle
204 \define@key{MeshAddOneBWinc}{colorCircle}[green]{\def\luameshval@colorcircle{#1}}%
206 %% a complete picture or some code of the engine
207 \define@choicekey*{MeshAddOneBWinc}{mode}[\val\nr]{int, ext}{%
209 \def\luameshval@mode{int}%
211 \def\luameshval@mode{ext}%
214 \define@choicekey*{MeshAddOneBWinc}{bbox}[\val\nr]{none, show}{%
216 \def\luameshval@bbox{none}%
218 \def\luameshval@bbox{bbox}%
221 \presetkeys{MeshAddOneBWinc}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none}{}%
223 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
224 % the difinition BW embedded code between the 2 last arguments
225 \newcommand*{\meshAddPointBWinc}[5][]{%
226 % #1 : the string containing the list of points
227 % (x1,y1);(x2,y2);... or the name file containing the points
228 \setkeys{MeshAddOneBWinc}{#1} %
229 \def\MeshPoint{\luameshval@meshpoint}%
230 \def\NewPoint{\luameshval@newpoint}%
231 \ifKV@MeshAddOne@tikz% if we are using tikz
233 buildMeshTikZ("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@color")%
235 \else % we are using MP
236 \mplibcolor{\luameshmpcolor}{\luameshval@color}
237 \mplibcolor{\luameshmpcolorBack}{\luameshval@colorback}
238 \mplibcolor{\luameshmpcolorNew}{\luameshval@colornew}
239 \mplibcolor{\luameshmpcolorCircle}{\luameshval@colorcircle}
241 TeXOnePointMPBWinc("#2","#3","#4","#5","\luameshval@step","\luameshval@scale","\luameshval@mode","\luameshval@bbox")%