()
| 45 | return parser.parse_args(); |
| 46 | |
| 47 | def main(): |
| 48 | args = parse_args(); |
| 49 | mesh_1 = pymesh.load_mesh(args.input_mesh_1); |
| 50 | mesh_2 = pymesh.load_mesh(args.input_mesh_2); |
| 51 | assert(mesh_1.dim == 3); |
| 52 | assert(mesh_2.dim == 3); |
| 53 | |
| 54 | bbox_min_1, bbox_max_1 = mesh_1.bbox; |
| 55 | bbox_min_2, bbox_max_2 = mesh_2.bbox; |
| 56 | |
| 57 | bbox_min = np.minimum(bbox_min_1, bbox_min_2); |
| 58 | bbox_max = np.maximum(bbox_max_1, bbox_max_2); |
| 59 | |
| 60 | #queries = grid_sample(bbox_min, bbox_max, args.num_samples); |
| 61 | queries = random_sample(bbox_min, bbox_max, args.num_samples); |
| 62 | |
| 63 | winding_number_1 = pymesh.compute_winding_number(mesh_1, queries, |
| 64 | engine=args.winding_number_engine) > 0.5; |
| 65 | winding_number_2 = pymesh.compute_winding_number(mesh_2, queries, |
| 66 | engine=args.winding_number_engine) > 0.5; |
| 67 | |
| 68 | diff = np.logical_xor(winding_number_1, winding_number_2); |
| 69 | num_diff = np.count_nonzero(diff); |
| 70 | print("Winding numbers of {} out of {} samples differ".format( |
| 71 | num_diff, len(queries))); |
| 72 | |
| 73 | if args.output is not None: |
| 74 | r = np.amax(bbox_max - bbox_min) * 0.01; |
| 75 | box = pymesh.generate_box_mesh(np.ones(3) * -r, np.ones(3) * r); |
| 76 | |
| 77 | vertices = []; |
| 78 | faces = []; |
| 79 | for i in range(len(queries)): |
| 80 | vertices.append(box.vertices + queries[i]); |
| 81 | faces.append(box.faces + box.num_vertices * i); |
| 82 | vertices = np.vstack(vertices); |
| 83 | faces = np.vstack(faces); |
| 84 | mesh = pymesh.form_mesh(vertices, faces); |
| 85 | mesh.add_attribute("diff"); |
| 86 | mesh.set_attribute("diff", np.repeat(diff, box.num_faces)); |
| 87 | pymesh.save_mesh(args.output, mesh, "diff"); |
| 88 | |
| 89 | if args.export: |
| 90 | info = load_info(args.input_mesh_2); |
| 91 | info["diff"] = num_diff |
| 92 | dump_info(args.input_mesh_2, info); |
| 93 | |
| 94 | if args.timing: |
| 95 | pymesh.timethis.summarize(); |
| 96 | |
| 97 | if __name__ == "__main__": |
| 98 | main(); |
no test coverage detected