X-Git-Url: https://melusine.eu.org/syracuse/G/git/?p=delaunay.git;a=blobdiff_plain;f=luamesh-tex.lua;h=528b6a4838f51a746f04f661d02c522f0471ce46;hp=56b635c5e3cfe9dde2d26dcf2b0755745eec0ee4;hb=69d738f58952eaf2e69da5817f9c7ab8c81a68c1;hpb=d40b2486ba6be29e1e905d3b55dc7199af2abe8a diff --git a/luamesh-tex.lua b/luamesh-tex.lua index 56b635c..528b6a4 100644 --- a/luamesh-tex.lua +++ b/luamesh-tex.lua @@ -209,6 +209,17 @@ function traceMeshTikZ(listPoints, triangulation,points,color,colorBbox) end end end + if(points=="dotpoints") then + j=1 + for i=1,#listPoints do + if(listPoints[i].type == "bbox") then + output = output .. "\\draw[color="..colorBbox.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$};" + j=j+1 + else + output = output .. "\\draw[color="..color.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$};" + end + end + end return output end @@ -811,11 +822,6 @@ end -- Meshing of a polygon -- -------------------------------------------------- - -function TeXMeshPolygonMP(polygon,listPoints, grid, step) - -end - function tracePolygonMP(polygon,points) output = ""; output = output .. "pair polygon[];" @@ -841,6 +847,30 @@ function tracePolygonMP(polygon,points) end +function tracePolygonTikZ(polygon,points, colorPoly) + output = ""; + for i=1,#polygon do + output = output .. "\\coordinate (polygon".. i .. ") at (" .. polygon[i].x .. "," .. polygon[i].y .. ");" + end + output = output .. "\\draw[color=".. colorPoly .. ", thick]" + for i=1,#polygon do + output = output .. "(" .. polygon[i].x .. "," .. polygon[i].y .. ") -- " + end + output = output .. "cycle;" + if(points=="points") then + for i=1,#polygon do + output = output .. "\\draw[color="..colorPoly.."] (" .. polygon[i].x ..",".. polygon[i].y .. ") node {$\\bullet$} node[anchor=north east] {$\\MeshPoint_{" .. i .. "}$};" + end + end + if(points=="dotpoints") then + for i=1,#polygon do + output = output .. "\\draw[color="..colorPoly.."] (" .. polygon[i].x ..",".. polygon[i].y .. ") node {$\\bullet$};" + end + end + return output +end + + function drawMeshPolygonMP(chaine,mode,h,step, points,scale) @@ -872,3 +902,35 @@ function drawMeshPolygonMP(chaine,mode,h,step, output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale.. ";" .. output .."endfig;\\end{mplibcode}" tex.sprint(output) end + + + +function drawMeshPolygonTikZ(chaine,mode,h,step, + points,scale,color,colorPoly) + local polygon = buildList(chaine, mode) + polygon = addPointsPolygon(polygon,h) + local grid = buildGrid(polygon,h) + local listPoints = addGridPoints(polygon,grid,h) + if(step=="polygon") then + -- the polygon + output = tracePolygonTikZ(polygon,points,colorPoly) + end + if(step=="grid") then + -- polygon + grid + output = tracePointsTikZ(grid,points,color,"none") -- none for colorBbox + output = output .. tracePolygonTikZ(polygon,points,colorPoly) + end + if(step=="points") then + -- polygon + only grid points inside the polygon + output = tracePointsTikZ(listPoints,points,color,"none") + output = output .. tracePolygonTikZ(polygon,points,colorPoly) + end + if(step=="mesh") then + -- polygon + mesh + triangulation = BowyerWatson(listPoints,"none") -- no bbox + output = traceMeshTikZ(listPoints,triangulation,points,color,"none") + output = output .. tracePolygonTikZ(polygon,points,colorPoly) + end + output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" .. output .."\\end{tikzpicture}" + tex.sprint(output) +end