()
| 24 | return parser.parse_args(); |
| 25 | |
| 26 | def main(): |
| 27 | args = parse_args(); |
| 28 | mesh = pymesh.load_mesh(args.in_mesh); |
| 29 | if (args.with_rounding): |
| 30 | mesh = pymesh.form_mesh( |
| 31 | np.round(mesh.vertices, args.precision), |
| 32 | mesh.faces); |
| 33 | intersecting_faces = pymesh.detect_self_intersection(mesh); |
| 34 | |
| 35 | counter = 0; |
| 36 | while len(intersecting_faces) > 0 and counter < args.max_iterations: |
| 37 | if (args.with_rounding): |
| 38 | involved_vertices = np.unique(mesh.faces[intersecting_faces].ravel()); |
| 39 | mesh.vertices_ref[involved_vertices, :] =\ |
| 40 | np.round(mesh.vertices[involved_vertices, :], |
| 41 | args.precision//2); |
| 42 | mesh = pymesh.resolve_self_intersection(mesh, "igl"); |
| 43 | mesh, __ = pymesh.remove_duplicated_faces(mesh, fins_only=True); |
| 44 | if (args.with_rounding): |
| 45 | mesh = pymesh.form_mesh( |
| 46 | np.round(mesh.vertices, args.precision), |
| 47 | mesh.faces); |
| 48 | intersecting_faces = pymesh.detect_self_intersection(mesh); |
| 49 | counter += 1; |
| 50 | |
| 51 | if len(intersecting_faces) > 0: |
| 52 | logging.warn("Resolving failed: max iteration reached!"); |
| 53 | |
| 54 | pymesh.save_mesh(args.out_mesh, mesh); |
| 55 | |
| 56 | if __name__ == "__main__": |
| 57 | main(); |
no test coverage detected