604_Triangle.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. # This file is part of libigl, a simple c++ geometry processing library.
  2. #
  3. # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>
  4. #
  5. # This Source Code Form is subject to the terms of the Mozilla Public License
  6. # v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. # obtain one at http://mozilla.org/MPL/2.0/.
  8. import sys, os
  9. # Add the igl library to the modules search path
  10. sys.path.insert(0, os.getcwd() + "/../")
  11. import pyigl as igl
  12. from shared import check_dependencies
  13. dependencies = ["triangle", "viewer"]
  14. check_dependencies(dependencies)
  15. # Input polygon
  16. V = igl.eigen.MatrixXd([[-1, -1], [1, -1], [1, 1], [-1, 1], [-2, -2], [2, -2], [2, 2], [-2, 2]])
  17. E = igl.eigen.MatrixXi([[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6,7], [7,4]])
  18. H = igl.eigen.MatrixXd([[0, 0]])
  19. # Triangulated Interior
  20. V2 = igl.eigen.MatrixXd()
  21. F2 = igl.eigen.MatrixXi()
  22. igl.triangle.triangulate(V, E, H, "a0.005q", V2, F2)
  23. # Plot the mesh
  24. viewer = igl.viewer.Viewer()
  25. viewer.data.set_mesh(V2, F2)
  26. viewer.launch()