drufat / triangle

Python bindings to the triangle library
GNU Lesser General Public License v3.0
236 stars 54 forks source link

Segmentation fault while doing multiple loop in ubuntu. #70

Open aasmanbashyal opened 1 year ago

aasmanbashyal commented 1 year ago
          I am also getting the segmentation fault while running it on ubuntu. But while running it on windows there is no problem.
import faulthandler
# Enable fault handler
faulthandler.enable()
import triangle as tr
import numpy as np

def delaunay_triangulation(pts, segments):
    """
    Apply constrained delaunay triangulation
    https://rufat.be/triangle/API.html
    """
    pts = np.array(pts[:-1])
    segments[-1][1] = 0

    t = tr.triangulate({"vertices": pts[:, 0:2], "segments": segments}, 'p')

    if 'triangles' not in t:
        return []

    triangulated_pts = [pts[triangle] for triangle in t['triangles'].tolist()]

    return triangulated_pts

boundary_pts = [[1383, 171, 18.0], [1998, 0, 9.170907020568848], [2378, 750, 18.0], [660, 1483, 18.0], [0, 551, 4.605607986450195], [0, 551, 4.605607986450195], [1383, 171, 18.0]]
boundary_segments =[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]

for i in range(100):
    triangulated_pts = delaunay_triangulation(pts=boundary_pts, segments=boundary_segments)
    print(f" is {triangulated_pts}")

faulthandler.disable()

The error i get: Current thread 0x00007fcae2b78740 (most recent call first): File "/usr/local/lib/python3.8/dist-packages/triangle/tri.py", line 73 in triangulate File "testtriangle.py", line 15 in delaunay_triangulation File "testtriangle.py", line 28 in

Originally posted by @aasmanbashyal in https://github.com/drufat/triangle/issues/68#issuecomment-1444976158

cgreening commented 1 year ago

Hmm, I think I've just hit this on mac - did you find a solution?

Hexus-One commented 1 year ago

I've found a possible cause of the problem (mesh with lots of colinear points), see my comment in this other repo that also uses the triangle library.