-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
I've been using the triangle lib a lot and I frequently get the following RuntimeError :
File "triangle/core.pyx", line 252, in triangle.core.triang
RuntimeError: Triangulation failed -- probably because of invalid geometry on input.
It happens this occurs if and only if I have used matplotlib before calling the triangulate function.
Here is a code sample I use to get the RuntimeError:
import matplotlib.pyplot as plt
import triangle as tr
plt.plot([0,1,2],[1,-1,1])
plt.show()
vertices = [[0,0],[0,1],[1,0]]
segments = [[0,1],[1,2],[2,0]]
domain_dict = {"vertices" : vertices,
"segments" : segments,
}
mesh_dict = tr.triangulate(domain_dict, "q10pa0.1")As a contrast, if I use the following code (without the matplotlib plot), I get a perfectly fine mesh without any RuntimeError:
import matplotlib.pyplot as plt
import triangle as tr
vertices = [[0,0],[0,1],[1,0]]
segments = [[0,1],[1,2],[2,0]]
domain_dict = {"vertices" : vertices,
"segments" : segments,
}
mesh_dict = tr.triangulate(domain_dict, "q10pa0.1")I run these codes on Ubuntu 22.04,
Python versions tested 3.9 to 3.13,
I use python-uv as a dependancy and venv manager, you can recreate the exact env I use with:
uv init
uv add matplotlib, pyqt6, triangle
Metadata
Metadata
Assignees
Labels
No labels