(mesh, selection)
| 9 | import pymesh |
| 10 | |
| 11 | def extract_intersecting_faces(mesh, selection): |
| 12 | face_pairs = pymesh.detect_self_intersection(mesh); |
| 13 | selected_faces = np.zeros(mesh.num_faces, dtype=bool); |
| 14 | |
| 15 | if selection is not None: |
| 16 | selected_pairs = np.any(face_pairs == selection, axis=1); |
| 17 | face_pairs = face_pairs[selected_pairs]; |
| 18 | |
| 19 | selected_faces[face_pairs[:,0]] = True; |
| 20 | selected_faces[face_pairs[:,1]] = True; |
| 21 | faces = mesh.faces[selected_faces]; |
| 22 | intersecting_mesh = pymesh.form_mesh(mesh.vertices, faces); |
| 23 | intersecting_mesh, __ = pymesh.remove_isolated_vertices(intersecting_mesh); |
| 24 | return intersecting_mesh; |
| 25 | |
| 26 | def parse_args(): |
| 27 | parser = argparse.ArgumentParser(description=__doc__); |
no test coverage detected