Open mahmouddinar opened 1 month ago
Glad it's helpful! I think you should just need to turn off the default merge-vertex-on-creation behavior as your scale is smaller than trimesh.tol.merge
(or set that value to something smaller if you'd like it to merge just at the different scale):
cuboid = trimesh.Trimesh(vertices=vertices, faces=faces, process=False)
I appreciate your quick feedback. Though I don't understand exactly what setting the process=False does, it avoids the previous problem which is great. But I tried setting the tolerance as you suggested to a value based on the mesh I am processing, something like:
trimesh.tol.merge = min(bb_x,bb_y,bb_z)/resolution
But should this be with process=False, or process=True, or no process flag at all? I am creating these cuboids one by one by defining the 8 vertices and 6 faces. Does merge-vertex-on-creation even apply, or does it apply when checking the intersection of each cuboid with the mesh? I noticed that for the same mesh, when I scale it down, there are fewer intersecting cuboids which shouldn't be happening since the size of the cuboids are based on the size of the bounding box of the mesh; the proportion should remain the same. Thank you.
Thank you very much for sharing this amazing library. I am trying to create very tiny cuboids within the bounding box of a mesh and compute their overlapping volumes with the mesh. When the coordinates of the vertices are too close, the cube is not formed: cuboid.extents returns [0,0,0] and the exception is thrown 'Not all meshes are volumes!' The cuboids are created using:
cuboid = trimesh.Trimesh(vertices=vertices, faces=faces)
The following is an example of the coordinates used to form two cuboids, preceded by the bounding box extents, the first being 0 leading to the exception, and another with non zero extents:cuboid[0,0,0]: [0. 0. 0.] [[ 8.53873789e-06 -1.73472348e-18 1.73472348e-18] [ 8.53873789e-06 -1.73472348e-18 7.38000008e-10] [ 8.53873789e-06 7.64906759e-10 1.73472348e-18] [ 8.53873789e-06 7.64906759e-10 7.38000008e-10] [ 8.53967351e-06 -1.73472348e-18 1.73472348e-18] [ 8.53967351e-06 -1.73472348e-18 7.38000008e-10] [ 8.53967351e-06 7.64906759e-10 1.73472348e-18] [ 8.53967351e-06 7.64906759e-10 7.38000008e-10]] cuboid[0,0,1]: [0.00000000e+00 0.00000000e+00 7.38000007e-09] [[ 8.53873789e-06 -1.73472348e-18 7.38000008e-10] [ 8.53873789e-06 -1.73472348e-18 8.11800008e-09] [ 8.53873789e-06 7.64906759e-10 7.38000008e-10] [ 8.53873789e-06 7.64906759e-10 8.11800008e-09] [ 8.53967351e-06 -1.73472348e-18 7.38000008e-10] [ 8.53967351e-06 -1.73472348e-18 8.11800008e-09] [ 8.53967351e-06 7.64906759e-10 7.38000008e-10] [ 8.53967351e-06 7.64906759e-10 8.11800008e-09]]
when I scale up my mesh by one order of magnitude, for the same example, I get no errors:
cuboid[0,0,0]: [9.35615767e-09 7.64906762e-09 7.38000007e-09] [[ 8.53873789e-05 1.38777878e-17 -1.38777878e-17] [ 8.53873789e-05 1.38777878e-17 7.38000006e-09] [ 8.53873789e-05 7.64906763e-09 -1.38777878e-17] [ 8.53873789e-05 7.64906763e-09 7.38000006e-09] [ 8.53967351e-05 1.38777878e-17 -1.38777878e-17] [ 8.53967351e-05 1.38777878e-17 7.38000006e-09] [ 8.53967351e-05 7.64906763e-09 -1.38777878e-17] [ 8.53967351e-05 7.64906763e-09 7.38000006e-09]] cuboid[0,0,1]: [9.35615767e-09 7.64906762e-09 7.38000007e-08] [[8.53873789e-05 1.38777878e-17 7.38000006e-09] [8.53873789e-05 1.38777878e-17 8.11800008e-08] [8.53873789e-05 7.64906763e-09 7.38000006e-09] [8.53873789e-05 7.64906763e-09 8.11800008e-08] [8.53967351e-05 1.38777878e-17 7.38000006e-09] [8.53967351e-05 1.38777878e-17 8.11800008e-08] [8.53967351e-05 7.64906763e-09 7.38000006e-09] [8.53967351e-05 7.64906763e-09 8.11800008e-08]]
This example at least implies vertices shouldn't be less than 1e-9 along any dimension from one another. Is there a way to control/know the precision of the vertices that allow/disallow forming a mesh?
Thanks again.