604_Triangle.py 1.1 KB

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