CadQuery / cadquery

A python parametric CAD scripting framework based on OCCT
https://cadquery.readthedocs.io
Other
3.13k stars 289 forks source link

Sweep along spline fails with numerical dependency #1039

Open gumyr opened 2 years ago

gumyr commented 2 years ago

While sweeping a spline I discovered strange numerical dependencies as illustrated in this example:

from cadquery import Vector, Edge, Wire, Solid

arc_width = 701.0
x_offset = 2 * arc_width + 1
spline_start = Vector(x_offset, 0.0, 0.0)
spline_end = Vector(x_offset, arc_width, 0.0)
spline_initial_tangent = Vector(2.0, 0.0, 0.1)

# The following sweep fails if 700.0 > arc_width < 2789.0 and generates the following errors:
# if x_offset > 2*arc_width:
#   OCP.Standard.Standard_ConstructionError: gp_Vec::Normalized() - vector has zero norm
# else:
#   OCP.StdFail.StdFail_NotDone: BRepOffsetAPI_MakePipeShell::MakeSolid

problematic_spline = Edge.makeSpline(
    [spline_start, spline_end],
    tangents=(spline_initial_tangent, -spline_initial_tangent),
    scale=False,
)
swept_problematic_spline = Solid.sweep(
    Wire.makeCircle(
        50, problematic_spline.positionAt(0), problematic_spline.tangentAt(0)
    ),
    [],
    problematic_spline,
)
if "show_object" in locals():
    show_object(swept_problematic_spline, name="swept_problematic_spline")

I'm guessing something strange is happening in OCCT - is there any other explanation that makes sense?

I get the same result with cadquery master of a couple weeks ago and one from the end of last year.

output of conda list:

