101_FileIO.py 918 B

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