diff options
author | Karl Berry <karl@freefriends.org> | 2020-06-07 20:38:49 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-06-07 20:38:49 +0000 |
commit | 0d6294a01690ace95d88ecdbc70242dc89912368 (patch) | |
tree | eef4df79d70ac95cc8fe2fea1fbf0625370f7790 /Master/texmf-dist/scripts/luamesh | |
parent | 4429ead320ce6d8f38632b2255fc52a0fa086165 (diff) |
luamesh (7jun20)
git-svn-id: svn://tug.org/texlive/trunk@55468 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/luamesh')
-rwxr-xr-x | Master/texmf-dist/scripts/luamesh/luamesh-polygon.lua | 6 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/luamesh/luamesh-tex.lua | 5 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/luamesh/luamesh.lua | 112 |
3 files changed, 96 insertions, 27 deletions
diff --git a/Master/texmf-dist/scripts/luamesh/luamesh-polygon.lua b/Master/texmf-dist/scripts/luamesh/luamesh-polygon.lua index fd8a228aa3e..37dc7c0487b 100755 --- a/Master/texmf-dist/scripts/luamesh/luamesh-polygon.lua +++ b/Master/texmf-dist/scripts/luamesh/luamesh-polygon.lua @@ -1,3 +1,9 @@ +----------------------------------------------------------------------- +-- FILE: luamesh-polygon.lua +-- DESCRIPTION: functions of luamesh package to mesh a polygon +-- AUTHOR: Maxime Chupin +----------------------------------------------------------------------- + -- Given three colinear points p, q, r, the function checks if -- point q lies on line segment 'pr' function onSegment(p,q,r) diff --git a/Master/texmf-dist/scripts/luamesh/luamesh-tex.lua b/Master/texmf-dist/scripts/luamesh/luamesh-tex.lua index 11e31a4c77c..34755092ed4 100755 --- a/Master/texmf-dist/scripts/luamesh/luamesh-tex.lua +++ b/Master/texmf-dist/scripts/luamesh/luamesh-tex.lua @@ -1,3 +1,8 @@ +----------------------------------------------------------------------- +-- FILE: luamesh-tex.lua +-- DESCRIPTION: functions of luamesh package to produce LaTeX code +-- AUTHOR: Maxime Chupin +----------------------------------------------------------------------- -- trace Voronoi with MP function traceVoronoiMP(listPoints, triangulation,listVoronoi, points, tri,styleD,styleV) if(styleD == "dashed") then diff --git a/Master/texmf-dist/scripts/luamesh/luamesh.lua b/Master/texmf-dist/scripts/luamesh/luamesh.lua index a1023aace9c..e03703c6d72 100755 --- a/Master/texmf-dist/scripts/luamesh/luamesh.lua +++ b/Master/texmf-dist/scripts/luamesh/luamesh.lua @@ -1,3 +1,9 @@ +----------------------------------------------------------------------- +-- FILE: luamesh.lua +-- DESCRIPTION: core functions of luamesh package +-- REQUIREMENTS: local scripts (luamesh-polygon and luamesh-tex) +-- AUTHOR: Maxime Chupin +----------------------------------------------------------------------- require "luamesh-polygon" require "luamesh-tex" @@ -509,36 +515,88 @@ function readGmsh(file) Jnodes = 0 boolElements = false Jelements = 0 + J=0 - for i=1,#lines-J do - if(lines[i+J] == "$EndNodes") then - boolNodes = false - -- go to the next line - end - if(boolNodes) then -- we are in the Nodes environment - xy=split(lines[i+J]," +") - table.insert(listPoints,{x=tonumber(xy[2]),y=tonumber(xy[3])}) - end - if(lines[i+J] == "$Nodes") then - boolNodes = true - -- go to the next line - J=J+1 - end - if(lines[i+J] == "$EndElements") then - boolElements = false - -- go to the next line - end - if(boolElements) then -- we are in the Nodes environment - xy=split(lines[i+J]," +") - if(tonumber(xy[2]) == 2) then -- if the element is a triangle - nbrTags = xy[3]+1 - table.insert(triangulation,{tonumber(xy[2+nbrTags+1]),tonumber(xy[2+nbrTags+2]),tonumber(xy[2+nbrTags+3])}) + format=split(lines[2]," +") + if((tonumber(format[1])>=2.0) and (tonumber(format[1])<3.0)) then -- Format 2 + for i=4,#lines-J do + if(lines[i+J] == "$EndNodes") then + boolNodes = false + -- go to the next line + end + if(boolNodes) then -- we are in the Nodes environment + xy=split(lines[i+J]," +") + table.insert(listPoints,{x=tonumber(xy[2]),y=tonumber(xy[3])}) + end + if(lines[i+J] == "$Nodes") then + boolNodes = true + -- go to the next line + J=J+1 + end + if(lines[i+J] == "$EndElements") then + boolElements = false + -- go to the next line + end + if(boolElements) then -- we are in the Elements environment + xy=split(lines[i+J]," +") + if(tonumber(xy[2]) == 2) then -- if the element is a triangle + nbrTags = xy[3]+1 + table.insert(triangulation,{tonumber(xy[2+nbrTags+1]),tonumber(xy[2+nbrTags+2]),tonumber(xy[2+nbrTags+3])}) + end + end + if(lines[i+J] == "$Elements") then + boolElements = true + -- go to the next line + J=J+1 end end - if(lines[i+J] == "$Elements") then - boolElements = true - -- go to the next line - J=J+1 + end + + + if(tonumber(format[1]) >= 4.0) then -- format 4 + for i=4,#lines-J do + if(lines[i+J] == "$EndNodes") then + boolNodes = false + -- go to the next line + end + if(boolNodes) then -- we are in the Nodes environment + xy=split(lines[i+J]," +") -- bloc 4 number + nbrBloc = tonumber(xy[4]) + for k=1,nbrBloc do + xyz=split(lines[i+J+nbrBloc+k]," +") -- x y z + table.insert(listPoints,{x=tonumber(xyz[1]),y=tonumber(xyz[2])}) + end + J =J+ 2*tonumber(xy[4]) + end + if(lines[i+J] == "$Nodes") then + boolNodes = true + -- go to the next line + J=J+1 + end + if(lines[i+J] == "$EndElements") then + boolElements = false + -- go to the next line + end + if(boolElements) then -- we are in the Elements environment + xy=split(lines[i+J]," +") + if(tonumber(xy[1]) < 2) then -- if the elements block is not a triangle + J = J+tonumber(xy[4]) -- we jump to the new block + end + if(tonumber(xy[1]) == 2) then -- if the elements block is a triangle + nbrElements = tonumber(xy[4]) + for k=1,nbrElements do + xyz=split(lines[i+J+k]," +") -- line tag node1 node2 node3 + table.insert(triangulation,{tonumber(xyz[2]),tonumber(xyz[3]),tonumber(xyz[4])}) + end + J = J+nbrElements + end + end + if(lines[i+J] == "$Elements") then + boolElements = true + -- go to the next line + J=J+1 + end + end end return listPoints, triangulation |