X-Git-Url: https://melusine.eu.org/syracuse/G/git/?p=delaunay.git;a=blobdiff_plain;f=luamesh.lua;h=833684ebf9a72ccae0902812832bad67d3e31953;hp=10a2084193c4956b5d9b1af658aeb75eb3c92d2b;hb=d40b2486ba6be29e1e905d3b55dc7199af2abe8a;hpb=fe3a5df51411d6ea20f72115641db9bc7d19a466 diff --git a/luamesh.lua b/luamesh.lua index 10a2084..833684e 100644 --- a/luamesh.lua +++ b/luamesh.lua @@ -13,7 +13,7 @@ end -- 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 @@ -139,7 +139,6 @@ end 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]] @@ -365,14 +364,9 @@ function addPointsPolygon(polygon,h) -- 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 @@ -427,8 +421,8 @@ end -- 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) @@ -464,7 +458,7 @@ end -- 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 @@ -500,8 +494,8 @@ function readGmsh(file) 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