Séparation en trois fichiers lua, et fonction d'ajout de points d'une grille à l...
authorMaxime Chupin (escudo) <chupin@fougeriens.org>
Tue, 7 Feb 2017 22:33:43 +0000 (23:33 +0100)
committerMaxime Chupin (escudo) <chupin@fougeriens.org>
Tue, 7 Feb 2017 22:33:43 +0000 (23:33 +0100)
doc/luamesh-doc.pdf
luamesh-polygon.lua [moved from polygon-luamesh.lua with 99% similarity]
luamesh-tex.lua [new file with mode: 0644]
luamesh.lua
test/delaunay.pdf
test/luamesh-polygon.lua [new symlink]
test/luamesh-tex.lua [new symlink]
test/polygon-luamesh.lua [deleted symlink]
test/test.lua

index f0cb2d5..0a56ba0 100644 (file)
Binary files a/doc/luamesh-doc.pdf and b/doc/luamesh-doc.pdf differ
similarity index 99%
rename from polygon-luamesh.lua
rename to luamesh-polygon.lua
index 555ccc6..2c14268 100644 (file)
@@ -70,7 +70,6 @@ function isInside(listPoints,p)
          -- If the point 'p' is colinear with line segment 'i-ip',
          -- then check if it lies on segment. If it lies, return true,
          -- otherwise false
-         print("coucou")
          if (orientation(listPoints[i], p, listPoints[ip]) == 0) then
             return onSegment(listPoints[i], p, listPoints[ip])
          end
