Un peu de nettoyage et rajout de déclaration local
[delaunay.git] / luamesh.lua
index 10a2084..833684e 100644 (file)
@@ -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

Licence Creative Commons Les fichiers de Syracuse sont mis à disposition (sauf mention contraire) selon les termes de la
Licence Creative Commons Attribution - Pas d’Utilisation Commerciale - Partage dans les Mêmes Conditions 4.0 International.