# packages in environment at /home/roger/anaconda3/envs/cq39:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       1_gnu    conda-forge
alabaster                 0.7.12                     py_0    conda-forge
alsa-lib                  1.2.3                h516909a_0    conda-forge
argh                      0.26.2          pyh9f0ad1d_1002    conda-forge
arrow                     1.2.2              pyhd8ed1ab_0    conda-forge
astroid                   2.5.8            py39hf3d152e_0    conda-forge
asttokens                 2.0.5              pyhd8ed1ab_0    conda-forge
atomicwrites              1.4.0              pyh9f0ad1d_0    conda-forge
attrs                     21.4.0             pyhd8ed1ab_0    conda-forge
autopep8                  1.6.0              pyhd8ed1ab_0    conda-forge
babel                     2.9.1              pyh44b312d_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                        py_2    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
beautifulsoup4            4.10.0             pyha770c72_0    conda-forge
binaryornot               0.4.4                      py_1    conda-forge
black                     22.1.0             pyhd8ed1ab_0    conda-forge
bleach                    4.1.0              pyhd8ed1ab_0    conda-forge
brotlipy                  0.7.0           py39h3811e60_1003    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
c-ares                    1.18.1               h7f98852_0    conda-forge
ca-certificates           2021.10.8            ha878542_0    conda-forge
cadquery                  master                    py3.9    cadquery
certifi                   2021.10.8        py39hf3d152e_1    conda-forge
cffi                      1.15.0           py39h4bc2ebd_0    conda-forge
chardet                   4.0.0            py39hf3d152e_2    conda-forge
charset-normalizer        2.0.12             pyhd8ed1ab_0    conda-forge
click                     8.0.4            py39hf3d152e_0    conda-forge
cloudpickle               2.0.0              pyhd8ed1ab_0    conda-forge
colorama                  0.4.4              pyh9f0ad1d_0    conda-forge
cookiecutter              1.7.3              pyh6c4a22f_1    conda-forge
coverage                  6.3.2                    pypi_0    pypi
cq-editor                 master                    py3.9    cadquery
cq-warehouse              0.5.3                     dev_0    <develop>
cryptography              36.0.1           py39h95dcef6_0    conda-forge
curl                      7.82.0               h7bff187_0    conda-forge
dataclasses               0.8                pyhc8e2a94_3    conda-forge
dbus                      1.13.6               h5008d03_3    conda-forge
debugpy                   1.5.1            py39he80948d_0    conda-forge
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
diff-match-patch          20200713           pyh9f0ad1d_0    conda-forge
docutils                  0.16             py39hf3d152e_3    conda-forge
double-conversion         3.1.7                h9c3ff4c_0    conda-forge
eigen                     3.4.0                h4bd325d_0    conda-forge
entrypoints               0.4                pyhd8ed1ab_0    conda-forge
executing                 0.8.3              pyhd8ed1ab_0    conda-forge
expat                     2.4.7                h27087fc_0    conda-forge
ezdxf                     0.17.2           py39h1a9c180_0    conda-forge
ffmpeg                    4.3.2                h37c90e5_3    conda-forge
flake8                    3.9.2              pyhd8ed1ab_0    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 hab24e00_0    conda-forge
fontconfig                2.13.96              h8e229c2_2    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
freeimage                 3.18.0               h88c329d_7    conda-forge
freetype                  2.10.4               h0708190_1    conda-forge
gettext                   0.19.8.1          h73d1719_1008    conda-forge
gl2ps                     1.4.2                h0708190_0    conda-forge
glew                      2.1.0                h9c3ff4c_2    conda-forge
gmp                       6.2.1                h58526e2_0    conda-forge
gnutls                    3.6.13               h85f3911_1    conda-forge
gst-plugins-base          1.18.5               hf529b03_3    conda-forge
gstreamer                 1.18.5               h9f60fe5_3    conda-forge
hdf4                      4.2.15               h10796ff_3    conda-forge
hdf5                      1.10.6          nompi_h3c11f04_101    conda-forge
icu                       69.1                 h9c3ff4c_0    conda-forge
idna                      3.3                pyhd8ed1ab_0    conda-forge
ilmbase                   2.5.5                h780b84a_0    conda-forge
imagesize                 1.3.0              pyhd8ed1ab_0    conda-forge
importlib-metadata        4.11.3           py39hf3d152e_0    conda-forge
importlib_metadata        4.11.3               hd8ed1ab_0    conda-forge
importlib_resources       5.4.0              pyhd8ed1ab_0    conda-forge
inflection                0.5.1              pyh9f0ad1d_0    conda-forge
intervaltree              3.0.2                      py_0    conda-forge
ipykernel                 6.9.2            py39hef51801_0    conda-forge
ipython                   8.1.1            py39hf3d152e_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
isort                     5.10.1             pyhd8ed1ab_0    conda-forge
jbig                      2.1               h7f98852_2003    conda-forge
jedi                      0.18.1           py39hf3d152e_0    conda-forge
jeepney                   0.7.1              pyhd8ed1ab_0    conda-forge
jinja2                    3.0.3              pyhd8ed1ab_0    conda-forge
jinja2-time               0.2.0              pyhd8ed1ab_3    conda-forge
jpeg                      9e                   h7f98852_0    conda-forge
jsoncpp                   1.9.4                h4bd325d_3    conda-forge
jsonschema                4.4.0              pyhd8ed1ab_0    conda-forge
jupyter_client            6.1.12             pyhd8ed1ab_0    conda-forge
jupyter_core              4.9.2            py39hf3d152e_0    conda-forge
jupyterlab_pygments       0.1.2              pyh9f0ad1d_0    conda-forge
jxrlib                    1.1                  h7f98852_2    conda-forge
keyring                   23.4.0           py39hf3d152e_2    conda-forge
keyutils                  1.6.1                h166bdaf_0    conda-forge
krb5                      1.19.3               h3790be6_0    conda-forge
lame                      3.100             h7f98852_1001    conda-forge
lazy-object-proxy         1.7.1            py39h3811e60_0    conda-forge
lcms2                     2.12                 hddcbb42_0    conda-forge
ld_impl_linux-64          2.36.1               hea4e1c9_2    conda-forge
lerc                      3.0                  h9c3ff4c_0    conda-forge
libblas                   3.9.0                8_openblas    conda-forge
libcblas                  3.9.0                8_openblas    conda-forge
libclang                  13.0.1          default_hc23dcda_0    conda-forge
libcurl                   7.82.0               h7bff187_0    conda-forge
libdeflate                1.10                 h7f98852_0    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libev                     4.33                 h516909a_1    conda-forge
libevent                  2.1.10               h9b69904_4    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 11.2.0              h1d223b6_14    conda-forge
libgfortran-ng            7.5.0               h14aa051_20    conda-forge
libgfortran4              7.5.0               h14aa051_20    conda-forge
libglib                   2.70.2               h174f98d_4    conda-forge
libglu                    9.0.0             he1b5a44_1001    conda-forge
libgomp                   11.2.0              h1d223b6_14    conda-forge
libiconv                  1.16                 h516909a_0    conda-forge
liblapack                 3.9.0                8_openblas    conda-forge
libllvm13                 13.0.1               hf817b99_2    conda-forge
libnetcdf                 4.8.0           nompi_hcd642e3_103    conda-forge
libnghttp2                1.47.0               h727a467_0    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libogg                    1.3.4                h7f98852_1    conda-forge
libopenblas               0.3.12          pthreads_hb3c22a3_1    conda-forge
libopus                   1.3.1                h7f98852_1    conda-forge
libpng                    1.6.37               h21135ba_2    conda-forge
libpq                     14.2                 hd57d9b9_0    conda-forge
libraw                    0.20.2               h10796ff_1    conda-forge
libsodium                 1.0.18               h36c2ea0_1    conda-forge
libspatialindex           1.9.3                h9c3ff4c_4    conda-forge
libssh2                   1.10.0               ha56f1ee_2    conda-forge
libstdcxx-ng              11.2.0              he4da1e4_14    conda-forge
libtheora                 1.1.1             h7f98852_1005    conda-forge
libtiff                   4.3.0                h542a066_3    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libvorbis                 1.3.7                h9c3ff4c_0    conda-forge
libwebp-base              1.2.2                h7f98852_1    conda-forge
libxcb                    1.13              h7f98852_1004    conda-forge
libxkbcommon              1.0.3                he3ba5ed_0    conda-forge
libxml2                   2.9.12               h885dcf4_1    conda-forge
libzip                    1.8.0                h4de3113_1    conda-forge
libzlib                   1.2.11            h36c2ea0_1013    conda-forge
logbook                   1.5.3            py39h3811e60_5    conda-forge
loguru                    0.5.3            py39hf3d152e_3    conda-forge
lz4-c                     1.9.3                h9c3ff4c_1    conda-forge
markupsafe                2.1.0            py39hb9d737c_1    conda-forge
matplotlib-inline         0.1.3              pyhd8ed1ab_0    conda-forge
mccabe                    0.6.1                      py_1    conda-forge
mistune                   0.8.4           py39h3811e60_1005    conda-forge
multimethod               1.6                pyhd8ed1ab_0    conda-forge
mypy_extensions           0.4.3            py39hf3d152e_4    conda-forge
mysql-common              8.0.28               ha770c72_0    conda-forge
mysql-libs                8.0.28               hfa10184_0    conda-forge
nbclient                  0.5.13             pyhd8ed1ab_0    conda-forge
nbconvert                 6.4.4            py39hf3d152e_0    conda-forge
nbformat                  5.2.0              pyhd8ed1ab_0    conda-forge
ncurses                   6.3                  h9c3ff4c_0    conda-forge
nest-asyncio              1.5.4              pyhd8ed1ab_0    conda-forge
nettle                    3.6                  he412f7d_0    conda-forge
nlopt                     2.7.1            py39h3e08f04_0    conda-forge
nptyping                  1.4.4              pyhd8ed1ab_0    conda-forge
nspr                      4.32                 h9c3ff4c_1    conda-forge
nss                       3.74                 hb5efdd6_0    conda-forge
numpy                     1.22.3           py39h18676bf_0    conda-forge
numpydoc                  1.2                pyhd8ed1ab_0    conda-forge
occt                      7.5.3                h7391655_0    conda-forge
ocp                       7.5.3.0                  py39_3    cadquery
openexr                   2.5.5                hf817b99_0    conda-forge
openh264                  2.1.1                h780b84a_0    conda-forge
openjpeg                  2.4.0                hb52868f_1    conda-forge
openssl                   1.1.1l               h7f98852_0    conda-forge
packaging                 21.3               pyhd8ed1ab_0    conda-forge
pandoc                    2.17.1.1             ha770c72_0    conda-forge
pandocfilters             1.5.0              pyhd8ed1ab_0    conda-forge
parso                     0.8.3              pyhd8ed1ab_0    conda-forge
path                      16.4.0           py39hf3d152e_0    conda-forge
pathspec                  0.9.0              pyhd8ed1ab_0    conda-forge
pcre                      8.45                 h9c3ff4c_0    conda-forge
pexpect                   4.8.0              pyh9f0ad1d_2    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pip                       22.0.4             pyhd8ed1ab_0    conda-forge
platformdirs              2.5.1              pyhd8ed1ab_0    conda-forge
pluggy                    1.0.0            py39hf3d152e_2    conda-forge
poyo                      0.5.0                      py_0    conda-forge
proj                      7.2.0                h277dcde_2    conda-forge
prompt-toolkit            3.0.27             pyha770c72_0    conda-forge
psutil                    5.9.0            py39h3811e60_0    conda-forge
pthread-stubs             0.4               h36c2ea0_1001    conda-forge
ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
pugixml                   1.11.4               h9c3ff4c_0    conda-forge
pure_eval                 0.2.2              pyhd8ed1ab_0    conda-forge
pycodestyle               2.7.0              pyhd3eb1b0_0  
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pydocstyle                6.1.1              pyhd8ed1ab_0    conda-forge
pyflakes                  2.3.1              pyhd3eb1b0_0  
pygments                  2.11.2             pyhd8ed1ab_0    conda-forge
pylint                    2.7.2            py39hf3d152e_0    conda-forge
pyls-spyder               0.4.0              pyhd8ed1ab_0    conda-forge
pyopenssl                 22.0.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.7              pyhd8ed1ab_0    conda-forge
pyqt                      5.12.3           py39hf3d152e_8    conda-forge
pyqt-impl                 5.12.3           py39hde8b62d_8    conda-forge
pyqt5-sip                 4.19.18          py39he80948d_8    conda-forge
pyqtchart                 5.12             py39h0fcd23e_8    conda-forge
pyqtgraph                 0.12.4             pyhd8ed1ab_0    conda-forge
pyqtwebengine             5.12.1           py39h0fcd23e_8    conda-forge
pyrsistent                0.18.1           py39h3811e60_0    conda-forge
pysocks                   1.7.1            py39hf3d152e_4    conda-forge
python                    3.9.10          h85951f9_2_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-lsp-black          1.1.0              pyhd8ed1ab_0    conda-forge
python-lsp-jsonrpc        1.0.0              pyhd8ed1ab_0    conda-forge
python-lsp-server         1.2.4              pyhd3eb1b0_0  
python-slugify            6.1.1              pyhd8ed1ab_0    conda-forge
python_abi                3.9                      2_cp39    conda-forge
pytz                      2021.3             pyhd8ed1ab_0    conda-forge
pyxdg                     0.27               pyhd8ed1ab_0    conda-forge
pyyaml                    6.0              py39h3811e60_3    conda-forge
pyzmq                     22.3.0           py39h37b5a0c_1    conda-forge
qdarkstyle                3.0.2              pyhd3eb1b0_0  
qstylizer                 0.2.1              pyhd8ed1ab_0    conda-forge
qt                        5.12.9               ha98a1a1_5    conda-forge
qtawesome                 1.1.1              pyhd8ed1ab_0    conda-forge
qtconsole                 5.2.2              pyhd8ed1ab_1    conda-forge
qtconsole-base            5.2.2              pyhd8ed1ab_1    conda-forge
qtpy                      2.0.1              pyhd8ed1ab_0    conda-forge
rapidjson                 1.1.0             he1b5a44_1002    conda-forge
readline                  8.1                  h46c0cb4_0    conda-forge
requests                  2.27.1             pyhd8ed1ab_0    conda-forge
rope                      0.23.0             pyhd8ed1ab_0    conda-forge
rtree                     0.9.7            py39hb102c33_3    conda-forge
secretstorage             3.3.1            py39hf3d152e_1    conda-forge
setuptools                60.9.3           py39hf3d152e_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
snowballstemmer           2.2.0              pyhd8ed1ab_0    conda-forge
sortedcontainers          2.4.0              pyhd8ed1ab_0    conda-forge
soupsieve                 2.3.1              pyhd8ed1ab_0    conda-forge
sphinx                    4.4.0              pyh6c4a22f_1    conda-forge
sphinxcontrib-applehelp   1.0.2                      py_0    conda-forge
sphinxcontrib-devhelp     1.0.2                      py_0    conda-forge
sphinxcontrib-htmlhelp    2.0.0              pyhd8ed1ab_0    conda-forge
sphinxcontrib-jsmath      1.0.1                      py_0    conda-forge
sphinxcontrib-qthelp      1.0.3                      py_0    conda-forge
sphinxcontrib-serializinghtml 1.1.5              pyhd8ed1ab_1    conda-forge
spyder                    5.1.5            py39h06a4308_1  
spyder-kernels            2.1.3            py39h06a4308_0  
sqlite                    3.37.0               h9cd32fc_0    conda-forge
stack_data                0.2.0              pyhd8ed1ab_0    conda-forge
tbb                       2020.2               h4bd325d_4    conda-forge
tbb-devel                 2020.2               h4bd325d_4    conda-forge
testpath                  0.6.0              pyhd8ed1ab_0    conda-forge
text-unidecode            1.3                        py_0    conda-forge
textdistance              4.2.2              pyhd8ed1ab_0    conda-forge
three-merge               0.1.1              pyh9f0ad1d_0    conda-forge
tinycss2                  1.1.1              pyhd8ed1ab_0    conda-forge
tk                        8.6.12               h27826a3_0    conda-forge
toml                      0.10.2             pyhd8ed1ab_0    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
tornado                   6.1              py39h3811e60_2    conda-forge
traitlets                 5.1.1              pyhd8ed1ab_0    conda-forge
typed-ast                 1.5.2            py39h3811e60_0    conda-forge
typing_extensions         4.1.1              pyha770c72_0    conda-forge
typish                    1.9.3              pyhd8ed1ab_0    conda-forge
tzdata                    2021e                he74cb21_0    conda-forge
ujson                     5.1.0            py39he80948d_0    conda-forge
unidecode                 1.3.4              pyhd8ed1ab_0    conda-forge
urllib3                   1.26.8             pyhd8ed1ab_1    conda-forge
utfcpp                    3.2.1                ha770c72_0    conda-forge
vtk                       9.0.1           no_osmesa_py39h3e52c05_107    conda-forge
watchdog                  2.1.6            py39hf3d152e_1    conda-forge
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
wrapt                     1.12.1           py39h3811e60_3    conda-forge
wurlitzer                 3.0.2            py39hf3d152e_1    conda-forge
x264                      1!161.3030           h7f98852_1    conda-forge
xorg-kbproto              1.0.7             h7f98852_1002    conda-forge
xorg-libice               1.0.10               h7f98852_0    conda-forge
xorg-libsm                1.2.3             hd9c2040_1000    conda-forge
xorg-libx11               1.7.2                h7f98852_0    conda-forge
xorg-libxau               1.0.9                h7f98852_0    conda-forge
xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
xorg-libxext              1.3.4                h7f98852_1    conda-forge
xorg-libxt                1.2.1                h7f98852_2    conda-forge
xorg-xextproto            7.3.0             h7f98852_1002    conda-forge
xorg-xproto               7.0.31            h7f98852_1007    conda-forge
xz                        5.2.5                h516909a_1    conda-forge
yaml                      0.2.5                h7f98852_2    conda-forge
yapf                      0.32.0             pyhd8ed1ab_0    conda-forge
zeromq                    4.3.4                h9c3ff4c_1    conda-forge
zipp                      3.7.0              pyhd8ed1ab_1    conda-forge
zlib                      1.2.11            h36c2ea0_1013    conda-forge
zstd                      1.5.2                ha95c52a_0    conda-forge
lorenzncode commented 2 years ago

I find the sweep is successful when specifying the isFrenet arg as True.