Debian Codegraph @

texmf-dist/doc/lualatex/luamesh/luamesh-doc.tex

raw
1 % luamesh: compute and draw meshes with lua, luamplib and tikz
2 %
3 % Originally written by Maxime Chupin <[email protected]>,
4 % 2017.
5 %
6 % Distributed under the terms of the GNU free documentation licence:
7 % http://www.gnu.org/licenses/fdl.html
8 % without any invariant section or cover text.
9
10 \documentclass{luameshdoc}
11 \usepackage{tcolorbox}
12 \usepackage{enumitem}
13 \usepackage[tikz]{bclogo}
14 \usepackage{wrapfig}
15 \usepackage{animate}
16
17 \title{\Verb+luamesh+: compute and draw meshes with \lualatex}
18 \author{Maxime Chupin \email{[email protected]}}
19 \date{\today}
20
21 \addbibresource{biblio.bib}
22
23 \definecolor{darkred}{rgb}{0.8,0.1,0.1}
24
25
26 \newcommand*\commande{\noindent\hspace{-30pt}%
27 \SaveVerb[aftersave={%
28 \UseVerb{Vitem}
29 }%
30 ]{Vitem}}
31
32 \newcommand*\textme[1]{\textcolor{black}{\rmfamily\textit{#1}}}
33 \newcommand*\meta[1]{% % meta
34 \textme{\ensuremath{\langle}#1\ensuremath{\rangle}}}
35 \newcommand*\optstar{% % optional star
36 \meta{\ensuremath{*}}\xspace}
37 \DefineShortVerb{\|}
38 \newcommand\R{\mathbf{R}}
39 \setlength{\fboxsep}{2pt}
40 \fvset{%
41 codes={\catcode`\«\active \catcode`\×\active },
42 defineactive={\makefancyog\makefancytimes},
43 formatcom=\color{darkred},
44 frame=single
45 }
46 % rendre «...» équivalent à \meta{...}
47 {\catcode`\«\active
48 \newcommandx\makefancyog[0][addprefix=\global]{%
49 \def«##1»{\meta{##1}}}}
50 % rendre × équivalent à \optstar
51 {\catcode`\×\active
52 \newcommandx\makefancytimes[0][addprefix=\global]{%
53 \def×{\optstar{}}}}
54
55
56 \tcbuselibrary{listings,breakable}
57
58 \definecolor{vert}{rgb}{0.1,0.4,0.1}
59 \definecolor{bleu}{rgb}{0.1,0.1,0.4}
60 \lstset{
61 numberstyle=\footnotesize\color{vert},
62 keywordstyle=\ttfamily\bfseries\color{blue},
63 basicstyle=\ttfamily\footnotesize,
64 commentstyle=\itshape\color{vert},
65 stringstyle=\ttfamily,
66 showstringspaces=false,
67 language=[LaTeX]TeX,
68 breaklines=true,
69 breakindent=30pt,
70 defaultdialect=[LaTeX]TeX,
71 morekeywords={buildMeshBW,buildMeshBWinc,drawPointsMesh,buildVoronoiBW,buildVoronoiBWinc,
72 drawPointsMeshinc, meshAddPointBW,
73 meshAddPointBWinc,drawGmsh,drawGmshinc,gmshVoronoi,gmshVoronoiinc}% frame=tb
74 }
75
76 \lstdefinelanguage{lua}
77 {morekeywords={for,end,function,do,if,else,elseif,then,
78 tex.print,tex.sprint,io.read,io.open,string.find,string.explode,require},
79 morecomment=[l]{--},
80 morecomment=[s]{--[[}{]]},
81 morestring=[b]''
82 }
83
84 \newtcblisting{Exemple}{%
85 arc=0pt,outer arc=0pt,
86 colback=red!2!white,
87 colframe=red!75!black,
88 breakable,
89 boxsep=0pt,left=5pt,right=5pt,top=5pt,bottom=5pt, bottomtitle =
90 3pt, toptitle=3pt,
91 boxrule=0pt,bottomrule=0.5pt,toprule=0.5pt, toprule at break =
92 0pt, bottomrule at break = 0pt,
93 listing options={breaklines},
94 }
95
96 \newtcblisting{commandshell}{colback=black,colupper=white,colframe=black,
97 arc=0pt,
98 listing only,boxsep=0pt,listing
99 options={style=tcblatex,language=sh},
100 every listing line={\textcolor{red}{\small\ttfamily\bfseries user \$> }}}
101
102 \newtcblisting{latexcode}{
103 arc=0pt,outer arc=0pt,
104 colback=red!2!white,
105 colframe=red!75!black,
106 breakable,
107 boxsep=0pt,left=5pt,right=5pt,top=5pt,bottom=5pt, bottomtitle =
108 3pt, toptitle=3pt,
109 boxrule=0pt,bottomrule=0.5pt,toprule=0.5pt, toprule at break =
110 0pt, bottomrule at break = 0pt,
111 listing only,boxsep=0pt,listing
112 options={breaklines}
113 }
114
115
116 \newcommand\luamesh{\Verb+luamesh+\xspace}
117
118 \newenvironment{optionsenum}[1][]
119 {\begin{description}[font=\color{darkred}\ttfamily]}
120 {\end{description}}
121
122 \newenvironment{warning}{%
123 \setlength{\logowidth}{24pt}
124 \tcbset{%
125 arc=0pt,outer arc=0pt,colback=gray!10!white,colframe=gray!60!white,
126 boxsep=0pt,left=5pt,right=5pt,top=5pt,bottom=5pt, bottomtitle = 3pt, toptitle=3pt,
127 boxrule=0pt,bottomrule=0.5pt,toprule=0.5pt}
128 \medskip
129 \begin{tcolorbox}%
130 \begin{wrapfigure}[2]{L}{17pt}%
131 % \raisebox{-5pt}{
132 \vspace*{-0.55cm}
133 \bcinfo
134 % }%
135 \end{wrapfigure}
136 }%
137 {\end{tcolorbox}\medskip}
138
139 \lstset{moredelim=*[s][\color{red}\rmfamily\itshape]{<}{>}}
140 \lstset{moredelim=*[s][\color{blue}\rmfamily\itshape]{<<}{>>}}
141
142 \begin{document}
143 %% === Page de garde ===================================================
144 \thispagestyle{empty}
145 \begin{tikzpicture}[remember picture, overlay]
146 \node[below right, shift={(-4pt,4pt)}] at (current page.north west) {%
147 \includegraphics{fond.pdf}%
148 };
149 \end{tikzpicture}%
150
151 \noindent
152 \includegraphics{luamesh-title}\\
153 {\large compute and draw meshes with \lualatex}\\[1cm]
154 \parbox{0.6\textwidth}{
155 \meshAddPointBW[
156 mode=ext,step=badtriangles,
157 colorNew =green!20!red,
158 colorBack=red!10,
159 colorCircle = blue,
160 bbox = show,
161 colorBbox = black!30
162 ]
163 {meshgarde.txt}{7}
164 }\hfill
165 \parbox{0.4\textwidth}{\Large\raggedleft
166 \textbf{Contributor}\\
167 Maxime \textsc{Chupin}
168 }
169 \vfill
170 \begin{center}
171 Version 0.7, 2022, July, 8th \\
172 \url{https://plmlab.math.cnrs.fr/mchupin/luamesh}
173 \end{center}
174 %% == Page de garde ====================================================
175 \newpage
176
177 \maketitle
178
179 \begin{abstract}
180 The package \Verb|luamesh| allows to compute and draw 2D Delaunay
181 triangulation. The algorithm is written with lua, and depending on the
182 choice of the ``engine'', the drawing is done by MetaPost (with
183 \Verb|luamplib|) or by \Verb|tikz|.
184
185 The Delaunay triangulation algorithm is the Bowyer and Watson
186 algorithm. Several macros are provided to draw the global mesh, the
187 set of points, or a particular step of the algorithm.
188 \end{abstract}
189
190 I would like to thank Jean-Michel Sarlat, who hosts first the development
191 with a git project on the \Verb+melusine+ machine. Now the project is hosted
192 here :
193 \begin{center}
194 \url{https://plmlab.math.cnrs.fr/mchupin/luamesh}
195 \end{center}
196 I would also like to thank the first user, an intensive
197 \emph{test} user, and a very kind English corrector: Nicole Spillane.
198
199 For the references of the algorithm, see~\cite{Bowyer,Watson} and a reference about
200 mesh is~\cite{Frey}.
201
202 \tableofcontents
203
204
205 \section{Installation}
206
207 \luamesh is on the CTAN and can be installed with the package manager of
208 your distribution.
209
210 \begin{center}
211 \url{https://www.ctan.org/pkg/luamesh}
212 \end{center}
213
214
215 \subsection{With \TeX live and Linux or Mac OSX}
216
217 To install \luamesh with \TeX live, you have to create the local
218 \Verb+texmf+ directory in your \Verb+home+.
219
220 \begin{commandshell}
221 mkdir ~/texmf
222 \end{commandshell}
223
224 Then place the files in the correct directories. The
225 \Verb+luamesh.sty+ file must be in directory:
226 \begin{center}
227 \Verb+~/texmf/tex/latex/luamesh/+
228 \end{center}
229 the \Verb+luamesh.lua+, the \Verb+luamesh-tex.lua+ and the
230 \Verb-luamesh-polygon.lua+ files must be in directory:
231 \begin{center}
232 \Verb+~/texmf/scripts/luamesh/+
233 \end{center}
234 and the \Verb+luamesh.mp+ file must be in directory:
235 \begin{center}
236 \Verb+~/texmf/metapost/luamesh/+
237 \end{center}
238 Once you have done this, \luamesh can be included in your document
239 with
240 \begin{latexcode}
241 \usepackage{luamesh}
242 \end{latexcode}
243
244 \subsection{With Mik\TeX{} and Windows}
245
246 As these two systems are unknown to the contributor, we refer to the
247 documentation for integrating local additions to Mik\TeX:
248 \begin{center}
249 \url{http://docs.miktex.org/manual/localadditions.html}
250 \end{center}
251
252
253 \subsection{A \lualatex package}
254
255 If you want to use this package, you must compile your document with
256 \Verb+lualatex+:
257
258 \begin{commandshell}
259 lualatex mylatexfile.tex
260 \end{commandshell}
261
262
263 \subsection{Dependencies}
264
265 This package is built upon two main existing packages that one used to
266 draw the
267 triangulations :
268 \begin{enumerate}
269 \item \Verb+luamplib+ to use MetaPost~\cite{luamplib} via the \luatex library
270 \Verb+mplib+;
271 \item \Verb+tikz+~\cite{tikz}.
272 \end{enumerate}
273 We will see how to choose between these two \emph{drawing engines}.
274 Moreover, the following packages are necessary:
275 \begin{enumerate}
276 \item \Verb+xkeyval+ to manage the optional arguments;
277 \item \Verb+xcolor+ to use colors (required by \Verb+luamplib+);
278 \item \Verb+ifthen+ to help programming with \TeX.
279 \end{enumerate}
280
281
282 \section{The Basic Macros}
283
284 This package provides macros to draw two
285 dimensional triangulations (or meshes).
286
287 \subsection{Draw a Complete Mesh}\label{sec:buildMesh}
288
289 \commande|\buildMeshBW[«options»]{«list of points» or «file name»}|\medskip
290
291 This macro produces the Delaunay triangulation (using the Bowyer and
292 Watson algorithm, \cite[Bowyer]) of the given \meta{list of points}. The list of
293 points must be given in the following way :
294 \begin{center}
295 \verb+(x1,y1);(x2,y2);(x3,y3);...;(xn,yn)+
296 \end{center}
297
298 \begin{Exemple}
299 \buildMeshBW{(0.3,0.3);(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}
300 \end{Exemple}
301
302 \subsubsection{The Options}
303
304 There are several options to customize the drawing.
305 \begin{optionsenum}
306 \item[mode = int (default) \textme{or} ext:] this option allows to
307 use either the previously described set of points in the argument, or
308 a file containing the points line by line (in 2 columns). Such a
309 file looks like :
310 \begin{verbatim}
311 x1 y1
312 x2 y2
313 x3 y3
314 ...
315 xn yn
316 \end{verbatim}
317 \item[bbox = none (default) \textme{or} show:] this option allows to draw the
318 points added to form the \emph{bounding box}\footnote{The bounding
319 box is defined by four points place at 15\% around the box
320 defined by $(x_{\min},y_{\min})$, $(x_{\min},y_{\max})$,
321 $(x_{\max},y_{\max})$, and $(x_{\min},y_{\max})$. It is used by
322 the algorithm and will be computed in any case.} and the
323 triangles attached. By default, these triangles are removed at the end of
324 the algorithm.
325 \item[color = \meta{value} (default: black):] The color of the
326 drawing.
327 \item[colorBbox = \meta{value} (default: black):] The color of the
328 drawing for the elements (points and triangles) belonging to the
329 bounding box.
330 \item[print = none (default) \textme{or} points \textme{or}
331 dotpoints:] The \Verb+point+ value allows to label the vertices of the
332 triangulation. This also adds a \emph{dot} at each vertex. The
333 \Verb+dotpoints+ value only add a dot without the labeling.
334 \item[meshpoint = \meta{value} (default: P):] The letter(s) used to
335 label the vertices of the triangulation. It is included in the math
336 mode delimiters \Verb+$...$+. The bounding box points are labeled
337 with numbers 1 to 4 and with a star exponent.
338 \item[tikz (boolean, default:false):] By default, this boolean is set
339 to \Verb+false+, and MetaPost (with \Verb+luamplib+) is used to draw
340 the picture. With this option, \Verb+tikz+ becomes the \textit{drawing
341 engine}.
342 \item[scale = \meta{value} (default: 1cm):] The scale option defines
343 the scale at which the picture is drawn (the same for both
344 axes). It must contain the unit of length (cm,
345 pt, etc.).
346 \item[thickness = \meta{value} (default: 0.4pt):] The thickness option defines
347 the thickness of the lines. It must contain the unit of length (cm,
348 pt, etc.).
349 \end{optionsenum}
350
351 To illustrate the options, let us show you an example. We consider a
352 file \Verb+mesh.txt+:
353 \begin{verbatim}
354 0.3 0.3
355 1.5 1
356 4 0
357 4.5 2.5
358 1.81 2.14
359 2.5 0.5
360 2.8 1.5
361 \end{verbatim}
362 \begin{Exemple}
363 \buildMeshBW[%
364 tikz,
365 mode = ext,
366 bbox = show,
367 color = red,
368 colorBbox = blue!30,
369 print = points,
370 meshpoint = x,
371 scale = 1.3cm,
372 thickness = 1pt
373 ]{mesh.txt}
374 \end{Exemple}
375
376 \begin{warning}
377 The drawing engine is not very relevant here, although it is useful to
378 understand how the drawing is produced. However, the engine will be
379 relevant to
380 the so called \emph{inc} macros (section~\ref{sec:inc}) for adding
381 code before and after the one generated by
382 \luamesh.
383 \end{warning}
384
385 \subsection{Draw the Set of Points}
386
387 \commande|\drawPointsMesh[«options»]{«list of points» or «file name»}|\medskip
388
389 With the \Verb+\drawPointsMesh+, we plot the set of (user chosen) points from
390 which the Bowyer and Watson algorithm computes the triangulation.
391
392 The use of this macro is quite similar to
393 \Verb+\buildMeshBW+. Here is an example of the basic uses.
394 \begin{Exemple}
395 \drawPointsMesh{(0.3,0.3);(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}
396 \end{Exemple}
397
398
399 \subsubsection{The Options}
400
401 There are several options (exactly the same as for the
402 \Verb+\buildMeshBW+) to customize the drawing.
403 \begin{optionsenum}
404 \item[mode = int (default) \textme{or} ext:] this option allows to
405 use either the previously described set of points as the argument, or
406 a file containing the points line by line (in 2 columns). Such a
407 file looks like :
408 \begin{verbatim}
409 x1 y1
410 x2 y2
411 x3 y3
412 ...
413 xn yn
414 \end{verbatim}
415 \item[bbox = none (default) \textme{or} show:] this option allows to draw the
416 points added to form the \emph{bounding box}\footnote{The bounding
417 box is defined by four points place at 15\% around the box
418 defined by $(x_{\min},y_{\min})$, $(x_{\min},y_{\max})$,
419 $(x_{\max},y_{\max})$, and $(x_{\min},y_{\max})$. It is used by
420 the algorithm and will be computed in any case.} and the
421 triangles attached. By default, these triangles are removed at the end of
422 the algorithm. \emph{Here, because we plot only the vertices of the
423 mesh, there are no triangles, only dots.}
424 \item[color = \meta{value} (default: black):] The color of the
425 drawing.
426 \item[colorBbox = \meta{value} (default: black):] The color of the
427 drawing for the elements (points and triangles) belonging to the
428 bounding box.
429 \item[print = none (default) \textme{or} points:] To label the vertices of the
430 triangulation. This also adds a \emph{dot} at each vertex. With no
431 label, the dot remains.
432 \item[meshpoint = \meta{value} (default: P):] The letter(s) used to
433 label the vertices of the triangulation. This is included in the math
434 mode delimiters \Verb+$...$+. The bounding box points are labeled
435 with numbers 1 to 4 and with a star exponent.
436 \item[tikz (boolean, default:false):] By default, this boolean is set
437 to \Verb+false+, and MetaPost (with \Verb+luamplib+) is used to draw
438 the picture. With this option, \Verb+tikz+ becomes the \textit{drawing
439 engine}.
440 \item[scale = \meta{value} (default: 1cm):] The scale option defines
441 the scale at which the picture is drawn (the same for both
442 axes). It must contain the unit of length (cm,
443 pt, etc.).
444 \end{optionsenum}
445 With the same external mesh point file presented in
446 section~\ref{sec:buildMesh}, we illustrate the different options.
447
448 \begin{Exemple}
449 \drawPointsMesh[%
450 tikz,
451 mode = ext,
452 bbox = show,
453 color = blue,
454 colorBbox = red,
455 print = points,
456 meshpoint = y,
457 scale = 1.3cm,
458 ]{mesh.txt}
459 \end{Exemple}
460
461
462 \subsection{Draw a Step of the Bowyer and Watson Algorithm}
463
464 \commande|\meshAddPointBW[«options»]{«list of points» or «file name»}{«point» or «number of line»}|\medskip
465
466 This command allows to plot the steps within the addition of a
467 point in a Delaunay triangulation by the Bowyer and Watson
468 algorithm.
469
470 This macro produces the Delaunay triangulation (using the Bowyer and
471 Watson algorithm) of the given \meta{list of points} and shows a step
472 of the algorithm when the \meta{point} is added. The list of
473 points must be given in the following way:
474 \begin{center}
475 \verb+(x1,y1);(x2,y2);(x3,y3);...;(xn,yn)+
476 \end{center}
477 and the point is of the form \verb+(x,y)+. The \meta{file name}
478 and \meta{number of line} will be explained in the option
479 description.
480
481 One can use the macro as follows:
482 \begin{Exemple}
483 \meshAddPointBW[step=badtriangles]{(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}{(2.2,1.8)}
484 \meshAddPointBW[step=cavity]{(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}{(2.2,1.8)}
485 \meshAddPointBW[step=newtriangles]{(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}{(2.2,1.8)}
486 \end{Exemple}
487 The default value for \Verb+step+ is
488 \Verb+badtriangles+. Consequently, the first
489 line is equivalent to
490 \begin{latexcode}
491 \meshAddPointBW{(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}{(2.2,1.8)}
492 \end{latexcode}
493
494 \subsubsection{The Options}
495
496 There are several options (some of them are the same as for
497 \Verb+\buildMeshBW+) to customize the drawing.
498 \begin{optionsenum}
499 \item[mode = int (default) \textme{or} ext:] this option allows to
500 use either the previously described set of points as the argument, or
501 a file containing the points line by line (in 2 columns). Such a
502 file looks like :
503 \begin{verbatim}
504 x1 y1
505 x2 y2
506 x3 y3
507 ...
508 xn yn
509 \end{verbatim}
510 For the second argument of the macro, if we are in
511 \Verb+mode = ext+, the argument must be the \emph{line number} of the file
512 corresponding to the point we want to add. The algorithm will stop at the
513 previous line to build the initial triangulation and proceed to add
514 the point corresponding to the line requested. The subsequent lines in
515 the file are
516 ignored.
517 \item[bbox = none (default) \textme{or} show:] this option allows to draw the
518 added points that form the \emph{bounding box} and the triangles
519 attached. Although they are always computed, by default, these
520 triangles are removed at the end of
521 the algorithm.
522 \item[color = \meta{value} (default: black):] The color of the
523 drawing.
524 \item[colorBbox = \meta{value} (default: black):] The color of the
525 drawing for the elements (points and triangles) belonging to the
526 bounding box.
527 \item[colorNew = \meta{value} (default: red):] The color of the
528 drawing of the ``new'' elements which are the point to add, the
529 polygon delimiting the cavity, and the new triangles.
530 \item[colorBack = \meta{value} (default: black!20):] The color for the
531 filling of the region concerned by the addition of the new point.
532 \item[colorCircle = \meta{value} (default: green):] The color for
533 the circumcircle of the triangles containing the point to add.
534 \item[meshpoint = \meta{value} (default: P):] The letter(s) used to
535 label the vertices of the triangulation. It is included in the math
536 mode delimiters \Verb+$...$+. The bounding box points are labeled
537 with numbers 1 to 4 and with a star exponent.
538 \item[step = badtriangles (default) \textme{or} cavity \textme{or}
539 newtriangles:] To choose the step we want to draw, corresponding to
540 the steps of the Bowyer and Watson algorithm.
541 \item[newpoint = \meta{value} (default: P):] The letter(s) used to
542 label the new point of the triangulation. It is include in the math
543 mode delimiters \Verb+$...$+.
544 \item[tikz (boolean, default:false):] By default, this boolean is set
545 to \Verb+false+, and MetaPost (with \Verb+luamplib+) is used to draw
546 the picture. With this option, \Verb+tikz+ is the \textit{drawing
547 engine}.
548 \item[scale = \meta{value} (default: 1cm):] The scale option defines
549 the scale at which the picture is drawn (the same for both
550 axis). It must contain the unit of length (cm,
551 pt, etc.).
552 \item[thickness = \meta{value} (default: 0.4pt):] The thickness option defines
553 the thickness of the lines for the mesh. It must contain the unit of length (cm,
554 pt, etc.).
555 \item[thicknessNew = \meta{value} (default: 0.4pt):] The thickness option defines
556 the thickness of the lines for the polygon and the \emph{new} elements. It
557 must contain the unit of length (cm,
558 pt, etc.).
559 \item[thicknessCircle = \meta{value} (default: 0.4pt):] The thickness option defines
560 the thickness of the lines of the circles. It must contain the unit of length (cm,
561 pt, etc.).
562 \end{optionsenum}
563
564 Here is an example of customizing the drawing. First, recall that
565 the external file \Verb+mesh.txt+ is:
566 \begin{verbatim}
567 0.3 0.3
568 1.5 1
569 4 0
570 4.5 2.5
571 1.81 2.14
572 2.5 0.5
573 2.8 1.5
574 \end{verbatim}
575 We draw the addition of the 6th point. The 7th line will be ignored.
576 \begin{Exemple}
577 \meshAddPointBW[
578 tikz,
579 mode = ext,
580 color = blue!70,
581 meshpoint = \alpha,
582 newpoint = y,
583 colorBack=red!10,
584 colorNew = green!50!red,
585 colorCircle = blue,
586 colorBbox = black!20,
587 bbox = show,
588 scale=1.4cm,
589 step=badtriangles,
590 thickness=0.2pt,
591 thicknessCircle=1pt,
592 thicknessNew=3pt % useless because this step
593 ]
594 {mesh.txt}{6}
595 \end{Exemple}
596
597 \subsection{Mesh a Polygon}
598
599 \commande|\meshPolygon[«options»]{«list of points» or «file name»}|\medskip
600
601
602 With \luamesh, it is possible to mesh an object giving the
603 \emph{border}, \emph{i.e.}, one closed polygon. The polygon is given
604 as a list of points as above:
605 \begin{center}
606 \verb+(x1,y1);(x2,y2);(x3,y3);...;(xn,yn)+
607 \end{center}
608 Once again we can also give a file of points using the \Verb+mode+
609 option.
610
611 This command allows to plot the steps within the building of a complete
612 mesh. The followed method is, given a parameter $h$:
613 \begin{itemize}
614 \item to build a squared grid of points with a unit distance equal to
615 $h$;
616 \item to keep the grid points inside the polygon;
617 \item if necessary to add points along the polygon to respect the
618 distance parameter;
619 \item to mesh the complete set of points (using the Bowyer and Watson
620 algorithm).
621 \end{itemize}
622 One can use the macro as follows:
623 \begin{Exemple}
624 \meshPolygon[step=polygon,scale=2cm]{(0,0);(1,0);(1,0.5);(0,0.5);(-0.20,0.35);(-0.25,0.25);(-0.20,0.15)}
625 \meshPolygon[step=grid,scale=2cm]{(0,0);(1,0);(1,0.5);(0,0.5);(-0.20,0.35);(-0.25,0.25);(-0.20,0.15)}
626 \meshPolygon[step=points,scale=2cm]{(0,0);(1,0);(1,0.5);(0,0.5);(-0.20,0.35);(-0.25,0.25);(-0.20,0.15)}
627 \meshPolygon[step=mesh,scale=2cm]{(0,0);(1,0);(1,0.5);(0,0.5);(-0.20,0.35);(-0.25,0.25);(-0.20,0.15)}
628 \end{Exemple}
629
630 Note that if the points of the grid are too closed to the points of
631 the refined boundary, they are ejected.
632
633 \subsubsection{The Options}
634
635 There are several options (some of them are the same as for
636 \Verb+\buildMeshBW+) to customize the drawing.
637 \begin{optionsenum}
638 \item[mode = int (default) \textme{or} ext:] this option allows to
639 use either the previously described set of points as the argument, or
640 a file containing the points line by line (in 2 columns). Such a
641 file looks like :
642 \begin{verbatim}
643 x1 y1
644 x2 y2
645 x3 y3
646 ...
647 xn yn
648 \end{verbatim}
649 \item[h = \meta{value} (default: 0.2):] The mesh parameter, it is the
650 unit distance for the grid. If necessary, the boundary is refined to
651 get points which respect the distance constrain.
652 \item[color = \meta{value} (default: black):] The color of the
653 drawing (the grid point and the mesh).
654 \item[colorPolygon = \meta{value} (default: red):] The color of the
655 drawing for the boundary polygon.
656 \item[print = none (default) \textme{or} points \textme{or}
657 dotpoints:] The \Verb+point+ value allows to label the vertices of the
658 triangulation. This also adds a \emph{dot} at each vertex. The
659 \Verb+dotpoints+ value only add a dot without the labeling.
660 \item[meshpoint = \meta{value} (default: P):] The letter(s) used to
661 label the vertices of the triangulation. It is included in the math
662 mode delimiters \Verb+$...$+.
663 \item[step = polygon \textme{or} grid \textme{or}
664 points \textme{or} mesh (default):] To choose the step we want to draw,
665 see the description above.
666 \item[tikz (boolean, default:false):] By default, this boolean is set
667 to \Verb+false+, and MetaPost (with \Verb+luamplib+) is used to draw
668 the picture. With this option, \Verb+tikz+ is the \textit{drawing
669 engine}.
670 \item[scale = \meta{value} (default: 1cm):] The scale option defines
671 the scale at which the picture is drawn (the same for both
672 axis). It must contain the unit of length (cm,
673 pt, etc.).
674 \item[gridpoints = rect (default) \textme{or} perturb:] This option
675 allows to specify the mode of generation of the grid points. The
676 value \Verb+rect+ produces a simple rectangular grid, and the value
677 \Verb+pertub+ randomly perturbs the rectangular grid.
678 \item[thickness = \meta{value} (default: 0.4pt):] The thickness option defines
679 the thickness of the lines of the mesh. It must contain the unit of length (cm,
680 pt, etc.).
681 \item[thicknessPolygon = \meta{value} (default: 0.4pt):] The thickness option defines
682 the thickness of the lines of the polygon. It must contain the unit of length (cm,
683 pt, etc.).
684 \end{optionsenum}
685
686 Here is an example of customizing the drawing.
687 \begin{Exemple}
688 \meshPolygon[
689 tikz,
690 color = blue!70,
691 meshpoint = \alpha,
692 colorPolygon=red!100,
693 scale=4cm,
694 step=mesh,
695 print=points,
696 gridpoints=perturb,
697 thickness=0.5pt,
698 thicknessPolygon=1pt]
699 {(0,0);(1,0);(1,0.5);(0,0.5);(-0.20,0.35);(-0.25,0.25);(-0.20,0.15)}
700 \end{Exemple}
701
702
703 \section{The \emph{inc} Macros}\label{sec:inc}
704
705 The three macros presented in the above sections have complementary
706 macros, with the suffix \Verb+inc+ that allow the user to add code
707 (MetaPost or \Verb+tikz+, depending of the drawing engine) before and
708 after the code generated by \luamesh. These commands have the same options as
709 the non \emph{inc} one.
710
711 The three macros are:\medskip
712
713
714 \commande|\buildMeshBWinc[«options»]{«list of points» or «file name»}{«code before»}{«code after»}|\medskip
715
716 \commande|\drawPointsMeshinc[«options»]{«list of points» or «file name»}{«code before»}{«code after»}|\medskip
717
718 \commande|\meshAddPointBWinc[«options»]{«list of points» or «file name»}%|
719
720 \commande| {«point» or «number of line»}{«code before»}{«code after»}|\medskip
721
722 \subsection{With MetaPost}
723
724 We consider the case where the drawing engine is MetaPost (through the
725 \Verb+luamplib+ package).
726
727 The feature is described for the \Verb+\buildMeshBWinc+ but the mechanism
728 and possibilities are exactly the same for all three macros.
729
730 When we use the MetaPost drawing engine, the macros previously
731 described produce a code of the form
732 \begin{latexcode}
733 \begin{luamplib}
734 u:=<scale>;
735 beginfig(0);
736 <code for the drawing>
737 endfig;
738 \end{luamplib}
739 \end{latexcode}
740
741 Then, the arguments \meta{code before} and \meta{code after} are
742 inserted as follows:
743 \begin{latexcode}
744 \begin{luamplib}
745 u:=<scale>;
746 <<code before>>
747 <code for the drawing>
748 <<code after>>
749 \end{luamplib}
750 \end{latexcode}
751 \begin{warning}
752 With the \emph{inc} macros, the user has to add the \Verb+beginfig();+
753 and \Verb+endfig;+ commands to produce a picture. Indeed, this allows
754 to use the \Verb+\everymplib+ command from the \Verb+\luamplib+ package.
755 \end{warning}
756
757 \subsubsection{The \LaTeX{} Colors Inside the MetaPost Code}\label{sec:mpcolor}
758
759 The configurable colors
760 of the \LaTeX{} macro are accessible inside the MetaPost code. For
761 \Verb+\buildMeshBWinc+ and \Verb+\drawPointsMeshinc+,
762 \Verb+\luameshmpcolor+,
763 and \Verb+\luameshmpcolorBbox+ have been defined.
764 For the macro \Verb+\meshAddPointBWinc+ three additional
765 colors are present: \Verb+\luameshmpcolorBack+,
766 \Verb+\luameshmpcolorNew+, and
767 \Verb+\luameshmpcolorCircle+. For the macro \Verb+\meshPolygon+, the
768 color \Verb+\luameshmpcolorPoly+ is defined. Of course, MetaPost
769 colors can be defined as well. Finally, the \Verb+luamplib+ mechanism
770 \Verb+\mpcolor+ is also available.
771
772 \subsubsection{The Mesh Points}
773
774 At the beginning of the automatically generated code, a list of
775 MetaPost \Verb+pair+s are defined corresponding to all the vertices in
776 the mesh (when the option \Verb+bbox=show+, the last 4 points are the
777 \emph{bounding box points}). The points are available with the
778 \Verb+MeshPoints[]+ table of variables. The \Verb+pair+s ($\R^{2}$ points)
779 \Verb+MeshPoints[i]+ are
780 defined using the unit length \Verb+u+.
781
782 With the \Verb+\meshPolygon+ macro, we have the points of the polygon
783 (refined) that are available with the
784 \Verb+polygon[]+ table of variables.
785
786 \subsubsection{Examples}
787
788 Here is three examples for the different macros.
789 \begin{Exemple}
790 \drawPointsMeshinc[
791 color = blue!50,
792 print = points,
793 meshpoint = x,
794 scale=0.8cm,
795 ]{(0.3,0.3);(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}%
796 {% code before
797 beginfig(0);
798 }%
799 {% code after
800 label(btex Mesh $\mathbb{T}$ etex, (0,2u)) withcolor \luameshmpcolor;
801 endfig;
802 }
803 \buildMeshBWinc[%
804 bbox = show,
805 color = red,
806 colorBbox = blue!30,
807 print = points,
808 meshpoint = x,
809 scale=0.8cm,
810 thickness = 1.4pt
811 ]{(0.3,0.3);(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}%
812 {% code before
813 beginfig(0);
814 }
815 {% code after
816 drawdblarrow MeshPoints[3] -- MeshPoints[9] withpen pencircle scaled 1pt
817 withcolor (0.3,0.7,0.2);
818 endfig;
819 }
820 \meshAddPointBWinc[
821 meshpoint = \alpha,
822 newpoint = y,
823 colorBack=red!10,
824 colorNew = green!50!red,
825 colorCircle = blue,
826 colorBbox = black!20,
827 bbox = show,
828 scale=0.8cm,
829 step=badtriangles]
830 {(0.3,0.3);(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5)}{(2.8,1.5)}%
831 {%code before
832 picture drawing;
833 drawing := image(
834 }{%code after
835 );
836 beginfig(0);
837 fill MeshPoints[7]--MeshPoints[8]--MeshPoints[9]--MeshPoints[10]--cycle
838 withcolor \mpcolor{blue!10};
839 draw drawing;
840 endfig;
841 }
842 \end{Exemple}
843 \begin{warning}
844 The variables \Verb+MeshPoints[]+ are not defined for the argument
845 corresponding to the code placed \textbf{before} the code generated by
846 \luamesh. Hence, to use such variables, we have to define a
847 \Verb+picture+ as shown in the third example above.
848 \end{warning}
849
850
851 \subsection{With TikZ}
852
853 If we have chosen \Verb+tikz+ as the drawing engine, the added code
854 will be written in \Verb+tikz+. In that case, the two arguments
855 \meta{code before} and \meta{code after} will be inserted as follows:
856 \begin{latexcode}
857 \noindent
858 \begin{tikzpicture}[x=<scale>,y=<scale>]
859 <<code before>>
860 <generated code>
861 <<code after>>
862 \end{tikzpicture}
863 \end{latexcode}
864
865 Because the engine is \Verb+tikz+ their is no issue with colors, the
866 \LaTeX{} colors (e.g.: \Verb+xcolor+) can be used directly.
867
868 \subsubsection{The Mesh Points}
869
870 The mesh points are defined here as \Verb+tikz+
871 \Verb+\coordinate+ and named as follows
872 \begin{latexcode}
873 \coordinate (MeshPoints1) at (...,...);
874 \coordinate (MeshPoints2) at (...,...);
875 \coordinate (MeshPoints3) at (...,...);
876 %etc.
877 \end{latexcode}
878
879 With the \Verb+\meshPolygon+ we have also the polygon points coordinates:
880 \begin{latexcode}
881 \coordinate (polygon1) at (...,...);
882 %etc.
883 \end{latexcode}
884
885 Once again these coordinates are not yet defined to be used in the
886 code given by \meta{code
887 before} argument.
888
889 \subsubsection{Examples}
890
891 \begin{Exemple}
892 \drawPointsMeshinc[
893 tikz,
894 color = blue!50,
895 print = points,
896 meshpoint = x,
897 scale=0.8cm,
898 ]{(0.3,0.3);(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}%
899 {% code before
900 }%
901 {% code after
902 \node[color = blue!50] at (0,2) {Mesh $\mathbb{T}$} ;
903 }
904 \buildMeshBWinc[%
905 tikz,
906 bbox = show,
907 color = red,
908 colorBbox = blue!30,
909 print = points,
910 meshpoint = x,
911 scale=0.8cm,
912 thickness=1pt
913 ]{(0.3,0.3);(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}%
914 {% code before
915 }
916 {% code after
917 \draw[<->,thick, color=green] (MeshPoints3) -- (MeshPoints9);
918 }
919 \end{Exemple}
920
921 \section{Voronoï Diagrams}
922
923 Another interesting feature of the Delaunay triangulation is that its
924 \emph{dual} is the so-called Voronoï diagram. More precisely, for a
925 finite set of
926 points $\{p_{1},\ldots, p_{n}\}$ in the Euclidean plane, the Voronoï
927 cell $R_{k}$ corresponding to $p_{k}$ is the set of
928 all points in the Euclidean plane $\R^{2}$ whose distance to $p_{k}$ is less
929 than
930 or equal to its distance to any other $p_{k'}$.\bigskip
931
932
933 \commande|\buildVoronoiBW[«options»]{«list of points» or «file name»}|\medskip
934
935 This macro produce the Voronoï diagram of the given \meta{list of
936 points}. Once again, the
937 list of
938 points must be given in the following way :
939 \begin{center}
940 \verb+(x1,y1);(x2,y2);(x3,y3);...;(xn,yn)+
941 \end{center}
942
943 \begin{Exemple}
944 \buildVoronoiBW{(0.3,0.3);(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5);(0.1,2);(1.5,-0.3)}
945 \end{Exemple}
946
947 \subsection{The Options}\label{sec:voronoiOptions}
948
949
950 There are several options to customize the drawing.
951 \begin{optionsenum}
952 \item[mode = int (default) \textme{or} ext:] this option allows to
953 use either the previously described set of points in the argument, or
954 a file containing the points line by line (in 2 columns). Such a
955 file looks like :
956 \begin{verbatim}
957 x1 y1
958 x2 y2
959 x3 y3
960 ...
961 xn yn
962 \end{verbatim}
963 \item[bbox = none (default) \textme{or} show:] this option allows to draw the
964 added points to form a \emph{bounding box}\footnote{The bounding
965 box is defined by four points place at 15\% around the box
966 defined by $(x_{\min},y_{\min})$, $(x_{\min},y_{\max})$,
967 $(x_{\max},y_{\max})$, and $(x_{\min},y_{\max})$. It is used by
968 the algorithm and will be computed in any case.} and the corresponding
969 triangulation. By default, these points are removed at the end of
970 the algorithm.
971 \item[color = \meta{value} (default: black):] The color of the
972 drawing of the Delaunay mesh.
973 \item[colorBbox = \meta{value} (default: black):] The color of the
974 drawing for the elements (points and triangles) belonging to the
975 bounding box.
976 \item[colorVoronoi = \meta{value} (default: red):] The color of the
977 drawing for the elements (points and polygons) belonging to the
978 Voronoï diagram.
979 \item[print = none (default) \textme{or} points:] To label the
980 vertices in the
981 triangulation. Contrary to the previous macros, where
982 \Verb+print=none+, a \emph{dot} is produced at each vertex of the
983 set of points and at the circumcircle centers which are the nodes of
984 the Voronoï diagram.
985 \item[meshpoint = \meta{value} (default: P):] The letter(s) used to
986 label the vertices of the triangulation. This is included in the math
987 mode delimiters \Verb+$...$+. The bounding box points are labelled
988 with numbers 1 to 4 and with a star exponent.
989 \item[circumpoint = \meta{value} (default: P):] The letter(s) used to
990 label the vertices of the Voronoï diagram. This is included in the math
991 mode delimiters \Verb+$...$+.
992 \item[tikz (boolean, default:false):] By default, this boolean is set
993 to \Verb+false+, and MetaPost (with \Verb+luamplib+) is used to draw
994 the picture. With this option, \Verb+tikz+ becomes the \textit{drawing
995 engine}.
996 \item[scale = \meta{value} (default: 1cm):] The scale option defines
997 the scale at which the picture is drawn (the same for both
998 axes). It must contain the unit of length (cm,
999 pt, etc.).
1000 \item[delaunay = none (default) \textme{or} show:] This option
1001 allows to draw the Delaunay triangulation under the Voronoï diagram.
1002 \item[styleDelaunay = none (default) \textme{or} dashed:] This option
1003 allows to draw the Delaunay triangulation in dashed lines.
1004 \item[styleVoronoi = none (default) \textme{or} dashed:] This option
1005 allows to draw the Voronoï edges in dashed lines.
1006 \item[thickness = \meta{value} (default: 0.4pt):] The thickness option defines
1007 the thickness of the lines of the mesh (if plotted). It must contain the unit of length (cm,
1008 pt, etc.).
1009 \item[thicknessVoronoi = \meta{value} (default: 0.4pt):] The thickness option defines
1010 the thickness of the lines of the Voronoï diagram. It must contain the unit of length (cm,
1011 pt, etc.).
1012 \end{optionsenum}
1013
1014 \begin{Exemple}
1015 \buildVoronoiBW[tikz,
1016 delaunay=show,
1017 styleDelaunay=dashed,
1018 thickness = 1pt,
1019 thicknessVoronoi=2pt]
1020 {(0.3,0.3);(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5);(0.1,2);(1.5,-0.3)}
1021 \end{Exemple}
1022
1023 \subsection{The \emph{inc} variant}
1024
1025 Once again, a variant of the macros is available allowing the user to
1026 add code before and after the code produced by \luamesh (with the same options
1027 as the non \emph{inc} command). We refer to
1028 section~\ref{sec:inc} because it works the same way.
1029
1030 Let us note that:
1031 \begin{itemize}
1032 \item with MetaPost, the circumcenters are defined using
1033 \Verb+pair CircumPoints[];+ and so they are accessible.
1034 \item With \Verb+tikz+, there are new coordinates defined as follows
1035 \begin{latexcode}
1036 \coordinate (CircumPoints1) at (...,...);
1037 \coordinate (CircumPoints2) at (...,...);
1038 \coordinate (CircumPoints3) at (...,...);
1039 % etc.
1040 \end{latexcode}
1041 \end{itemize}
1042
1043 Finally, when the MetaPost drawing engine is used another color is
1044 available (see~\ref{sec:mpcolor}): \Verb+\luameshmpcolorVoronoi+.
1045
1046 \section{With Gmsh}
1047
1048 Gmsh~\cite{gmsh} is an open source efficient software that produces meshes. The
1049 exporting format is the \emph{MSH ASCII file format} and can be easily
1050 read by a Lua program. \luamesh provides the user with dedicated
1051 macros to read and draw meshes coming from a Gmsh exportation.\bigskip
1052
1053 \commande|\drawGmsh[«options»]{«file name»}|\medskip
1054
1055 This macro draws the triangulation produced by Gmsh and exported in the
1056 \Verb+msh+ format. The argument is the name of the file to be read
1057 (e.g.: \Verb+maillage.msh+).
1058
1059 Since the version 0.6, \luamesh support both version 2 and 4 of the \emph{MSH ASCII file format}.
1060
1061
1062 \begin{Exemple}
1063 \drawGmsh{maillage.msh} % version 2.2 of MSH ASCII file format
1064 \end{Exemple}
1065
1066
1067 \begin{Exemple}
1068 \drawGmsh{maillagev4.msh} % version 4.1 of MSH ASCII file format
1069 \end{Exemple}
1070
1071 There are several options to customize the drawing.
1072 \begin{optionsenum}
1073 \item[color = \meta{value} (default: black):] The color of the
1074 drawing.
1075 \item[print = none (default) \textme{or} points:] To label the vertices of the
1076 triangulation. Contrary to some previous macros, when
1077 \Verb+print=none+ a \emph{dot} is produced at each vertex of the
1078 set of points and at the circumcircle centers (these are the nodes of
1079 the Voronoï diagram).
1080 \item[meshpoint = \meta{value} (default: P):] The letter(s) used to
1081 label the vertices of the triangulation. This is included in the math
1082 mode delimiters \Verb+$...$+. The bounding box points are labeled
1083 with numbers 1 to 4 and with a star exponent.
1084 \item[tikz (boolean, default:false):] By default, this boolean is set
1085 to \Verb+false+, and MetaPost (with \Verb+luamplib+) is used to draw
1086 the picture. With this option, \Verb+tikz+ becomes the \textit{drawing
1087 engine}.
1088 \item[scale = \meta{value} (default: 1cm):] The scale option defines
1089 the scale at which the picture is drawn (the same for both
1090 axes). It must contain the unit of length (cm,
1091 pt, etc.).
1092 \item[thickness = \meta{value} (default: 0.4pt):] The thickness option defines
1093 the thickness of the lines of the mesh. It must contain the unit of length (cm,
1094 pt, etc.).
1095 \end{optionsenum}
1096 Here is an example:
1097 \begin{Exemple}
1098 \drawGmsh[scale=2cm,print=points, color=blue!30,thickness=0.8pt]{maillage.msh}
1099 \end{Exemple}
1100
1101 \subsection{Gmsh and Voronoï Diagrams}
1102
1103 Because Gmsh generates Delaunay triangulations, we can plot the associated
1104 Voronoï diagram. This is done by the following macro:\bigskip
1105
1106 \commande|\gmshVoronoi[«options»]{«file name»}|\medskip
1107
1108 \begin{Exemple}
1109 \gmshVoronoi{maillage.msh}
1110 \end{Exemple}
1111
1112
1113 \subsection{The Options}\label{sec:voronoiOptions}
1114
1115
1116 There are several options to customize the drawing.
1117 \begin{optionsenum}
1118 \item[color = \meta{value} (default: black):] The color of the
1119 drawing of the Delaunay mesh.
1120 \item[colorVoronoi = \meta{value} (default: red):] The color of the
1121 drawing for the elements (points and polygons) belonging to the
1122 Voronoï diagram.
1123 \item[print = none (default) \textme{or} points:] To label the vertices of the
1124 triangulation. Contrary to some previous macros, when
1125 \Verb+print=none+, a \emph{dot} is produced at each vertex of the
1126 set of points and at the circumcircle centers (these are the nodes of
1127 the Voronoï diagram).
1128 \item[meshpoint = \meta{value} (default: P):] The letter(s) used to
1129 label the vertices of the triangulation. It is included in the math
1130 mode delimiters \Verb+$...$+. The bounding box points are labeled
1131 with numbers 1 to 4 and with a star exponent.
1132 \item[circumpoint = \meta{value} (default: P):] The letter(s) used to
1133 label the vertices of the Voronoï diagram. This is included in the math
1134 mode delimiters \Verb+$...$+.
1135 \item[tikz (boolean, default:false):] By default, this boolean is set
1136 to \Verb+false+, and MetaPost (with \Verb+luamplib+) is used to draw
1137 the picture. With this option, \Verb+tikz+ becomes the \textit{drawing
1138 engine}.
1139 \item[scale = \meta{value} (default: 1cm):] The scale option defines
1140 the scale at which the picture is drawn (the same for both
1141 axes). It must contain the unit of length (cm,
1142 pt, etc.).
1143 \item[delaunay = none (default) \textme{or} show] This option
1144 allows to draw the Delaunay triangulation overlapped with the
1145 Voronoï diagram.
1146 \item[styleDelaunay = none (default) \textme{or} dashed] This option
1147 allows to draw the Delaunay triangulation in dashed lines.
1148 \item[styleVoronoi = none (default) \textme{or} dashed] This option
1149 allows to draw the Voronoï edges in dashed lines.
1150 \item[thickness = \meta{value} (default: 0.4pt):] The thickness option defines
1151 the thickness of the lines of the mesh (if plotted). It must contain the unit of length (cm,
1152 pt, etc.).
1153 \item[thicknessVoronoi = \meta{value} (default: 0.4pt):] The thickness option defines
1154 the thickness of the lines of the Voronoï diagram. It must contain the unit of length (cm,
1155 pt, etc.).
1156 \end{optionsenum}
1157
1158 \begin{Exemple}
1159 \gmshVoronoi[tikz,
1160 scale=4cm,
1161 delaunay=show,
1162 styleVoronoi=dashed,
1163 thickness=0.4pt,
1164 thicknessVoronoi=2pt
1165 ]{maillagev4.msh}
1166 \end{Exemple}
1167
1168
1169 \subsection{The \emph{inc} variants}
1170
1171 Once again, there exist \emph{inc} variant macros (with the same options):\bigskip
1172
1173 \commande|\drawGmshinc[«options»]{«file name»}{«code before»}{«code after»}|\medskip
1174
1175 \commande|\gmshVoronoiinc[«options»]{«file name»}{«code before»}{«code after»}|\medskip
1176
1177 We refer to the previous sections for explanations.
1178
1179
1180 \section{\texttt{mplibcode} environments}
1181
1182 All the \Verb+mplibcode+ environments produced by this package use instance
1183 mechanism provided by the \Verb+luamplib+ package~\cite{luamplib}. The name of
1184 the instance is \verb+luamesh+.
1185
1186 \subsection{A MetaPost package}
1187
1188 This package comes with a \Verb+luamesh.mp+ file. This file provide for the
1189 moment only one macro to draw circumscribed circles of three points. All of the
1190 \Verb+luamesh+ instances of \Verb+mplibcode+ environments include the MetaPost
1191 \Verb+luamesh.mp+ package.
1192 \bigskip
1193
1194 \commande|circumcircle(«pair1»,«pair2»,«pair3»)|\medskip
1195
1196 This macro returns a \Verb+path+: the circumscribed circle passing by the three
1197 argument \Verb+pair+s.\footnote{For the tikz users, we refer to
1198 \texttt{tkz-euclide}~\cite{tkzeuclide} package that provides a large number of tools including
1199 on to draw circumscribed circles.}
1200
1201 \begin{Exemple}
1202 \buildVoronoiBWinc{(0, 0);(6,0);(2,4);(1.5,2);(2.,0.5);(3,2.6);(3.5,1);(5,3.);(0.3,3.2)}{beginfig(0);}{draw circumcircle(MeshPoints1,MeshPoints2,MeshPoints3);endfig;}
1203 \end{Exemple}
1204
1205
1206 \section{Gallery}
1207 \subsection{With Animate}
1208
1209 If you use \emph{Adobe Acrobat reader} or \emph{Okular}, you can easily produce an
1210 animation of the Bowyer and Watson algorithm with the package
1211 \Verb+animate+~\cite{animate}.
1212
1213 For example, the following code (in a file name \Verb+animation.tex+):
1214 \begin{latexcode}
1215 \documentclass{article}
1216 %% lualatex compilation
1217 \usepackage[margin=2.5cm]{geometry}
1218 \usepackage{luamesh}
1219 \usepackage{fontspec}
1220 \usepackage{multido}
1221 \pagestyle{empty}
1222 \def\drawPath{draw (-2,-2)*u--(8,-2)*u--(8,6)*u--(-2,6)*u--cycle withcolor 0.99white;}
1223 \def\clipPath{clip currentpicture to (-2,-2)*u--(8,-2)*u--(8,6)*u--(-2,6)*u--cycle;}
1224 \begin{document}
1225 \drawPointsMeshinc[mode=ext, bbox = show,colorBbox = blue!20,print=points]{mesh.txt}%
1226 {%
1227 beginfig(0);
1228 \drawPath
1229 }%
1230 {%
1231 \clipPath
1232 endfig;
1233 }
1234 \newpage\buildMeshBWinc[mode=ext,bbox = show,colorBbox = blue!20,print=points]{meshInit.txt}%
1235 {%
1236 beginfig(0);
1237 \drawPath
1238 }%
1239 {%
1240 \clipPath
1241 endfig;
1242 }
1243 \multido{\ii=5+1}{4}{%
1244 \newpage\meshAddPointBWinc[mode=ext,step=badtriangles,colorNew
1245 =green!20!red,colorBack=red!10,colorCircle = blue,bbox =
1246 show,colorBbox = blue!20]{mesh.txt}{\ii}%
1247 {%
1248 beginfig(0);
1249 \drawPath
1250 }%
1251 {%
1252 \clipPath
1253 endfig;
1254 } \newpage
1255 \meshAddPointBWinc[mode=ext,step=cavity,colorNew
1256 =green!20!red,colorBack=red!10,colorCircle = blue,bbox =
1257 show,colorBbox = blue!20]{mesh.txt}{\ii}%
1258 {%
1259 beginfig(0);
1260 \drawPath
1261 }%
1262 {%
1263 \clipPath
1264 endfig;
1265 } \newpage
1266 \meshAddPointBWinc[mode=ext,step=newtriangles,colorNew
1267 =green!20!red,colorBack=red!10,colorCircle = blue,bbox =
1268 show,colorBbox = blue!20]{mesh.txt}{\ii}%
1269 {%
1270 beginfig(0);
1271 \drawPath
1272 }%
1273 {%
1274 \clipPath
1275 endfig;
1276 }
1277 }
1278 \newpage
1279 \buildMeshBWinc[mode=ext,bbox = show,colorBbox = blue!20,print=points]{mesh.txt}%
1280 {%
1281 beginfig(0);
1282 \drawPath
1283 }%
1284 {%
1285 \clipPath
1286 endfig;
1287 }
1288 \newpage
1289 \buildMeshBWinc[mode=ext,print=points]{mesh.txt}%
1290 {%
1291 beginfig(0);
1292 \drawPath
1293 }%
1294 {%
1295 \clipPath
1296 endfig;
1297 }
1298 \end{document}
1299 \end{latexcode}
1300 produces a PDF with multiple pages. Using the \Verb+pdfcrop+ program,
1301 we crop the pages to the material, and then we can animate the PDF
1302 using the \Verb+animate+ package.
1303
1304 %\begin{Exemple}
1305 %\animategraphics[controls]{1}{animation-crop}{}{}
1306 %\end{Exemple}
1307
1308
1309 \section{History}
1310
1311 \begin{itemize}
1312 \item July, 2022, v~0.7, adding of thickness options, creation of the MetaPost
1313 package, and improvement of the documentation.
1314 \item June, 6th, 2020, v 0.6, correction of bug produced by the
1315 deleted \Verb+\mplibcolor+ function of \Verb+luamplib+ package.
1316 \item June, 6th, 2020, v 0.6, add support of version 4 of the
1317 \emph{MSH ASCII file format}.
1318 \end{itemize}
1319
1320
1321 \printbibliography
1322
1323 \end{document}
1324
1325
1326
1327 %%% Local Variables:
1328 %%% flyspell-mode: 1
1329 %%% ispell-local-dictionary: "american"
1330 %%% End: