Skip to content

Commit

Permalink
Fix crash on invalid faces (#1541)
Browse files Browse the repository at this point in the history
* Fix crash on invalid faces

* Add test

---------

Co-authored-by: AU <adam-urbanczyk@users.noreply.github.com>
  • Loading branch information
openvmp and adam-urbanczyk authored May 30, 2024
1 parent f29f2d6 commit 1bdc28f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cadquery/occ_impl/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,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 @@ -5732,3 +5732,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

0 comments on commit 1bdc28f

Please sign in to comment.