numpy-stl icon indicating copy to clipboard operation
numpy-stl copied to clipboard

Delete specific triangles from the mesh

Open uffacci opened this issue 4 years ago • 2 comments

Hi, I want to know if there is an easy way to delete specific triangles from a mesh from an STL file. I can delete the vertices of the triangles that I want to reject, but then I cannot visualize the new result ... any ideas? Thanks a lot

uffacci avatar Sep 29 '21 13:09 uffacci

Since numpy arrays have a fixed size, the only way you can delete them is by creating a new array (or a view).

One option would be to create a view, simply put, you can slice a numpy array by passing a list of selected indices:

>>> import numpy
>>> a = numpy.arange(10, 19).reshape((3, 3))
>>> a
array([[10, 11, 12],
       [13, 14, 15],
       [16, 17, 18]])
>>> a[[1, 2]]
array([[13, 14, 15],
       [16, 17, 18]])

If you create a new Mesh object with the sliced data argument you can easily delete triangles like that.

wolph avatar Sep 30 '21 00:09 wolph

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 28 '21 14:11 stale[bot]