From: Maxime Chupin (escudo) Date: Tue, 22 Nov 2016 17:50:07 +0000 (+0100) Subject: Fonction \buildMeshBWinc X-Git-Url: https://melusine.eu.org/syracuse/G/git/?p=delaunay.git;a=commitdiff_plain;h=d865bd5b172801559649eabbef29fd8f3898ce70 Fonction \buildMeshBWinc --- diff --git a/luamesh.lua b/luamesh.lua index de0c274..b977e4e 100644 --- a/luamesh.lua +++ b/luamesh.lua @@ -323,6 +323,16 @@ function buildMeshMPBW(chaine,mode,points,bbox,scale) tex.sprint(output) end + +-- buildMesh with MP include code +function buildMeshMPBWinc(chaine,beginning, ending,mode,points,bbox,scale) + listPoints = buildList(chaine, mode) + triangulation = BowyerWatson(listPoints,bbox) + output = traceMeshMP(listPoints, triangulation,points) + output = "\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}" + tex.sprint(output) +end + -- buildMesh function buildRect(largeur,a,b,nbrA, nbrB) listPoints = rectangleList(a,b,nbrA,nbrB) diff --git a/luamesh.sty b/luamesh.sty index 82e3214..081cf5a 100644 --- a/luamesh.sty +++ b/luamesh.sty @@ -38,6 +38,68 @@ %%%%%%%%%%%%%%%% the buildMesh command %% engine of drawing \newif\ifluameshengineMP% +\define@boolkey{buildMeshInc}{tikz}[true]{}% +%% show the bounding box for delaunay +\define@choicekey*{buildMeshInc}{bbox}[\val\nr]{none, show}{% + \ifcase\nr\relax% + \def\luameshval@bm@bbox{none}% + \or% + \def\luameshval@bm@bbox{bbox}% + \fi% +}% +%% the scale +\define@key{buildMeshInc}{scale}[1cm]{\def\luameshval@bm@scale{#1}}% +%% print ponits ? +\define@choicekey*{buildMeshInc}{print}[\val\nr]{none, points}{% + \ifcase\nr\relax% + \def\luameshval@bm@print{none}% + \or% + \def\luameshval@bm@print{points}% + \fi% +}% +%% the name of the point +\define@key{buildMeshInc}{meshpoint}[P]{\def\luameshval@bm@meshpoint{#1}}% +%% the mode for reading the points +\define@choicekey*{buildMeshInc}{mode}[\val\nr]{int, ext}{% + \ifcase\nr\relax% + \def\luameshval@bm@mode{int}% + \or% + \def\luameshval@bm@mode{ext}% + \fi% +}% +% +%color +%% the name of the color of drawing +\define@key{buildMeshInc}{color}[black]{\def\luameshval@bm@color{#1}}% +%% the name of the color of drawing the bbox +\define@key{buildMeshInc}{colorBbox}[black]{\def\luameshval@bm@colorbbox{#1}}% +% +\presetkeys{buildMeshInc}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}% +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% the difinition BW Bowyer and Watson algo +\newcommand*{\buildMeshBWinc}[4][]{% + % #1 : the string containing the list of points + % (x1,y1);(x2,y2);... or the name file containing the points + \setkeys{buildMesh}{#1} % + \def\MeshPoint{\luameshval@bm@meshpoint}% + \ifKV@buildMesh@tikz% if we are using tikz + \directlua{% + buildMeshTikZ("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","full","\luameshval@bm@scale","\luameshval@bm@color")% + }% + \else % we are using MP + \mplibcolor{\luameshmpcolor}{\luameshval@bm@color} + \mplibcolor{\luameshmpcolorBbox}{\luameshval@bm@colorbbox} + \directlua{% + buildMeshMPBWinc("#2","#3","#4","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","\luameshval@bm@scale")% + }% + % + \fi% +}% +% +%%%%%%%%%%%%%%%% the buildMeshBW command +%% engine of drawing +\newif\ifluameshengineMP% \define@boolkey{buildMesh}{tikz}[true]{}% %% show the bounding box for delaunay \define@choicekey*{buildMesh}{bbox}[\val\nr]{none, show}{% @@ -49,7 +111,7 @@ }% %% the scale \define@key{buildMesh}{scale}[1cm]{\def\luameshval@bm@scale{#1}}% -%% print ponits ? +%% print points \define@choicekey*{buildMesh}{print}[\val\nr]{none, points}{% \ifcase\nr\relax% \def\luameshval@bm@print{none}% @@ -68,7 +130,7 @@ \fi% }% % -%color +% color %% the name of the color of drawing \define@key{buildMesh}{color}[black]{\def\luameshval@bm@color{#1}}% %% the name of the color of drawing the bbox @@ -97,6 +159,8 @@ \fi% }% % +% +% %% % %%the meshAddOnePointBW commande diff --git a/test/delaunay.pdf b/test/delaunay.pdf index 05c518f..199be36 100644 Binary files a/test/delaunay.pdf and b/test/delaunay.pdf differ diff --git a/test/delaunay.tex b/test/delaunay.tex index b45f05d..5b98391 100644 --- a/test/delaunay.tex +++ b/test/delaunay.tex @@ -13,6 +13,16 @@ \buildMeshBW[mode=ext,bbox = show, color=red,colorBbox = blue]{mesh.txt} + +\buildMeshBWinc[mode=ext,bbox = show, color=red,colorBbox = +blue]{mesh.txt}{% + beginfig(0); +}% +{% + draw MeshPoints[3] -- MeshPoints[9]; + endfig; +} + \meshAddPointBW[ meshpoint = x, colorNew =green!20!red,