diff --git a/luamesh-tex.lua b/luamesh-tex.lua
new file mode 100644 (file)
index 0000000..f3c06ab
--- /dev/null
@@ -0,0 +1,790 @@
+-- trace Voronoi with MP
+function traceVoronoiMP(listPoints, triangulation,listVoronoi, points, tri,styleD,styleV)
+   if(styleD == "dashed") then
+      sDelaunay = "dashed evenly"
+   else
+      sDelaunay = ""
+   end
+   if(styleV == "dashed") then
+      sVoronoi = "dashed evenly"
+   else
+      sVoronoi = ""
+   end
+   listCircumC = listCircumCenter(listPoints,triangulation)
+   output = "";
+   output = output .. " pair MeshPoints[];"
+   for i=1,#listPoints do
+      output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ")*u;"
+   end
+   output = output .. " pair CircumCenters[];"
+   for i=1,#listCircumC do
+      output = output .. "CircumCenters[".. i .. "] = (" .. listCircumC[i].x .. "," .. listCircumC[i].y .. ")*u;"
+   end
+   if(tri=="show") then
+      for i=1,#triangulation do
+         PointI = listPoints[triangulation[i][1]]
+         PointJ = listPoints[triangulation[i][2]]
+         PointK = listPoints[triangulation[i][3]]
+         if(triangulation[i].type == "bbox") then
+            output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle "..sDelaunay.." withcolor \\luameshmpcolorBbox;"
+         else
+            output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle "..sDelaunay.." withcolor \\luameshmpcolor;"
+         end
+      end
+   end
+   for i=1,#listVoronoi do
+      PointI = listCircumC[listVoronoi[i][1]]
+      PointJ = listCircumC[listVoronoi[i][2]]
+      output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u "..sVoronoi.." withcolor \\luameshmpcolorVoronoi;"
+   end
+   if(points=="points") then
+      j=1
+      for i=1,#listPoints do
+         if(listPoints[i].type == "bbox") then
+            output = output .. "dotlabel.llft (btex $\\MeshPoint^{*}_{"..j.."}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
+            j=j+1
+         else
+            output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor ;"
+         end
+      end
+      for i=1,#listCircumC do
+         output = output .. "dotlabel.llft (btex $\\CircumPoint_{" .. i .. "}$ etex, (" .. listCircumC[i].x ..",".. listCircumC[i].y .. ")*u ) withcolor \\luameshmpcolorVoronoi ;"
+      end
+   else
+      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
+      for i=1,#listCircumC do
+         output = output .. "drawdot  (" .. listCircumC[i].x ..",".. listCircumC[i].y .. ")*u  withcolor \\luameshmpcolorVoronoi withpen pencircle scaled 3;"
+      end
+   end
+
+   return output
+end
+
+
+-- trace Voronoi with TikZ
+function traceVoronoiTikZ(listPoints, triangulation,listVoronoi, points, tri,color,colorBbox,colorVoronoi,styleD,styleV)
+   if(styleD == "dashed") then
+      sDelaunay = ",dashed"
+   else
+      sDelaunay = ""
+   end
+   if(styleV == "dashed") then
+      sVoronoi = ",dashed"
+   else
+      sVoronoi = ""
+   end
+   listCircumC = listCircumCenter(listPoints,triangulation)
+    output = ""
+   for i=1,#listPoints do
+      output = output .. "\\coordinate (MeshPoints".. i .. ") at  (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");"
+   end
+   for i=1,#listCircumC do
+      output = output .. "\\coordinate (CircumPoints".. i .. ") at  (" .. listCircumC[i].x .. "," .. listCircumC[i].y .. ");"
+   end
+   if(tri=="show") then
+      for i=1,#triangulation do
+         PointI = listPoints[triangulation[i][1]]
+         PointJ = listPoints[triangulation[i][2]]
+         PointK = listPoints[triangulation[i][3]]
+         if(triangulation[i].type == "bbox") then
+            output = output .. "\\draw[color="..colorBbox..sDelaunay.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
+         else
+            output = output .. "\\draw[color="..color..sDelaunay.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
+         end
+      end
+   end
+   for i=1,#listVoronoi do
+      PointI = listCircumC[listVoronoi[i][1]]
+      PointJ = listCircumC[listVoronoi[i][2]]
+      output = output .. "\\draw[color="..colorVoronoi..sVoronoi.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..");"
+   end
+   if(points=="points") 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$} node[anchor=north east] {$\\MeshPoint^*_{" .. j .. "}$};"
+            j=j+1
+         else
+            output = output .. "\\draw[color="..color.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$} node[anchor=north east] {$\\MeshPoint_{" .. i .. "}$};"
+         end
+      end
+      for i=1,#listCircumC do
+         output = output .. "\\draw[color="..colorVoronoi.."] (" .. listCircumC[i].x ..",".. listCircumC[i].y .. ") node {$\\bullet$} node[anchor=north east] {$\\CircumPoint_{" .. i .. "}$};"
+      end
+   else
+      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
+      for i=1,#listCircumC do
+         output = output .. "\\draw[color="..colorVoronoi.."] (" .. listCircumC[i].x ..",".. listCircumC[i].y .. ") node {$\\bullet$};"
+      end
+   end
+   return output
+end
+
+
+
+-- buildVoronoi with MP
+function buildVoronoiMPBW(chaine,mode,points,bbox,scale,tri,styleD,styleV)
+   listPoints = buildList(chaine, mode)
+   triangulation = BowyerWatson(listPoints,bbox)
+   listVoronoi = buildVoronoi(listPoints, triangulation)
+   output = traceVoronoiMP(listPoints,triangulation,listVoronoi,points,tri,styleD,styleV)
+   output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale.. ";" .. output .."endfig;\\end{mplibcode}"
+   tex.sprint(output)
+end
+
+
+-- buildVoronoi with TikZ
+function buildVoronoiTikZBW(chaine,mode,points,bbox,scale,tri,color,colorBbox,colorVoronoi,styleD,styleV)
+   listPoints = buildList(chaine, mode)
+   triangulation = BowyerWatson(listPoints,bbox)
+   listVoronoi = buildVoronoi(listPoints, triangulation)
+   output = traceVoronoiTikZ(listPoints,triangulation,listVoronoi,points,tri,color,colorBbox,colorVoronoi,styleD,styleV)
+   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" .. output .."\\end{tikzpicture}"   tex.sprint(output)
+end
+
+
+-- buildVoronoi with MP
+function buildVoronoiMPBWinc(chaine,beginning, ending,mode,points,bbox,scale,tri,styleD,styleV)
+   listPoints = buildList(chaine, mode)
+   triangulation = BowyerWatson(listPoints,bbox)
+   listVoronoi = buildVoronoi(listPoints, triangulation)
+   output = traceVoronoiMP(listPoints,triangulation,listVoronoi,points,tri,styleD,styleV)
+   output = "\\leavevmode\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}"
+   tex.sprint(output)
+end
+
+
+-- buildVoronoi with TikZ
+function buildVoronoiTikZBWinc(chaine,beginning, ending,mode,points,bbox,scale,tri,color,colorBbox,colorVoronoi)
+   listPoints = buildList(chaine, mode,styleD,styleV)
+   triangulation = BowyerWatson(listPoints,bbox)
+   listVoronoi = buildVoronoi(listPoints, triangulation)
+   output = traceVoronoiTikZ(listPoints,triangulation,listVoronoi,points,tri,color,colorBbox,colorVoronoi,styleD,styleV)
+   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" ..beginning.. output..ending .."\\end{tikzpicture}"
+   tex.sprint(output)
+end
+
+
+
+-- trace a triangulation with TikZ
+function traceMeshTikZ(listPoints, triangulation,points,color,colorBbox)
+   output = ""
+   for i=1,#listPoints do
+      output = output .. "\\coordinate (MeshPoints".. i .. ") at  (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");"
+   end
+   for i=1,#triangulation do
+      PointI = listPoints[triangulation[i][1]]
+      PointJ = listPoints[triangulation[i][2]]
+      PointK = listPoints[triangulation[i][3]]
+      if(triangulation[i].type == "bbox") then
+         output = output .. "\\draw[color="..colorBbox.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
+      else
+         output = output .. "\\draw[color="..color.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
+      end
+   end
+   if(points=="points") 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$} node[anchor=north east] {$\\MeshPoint^*_{" .. j .. "}$};"
+            j=j+1
+         else
+            output = output .. "\\draw[color="..color.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$} node[anchor=north east] {$\\MeshPoint_{" .. i .. "}$};"
+         end
+      end
+   end
+   return output
+end
+
+
+-- trace a triangulation with MP
+function traceMeshMP(listPoints, triangulation,points)
+   output = "";
+   output = output .. " pair MeshPoints[];"
+   for i=1,#listPoints do
+      output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ")*u;"
+   end
+   for i=1,#triangulation do
+      PointI = listPoints[triangulation[i][1]]
+      PointJ = listPoints[triangulation[i][2]]
+      PointK = listPoints[triangulation[i][3]]
+      if(triangulation[i].type == "bbox") then
+         output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolorBbox;"
+      else
+         output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolor;"
+      end
+   end
+   if(points=="points") then
+      j=1
+      for i=1,#listPoints do
+         if(listPoints[i].type == "bbox") then
+            output = output .. "dotlabel.llft (btex $\\MeshPoint^{*}_{"..j.."}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
+            j=j+1
+         else
+            output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor ;"
+         end
+      end
+   end
+   return output
+end
+
+
+-- buildMesh with MP
+function buildMeshMPBW(chaine,mode,points,bbox,scale)
+   listPoints = buildList(chaine, mode)
+   triangulation = BowyerWatson(listPoints,bbox)
+   output = traceMeshMP(listPoints, triangulation,points)
+   output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale.. ";" .. output .."endfig;\\end{mplibcode}"
+   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 = "\\leavevmode\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}"
+   tex.sprint(output)
+end
+
+-- buildMesh with TikZ
+function buildMeshTikZBW(chaine,mode,points,bbox,scale,color,colorBbox)
+   listPoints = buildList(chaine, mode)
+   triangulation = BowyerWatson(listPoints,bbox)
+   output = traceMeshTikZ(listPoints, triangulation,points,color,colorBbox)
+   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" .. output .."\\end{tikzpicture}"
+   tex.sprint(output)
+end
+
+-- buildMesh with TikZ
+function buildMeshTikZBWinc(chaine,beginning, ending,mode,points,bbox,scale,color,colorBbox)
+   listPoints = buildList(chaine, mode)
+   triangulation = BowyerWatson(listPoints,bbox)
+   output = traceMeshTikZ(listPoints, triangulation,points,color,colorBbox)
+   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" ..beginning.. output..ending .."\\end{tikzpicture}"
+   tex.sprint(output)
+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 .. ")*u;"
+   end
+   if(points=="points") then
+      j=1
+      for i=1,#listPoints do
+         if(listPoints[i].type == "bbox") then
+            output = output .. "dotlabel.llft (btex $\\MeshPoint^{*}_{" .. j .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
+            j=j+1
+         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 withpen pencircle scaled 3;"
+         else
+            output = output .. "drawdot (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u  withcolor \\luameshmpcolor withpen pencircle scaled 3;"
+         end
+      end
+   end
+   return output
+end
+
+-- print points of the mesh
+function tracePointsTikZ(listPoints,points,color,colorBbox)
+   output = "";
+   for i=1,#listPoints do
+      output = output .. "\\coordinate (MeshPoints".. i .. ") at  (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");"
+   end
+   if(points=="points") 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$} node[anchor=north east] {$\\MeshPoint^*_{" .. j .. "}$};"
+            j = j+1
+         else
+            output = output .. "\\draw[color="..color.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$} node[anchor=north east] {$\\MeshPoint_{" .. i .. "}$};"
+         end
+      end
+   else
+      for i=1,#listPoints do
+         if(listPoints[i].type == "bbox") then
+            output = output .. "\\draw[color="..colorBbox.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$} ;"
+         else
+            output = output .. "\\draw[color="..color.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$} ;"
+         end
+      end
+   end
+   return 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 = "\\leavevmode\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}"
+   tex.sprint(output)
+end
+
+-- print points to mesh
+function printPointsTikZ(chaine,mode,points,bbox,scale,color,colorBbox)
+   listPoints = buildList(chaine, mode)
+   if(bbox == "bbox" ) then
+      listPoints = buildBoundingBox(listPoints)
+   end
+   output = tracePointsTikZ(listPoints,points,color,colorBbox)
+   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" .. output .."\\end{tikzpicture}"
+   tex.sprint(output)
+end
+
+
+-- print points to mesh
+function printPointsTikZinc(chaine,beginning, ending, mode,points,bbox,scale,color,colorBbox)
+   listPoints = buildList(chaine, mode)
+   if(bbox == "bbox" ) then
+      listPoints = buildBoundingBox(listPoints)
+   end
+   output = tracePointsTikZ(listPoints,points,color,colorBbox)
+   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" ..beginning.. output..ending .."\\end{tikzpicture}"
+   tex.sprint(output)
+end
+
+
+-- buildMesh
+function buildRect(largeur,a,b,nbrA, nbrB)
+   listPoints = rectangleList(a,b,nbrA,nbrB)
+   triangulation = BowyerWatson(listPoints,"none")
+   traceTikZ(listPoints, triangulation,largeur,"none")
+end
+
+
+--
+function TeXaddOnePointTikZ(listPoints,P,step,bbox,color,colorBack, colorNew, colorCircle,colorBbox)
+   output = ""
+   -- build the triangulation
+   triangulation = BowyerWatson(listPoints,bbox)
+   badTriangles = buildBadTriangles(P,triangulation)
+   for i=1,#listPoints do
+      output = output .. "\\coordinate (MeshPoints".. i .. ") at  (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");"
+   end
+   if(step == "badT") then
+      -- draw all triangle
+      for i=1,#triangulation do
+         PointI = listPoints[triangulation[i][1]]
+         PointJ = listPoints[triangulation[i][2]]
+         PointK = listPoints[triangulation[i][3]]
+         if(triangulation[i].type == "bbox") then
+            output = output .. "\\draw[color="..colorBbox.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
+         else
+            output = output .. "\\draw[color="..color.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
+         end
+      end
+      -- draw and fill the bad triangle
+      for i=1,#badTriangles do
+         PointI = listPoints[triangulation[badTriangles[i]][1]]
+         PointJ = listPoints[triangulation[badTriangles[i]][2]]
+         PointK = listPoints[triangulation[badTriangles[i]][3]]
+         output = output .. "\\draw[fill="..colorBack.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
+      end
+      -- draw the circoncircle
+      for i=1,#badTriangles do
+         PointI = listPoints[triangulation[badTriangles[i]][1]]
+         PointJ = listPoints[triangulation[badTriangles[i]][2]]
+         PointK = listPoints[triangulation[badTriangles[i]][3]]
+         center, radius = circoncircle(PointI, PointJ, PointK)
+         output = output .. "\\draw[dashed, color="..colorCircle.."] ("..center.x .. "," .. center.y .. ") circle ("..radius ..");"
+      end
+      -- mark the points
+      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$} node[anchor=north east] {$\\MeshPoint^*_{" .. j .. "}$};"
+            j = j+1
+         else
+            output = output .. "\\draw[color="..color.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$} node[anchor=north east] {$\\MeshPoint_{" .. i .. "}$};"
+         end
+      end
+      -- mark the point to add
+      output = output .. "\\draw[color="..colorNew.."] (" .. P.x ..",".. P.y .. ") node {$\\bullet$} node[anchor=north east] {$\\NewPoint$};"
+   elseif(step == "cavity") then
+      polygon = buildCavity(badTriangles, triangulation)
+      polyNew = cleanPoly(polygon)
+      -- remove the bad triangles
+      for j=1,#badTriangles do
+         table.remove(triangulation,badTriangles[j]-(j-1))
+      end
+      -- draw the triangles
+      for i=1,#triangulation do
+         PointI = listPoints[triangulation[i][1]]
+         PointJ = listPoints[triangulation[i][2]]
+         PointK = listPoints[triangulation[i][3]]
+         if(triangulation[i].type == "bbox") then
+            output = output .. "\\draw[color="..colorBbox.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
+         else
+            output = output .. "\\draw[color="..color.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
+         end
+      end
+      -- fill and draw the cavity
+      path = ""
+      for i=1,#polyNew do
+         PointI = listPoints[polyNew[i]]
+         path = path .. "(".. PointI.x ..",".. PointI.y ..")--"
+      end
+      output = output .. "\\draw[color="..colorNew..",fill ="..colorBack..", thick] " .. path .. "cycle;"
+      -- mark the points of the mesh
+      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$} node[anchor=north east] {$\\MeshPoint^*_{" .. j .. "}$};"
+            j=j+1
+         else
+            output = output .. "\\draw[color="..color.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$} node[anchor=north east] {$\\MeshPoint_{" .. i .. "}$};"
+         end
+      end
+      -- mark the adding point
+      output = output .. "\\draw[color="..colorNew.."] (" .. P.x ..",".. P.y .. ") node {$\\bullet$} node[anchor=north east] {$\\NewPoint$};"
+   elseif(step == "newT") then
+      polygon = buildCavity(badTriangles, triangulation)
+      polyNew = cleanPoly(polygon)
+      -- remove the bad triangles
+      for j=1,#badTriangles do
+         table.remove(triangulation,badTriangles[j]-(j-1))
+      end
+      -- draw the triangle of the triangulation
+      for i=1,#triangulation do
+         PointI = listPoints[triangulation[i][1]]
+         PointJ = listPoints[triangulation[i][2]]
+         PointK = listPoints[triangulation[i][3]]
+         if(triangulation[i].type == "bbox") then
+            output = output .. "\\draw[color="..colorBbox.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
+         else
+            output = output .. "\\draw[color="..color.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
+         end
+      end
+      -- fill and draw the cavity
+      path = ""
+      for i=1,#polyNew do
+         PointI = listPoints[polyNew[i]]
+         path = path .. "(".. PointI.x ..",".. PointI.y ..")--"
+      end
+      output = output .. "\\draw[color="..colorNew..",fill ="..colorBack..", thick] " .. path .. "cycle;"
+      -- draw the new triangles composed by the edges of the polygon and the added point
+      for i=1,#polygon do
+         output = output .. "\\draw[color=TeXCluaMeshNewTikZ, thick]".."(".. listPoints[polygon[i][1]].x .. "," .. listPoints[polygon[i][1]].y .. ") -- (" .. listPoints[polygon[i][2]].x .. "," .. listPoints[polygon[i][2]].y ..");"
+         output = output .. "\\draw[color="..colorNew..", thick]".."(".. listPoints[polygon[i][1]].x .. "," .. listPoints[polygon[i][1]].y .. ") -- (" .. P.x .. "," .. P.y ..");"
+         output = output .. "\\draw[color="..colorNew..", thick]".."(".. listPoints[polygon[i][2]].x .. "," .. listPoints[polygon[i][2]].y .. ") -- (" .. P.x .. "," .. P.y ..");"
+      end
+      -- mark points
+      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$} node[anchor=north east] {$\\MeshPoint^*_{" .. j .. "}$};"
+            j=j+1
+         else
+            output = output .. "\\draw[color="..color.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$} node[anchor=north east] {$\\MeshPoint_{" .. i .. "}$};"
+         end
+      end
+      -- mark the added point
+      output = output .. "\\draw[color="..colorNew.."] (" .. P.x ..",".. P.y .. ") node {$\\bullet$} node[anchor=north east] {$\\NewPoint$};"
+   end
+   return output
+end
+
+function TeXaddOnePointMPBW(listPoints,P,step,bbox)
+   output = "";
+   output = output .. "pair MeshPoints[];"
+   -- build the triangulation
+   triangulation = BowyerWatson(listPoints,bbox)
+   badTriangles = buildBadTriangles(P,triangulation)
+   for i=1,#listPoints do
+      output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ")*u;"
+   end
+   if(step == "badT") then
+      -- draw all triangle
+      for i=1,#triangulation do
+         PointI = listPoints[triangulation[i][1]]
+         PointJ = listPoints[triangulation[i][2]]
+         PointK = listPoints[triangulation[i][3]]
+         if(triangulation[i].type == "bbox") then
+            output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolorBbox;"
+         else
+            output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolor;"
+         end
+      end
+      -- draw and fill the bad triangle
+      for i=1,#badTriangles do
+         PointI = listPoints[triangulation[badTriangles[i]][1]]
+         PointJ = listPoints[triangulation[badTriangles[i]][2]]
+         PointK = listPoints[triangulation[badTriangles[i]][3]]
+         output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolor;"
+         output = output .. "fill (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolorBack;"
+      end
+      -- draw the circoncircle
+      for i=1,#badTriangles do
+         PointI = listPoints[triangulation[badTriangles[i]][1]]
+         PointJ = listPoints[triangulation[badTriangles[i]][2]]
+         PointK = listPoints[triangulation[badTriangles[i]][3]]
+         center, radius = circoncircle(PointI, PointJ, PointK)
+         output = output .. "draw fullcircle scaled ("..radius .."*2u) shifted ("..center.x .. "*u," .. center.y .. "*u) dashed evenly withcolor \\luameshmpcolorCircle;"
+      end
+      -- mark the points
+      j=1
+      for i=1,#listPoints do
+         if(listPoints[i].type == "bbox") then
+            output = output .. "dotlabel.llft (btex $\\MeshPoint^{*}_{" .. j .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
+            j=j+1
+         else
+            output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor ;"
+         end
+      end
+      -- mark the point to add
+      output = output .. "dotlabel.llft (btex $\\NewPoint$ etex,(" .. P.x ..",".. P.y .. ")*u) withcolor \\luameshmpcolorNew;"
+   elseif(step == "cavity") then
+      polygon = buildCavity(badTriangles, triangulation)
+      polyNew = cleanPoly(polygon)
+      -- remove the bad triangles
+      for j=1,#badTriangles do
+         table.remove(triangulation,badTriangles[j]-(j-1))
+      end
+      -- draw the triangles
+      for i=1,#triangulation do
+         PointI = listPoints[triangulation[i][1]]
+         PointJ = listPoints[triangulation[i][2]]
+         PointK = listPoints[triangulation[i][3]]
+         if(triangulation[i].type == "bbox") then
+            output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolorBbox;"
+         else
+            output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolor;"
+         end
+      end
+      -- fill and draw the cavity
+      path = ""
+      for i=1,#polyNew do
+         PointI = listPoints[polyNew[i]]
+         path = path .. "(".. PointI.x ..",".. PointI.y ..")*u--"
+      end
+      output = output .. "fill " .. path .. "cycle withcolor \\luameshmpcolorBack;"
+      output = output .. "draw " .. path .. "cycle withcolor \\luameshmpcolorNew  withpen pencircle scaled 1pt;"
+      -- mark the points of the mesh
+      j=1
+      for i=1,#listPoints do
+         if(listPoints[i].type == "bbox") then
+            output = output .. "dotlabel.llft (btex $\\MeshPoint^{*}_{" .. j .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
+            j=j+1
+         else
+            output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor ;"
+         end
+      end
+      -- mark the adding point
+      output = output .. "dotlabel.llft (btex $\\NewPoint$ etex,(" .. P.x ..",".. P.y .. ")*u) withcolor \\luameshmpcolorNew ;"
+   elseif(step == "newT") then
+      polygon = buildCavity(badTriangles, triangulation)
+      polyNew = cleanPoly(polygon)
+      -- remove the bad triangles
+      for j=1,#badTriangles do
+         table.remove(triangulation,badTriangles[j]-(j-1))
+      end
+      -- draw the triangle of the triangulation
+      for i=1,#triangulation do
+         PointI = listPoints[triangulation[i][1]]
+         PointJ = listPoints[triangulation[i][2]]
+         PointK = listPoints[triangulation[i][3]]
+         if(triangulation[i].type == "bbox") then
+            output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolorBbox;"
+         else
+            output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolor;"
+         end
+      end
+      -- fill  the cavity
+      path = ""
+      for i=1,#polyNew do
+         PointI = listPoints[polyNew[i]]
+         path = path .. "(".. PointI.x ..",".. PointI.y ..")*u--"
+      end
+      output = output .. "fill " .. path .. "cycle withcolor \\luameshmpcolorBack;"
+      -- draw the new triangles composed by the edges of the polygon and the added point
+      for i=1,#polygon do
+         output = output .. "draw".."(".. listPoints[polygon[i][1]].x .. "," .. listPoints[polygon[i][1]].y .. ")*u -- (" .. listPoints[polygon[i][2]].x .. "," .. listPoints[polygon[i][2]].y ..")*u withcolor \\luameshmpcolorNew  withpen pencircle scaled 1pt;"
+         output = output .. "draw".."(".. listPoints[polygon[i][1]].x .. "," .. listPoints[polygon[i][1]].y .. ")*u -- (" .. P.x .. "," .. P.y ..")*u withcolor \\luameshmpcolorNew withpen pencircle scaled 1pt;"
+         output = output .. "draw".."(".. listPoints[polygon[i][2]].x .. "," .. listPoints[polygon[i][2]].y .. ")*u -- (" .. P.x .. "," .. P.y ..")*u withcolor \\luameshmpcolorNew withpen pencircle scaled 1pt;"
+      end
+      -- mark points
+      j=1
+      for i=1,#listPoints do
+         if(listPoints[i].type == "bbox") then
+            output = output .. "dotlabel.llft (btex $\\MeshPoint^{*}_{" .. j .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
+            j=j+1
+         else
+            output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor ;"
+         end
+      end
+      -- mark the added point
+      output = output .. "dotlabel.llft (btex $\\NewPoint$ etex,(" .. P.x ..",".. P.y .. ")*u) withcolor \\luameshmpcolorNew ;"
+   end
+   return output
+end
+
+
+function TeXOnePointTikZBW(chaine,point,step,scale,mode,bbox,color,colorBack,colorNew,colorCircle,colorBbox)
+   if(mode=="int") then
+      Sx,Sy=string.match(point,"%((.+),(.+)%)")
+      P = {x=Sx, y=Sy}
+      listPoints = buildList(chaine, mode)
+   else
+      -- point is a number
+      P, listPoints = buildListExt(chaine,tonumber(point))
+   end
+   output = TeXaddOnePointTikZ(listPoints,P,step,bbox,color,colorBack,colorNew,colorCircle,colorBbox)
+   output = "\\noindent\\begin{tikzpicture}[x="..scale..",y="..scale.."]".. output .. "\\end{tikzpicture}"
+   tex.sprint(output)
+end
+
+function TeXOnePointTikZBWinc(chaine,point,beginning, ending,step,scale,mode,bbox,color,colorBack,colorNew,colorCircle,colorBbox)
+   if(mode=="int") then
+      Sx,Sy=string.match(point,"%((.+),(.+)%)")
+      P = {x=Sx, y=Sy}
+      listPoints = buildList(chaine, mode)
+   else
+      -- point is a number
+      P, listPoints = buildListExt(chaine,tonumber(point))
+   end
+   output = TeXaddOnePointTikZ(listPoints,P,step,bbox,color,colorBack,colorNew,colorCircle,colorBbox)
+   output = "\\noindent\\begin{tikzpicture}[x="..scale..",y="..scale.."]".. beginning..output ..ending.. "\\end{tikzpicture}"
+   tex.sprint(output)
+end
+
+function TeXOnePointMPBW(chaine,point,step,scale,mode,bbox)
+   if(mode=="int") then
+      Sx,Sy=string.match(point,"%((.+),(.+)%)")
+      P = {x=Sx, y=Sy}
+      listPoints = buildList(chaine, mode)
+   else
+      -- point is a number
+      P, listPoints = buildListExt(chaine,tonumber(point))
+   end
+   output = TeXaddOnePointMPBW(listPoints,P,step,bbox)
+   output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale..";".. output .. "endfig;\\end{mplibcode}"
+   tex.sprint(output)
+end
+
+function TeXOnePointMPBWinc(chaine,point,beginning,ending,step,scale,mode,bbox)
+   if(mode=="int") then
+      Sx,Sy=string.match(point,"%((.+),(.+)%)")
+      P = {x=Sx, y=Sy}
+      listPoints = buildList(chaine, mode)
+   else
+      -- point is a number
+      P, listPoints = buildListExt(chaine,tonumber(point))
+   end
+   output = TeXaddOnePointMPBW(listPoints,P,step,bbox)
+   output = "\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}"
+   tex.sprint(output)
+end
+
+
+function drawGmshMP(file,points,scale)
+   listPoints,triangulation = readGmsh(file)
+   output = traceMeshMP(listPoints,triangulation,points)
+   output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale.. ";" .. output .."endfig;\\end{mplibcode}"
+   tex.sprint(output)
+end
+
+function drawGmshMPinc(file,beginning,ending,points,scale)
+   listPoints,triangulation = readGmsh(file)
+   output = traceMeshMP(listPoints,triangulation,points)
+   output = "\\leavevmode\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}"
+   tex.sprint(output)
+end
+
+
+
+--
+function drawGmshTikZ(file,points,scale,color)
+   listPoints,triangulation = readGmsh(file)
+   output = traceMeshTikZ(listPoints, triangulation,points,color,colorBbox)
+   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" .. output .."\\end{tikzpicture}"
+   tex.sprint(output)
+end
+
+--
+function drawGmshTikZinc(file,beginning, ending,points,scale,color)
+   listPoints,triangulation = readGmsh(file)
+   output = traceMeshTikZ(listPoints, triangulation,points,color,colorBbox)
+   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" ..beginning.. output..ending .."\\end{tikzpicture}"
+   tex.sprint(output)
+end
+
+
+-- buildVoronoi with MP
+function gmshVoronoiMP(file,points,scale,tri,styleD,styleV)
+   listPoints,triangulation = readGmsh(file)
+   listVoronoi = buildVoronoi(listPoints, triangulation)
+   output = traceVoronoiMP(listPoints,triangulation,listVoronoi,points,tri,styleD,styleV)
+   output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale.. ";" .. output .."endfig;\\end{mplibcode}"
+   tex.sprint(output)
+end
+
+
+-- buildVoronoi with TikZ
+function gmshVoronoiTikZ(file,points,scale,tri,color,colorVoronoi,styleD,styleV)
+   listPoints,triangulation = readGmsh(file)
+   listVoronoi = buildVoronoi(listPoints, triangulation)
+   output = traceVoronoiTikZ(listPoints,triangulation,listVoronoi,points,tri,color,colorBbox,colorVoronoi,styleD,styleV)
+   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" .. output .."\\end{tikzpicture}"   tex.sprint(output)
+end
+
+
+-- buildVoronoi with MP
+function gmshVoronoiMPinc(file,beginning, ending,points,scale,tri,styleD,styleV)
+   listPoints,triangulation = readGmsh(file)
+   listVoronoi = buildVoronoi(listPoints, triangulation)
+   output = traceVoronoiMP(listPoints,triangulation,listVoronoi,points,tri,styleD,styleV)
+   output = "\\leavevmode\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}"
+   tex.sprint(output)
+end
+
+
+-- buildVoronoi with TikZ
+function gmshVoronoiTikZinc(file,beginning, ending,points,scale,tri,color,colorVoronoi,styleD,styleV)
+   listPoints,triangulation = readGmsh(file)
+   listVoronoi = buildVoronoi(listPoints, triangulation)
+   output = traceVoronoiTikZ(listPoints,triangulation,listVoronoi,points,tri,color,colorBbox,colorVoronoi,styleD,styleV)
+   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" ..beginning.. output..ending .."\\end{tikzpicture}"
+   tex.sprint(output)
+end
index a2c2608..402e33d 100644 (file)
@@ -1,4 +1,5 @@
-require "polygon-luamesh"
+require "luamesh-polygon"
+require "luamesh-tex"
 
 -- Bowyer and Watson algorithm
 -- Delaunay meshing
