MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / compute_metric

Function compute_metric

scripts/refine_triangulation.py:19–35  ·  view source on GitHub ↗
(mesh)

Source from the content-addressed store, hash-verified

17 return parser.parse_args();
18
19def 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
38def main():

Callers 1

mainFunction · 0.85

Calls 6

load_dataMethod · 0.95
look_upMethod · 0.95
AABBTree2Method · 0.80
clipMethod · 0.80
has_attributeMethod · 0.45
get_attributeMethod · 0.45

Tested by

no test coverage detected