From: Maxime Chupin (escudo) Date: Tue, 29 Nov 2016 16:45:11 +0000 (+0100) Subject: Fonctions (TikZ et MP) inc pour Voronoi X-Git-Url: https://melusine.eu.org/syracuse/G/git/?a=commitdiff_plain;h=93a6d2fd77327d5abb1ee4a8324e5d0f79f29927;p=delaunay.git Fonctions (TikZ et MP) inc pour Voronoi --- diff --git a/archives/luamesh-v0-1.zip b/archives/luamesh-v0-1.zip index fb95e48..ac51292 100644 Binary files a/archives/luamesh-v0-1.zip and b/archives/luamesh-v0-1.zip differ diff --git a/luamesh.lua b/luamesh.lua index af3da31..179024d 100644 --- a/luamesh.lua +++ b/luamesh.lua @@ -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) diff --git a/luamesh.sty b/luamesh.sty index 7d13961..14bc1b1 100644 --- a/luamesh.sty +++ b/luamesh.sty @@ -177,6 +177,8 @@ }% %% 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% @@ -185,12 +187,22 @@ \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 @@ -200,15 +212,17 @@ % #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% diff --git a/test/delaunay.pdf b/test/delaunay.pdf index a20e09e..666c3cc 100644 Binary files a/test/delaunay.pdf and b/test/delaunay.pdf differ diff --git a/test/delaunay.tex b/test/delaunay.tex index 242e08b..0c8352e 100644 --- a/test/delaunay.tex +++ b/test/delaunay.tex @@ -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}