@@ -77,6 +78,36 @@ function buildBoundingBox(listPoints)
    return listPoints
 end
 
+function BoundingBox(listPoints)
+   -- listPoints : list of points
+   -- epsV        : parameter for the distance of the bounding box
+   local xmin, xmax, ymin, ymax, eps
+   xmin = 1000
+   ymin = 1000
+   xmax = -1000
+   ymax = -1000
+   for i=1,#listPoints do
+      if (listPoints[i].x < xmin) then
+         xmin = listPoints[i].x
+      end
+      if (listPoints[i].x > xmax) then
+         xmax = listPoints[i].x
+      end
+      if (listPoints[i].y < ymin) then
+         ymin = listPoints[i].y
+      end
+      if (listPoints[i].y > ymax) then
+         ymax = listPoints[i].y
+      end
+   end
+   eps = math.max(math.abs(xmax-xmin),math.abs(ymax-ymin))*0.15
+   xmin = xmin - eps
+   xmax = xmax + eps
+   ymin = ymin - eps
+   ymax = ymax + eps
+   return xmin, xmax, ymin, ymax
+end
+
 function removeBoundingBox(triangulation,lgth)
    -- build the four bounding box edge
    point1 = lgth+1
@@ -84,7 +115,7 @@ function removeBoundingBox(triangulation,lgth)
    point3 = lgth+3
    point4 = lgth+4
    -- for all triangle
