Fonctions (TikZ et MP) inc pour Voronoi
authorMaxime Chupin (escudo) <chupin@fougeriens.org>
Tue, 29 Nov 2016 16:45:11 +0000 (17:45 +0100)
committerMaxime Chupin (escudo) <chupin@fougeriens.org>
Tue, 29 Nov 2016 16:45:11 +0000 (17:45 +0100)
archives/luamesh-v0-1.zip
luamesh.lua
luamesh.sty
test/delaunay.pdf
test/delaunay.tex

index fb95e48..ac51292 100644 (file)
Binary files a/archives/luamesh-v0-1.zip and b/archives/luamesh-v0-1.zip differ
index af3da31..179024d 100644 (file)
@@ -471,6 +471,28 @@ function buildVoronoiTikZBW(chaine,mode,points,bbox,scale,tri,color,colorBbox,co
 end
 
 
+-- buildVoronoi with MP
+function buildVoronoiMPBWinc(chaine,beginning, ending,mode,points,bbox,scale,tri)
+   listPoints = buildList(chaine, mode)
+   triangulation = BowyerWatson(listPoints,bbox)
+   listVoronoi = buildVoronoi(listPoints, triangulation)
+   output = traceVoronoiMP(listPoints,triangulation,listVoronoi,points,tri)
+   output = "\\leavevmode\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}"
+   tex.sprint(output)
+end
+
+
+-- buildVoronoi with TikZ
+function buildVoronoiTikZBWinc(chaine,beginning, ending,mode,points,bbox,scale,tri,color,colorBbox,colorVoronoi)
+   listPoints = buildList(chaine, mode)
+   triangulation = BowyerWatson(listPoints,bbox)
+   listVoronoi = buildVoronoi(listPoints, triangulation)
+   output = traceVoronoiTikZ(listPoints,triangulation,listVoronoi,points,tri,color,colorBbox,colorVoronoi)
+   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" ..beginning.. output..ending .."\\end{tikzpicture}"
+   tex.sprint(output)
+end
+
+
 
 -- trace a triangulation with TikZ
 function traceMeshTikZ(listPoints, triangulation,points,color,colorBbox)
index 7d13961..14bc1b1 100644 (file)
 }%
 %% the name of the point
 \define@key{buildVoronoiInc}{meshpoint}[P]{\def\luameshval@bvi@meshpoint{#1}}%
+%% the name of the circum point
+\define@key{buildVoronoiInc}{circumpoint}[P]{\def\luameshval@bvi@circumpoint{#1}}%
 %% the mode for reading the points
 \define@choicekey*{buildVoronoiInc}{mode}[\val\nr]{int, ext}{%
   \ifcase\nr\relax%
   \def\luameshval@bvi@mode{ext}%
   \fi%
 }%
+%% the mode for reading the points
+\define@choicekey*{buildVoronoiInc}{delaunay}[\val\nr]{none, show}{%
+  \ifcase\nr\relax%
+  \def\luameshval@bvi@delaunay{none}%
+  \or%
+  \def\luameshval@bvi@delaunay{show}%
+  \fi%
+}%
 %% the name of the color of drawing
 \define@key{buildVoronoiInc}{color}[black]{\def\luameshval@bvi@color{#1}}%
+%% the name of the color of drawing Voronoi
+\define@key{buildVoronoiInc}{colorVoronoi}[red]{\def\luameshval@bvi@colorvoronoi{#1}}%
 %% 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,mode=int,print=none,color,colorBbox}{}%
+\presetkeys{buildVoronoiInc}{tikz=false,bbox=none,scale, meshpoint,circumpoint,mode=int,print=none,color,colorVoronoi,colorBbox,delaunay=none}{}%
 %
 \newcommand*{\buildVoronoiBWinc}[4][]{%
   % #1 : optionnal arguments
   % #4 : the code to place after the generated one
   \setkeys{buildVoronoiInc}{#1} %
   \def\MeshPoint{\luameshval@bvi@meshpoint}%
+  \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@color","\luameshval@bvi@colorbbox")%
+    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")%
   }%
   \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")%
+    buildVoronoiMPBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bvi@mode","\luameshval@bvi@print","\luameshval@bvi@bbox","\luameshval@bvi@scale","\luameshval@bvi@delaunay")%
   }%
   %
   \fi%
index a20e09e..666c3cc 100644 (file)
Binary files a/test/delaunay.pdf and b/test/delaunay.pdf differ
index 242e08b..0c8352e 100644 (file)
@@ -154,4 +154,10 @@ colorBbox = black
 \buildVoronoiBW[tikz,mode=ext,delaunay=show,colorVoronoi=green!60!blue]{mesh.txt}\par
 \buildVoronoiBW[tikz,mode=ext,print=points,delaunay=show,bbox=show,meshpoint=x,circumpoint=y]{mesh.txt}
 
+\buildVoronoiBWinc[mode=ext]{mesh.txt}{beginfig(0);}{endfig;}
+\buildVoronoiBWinc[tikz,mode=ext]{mesh.txt}{}{}
+
+
+\buildVoronoiBWinc[tikz,mode=ext,print=points,delaunay=show,meshpoint=x,circumpoint=y]{mesh.txt}{}{\draw[color=blue,thick] (0,0)--(3,3);}
+
 \end{document}

Licence Creative Commons Les fichiers de Syracuse sont mis à disposition (sauf mention contraire) selon les termes de la
Licence Creative Commons Attribution - Pas d’Utilisation Commerciale - Partage dans les Mêmes Conditions 4.0 International.