()
| 40 | return parser.parse_args(); |
| 41 | |
| 42 | def main(): |
| 43 | args = parse_args(); |
| 44 | mesh = pymesh.load_mesh(args.input_mesh); |
| 45 | if mesh.vertex_per_face == 4: |
| 46 | logging.warning("Converting quad mesh to triangle mesh."); |
| 47 | mesh = pymesh.quad_to_tri(mesh); |
| 48 | |
| 49 | if args.exact: |
| 50 | name,ext = os.path.splitext(args.output_mesh); |
| 51 | exact_mesh_file = name + ".xml"; |
| 52 | else: |
| 53 | exact_mesh_file = None; |
| 54 | |
| 55 | if mesh.num_vertices ==0 or mesh.num_faces == 0: |
| 56 | # Empty input mesh, output empty mesh as well. |
| 57 | result = pymesh.form_mesh(np.zeros((0,3),dtype=float), |
| 58 | np.zeros((0,3),dtype=int)); |
| 59 | if args.timing: |
| 60 | update_info(args.output_mesh, 0); |
| 61 | else: |
| 62 | if args.engine == "igl": |
| 63 | empty = pymesh.form_mesh(np.zeros((0,3)), np.zeros((0,3))); |
| 64 | r = pymesh.boolean( |
| 65 | mesh, empty, "union", engine=args.engine, |
| 66 | with_timing = args.timing, |
| 67 | exact_mesh_file=exact_mesh_file); |
| 68 | else: |
| 69 | # Empty mesh is valid for these libraries, using bbox instead. |
| 70 | bbox = mesh.bbox; |
| 71 | center = (bbox[0] + bbox[1]) * 0.5; |
| 72 | box = pymesh.generate_box_mesh( |
| 73 | bbox[0] - np.ones(mesh.dim), |
| 74 | bbox[1] + np.ones(mesh.dim)); |
| 75 | |
| 76 | r = pymesh.boolean( |
| 77 | mesh, box, "intersection", engine=args.engine, |
| 78 | with_timing = args.timing, |
| 79 | exact_mesh_file=exact_mesh_file); |
| 80 | |
| 81 | if args.timing: |
| 82 | result, timing = r; |
| 83 | update_info(args.output_mesh, timing); |
| 84 | else: |
| 85 | result = r; |
| 86 | |
| 87 | pymesh.save_mesh(args.output_mesh, result); |
| 88 | |
| 89 | if __name__ == "__main__": |
| 90 | main(); |
no test coverage detected