-   newTriangulation = {}
+   local newTriangulation = {}
    for i=1,#triangulation do
       boolE1 = pointInTriangle(point1,triangulation[i])
       boolE2 = pointInTriangle(point2,triangulation[i])
@@ -99,7 +130,7 @@ end
 
 
 function buildBadTriangles(point, triangulation)
-   badTriangles = {}
+   local badTriangles = {}
    for j=1,#triangulation do -- for all triangles
       A = listPoints[triangulation[j][1]]
       B = listPoints[triangulation[j][2]]
@@ -115,7 +146,7 @@ end
 
 -- construction of the cavity composed by the bad triangles around the point to add
 function buildCavity(badTriangles, triangulation)
-   polygon = {}
+   local polygon = {}
    for j=1,#badTriangles do -- for all bad triangles
       ind = badTriangles[j]
       for k=1,3 do -- for all edges
@@ -211,7 +242,7 @@ end
 
 -- compute the list of the circumcircle of a triangulation
 function listCircumCenter(listPoints,triangulation)
-   list = {}
+   local list = {}
    for j=1,#triangulation do
       A = listPoints[triangulation[j][1]]
       B = listPoints[triangulation[j][2]]
@@ -271,8 +302,8 @@ end
 
 -- build the edges of the Voronoi diagram with a given triangulation
 function buildVoronoi(listPoints, triangulation)
-   listCircumCircle = listCircumCenter(listPoints, triangulation)
-   listVoronoi = {}
+   local listCircumCircle = listCircumCenter(listPoints, triangulation)
+   local listVoronoi = {}
    for i=1,#listCircumCircle do
       listN = findNeighbour(triangulation[i],i,triangulation)
       for j=1,#listN do
