From: Maxime Chupin (escudo) Date: Tue, 22 Nov 2016 23:19:18 +0000 (+0100) Subject: Fonction pour tracer seulement les points du maillage X-Git-Url: https://melusine.eu.org/syracuse/G/git/?a=commitdiff_plain;h=ce88841e4c39f70da4603909378967a0fd5c48ae;p=delaunay.git Fonction pour tracer seulement les points du maillage --- diff --git a/luamesh.lua b/luamesh.lua index 060d389..5227f86 100644 --- a/luamesh.lua +++ b/luamesh.lua @@ -301,6 +301,34 @@ function traceMeshMP(listPoints, triangulation,points) end +-- print points of the mesh +function tracePointsMP(listPoints,points) + output = ""; + output = output .. " pair MeshPoints[];" + for i=1,#listPoints do + output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");" + end + if(points=="points") then + for i=1,#listPoints do + if(listPoints[i].type == "bbox") then + output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;" + else + output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor ;" + end + end + else + for i=1,#listPoints do + if(listPoints[i].type == "bbox") then + output = output .. "drawdot (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;" + else + output = output .. "drawdot (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor ;" + end + end + end + return output +end + + -- buildMesh with TikZ function buildMeshTikZ(chaine,mode,points,bbox,full,scale,color) @@ -323,6 +351,29 @@ function buildMeshMPBW(chaine,mode,points,bbox,scale) tex.sprint(output) end +-- print points to mesh +function printPointsMP(chaine,mode,points,bbox,scale) + listPoints = buildList(chaine, mode) + if(bbox == "bbox" ) then + listPoints = buildBoundingBox(listPoints) + end + output = tracePointsMP(listPoints,points) + output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale.. ";" .. output .."endfig;\\end{mplibcode}" + tex.sprint(output) +end + + +-- print points to mesh +function printPointsMPinc(chaine,beginning, ending, mode,points,bbox,scale) + listPoints = buildList(chaine, mode) + if(bbox == "bbox" ) then + listPoints = buildBoundingBox(listPoints) + end + output = tracePointsMP(listPoints,points) + output = "\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}" + tex.sprint(output) +end + -- buildMesh with MP include code function buildMeshMPBWinc(chaine,beginning, ending,mode,points,bbox,scale) diff --git a/luamesh.sty b/luamesh.sty index 081cf5a..ccb1863 100644 --- a/luamesh.sty +++ b/luamesh.sty @@ -159,6 +159,129 @@ \fi% }% % +%%%%%%%%%%%%%%%%% the trace Points macro +%% engine of drawing +\newif\ifluameshengineMP% +\define@boolkey{tracePoints}{tikz}[true]{}% +%% show the bounding box for delaunay +\define@choicekey*{tracePoints}{bbox}[\val\nr]{none, show}{% + \ifcase\nr\relax% + \def\luameshval@tp@bbox{none}% + \or% + \def\luameshval@tp@bbox{bbox}% + \fi% +}% +%% the scale +\define@key{tracePoints}{scale}[1cm]{\def\luameshval@tp@scale{#1}}% +%% print points +\define@choicekey*{tracePoints}{print}[\val\nr]{none, points}{% + \ifcase\nr\relax% + \def\luameshval@tp@print{none}% + \or% + \def\luameshval@tp@print{points}% + \fi% +}% +%% the name of the point +\define@key{tracePoints}{meshpoint}[P]{\def\luameshval@tp@meshpoint{#1}}% +%% the mode for reading the points +\define@choicekey*{tracePoints}{mode}[\val\nr]{int, ext}{% + \ifcase\nr\relax% + \def\luameshval@tp@mode{int}% + \or% + \def\luameshval@tp@mode{ext}% + \fi% +}% +% +% color +%% the name of the color of drawing +\define@key{tracePoints}{color}[black]{\def\luameshval@tp@color{#1}}% +%% the name of the color of drawing the bbox +\define@key{tracePoints}{colorBbox}[black]{\def\luameshval@tp@colorbbox{#1}}% +% +\presetkeys{tracePoints}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}% +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% the difinition BW Bowyer and Watson algo +\newcommand{\tracePointsMesh}[2][]{% + % #1 : the string containing the list of points + % (x1,y1);(x2,y2);... or the name file containing the points + \setkeys{tracePoints}{#1} % + \def\MeshPoint{\luameshval@tp@meshpoint}% + \ifKV@buildMesh@tikz% if we are using tikz + \directlua{% + % buildMeshTikZ("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","full","\luameshval@tp@scale","\luameshval@tp@color")% + }% + \else % we are using MP + \mplibcolor{\luameshmpcolor}{\luameshval@tp@color} + \mplibcolor{\luameshmpcolorBbox}{\luameshval@tp@colorbbox} + \directlua{% + printPointsMP("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale")% + }% + % + \fi% +}% +% + +%%%%%%%%%%%%%%%% the trace Points macro inc +%% engine of drawing +\newif\ifluameshengineMP% +\define@boolkey{tracePointsInc}{tikz}[true]{}% +%% show the bounding box for delaunay +\define@choicekey*{tracePointsInc}{bbox}[\val\nr]{none, show}{% + \ifcase\nr\relax% + \def\luameshval@tp@bbox{none}% + \or% + \def\luameshval@tp@bbox{bbox}% + \fi% +}% +%% the scale +\define@key{tracePointsInc}{scale}[1cm]{\def\luameshval@tp@scale{#1}}% +%% print points +\define@choicekey*{tracePointsInc}{print}[\val\nr]{none, points}{% + \ifcase\nr\relax% + \def\luameshval@tp@print{none}% + \or% + \def\luameshval@tp@print{points}% + \fi% +}% +%% the name of the point +\define@key{tracePointsInc}{meshpoint}[P]{\def\luameshval@tp@meshpoint{#1}}% +%% the mode for reading the points +\define@choicekey*{tracePointsInc}{mode}[\val\nr]{int, ext}{% + \ifcase\nr\relax% + \def\luameshval@tp@mode{int}% + \or% + \def\luameshval@tp@mode{ext}% + \fi% +}% +% +% color +%% the name of the color of drawing +\define@key{tracePointsInc}{color}[black]{\def\luameshval@tp@color{#1}}% +%% the name of the color of drawing the bbox +\define@key{tracePointsInc}{colorBbox}[black]{\def\luameshval@tp@colorbbox{#1}}% +% +\presetkeys{tracePointsInc}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}% +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% the difinition BW Bowyer and Watson algo +\newcommand*{\tracePointsMeshinc}[4][]{% + % #1 : the string containing the list of points + % (x1,y1);(x2,y2);... or the name file containing the points + \setkeys{tracePointsInc}{#1} % + \def\MeshPoint{\luameshval@tp@meshpoint}% + \ifKV@tracePointsInc@tikz% if we are using tikz + \directlua{% + buildMeshTikZ("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","full","\luameshval@tp@sc%ale","\luameshval@tp@color")% + }% + \else % we are using MP + \mplibcolor{\luameshmpcolor}{\luameshval@tp@color} + \mplibcolor{\luameshmpcolorBbox}{\luameshval@tp@colorbbox} + \directlua{% + printPointsMPinc("#2","#3","#4","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale")% + }% + \fi% +}% % % %% diff --git a/test/animation-crop.pdf b/test/animation-crop.pdf index 8aeb3f0..1167450 100644 Binary files a/test/animation-crop.pdf and b/test/animation-crop.pdf differ diff --git a/test/animation.pdf b/test/animation.pdf index d437093..5f3dd51 100644 Binary files a/test/animation.pdf and b/test/animation.pdf differ diff --git a/test/animation.tex b/test/animation.tex index d47832a..aa5c29c 100644 --- a/test/animation.tex +++ b/test/animation.tex @@ -8,8 +8,27 @@ \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} +\tracePointsMeshinc[ +mode=ext, +bbox = show, +colorBbox = blue!20, +print=points +] +{mesh.txt}% +{% + beginfig(0); + \drawPath +}% +{% + \clipPath + endfig; +} + +\newpage + \buildMeshBWinc[ mode=ext, bbox = show,