find_hull crashes or returns unclear result
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 541
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 5
Description
Trying to get the convex hull of a simple face I run into exceptions or unclear results:
## To Reproduce the crash
### Code
```python
import cadquery as cq
obj = cq.Workplane().box(2, 4, 0.1)
obj = obj.cut(cq.Workplane().cylinder(0.1, 0.9))
obj = obj.cut(cq.Workplane().cylinder(0.1, 0.9).translate((0.4, 2, 0)))
obj = obj.union(cq.Workplane().cylinder(0.1, 0.9).translate((-0.4, -2, 0)))
face = obj.faces(">Z")
show(face)
```

```python
hull = cq.hull.find_hull(face.edges().vals())
```
### Backtrace
```
---------------------------------------------------------------------------
StdFail_NotDone Traceback (most recent call last)
Input In [142], in ()
----> 1 hull = cq.hull.find_hull(face.edges().vals())
2 show(face, hull, show_parent=False)
File /opt/anaconda/envs/jcq3/lib/python3.9/site-packages/cadquery/hull.py:405, in find_hull(edges)
400 current_e, current_angle, finished = update_hull(
401 current_e, next_ix, entities, angles, segments, rv
402 )
404 # convert back to Edges and return
--> 405 return finalize_hull(rv)
File /opt/anaconda/envs/jcq3/lib/python3.9/site-packages/cadquery/hull.py:342, in finalize_hull(hull)
339 for el_p, el, el_n in zip(hull, hull[1:], hull[2:]):
341 if isinstance(el, Segment):
--> 342 rv.append(Edge.makeLine(Vector(el.a.x, el.a.y), Vector(el.b.x, el.b.y)))
343 elif (
344 isinstance(el, Arc)
345 and isinstance(el_p, Segment)
346 and isinstance(el_n, Segment)
347 ):
348 a1 = degrees(atan2p(el_p.b.x - el.c.x, el_p.b.y - el.c.y))
File /opt/anaconda/envs/jcq3/lib/python3.9/site-packages/cadquery/occ_impl/shapes.py:1826, in Edge.makeLine(cls, v1, v2)
1818 @classmethod
1819 def makeLine(cls, v1: Vector, v2: Vector) -> "Edge":
1820 """
1821 Create a line between two points
1822 :param v1: Vector that represents the first point
1823 :param v2: Vector that represents the second point
1824 :return: A linear edge between the two provided points
1825 """
-> 1826 return cls(BRepBuilderAPI_MakeEdge(v1.toPnt(), v2.toPnt()).Edge())
StdFail_NotDone: BRep_API: command not done
```
## To Reproduce the unclear result:
### Code
Simplify the object
```python
import cadquery as cq
obj = cq.Workplane().box(2, 4, 0.1)
obj = obj.cut(cq.Workplane().cylinder(0.1, 0.9))
obj = obj.cut(cq.Workplane().cylinder(0.1, 0.9).translate((0.4, 2, 0)))
face = obj.faces(">Z")
hull = cq.hull.find_hull(face.edges().vals())
show(face, hull)
```
### Result

## What I would have expected:
First case

Second case