@@ -290,7 +321,7 @@ end
 function buildList(chaine, mode)
    -- if mode = int : the list is given in the chaine string (x1,y1);(x2,y2);...;(xn,yn)
    -- if mode = ext : the list is given in a file line by line with space separation
-   listPoints = {}
+   local listPoints = {}
    if mode == "int" then
       local points = string.explode(chaine, ";")
       local lgth=#points
@@ -314,417 +345,49 @@ function buildList(chaine, mode)
 end
 
 
---
-function rectangleList(a,b,nbrA,nbrB)
-   stepA = a/nbrA
-   stepB = b/nbrB
-   listPoints = {}
-   k=1
-   for i=1,(nbrA+1) do
-      for j=1,(nbrB+1) do
-         listPoints[k] = {x = (i-1)*stepA, y=(j-1)*stepB}
-         k=k+1
-      end
-   end
-   return listPoints
-end
-
-
--- trace Voronoi with MP
-function traceVoronoiMP(listPoints, triangulation,listVoronoi, points, tri,styleD,styleV)
-   if(styleD == "dashed") then
-      sDelaunay = "dashed evenly"
-   else
-      sDelaunay = ""
-   end
-   if(styleV == "dashed") then
-      sVoronoi = "dashed evenly"
-   else
-      sVoronoi = ""
-   end
-   listCircumC = listCircumCenter(listPoints,triangulation)
-   output = "";
-   output = output .. " pair MeshPoints[];"
-   for i=1,#listPoints do
-      output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ")*u;"
-   end
-   output = output .. " pair CircumCenters[];"
-   for i=1,#listCircumC do
-      output = output .. "CircumCenters[".. i .. "] = (" .. listCircumC[i].x .. "," .. listCircumC[i].y .. ")*u;"
-   end
-   if(tri=="show") then
-      for i=1,#triangulation do
-         PointI = listPoints[triangulation[i][1]]
-         PointJ = listPoints[triangulation[i][2]]
-         PointK = listPoints[triangulation[i][3]]
-         if(triangulation[i].type == "bbox") then
-            output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle "..sDelaunay.." withcolor \\luameshmpcolorBbox;"
-         else
-            output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle "..sDelaunay.." withcolor \\luameshmpcolor;"
-         end
-      end
-   end
-   for i=1,#listVoronoi do
-      PointI = listCircumC[listVoronoi[i][1]]
-      PointJ = listCircumC[listVoronoi[i][2]]
-      output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u "..sVoronoi.." withcolor \\luameshmpcolorVoronoi;"
-   end
-   if(points=="points") then
-      j=1
-      for i=1,#listPoints do
-         if(listPoints[i].type == "bbox") then
-            output = output .. "dotlabel.llft (btex $\\MeshPoint^{*}_{"..j.."}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
-            j=j+1
-         else
-            output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor ;"
-         end
-      end
-      for i=1,#listCircumC do
-         output = output .. "dotlabel.llft (btex $\\CircumPoint_{" .. i .. "}$ etex, (" .. listCircumC[i].x ..",".. listCircumC[i].y .. ")*u ) withcolor \\luameshmpcolorVoronoi ;"
-      end
-   else
-      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
-      for i=1,#listCircumC do
-         output = output .. "drawdot  (" .. listCircumC[i].x ..",".. listCircumC[i].y .. ")*u  withcolor \\luameshmpcolorVoronoi withpen pencircle scaled 3;"
-      end
-   end
+-- function to build a gridpoints from the bounding box
+-- with a prescribed
+function buildGrid(listPoints,h)
+   -- listPoints : list of the points of the polygon, ordered
+   -- h : parameter for the grid
+   xmin, xmax, ymin, ymax = BoundingBox(listPoints)
 
-   return output
+   local grid = rectangleList(xmin,xmax,ymin,ymax,h)
+   return grid
 end
 
-
--- trace Voronoi with TikZ
-function traceVoronoiTikZ(listPoints, triangulation,listVoronoi, points, tri,color,colorBbox,colorVoronoi,styleD,styleV)
-   if(styleD == "dashed") then
-      sDelaunay = ",dashed"
-   else
-      sDelaunay = ""
-   end
-   if(styleV == "dashed") then
-      sVoronoi = ",dashed"
-   else
-      sVoronoi = ""
-   end
-   listCircumC = listCircumCenter(listPoints,triangulation)
-    output = ""
-   for i=1,#listPoints do
-      output = output .. "\\coordinate (MeshPoints".. i .. ") at  (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");"
-   end
-   for i=1,#listCircumC do
-      output = output .. "\\coordinate (CircumPoints".. i .. ") at  (" .. listCircumC[i].x .. "," .. listCircumC[i].y .. ");"
-   end
-   if(tri=="show") then
-      for i=1,#triangulation do
-         PointI = listPoints[triangulation[i][1]]
-         PointJ = listPoints[triangulation[i][2]]
-         PointK = listPoints[triangulation[i][3]]
-         if(triangulation[i].type == "bbox") then
-            output = output .. "\\draw[color="..colorBbox..sDelaunay.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
-         else
-            output = output .. "\\draw[color="..color..sDelaunay.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
-         end
-      end
-   end
-   for i=1,#listVoronoi do
-      PointI = listCircumC[listVoronoi[i][1]]
-      PointJ = listCircumC[listVoronoi[i][2]]
-      output = output .. "\\draw[color="..colorVoronoi..sVoronoi.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..");"
-   end
-   if(points=="points") 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$} node[anchor=north east] {$\\MeshPoint^*_{" .. j .. "}$};"
-            j=j+1
-         else
-            output = output .. "\\draw[color="..color.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$} node[anchor=north east] {$\\MeshPoint_{" .. i .. "}$};"
-         end
-      end
-      for i=1,#listCircumC do
-         output = output .. "\\draw[color="..colorVoronoi.."] (" .. listCircumC[i].x ..",".. listCircumC[i].y .. ") node {$\\bullet$} node[anchor=north east] {$\\CircumPoint_{" .. i .. "}$};"
-      end
-   else
-      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
-      for i=1,#listCircumC do
-         output = output .. "\\draw[color="..colorVoronoi.."] (" .. listCircumC[i].x ..",".. listCircumC[i].y .. ") node {$\\bullet$};"
-      end
-   end
-   return output
-end
-
-
-
--- buildVoronoi with MP
-function buildVoronoiMPBW(chaine,mode,points,bbox,scale,tri,styleD,styleV)
-   listPoints = buildList(chaine, mode)
-   triangulation = BowyerWatson(listPoints,bbox)
-   listVoronoi = buildVoronoi(listPoints, triangulation)
-   output = traceVoronoiMP(listPoints,triangulation,listVoronoi,points,tri,styleD,styleV)
-   output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale.. ";" .. output .."endfig;\\end{mplibcode}"
-   tex.sprint(output)
-end
-
-
--- buildVoronoi with TikZ
-function buildVoronoiTikZBW(chaine,mode,points,bbox,scale,tri,color,colorBbox,colorVoronoi,styleD,styleV)
-   listPoints = buildList(chaine, mode)
-   triangulation = BowyerWatson(listPoints,bbox)
-   listVoronoi = buildVoronoi(listPoints, triangulation)
-   output = traceVoronoiTikZ(listPoints,triangulation,listVoronoi,points,tri,color,colorBbox,colorVoronoi,styleD,styleV)
-   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" .. output .."\\end{tikzpicture}"   tex.sprint(output)
-end
-
-
--- buildVoronoi with MP
-function buildVoronoiMPBWinc(chaine,beginning, ending,mode,points,bbox,scale,tri,styleD,styleV)
-   listPoints = buildList(chaine, mode)
-   triangulation = BowyerWatson(listPoints,bbox)
-   listVoronoi = buildVoronoi(listPoints, triangulation)
-   output = traceVoronoiMP(listPoints,triangulation,listVoronoi,points,tri,styleD,styleV)
-   output = "\\leavevmode\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}"
-   tex.sprint(output)
-end
-
-
--- buildVoronoi with TikZ
-function buildVoronoiTikZBWinc(chaine,beginning, ending,mode,points,bbox,scale,tri,color,colorBbox,colorVoronoi)
-   listPoints = buildList(chaine, mode,styleD,styleV)
-   triangulation = BowyerWatson(listPoints,bbox)
-   listVoronoi = buildVoronoi(listPoints, triangulation)
-   output = traceVoronoiTikZ(listPoints,triangulation,listVoronoi,points,tri,color,colorBbox,colorVoronoi,styleD,styleV)
-   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" ..beginning.. output..ending .."\\end{tikzpicture}"
-   tex.sprint(output)
-end
-
-
-
--- trace a triangulation with TikZ
-function traceMeshTikZ(listPoints, triangulation,points,color,colorBbox)
-   output = ""
-   for i=1,#listPoints do
-      output = output .. "\\coordinate (MeshPoints".. i .. ") at  (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");"
-   end
-   for i=1,#triangulation do
-      PointI = listPoints[triangulation[i][1]]
-      PointJ = listPoints[triangulation[i][2]]
-      PointK = listPoints[triangulation[i][3]]
-      if(triangulation[i].type == "bbox") then
-         output = output .. "\\draw[color="..colorBbox.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
-      else
-         output = output .. "\\draw[color="..color.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
-      end
-   end
-   if(points=="points") 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$} node[anchor=north east] {$\\MeshPoint^*_{" .. j .. "}$};"
-            j=j+1
-         else
-            output = output .. "\\draw[color="..color.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$} node[anchor=north east] {$\\MeshPoint_{" .. i .. "}$};"
-         end
-      end
-   end
-   return output
-end
-
-
--- trace a triangulation with MP
-function traceMeshMP(listPoints, triangulation,points)
-   output = "";
-   output = output .. " pair MeshPoints[];"
-   for i=1,#listPoints do
-      output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ")*u;"
-   end
-   for i=1,#triangulation do
-      PointI = listPoints[triangulation[i][1]]
-      PointJ = listPoints[triangulation[i][2]]
-      PointK = listPoints[triangulation[i][3]]
-      if(triangulation[i].type == "bbox") then
-         output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolorBbox;"
-      else
-         output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolor;"
-      end
-   end
-   if(points=="points") then
-      j=1
-      for i=1,#listPoints do
-         if(listPoints[i].type == "bbox") then
-            output = output .. "dotlabel.llft (btex $\\MeshPoint^{*}_{"..j.."}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
-            j=j+1
-         else
-            output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor ;"
-         end
+-- function to build the list of points in the rectangle
+function rectangleList(xmin,xmax,ymin,ymax,h)
+   nbrX = math.floor(math.abs(xmax-xmin)/h)
+   nbrY = math.floor(math.abs(ymax-ymin)/h)
+   local listPoints = {}
+   k=1
+   for i=1,(nbrX+1) do
+      for j=1,(nbrY+1) do
+         listPoints[k] = {x = xmin+(i-1)*h, y=ymin+(j-1)*h}
+         k=k+1
       end
    end
