\documentclass{lltxdoc}
\usepackage{tcolorbox}
-\usepackage{xargs}
\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}}
\date{\today}
+
+\definecolor{darkred}{rgb}{0.8,0.1,0.1}
+
+
\newcommand*\commande{\noindent\hspace{-30pt}%
\SaveVerb[aftersave={%
\UseVerb{Vitem}
\newcommand*\optstar{% % optional star
\meta{\ensuremath{*}}\xspace}
\DefineShortVerb{\|}
-
+\newcommand\R{\mathbf{R}}
\setlength{\fboxsep}{2pt}
\fvset{%
codes={\catcode`\«\active \catcode`\×\active },
defineactive={\makefancyog\makefancytimes},
- formatcom=\color{red},
+ formatcom=\color{darkred},
frame=single
}
% rendre «...» équivalent à \meta{...}
breaklines=true,
breakindent=30pt,
defaultdialect=[LaTeX]TeX,
- morekeywords={buildMeshBW,buildMeshBWinc,drawPointsMesh,
- drawPointsMeshinc, meshAddPointBW, meshAddPointBWinc}% frame=tb
+ morekeywords={buildMeshBW,buildMeshBWinc,drawPointsMesh,buildVoronoiBW,buildVoronoiBWinc,
+ drawPointsMeshinc, meshAddPointBW,
+ meshAddPointBWinc,drawGmsh,drawGmshinc,gmshVoronoi,gmshVoronoiinc}% frame=tb
}
\lstdefinelanguage{lua}
\newcommand\luamesh{\Verb+luamesh+\xspace}
\newenvironment{optionsenum}[1][]
-{\begin{description}[font=\color{red}\ttfamily]}
+{\begin{description}[font=\color{darkred}\ttfamily]}
{\end{description}}
\newenvironment{warning}{%
}%
{\end{tcolorbox}\medskip}
-
-
+\lstset{moredelim=*[s][\color{red}\rmfamily\itshape]{<}{>}}
+\lstset{moredelim=*[s][\color{blue}\rmfamily\itshape]{<<}{>>}}
+\usepackage[colorlinks=true]{hyperref}
\begin{document}
%% === Page de garde ===================================================
\thispagestyle{empty}
}
\vfill
\begin{center}
- Version 0.1, 25 novembre 2016\\
+ Version 0.2, 29 novembre 2016\\
\url{http://melusine.eu.org/syracuse/G/delaunay/}
\end{center}
%% == Page de garde ====================================================
\maketitle
\begin{abstract}
- The package \Verb|luamesh| allows to compute and draw 2D triangulation
- of Delaunay. The algorithm is written with lua, and depending of the
- choice of the ``engine'', the draw is done by MetaPost (with
+ The package \Verb|luamesh| allows to compute and draw 2D Delaunay
+ triangulation. The algorithm is written with lua, and depending on the
+ choice of the ``engine'', the drawing is done by MetaPost (with
\Verb|luamplib|) or by \Verb|tikz|.
The Delaunay triangulation algorithm is the Bowyer and Watson
algorithm. Several macros are provided to draw the global mesh, the
- set of points, a particular step of the algorithm.
+ set of points, or a particular step of the algorithm.
\end{abstract}
I would like to thank Jean-Michel Sarlat, who hosts the development
\begin{center}
\url{https://melusine.eu.org/syracuse/G/delaunay/}
\end{center}
-Then, I would like to thank the first user, an intensive
+I would also like to thank the first user, an intensive
\emph{test} user, and a very kind English corrector: Nicole Spillane.
+\tableofcontents
+
\section{Installation}
Of course, you can just put the two files \Verb+luamesh.lua+ and
-\Verb+luamesh.sty+ in the working directory, but it is not
+\Verb+luamesh.sty+ in the working directory but this is not
recommended.
mkdir ~/texmf
\end{commandshell}
-Then we have to files to place in the correct directories. First, the
-\Verb+luamesh.sty+ file must be in the directory:
+Then place the files in the correct directories. The
+\Verb+luamesh.sty+ file must be in directory:
\begin{center}
\Verb+~/texmf/tex/latex/luamesh/+
\end{center}
-and secondly, the \Verb+luamesh.lua+ must be in the directory:
+and the \Verb+luamesh.lua+ file must be in directory:
\begin{center}
\Verb+~/texmf/scripts/luamesh/+
\end{center}
\subsection{With Mik\TeX{} and Windows}
-We do not know these two systems, so we refer to the
+As these two systems are unknown to the contributor, we refer to the
documentation for integrating local additions to Mik\TeX:
\begin{center}
\url{http://docs.miktex.org/manual/localadditions.html}
\subsection{Dependencies}
-This package is built upon two main packages to draw the
+This package is built upon two main existing packages that one used to
+draw the
triangulations :
\begin{enumerate}
\item \Verb+luamplib+ to use MetaPost via the \luatex library
\Verb+mplib+;
-\item and \Verb+tikz+.
+\item \Verb+tikz+.
\end{enumerate}
We will see how to choose between these two \emph{drawing engines}.
-
Moreover, the following packages are necessary:
\begin{enumerate}
\item \Verb+xkeyval+ to manage the optional arguments;
-\item \Verb+xcolor+ to use colors (needed by \Verb+luamplib+);
-\item \Verb+ifthen+ to help the programming with \TeX.
+\item \Verb+xcolor+ to use colors (required by \Verb+luamplib+);
+\item \Verb+ifthen+ to help programming with \TeX.
\end{enumerate}
\section{The Basic Macros}
-Let us recall that this package provides macros to draw two
+This package provides macros to draw two
dimensional triangulations (or meshes).
\subsection{Draw a Complete Mesh}\label{sec:buildMesh}
\commande|\buildMeshBW[«options»]{«list of points» or «file name»}|\medskip
-This macro produce the Delaunay triangulation (using the Bowyer and
+This macro produces the Delaunay triangulation (using the Bowyer and
Watson algorithm) of the given \meta{list of points}. The list of
points must be given in the following way :
\begin{center}
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 point in the argument, or
- a file, containing, line by line (2 columns), the points. Such a
+ use either the previously described set of points in the argument, or
+ a file containing the points line by line (in 2 columns). Such a
file looks like :
\begin{verbatim}
x1 y1
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
+ points added to form the \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})$.} and the corresponding
- triangulation. By default, these triangles are removed at the end of
+ $(x_{\max},y_{\max})$, and $(x_{\min},y_{\max})$. It is used by
+ the algorithm and will be computed in any case.} and the
+ triangles attached. By default, these triangles are removed at the end of
the algorithm.
\item[color = \meta{value} (default: black):] The color of the
drawing.
drawing for the elements (points and triangles) belonging to the
bounding box.
\item[print = none (default) \textme{or} points:] To label the vertices of the
- triangulations with an adding dot.
+ triangulation. This also adds a \emph{dot} at each vertex.
\item[meshpoint = \meta{value} (default: P):] The letter(s) used to
- label the vertices of the triangulation. It is include in the math
+ label the vertices of the triangulation. It is included in the math
mode delimiters \Verb+$...$+. The bounding box points are labeled
- with a star exponent, and numbered from 1 to 4.
+ 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, it is \Verb+tikz+ the \textit{drawing
+ 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 draw (the same for the two
- axis). It must contain the unit of length (cm,
+ 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}
\end{Exemple}
\begin{warning}
-The drawing engine is not here very relevant. But it is useful to
-understand how the drawing is made. However, the engine will make sens
-for the so called \emph{inc} macros (section~\ref{sec:inc}), where we
-will be allowed to add code before and after the generated one by
+The drawing engine is not very relevant here, although it is useful to
+understand how the drawing is produced. However, the engine will be
+relevant to
+the so called \emph{inc} macros (section~\ref{sec:inc}) for adding
+code before and after the one generated by
\luamesh.
\end{warning}
\commande|\drawPointsMesh[«options»]{«list of points» or «file name»}|\medskip
-With the \Verb+\drawPointsMesh+, we plot the set of the points from
-which the Browyer and Watson algorithm compute the triangulation.
+With the \Verb+\drawPointsMesh+, we plot the set of (user chosen) points from
+which the Bowyer and Watson algorithm computes the triangulation.
-The use of this macro is quite similar to the
+The use of this macro is quite similar to
\Verb+\buildMeshBW+. Here is an example of the basic uses.
\begin{Exemple}
\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)}
\subsubsection{The Options}
-There are several options (exactly the same that for the
-\Verb+\buildMeshBW+)to customize the drawing.
+There are several options (exactly the same as for the
+\Verb+\buildMeshBW+) to customize the drawing.
\begin{optionsenum}
\item[mode = int (default) \textme{or} ext:] this option allows to
- use either the previously described set of point in the argument, or
- a file, containing, line by line (2 columns), the points. Such a
+ use either the previously described set of points as the argument, or
+ a file containing the points line by line (in 2 columns). Such a
file looks like :
\begin{verbatim}
x1 y1
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} and the corresponding
- triangulation. By default, these triangles are removed at the end of
+ points added to form the \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
+ triangles attached. By default, these triangles are removed at the end of
the algorithm. \emph{Here, because we plot only the vertices of the
- mesh, there is no triangles, but only dots.}
+ mesh, there are no triangles, only dots.}
\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[print = none (default) \textme{or} points:] To label the vertices of the
- triangulations with an adding dot. Without label, there is a dot.
+ triangulation. This also adds a \emph{dot} at each vertex. With no
+ label, the dot remains.
\item[meshpoint = \meta{value} (default: P):] The letter(s) used to
- label the vertices of the triangulation. It is include in the math
+ label the vertices of the triangulation. This is included in the math
mode delimiters \Verb+$...$+. The bounding box points are labeled
- with a star exponent, and numbered from 1 to 4.
+ 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, it is \Verb+tikz+ the \textit{drawing
+ 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 draw (the same for the two
- axis). It must contain the unit of length (cm,
+ 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}
With the same external mesh point file presented in
\commande|\meshAddPointBW[«options»]{«list of points» or «file name»}{«point» or «number of line»}|\medskip
-This command allows to plot the different step of the addition of a
-point in a Delaunay triangulation, using the Bowyer and Watson
+This command allows to plot the steps within the addition of a
+point in a Delaunay triangulation by the Bowyer and Watson
algorithm.
-This macro produce the Delaunay triangulation (using the Bowyer and
+This macro produces the Delaunay triangulation (using the Bowyer and
Watson algorithm) of the given \meta{list of points} and shows a step
of the algorithm when the \meta{point} is added. The list of
points must be given in the following way:
and \meta{number of line} will be explained in the option
description.
-One can use the macro as fallow:
+One can use the macro as follows:
\begin{Exemple}
\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)}
\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)}
\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)}
\end{Exemple}
-The default value for \Verb+step+ is \Verb+badtriangles+. The first
-line is then equivalent to
+The default value for \Verb+step+ is
+\Verb+badtriangles+. Consequently, the first
+line is equivalent to
\begin{latexcode}
\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)}
\end{latexcode}
\Verb+\buildMeshBW+) to customize the drawing.
\begin{optionsenum}
\item[mode = int (default) \textme{or} ext:] this option allows to
- use either the previously described set of point in the argument
- number one, or
- a file, containing, line by line (2 columns), the points. Such a
+ use either the previously described set of points as the argument, or
+ a file containing the points line by line (in 2 columns). Such a
file looks like :
\begin{verbatim}
x1 y1
...
xn yn
\end{verbatim}
-For the second argument of the macro, if we are in the
+For the second argument of the macro, if we are in
\Verb+mode = ext+, the argument must be the \emph{line number} of the file
-corresponding to the point we want to add. The algorithm will stop the
-line before to build the initial triangulation for which it will add
-the point corresponding to the line. The other lines of the file are
+corresponding to the point we want to add. The algorithm will stop at the
+previous line to build the initial triangulation and proceed to add
+the point corresponding to the line requested. The subsequent lines in
+the file are
ignored.
\item[bbox = none (default) \textme{or} show:] this option allows to draw the
- added points to form a \emph{bounding box} and the corresponding
- triangulation. By default, these triangles are removed at the end of
+ added points that form the \emph{bounding box} and the triangles
+ attached. Although they are always computed, by default, these
+ triangles are removed at the end of
the algorithm.
\item[color = \meta{value} (default: black):] The color of the
drawing.
bounding box.
\item[colorNew = \meta{value} (default: red):] The color of the
drawing of the ``new'' elements which are the point to add, the
- polygon of the cavity, and the new triangles.
+ polygon delimiting the cavity, and the new triangles.
\item[colorBack = \meta{value} (default: black!20):] The color for the
filling of the region concerned by the addition of the new point.
\item[colorCircle = \meta{value} (default: green):] The color for
- circoncircle of the triangles containing the point to add.
+ the circumcircle of the triangles containing the point to add.
\item[meshpoint = \meta{value} (default: P):] The letter(s) used to
- label the vertices of the triangulation. It is include in the math
+ label the vertices of the triangulation. It is included in the math
mode delimiters \Verb+$...$+. The bounding box points are labeled
- with a star exponent, and numbered from 1 to 4.
+ with numbers 1 to 4 and with a star exponent.
\item[step = badtriangles (default) \textme{or} cavity \textme{or}
newtriangles:] To choose the step we want to draw, corresponding to
the steps of the Bowyer and Watson algorithm.
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, it is \Verb+tikz+ the \textit{drawing
+ the picture. With this option, \Verb+tikz+ is the \textit{drawing
engine}.
\item[scale = \meta{value} (default: 1cm):] The scale option defines
- the scale at which the picture is draw (the same for the two
+ the scale at which the picture is drawn (the same for both
axis). It must contain the unit of length (cm,
pt, etc.).
\end{optionsenum}
-Here is an example of customization of the drawing. First, recall that
+Here is an example of customizing the drawing. First, recall that
the external file \Verb+mesh.txt+ is:
\begin{verbatim}
0.3 0.3
(MetaPost or \Verb+tikz+, depending of the drawing engine) before and
after the code generated by \luamesh.
-The three macros are:
+The three macros are:\medskip
+
\commande|\buildMeshBWinc[«options»]{«list of points» or «file name»}{«code before»}{«code after»}|\medskip
We consider the case where the drawing engine is MetaPost (through the
\Verb+luamplib+ package).
+The feature is described for the \Verb+\buildMeshBWinc+ but the mechanism
+and possibilities are exactly the same for all three macros.
+
+When we use the MetaPost drawing engine, the macros previously
+described produce a code of the form
+\begin{latexcode}
+\begin{luamplib}
+ u:=<scale>;
+ beginfig(0);
+ <code for the drawing>
+ endfig;
+\end{luamplib}
+\end{latexcode}
+
+Then, the arguments \meta{code before} and \meta{code after} are
+inserted as follows:
+\begin{latexcode}
+\begin{luamplib}
+ u:=<scale>;
+ <<code before>>
+ <code for the drawing>
+ <<code after>>
+\end{luamplib}
+\end{latexcode}
+\begin{warning}
+With the \emph{inc} macros, the user has to add the \Verb+beginfig();+
+and \Verb+endfig;+ commands to produce a picture. Indeed, this allows
+to use the \Verb+\everymplib+ command from the \Verb+\luamplib+ package.
+\end{warning}
+
+\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
+\Verb+\buildMeshBWinc+ and \Verb+\drawPointsMeshinc+,
+\Verb+\luameshmpcolor+,
+and \Verb+\luameshmpcolorBbox+ have been defined.
+For the macro \Verb+\meshAddPointBWinc+ three additional
+colors are present: \Verb+\luameshmpcolorBack+,
+\Verb+\luameshmpcolorNew+, and
+\Verb+\luameshmpcolorCircle+. Of course, MetaPost
+colors can be defined as well. Finally, the \Verb+luamplib+ mechanism
+\Verb+\mpcolor+ is also available.
+
+\subsubsection{The Mesh Points}
+
+At the beginning of the automatically generated code, a list of
+MetaPost \Verb+pair+s are defined corresponding to all the vertices in
+the mesh (when the option \Verb+bbox=show+, the last 4 points are the
+\emph{bounding box points}). The points are available with the
+\Verb+MeshPoints[]+ table of variables. The \Verb+pair+s ($\R^{2}$ points)
+\Verb+MeshPoints[i]+ are
+defined using the unit length \Verb+u+.
+
+\subsubsection{Examples}
+
+Here is three examples for the different macros.
+\begin{Exemple}
+\drawPointsMeshinc[
+color = blue!50,
+print = points,
+meshpoint = x,
+scale=0.8cm,
+]{(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)}%
+{% code before
+ beginfig(0);
+}%
+{% code after
+ label(btex Mesh $\mathbb{T}$ etex, (0,2u)) withcolor \luameshmpcolor;
+ endfig;
+}
+\buildMeshBWinc[%
+bbox = show,
+color = red,
+colorBbox = blue!30,
+print = points,
+meshpoint = x,
+scale=0.8cm
+]{(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)}%
+{% code before
+ beginfig(0);
+}
+{% code after
+ drawdblarrow MeshPoints[3] -- MeshPoints[9] withpen pencircle scaled 1pt
+ withcolor (0.3,0.7,0.2);
+ endfig;
+}
+\meshAddPointBWinc[
+meshpoint = \alpha,
+newpoint = y,
+colorBack=red!10,
+colorNew = green!50!red,
+colorCircle = blue,
+colorBbox = black!20,
+bbox = show,
+scale=0.8cm,
+step=badtriangles]
+{(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)}%
+{%code before
+ picture drawing;
+ drawing := image(
+}{%code after
+ );
+ beginfig(0);
+ fill MeshPoints[7]--MeshPoints[8]--MeshPoints[9]--MeshPoints[10]--cycle
+ withcolor \mpcolor{blue!10};
+ draw drawing;
+ endfig;
+}
+\end{Exemple}
+\begin{warning}
+ The variables \Verb+MeshPoints[]+ are not defined for the argument
+ corresponding to the code placed \textbf{before} the code generated by
+ \luamesh. Hence, to use such variables, we have to define a
+ \Verb+picture+ as shown in the third example above.
+\end{warning}
\subsection{With TikZ}
-\section{Gallery of Examples}
+If we have chosen \Verb+tikz+ as the drawing engine, the added code
+will be written in \Verb+tikz+. In that case, the two arguments
+\meta{code before} and \meta{code after} will be inserted as follows:
+\begin{latexcode}
+\noindent
+\begin{tikzpicture}[x=<scale>,y=<scale>]
+ <<code before>>
+ <generated code>
+ <<code after>>
+\end{tikzpicture}
+\end{latexcode}
+
+Because the engine is \Verb+tikz+ their is no issue with colors, the
+\LaTeX{} colors (e.g.: \Verb+xcolor+) can be used directly.
+
+\subsubsection{The Mesh Points}
+
+The mesh points are defined here as \Verb+tikz+
+\Verb+\coordinate+ and named as follows
+\begin{latexcode}
+\coordinate (MeshPoints1) at (...,...);
+\coordinate (MeshPoints2) at (...,...);
+\coordinate (MeshPoints3) at (...,...);
+%etc.
+\end{latexcode}
+
+Once again these coordinates are not yet defined to be used in the
+code given by \meta{code
+ before} argument.
+
+\subsubsection{Examples}
+
+\begin{Exemple}
+ \drawPointsMeshinc[
+ tikz,
+ color = blue!50,
+ print = points,
+ meshpoint = x,
+ scale=0.8cm,
+ ]{(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)}%
+ {% code before
+ }%
+ {% code after
+ \node[color = blue!50] at (0,2) {Mesh $\mathbb{T}$} ;
+ }
+ \buildMeshBWinc[%
+ tikz,
+ bbox = show,
+ color = red,
+ colorBbox = blue!30,
+ print = points,
+ meshpoint = x,
+ scale=0.8cm
+ ]{(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)}%
+ {% code before
+ }
+ {% code after
+ \draw[<->,thick, color=green] (MeshPoints3) -- (MeshPoints9);
+ }
+\end{Exemple}
+
+\section{Voronoï Diagrams}
+
+Another interesting feature of b Delaunay triangulation is that its
+\emph{dual} is the so-called Voronoï diagram. More precisely, for a
+finite set of
+points $\{p_{1},\ldots, p_{n}\}$ in the Euclidean plane, the Voronoï
+cell $R_{k}$ corresponding to $p_{k}$ is the set of
+all points in the Euclidean plane $\R^{2}$ 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 Voronoï diagram 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 the points line by line (in 2 columns). 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
+ Voronoï diagram.
+\item[print = none (default) \textme{or} points:] To label the
+ vertices in 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 at the circumcircle centers which are the nodes of
+ the Voronoï diagram.
+\item[meshpoint = \meta{value} (default: P):] The letter(s) used to
+ label the vertices of the triangulation. This is included in the math
+ mode delimiters \Verb+$...$+. The bounding box points are labelled
+ 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 Voronoï diagram. This 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.).
+\item[delaunay = none (default) \textme{or} show:] This option
+ allows to draw the Delaunay triangulation under the Voronoï diagram.
+\item[styleDelaunay = none (default) \textme{or} dashed:] This option
+ allows to draw the Delaunay triangulation in dashed lines.
+\item[styleVoronoi = none (default) \textme{or} dashed:] This option
+ allows to draw the Voronoï edges in dashed lines.
+\end{optionsenum}
+
+\begin{Exemple}
+ \buildVoronoiBW[tikz,delaunay=show,styleDelaunay=dashed]
+ {(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 \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
+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 they 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 an 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 draws the triangulation produced by Gmsh and exported in the
+\Verb+msh+ format. The argument is the name of the file to be 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 some previous macros, when
+ \Verb+print=none+ a \emph{dot} is produced at each vertex of the
+ set of points and at the circumcircle centers (these are the nodes of
+ the Voronoï diagram).
+\item[meshpoint = \meta{value} (default: P):] The letter(s) used to
+ label the vertices of the triangulation. This 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 Voronoï Diagrams}
+
+Because Gmsh generates Delaunay triangulations, we can plot the associated
+Voronoï diagram. This is done by the following macro:\bigskip
+
+\commande|\gmshVoronoi[«options»]{«file name»}|\medskip
+
+\begin{Exemple}
+ \gmshVoronoi{maillage.msh}
+\end{Exemple}
+
+
+\subsection{The Options}\label{sec:voronoiOptions}
+
+
+There are several options to customize the drawing.
+\begin{optionsenum}
+\item[color = \meta{value} (default: black):] The color of the
+ drawing.
+\item[colorVoronoi = \meta{value} (default: black):] The color of the
+ drawing for the elements (points and polygons) belonging to the
+ Voronoï diagram.
+\item[print = none (default) \textme{or} points:] To label the vertices of the
+ triangulation. Contrary to some previous macros, when
+ \Verb+print=none+, a \emph{dot} is produced at each vertex of the
+ set of points and at the circumcircle centers (these are the nodes of
+ the Voronoï 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 Voronoï diagram. This 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.).
+\item[delaunay = none (default) \textme{or} show] This option
+ allows to draw the Delaunay triangulation overlapped with the
+ Voronoï diagram.
+\item[styleDelaunay = none (default) \textme{or} dashed] This option
+ allows to draw the Delaunay triangulation in dashed lines.
+\item[styleVoronoi = none (default) \textme{or} dashed] This option
+ allows to draw the Voronoï edges in dashed lines.
+\end{optionsenum}
+
+\begin{Exemple}
+ \gmshVoronoi[tikz,scale=1.5cm, delaunay=show,styleVoronoi=dashed]{maillage.msh}
+\end{Exemple}
+
+
+\subsection{The \emph{inc} variants}
+
+Once again, there exist \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}