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