-   return output
-end
-
-
--- buildMesh with MP
-function buildMeshMPBW(chaine,mode,points,bbox,scale)
-   listPoints = buildList(chaine, mode)
-   triangulation = BowyerWatson(listPoints,bbox)
-   output = traceMeshMP(listPoints, triangulation,points)
-   output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale.. ";" .. output .."endfig;\\end{mplibcode}"
-   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 = "\\leavevmode\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}"
-   tex.sprint(output)
-end
-
--- buildMesh with TikZ
-function buildMeshTikZBW(chaine,mode,points,bbox,scale,color,colorBbox)
-   listPoints = buildList(chaine, mode)
-   triangulation = BowyerWatson(listPoints,bbox)
-   output = traceMeshTikZ(listPoints, triangulation,points,color,colorBbox)
-   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" .. output .."\\end{tikzpicture}"
-   tex.sprint(output)
-end
-
--- buildMesh with TikZ
-function buildMeshTikZBWinc(chaine,beginning, ending,mode,points,bbox,scale,color,colorBbox)
-   listPoints = buildList(chaine, mode)
-   triangulation = BowyerWatson(listPoints,bbox)
-   output = traceMeshTikZ(listPoints, triangulation,points,color,colorBbox)
-   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" ..beginning.. output..ending .."\\end{tikzpicture}"
-   tex.sprint(output)
+   return listPoints
 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 .. ")*u;"
-   end
-   if(points=="points") then
-      j=1
-      for i=1,#listPoints do
-         if(listPoints[i].type == "bbox") then
-            output = output .. "dotlabel.llft (btex $\\MeshPoint^{*}_{" .. j .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
-            j=j+1
-         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 withpen pencircle scaled 3;"
-         else
-            output = output .. "drawdot (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u  withcolor \\luameshmpcolor withpen pencircle scaled 3;"
-         end
-      end
-   end
-   return output
-end
-
--- print points of the mesh
-function tracePointsTikZ(listPoints,points,color,colorBbox)
-   output = "";
-   for i=1,#listPoints do
-      output = output .. "\\coordinate (MeshPoints".. i .. ") at  (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");"
-   end
-   if(points=="points") 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$} node[anchor=north east] {$\\MeshPoint^*_{" .. j .. "}$};"
-            j = j+1
-         else
-            output = output .. "\\draw[color="..color.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$} node[anchor=north east] {$\\MeshPoint_{" .. i .. "}$};"
-         end
-      end
-   else
-      for i=1,#listPoints do
-         if(listPoints[i].type == "bbox") then
-            output = output .. "\\draw[color="..colorBbox.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$} ;"
-         else
-            output = output .. "\\draw[color="..color.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$} ;"
-         end
+-- function to add points from a grid to the interior of a polygon
+function addGridPoints(polygon, grid)
+   local listPoints = polygon
+   k = #polygon
+   for i=1, #grid do
+      --print(grid[i].x,grid[i].y)
+      --print(isInside(polygon,grid[i]))
+      if(isInside(polygon,grid[i])) then
+         k=k+1
+         listPoints[k] = grid[i]
       end
    end
-   return 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 = "\\leavevmode\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}"
-   tex.sprint(output)
-end
-
--- print points to mesh
-function printPointsTikZ(chaine,mode,points,bbox,scale,color,colorBbox)
-   listPoints = buildList(chaine, mode)
-   if(bbox == "bbox" ) then
-      listPoints = buildBoundingBox(listPoints)
-   end
-   output = tracePointsTikZ(listPoints,points,color,colorBbox)
-   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" .. output .."\\end{tikzpicture}"
-   tex.sprint(output)
-end
-
-
--- print points to mesh
-function printPointsTikZinc(chaine,beginning, ending, mode,points,bbox,scale,color,colorBbox)
-   listPoints = buildList(chaine, mode)
-   if(bbox == "bbox" ) then
-      listPoints = buildBoundingBox(listPoints)
-   end
-   output = tracePointsTikZ(listPoints,points,color,colorBbox)
-   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" ..beginning.. output..ending .."\\end{tikzpicture}"
-   tex.sprint(output)
+   return listPoints
 end
 
 
--- buildMesh
-function buildRect(largeur,a,b,nbrA, nbrB)
-   listPoints = rectangleList(a,b,nbrA,nbrB)
-   triangulation = BowyerWatson(listPoints,"none")
-   traceTikZ(listPoints, triangulation,largeur,"none")
-end
-
 local function shallowCopy(original)
    local copy = {}
    for key, value in pairs(original) do
@@ -768,271 +431,6 @@ function cleanPoly(polygon)
    return polyNew
 end
 
