\BOOKMARK [3][-]{subsubsection.2.2.1}{The Options}{subsection.2.2}% 10
\BOOKMARK [2][-]{subsection.2.3}{Draw a Step of the Bowyer and Watson Algorithm}{section.2}% 11
\BOOKMARK [3][-]{subsubsection.2.3.1}{The Options}{subsection.2.3}% 12
-\BOOKMARK [1][-]{section.3}{The inc Macros}{}% 13
-\BOOKMARK [2][-]{subsection.3.1}{With MetaPost}{section.3}% 14
-\BOOKMARK [3][-]{subsubsection.3.1.1}{The LaTeX Colors Inside the MetaPost Code}{subsection.3.1}% 15
-\BOOKMARK [3][-]{subsubsection.3.1.2}{The Mesh Points}{subsection.3.1}% 16
-\BOOKMARK [3][-]{subsubsection.3.1.3}{Examples}{subsection.3.1}% 17
-\BOOKMARK [2][-]{subsection.3.2}{With TikZ}{section.3}% 18
-\BOOKMARK [3][-]{subsubsection.3.2.1}{The Mesh Points}{subsection.3.2}% 19
-\BOOKMARK [3][-]{subsubsection.3.2.2}{Examples}{subsection.3.2}% 20
-\BOOKMARK [1][-]{section.4}{Voronoï Diagrams}{}% 21
-\BOOKMARK [2][-]{subsection.4.1}{The Options}{section.4}% 22
-\BOOKMARK [2][-]{subsection.4.2}{The inc variant}{section.4}% 23
-\BOOKMARK [1][-]{section.5}{With Gmsh}{}% 24
-\BOOKMARK [2][-]{subsection.5.1}{Gmsh and Voronoï Diagrams}{section.5}% 25
-\BOOKMARK [2][-]{subsection.5.2}{The Options}{section.5}% 26
-\BOOKMARK [2][-]{subsection.5.3}{The inc variants}{section.5}% 27
-\BOOKMARK [1][-]{section.6}{Gallery}{}% 28
-\BOOKMARK [2][-]{subsection.6.1}{With Animate}{section.6}% 29
+\BOOKMARK [2][-]{subsection.2.4}{Mesh a Polygon}{section.2}% 13
+\BOOKMARK [3][-]{subsubsection.2.4.1}{The Options}{subsection.2.4}% 14
+\BOOKMARK [1][-]{section.3}{The inc Macros}{}% 15
+\BOOKMARK [2][-]{subsection.3.1}{With MetaPost}{section.3}% 16
+\BOOKMARK [3][-]{subsubsection.3.1.1}{The LaTeX Colors Inside the MetaPost Code}{subsection.3.1}% 17
+\BOOKMARK [3][-]{subsubsection.3.1.2}{The Mesh Points}{subsection.3.1}% 18
+\BOOKMARK [3][-]{subsubsection.3.1.3}{Examples}{subsection.3.1}% 19
+\BOOKMARK [2][-]{subsection.3.2}{With TikZ}{section.3}% 20
+\BOOKMARK [3][-]{subsubsection.3.2.1}{The Mesh Points}{subsection.3.2}% 21
+\BOOKMARK [3][-]{subsubsection.3.2.2}{Examples}{subsection.3.2}% 22
+\BOOKMARK [1][-]{section.4}{Voronoï Diagrams}{}% 23
+\BOOKMARK [2][-]{subsection.4.1}{The Options}{section.4}% 24
+\BOOKMARK [2][-]{subsection.4.2}{The inc variant}{section.4}% 25
+\BOOKMARK [1][-]{section.5}{With Gmsh}{}% 26
+\BOOKMARK [2][-]{subsection.5.1}{Gmsh and Voronoï Diagrams}{section.5}% 27
+\BOOKMARK [2][-]{subsection.5.2}{The Options}{section.5}% 28
+\BOOKMARK [2][-]{subsection.5.3}{The inc variants}{section.5}% 29
+\BOOKMARK [1][-]{section.6}{Gallery}{}% 30
+\BOOKMARK [2][-]{subsection.6.1}{With Animate}{section.6}% 31
}
\vfill
\begin{center}
- Version 0.2, 29 novembre 2016\\
+ Version 0.5, 2017, February, 9th \\
\url{http://melusine.eu.org/syracuse/G/delaunay/}
\end{center}
%% == Page de garde ====================================================
\begin{center}
\Verb+~/texmf/tex/latex/luamesh/+
\end{center}
-and the \Verb+luamesh.lua+ file must be in directory:
+and the \Verb+luamesh.lua+, the \Verb+luamesh-tex.lua+ and the
+\Verb-luamesh-polygon.lua+ files must be in directory:
\begin{center}
\Verb+~/texmf/scripts/luamesh/+
\end{center}
\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
- triangulation. This also adds a \emph{dot} at each vertex.
+\item[print = none (default) \textme{or} points \textme{or}
+ dotpoints:] The \Verb+point+ value allows to label the vertices of the
+ triangulation. This also adds a \emph{dot} at each vertex. The
+ \Verb+dotpoints+ value only add a dot without the labeling.
\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
{mesh.txt}{6}
\end{Exemple}
+\subsection{Mesh a Polygon}
+
+\commande|\meshPolygon[«options»]{«list of points» or «file name»}|\medskip
+
+
+With \luamesh, it is possible to mesh an object giving the
+\emph{border}, \emph{i.e.}, one closed polygon. The polygon is given
+as a list of points as above:
+\begin{center}
+ \verb+(x1,y1);(x2,y2);(x3,y3);...;(xn,yn)+
+\end{center}
+Once again we can also give a file of points using the \Verb+mode+
+option.
+
+This command allows to plot the steps within the building of a complete
+mesh. The followed method is, given a parameter $h$:
+\begin{itemize}
+\item to build a squared grid of points with a unit distance equal to
+ $h$;
+\item to keep the grid points inside the polygon;
+\item if necessary to add points along the polygon to respect the
+ distance parameter;
+\item to mesh the complete set of points (using the Bowyer and Watson
+ algorithm).
+\end{itemize}
+
+One can use the macro as follows:
+\begin{Exemple}
+ \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)}
+ \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)}
+ \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)}
+ \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)}
+\end{Exemple}
+
+Note that if the points of the grid are too closed to the points of
+the refined boundary, they are ejected.
+
+\subsubsection{The Options}
+
+There are several options (some of them are the same as for
+\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 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
+x2 y2
+x3 y3
+...
+xn yn
+\end{verbatim}
+\item[h = \meta{value} (default: 0.2):] The mesh parameter, it is the
+ unit distance for the grid. If necessary, the boundary is refined to
+ get points which respect the distance constrain.
+\item[color = \meta{value} (default: black):] The color of the
+ drawing (the grid point and the mesh).
+\item[colorPolygon = \meta{value} (default: red):] The color of the
+ drawing for the boundary polygon.
+\item[print = none (default) \textme{or} points \textme{or}
+ dotpoints:] The \Verb+point+ value allows to label the vertices of the
+ triangulation. This also adds a \emph{dot} at each vertex. The
+ \Verb+dotpoints+ value only add a dot without the labeling.
+\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+$...$+.
+\item[step = polyqon \textme{or} grid \textme{or}
+ points \textme{or} mesh (default):] To choose the step we want to draw,
+ see the description above.
+\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+ is 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
+ axis). It must contain the unit of length (cm,
+ pt, etc.).
+\end{optionsenum}
+
+Here is an example of customizing the drawing.
+\begin{Exemple}
+ \meshPolygon[
+ tikz,
+ color = blue!70,
+ meshpoint = \alpha,
+ colorPolygon=red!120,
+ scale=4cm,
+ step=mesh,
+ print=points]
+ {(0,0);(1,0);(1,0.5);(0,0.5);(-0.20,0.35);(-0.25,0.25);(-0.20,0.15)}
+\end{Exemple}
+
+
\section{The \emph{inc} Macros}\label{sec:inc}
The three macros presented in the above sections have complementary
For the macro \Verb+\meshAddPointBWinc+ three additional
colors are present: \Verb+\luameshmpcolorBack+,
\Verb+\luameshmpcolorNew+, and
-\Verb+\luameshmpcolorCircle+. Of course, MetaPost
+\Verb+\luameshmpcolorCircle+. For the macro \Verb+\meshPolygon+, the
+color \Verb+\luameshmpcolorPoly+ is defined. Of course, MetaPost
colors can be defined as well. Finally, the \Verb+luamplib+ mechanism
\Verb+\mpcolor+ is also available.
\Verb+MeshPoints[i]+ are
defined using the unit length \Verb+u+.
+With the \Verb+\meshPolygon+ macro, we have the points of the polygon
+(refined) that are available with the
+\Verb+polygon[]+ table of variables.
+
\subsubsection{Examples}
Here is three examples for the different macros.
%etc.
\end{latexcode}
+With the \Verb+\meshPolygon+ we have also the polygon points coordinates:
+\begin{latexcode}
+\coordinate (polygon1) at (...,...);
+%etc.
+\end{latexcode}
+
Once again these coordinates are not yet defined to be used in the
code given by \meta{code
before} argument.
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
We refer to the previous sections for explanations.
+
+
\section{Gallery}
\subsection{With Animate}
\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.1}With MetaPost}{11}{subsection.3.1}
-\contentsline {subsubsection}{\numberline {3.1.1}The \LaTeX {} Colors Inside the MetaPost Code}{12}{subsubsection.3.1.1}
-\contentsline {subsubsection}{\numberline {3.1.2}The Mesh Points}{12}{subsubsection.3.1.2}
-\contentsline {subsubsection}{\numberline {3.1.3}Examples}{12}{subsubsection.3.1.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}{15}{subsubsection.3.2.2}
-\contentsline {section}{\numberline {4}Voronoï 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}{18}{section.5}
-\contentsline {subsection}{\numberline {5.1}Gmsh and Voronoï Diagrams}{19}{subsection.5.1}
-\contentsline {subsection}{\numberline {5.2}The Options}{20}{subsection.5.2}
-\contentsline {subsection}{\numberline {5.3}The \emph {inc} variants}{21}{subsection.5.3}
-\contentsline {section}{\numberline {6}Gallery}{21}{section.6}
-\contentsline {subsection}{\numberline {6.1}With Animate}{21}{subsection.6.1}
+\contentsline {subsection}{\numberline {2.4}Mesh a Polygon}{11}{subsection.2.4}
+\contentsline {subsubsection}{\numberline {2.4.1}The Options}{12}{subsubsection.2.4.1}
+\contentsline {section}{\numberline {3}The \emph {inc} Macros}{13}{section.3}
+\contentsline {subsection}{\numberline {3.1}With MetaPost}{13}{subsection.3.1}
+\contentsline {subsubsection}{\numberline {3.1.1}The \LaTeX {} Colors Inside the MetaPost Code}{14}{subsubsection.3.1.1}
+\contentsline {subsubsection}{\numberline {3.1.2}The Mesh Points}{14}{subsubsection.3.1.2}
+\contentsline {subsubsection}{\numberline {3.1.3}Examples}{14}{subsubsection.3.1.3}
+\contentsline {subsection}{\numberline {3.2}With TikZ}{16}{subsection.3.2}
+\contentsline {subsubsection}{\numberline {3.2.1}The Mesh Points}{16}{subsubsection.3.2.1}
+\contentsline {subsubsection}{\numberline {3.2.2}Examples}{17}{subsubsection.3.2.2}
+\contentsline {section}{\numberline {4}Voronoï Diagrams}{17}{section.4}
+\contentsline {subsection}{\numberline {4.1}The Options}{18}{subsection.4.1}
+\contentsline {subsection}{\numberline {4.2}The \emph {inc} variant}{19}{subsection.4.2}
+\contentsline {section}{\numberline {5}With Gmsh}{20}{section.5}
+\contentsline {subsection}{\numberline {5.1}Gmsh and Voronoï Diagrams}{21}{subsection.5.1}
+\contentsline {subsection}{\numberline {5.2}The Options}{22}{subsection.5.2}
+\contentsline {subsection}{\numberline {5.3}The \emph {inc} variants}{23}{subsection.5.3}
+\contentsline {section}{\numberline {6}Gallery}{23}{section.6}
+\contentsline {subsection}{\numberline {6.1}With Animate}{23}{subsection.6.1}
function isInside(listPoints,p,h)
-- if the point is to close to a point of the polygon
for i=1,#listPoints do
- if(math.sqrt(math.pow(p.x-listPoints[i].x,2) + math.pow(p.y-listPoints[i].y,2))<0.5*h) then
+ if(math.sqrt(math.pow(p.x-listPoints[i].x,2) + math.pow(p.y-listPoints[i].y,2))<0.4*h) then
return false
end
end
output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" .. output .."\\end{tikzpicture}"
tex.sprint(output)
end
+
+function drawMeshPolygonMPinc(chaine,beginning,ending,mode,h,step,
+ points,scale)
+ local polygon = buildList(chaine, mode)
+ polygon = addPointsPolygon(polygon,h)
+ local grid = buildGrid(polygon,h)
+ local listPoints = addGridPoints(polygon,grid,h)
+ if(step=="polygon") then
+ -- the polygon
+ output = tracePolygonMP(polygon,points)
+ end
+ if(step=="grid") then
+ -- polygon + grid
+ output = tracePointsMP(grid,points)
+ output = output .. tracePolygonMP(polygon,points)
+ end
+ if(step=="points") then
+ -- polygon + only grid points inside the polygon
+ output = tracePointsMP(listPoints,points)
+ output = output .. tracePolygonMP(polygon,points)
+ end
+ if(step=="mesh") then
+ -- polygon + mesh
+ triangulation = BowyerWatson(listPoints,"none") -- no bbox
+ output = traceMeshMP(listPoints,triangulation,points)
+ output = output .. tracePolygonMP(polygon,points)
+ end
+ output = "\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}"
+ tex.sprint(output)
+end
+
+
+
+function drawMeshPolygonTikZinc(chaine,beginning,ending,mode,h,step,
+ points,scale,color,colorPoly)
+ local polygon = buildList(chaine, mode)
+ polygon = addPointsPolygon(polygon,h)
+ local grid = buildGrid(polygon,h)
+ local listPoints = addGridPoints(polygon,grid,h)
+ if(step=="polygon") then
+ -- the polygon
+ output = tracePolygonTikZ(polygon,points,colorPoly)
+ end
+ if(step=="grid") then
+ -- polygon + grid
+ output = tracePointsTikZ(grid,points,color,"none") -- none for colorBbox
+ output = output .. tracePolygonTikZ(polygon,points,colorPoly)
+ end
+ if(step=="points") then
+ -- polygon + only grid points inside the polygon
+ output = tracePointsTikZ(listPoints,points,color,"none")
+ output = output .. tracePolygonTikZ(polygon,points,colorPoly)
+ end
+ if(step=="mesh") then
+ -- polygon + mesh
+ triangulation = BowyerWatson(listPoints,"none") -- no bbox
+ output = traceMeshTikZ(listPoints,triangulation,points,color,"none")
+ output = output .. tracePolygonTikZ(polygon,points,colorPoly)
+ end
+ output = "\\noindent\\begin{tikzpicture}[x="..scale..",y="..scale.."]".. beginning..output ..ending.. "\\end{tikzpicture}"
+ tex.sprint(output)
+end
\NeedsTeXFormat{LaTeX2e}%
\def\PackageName{luamesh}%
-\def\fileversion{v0.2}%
-\def\filedate{2016/11/29}%
+\def\fileversion{v0.5}%
+\def\filedate{2017/02/09}%
\ProvidesPackage{luamesh}[\filedate\space\fileversion]%
%
% package to load
%
\fi%
}%
+%%%%%%%%%%%%%%%% the meshPolygonInc command
+%%
+\define@boolkey{meshPolygonInc}{tikz}[true]{}%
+
+%% the scale
+\define@key{meshPolygonInc}{scale}[1cm]{\def\luameshval@mpi@scale{#1}}%
+%% print points
+\define@choicekey*{meshPolygonInc}{print}[\val\nr]{none, points,dotpoints}{%
+ \ifcase\nr\relax%
+ \def\luameshval@mpi@print{none}%
+ \or%
+ \def\luameshval@mpi@print{points}%
+ \or%
+ \def\luameshval@mpi@print{dotpoints}%
+ \fi%
+}%
+%% the name of the point
+\define@key{meshPolygonInc}{meshpoint}[P]{\def\luameshval@mpi@meshpoint{#1}}%
+%% the grid parameter
+\define@key{meshPolygonInc}{h}[0.2]{\def\luameshval@mpi@h{#1}}%
+%% the mode for reading the points
+\define@choicekey*{meshPolygonInc}{mode}[\val\nr]{int, ext}{%
+ \ifcase\nr\relax%
+ \def\luameshval@mpi@mode{int}%
+ \or%
+ \def\luameshval@mpi@mode{ext}%
+ \fi%
+}%
+%% the different steps of the meshing
+\define@choicekey*{meshPolygonInc}{step}[\val\nr]{polygon, grid, points, mesh}{%
+ \ifcase\nr\relax%
+ \def\luameshval@mpi@step{polygon}%
+ \or%
+ \def\luameshval@mpi@step{grid}%
+ \or%
+ \def\luameshval@mpi@step{points}%
+ \or%
+ \def\luameshval@mpi@step{mesh}%
+ \fi%
+}%
+
+%% the name of the color of drawing
+\define@key{meshPolygonInc}{color}[black]{\def\luameshval@mpi@color{#1}}%
+%% the name of the color of drawing Voronoi
+\define@key{meshPolygonInc}{colorPolygon}[red]{\def\luameshval@mpi@colorPolygon{#1}}%
+%% the name of the color of drawing the bbox
+%
+\presetkeys{meshPolygonInc}{tikz=false,scale,mode=int,step=mesh,print=none,color,colorPolygon,h,meshpoint}{}%
+%
+\newcommand{\meshPolygonInc}[4][]{%
+ % #1 : optionnal arguments
+ % #2 : the string containing the list of points
+ % (x1,y1);(x2,y2);... or the name file containing the points
+ % #3 : the code to place before the generated one
+ % #4 : the code to place after the generated one
+ \setkeys{meshPolygonInc}{#1} %
+ \def\MeshPoint{\luameshval@mpi@meshpoint}%
+ \ifKV@meshPolygonInc@tikz% if we are using tikz
+ \directlua{%
+ drawMeshPolygonTikZinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@mpi@mode","\luameshval@mpi@h","\luameshval@mpi@step","\luameshval@mpi@print","\luameshval@mpi@scale","\luameshval@mpi@color","\luameshval@mpi@colorPolygon")%
+ }%
+ \else % we are using MP
+ \mplibcolor{\luameshmpcolor}{\luameshval@mpi@color}%
+ \mplibcolor{\luameshmpcolorPoly}{\luameshval@mpi@colorPolygon}%
+ \directlua{%
+ drawMeshPolygonMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@mpi@mode","\luameshval@mpi@h","\luameshval@mpi@step","\luameshval@mpi@print","\luameshval@mpi@scale")%
+ }%
+ %
+ \fi%
+}%
rm luamesh/doc/lualatex/luamesh/*.out
rm luamesh/doc/lualatex/luamesh/*.toc
-zip -r archives/luamesh-v0-2.zip luamesh/
+zip -r archives/luamesh-v0-5.zip luamesh/
rm -r luamesh
\meshPolygon[tikz,step=grid,scale=3cm]{(0,0);(1,0);(1,0.5);(0.5,1);(-0.3,0.3)}
\meshPolygon[tikz,step=points,scale=3cm,print=points]{(0,0);(1,0);(1,0.5);(0.5,1);(-0.3,0.3)}
\meshPolygon[tikz,step=mesh,scale=3cm,print=dotpoints]{(0,0);(1,0);(1,0.5);(0.5,1);(-0.3,0.3)}
+
+\meshPolygonInc[step=points,scale=3cm,print=dotpoints]{(0,0);(1,0);(1,0.5);(0.5,1);(-0.3,0.3)}{%
+ beginfig(1);
+}{%
+endfig;
+}
+
\end{document}