| 1 |
#!/usr/bin/env python |
| 2 |
|
| 3 |
import numpy as np |
| 4 |
import matplotlib |
| 5 |
import matplotlib.tri |
| 6 |
import matplotlib.pyplot as plt |
| 7 |
import sys |
| 8 |
|
| 9 |
# plots the output of printVertEdges |
| 10 |
|
| 11 |
if len(sys.argv) == 2: |
| 12 |
fname = sys.argv[1]; |
| 13 |
else: |
| 14 |
print("Usage: {} fname".format(sys.argv[0])) |
| 15 |
exit(1) |
| 16 |
|
| 17 |
|
| 18 |
verts = np.loadtxt(fname + "_verts.txt") |
| 19 |
edges = np.loadtxt(fname + "_edges.txt", int) |
| 20 |
|
| 21 |
print("verts = \n", verts) |
| 22 |
print("edges = \n", edges) |
| 23 |
|
| 24 |
#tri = matplotlib.tri.Triangulation(verts[:, 0], verts[:, 1], tris) |
| 25 |
|
| 26 |
fig, ax = plt.subplots() |
| 27 |
ax.plot(verts[:, 0], verts[:, 1], 'ro') |
| 28 |
|
| 29 |
for i in range(verts.shape[0]): |
| 30 |
ax.annotate(i, (verts[i, 0], verts[i, 1])) |
| 31 |
|
| 32 |
for i in range(edges.shape[0]): |
| 33 |
print("edge between verts ", edges[i, 0], " and ", edges[i, 1]) |
| 34 |
print("v1 = ", verts[edges[i, 0], :], ", v2 = ", verts[edges[i, 1], :]) |
| 35 |
ax.plot(verts[edges[i, :], 0], verts[edges[i, :], 1], 'b-') |
| 36 |
|
| 37 |
fig.savefig(fname + ".png", dpi=300) |
| 38 |
|
| 39 |
plt.show() |