---
-function TeXaddOnePointTikZ(listPoints,P,step,bbox,color,colorBack, colorNew, colorCircle,colorBbox)
-   output = ""
-   -- build the triangulation
-   triangulation = BowyerWatson(listPoints,bbox)
-   badTriangles = buildBadTriangles(P,triangulation)
-   for i=1,#listPoints do
-      output = output .. "\\coordinate (MeshPoints".. i .. ") at  (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");"
-   end
-   if(step == "badT") then
-      -- draw all triangle
-      for i=1,#triangulation do
-         PointI = listPoints[triangulation[i][1]]
-         PointJ = listPoints[triangulation[i][2]]
-         PointK = listPoints[triangulation[i][3]]
-         if(triangulation[i].type == "bbox") then
-            output = output .. "\\draw[color="..colorBbox.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
-         else
-            output = output .. "\\draw[color="..color.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
-         end
-      end
-      -- draw and fill the bad triangle
-      for i=1,#badTriangles do
-         PointI = listPoints[triangulation[badTriangles[i]][1]]
-         PointJ = listPoints[triangulation[badTriangles[i]][2]]
-         PointK = listPoints[triangulation[badTriangles[i]][3]]
-         output = output .. "\\draw[fill="..colorBack.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
-      end
-      -- draw the circoncircle
-      for i=1,#badTriangles do
-         PointI = listPoints[triangulation[badTriangles[i]][1]]
-         PointJ = listPoints[triangulation[badTriangles[i]][2]]
-         PointK = listPoints[triangulation[badTriangles[i]][3]]
-         center, radius = circoncircle(PointI, PointJ, PointK)
-         output = output .. "\\draw[dashed, color="..colorCircle.."] ("..center.x .. "," .. center.y .. ") circle ("..radius ..");"
-      end
-      -- mark the points
-      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$} node[anchor=north east] {$\\MeshPoint^*_{" .. j .. "}$};"
-            j = j+1
-         else
-            output = output .. "\\draw[color="..color.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$} node[anchor=north east] {$\\MeshPoint_{" .. i .. "}$};"
-         end
-      end
-      -- mark the point to add
-      output = output .. "\\draw[color="..colorNew.."] (" .. P.x ..",".. P.y .. ") node {$\\bullet$} node[anchor=north east] {$\\NewPoint$};"
-   elseif(step == "cavity") then
-      polygon = buildCavity(badTriangles, triangulation)
-      polyNew = cleanPoly(polygon)
-      -- remove the bad triangles
-      for j=1,#badTriangles do
-         table.remove(triangulation,badTriangles[j]-(j-1))
-      end
-      -- draw the triangles
-      for i=1,#triangulation do
-         PointI = listPoints[triangulation[i][1]]
-         PointJ = listPoints[triangulation[i][2]]
-         PointK = listPoints[triangulation[i][3]]
-         if(triangulation[i].type == "bbox") then
-            output = output .. "\\draw[color="..colorBbox.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
-         else
-            output = output .. "\\draw[color="..color.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
-         end
-      end
-      -- fill and draw the cavity
-      path = ""
-      for i=1,#polyNew do
-         PointI = listPoints[polyNew[i]]
-         path = path .. "(".. PointI.x ..",".. PointI.y ..")--"
-      end
-      output = output .. "\\draw[color="..colorNew..",fill ="..colorBack..", thick] " .. path .. "cycle;"
-      -- mark the points of the mesh
-      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$} node[anchor=north east] {$\\MeshPoint^*_{" .. j .. "}$};"
-            j=j+1
-         else
-            output = output .. "\\draw[color="..color.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$} node[anchor=north east] {$\\MeshPoint_{" .. i .. "}$};"
-         end
-      end
-      -- mark the adding point
-      output = output .. "\\draw[color="..colorNew.."] (" .. P.x ..",".. P.y .. ") node {$\\bullet$} node[anchor=north east] {$\\NewPoint$};"
-   elseif(step == "newT") then
-      polygon = buildCavity(badTriangles, triangulation)
-      polyNew = cleanPoly(polygon)
-      -- remove the bad triangles
-      for j=1,#badTriangles do
-         table.remove(triangulation,badTriangles[j]-(j-1))
-      end
-      -- draw the triangle of the triangulation
-      for i=1,#triangulation do
-         PointI = listPoints[triangulation[i][1]]
-         PointJ = listPoints[triangulation[i][2]]
-         PointK = listPoints[triangulation[i][3]]
-         if(triangulation[i].type == "bbox") then
-            output = output .. "\\draw[color="..colorBbox.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
-         else
-            output = output .. "\\draw[color="..color.."] (".. PointI.x ..",".. PointI.y ..")--("..PointJ.x..",".. PointJ.y ..")--("..PointK.x..",".. PointK.y ..")--cycle;"
-         end
-      end
-      -- fill and draw the cavity
-      path = ""
-      for i=1,#polyNew do
-         PointI = listPoints[polyNew[i]]
-         path = path .. "(".. PointI.x ..",".. PointI.y ..")--"
-      end
-      output = output .. "\\draw[color="..colorNew..",fill ="..colorBack..", thick] " .. path .. "cycle;"
-      -- draw the new triangles composed by the edges of the polygon and the added point
-      for i=1,#polygon do
-         output = output .. "\\draw[color=TeXCluaMeshNewTikZ, thick]".."(".. listPoints[polygon[i][1]].x .. "," .. listPoints[polygon[i][1]].y .. ") -- (" .. listPoints[polygon[i][2]].x .. "," .. listPoints[polygon[i][2]].y ..");"
-         output = output .. "\\draw[color="..colorNew..", thick]".."(".. listPoints[polygon[i][1]].x .. "," .. listPoints[polygon[i][1]].y .. ") -- (" .. P.x .. "," .. P.y ..");"
-         output = output .. "\\draw[color="..colorNew..", thick]".."(".. listPoints[polygon[i][2]].x .. "," .. listPoints[polygon[i][2]].y .. ") -- (" .. P.x .. "," .. P.y ..");"
-      end
-      -- mark points
-      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$} node[anchor=north east] {$\\MeshPoint^*_{" .. j .. "}$};"
-            j=j+1
-         else
-            output = output .. "\\draw[color="..color.."] (" .. listPoints[i].x ..",".. listPoints[i].y .. ") node {$\\bullet$} node[anchor=north east] {$\\MeshPoint_{" .. i .. "}$};"
-         end
-      end
-      -- mark the added point
-      output = output .. "\\draw[color="..colorNew.."] (" .. P.x ..",".. P.y .. ") node {$\\bullet$} node[anchor=north east] {$\\NewPoint$};"
-   end
-   return output
-end
-
-function TeXaddOnePointMPBW(listPoints,P,step,bbox)
-   output = "";
-   output = output .. "pair MeshPoints[];"
-   -- build the triangulation
-   triangulation = BowyerWatson(listPoints,bbox)
-   badTriangles = buildBadTriangles(P,triangulation)
-   for i=1,#listPoints do
-      output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ")*u;"
-   end
-   if(step == "badT") then
-      -- draw all triangle
-      for i=1,#triangulation do
-         PointI = listPoints[triangulation[i][1]]
-         PointJ = listPoints[triangulation[i][2]]
-         PointK = listPoints[triangulation[i][3]]
-         if(triangulation[i].type == "bbox") then
-            output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolorBbox;"
-         else
-            output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolor;"
-         end
-      end
-      -- draw and fill the bad triangle
-      for i=1,#badTriangles do
-         PointI = listPoints[triangulation[badTriangles[i]][1]]
-         PointJ = listPoints[triangulation[badTriangles[i]][2]]
-         PointK = listPoints[triangulation[badTriangles[i]][3]]
-         output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolor;"
-         output = output .. "fill (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolorBack;"
-      end
-      -- draw the circoncircle
-      for i=1,#badTriangles do
-         PointI = listPoints[triangulation[badTriangles[i]][1]]
-         PointJ = listPoints[triangulation[badTriangles[i]][2]]
-         PointK = listPoints[triangulation[badTriangles[i]][3]]
-         center, radius = circoncircle(PointI, PointJ, PointK)
-         output = output .. "draw fullcircle scaled ("..radius .."*2u) shifted ("..center.x .. "*u," .. center.y .. "*u) dashed evenly withcolor \\luameshmpcolorCircle;"
-      end
-      -- mark the points
-      j=1
-      for i=1,#listPoints do
-         if(listPoints[i].type == "bbox") then
-            output = output .. "dotlabel.llft (btex $\\MeshPoint^{*}_{" .. j .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
-            j=j+1
-         else
-            output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor ;"
-         end
-      end
-      -- mark the point to add
-      output = output .. "dotlabel.llft (btex $\\NewPoint$ etex,(" .. P.x ..",".. P.y .. ")*u) withcolor \\luameshmpcolorNew;"
-   elseif(step == "cavity") then
-      polygon = buildCavity(badTriangles, triangulation)
-      polyNew = cleanPoly(polygon)
-      -- remove the bad triangles
-      for j=1,#badTriangles do
-         table.remove(triangulation,badTriangles[j]-(j-1))
-      end
-      -- draw the triangles
-      for i=1,#triangulation do
-         PointI = listPoints[triangulation[i][1]]
-         PointJ = listPoints[triangulation[i][2]]
-         PointK = listPoints[triangulation[i][3]]
-         if(triangulation[i].type == "bbox") then
-            output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolorBbox;"
-         else
-            output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolor;"
-         end
-      end
-      -- fill and draw the cavity
-      path = ""
-      for i=1,#polyNew do
-         PointI = listPoints[polyNew[i]]
-         path = path .. "(".. PointI.x ..",".. PointI.y ..")*u--"
-      end
-      output = output .. "fill " .. path .. "cycle withcolor \\luameshmpcolorBack;"
-      output = output .. "draw " .. path .. "cycle withcolor \\luameshmpcolorNew  withpen pencircle scaled 1pt;"
-      -- mark the points of the mesh
-      j=1
-      for i=1,#listPoints do
-         if(listPoints[i].type == "bbox") then
-            output = output .. "dotlabel.llft (btex $\\MeshPoint^{*}_{" .. j .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
-            j=j+1
-         else
-            output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor ;"
-         end
-      end
-      -- mark the adding point
-      output = output .. "dotlabel.llft (btex $\\NewPoint$ etex,(" .. P.x ..",".. P.y .. ")*u) withcolor \\luameshmpcolorNew ;"
-   elseif(step == "newT") then
-      polygon = buildCavity(badTriangles, triangulation)
-      polyNew = cleanPoly(polygon)
-      -- remove the bad triangles
-      for j=1,#badTriangles do
-         table.remove(triangulation,badTriangles[j]-(j-1))
-      end
-      -- draw the triangle of the triangulation
-      for i=1,#triangulation do
-         PointI = listPoints[triangulation[i][1]]
-         PointJ = listPoints[triangulation[i][2]]
-         PointK = listPoints[triangulation[i][3]]
-         if(triangulation[i].type == "bbox") then
-            output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolorBbox;"
-         else
-            output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolor;"
-         end
-      end
-      -- fill  the cavity
-      path = ""
-      for i=1,#polyNew do
-         PointI = listPoints[polyNew[i]]
-         path = path .. "(".. PointI.x ..",".. PointI.y ..")*u--"
-      end
-      output = output .. "fill " .. path .. "cycle withcolor \\luameshmpcolorBack;"
-      -- draw the new triangles composed by the edges of the polygon and the added point
-      for i=1,#polygon do
-         output = output .. "draw".."(".. listPoints[polygon[i][1]].x .. "," .. listPoints[polygon[i][1]].y .. ")*u -- (" .. listPoints[polygon[i][2]].x .. "," .. listPoints[polygon[i][2]].y ..")*u withcolor \\luameshmpcolorNew  withpen pencircle scaled 1pt;"
-         output = output .. "draw".."(".. listPoints[polygon[i][1]].x .. "," .. listPoints[polygon[i][1]].y .. ")*u -- (" .. P.x .. "," .. P.y ..")*u withcolor \\luameshmpcolorNew withpen pencircle scaled 1pt;"
-         output = output .. "draw".."(".. listPoints[polygon[i][2]].x .. "," .. listPoints[polygon[i][2]].y .. ")*u -- (" .. P.x .. "," .. P.y ..")*u withcolor \\luameshmpcolorNew withpen pencircle scaled 1pt;"
-      end
-      -- mark points
-      j=1
-      for i=1,#listPoints do
-         if(listPoints[i].type == "bbox") then
-            output = output .. "dotlabel.llft (btex $\\MeshPoint^{*}_{" .. j .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
-            j=j+1
-         else
-            output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor ;"
-         end
-      end
-      -- mark the added point
-      output = output .. "dotlabel.llft (btex $\\NewPoint$ etex,(" .. P.x ..",".. P.y .. ")*u) withcolor \\luameshmpcolorNew ;"
-   end
-   return output
-end
 
 
 -- build the list of points extern and stop at nbr
