\usepackage{enumitem}
\usepackage[tikz]{bclogo}
\usepackage{wrapfig}
-
+\usepackage{animate}
\title{\Verb+luamesh+: compute and draw meshes with \lualatex}
\author{Maxime Chupin \email{mc@melusine.eu.org}}
to use the \Verb+\everymplib+ command from the \Verb+\luamplib+ package.
\end{warning}
-\subsubsection{The \LaTeX{} Colors Inside the MetaPost Code}
+\subsubsection{The \LaTeX{} Colors Inside the MetaPost Code}\label{sec:mpcolor}
The configurable colors
of the \LaTeX{} macro are accessible inside the MetaPost code. For
}
\end{Exemple}
+\section{Voronio Diagrams}
+
+Another interesting concept of Delaunay triangulation is that it is
+\emph{dual} to it so-called Voronio diagram. For a finite set of
+points $\{p_{1},\ldots, p_{n}\}$ in the Euclidean plane, for all
+$p_{k}$, it corresponds a Voronoi cell $R_{k}$ consisting of
+every point in the Euclidean plane whose distance to $p_{k}$ is less
+than
+or equal to its distance to any other $p_{k'}$.\bigskip
+
+
+\commande|\buildVoronoiBW[«options»]{«list of points» or «file name»}|\medskip
+
+This macro produce the Voronio diagram dual to the Delaunay
+triangulation (computed by the Bowyer and Watson
+algorithm) of the given \meta{list of points}. Once again, the
+list of
+points must be given in the following way :
+\begin{center}
+ \verb+(x1,y1);(x2,y2);(x3,y3);...;(xn,yn)+
+\end{center}
+
+\begin{Exemple}
+ \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)}
+\end{Exemple}
+
+\subsection{The Options}\label{sec:voronoiOptions}
+
+
+There are several options to customize the drawing.
+\begin{optionsenum}
+\item[mode = int (default) \textme{or} ext:] this option allows to
+ use either the previously described set of points in the argument, or
+ a file, containing, line by line (2 columns), the points. Such a
+ file looks like :
+\begin{verbatim}
+x1 y1
+x2 y2
+x3 y3
+...
+xn yn
+\end{verbatim}
+\item[bbox = none (default) \textme{or} show:] this option allows to draw the
+ added points to form a \emph{bounding box}\footnote{The bounding
+ box is defined by four points place at 15\% around the box
+ defined by $(x_{\min},y_{\min})$, $(x_{\min},y_{\max})$,
+ $(x_{\max},y_{\max})$, and $(x_{\min},y_{\max})$. It is used by
+ the algorithm and will be computed in any case.} and the corresponding
+ triangulation. By default, these points are removed at the end of
+ the algorithm.
+\item[color = \meta{value} (default: black):] The color of the
+ drawing.
+\item[colorBbox = \meta{value} (default: black):] The color of the
+ drawing for the elements (points and triangles) belonging to the
+ bounding box.
+\item[colorVoronoi = \meta{value} (default: black):] The color of the
+ drawing for the elements (points and polygons) belonging to the
+ Voronoi diagram.
+\item[print = none (default) \textme{or} points:] To label the vertices of the
+ triangulation. Contrary to the previous macros, where
+ \Verb+print=none+, a \emph{dot} is produced at each vertex (of the
+ set of points and on the circumcircle center which are the nodes of
+ the Voronoi diagram).
+\item[meshpoint = \meta{value} (default: P):] The letter(s) used to
+ label the vertices of the triangulation. It is included in the math
+ mode delimiters \Verb+$...$+. The bounding box points are labeled
+ with numbers 1 to 4 and with a star exponent.
+\item[circumpoint = \meta{value} (default: P):] The letter(s) used to
+ label the vertices of the Voronoi diagram. It is included in the math
+ mode delimiters \Verb+$...$+.
+\item[tikz (boolean, default:false):] By default, this boolean is set
+ to \Verb+false+, and MetaPost (with \Verb+luamplib+) is used to draw
+ the picture. With this option, \Verb+tikz+ becomes the \textit{drawing
+ engine}.
+\item[scale = \meta{value} (default: 1cm):] The scale option defines
+ the scale at which the picture is drawn (the same for both
+ axes). It must contain the unit of length (cm,
+ pt, etc.).
+\end{optionsenum}
+
+
+\subsection{The \emph{inc} variant}
+
+Once again, a variant of the macros is available allowing the user to
+add code before and after the code produced by \luamesh. We refer to
+the section~\ref{sec:inc} because it works the same way.
+
+Let us note that:
+\begin{itemize}
+\item with MetaPost, the circumcenters are defined using
+ \Verb+pair CircumPoints[];+, and so, are accessible.
+\item With \Verb+tikz+, there are new coordinates defined as follows
+ \begin{latexcode}
+ \coordinate (CircumPoints1) at (...,...);
+ \coordinate (CircumPoints2) at (...,...);
+ \coordinate (CircumPoints3) at (...,...);
+ % etc.
+ \end{latexcode}
+\end{itemize}
+
+Finally, when the MetaPost drawing engine is used, another color is
+available (see~\ref{sec:mpcolor}): \Verb+\luameshmpcolorVoronoi+.
+
+
+\section{With Gmsh}
+
+Gmsh is a open source efficient software that produces meshes. The
+exporting format is the \emph{MSH ASCII file format} and can be easily
+read by a Lua program. \luamesh provides the user with dedicated
+macros to read and draw meshes coming from a Gmsh exportation.\bigskip
+
+\commande|\drawGmsh[«options»]{«file name»}|\medskip
+
+This macro draw the triangulation produced by Gmsh and exported in the
+\Verb+msh+ format. The argument is the name of the file to read
+(e.g.: \Verb+maillage.msh+).
+
+\begin{Exemple}
+\drawGmsh{maillage.msh}
+\end{Exemple}
+
+There are several options to customize the drawing.
+\begin{optionsenum}
+\item[color = \meta{value} (default: black):] The color of the
+ drawing.
+\item[print = none (default) \textme{or} points:] To label the vertices of the
+ triangulation. Contrary to the previous macros, where
+ \Verb+print=none+, a \emph{dot} is produced at each vertex (of the
+ set of points and on the circumcircle center which are the nodes of
+ the Voronoi diagram).
+\item[meshpoint = \meta{value} (default: P):] The letter(s) used to
+ label the vertices of the triangulation. It is included in the math
+ mode delimiters \Verb+$...$+. The bounding box points are labeled
+ with numbers 1 to 4 and with a star exponent.
+\item[tikz (boolean, default:false):] By default, this boolean is set
+ to \Verb+false+, and MetaPost (with \Verb+luamplib+) is used to draw
+ the picture. With this option, \Verb+tikz+ becomes the \textit{drawing
+ engine}.
+\item[scale = \meta{value} (default: 1cm):] The scale option defines
+ the scale at which the picture is drawn (the same for both
+ axes). It must contain the unit of length (cm,
+ pt, etc.).
+\end{optionsenum}
+Here is an example:
+\begin{Exemple}
+ \drawGmsh[scale=2cm,print=points, color=blue!30]{maillage.msh}
+\end{Exemple}
+
+\subsection{Gmsh and Voronoi Diagrams}
+
+Because Gmsh generates Delaunay triangulations, we can plot the
+Voronoi diagram associated. This is done by the following macro:\bigskip
+
+\commande|\gmshVoronoi[«options»]{«file name»}|\medskip
+
+\begin{Exemple}
+ \gmshVoronoi{maillage.msh}
+\end{Exemple}
+
+We refer to the section~\ref{sec:voronoiOptions} for the list of the options.
+
+\subsection{The \emph{inc} variants}
+
+Once again, there exists \emph{inc} variant macros:\bigskip
+
+\commande|\drawGmshinc[«options»]{«file name»}{«code before»}{«code after»}|\medskip
+
+\commande|\gmshVoronoiinc[«options»]{«file name»}{«code before»}{«code after»}|\medskip
+
+We refer to the previous sections for explanations.
+
+\section{Gallery}
+\subsection{With Animate}
+
+If you use \emph{adobe acrobat reader}, you can easily produce an
+animation of the Bowyer and Watson algorithm with the package
+\Verb+animate+.
+
+For example, the following code (in a file name \Verb+animation.tex+):
+\begin{latexcode}
+ \documentclass{article}
+ %% lualatex compilation
+ \usepackage[margin=2.5cm]{geometry}
+ \usepackage{luamesh}
+ \usepackage{fontspec}
+ \usepackage{multido}
+ \pagestyle{empty}
+
+ \def\drawPath{draw (-2,-2)*u--(8,-2)*u--(8,6)*u--(-2,6)*u--cycle withcolor 0.99white;}
+ \def\clipPath{clip currentpicture to (-2,-2)*u--(8,-2)*u--(8,6)*u--(-2,6)*u--cycle;}
+
+ \begin{document}
+
+ \drawPointsMeshinc[
+ mode=ext,
+ bbox = show,
+ colorBbox = blue!20,
+ print=points
+ ]
+ {mesh.txt}%
+ {%
+ beginfig(0);
+ \drawPath
+ }%
+ {%
+ \clipPath
+ endfig;
+ }
+ \newpage
+ \buildMeshBWinc[
+ mode=ext,
+ bbox = show,
+ colorBbox = blue!20,
+ print=points
+ ]
+ {meshInit.txt}%
+ {%
+ beginfig(0);
+ \drawPath
+ }%
+ {%
+ \clipPath
+ endfig;
+ }
+ \multido{\ii=5+1}{4}{%
+ \newpage
+ \meshAddPointBWinc[
+ mode=ext,step=badtriangles,
+ colorNew =green!20!red,
+ colorBack=red!10,
+ colorCircle = blue,
+ bbox = show,
+ colorBbox = blue!20
+ ]
+ {mesh.txt}{\ii}%
+ {%
+ beginfig(0);
+ \drawPath
+ }%
+ {%
+ \clipPath
+ endfig;
+ } \newpage
+ \meshAddPointBWinc[
+ mode=ext,step=cavity,
+ colorNew =green!20!red,
+ colorBack=red!10,
+ colorCircle = blue,
+ bbox = show,
+ colorBbox = blue!20
+ ]
+ {mesh.txt}{\ii}%
+ {%
+ beginfig(0);
+ \drawPath
+ }%
+ {%
+ \clipPath
+ endfig;
+ } \newpage
+ \meshAddPointBWinc[
+ mode=ext,step=newtriangles,
+ colorNew =green!20!red,
+ colorBack=red!10,
+ colorCircle = blue,
+ bbox = show,
+ colorBbox = blue!20]
+ {mesh.txt}{\ii}%
+ {%
+ beginfig(0);
+ \drawPath
+ }%
+ {%
+ \clipPath
+ endfig;
+ }
+ }
+ \newpage
+ \buildMeshBWinc[
+ mode=ext,
+ bbox = show,
+ colorBbox = blue!20,
+ print=points
+ ]
+ {mesh.txt}%
+ {%
+ beginfig(0);
+ \drawPath
+ }%
+ {%
+ \clipPath
+ endfig;
+ }
+ \newpage
+ \buildMeshBWinc[
+ mode=ext,
+ print=points
+ ]
+ {mesh.txt}%
+ {%
+ beginfig(0);
+ \drawPath
+ }%
+ {%
+ \clipPath
+ endfig;
+ }
+\end{document}
+\end{latexcode}
+produces a PDF with multiple pages. Using the \Verb+pdfcrop+ program,
+we crop the pages to the material, and then we can animate the PDF
+using the \Verb+animate+ package.
+
+%\begin{Exemple}
+%\animategraphics[controls]{1}{animation-crop}{}{}
+%\end{Exemple}
+
\input{dum.bbl}
\end{document}
\select@language {english}
\contentsline {section}{\numberline {1}Installation}{3}{section.1}
\contentsline {subsection}{\numberline {1.1}With \TeX live and Linux or Mac OSX}{3}{subsection.1.1}
-\contentsline {subsection}{\numberline {1.2}With Mik\TeX {} and Windows}{3}{subsection.1.2}
-\contentsline {subsection}{\numberline {1.3}A \LuaLaTeX \xspace package}{3}{subsection.1.3}
+\contentsline {subsection}{\numberline {1.2}With Mik\TeX {} and Windows}{4}{subsection.1.2}
+\contentsline {subsection}{\numberline {1.3}A \LuaLaTeX \xspace package}{4}{subsection.1.3}
\contentsline {subsection}{\numberline {1.4}Dependencies}{4}{subsection.1.4}
\contentsline {section}{\numberline {2}The Basic Macros}{4}{section.2}
\contentsline {subsection}{\numberline {2.1}Draw a Complete Mesh}{4}{subsection.2.1}
-\contentsline {subsubsection}{\numberline {2.1.1}The Options}{4}{subsubsection.2.1.1}
+\contentsline {subsubsection}{\numberline {2.1.1}The Options}{5}{subsubsection.2.1.1}
\contentsline {subsection}{\numberline {2.2}Draw the Set of Points}{6}{subsection.2.2}
-\contentsline {subsubsection}{\numberline {2.2.1}The Options}{6}{subsubsection.2.2.1}
+\contentsline {subsubsection}{\numberline {2.2.1}The Options}{7}{subsubsection.2.2.1}
\contentsline {subsection}{\numberline {2.3}Draw a Step of the Bowyer and Watson Algorithm}{8}{subsection.2.3}
\contentsline {subsubsection}{\numberline {2.3.1}The Options}{9}{subsubsection.2.3.1}
\contentsline {section}{\numberline {3}The \emph {inc} Macros}{11}{section.3}
\contentsline {subsection}{\numberline {3.2}With TikZ}{14}{subsection.3.2}
\contentsline {subsubsection}{\numberline {3.2.1}The Mesh Points}{14}{subsubsection.3.2.1}
\contentsline {subsubsection}{\numberline {3.2.2}Examples}{14}{subsubsection.3.2.2}
+\contentsline {section}{\numberline {4}Voronio Diagrams}{15}{section.4}
+\contentsline {subsection}{\numberline {4.1}The Options}{16}{subsection.4.1}
+\contentsline {subsection}{\numberline {4.2}The \emph {inc} variant}{17}{subsection.4.2}
+\contentsline {section}{\numberline {5}With Gmsh}{17}{section.5}
+\contentsline {subsection}{\numberline {5.1}Gmsh and Voronoi Diagrams}{18}{subsection.5.1}
+\contentsline {subsection}{\numberline {5.2}The \emph {inc} variants}{19}{subsection.5.2}
+\contentsline {section}{\numberline {6}Gallery}{19}{section.6}
+\contentsline {subsection}{\numberline {6.1}With Animate}{19}{subsection.6.1}
--- /dev/null
+$MeshFormat
+2.2 0 8
+$EndMeshFormat
+$Nodes
+50
+1 0 0 0
+2 3 0 0
+3 0 3 0
+4 0.4693033951192702 2.963065021785638 0
+5 0.9270509831224205 2.853169548886248 0
+6 1.361971499215402 2.673019572566753 0
+7 1.763355756873741 2.427050983127515 0
+8 2.121320343555531 2.121320343563755 0
+9 2.427050983122084 1.763355756881216 0
+10 2.673019572563731 1.361971499221335 0
+11 2.853169548884875 0.9270509831266447 0
+12 2.963065021785299 0.4693033951214145 0
+13 0 0.499999999997822 0
+14 0 0.9999999999960245 0
+15 0 1.499999999994285 0
+16 0 1.999999999996158 0
+17 0 2.499999999998079 0
+18 2.500000000003167 0 0
+19 2.000000000001941 0 0
+20 1.500000000004168 0 0
+21 1.00000000000281 0 0
+22 0.5000000000014051 0 0
+23 1.234141133439995 1.234706476168725 0
+24 2.019011585984451 0.8482511421012229 0
+25 0.7996467420535595 2.004579558507475 0
+26 0.7193791167395813 0.7231883013413306 0
+27 1.519111484662544 1.840362994240276 0
+28 1.444230772066577 0.6206006444007433 0
+29 0.6032715654033697 1.482446070099814 0
+30 1.967205997854255 1.422470442749536 0
+31 2.483520846404239 0.5934345676487791 0
+32 0.5639644981111984 2.469590570556198 0
+33 1.323592795170413 2.162102387974417 0
+34 2.468934320532775 1.014872883347498 0
+35 1.818185974210566 0.4238910154260575 0
+36 0.3947241723756524 1.821731472036314 0
+37 1.134164055943625 1.659777451599567 0
+38 1.613471831330844 1.104183945170989 0
+39 0.9806274474984064 2.435458768712165 0
+40 0.4081594929391452 1.008296761660148 0
+41 1.00688752284509 0.4118199261386256 0
+42 0.439071022087537 0.4405508315229876 0
+43 1.118714369352139 0.8621581647343061 0
+44 1.923763789491919 1.798468600466841 0
+45 2.313447213716825 1.312293020670456 0
+46 1.529398659496223 1.467534627005675 0
+47 0.8456544688053689 1.137388163063763 0
+48 1.73022883395083 2.069861061874561 0
+49 2.160830764549087 0.3569017273154402 0
+50 0.3343775807151865 2.155932068334013 0
+$EndNodes
+$Elements
+101
+1 15 2 0 1 1
+2 15 2 0 2 2
+3 15 2 0 3 3
+4 1 2 0 1 3 4
+5 1 2 0 1 4 5
+6 1 2 0 1 5 6
+7 1 2 0 1 6 7
+8 1 2 0 1 7 8
+9 1 2 0 1 8 9
+10 1 2 0 1 9 10
+11 1 2 0 1 10 11
+12 1 2 0 1 11 12
+13 1 2 0 1 12 2
+14 1 2 0 2 1 13
+15 1 2 0 2 13 14
+16 1 2 0 2 14 15
+17 1 2 0 2 15 16
+18 1 2 0 2 16 17
+19 1 2 0 2 17 3
+20 1 2 0 3 2 18
+21 1 2 0 3 18 19
+22 1 2 0 3 19 20
+23 1 2 0 3 20 21
+24 1 2 0 3 21 22
+25 1 2 0 3 22 1
+26 2 2 0 6 12 18 31
+27 2 2 0 6 4 32 17
+28 2 2 0 6 47 37 23
+29 2 2 0 6 29 37 47
+30 2 2 0 6 13 40 42
+31 2 2 0 6 22 42 41
+32 2 2 0 6 17 3 4
+33 2 2 0 6 18 12 2
+34 2 2 0 6 13 14 40
+35 2 2 0 6 21 22 41
+36 2 2 0 6 20 41 28
+37 2 2 0 6 15 29 40
+38 2 2 0 6 25 37 29
+39 2 2 0 6 24 28 38
+40 2 2 0 6 28 43 38
+41 2 2 0 6 23 38 43
+42 2 2 0 6 20 28 35
+43 2 2 0 6 15 36 29
+44 2 2 0 6 11 12 31
+45 2 2 0 6 4 5 32
+46 2 2 0 6 24 35 28
+47 2 2 0 6 25 29 36
+48 2 2 0 6 20 21 41
+49 2 2 0 6 14 15 40
+50 2 2 0 6 24 30 45
+51 2 2 0 6 26 42 40
+52 2 2 0 6 26 41 42
+53 2 2 0 6 11 31 34
+54 2 2 0 6 24 45 34
+55 2 2 0 6 9 30 44
+56 2 2 0 6 6 7 33
+57 2 2 0 6 5 39 32
+58 2 2 0 6 27 37 33
+59 2 2 0 6 9 45 30
+60 2 2 0 6 25 33 37
+61 2 2 0 6 24 38 30
+62 2 2 0 6 1 13 42
+63 2 2 0 6 1 42 22
+64 2 2 0 6 24 31 49
+65 2 2 0 6 25 50 32
+66 2 2 0 6 24 34 31
+67 2 2 0 6 15 16 36
+68 2 2 0 6 19 20 35
+69 2 2 0 6 25 32 39
+70 2 2 0 6 7 48 33
+71 2 2 0 6 24 49 35
+72 2 2 0 6 25 36 50
+73 2 2 0 6 30 46 44
+74 2 2 0 6 8 9 44
+75 2 2 0 6 27 44 46
+76 2 2 0 6 5 6 39
+77 2 2 0 6 6 33 39
+78 2 2 0 6 18 49 31
+79 2 2 0 6 17 32 50
+80 2 2 0 6 10 11 34
+81 2 2 0 6 25 39 33
+82 2 2 0 6 27 33 48
+83 2 2 0 6 18 19 49
+84 2 2 0 6 16 17 50
+85 2 2 0 6 9 10 45
+86 2 2 0 6 7 8 48
+87 2 2 0 6 30 38 46
+88 2 2 0 6 23 43 47
+89 2 2 0 6 27 46 37
+90 2 2 0 6 28 41 43
+91 2 2 0 6 26 43 41
+92 2 2 0 6 23 37 46
+93 2 2 0 6 10 34 45
+94 2 2 0 6 19 35 49
+95 2 2 0 6 16 50 36
+96 2 2 0 6 23 46 38
+97 2 2 0 6 26 40 47
+98 2 2 0 6 29 47 40
+99 2 2 0 6 8 44 48
+100 2 2 0 6 26 47 43
+101 2 2 0 6 27 48 44
+$EndElements