| 1 |
#!/usr/bin/env python |
| 2 |
|
| 3 |
import numpy as np |
| 4 |
import matplotlib |
| 5 |
import matplotlib.tri |
| 6 |
from mpl_toolkits import mplot3d |
| 7 |
import matplotlib.pyplot as plt |
| 8 |
import sys |
| 9 |
|
| 10 |
# plots the output of printVertEdges |
| 11 |
|
| 12 |
if len(sys.argv) == 2: |
| 13 |
fname = sys.argv[1]; |
| 14 |
else: |
| 15 |
print("Usage: {} fname".format(sys.argv[0])) |
| 16 |
exit(1) |
| 17 |
|
| 18 |
|
| 19 |
verts = np.loadtxt(fname + "_verts.txt") |
| 20 |
edges = np.loadtxt(fname + "_edges.txt", int) |
| 21 |
|
| 22 |
print("verts = \n", verts) |
| 23 |
print("edges = \n", edges) |
| 24 |
|
| 25 |
print("vert radii") |
| 26 |
for i in range(verts.shape[0]): |
| 27 |
print("vert ", i, ", r = ", np.sqrt(verts[i, 0]**2 + verts[i, 1]**2 + verts[i, 2]**2)) |
| 28 |
|
| 29 |
|
| 30 |
fig = plt.figure() |
| 31 |
ax = plt.axes(projection='3d') |
| 32 |
ax.plot3D(verts[:, 0], verts[:, 1], verts[:, 2], 'ro') |
| 33 |
|
| 34 |
#for i in range(verts.shape[0]): |
| 35 |
# ax.text(verts[i, 0], verts[i, 1], verts[i,2], '%s' % (str(i))) |
| 36 |
|
| 37 |
|
| 38 |
for i in range(edges.shape[0]): |
| 39 |
print("edge between verts ", edges[i, 0], " and ", edges[i, 1]) |
| 40 |
print(verts[edges[i, :], 1]) |
| 41 |
ax.plot3D(verts[edges[i, :], 0], verts[edges[i, :], 1], verts[edges[i, :], 2], 'b-') |
| 42 |
|
| 43 |
ax.set_xlabel('x') |
| 44 |
ax.set_ylabel('y') |
| 45 |
ax.set_zlabel('z') |
| 46 |
|
| 47 |
fig.savefig(fname + ".png", dpi=300) |
| 48 |
plt.show() |