Shape.tessellate seems to be slow and crashes when poly is None
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 541
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 5
Description
### 1 Performance issue
I got complaints that `juypter-cadquery` is very slow, so I looked into it. Despite some less optimal implementations on my side, it turns out that the python code for `Shape.tessellate` seems to be very slow.
If I compare the latest version of `pythonocc-core` 7.4.1 with CadQuery 2.1 based on `OCP 7.4.1` for one of the `pythonocc-demos` examples (https://github.com/tpaviot/pythonocc-demos/blob/master/assets/models/RC_Buggy_2_front_suspension.stp), I find the following:
- PythonOCC

- Cadquery 2.1 (for comparison I selected the quality params to return roughly the same number of vertices)

This is 1.671 sec for `pythonocc-code` vs. 35.272 sec for CadQuery (which means CadQuery is 20x slower, already without delivering the normals)
**Question**: Could the tessellate algorithm (including the currently missing normals) be added as C++ code to CadQuery? Maybe similar to https://github.com/tpaviot/pythonocc-core/tree/6564f034dcebf882d4f51c897bd0a8adfe912817/src/Tesselator
### 2 Bug
Additionally I had to patch `Shape.tessellate` from
```python
loc = TopLoc_Location()
poly = BRep_Tool.Triangulation_s(f.wrapped, loc)
Trsf = loc.Transformation()
```
```python
loc = TopLoc_Location()
poly = BRep_Tool.Triangulation_s(f.wrapped, loc)
if poly is None:
continue
Trsf = loc.Transformation()
```
It looks like `BRep_Tool.Triangulation_s` sometimes comes back with `None`
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.