From: Maxime Chupin (escudo) Date: Wed, 30 Nov 2016 19:16:41 +0000 (+0100) Subject: Ajout fonctionnalité de dashed pour Voronoi, documentation X-Git-Url: https://melusine.eu.org/syracuse/G/git/?a=commitdiff_plain;h=e6cdb2e004ddba7c63705df4835de516ce0f297c;p=delaunay.git Ajout fonctionnalité de dashed pour Voronoi, documentation --- diff --git a/archives/luamesh-v0-2.zip b/archives/luamesh-v0-2.zip index b9b264c..0bd6309 100644 Binary files a/archives/luamesh-v0-2.zip and b/archives/luamesh-v0-2.zip differ diff --git a/doc/luamesh-doc.listing b/doc/luamesh-doc.listing index 12eb637..e2c8906 100644 --- a/doc/luamesh-doc.listing +++ b/doc/luamesh-doc.listing @@ -5,19 +5,10 @@ \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}% + \drawPointsMeshinc[mode=ext, bbox = show,colorBbox = blue!20,print=points]{mesh.txt}% {% beginfig(0); \drawPath @@ -26,14 +17,7 @@ \clipPath endfig; } - \newpage - \buildMeshBWinc[ - mode=ext, - bbox = show, - colorBbox = blue!20, - print=points - ] - {meshInit.txt}% + \newpage\buildMeshBWinc[mode=ext,bbox = show,colorBbox = blue!20,print=points]{meshInit.txt}% {% beginfig(0); \drawPath @@ -43,16 +27,9 @@ 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}% + \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 @@ -61,15 +38,9 @@ \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}% + \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 @@ -78,14 +49,9 @@ \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}% + \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 @@ -96,13 +62,7 @@ } } \newpage - \buildMeshBWinc[ - mode=ext, - bbox = show, - colorBbox = blue!20, - print=points - ] - {mesh.txt}% + \buildMeshBWinc[mode=ext,bbox = show,colorBbox = blue!20,print=points]{mesh.txt}% {% beginfig(0); \drawPath @@ -112,11 +72,7 @@ endfig; } \newpage - \buildMeshBWinc[ - mode=ext, - print=points - ] - {mesh.txt}% + \buildMeshBWinc[mode=ext,print=points]{mesh.txt}% {% beginfig(0); \drawPath diff --git a/doc/luamesh-doc.out b/doc/luamesh-doc.out index 4a7328f..7407af4 100644 --- a/doc/luamesh-doc.out +++ b/doc/luamesh-doc.out @@ -23,6 +23,7 @@ \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 Voronoi Diagrams}{section.5}% 25 -\BOOKMARK [2][-]{subsection.5.2}{The inc variants}{section.5}% 26 -\BOOKMARK [1][-]{section.6}{Gallery}{}% 27 -\BOOKMARK [2][-]{subsection.6.1}{With Animate}{section.6}% 28 +\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 diff --git a/doc/luamesh-doc.pdf b/doc/luamesh-doc.pdf index 33cdaaf..2060b52 100644 Binary files a/doc/luamesh-doc.pdf and b/doc/luamesh-doc.pdf differ diff --git a/doc/luamesh-doc.tex b/doc/luamesh-doc.tex index 3e13204..e3408cc 100644 --- a/doc/luamesh-doc.tex +++ b/doc/luamesh-doc.tex @@ -67,8 +67,9 @@ 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} @@ -835,8 +836,18 @@ xn yn 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 Voronoi diagram. +\item[styleDelaunay = none (default) \textme{or} dashed] This option + allows to draw dashed lines for the Delaunay triangulation. +\item[styleVoronoi = none (default) \textme{or} dashed] This option + allows to draw dashed lines for the Voronoi edges. \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} @@ -916,7 +927,49 @@ Voronoi diagram associated. This is done by the following macro:\bigskip \gmshVoronoi{maillage.msh} \end{Exemple} -We refer to the section~\ref{sec:voronoiOptions} for the list of the options. + +\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 + 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.). +\item[delaunay = none (default) \textme{or} show] This option + allows to draw the Delaunay triangulation under the Voronoi diagram. +\item[styleDelaunay = none (default) \textme{or} dashed] This option + allows to draw dashed lines for the Delaunay triangulation. +\item[styleVoronoi = none (default) \textme{or} dashed] This option + allows to draw dashed lines for the Voronoi edges. +\end{optionsenum} + +\begin{Exemple} + \gmshVoronoi[tikz,scale=1.5cm, delaunay=show,styleVoronoi=dashed]{maillage.msh} +\end{Exemple} + \subsection{The \emph{inc} variants} @@ -944,19 +997,10 @@ For example, the following code (in a file name \Verb+animation.tex+): \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}% + \drawPointsMeshinc[mode=ext, bbox = show,colorBbox = blue!20,print=points]{mesh.txt}% {% beginfig(0); \drawPath @@ -965,14 +1009,7 @@ For example, the following code (in a file name \Verb+animation.tex+): \clipPath endfig; } - \newpage - \buildMeshBWinc[ - mode=ext, - bbox = show, - colorBbox = blue!20, - print=points - ] - {meshInit.txt}% + \newpage\buildMeshBWinc[mode=ext,bbox = show,colorBbox = blue!20,print=points]{meshInit.txt}% {% beginfig(0); \drawPath @@ -982,16 +1019,9 @@ For example, the following code (in a file name \Verb+animation.tex+): 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}% + \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 @@ -1000,15 +1030,9 @@ For example, the following code (in a file name \Verb+animation.tex+): \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}% + \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 @@ -1017,14 +1041,9 @@ For example, the following code (in a file name \Verb+animation.tex+): \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}% + \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 @@ -1035,13 +1054,7 @@ For example, the following code (in a file name \Verb+animation.tex+): } } \newpage - \buildMeshBWinc[ - mode=ext, - bbox = show, - colorBbox = blue!20, - print=points - ] - {mesh.txt}% + \buildMeshBWinc[mode=ext,bbox = show,colorBbox = blue!20,print=points]{mesh.txt}% {% beginfig(0); \drawPath @@ -1051,11 +1064,7 @@ For example, the following code (in a file name \Verb+animation.tex+): endfig; } \newpage - \buildMeshBWinc[ - mode=ext, - print=points - ] - {mesh.txt}% + \buildMeshBWinc[mode=ext,print=points]{mesh.txt}% {% beginfig(0); \drawPath diff --git a/doc/luamesh-doc.toc b/doc/luamesh-doc.toc index 5b9e8cf..bd488c1 100644 --- a/doc/luamesh-doc.toc +++ b/doc/luamesh-doc.toc @@ -23,7 +23,8 @@ \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} +\contentsline {subsection}{\numberline {5.1}Gmsh and Voronoi Diagrams}{19}{subsection.5.1} +\contentsline {subsection}{\numberline {5.2}The Options}{19}{subsection.5.2} +\contentsline {subsection}{\numberline {5.3}The \emph {inc} variants}{20}{subsection.5.3} +\contentsline {section}{\numberline {6}Gallery}{21}{section.6} +\contentsline {subsection}{\numberline {6.1}With Animate}{21}{subsection.6.1} diff --git a/luamesh.lua b/luamesh.lua index bc961b7..3ff737b 100644 --- a/luamesh.lua +++ b/luamesh.lua @@ -329,7 +329,17 @@ end -- trace Voronoi with MP -function traceVoronoiMP(listPoints, triangulation,listVoronoi, points, tri) +function traceVoronoiMP(listPoints, triangulation,listVoronoi, points, tri,styleD,styleV) + if(styleD == "dashed") then + sDelaunay = "dashed evenly" + else + sDelaunay = "" + end + if(styleV == "dashed") then + sVoronoi = "dashed evenly" + else + sVoronoi = "" + end listCircumC = listCircumCenter(listPoints,triangulation) output = ""; output = output .. " pair MeshPoints[];" @@ -346,16 +356,16 @@ function traceVoronoiMP(listPoints, triangulation,listVoronoi, points, tri) PointJ = listPoints[triangulation[i][2]] PointK = listPoints[triangulation[i][3]] if(triangulation[i].type == "bbox") then - output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolorBbox;" + output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle "..sDelaunay.." withcolor \\luameshmpcolorBbox;" else - output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolor;" + output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle "..sDelaunay.." withcolor \\luameshmpcolor;" end end end for i=1,#listVoronoi do PointI = listCircumC[listVoronoi[i][1]] PointJ = listCircumC[listVoronoi[i][2]] - output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u withcolor \\luameshmpcolorVoronoi;" + output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u "..sVoronoi.." withcolor \\luameshmpcolorVoronoi;" end if(points=="points") then j=1 @@ -390,7 +400,17 @@ end -- trace Voronoi with TikZ -function traceVoronoiTikZ(listPoints, triangulation,listVoronoi, points, tri,color,colorBbox,colorVoronoi) +function traceVoronoiTikZ(listPoints, triangulation,listVoronoi, points, tri,color,colorBbox,colorVoronoi,styleD,styleV) + if(styleD == "dashed") then + sDelaunay = ",dashed" + else + sDelaunay = "" + end + if(styleV == "dashed") then + sVoronoi = ",dashed" + else + sVoronoi = "" + end listCircumC = listCircumCenter(listPoints,triangulation) output = "" for i=1,#listPoints do @@ -405,16 +425,16 @@ function traceVoronoiTikZ(listPoints, triangulation,listVoronoi, points, tri,col PointJ = listPoints[triangulation[i][2]] PointK = listPoints[triangulation[i][3]] if(triangulation[i].type == "bbox") then - output = output .. "\\draw[color="..colorBbox.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;" + output = output .. "\\draw[color="..colorBbox..sDelaunay.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;" else - output = output .. "\\draw[color="..color.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;" + output = output .. "\\draw[color="..color..sDelaunay.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;" end end end for i=1,#listVoronoi do PointI = listCircumC[listVoronoi[i][1]] PointJ = listCircumC[listVoronoi[i][2]] - output = output .. "\\draw[color="..colorVoronoi.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..");" + output = output .. "\\draw[color="..colorVoronoi..sVoronoi.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..");" end if(points=="points") then j=1 @@ -449,32 +469,32 @@ end -- buildVoronoi with MP -function buildVoronoiMPBW(chaine,mode,points,bbox,scale,tri) +function buildVoronoiMPBW(chaine,mode,points,bbox,scale,tri,styleD,styleV) listPoints = buildList(chaine, mode) triangulation = BowyerWatson(listPoints,bbox) listVoronoi = buildVoronoi(listPoints, triangulation) - output = traceVoronoiMP(listPoints,triangulation,listVoronoi,points,tri) + output = traceVoronoiMP(listPoints,triangulation,listVoronoi,points,tri,styleD,styleV) output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale.. ";" .. output .."endfig;\\end{mplibcode}" tex.sprint(output) end -- buildVoronoi with TikZ -function buildVoronoiTikZBW(chaine,mode,points,bbox,scale,tri,color,colorBbox,colorVoronoi) +function buildVoronoiTikZBW(chaine,mode,points,bbox,scale,tri,color,colorBbox,colorVoronoi,styleD,styleV) listPoints = buildList(chaine, mode) triangulation = BowyerWatson(listPoints,bbox) listVoronoi = buildVoronoi(listPoints, triangulation) - output = traceVoronoiTikZ(listPoints,triangulation,listVoronoi,points,tri,color,colorBbox,colorVoronoi) + output = traceVoronoiTikZ(listPoints,triangulation,listVoronoi,points,tri,color,colorBbox,colorVoronoi,styleD,styleV) output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" .. output .."\\end{tikzpicture}" tex.sprint(output) end -- buildVoronoi with MP -function buildVoronoiMPBWinc(chaine,beginning, ending,mode,points,bbox,scale,tri) +function buildVoronoiMPBWinc(chaine,beginning, ending,mode,points,bbox,scale,tri,styleD,styleV) listPoints = buildList(chaine, mode) triangulation = BowyerWatson(listPoints,bbox) listVoronoi = buildVoronoi(listPoints, triangulation) - output = traceVoronoiMP(listPoints,triangulation,listVoronoi,points,tri) + output = traceVoronoiMP(listPoints,triangulation,listVoronoi,points,tri,styleD,styleV) output = "\\leavevmode\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}" tex.sprint(output) end @@ -482,10 +502,10 @@ end -- buildVoronoi with TikZ function buildVoronoiTikZBWinc(chaine,beginning, ending,mode,points,bbox,scale,tri,color,colorBbox,colorVoronoi) - listPoints = buildList(chaine, mode) + listPoints = buildList(chaine, mode,styleD,styleV) triangulation = BowyerWatson(listPoints,bbox) listVoronoi = buildVoronoi(listPoints, triangulation) - output = traceVoronoiTikZ(listPoints,triangulation,listVoronoi,points,tri,color,colorBbox,colorVoronoi) + output = traceVoronoiTikZ(listPoints,triangulation,listVoronoi,points,tri,color,colorBbox,colorVoronoi,styleD,styleV) output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" ..beginning.. output..ending .."\\end{tikzpicture}" tex.sprint(output) end @@ -1184,39 +1204,39 @@ end -- buildVoronoi with MP -function gmshVoronoiMP(file,points,scale,tri) +function gmshVoronoiMP(file,points,scale,tri,styleD,styleV) listPoints,triangulation = readGmsh(file) listVoronoi = buildVoronoi(listPoints, triangulation) - output = traceVoronoiMP(listPoints,triangulation,listVoronoi,points,tri) + output = traceVoronoiMP(listPoints,triangulation,listVoronoi,points,tri,styleD,styleV) output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale.. ";" .. output .."endfig;\\end{mplibcode}" tex.sprint(output) end -- buildVoronoi with TikZ -function gmshVoronoiTikZ(file,points,scale,tri,color,colorVoronoi) +function gmshVoronoiTikZ(file,points,scale,tri,color,colorVoronoi,styleD,styleV) listPoints,triangulation = readGmsh(file) listVoronoi = buildVoronoi(listPoints, triangulation) - output = traceVoronoiTikZ(listPoints,triangulation,listVoronoi,points,tri,color,colorBbox,colorVoronoi) + output = traceVoronoiTikZ(listPoints,triangulation,listVoronoi,points,tri,color,colorBbox,colorVoronoi,styleD,styleV) output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" .. output .."\\end{tikzpicture}" tex.sprint(output) end -- buildVoronoi with MP -function gmshVoronoiMPinc(file,beginning, ending,points,scale,tri) +function gmshVoronoiMPinc(file,beginning, ending,points,scale,tri,styleD,styleV) listPoints,triangulation = readGmsh(file) listVoronoi = buildVoronoi(listPoints, triangulation) - output = traceVoronoiMP(listPoints,triangulation,listVoronoi,points,tri) + output = traceVoronoiMP(listPoints,triangulation,listVoronoi,points,tri,styleD,styleV) output = "\\leavevmode\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}" tex.sprint(output) end -- buildVoronoi with TikZ -function gmshVoronoiTikZinc(file,beginning, ending,points,scale,tri,color,colorVoronoi) +function gmshVoronoiTikZinc(file,beginning, ending,points,scale,tri,color,colorVoronoi,styleD,styleV) listPoints,triangulation = readGmsh(file) listVoronoi = buildVoronoi(listPoints, triangulation) - output = traceVoronoiTikZ(listPoints,triangulation,listVoronoi,points,tri,color,colorBbox,colorVoronoi) + output = traceVoronoiTikZ(listPoints,triangulation,listVoronoi,points,tri,color,colorBbox,colorVoronoi,styleD,styleV) output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" ..beginning.. output..ending .."\\end{tikzpicture}" tex.sprint(output) end diff --git a/luamesh.sty b/luamesh.sty index 1842370..9d7c06b 100644 --- a/luamesh.sty +++ b/luamesh.sty @@ -175,6 +175,22 @@ \def\luameshval@bvi@print{points}% \fi% }% +%% style dashed Delaunay +\define@choicekey*{buildVoronoiInc}{styleDelaunay}[\val\nr]{none, dashed}{% + \ifcase\nr\relax% + \def\luameshval@bvi@styleDelaunay{none}% + \or% + \def\luameshval@bvi@styleDelaunay{dashed}% + \fi% +}% +%% style dashed Voronoi +\define@choicekey*{buildVoronoiInc}{styleVoronoi}[\val\nr]{none, dashed}{% + \ifcase\nr\relax% + \def\luameshval@bvi@styleVoronoi{none}% + \or% + \def\luameshval@bvi@styleVoronoi{dashed}% + \fi% +}% %% the name of the point \define@key{buildVoronoiInc}{meshpoint}[P]{\def\luameshval@bvi@meshpoint{#1}}% %% the name of the circum point @@ -202,7 +218,7 @@ %% the name of the color of drawing the bbox \define@key{buildVoronoiInc}{colorBbox}[black]{\def\luameshval@bvi@colorbbox{#1}}% % -\presetkeys{buildVoronoiInc}{tikz=false,bbox=none,scale, meshpoint,circumpoint,mode=int,print=none,color,colorVoronoi,colorBbox,delaunay=none}{}% +\presetkeys{buildVoronoiInc}{tikz=false,bbox=none,scale, meshpoint,circumpoint,mode=int,print=none,color,colorVoronoi,colorBbox,delaunay=none,styleDelaunay=none,styleVoronoi=none}{}% % \newcommand*{\buildVoronoiBWinc}[4][]{% % #1 : optionnal arguments @@ -215,14 +231,14 @@ \def\CircumPoint{\luameshval@bvi@circumpoint}% \ifKV@buildVoronoiInc@tikz% if we are using tikz \directlua{% - buildVoronoiTikZBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bvi@mode","\luameshval@bvi@print","\luameshval@bvi@bbox","\luameshval@bvi@scale","\luameshval@bvi@delaunay","\luameshval@bvi@color","\luameshval@bvi@colorbbox","\luameshval@bvi@colorvoronoi")% + buildVoronoiTikZBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bvi@mode","\luameshval@bvi@print","\luameshval@bvi@bbox","\luameshval@bvi@scale","\luameshval@bvi@delaunay","\luameshval@bvi@color","\luameshval@bvi@colorbbox","\luameshval@bvi@colorvoronoi","\luameshval@bvi@styleDelaunay","\luameshval@bvi@styleVoronoi")% }% \else % we are using MP \mplibcolor{\luameshmpcolor}{\luameshval@bvi@color}% \mplibcolor{\luameshmpcolorBbox}{\luameshval@bvi@colorbbox}% \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@bvi@colorvoronoi}% \directlua{% - buildVoronoiMPBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bvi@mode","\luameshval@bvi@print","\luameshval@bvi@bbox","\luameshval@bvi@scale","\luameshval@bvi@delaunay")% + buildVoronoiMPBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bvi@mode","\luameshval@bvi@print","\luameshval@bvi@bbox","\luameshval@bvi@scale","\luameshval@bvi@delaunay","\luameshval@bvi@styleDelaunay","\luameshval@bvi@styleVoronoi")% }% % \fi% @@ -261,6 +277,22 @@ \def\luameshval@bv@mode{ext}% \fi% }% +%% style dashed Delaunay +\define@choicekey*{buildVoronoi}{styleDelaunay}[\val\nr]{none, dashed}{% + \ifcase\nr\relax% + \def\luameshval@bv@styleDelaunay{none}% + \or% + \def\luameshval@bv@styleDelaunay{dashed}% + \fi% +}% +%% style dashed Voronoi +\define@choicekey*{buildVoronoi}{styleVoronoi}[\val\nr]{none, dashed}{% + \ifcase\nr\relax% + \def\luameshval@bv@styleVoronoi{none}% + \or% + \def\luameshval@bv@styleVoronoi{dashed}% + \fi% +}% %% the mode for reading the points \define@choicekey*{buildVoronoi}{delaunay}[\val\nr]{none, show}{% \ifcase\nr\relax% @@ -276,7 +308,8 @@ %% the name of the color of drawing the bbox \define@key{buildVoronoi}{colorBbox}[black]{\def\luameshval@bv@colorbbox{#1}}% % -\presetkeys{buildVoronoi}{tikz=false,bbox=none,scale, meshpoint,circumpoint,mode=int,print=none,color,colorVoronoi,colorBbox,delaunay=none}{}% +\presetkeys{buildVoronoi}{tikz=false,bbox=none,scale, + meshpoint,circumpoint,mode=int,print=none,color,colorVoronoi,colorBbox,delaunay=none,styleDelaunay=none, styleVoronoi=none}{}% % \newcommand{\buildVoronoiBW}[2][]{% % #1 : optionnal arguments @@ -287,14 +320,14 @@ \def\CircumPoint{\luameshval@bv@circumpoint}% \ifKV@buildVoronoi@tikz% if we are using tikz \directlua{% - buildVoronoiTikZBW("#2","\luameshval@bv@mode","\luameshval@bv@print","\luameshval@bv@bbox","\luameshval@bv@scale","\luameshval@bv@delaunay","\luameshval@bv@color","\luameshval@bv@colorbbox","\luameshval@bv@colorVoronoi")% + buildVoronoiTikZBW("#2","\luameshval@bv@mode","\luameshval@bv@print","\luameshval@bv@bbox","\luameshval@bv@scale","\luameshval@bv@delaunay","\luameshval@bv@color","\luameshval@bv@colorbbox","\luameshval@bv@colorVoronoi","\luameshval@bv@styleDelaunay","\luameshval@bv@styleVoronoi")% }% \else % we are using MP \mplibcolor{\luameshmpcolor}{\luameshval@bv@color}% \mplibcolor{\luameshmpcolorBbox}{\luameshval@bv@colorbbox}% \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@bv@colorVoronoi}% \directlua{% - buildVoronoiMPBW("#2","\luameshval@bv@mode","\luameshval@bv@print","\luameshval@bv@bbox","\luameshval@bv@scale","\luameshval@bv@delaunay")% + buildVoronoiMPBW("#2","\luameshval@bv@mode","\luameshval@bv@print","\luameshval@bv@bbox","\luameshval@bv@scale","\luameshval@bv@delaunay","\luameshval@bv@styleDelaunay","\luameshval@bv@styleVoronoi")% }% % \fi% @@ -675,14 +708,31 @@ \def\luameshval@gvi@delaunay{show}% \fi% }% +%% style dashed Delaunay +\define@choicekey*{gmshVoronoiInc}{styleDelaunay}[\val\nr]{none, dashed}{% + \ifcase\nr\relax% + \def\luameshval@gvi@styleDelaunay{none}% + \or% + \def\luameshval@gvi@styleDelaunay{dashed}% + \fi% +}% +%% style dashed Voronoi +\define@choicekey*{gmshVoronoiInc}{styleVoronoi}[\val\nr]{none, dashed}{% + \ifcase\nr\relax% + \def\luameshval@gvi@styleVoronoi{none}% + \or% + \def\luameshval@gvi@styleVoronoi{dashed}% + \fi% +}% %% the name of the color of drawing \define@key{gmshVoronoiInc}{color}[black]{\def\luameshval@gvi@color{#1}}% %% the name of the color of drawing Voronoi \define@key{gmshVoronoiInc}{colorVoronoi}[red]{\def\luameshval@gvi@colorvoronoi{#1}}% % -\presetkeys{gmshVoronoiInc}{tikz=false,scale, meshpoint,circumpoint,print=none,color,colorVoronoi,delaunay=none}{}% +\presetkeys{gmshVoronoiInc}{tikz=false,scale, + meshpoint,circumpoint,print=none,color,colorVoronoi,delaunay=none,styleVoronoi=none, styleDelaunay=none}{}% % -\newcommand*{\gmshVoronoiBWinc}[4][]{% +\newcommand*{\gmshVoronoiinc}[4][]{% % #1 : optionnal arguments % #2 : the gmsh file % #3 : the code to place before the generated one @@ -692,13 +742,13 @@ \def\CircumPoint{\luameshval@gvi@circumpoint}% \ifKV@gmshVoronoiInc@tikz% if we are using tikz \directlua{% - gmshVoronoiTikZinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@gvi@print","\luameshval@gvi@scale","\luameshval@gvi@delaunay","\luameshval@gvi@color","\luameshval@gvi@colorvoronoi")% + gmshVoronoiTikZinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@gvi@print","\luameshval@gvi@scale","\luameshval@gvi@delaunay","\luameshval@gvi@color","\luameshval@gvi@colorvoronoi","\luameshval@gvi@styleDelaunay","\luameshval@gvi@styleVoronoi")% }% \else % we are using MP \mplibcolor{\luameshmpcolor}{\luameshval@gvi@color}% \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@gvi@colorvoronoi}% \directlua{% - gmshVoronoiMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@gvi@print","\luameshval@gvi@scale","\luameshval@gvi@delaunay")% + gmshVoronoiMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@gvi@print","\luameshval@gvi@scale","\luameshval@gvi@delaunay","\luameshval@gvi@styleDelaunay","\luameshval@gvi@styleVoronoi")% }% % \fi% @@ -729,12 +779,28 @@ \def\luameshval@gv@delaunay{show}% \fi% }% +%% style dashed Delaunay +\define@choicekey*{gmshVoronoi}{styleDelaunay}[\val\nr]{none, dashed}{% + \ifcase\nr\relax% + \def\luameshval@gv@styleDelaunay{none}% + \or% + \def\luameshval@gv@styleDelaunay{dashed}% + \fi% +}% +%% style dashed Voronoi +\define@choicekey*{gmshVoronoi}{styleVoronoi}[\val\nr]{none, dashed}{% + \ifcase\nr\relax% + \def\luameshval@gv@styleVoronoi{none}% + \or% + \def\luameshval@gv@styleVoronoi{dashed}% + \fi% +}% %% the name of the color of drawing \define@key{gmshVoronoi}{color}[black]{\def\luameshval@gv@color{#1}}% %% the name of the color of drawing Voronoi \define@key{gmshVoronoi}{colorVoronoi}[red]{\def\luameshval@gv@colorVoronoi{#1}}% % -\presetkeys{gmshVoronoi}{tikz=false,scale, meshpoint,circumpoint,print=none,color,colorVoronoi,delaunay=none}{}% +\presetkeys{gmshVoronoi}{tikz=false,scale, meshpoint,circumpoint,print=none,color,colorVoronoi,delaunay=none,styleVoronoi=none, styleDelaunay=none}{}% % \newcommand{\gmshVoronoi}[2][]{% % #1 : optionnal arguments @@ -744,13 +810,13 @@ \def\CircumPoint{\luameshval@gv@circumpoint}% \ifKV@gmshVoronoi@tikz% if we are using tikz \directlua{% - gmshVoronoiTikZ("#2","\luameshval@gv@print","\luameshval@gv@scale","\luameshval@gv@delaunay","\luameshval@gv@color","\luameshval@gv@colorVoronoi")% + gmshVoronoiTikZ("#2","\luameshval@gv@print","\luameshval@gv@scale","\luameshval@gv@delaunay","\luameshval@gv@color","\luameshval@gv@colorVoronoi","\luameshval@gv@styleDelaunay","\luameshval@gv@styleVoronoi")% }% \else % we are using MP \mplibcolor{\luameshmpcolor}{\luameshval@gv@color}% \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@gv@colorVoronoi}% \directlua{% - gmshVoronoiMP("#2","\luameshval@gv@print","\luameshval@gv@scale","\luameshval@gv@delaunay")% + gmshVoronoiMP("#2","\luameshval@gv@print","\luameshval@gv@scale","\luameshval@gv@delaunay","\luameshval@gv@styleDelaunay","\luameshval@gv@styleVoronoi")% }% % \fi%