Fonction \buildMeshBWinc
authorMaxime Chupin (escudo) <chupin@fougeriens.org>
Tue, 22 Nov 2016 17:50:07 +0000 (18:50 +0100)
committerMaxime Chupin (escudo) <chupin@fougeriens.org>
Tue, 22 Nov 2016 17:50:07 +0000 (18:50 +0100)
luamesh.lua
luamesh.sty
test/delaunay.pdf
test/delaunay.tex

index de0c274..b977e4e 100644 (file)
@@ -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)
index 82e3214..081cf5a 100644 (file)
 %%%%%%%%%%%%%%%% 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}{%
 }%
 %% 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}%
   \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
   \fi%
 }%
 %
+%
+%
 %%
 %
 %%the meshAddOnePointBW commande
index 05c518f..199be36 100644 (file)
Binary files a/test/delaunay.pdf and b/test/delaunay.pdf differ
index b45f05d..5b98391 100644 (file)
 
 \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,

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.