isl-org / Open3D

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

Fastest way to test intersection between two stl meshes #6523

Open JorgeFernandes-Git opened 9 months ago

JorgeFernandes-Git commented 9 months ago

Checklist

My Question

Hi Open3D team,

I hope this message finds you well. I am currently working on a project that involves testing whether two STL meshes intersect or not using Open3D. I've been experimenting with the following code:

import open3d as o3d

box = o3d.geometry.TriangleMesh.create_box()
box = o3d.t.geometry.TriangleMesh.from_legacy(box)
sphere = o3d.geometry.TriangleMesh.create_sphere(0.8)
sphere = o3d.t.geometry.TriangleMesh.from_legacy(sphere)

result = triangle_mesh1.boolean_intersection(triangle_mesh2)
o3d.visualization.draw([result])

This code successfully detects mesh intersections, but the execution time is quite slow for my specific application. I'm reaching out to inquire if there's a more efficient method or an alternative approach to check for mesh intersection in Open3D.

Is there a dedicated function or method within Open3D that allows for a faster evaluation of mesh intersections without generating the entire intersection mesh? I'm primarily interested in determining if there is any intersection between the two meshes, rather than visualizing the intersection result.

Any guidance or suggestions on optimizing the code for faster execution would be greatly appreciated.

Thank you for your time and assistance.

Best regards,

ssheorey commented 9 months ago

Hi @JorgeFernandes-Git which part is slow and how fast do you want it to be? You can avoid displaying the mesh (draw) and just check if the intersection is non-empty instead.