X-Git-Url: https://melusine.eu.org/syracuse/G/git/?p=delaunay.git;a=blobdiff_plain;f=luamesh-tex.lua;h=158163883590f029a0812503500a800d7a052785;hp=f3c06ab611621ed6d421a0e75b133d26c4002cd4;hb=fe3a5df51411d6ea20f72115641db9bc7d19a466;hpb=7bc85345ad42b4b24478accec113804862650422 diff --git a/luamesh-tex.lua b/luamesh-tex.lua index f3c06ab..1581638 100644 --- a/luamesh-tex.lua +++ b/luamesh-tex.lua @@ -241,6 +241,17 @@ function traceMeshMP(listPoints, triangulation,points) end end end + if(points=="dotpoints") then + j=1 + for i=1,#listPoints do + if(listPoints[i].type == "bbox") then + output = output .. "drawdot (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u withcolor \\luameshmpcolorBbox withpen pencircle scaled 3;" + j=j+1 + else + output = output .. "drawdot (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u withcolor \\luameshmpcolor withpen pencircle scaled 3;" + end + end + end return output end @@ -788,3 +799,74 @@ function gmshVoronoiTikZinc(file,beginning, ending,points,scale,tri,color,colorV output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" ..beginning.. output..ending .."\\end{tikzpicture}" tex.sprint(output) end + + +-------------------------------------------------- +-- Meshing of a polygon -- +-------------------------------------------------- + + +function TeXMeshPolygonMP(polygon,listPoints, grid, step) + +end + +function tracePolygonMP(polygon,points) + output = ""; + output = output .. "pair polygon[];" + print(#polygon) + for i=1,#polygon do + output = output .. "polygon[".. i .. "] = (" .. polygon[i].x .. "," .. polygon[i].y .. ")*u;" + end + output = output .. "draw " + for i=1,#polygon do + output = output .. "(" .. polygon[i].x .. "," .. polygon[i].y .. ")*u -- " + end + output = output .. "cycle withcolor \\luameshmpcolorPoly withpen pencircle scaled 1pt;" + if(points=="points") then + for i=1,#polygon do + output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. polygon[i].x ..",".. polygon[i].y .. ")*u ) withcolor \\luameshmpcolorPoly ;" + end + end + if(points=="dotpoints") then + for i=1,#polygon do + output = output .. "drawdot (" .. polygon[i].x ..",".. polygon[i].y .. ")*u withcolor \\luameshmpcolorPoly withpen pencircle scaled 3;" + end + end + return output +end + + + +function drawMeshPolygonMP(chaine,mode,h,step, + points,scale) + local polygon = buildList(chaine, mode) + polygon = addPointsPolygon(polygon,h) + print(#polygon) + local grid = buildGrid(polygon,h) + print(#polygon) + local listPoints = addGridPoints(polygon,grid,h) + print(#polygon) + if(step=="polygon") then + -- the polygon + output = tracePolygonMP(polygon,points) + end + if(step=="grid") then + -- polygon + grid + output = tracePointsMP(grid,points) + output = output .. tracePolygonMP(polygon,points) + end + if(step=="points") then + -- polygon + only grid points inside the polygon + output = tracePointsMP(listPoints,points) + output = output .. tracePolygonMP(polygon,points) + end + if(step=="mesh") then + -- polygon + mesh + triangulation = BowyerWatson(listPoints,"none") -- no bbox + output = traceMeshMP(listPoints,triangulation,points) + output = output .. tracePolygonMP(polygon,points) + end + + output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale.. ";" .. output .."endfig;\\end{mplibcode}" + tex.sprint(output) +end