101_FileIO.py 942 B

1234567891011121314151617181920212223242526272829
  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 TUTORIAL_SHARED_PATH
  15. # Load a mesh in OFF format
  16. V = igl.eigen.MatrixXd()
  17. F = igl.eigen.MatrixXi()
  18. igl.readOFF(TUTORIAL_SHARED_PATH + "cube.off", V, F)
  19. # Print the vertices and faces matrices (commented out to make this file compatible with python 2.x and 3.x)
  20. # print("Vertices: \n", V, sep='')
  21. # print("Faces: \n", F, sep='')
  22. # Save the mesh in OBJ format
  23. igl.writeOBJ("cube.obj",V,F)