Skip to content

Commit 1bdc28f

Browse files
Fix crash on invalid faces (#1541)
* Fix crash on invalid faces * Add test --------- Co-authored-by: AU <[email protected]>
1 parent f29f2d6 commit 1bdc28f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

cadquery/occ_impl/shapes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,8 @@ def tessellate(
13651365

13661366
loc = TopLoc_Location()
13671367
poly = BRep_Tool.Triangulation_s(f.wrapped, loc)
1368+
if poly is None:
1369+
continue
13681370
Trsf = loc.Transformation()
13691371
reverse = (
13701372
True

tests/test_cadquery.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5732,3 +5732,16 @@ def test_iterators(self):
57325732

57335733
res7 = list(fs.siblings(c, "Edge", 2))
57345734
assert len(res7) == 2
5735+
5736+
def test_tessellate(self):
5737+
5738+
# happy flow
5739+
verts, tris = Face.makePlane(1, 1).tessellate(1e-3)
5740+
5741+
assert len(verts) == 4
5742+
assert len(tris) == 2
5743+
5744+
# this should not crash, but return no verts
5745+
verts, _ = Face.makePlane(1e-9, 1e-9).tessellate(1e-3)
5746+
5747+
assert len(verts) == 0

0 commit comments

Comments
 (0)