Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trimesh.bounds.oriented_bounds is slow for NumPy array input. #2342

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/test_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ def setUp(self):
meshes = [g.get_mesh(i) for i in ["large_block.STL", "featuretype.STL"]]
self.meshes = g.np.append(meshes, list(g.get_meshes(5)))


def test_obb_mesh_large(self):
"""Test the OBB functionality on really large sets of vertices."""

torus_mesh = g.trimesh.creation.torus(major_radius=5, minor_radius=1, major_sections=512, minor_sections=256)
start = g.timeit.default_timer()
g.trimesh.bounds.oriented_bounds(torus_mesh.vertices)
stop = g.timeit.default_timer()

# Make sure oriented bound estimation runs within 30 seconds.
assert stop - start < 30, f"Took {stop - start} seconds to estimate the oriented bounding box."


def test_obb_mesh(self):
"""
Test the OBB functionality in attributes of Trimesh objects
Expand Down
2 changes: 1 addition & 1 deletion trimesh/bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def oriented_bounds_coplanar(points):
if util.is_shape(points, (-1, 2)):
return oriented_bounds_2D(points)
elif util.is_shape(points, (-1, 3)):
hull = convex.convex_hull(points, repair=False)
hull = convex.convex_hull(points, repair=True)
else:
raise ValueError("Points are not (n,3) or (n,2)!")
else:
Expand Down