Bug dans cleanPoly() réparé
authorMaxime Chupin (escudo) <chupin@fougeriens.org>
Tue, 22 Nov 2016 21:56:29 +0000 (22:56 +0100)
committerMaxime Chupin (escudo) <chupin@fougeriens.org>
Tue, 22 Nov 2016 21:56:29 +0000 (22:56 +0100)
luamesh.lua
test/animation-crop.pdf
test/animation.pdf
test/animation.tex
test/maillage.pdf [new file with mode: 0644]
test/maillage.tex [new file with mode: 0644]
test/mesh.txt
test/mesh2.txt [new file with mode: 0644]
test/meshInit.txt [new file with mode: 0644]

index b977e4e..060d389 100644 (file)
@@ -340,25 +340,43 @@ function buildRect(largeur,a,b,nbrA, nbrB)
    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
@@ -468,7 +486,6 @@ function TeXaddOnePointTikZ(chaine,point,step,color,colorBack, colorNew, colorCi
 end
 
 function TeXaddOnePointMPBW(listPoints,P,step,bbox)
-   print(bbox)
    output = "";
    output = output .. "pair MeshPoints[];"
    -- build the triangulation
index 2a23b30..8aeb3f0 100644 (file)
Binary files a/test/animation-crop.pdf and b/test/animation-crop.pdf differ
index 0af8e2d..d437093 100644 (file)
Binary files a/test/animation.pdf and b/test/animation.pdf differ
index b3d33a7..d47832a 100644 (file)
@@ -6,39 +6,60 @@
 \usepackage{multido}
 \pagestyle{empty}
 
-
+\def\drawPath{draw (-2,-2)*u--(8,-2)*u--(8,6)*u--(-2,6)*u--cycle  withcolor 0.99white;}
+\def\clipPath{clip currentpicture to (-2,-2)*u--(8,-2)*u--(8,6)*u--(-2,6)*u--cycle;}
 \begin{document}
 
-\multido{\ii=5+1}{3}{%
+\buildMeshBWinc[
+mode=ext,
+bbox = show,
+colorBbox = blue!20,
+print=points
+]
+{meshInit.txt}%
+{%
+  beginfig(0);
+  \drawPath
+}%
+{%
+  \clipPath
+  endfig;
+}
+
+\multido{\ii=5+1}{4}{%
   \newpage
   \meshAddPointBWinc[
   mode=ext,step=badtriangles,
   colorNew =green!20!red,
   colorBack=red!10,
   colorCircle = blue,
+  bbox = show,
+  colorBbox = blue!20
   ]
   {mesh.txt}{\ii}%
   {%
     beginfig(0);
+    \drawPath
   }%
   {%
-    draw (-1,-1)*u--(7.5,-1)*u--(7.5,5)*u--(-1,5)*u--cycle withcolor 0.99white;
-    clip currentpicture to (-1,-1)*u--(7.5,-1)*u--(7.5,5)*u--(-1,5)*u--cycle;
+    \clipPath
     endfig;
-  }  \newpage
+  }   \newpage
   \meshAddPointBWinc[
   mode=ext,step=cavity,
   colorNew =green!20!red,
   colorBack=red!10,
   colorCircle = blue,
+  bbox = show,
+  colorBbox = blue!20
   ]
   {mesh.txt}{\ii}%
   {%
     beginfig(0);
+    \drawPath
   }%
   {%
-    draw (-1,-1)*u--(7.5,-1)*u--(7.5,5)*u--(-1,5)*u--cycle withcolor 0.99white;
-    clip currentpicture to (-1,-1)*u--(7.5,-1)*u--(7.5,5)*u--(-1,5)*u--cycle;
+    \clipPath
     endfig;
   }  \newpage
   \meshAddPointBWinc[
   colorNew =green!20!red,
   colorBack=red!10,
   colorCircle = blue,
-  ]
+  bbox = show,
+  colorBbox = blue!20]
   {mesh.txt}{\ii}%
   {%
     beginfig(0);
+    \drawPath
   }%
   {%
-    draw (-1,-1)*u--(7.5,-1)*u--(7.5,5)*u--(-1,5)*u--cycle withcolor 0.99white;
-    clip currentpicture to (-1,-1)*u--(7.5,-1)*u--(7.5,5)*u--(-1,5)*u--cycle;
+    \clipPath
     endfig;
   }
 }
-
-
+\newpage
+\buildMeshBWinc[
+mode=ext,
+bbox = show,
+colorBbox = blue!20,
+print=points
+]
+{mesh.txt}%
+{%
+  beginfig(0);
+  \drawPath
+}%
+{%
+  \clipPath
+  endfig;
+}
+\newpage
+\buildMeshBWinc[
+mode=ext,
+print=points
+]
+{mesh.txt}%
+{%
+  beginfig(0);
+  \drawPath
+}%
+{%
+  \clipPath
+  endfig;
+}
 
 \end{document}
