warning pour l'index, et TODO list modifiée
[delaunay.git] / luamesh.lua
index 060d389..ad6ec6f 100644 (file)
@@ -289,9 +289,11 @@ function traceMeshMP(listPoints, triangulation,points)
       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_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
+            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
@@ -301,6 +303,36 @@ function traceMeshMP(listPoints, triangulation,points)
 end
 
 
+-- print points of the mesh
+function tracePointsMP(listPoints,points)
+   output = "";
+   output = output .. " pair MeshPoints[];"
+   for i=1,#listPoints do
+      output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");"
+   end
+   if(points=="points") then
+      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 ;"
+         else
+            output = output .. "drawdot (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor ;"
+         end
+      end
+   end
+   return output
+end
+
+
 
 -- buildMesh with TikZ
 function buildMeshTikZ(chaine,mode,points,bbox,full,scale,color)
@@ -323,6 +355,29 @@ function buildMeshMPBW(chaine,mode,points,bbox,scale)
    tex.sprint(output)
 end
 
+-- print points to mesh
+function printPointsMP(chaine,mode,points,bbox,scale)
+   listPoints = buildList(chaine, mode)
+   if(bbox == "bbox" ) then
+      listPoints = buildBoundingBox(listPoints)
+   end
+   output = tracePointsMP(listPoints,points)
+   output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale.. ";" .. output .."endfig;\\end{mplibcode}"
+   tex.sprint(output)
+end
+
+
+-- print points to mesh
+function printPointsMPinc(chaine,beginning, ending, mode,points,bbox,scale)
+   listPoints = buildList(chaine, mode)
+   if(bbox == "bbox" ) then
+      listPoints = buildBoundingBox(listPoints)
+   end
+   output = tracePointsMP(listPoints,points)
+   output = "\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}"
+   tex.sprint(output)
+end
+
 
 -- buildMesh with MP include code
 function buildMeshMPBWinc(chaine,beginning, ending,mode,points,bbox,scale)
@@ -523,9 +578,11 @@ function TeXaddOnePointMPBW(listPoints,P,step,bbox)
          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_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
+            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
@@ -559,9 +616,11 @@ function TeXaddOnePointMPBW(listPoints,P,step,bbox)
       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_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
+            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
@@ -600,9 +659,11 @@ function TeXaddOnePointMPBW(listPoints,P,step,bbox)
          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_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
+            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

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.