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
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