-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path19_meshing.py
35 lines (34 loc) · 982 Bytes
/
19_meshing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import numpy
import matplotlib.patches
import matplotlib.pyplot as plt
from del_msh import TriMesh, PolyLoop
if __name__ == "__main__":
vtx2xy_in = numpy.array([
[0, 0],
[1, 0],
[1, 0.6],
[0.6, 0.6],
[0.6, 1.0],
[0, 1]], dtype=numpy.float32)
##
tri2vtx, vtx2xy = PolyLoop.tesselation2d(vtx2xy_in)
_, ax = plt.subplots()
ax.set_aspect('equal')
ax.triplot(vtx2xy[:, 0], vtx2xy[:, 1], tri2vtx)
plt.show()
##
xys = TriMesh.sample_many(tri2vtx, vtx2xy, 1000)
_, ax = plt.subplots()
ax.set_aspect('equal')
ax.scatter(xys[:, 0], xys[:, 1])
ax.add_patch(matplotlib.patches.Polygon(xy=vtx2xy_in, closed=True, fill=False))
plt.show()
##
tri2vtx, vtx2xy = PolyLoop.tesselation2d(
vtx2xy_in,
resolution_edge=0.08,
resolution_face=0.08)
_, ax = plt.subplots()
ax.set_aspect('equal')
ax.triplot(vtx2xy[:, 0], vtx2xy[:, 1], tri2vtx)
plt.show()