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

Function distance_to_mesh

python/pymesh/aabb_tree.py:67–92  ·  view source on GitHub ↗

Compute the distance from a set of points to a mesh. Args: mesh (:class:`Mesh`): A input mesh. pts (:class:`numpy.ndarray`): A :math:`N \\times dim` array of query points. engine (``string``): BVH engine name. Valid choices are "cgal", "geogram",

(mesh, pts, engine="auto", bvh=None)

Source from the content-addressed store, hash-verified

65
66
67def distance_to_mesh(mesh, pts, engine="auto", bvh=None):
68 """ Compute the distance from a set of points to a mesh.
69
70 Args:
71 mesh (:class:`Mesh`): A input mesh.
72 pts (:class:`numpy.ndarray`): A :math:`N \\times dim` array of query
73 points.
74 engine (``string``): BVH engine name. Valid choices are "cgal",
75 "geogram", "igl" if all dependencies are used. The default is
76 "auto" where an available engine is automatically picked.
77 bvh (:class:`BVH`): BVH engine instance (optional)
78
79 Returns:
80 Three values are returned.
81
82 * ``squared_distances``: squared distances from each point to mesh.
83 * ``face_indices`` : the closest face to each point.
84 * ``closest_points``: the point on mesh that is closest to each
85 query point.
86 """
87
88 if not bvh:
89 bvh = BVH(engine, mesh.dim)
90 bvh.load_mesh(mesh)
91 squared_distances, face_indices, closest_points = bvh.lookup(pts)
92 return squared_distances, face_indices, closest_points
93
94def signed_distance_to_mesh(mesh, pts, engine="igl", bvh=None):
95 """ Compute the signed distance from a set of points to a mesh.

Callers 2

Calls 3

load_meshMethod · 0.95
lookupMethod · 0.95
BVHClass · 0.85

Tested by 2