@@ -1050,64 +448,6 @@ function buildListExt(chaine, stop)
    return point, listPoints
 end
 
-
-function TeXOnePointTikZBW(chaine,point,step,scale,mode,bbox,color,colorBack,colorNew,colorCircle,colorBbox)
-   if(mode=="int") then
-      Sx,Sy=string.match(point,"%((.+),(.+)%)")
-      P = {x=Sx, y=Sy}
-      listPoints = buildList(chaine, mode)
-   else
-      -- point is a number
-      P, listPoints = buildListExt(chaine,tonumber(point))
-   end
-   output = TeXaddOnePointTikZ(listPoints,P,step,bbox,color,colorBack,colorNew,colorCircle,colorBbox)
-   output = "\\noindent\\begin{tikzpicture}[x="..scale..",y="..scale.."]".. output .. "\\end{tikzpicture}"
-   tex.sprint(output)
-end
-
-function TeXOnePointTikZBWinc(chaine,point,beginning, ending,step,scale,mode,bbox,color,colorBack,colorNew,colorCircle,colorBbox)
-   if(mode=="int") then
-      Sx,Sy=string.match(point,"%((.+),(.+)%)")
-      P = {x=Sx, y=Sy}
-      listPoints = buildList(chaine, mode)
-   else
-      -- point is a number
-      P, listPoints = buildListExt(chaine,tonumber(point))
-   end
-   output = TeXaddOnePointTikZ(listPoints,P,step,bbox,color,colorBack,colorNew,colorCircle,colorBbox)
-   output = "\\noindent\\begin{tikzpicture}[x="..scale..",y="..scale.."]".. beginning..output ..ending.. "\\end{tikzpicture}"
-   tex.sprint(output)
-end
-
-function TeXOnePointMPBW(chaine,point,step,scale,mode,bbox)
-   if(mode=="int") then
-      Sx,Sy=string.match(point,"%((.+),(.+)%)")
-      P = {x=Sx, y=Sy}
-      listPoints = buildList(chaine, mode)
-   else
-      -- point is a number
-      P, listPoints = buildListExt(chaine,tonumber(point))
-   end
-   output = TeXaddOnePointMPBW(listPoints,P,step,bbox)
-   output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale..";".. output .. "endfig;\\end{mplibcode}"
-   tex.sprint(output)
-end
-
-function TeXOnePointMPBWinc(chaine,point,beginning,ending,step,scale,mode,bbox)
-   if(mode=="int") then
-      Sx,Sy=string.match(point,"%((.+),(.+)%)")
-      P = {x=Sx, y=Sy}
-      listPoints = buildList(chaine, mode)
-   else
-      -- point is a number
-      P, listPoints = buildListExt(chaine,tonumber(point))
-   end
-   output = TeXaddOnePointMPBW(listPoints,P,step,bbox)
-   output = "\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}"
-   tex.sprint(output)
-end
-
-
 function split(pString, pPattern)
    local Table = {}  -- NOTE: use {n = 0} in Lua-5.0
    local fpat = "(.-)" .. pPattern
@@ -1171,74 +511,3 @@ function readGmsh(file)
    end
    return listPoints, triangulation
 end
-
-function drawGmshMP(file,points,scale)
-   listPoints,triangulation = readGmsh(file)
-   output = traceMeshMP(listPoints,triangulation,points)
-   output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale.. ";" .. output .."endfig;\\end{mplibcode}"
-   tex.sprint(output)
-end
-
-function drawGmshMPinc(file,beginning,ending,points,scale)
-   listPoints,triangulation = readGmsh(file)
-   output = traceMeshMP(listPoints,triangulation,points)
-   output = "\\leavevmode\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}"
-   tex.sprint(output)
-end
-
-
-
---
-function drawGmshTikZ(file,points,scale,color)
-   listPoints,triangulation = readGmsh(file)
-   output = traceMeshTikZ(listPoints, triangulation,points,color,colorBbox)
-   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" .. output .."\\end{tikzpicture}"
-   tex.sprint(output)
-end
-
---
-function drawGmshTikZinc(file,beginning, ending,points,scale,color)
-   listPoints,triangulation = readGmsh(file)
-   output = traceMeshTikZ(listPoints, triangulation,points,color,colorBbox)
-   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" ..beginning.. output..ending .."\\end{tikzpicture}"
-   tex.sprint(output)
-end
-
-
--- buildVoronoi with MP
-function gmshVoronoiMP(file,points,scale,tri,styleD,styleV)
-   listPoints,triangulation = readGmsh(file)
-   listVoronoi = buildVoronoi(listPoints, triangulation)
-   output = traceVoronoiMP(listPoints,triangulation,listVoronoi,points,tri,styleD,styleV)
-   output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale.. ";" .. output .."endfig;\\end{mplibcode}"
-   tex.sprint(output)
-end
-
-
--- buildVoronoi with TikZ
-function gmshVoronoiTikZ(file,points,scale,tri,color,colorVoronoi,styleD,styleV)
-   listPoints,triangulation = readGmsh(file)
-   listVoronoi = buildVoronoi(listPoints, triangulation)
-   output = traceVoronoiTikZ(listPoints,triangulation,listVoronoi,points,tri,color,colorBbox,colorVoronoi,styleD,styleV)
-   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" .. output .."\\end{tikzpicture}"   tex.sprint(output)
-end
-
-
--- buildVoronoi with MP
-function gmshVoronoiMPinc(file,beginning, ending,points,scale,tri,styleD,styleV)
-   listPoints,triangulation = readGmsh(file)
-   listVoronoi = buildVoronoi(listPoints, triangulation)
-   output = traceVoronoiMP(listPoints,triangulation,listVoronoi,points,tri,styleD,styleV)
-   output = "\\leavevmode\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}"
-   tex.sprint(output)
-end
-
-
--- buildVoronoi with TikZ
-function gmshVoronoiTikZinc(file,beginning, ending,points,scale,tri,color,colorVoronoi,styleD,styleV)
-   listPoints,triangulation = readGmsh(file)
-   listVoronoi = buildVoronoi(listPoints, triangulation)
-   output = traceVoronoiTikZ(listPoints,triangulation,listVoronoi,points,tri,color,colorBbox,colorVoronoi,styleD,styleV)
-   output = "\\noindent\\begin{tikzpicture}[x=" .. scale .. ",y=" .. scale .."]" ..beginning.. output..ending .."\\end{tikzpicture}"
-   tex.sprint(output)
-end
index 0a399f9..14a41b6 100644 (file)
Binary files a/test/delaunay.pdf and b/test/delaunay.pdf differ
diff --git a/test/luamesh-polygon.lua b/test/luamesh-polygon.lua
new file mode 120000 (symlink)
index 0000000..e9903c7
--- /dev/null
@@ -0,0 +1 @@
+../luamesh-polygon.lua
\ No newline at end of file
diff --git a/test/luamesh-tex.lua b/test/luamesh-tex.lua
new file mode 120000 (symlink)
index 0000000..9dbbbde
--- /dev/null
@@ -0,0 +1 @@
+../luamesh-tex.lua
\ No newline at end of file
diff --git a/test/polygon-luamesh.lua b/test/polygon-luamesh.lua
deleted file mode 120000 (symlink)
index 2d6109a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../polygon-luamesh.lua
\ No newline at end of file
index 846ff8f..636f518 100644 (file)
@@ -24,6 +24,21 @@ print(#listPoints,#triangulation)
 print(listPoints[2].x)
 
 listPoints = {{x=0, y=0},{x=1,y=0},{x=1,y=0.5},{x=0.5, y=1},{x=-0.3,y=0.3}}
-q = {x=1.5,y=0.2}
+q = {x=1.105,y=1.105}
+--q = {x=0.5,y=0.2}
 print(q.x)
 print(isInside(listPoints,q))
+
+grid = buildGrid(listPoints,0.1)
+
+for i=1, #grid do
+  -- print(grid[i].x,grid[i].y)
+end
+
+listNew = addGridPoints(listPoints,grid)
+
+for i=1, #listNew do
+   print(listNew[i].x, listNew[i].y)
+end
+
+print(#grid, #listNew)

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.