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
end
function TeXaddOnePointMPBW(listPoints,P,step,bbox)
- print(bbox)
output = "";
output = output .. "pair MeshPoints[];"
-- build the triangulation
\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}
--- /dev/null
+\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}
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
--- /dev/null
+ 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
--- /dev/null
+0 0
+6 0
+2 4
+1.5 2
+2. 0.5