isl-org / Open3D

Open3D: A Modern Library for 3D Data Processing
http://www.open3d.org
Other
11.37k stars 2.29k forks source link

bug in open3d's algorithm for determining self-intersection of triangular mesh #6462

Open Amble12345 opened 11 months ago

Amble12345 commented 11 months ago

Checklist

Describe the issue

I used "is_self_intersecting()" function to check if the input triangular mesh has self-intersection, getting a return value of "True". However, when I exported these "intersecting" triangles (here I call it mesh1, for distinction) by "get_self_intersecting_triangles()" function and visualized them, I found that they don't actually intersect but seem to lie in the same plane. I did another test by customizing a mesh (mesh2) which only consists of 2 non-intersecting triangles but sharing the same plane, this time the function worked normally. I'm confused now, wondering why the pair of triangles in mesh1 are considered intersecting by open3d.

Steps to reproduce the bug

import open3d as o3d
import numpy as np

""" the example mesh1, by which I found the bug"""
v1_array = np.load('v_array.npy')  # url: https://github.com/Amble12345/123/blob/main/v_array.npy
t1_array = np.load('t_array.npy')  # url: https://github.com/Amble12345/123/blob/main/t_array.npy
mesh1 = o3d.geometry.TriangleMesh()
mesh1.vertices = o3d.utility.Vector3dVector(v1_array)
mesh1.triangles = o3d.utility.Vector3iVector(t1_array)
print(mesh1.is_self_intersecting())  # True
print(np.asarray(mesh1.get_self_intersecting_triangles()))  # [[0 1]]

# ************************** #

""" the example mesh2, for test """
v2_array = np.array([[0, 1, 1],
                    [1, 1, 1],
                    [1, 0, 1],
                    [2, 0, 1],
                    [2, 1, 1],
                    [3, 1, 1]], dtype=np.float64)

t2_array = np.array([[0, 1, 2],
                    [3, 4, 5]])  # a pair of non-intersecting triangles but sharing the same plane

mesh2 = o3d.geometry.TriangleMesh()
mesh2.vertices = o3d.utility.Vector3dVector(v2_array)
mesh2.triangles = o3d.utility.Vector3iVector(t2_array)
print(mesh2.is_self_intersecting())  # False
print(np.asarray(mesh2.get_self_intersecting_triangles()))  # [[]]

""" Visualization of mesh1 """
mesh1.paint_uniform_color([1.0, 0.0, 0.0])
o3d.visualization.draw_geometries([mesh1])

Error message

No response

Expected behavior

No response

Open3D, Python and System information

- Operating system: Windows 11 64-bit
- Python version: Python 3.9
- Open3D version: 0.17.0
- VTK version: 9.1.0
- System architecture: x64
- Is this a remote workstation?: no
- How did you install Open3D?: pip

Additional information

image image

hernot commented 11 months ago

I guess this is related to #5117 just that the tests are performed with triangles from the same geometry instead of two distinct.