i have an Array containing faces of a triangulation that looks like this:
faces = np.array([[4, 0, 1],
[5, 4, 1],
[7, 5, 1],
[7, 5, 4],
[3, 0, 1], # row to delete
[7, 3, 1],
[4, 2, 0],
[6, 4, 2],
[7, 6, 2],
[7, 6, 4],
[3, 2, 0], # row to delete
[7, 3, 2]])
Each number in the entry describes a 3-dimensional vertice.
Now i want to delete rows only containing combinations of following list:
indices = [0, 1, 2, 3]
How could i do this? I have tried some options, however i can't delete just the two faces that i wish to delete.
CodePudding user response:
Assuming you have unique elements in each row, you could use:
faces_filtered = faces[~np.isin(faces, indices).all(1)]
output (initial rows 4 and 10 have been removed):
array([[4, 0, 1],
[5, 4, 1],
[7, 5, 1],
[7, 5, 4],
[7, 3, 1],
[4, 2, 0],
[6, 4, 2],
[7, 6, 2],
[7, 6, 4],
[7, 3, 2]])