ShapeOp Python bindings

share on google plus share on facebook share on twitter share on linkedin share via email

Recently, the Computer Graphics and Geometry Laboratory of EPFL released the ShapeOp library, which is “a header-only C++ library for static and dynamic geometry processing, using a unified framework for optimization under constraints“.

The process of creating Python bindings for the library is described in the official documentation. However, if you are on Mac and using a non-framework version of Python, such as one provided by macports, anaconda, homebrew …, you may need a few more instructions. I will describe the process for the macports version of Python.

First of all, make sure you have the following ports installed:

  • cmake
  • swig
  • python-swig
  • boost
  • eigen
  • eigen3

This will take some time, so go do something else while it is happening. Then proceed as instructed in the SahpeOp documentation:

$ mkdir build
$ cd build
$ cmake .. -DSWIG_PYTHON=TRUE
$ make

Finally modify the link path of _shapeopPython.so using install_name_tool. You need to have the CommandLine Tools of XCode installed to do this, but if you got this far, i assume this is already taken care of.

First, check the current link path:

$ cd ./libShapeOp/bindings/python
$ otool -L _shapeopPython.so
/System/Library/Frameworks/Python.framework/Versions/2.7/Python
/usr/lib/libc++.1.dylib
/usr/lib/libSystem.B.dylib

The first link should be changed. Therefore, do the following:

$ install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib _shapeopPython.so

After this, executing the runme.py file should return this output:

Input points:
0.0 0.5 0.5 0.0 
0.0 0.0 1.0 1.0 
0.0 1.0 0.0 1.0 
Output points:
0.0 0.0 0.0 0.0 
0.0 0.0 1.0 1.0 
0.0 1.0 0.0 1.0 

Leave a response

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>