Skip to content

Commit 842652a

Browse files
committed
check for Z in polygons
1 parent e1d5af6 commit 842652a

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

trimesh/creation.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def extrude_triangulation(vertices,
255255

256256

257257
def triangulate_polygon(polygon,
258-
triangle_args='pq0D',
258+
triangle_args='pq30',
259259
engine='auto',
260260
**kwargs):
261261
"""
@@ -307,7 +307,7 @@ def triangulate_polygon(polygon,
307307

308308
# do the import here, as sometimes this import can segfault
309309
# which is not catchable with a try/except block
310-
import meshpy.triangle as triangle
310+
from meshpy import triangle
311311
# call meshpy.triangle on our cleaned representation of
312312
# the Shapely polygon
313313
info = triangle.MeshInfo()
@@ -403,6 +403,11 @@ def add_boundary(boundary, start):
403403
vertices = np.vstack(vertices)
404404
facets = np.vstack(facets).tolist()
405405

406+
# shapely polygons can include a Z component
407+
# strip it out for the triangulation
408+
if vertices.shape[1] == 3:
409+
vertices = vertices[:, :2]
410+
406411
result = {'vertices': vertices,
407412
'segments': facets}
408413
# holes in meshpy lingo are a (h, 2) list of (x,y) points

trimesh/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.35.12'
1+
__version__ = '2.35.13'

0 commit comments

Comments
 (0)