def face_index(vertices):
"""Takes an MxNx3 array and returns a 2D vertices and MxN face_indices arrays"""
new_verts = []
face_indices = []
for wall in vertices:
face_wall = []
for vert in wall:
if new_verts:
if not np.isclose(vert, new_verts).all(axis=1).any():
new_verts.append(vert)
else:
new_verts.append(vert)
face_index = np.where(np.isclose(vert, new_verts).all(axis=1))[0][0]
face_wall.append(face_index)
face_indices.append(face_wall)
return np.array(new_verts), np.array(face_indices)
评论列表
文章目录