ShapeOp  0.1.0
libShapeOp

C++ libShapeOp

libShapeOp is a lightweight C++ library for static and dynamic geometry processing. The main library is located in libShapeOp/src. The library can also be used as header only if SHAPEOP_HEADER_ONLY is defined. OpenMP can be activated by passing -DOPENMP=TRUE as options to CMake. The library can be compiled in double or in float by changing the ShapeOpScalar typedef located in Common.h. An example on how to use libShapeOp is provided (libShapeOp/bindings/c++/runme.cpp).

C API

A C API is provided along with the C++ library. The API is located in libShapeOp/api. This C API is useful when libShapeOp needs to be used from another programming language (see Automatic Bindings with SWIG for example). An example on how to use the API is provided (libShapeOp/bindings/c/runme.c).

Automatic Bindings with SWIG

SWIG (http://www.swig.org/) is a tool to automatically create binding between programs written in C and C++ and a variety of programming languages such as Javascript, Perl, and Python. The code generated by SWIG is compatible with both commercial and non-commercial projects. To install SWIG Unix or Mac use your favorite package manager. For Windows download the binary from the SWIG website. The CMake file builds Python, Java, and C# bindings as an example.

Python.

To generate the Python bindings you will need to pass -DSWIG_PYTHON=TRUE as options to CMake or set this cached variable in a CMake Gui. If CMake does not find your python installation automatically, you can set the PYTHON_LIBRARY and PYTHON_INCLUDE_DIR cached variable as before to your python version installed ( to e.g. on OSX10.10 with the preinstalled python only: /System/Library/Frameworks/Python.framework/Headers respectively /usr/lib/libpython2.7.dylib or on Windows default installer from python.org to C:/Python27/python.exe respectively C:/Python27/include ). Make sure you install a 64bit version of Python if you are building ShapeOp in 64bit (default), 32bit otherwise. A runme.py file is also provided (libShapeOp/bindings/python/runme.py). It shows how the Python bindings can be used to call libShapeOp. The runme.py file can be executed from the build directory by typing ( when building with Visual Studio, first copy the file _shapeopPython.pyd from the Release subfolder into the folder of runme.py )

For building bindings to python 3 add the flag -py3 as indicated in the comments in bindings/python/CMakeLists.txt, install python 3 and adapt the library and include_dir in cmake.

Java.

To generate the Java bindings you will need to pass -DSWIG_JAVA=TRUE as options to CMake. A runme.java file is also provided (libShapeOp/bindings/java/runme.java). It shows how the Java bindings can be used to call libShapeOp. The runme.java file can be executed from the build directory by typing

C#.

To generate the C# bindings you will need to pass -DSWIG_CSHARP=TRUE as options to CMake. A runme.cs file is also provided (libShapeOp/bindings/csharp/runme.cs). It shows how the C# bindings can be used to call libShapeOp. Under Unix first install Mono (http://www.mono-project.com) using the package manager. The runme.cs file can then can be executed from the build directory by typing

Coding Rules

We are using astyle (http://astyle.sourceforge.net/) to enforce a coding style for the library. To install astyle under Unix or Mac use your favorite package manager. For Windows download the binary from the astyle website. The style file libShapeOp.astyle can be found in the libShapeOp/astyle folder along with a bash script run_astyle.sh to run astyle with libShapeOp coding style.