-- buildMesh with MP
-function buildMeshMP(chaine,mode,points,bbox,full,scale,color)
+function buildMeshMPBW(chaine,mode,points,bbox,full,scale,color)
listPoints = buildList(chaine, mode)
triangulation = BowyerWatson(listPoints,bbox)
output = traceMeshMP(listPoints, triangulation,points,color)
return output
end
-function TeXaddOnePointMP(listPoints,P,step,color,colorBack, colorNew, colorCircle,bbox)
+function TeXaddOnePointMPBW(listPoints,P,step,bbox)
output = "";
output = output .. "pair MeshPoints[];"
-- build the triangulation
PointI = listPoints[triangulation[i][1]]
PointJ = listPoints[triangulation[i][2]]
PointK = listPoints[triangulation[i][3]]
- output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\mpcolorcolor;"
+ output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolor;"
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 \\mpcolorcolor;"
- output = output .. "fill (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\mpcolorcolorBack;"
+ 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
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 \\mpcolorcolorCircle;"
+ output = output .. "draw fullcircle scaled ("..radius .."*2u) shifted ("..center.x .. "*u," .. center.y .. "*u) dashed evenly withcolor \\luameshmpcolorCircle;"
end
-- mark the points
for i=1,#listPoints do
- output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\mpcolorcolor;"
+ output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor;"
end
-- mark the point to add
- output = output .. "dotlabel.llft (btex $\\NewPoint$ etex,(" .. P.x ..",".. P.y .. ")*u) withcolor \\mpcolorcolorNew;"
+ 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)
PointI = listPoints[triangulation[i][1]]
PointJ = listPoints[triangulation[i][2]]
PointK = listPoints[triangulation[i][3]]
- output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\mpcolorcolor;"
+ output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolor;"
end
-- fill and draw the cavity
path = ""
PointI = listPoints[polyNew[i]]
path = path .. "(".. PointI.x ..",".. PointI.y ..")*u--"
end
- output = output .. "fill " .. path .. "cycle withcolor \\mpcolorcolorBack;"
- output = output .. "draw " .. path .. "cycle withcolor \\mpcolorcolorNew withpen pencircle scaled 1pt;"
+ output = output .. "fill " .. path .. "cycle withcolor \\luameshmpcolorBack;"
+ output = output .. "draw " .. path .. "cycle withcolor \\luameshmpcolorNew withpen pencircle scaled 1pt;"
-- mark the points of the mesh
for i=1,#listPoints do
- output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\mpcolorcolor ;"
+ output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor ;"
end
-- mark the adding point
- output = output .. "dotlabel.llft (btex $\\NewPoint$ etex,(" .. P.x ..",".. P.y .. ")*u) withcolor \\mpcolorcolorNew ;"
+ 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)
PointI = listPoints[triangulation[i][1]]
PointJ = listPoints[triangulation[i][2]]
PointK = listPoints[triangulation[i][3]]
- output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\mpcolorcolor ;"
+ output = output .. "draw (".. PointI.x ..",".. PointI.y ..")*u--("..PointJ.x..",".. PointJ.y ..")*u--("..PointK.x..",".. PointK.y ..")*u--cycle withcolor \\luameshmpcolor ;"
end
-- fill the cavity
path = ""
PointI = listPoints[polyNew[i]]
path = path .. "(".. PointI.x ..",".. PointI.y ..")*u--"
end
- output = output .. "fill " .. path .. "cycle withcolor \\mpcolorcolorBack;"
+ 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 \\mpcolorcolorNew withpen pencircle scaled 1pt;"
- output = output .. "draw".."(".. listPoints[polygon[i][1]].x .. "," .. listPoints[polygon[i][1]].y .. ")*u -- (" .. P.x .. "," .. P.y ..")*u withcolor \\mpcolorcolorNew withpen pencircle scaled 1pt;"
- output = output .. "draw".."(".. listPoints[polygon[i][2]].x .. "," .. listPoints[polygon[i][2]].y .. ")*u -- (" .. P.x .. "," .. P.y ..")*u withcolor \\mpcolorcolorNew withpen pencircle scaled 1pt;"
+ 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
for i=1,#listPoints do
- output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\mpcolorcolor ;"
+ output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor ;"
end
-- mark the added point
- output = output .. "dotlabel.llft (btex $\\NewPoint$ etex,(" .. P.x ..",".. P.y .. ")*u) withcolor \\mpcolorcolorNew ;"
+ output = output .. "dotlabel.llft (btex $\\NewPoint$ etex,(" .. P.x ..",".. P.y .. ")*u) withcolor \\luameshmpcolorNew ;"
end
return output
end
tex.sprint(output)
end
-function TeXOnePointMP(chaine,point,step,color,colorBack,colorNew,colorCircle,scale,mode,picture,bbox)
+function TeXOnePointMPBW(chaine,point,step,scale,mode,picture,bbox)
if(mode=="int") then
Sx,Sy=string.match(point,"%((.+),(.+)%)")
P = {x=Sx, y=Sy}
-- point is a number
P, listPoints = buildListExt(chaine,tonumber(point))
end
- output = TeXaddOnePointMP(listPoints,P,step,color,colorBack,colorNew,colorCircle,bbox)
- if(picture=="full") then
- output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale..";".. output .. "endfig;\\end{mplibcode}"
+ 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,picture,bbox)
+ if(mode=="int") then
+ Sx,Sy=string.match(point,"%((.+),(.+)%)")
+ P = {x=Sx, y=Sy}
+ listPoints = buildList(chaine, mode)
else
- output = "u:="..scale..";".. output
+ -- 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