Skip to content

Commit 686d943

Browse files
author
Teseo Schneider
committed
Contributing
1 parent 283a0fd commit 686d943

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,4 @@ nav:
6767
- Chapter 5: tut-chapter5.ipynb
6868
- Chapter 6: tut-chapter6.ipynb
6969
- Docs: igl_docs.md
70+
- Contributing: contributing.md

tutorial/contributing.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Contributing
2+
3+
4+
We are trying to keep the development of the bindings flexible, thus there is no much organization/maintenance.
5+
6+
If you want to contribute and expose additional features, thank you!
7+
8+
For any new binding please create a new pull request on git, if everything looks good we will merge it.
9+
10+
**Note 1**, see your new feature in the conda version it might require some time, since we are planning to accumulate several fixes and
11+
features before publishing a new version on conda.
12+
13+
**Note 2** we are not planning to bind any function not under MIT/LGLP licence since it would make the whole package not LGPL. If you plan to bind something dependent on CGAL/Triangle/TetGen, don't do it.
14+
15+
16+
The general rule of thumb is to keep the python side clean, and copy/hack in the binding if necessary.
17+
In such a way, if something is fixed (on igl or the bindings) it will not break any python code.
18+
19+
20+
## Binding a function
21+
22+
**Note** The following are rough instructions, proceed with caution!
23+
24+
1. Some function have already a binding skeleton, you can look in subfolders of `attic`. If the file exists move it to `src`, otherwise copy an existing binding.
25+
2. Move to documentation in the correct spots.
26+
3. Fix the input types:
27+
* every `MatrixXi` it should have `dense_int`, `dense_long`, `dense_longlong`
28+
* every `MatrixXd` it should be `dense_float`, `dense_double`
29+
* similar for sparse matrice
30+
* avoid having too many combinations, for instance the second `MatrixXi` should be `npe_matches(v)`
31+
4. **IMPORTANT**: add assertions regarding the input (in particular the sizes), [common.h](https://github.com/libigl/libigl-python-bindings/blob/master/src/include/common.h) contains examples and typical assertions.
32+
5. If libigl has overloading, you can either remove some functions (e.g, multiple return type can be skipped in ptyhon) or give them different names.
33+
6. If libigl is not properly templated (or any other template related problem), you can create a copy of the input (see [qslim.cpp](https://github.com/libigl/libigl-python-bindings/blob/master/src/qslim.cpp)). In this case add the suffix `_copy` to any copied the variable and return the correct python type (which might involve another copy).
34+
7. *Add a test* to just run the new function in the [test_basic.py](https://github.com/libigl/libigl-python-bindings/blob/master/tests/test_basic.py) file. At least assert for the correct `dtype`, `size`, and `c_contiguous` (correct major).
35+
36+
A simple complete example is [decimate.cpp](https://github.com/libigl/libigl-python-bindings/blob/master/src/decimate.cpp).
37+
38+
Some times, libigl will not compile because of the MatrixBase vs PlainObjectBase, you need to change the PlainObjectBase to MatrixBase to make it compile.
39+
This requires chaning libigl, so you need to create a PR in the main repository.
40+
41+
42+
## Binding a class
43+
44+
We strongly discurage binding classes since it is more difficult and most of igl function do not require it.
45+
46+
If you still want to try, consider the option of "hidig the class in python", that is expose only the final compute, and internally allocate the object, call the methods and then compute.
47+
48+
If you are still convinced that a class (more complicated) is the way to go look at [classes.cpp](https://github.com/libigl/libigl-python-bindings/blob/master/classes/classes.cpp) for an example. There are not many guidelines for that since most igl function are class-less.
49+
50+
51+
In any case, **IMPORTANT**: add assertions regarding the input (in particular the sizes), [common.h](https://github.com/libigl/libigl-python-bindings/blob/master/src/include/common.h) contains examples and typical assertions.

0 commit comments

Comments
 (0)