Do I use it in a wrong way?
## Environment
OS: Linux
Was CadQuery installed using Conda?: With conda as described in the Readme
Output of `conda list` from your active Conda environment:
```
Package Version Editable project location
----------------------------- ------------------ ----------------------------------------------------------
anyio 3.5.0
argon2-cffi 21.3.0
argon2-cffi-bindings 21.2.0
astroid 2.9.0
asttokens 2.0.5
attrs 21.4.0
Babel 2.9.1
backcall 0.2.0
backports.functools-lru-cache 1.6.4
beautifulsoup4 4.11.1
black 21.12b0
blackcellmagic 0.0.3
bleach 5.0.0
brep-part-finder 0.4.1
brep-to-h5m 0.3.1
brotlipy 0.7.0
build123d 0.1.0 /home/bernhard/Development/CAD/build123d
bumpversion 0.5.3
cached-property 1.5.2
cachetools 5.2.0
cad-viewer-widget 1.4.0
cadquery 2.1
cadquery-massembly 1.0.0rc1 /home/bernhard/Development/CAD/cadquery/cadquery-massembly
certifi 2021.10.8
cffi 1.15.0
charset-normalizer 2.0.12
click 8.0.4
cmarkgfm 0.8.0
colorama 0.4.4
cq-gears 0.62
cryptography 36.0.0
cycler 0.11.0
dataclasses 0.8
debugpy 1.6.0
decorator 5.1.1
defusedxml 0.7.1
docstring-to-markdown 0.10
docutils 0.18.1
entrypoints 0.4
executing 0.8.3
ezdxf 0.17.2
fastjsonschema 2.15.3
fonttools 4.31.2
gitdb 4.0.9
GitPython 3.1.27
h5py 3.2.1
idna 3.3
importlib-metadata 4.11.3
ipykernel 6.13.0
ipython 8.2.0
ipython-genutils 0.2.0
ipywidgets 7.7.0
isort 5.10.1
jedi 0.17.2
jeepney 0.7.1
Jinja2 3.1.1
json5 0.9.6
jsonschema 4.4.0
jupyter 1.0.0
jupyter-cadquery 3.4.0 /home/bernhard/Development/CAD/cadquery/jupyter-cadquery
jupyter-client 6.1.12
jupyter-console 6.4.3
jupyter-core 4.9.2
jupyter-lsp 1.5.1
jupyter-server 1.17.0
jupyter-server-mathjax 0.2.5
jupyterlab 3.4.5
jupyterlab-git 0.37.1
jupyterlab-pygments 0.2.0
jupyterlab-server 2.11.2
jupyterlab-widgets 1.1.0
keyring 23.4.0
kiwisolver 1.4.1
lazy-object-proxy 1.7.1
loguru 0.5.3
MarkupSafe 2.1.1
matplotlib 3.5.1
matplotlib-inline 0.1.3
mccabe 0.6.1
mistune 0.8.4
mpmath 1.2.1
multimethod 1.6
mypy-extensions 0.4.3
nbclassic 0.3.7
nbclient 0.5.13
nbconvert 6.5.0
nbdime 3.1.1
nbformat 5.3.0
nest-asyncio 1.5.5
networkx 2.7.1
nlopt 2.7.1
notebook 6.4.10
notebook-shim 0.1.0
nptyping 1.4.4
numpy 1.22.3
numpy-quaternion 2022.4.1
OCP-stubs 7.5.1
packaging 21.3
pandas 1.4.2
pandocfilters 1.5.0
paramak 0.8.2
parso 0.7.1
pathspec 0.9.0
pexpect 4.8.0
pickleshare 0.7.5
Pillow 9.0.1
pip 22.0.4
pkginfo 1.8.2
plasmaboundaries 0.1.8
platformdirs 2.5.1
plotly 5.6.0
pluggy 1.0.0
prometheus-client 0.14.1
prompt-toolkit 3.0.29
psutil 5.9.0
ptyprocess 0.7.0
pure-eval 0.2.2
pycparser 2.21
Pygments 2.11.2
pylint 2.12.2
pyOpenSSL 22.0.0
pyparsing 3.0.8
pyrsistent 0.18.1
PySocks 1.7.1
python-dateutil 2.8.2
python-jsonrpc-server 0.4.0
python-language-server 0.36.2+49.g3536061
pytz 2022.1
pyzmq 22.3.0
qtconsole 5.3.0
QtPy 2.0.1
readme-renderer 27.0
requests 2.27.1
requests-toolbelt 0.9.1
rfc3986 2.0.0
scipy 1.8.0
SecretStorage 3.3.1
Send2Trash 1.8.0
setuptools 62.1.0
setuptools-scm 6.4.2
six 1.16.0
smmap 5.0.0
sniffio 1.2.0
soupsieve 2.3.2
stack-data 0.2.0
stl-to-h5m 0.2.1
sympy 1.10.1
tenacity 8.0.1
terminado 0.13.3
testpath 0.6.0
tinycss2 1.1.1
toml 0.10.2
tomli 1.2.3
tornado 6.1
tqdm 4.63.0
traitlets 5.1.1
trimesh 3.10.7
twine 0.0.0
typed-ast 1.5.2
typing_extensions 4.1.1
typish 1.9.3
ujson 5.2.0
urllib3 1.26.9
voila 0.3.5
vtk 9.0.1
wcwidth 0.2.5
webcolors 1.12
webencodings 0.5.1
websocket-client 1.3.1
websockets 10.2
wheel 0.37.1
widgetsnbextension 3.6.0
wrapt 1.12.1
zipp 3.7.0
```
Using: Jupyter Cadquery and verified on CQ-Editor
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.