(mesh)
| 17 | return parser.parse_args(); |
| 18 | |
| 19 | def compute_metric(mesh): |
| 20 | if mesh.has_attribute("cell"): |
| 21 | cell_ids = mesh.get_attribute("cell").astype(int).ravel(); |
| 22 | cut_mesh = pymesh.cut_mesh(mesh, cell_ids); |
| 23 | else: |
| 24 | cut_mesh = mesh; |
| 25 | |
| 26 | tree = pymesh.AABBTree2(); |
| 27 | tree.load_data(cut_mesh.vertices, cut_mesh.boundary_edges); |
| 28 | sq_dist, indices = tree.look_up(mesh.vertices); |
| 29 | dist = np.sqrt(sq_dist); |
| 30 | |
| 31 | bbox_min, bbox_max = mesh.bbox; |
| 32 | tol = norm(bbox_max - bbox_min) / 20.0; |
| 33 | |
| 34 | metric = np.clip(dist / tol, 0.1, 1.0) * tol; |
| 35 | return metric; |
| 36 | |
| 37 | |
| 38 | def main(): |
no test coverage detected