diff --git a/test/maillage.pdf b/test/maillage.pdf
new file mode 100644 (file)
index 0000000..69f345f
Binary files /dev/null and b/test/maillage.pdf differ
diff --git a/test/maillage.tex b/test/maillage.tex
new file mode 100644 (file)
index 0000000..dc9bb25
--- /dev/null
@@ -0,0 +1,58 @@
+\documentclass{article}
+%% compiler avec lualatex
+\usepackage[margin=2.5cm]{geometry}
+\usepackage{luamesh}
+\usepackage{fontspec}
+\usepackage{multido}
+\pagestyle{empty}
+
+
+\begin{document}
+
+\multido{\ii=17+1}{5}{%
+  \newpage
+  \meshAddPointBWinc[
+  scale=6cm,
+  mode=ext,step=badtriangles,
+  colorNew =green!20!red,
+  colorBack=red!10,
+  colorCircle = blue,
+  ]
+  {mesh2.txt}{\ii}%
+  {%
+    beginfig(0);
+  }%
+  {%
+    endfig;
+  }  \newpage
+  \meshAddPointBWinc[
+  scale=6cm,mode=ext,step=cavity,
+  colorNew =green!20!red,
+  colorBack=red!10,
+  colorCircle = blue,
+  ]
+  {mesh2.txt}{\ii}%
+  {%
+    beginfig(0);
+  }%
+  {%
+    endfig;
+  }  \newpage
+  \meshAddPointBWinc[
+  scale=6cm,mode=ext,step=newtriangles,
+  colorNew =green!20!red,
+  colorBack=red!10,
+  colorCircle = blue,
+  ]
+  {mesh2.txt}{\ii}%
+  {%
+    beginfig(0);
+  }%
+  {%
+    endfig;
+  }
+}
+
+
+
+\end{document}
index fffba49..89e58d4 100644 (file)
@@ -3,6 +3,7 @@
 2  4
 1.5  2
 2.  0.5
-3  3.
+3  2.6
 3.5  1
-3.7 1.5
+5 3.
+0.3 3.2
diff --git a/test/mesh2.txt b/test/mesh2.txt
new file mode 100644 (file)
index 0000000..8d7aa03
--- /dev/null
@@ -0,0 +1,36 @@
+ 8.43811445e-03 1.09038633e+00
+ 1.09386574e-01 2.26501818e-01
+ 1.03793069e-02 6.77330805e-01
+ 1.40862483e-01 9.90873081e-02
+ 9.22810362e-01 1.10875992e+00
+ 5.35578914e-01 6.56661725e-02
+ 9.27360354e-01 8.98346884e-01
+ 2.44172211e-01 5.42198897e-01
+ 4.43133582e-01 9.32939484e-01
+ 2.13065303e-01 1.09766820e+00
+ 9.16489523e-01 1.09868179e-01
+ 8.54731609e-01 6.99298222e-01
+ 7.23481980e-01 8.33816886e-01
+ 6.83575619e-01 5.39137230e-01
+ 6.97691070e-01 6.11015431e-01
+ 8.44174519e-01 3.17142034e-01
+ 6.39426875e-01 1.29410707e-01
+ 4.54014630e-01 6.34115530e-01
+ 2.74838943e-02 4.42217581e-01
+ 1.43809218e-02 9.39520820e-01
+ 2.06939623e-01 7.29778772e-01
+ 9.42208390e-01 4.38921327e-01
+ 1.06518191e+00 4.22856901e-02
+ 1.13637939e+00 5.20969145e-01
+ 3.22485260e-01 5.28391743e-02
+ 6.63903669e-01 1.12929363e+00
+ 1.01253378e+00 9.23893836e-01
+ 6.54843170e-01 2.10336417e-01
+ 1.10675068e+00 1.07951921e+00
+ 4.17646339e-01 4.64179150e-01
+ 2.31877872e-01 2.51771231e-01
+ 4.88174555e-01 2.34332232e-01
+ 1.00615585e+00 7.01003932e-01
+ 4.86847622e-01 1.08491057e+00
+ 2.49758774e-01 8.09075510e-01
+ 1.08347008e+00 2.86945022e-01
diff --git a/test/meshInit.txt b/test/meshInit.txt
new file mode 100644 (file)
index 0000000..17d8361
--- /dev/null
@@ -0,0 +1,5 @@
+0  0
+6  0
+2  4
+1.5  2
+2.  0.5

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.