Daniele Panozzo 629f5c7d8f reorganized folder and added a README 9 ani în urmă
..
matlab 629f5c7d8f reorganized folder and added a README 9 ani în urmă
py_igl 1524d4d294 fixed nasty memory bug in pybind11, appearing only with python 2.7 but also potentially affecting 3.x 9 ani în urmă
scripts 629f5c7d8f reorganized folder and added a README 9 ani în urmă
001_BasicTypes.py 8bcef21ea7 added conversion helpers between numpy/scipy and eigen types 9 ani în urmă
101_FileIO.py 6c117041d6 removed numpy dependencies, added constructor from lists to dense matrices 9 ani în urmă
102_DrawMesh.py 5ea66d91e2 started to support the viewer. Working on adding callbacks management 9 ani în urmă
102_DrawMeshTCP.py a2d34a6288 added reusable viewer, improved serialization 9 ani în urmă
103_Events.py 3d31b33ce7 added event handling and 103 py tutorial 9 ani în urmă
104_Colors.py ea90d493ec switched to MatrixXd for all wrappers, updated pybind11 9 ani în urmă
105_Overlays.py 6c117041d6 removed numpy dependencies, added constructor from lists to dense matrices 9 ani în urmă
201_Normals.py dc2c8e7a25 added UI in 201_Normals.py 9 ani în urmă
202_GaussianCurvature.py a11d43a8d8 added ui to 202 and 203 9 ani în urmă
203_CurvatureDirections.py 6c117041d6 removed numpy dependencies, added constructor from lists to dense matrices 9 ani în urmă
204_Gradient.py 6c117041d6 removed numpy dependencies, added constructor from lists to dense matrices 9 ani în urmă
205_Laplacian.py 6c117041d6 removed numpy dependencies, added constructor from lists to dense matrices 9 ani în urmă
301_Slice.py 026cea6924 added 304 9 ani în urmă
302_Sort.py 713685dbd4 tempoarary fix in slice, still requires some debugging 9 ani în urmă
303_LaplaceEquation.py cda229c05b added 303 LaplaceEquation 9 ani în urmă
304_LinearEqualityConstraints.py 026cea6924 added 304 9 ani în urmă
305_QuadraticProgramming.py 0cd2dc884b added 305 9 ani în urmă
306_EigenDecomposition.py b57ee21b85 added 306 9 ani în urmă
CMakeLists.txt 7b9284c5d4 trying to make the tcpwrapper python3+ compatible 9 ani în urmă
README.md 629f5c7d8f reorganized folder and added a README 9 ani în urmă
iglhelpers.py 026cea6924 added 304 9 ani în urmă
py_doc.cpp 50e014d623 windows fixes 9 ani în urmă
py_doc.h 50e014d623 windows fixes 9 ani în urmă
py_igl.cpp b57ee21b85 added 306 9 ani în urmă
py_igl_viewer.cpp a2d34a6288 added reusable viewer, improved serialization 9 ani în urmă
py_vector.cpp b57ee21b85 added 306 9 ani în urmă
python.cpp 50e499e0e9 added 301 9 ani în urmă
python.h 0cd2dc884b added 305 9 ani în urmă
tcpviewer.py 1772c67ce4 improved performances, win fixes for tcpviewer 9 ani în urmă
tcpviewer_single.py a2d34a6288 added reusable viewer, improved serialization 9 ani în urmă

README.md

Python wrappers for libigl

Work in progress

Everything in this folder is currently being developed and it is likely to be changed radically in the next couple of months, breaking compatibility between different version. We plan to stabilize the python API by the end of 2015.

Introduction

libigl functions can be called natively from python by compiling the wrappers in this folder. The wrappers supports both python 2.7 and python 3.5 and are generated using pybind11.

The generated library will statically link against all dependencies producing a single, self-contained binary.

Installation

The python bindings can be compiled with the following instructions, assuming that your terminal is pointing to the root of libigl:

cd python
mkdir build
cd build; make; cd ..

The cmake script will complain if it is not able to find python. In that case you can specify the location of the interpreter by specifying the following cmake variables.

MacOSX/Linux:

SET(PYTHON_LIBRARIES "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5m.dylib")
SET(PYTHON_INCLUDE_DIR "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/include/python3.5m")

Windows:

SET(PYTHON_LIBRARIES "C:/Python35/libs/python35.lib")
SET(PYTHON_INCLUDE_DIR "C:/Python35/include")

Tutorial

All libigl tutorials will be ported to python and will use the same naming scheme. You can find the tutorials in the folder python/tutorials and you can launch them with the following commands:

cd python
python 102_DrawMesh.py

Matrix Representation

TODO: describe in detail the wrapped eigen classes and how to convert them to numpy.

Viewer and callbacks

The igl viewer provides a convenient and efficient way of visualizing 3D surfaces in python. It behaves in the same way as the C++ viewer and supports native python functions as callbacks. This is a simple example that loads two meshes and switches between the two when a key is pressed:

import igl

V1 = igl.eigen.MatrixXd()
F1 = igl.eigen.MatrixXi()

V2 = igl.eigen.MatrixXd()
F2 = igl.eigen.MatrixXi()

def key_pressed(viewer, key, modifier):
    print("Key: ", chr(key))

    if key == ord('1'):
        # # Clear should be called before drawing the mesh
        viewer.data.clear();
        # # Draw_mesh creates or updates the vertices and faces of the displayed mesh.
        # # If a mesh is already displayed, draw_mesh returns an error if the given V and
        # # F have size different than the current ones
        viewer.data.set_mesh(V1, F1);
        viewer.core.align_camera_center(V1,F1);
    elif key == ord('2'):
        viewer.data.clear();
        viewer.data.set_mesh(V2, F2);
        viewer.core.align_camera_center(V2,F2);
    return False


#  Load two meshes
igl.readOFF("../tutorial/shared/bumpy.off", V1, F1);
igl.readOFF("../tutorial/shared/fertility.off", V2, F2);

print("1 Switch to bump mesh")
print("2 Switch to fertility mesh")

viewer = igl.viewer.Viewer()

# Register a keyboard callback that allows to switch between
# the two loaded meshes
viewer.callback_key_pressed = key_pressed
viewer.data.set_mesh(V1, F1)
viewer.launch()

Remote viewer

Whe using the viewer from an interactive python shell (iPython), it is inconvenient to let the viewer take control of the main thread for rendering purposes. We provide a simple wrapper for the viewer that allows to launch a remote process and send meshes to it via a TCP/IP socket. For more informations on how to use it see the documentation in tcpviewer.py

Matlab

The python wrappers can be natively being used from MATLAB. We provide a few examples in the folder python/matlab.

Documentation

The python functions have exactly the same prototypes as their C++ counterpart. To get help for a certain function, please check the documentation in the corresponding .h file in libigl/include. We will add a proper docstring documentation in the future.

Known Issues

Contact

Libigl is a group endeavor led by Alec Jacobson and Daniele Panozzo. Please contact us if you have questions or comments. For troubleshooting, please post an issue on github.

If you're using libigl in your projects, quickly drop us a note. Tell us who you are and what you're using it for. This helps us apply for funding and justify spending time maintaining this.

If you find bugs or have problems please use our github issue tracking page.

Copyright

2015 Alec Jacobson, Daniele Panozzo, Christian Schüller, Olga Diamanti, Qingnan Zhou, Nico Pietroni, Stefan Brugger, Kenshi Takayama, Wenzel Jakob, Nikolas De Giorgis, Luigi Rocca, Leonardo Sacht, Olga Sorkine-Hornung, and others.

Please see individual files for appropriate copyright notices.