Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash on invalid faces #1541

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cadquery/occ_impl/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,8 @@ def tessellate(

loc = TopLoc_Location()
poly = BRep_Tool.Triangulation_s(f.wrapped, loc)
if poly is None:
continue
Trsf = loc.Transformation()
reverse = (
True
Expand Down
13 changes: 13 additions & 0 deletions tests/test_cadquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -5671,3 +5671,16 @@ def test_iterators(self):

res7 = list(fs.siblings(c, "Edge", 2))
assert len(res7) == 2

def test_tessellate(self):

# happy flow
verts, tris = Face.makePlane(1, 1).tessellate(1e-3)

assert len(verts) == 4
assert len(tris) == 2

# this should not crash, but return no verts
verts, _ = Face.makePlane(1e-9, 1e-9).tessellate(1e-3)

assert len(verts) == 0