102_DrawMesh.py 576 B

12345678910111213141516171819202122
  1. import sys, os
  2. import numpy as np
  3. import igl
  4. import matplotlib.pyplot as plt
  5. from mpl_toolkits.mplot3d import Axes3D
  6. import matplotlib.tri as mtri
  7. # Load a mesh in OFF format
  8. V = igl.eigen.MatrixXd()
  9. F = igl.eigen.MatrixXi()
  10. igl.readOFF("../tutorial/shared/beetle.off", V, F)
  11. # Convert the mesh to numpy matrices (without copying it)
  12. Vn = np.array(V, copy=False)
  13. Fn = np.array(F, copy=False)
  14. # Plot using matplotlib
  15. fig = plt.figure()
  16. ax = fig.add_subplot(1, 1, 1, projection='3d')
  17. ax.plot_trisurf(Vn[:,0], Vn[:,1], Vn[:,2], triangles=Fn, cmap=plt.cm.Spectral)
  18. plt.show()