-- Delaunay meshing
function BowyerWatson (listPoints,bbox)
local triangulation = {}
- local lgth = #listPoints
+ lgth = #listPoints
-- add four points to listPoints to have a bounding box
listPoints = buildBoundingBox(listPoints)
-- the first triangle
function buildBadTriangles(point, triangulation,listPoints)
local badTriangles = {}
- print(#triangulation)
for j=1,#triangulation do -- for all triangles
A = listPoints[triangulation[j][1]]
B = listPoints[triangulation[j][2]]
-- if the distance between two ponits of the polygon is greater than 1.5*h
if(dist>=2*h) then
n = math.floor(dist/h)
- print(polygon[i].x,polygon[i].y,polygon[ip].x,polygon[ip].y)
step = dist/(n+1)
- print("step="..step)
- print("n="..n)
for j=1,n do
- print(j*step)
a = {x=polygon[i].x+j*step*(polygon[ip].x-polygon[i].x)/dist,y=polygon[i].y+j*step*(polygon[ip].y-polygon[i].y)/dist}
- print("new = "..a.x.." "..a.y)
table.insert(newPolygon,k+j,a)
end
k=k+n
-- function give a real polygon without repeting points
function cleanPoly(polygon)
- polyNew = {}
- polyCopy = shallowCopy(polygon)
+ local polyNew = {}
+ local polyCopy = shallowCopy(polygon)
e1 = polyCopy[1][1]
e2 = polyCopy[1][2]
table.insert(polyNew, e1)
-- build the list of points extern and stop at nbr
function buildListExt(chaine, stop)
- listPoints = {}
+ local listPoints = {}
io.input(chaine) -- open the file
text=io.read("*all")
lines=string.explode(text,"\n+") -- all the lines
io.input(file) -- open the file
text=io.read("*all")
local lines = split(text,"\n+") -- all the lines
- listPoints={}
- triangulation ={}
+ local listPoints={}
+ local triangulation ={}
boolNodes = false
Jnodes = 0
boolElements = false