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

Return subset of mesh using bound #630

Closed
sweco-sekrsv opened this issue Nov 26, 2019 · 1 comment
Closed

Return subset of mesh using bound #630

sweco-sekrsv opened this issue Nov 26, 2019 · 1 comment

Comments

@sweco-sekrsv
Copy link

sweco-sekrsv commented Nov 26, 2019

I have a large mesh object with a few milion triangles. I use trimesh.slice_plane with a box bound and get a nice looking result.

To speed this up (when slicing a small area from the large mesh) I wonder if there is a function to get all the faces/vertices of the mesh that is within or on the border of my slicing-bound? I'm thinking it would be quicker to first get all the triangles that can possibly be sliced before doing the actual slicing. Not sure if it would be quicker or not.

Similar to how the spat command in og2ogr works:.
-spat 182100 6731100 182200 6731200 -clipsrc 182100 6731100 182200 6731200
Spat defines the region of of the mesh that is of interest for the clipping, while clipscr is doing the actual slicing/clipping. Using just the clipsrc is alot slower using gdal.

@mikedh
Copy link
Owner

mikedh commented Dec 11, 2019

Yeah it's true the slice function could check mesh.triangles_tree against the AABB of the slice plane inside the AABB of the mesh. Given the speed of dot products, this may be slower below some threshold of triangles but yeah for big meshes seems like it would definitely be faster.

Constructing the triangles_tree is pretty expensive so we probably wouldn't want to do it for every plane normal, but you could imagine constructing a few trees along 2-3 different vectors and having this be pretty snappy on giant meshes. Cool idea and totally open to PR's!

I'll add it to the enhancements list and close this issue, thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants