{"id":664,"date":"2014-11-05T07:54:32","date_gmt":"2014-11-05T07:54:32","guid":{"rendered":"https:\/\/block.arch.ethz.ch\/blog\/?p=664"},"modified":"2015-01-05T14:13:30","modified_gmt":"2015-01-05T14:13:30","slug":"shapeop-python-bindings","status":"publish","type":"post","link":"https:\/\/block.arch.ethz.ch\/blog\/2014\/11\/shapeop-python-bindings\/","title":{"rendered":"ShapeOp Python bindings"},"content":{"rendered":"<p>Recently, the <a href=\"http:\/\/lgg.epfl.ch\/\" target=\"_blank\">Computer Graphics and Geometry Laboratory<\/a> of EPFL released the ShapeOp library, which is &#8220;<em>a header-only C++ library for static and dynamic geometry processing, using a unified framework for optimization under constraints<\/em>&#8220;.<\/p>\n<p>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 <a href=\"https:\/\/www.macports.org\/\" title=\"macports\" target=\"_blank\">macports<\/a>, <a href=\"https:\/\/store.continuum.io\/cshop\/anaconda\/\" title=\"anaconda python distribution\" target=\"_blank\">anaconda<\/a>, <a href=\"http:\/\/brew.sh\/\" title=\"homebrew\" target=\"_blank\">homebrew<\/a> &#8230;, you may need a few more instructions. I will describe the process for the macports version of Python.<\/p>\n<p><!--more--><\/p>\n<p>First of all, make sure you have the following ports installed:<\/p>\n<ul>\n<li>cmake<\/li>\n<li>swig<\/li>\n<li>python-swig<\/li>\n<li>boost<\/li>\n<li>eigen<\/li>\n<li>eigen3<\/li>\n<\/ul>\n<p>This will take some time, so go do something else while it is happening. Then proceed as instructed in the SahpeOp documentation:<\/p>\n<pre class=\"brush: bash; gutter: false\">\r\n$ mkdir build\r\n$ cd build\r\n$ cmake .. -DSWIG_PYTHON=TRUE\r\n$ make\r\n<\/pre>\n<p>Finally modify the link path of <em>_shapeopPython.so<\/em> using <em>install_name_tool<\/em>. You need to have the <em>CommandLine Tools<\/em> of <em>XCode<\/em> installed to do this, but if you got this far, i assume this is already taken care of.<\/p>\n<p>First, check the current link path:<\/p>\n<pre class=\"brush: bash; gutter: false\">\r\n$ cd .\/libShapeOp\/bindings\/python\r\n$ otool -L _shapeopPython.so\r\n\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Python\r\n\/usr\/lib\/libc++.1.dylib\r\n\/usr\/lib\/libSystem.B.dylib\r\n<\/pre>\n<p>The first link should be changed. Therefore, do the following:<\/p>\n<pre class=\"brush: bash; gutter: false\">\r\n$ 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\r\n<\/pre>\n<p>After this, executing the <em>runme.py<\/em> file should return this output:<\/p>\n<pre class=\"brush:py; gutter: false\">\r\nInput points:\r\n0.0 0.5 0.5 0.0 \r\n0.0 0.0 1.0 1.0 \r\n0.0 1.0 0.0 1.0 \r\nOutput points:\r\n0.0 0.0 0.0 0.0 \r\n0.0 0.0 1.0 1.0 \r\n0.0 1.0 0.0 1.0 \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Recently, the Computer Graphics and Geometry Laboratory of EPFL released the ShapeOp library, which is &#8220;a header-only C++ library for static and dynamic geometry processing, using a unified framework for optimization under constraints&#8220;. The process of creating Python bindings for the library is described in the official documentation. However, if you are on Mac and [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-664","post","type-post","status-publish","format-standard","hentry","category-code"],"_links":{"self":[{"href":"https:\/\/block.arch.ethz.ch\/blog\/wp-json\/wp\/v2\/posts\/664","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/block.arch.ethz.ch\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/block.arch.ethz.ch\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/block.arch.ethz.ch\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/block.arch.ethz.ch\/blog\/wp-json\/wp\/v2\/comments?post=664"}],"version-history":[{"count":12,"href":"https:\/\/block.arch.ethz.ch\/blog\/wp-json\/wp\/v2\/posts\/664\/revisions"}],"predecessor-version":[{"id":677,"href":"https:\/\/block.arch.ethz.ch\/blog\/wp-json\/wp\/v2\/posts\/664\/revisions\/677"}],"wp:attachment":[{"href":"https:\/\/block.arch.ethz.ch\/blog\/wp-json\/wp\/v2\/media?parent=664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/block.arch.ethz.ch\/blog\/wp-json\/wp\/v2\/categories?post=664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/block.arch.ethz.ch\/blog\/wp-json\/wp\/v2\/tags?post=664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}