1 % luamesh: compute and draw meshes with lua, luamplib and tikz
3 % Originally written by Maxime Chupin <mc@melusine.eu.org>,
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.
10 \documentclass{lltxdoc
}
11 \usepackage{tcolorbox
}
14 \usepackage[tikz
]{bclogo
}
16 \title{\Verb+luamesh+: compute and draw meshes with
\lualatex}
17 \author{Maxime Chupin
\email{mc@melusine.eu.org
}}
20 \newcommand*
\commande{\noindent\hspace{-
30pt
}%
21 \SaveVerb[aftersave=
{%
26 \newcommand*
\textme[1]{\textcolor{black
}{\rmfamily\textit{#1}}}
27 \newcommand*
\meta[1]{% % meta
28 \textme{\ensuremath{\langle}#1\ensuremath{\rangle}}}
29 \newcommand*
\optstar{% % optional star
30 \meta{\ensuremath{*
}}\xspace}
33 \setlength{\fboxsep}{2pt
}
35 codes=
{\catcode`\«
\active \catcode`\×
\active },
36 defineactive=
{\makefancyog\makefancytimes},
37 formatcom=
\color{red
},
40 % rendre «...» équivalent à \meta{...}
42 \newcommandx\makefancyog[0][addprefix=
\global]{%
43 \def«#
#1»
{\meta{#
#1}}}}
44 % rendre × équivalent à \optstar
46 \newcommandx\makefancytimes[0][addprefix=
\global]{%
50 \tcbuselibrary{listings,breakable
}
52 \definecolor{vert
}{rgb
}{0.1,
0.4,
0.1}
53 \definecolor{bleu
}{rgb
}{0.1,
0.1,
0.4}
55 numberstyle=
\footnotesize\color{vert
},
56 keywordstyle=
\ttfamily\bfseries\color{blue
},
57 basicstyle=
\ttfamily\footnotesize,
58 commentstyle=
\itshape\color{vert
},
59 stringstyle=
\ttfamily,
60 showstringspaces=false,
64 defaultdialect=
[LaTeX
]TeX,
68 \lstdefinelanguage{lua
}
69 {morekeywords=
{for,end,function,do,if,else,elseif,then,
70 tex.print,tex.sprint,io.read,io.open,string.find,string.explode,require
},
72 morecomment=
[s
]{--
[[}{]]},
76 \newtcblisting{Exemple
}{%
77 arc=
0pt,outer arc=
0pt,
79 colframe=red!
75!black,
81 boxsep=
0pt,left=
5pt,right=
5pt,top=
5pt,bottom=
5pt, bottomtitle =
83 boxrule=
0pt,bottomrule=
0.5pt,toprule=
0.5pt, toprule at break =
84 0pt, bottomrule at break =
0pt,
85 listing options=
{breaklines
},
88 \newtcblisting{commandshell
}{colback=black,colupper=white,colframe=black,
90 listing only,boxsep=
0pt,listing
91 options=
{style=tcblatex,language=sh
},
92 every listing line=
{\textcolor{red
}{\small\ttfamily\bfseries user \$>
}}}
94 \newtcblisting{latexcode
}{
96 listing only,boxsep=
0pt,listing
97 options=
{style=tcblatex
}}
100 \newcommand\luamesh{\Verb+luamesh+
\xspace}
102 \newenvironment{optionsenum
}[1][]
103 {\begin{description
}[font=
\color{red
}\ttfamily]}
106 \newenvironment{warning
}{%
107 \setlength{\logowidth}{24pt
}
109 arc=
0pt,outer arc=
0pt,colback=gray!
10!white,colframe=gray!
60!white,
110 boxsep=
0pt,left=
5pt,right=
5pt,top=
5pt,bottom=
5pt, bottomtitle =
3pt, toptitle=
3pt,
111 boxrule=
0pt,bottomrule=
0.5pt,toprule=
0.5pt
}
114 \begin{wrapfigure
}[2]{L
}{17pt
}%
121 {\end{tcolorbox
}\medskip}
126 %% === Page de garde ===================================================
127 \thispagestyle{empty
}
128 \begin{tikzpicture
}[remember picture, overlay
]
129 \node[below right, shift=
{(-
4pt,
4pt)
}] at (current page.north west)
{%
130 \includegraphics{fond.pdf
}%
135 \includegraphics{luamesh
}\\
136 {\large compute and draw meshes with
\lualatex}\\
[1cm
]
137 \parbox{0.6\textwidth}{
139 mode=ext,step=badtriangles,
140 colorNew =green!
20!red,
148 \parbox{0.4\textwidth}{\Large\raggedleft
149 \textbf{Contributor
}\\
150 Maxime
\textsc{Chupin
}
154 Version
0.1,
25 novembre
2016\\
155 \url{http://melusine.eu.org/syracuse/G/delaunay/
}
157 %% == Page de garde ====================================================
163 The package
\Verb|luamesh| allows to compute and draw
2D triangulation
164 of Delaunay. The algorithm is written with lua, and depending of the
165 choice of the ``engine'', the draw is done by MetaPost (with
166 \Verb|luamplib|) or by
\Verb|tikz|.
168 The Delaunay triangulation algorithm is the Bowyer and Watson
169 algorithm. Several macros are provided to draw the global mesh, the
170 set of points, a particular step of the algorithm.
173 \section{Installation
}
175 \subsection{With Linux
}
177 To install
\luamesh with
\TeX live, you have to create the local
178 \Verb+texmf+ directory in your
\Verb+home+.
184 Then we have to files to place in the correct directories. First, the
185 \Verb+luamesh.sty+ file must be in the directory:
187 \Verb+~/texmf/tex/latex/luamesh/+
189 and secondly, the
\Verb+luamesh.lua+ must be in the directory:
191 \Verb+~/texmf/scripts/luamesh/+
194 Once you have done this,
\luamesh can be included in your
document
200 \subsection{Dependencies
}
202 This package is built upon two main packages to draw the
205 \item \Verb+luamplib+ to use MetaPost via the
\luatex library
207 \item or
\Verb+tikz+.
209 We will see how to choose between these two
\emph{drawing engines
}.
211 Moreover, the following packages are necessary:
213 \item \Verb+xkeyval+ to manage the optional arguments;
214 \item \Verb+xcolor+ to use colors (needed by
\Verb+luamplib+);
215 \item \Verb+ifthen+ to help the programming with
\TeX.
219 \section{The Basic Macros
}
221 If you want to use this package, you must compile your
document with
225 lualatex mylatexfile.tex
228 Let us recall that this package provides macros to draw two
229 dimensional triangulations (or meshes).
231 \subsection{Draw a Complete Mesh
}
233 \commande|
\buildMeshBW[«options»
]{«list of points» or «file name»
}|
\medskip
235 This macro produce the Delaunay triangulation (using the Bowyer and
236 Watson algorithm) of the given
\meta{list of points
}. The list of
237 points must be given in the following way :
239 \verb+(x1,y1);(x2,y2);(x3,y3);...;(xn,yn)+
243 \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)
}
246 \subsubsection{The Options
}
248 There are several options to customize the drawing.
250 \item[mode = int (default) or ext:
] this option allows to
251 use either the previously described set of point in the argument, or
252 a file, containing, line by line (
2 columns), the points. Such a
261 \item[bbox = none (default) or show:
] this option allows to draw the
262 added points to form a
\emph{bounding box
}\footnote{The bounding
263 box is defined by four points place at
15\% around the box
264 defined by $(x_
{\min},y_
{\min})$, $(x_
{\min},y_
{\max})$,
265 $(x_
{\max},y_
{\max})$, and $(x_
{\min},y_
{\max})$.
} and the corresponding
266 triangulation. By default, these triangles are removed at the end of
268 \item[color =
\meta{value
} (default: black):
] The
color of the
270 \item[colorBbox =
\meta{value
} (default: black):
] The
color of the
271 drawing for the elements (points and triangles) belonging to the
273 \item[print = none (default) or points:
] To label the vertices of the
274 triangulations with an adding dot.
275 \item[meshpoint =
\meta{value
} (default: P):
] The letter(s) used to
276 label the vertices of the triangulation. It is include in the math
277 mode delimiters
\Verb+$...$+. The bounding box points are labeled
278 with a star exponent, and numbered from
1 to
4.
279 \item[tikz (boolean, default:false):
] By default, this boolean is set
280 to
\Verb+false+, and MetaPost (with
\Verb+luamplib+) is used to draw
281 the picture. With this option, it is
\Verb+tikz+ the
\textit{drawing
283 \item[scale =
\meta{value
} (default:
1cm):
] The scale option defines
284 the scale at which the picture is draw (the same for the two
285 axis). It must contain the unit of length (cm,
289 To illustrate the options, let us show you an example. We consider a
290 file
\Verb+mesh.txt+:
314 The drawing engine is not here very relevant. But it is useful to
315 understand how the drawing is made. However, the engine will make sens
316 for the so called
\emph{inc
} macros (section~
\ref{sec:inc
}), where we
317 will be allowed to add code before and after the generated one by
321 \subsection{Draw the Set of Points
}
323 \commande|
\drawPointsMesh[«options»
]{«list of points» or «file name»
}|
326 \subsection{Draw a Step of the Bowyer and Watson Algorithm
}
328 \commande|
\meshAddPointBW[«options»
]{«list of points» or «file name»
}{«point» or «number of line»
}|
331 \section{The
\emph{inc
} Macros
}\label{sec:inc
}
333 \section{Gallery of Examples
}
341 %%% ispell-local-dictionary: "american"