ShapeOp Python bindings
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:
1.
$
mkdir
build
2.
$
cd
build
3.
$ cmake .. -DSWIG_PYTHON=TRUE
4.
$
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:
1.
$
cd
./libShapeOp/bindings/python
2.
$ otool -L _shapeopPython.so
3.
/System/Library/Frameworks/Python.framework/Versions/2.7/Python
4.
/usr/lib/libc++.1.dylib
5.
/usr/lib/libSystem.B.dylib
The first link should be changed. Therefore, do the following:
1.
$ 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:
1.
Input points:
2.
0.0
0.5
0.5
0.0
3.
0.0
0.0
1.0
1.0
4.
0.0
1.0
0.0
1.0
5.
Output points:
6.
0.0
0.0
0.0
0.0
7.
0.0
0.0
1.0
1.0
8.
0.0
1.0
0.0
1.0