traceTikZ(listPoints, triangulation,largeur,"none")
end
+local function shallowCopy(original)
+ local copy = {}
+ for key, value in pairs(original) do
+ copy[key] = value
+ end
+ return copy
+end
-- function give a real polygon without repeting points
function cleanPoly(polygon)
polyNew = {}
- e1 = polygon[1][1]
- e2 = polygon[1][2]
+ polyCopy = shallowCopy(polygon)
+ e1 = polyCopy[1][1]
+ e2 = polyCopy[1][2]
table.insert(polyNew, e1)
table.insert(polyNew, e2)
+ table.remove(polyCopy,1)
j = 2
- for i=2,#polygon do
- bool1 = (polygon[i][1] == polyNew[j])
- bool2 = (polygon[i][2] == polyNew[j])
- if(bool1 or bool2) then -- the edge has a common point with polyNew[j]
- if(not bool1) then
- table.insert(polyNew, polygon[i][1])
- j = j+1
- elseif(not bool2) then
- table.insert(polyNew, polygon[i][2])
- j = j+1
+ while #polyCopy>1 do
+ i=1
+ find = false
+ while (i<=#polyCopy and find==false) do
+ i = i+1
+ bool1 = (polyCopy[i][1] == polyNew[j])
+ bool2 = (polyCopy[i][2] == polyNew[j])
+ if(bool1 or bool2) then -- the edge has a common point with polyNew[j]
+ if(not bool1) then
+ table.insert(polyNew, polyCopy[i][1])
+ find = true
+ table.remove(polyCopy,i)
+ j = j+1
+ elseif(not bool2) then
+ table.insert(polyNew, polyCopy[i][2])
+ find = true
+ table.remove(polyCopy,i)
+ j = j+1
+ end
end
end
end
end
function TeXaddOnePointMPBW(listPoints,P,step,bbox)
- print(bbox)
output = "";
output = output .. "pair MeshPoints[];"
-- build the triangulation