604_Triangle.py 582 B

123456789101112131415161718192021
  1. # Add the igl library to the modules search path
  2. import sys, os
  3. sys.path.insert(0, os.getcwd() + "/../")
  4. import pyigl as igl
  5. # Input polygon
  6. V = igl.eigen.MatrixXd([[-1, -1], [1, -1], [1, 1], [-1, 1], [-2, -2], [2, -2], [2, 2], [-2, 2]])
  7. E = igl.eigen.MatrixXi([[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6,7], [7,4]])
  8. H = igl.eigen.MatrixXd([[0, 0]])
  9. # Triangulated Interior
  10. V2 = igl.eigen.MatrixXd()
  11. F2 = igl.eigen.MatrixXi()
  12. igl.triangle_triangulate(V, E, H, "a0.005q", V2, F2)
  13. # Plot the mesh
  14. viewer = igl.viewer.Viewer()
  15. viewer.data.set_mesh(V2, F2)
  16. viewer.launch()