mikedh / trimesh

Python library for loading and using triangular meshes.

Home Page:https://trimesh.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

In the slicing algorythm loops are in some edge case not correctly detected

hit-the-luke opened this issue · comments

Hi,

I had a real part where for a single slice the hole was not correctly detected. This is a simplifyed example:

`import numpy as np
import trimesh
import sys

vertices = np.array([[19.402250931139097, -14.88787016674277, 64.0], [20.03318396099334, -14.02738654377374, 64.0], [19.402250931139097, -14.88787016674277, 0.0], [20.03318396099334, -14.02738654377374, 0.0], [21, -16.5, 32]])
faces = np.array([[1, 3, 0], [0, 3, 2], [1, 0, 4], [0, 2, 4], [3,1,4], [2, 3, 4]])
z_layer_centers = (np.array([3, 3.0283334255218506]))

print('sys.version', sys.version)
print('sys.version_info', sys.version_info)
print('trimesh.version', trimesh.version)

mesh = trimesh.Trimesh(vertices=vertices, faces=faces)
res = mesh.section_multiplane(np.array([0, 0, 0]), np.array([0, 0, 1]), z_layer_centers)
print('the number of entities should for all paths be 1, as the 3d Body is a rather simple Pyramid')
for thing in res:
print(len(thing.entities))
res[1].show()`

I get this this Output:

sys.version 3.11.6 (tags/v3.11.6:8b6ee5b, Oct 2 2023, 14:57:12) [MSC v.1935 64 bit (AMD64)]
sys.version_info sys.version_info(major=3, minor=11, micro=6, releaselevel='final', serial=0)
trimesh.version 4.3.2
the number of entities should for all paths be 1, as the 3d Body is a rather simple Pyramid
1
3

To me it looks like a rounding error so two points are not recognized as the same.