-- add four points to listPoints to have a bounding box
listPoints = buildBoundingBox(listPoints)
-- the first triangle
- triangulation[1] = {lgth+1, lgth+2, lgth+3}
+ triangulation[1] = {lgth+1, lgth+2, lgth+3,type="bbox"}
-- the second triangle
- triangulation[2] = {lgth+1, lgth+3, lgth+4}
+ triangulation[2] = {lgth+1, lgth+3, lgth+4,type="bbox"}
-- add points one by one
for i=1,lgth do
-- find the triangles which the circumcircle contained the point to add
end
-- build the new triangles and add them to triangulation
for j=1,#polygon do
- table.insert(triangulation,{polygon[j][1],polygon[j][2],i})
+ if((polygon[j][1]>lgth) or (polygon[j][2]>lgth) or (i>lgth)) then
+ table.insert(triangulation,{polygon[j][1],polygon[j][2],i,type="bbox"})
+ else
+ table.insert(triangulation,{polygon[j][1],polygon[j][2],i,type="in"})
+ end
end
end -- end adding points of the listPoints
-- remove bounding box
ymin = ymin - eps
ymax = ymax + eps
-- add points of the bounding box in last positions
- table.insert(listPoints,{x=xmin,y=ymin})
- table.insert(listPoints,{x=xmin,y=ymax})
- table.insert(listPoints,{x=xmax,y=ymax})
- table.insert(listPoints,{x=xmax,y=ymin})
+ table.insert(listPoints,{x=xmin,y=ymin,type="bbox"})
+ table.insert(listPoints,{x=xmin,y=ymax,type="bbox"})
+ table.insert(listPoints,{x=xmax,y=ymax,type="bbox"})
+ table.insert(listPoints,{x=xmax,y=ymin,type="bbox"})
return listPoints
end
-- trace a triangulation with MP
-function traceMeshMP(listPoints, triangulation,points,color)
+function traceMeshMP(listPoints, triangulation,points)
output = "";
output = output .. " pair MeshPoints[];"
for i=1,#listPoints do
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 \\mpcolor{"..color.. "};"
+ 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
for i=1,#listPoints do
- output = output .. "dotlabel.llft( btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u) withcolor \\mpcolor{"..color.. "};"
+ if(listPoints[i].type == "bbox") then
+ output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
+ else
+ output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor ;"
+ end
end
end
return output
-- buildMesh with MP
-function buildMeshMPBW(chaine,mode,points,bbox,full,scale,color)
+function buildMeshMPBW(chaine,mode,points,bbox,scale)
listPoints = buildList(chaine, mode)
triangulation = BowyerWatson(listPoints,bbox)
- output = traceMeshMP(listPoints, triangulation,points,color)
- if(full=="full") then
- output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale.. ";" .. output .."endfig;\\end{mplibcode}"
- else
- output = "u:="..scale.. ";".. output
- end
+ output = traceMeshMP(listPoints, triangulation,points)
+ output = "\\leavevmode\\begin{mplibcode}beginfig(0);u:="..scale.. ";" .. output .."endfig;\\end{mplibcode}"
tex.sprint(output)
end
end
function TeXaddOnePointMPBW(listPoints,P,step,bbox)
+ print(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 \\luameshmpcolor;"
+ 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
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 \\luameshmpcolor;"
+ if(listPoints[i].type == "bbox") then
+ output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
+ 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;"
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 \\luameshmpcolor;"
+ 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 = ""
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 \\luameshmpcolor ;"
+ if(listPoints[i].type == "bbox") then
+ output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
+ 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 ;"
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 \\luameshmpcolor ;"
+ 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 = ""
end
-- mark points
for i=1,#listPoints do
- output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolor ;"
+ if(listPoints[i].type == "bbox") then
+ output = output .. "dotlabel.llft (btex $\\MeshPoint_{" .. i .. "}$ etex, (" .. listPoints[i].x ..",".. listPoints[i].y .. ")*u ) withcolor \\luameshmpcolorBbox ;"
+ 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 ;"
tex.sprint(output)
end
-function TeXOnePointMPBW(chaine,point,step,scale,mode,picture,bbox)
+function TeXOnePointMPBW(chaine,point,step,scale,mode,bbox)
if(mode=="int") then
Sx,Sy=string.match(point,"%((.+),(.+)%)")
P = {x=Sx, y=Sy}
tex.sprint(output)
end
-function TeXOnePointMPBWinc(chaine,point,beginning,ending,step,scale,mode,picture,bbox)
+function TeXOnePointMPBWinc(chaine,point,beginning,ending,step,scale,mode,bbox)
if(mode=="int") then
Sx,Sy=string.match(point,"%((.+),(.+)%)")
P = {x=Sx, y=Sy}