Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if source_mask is not None:
gids = np.arange(source.n_points)
name_ids = source.append_array(gids, at='p')
source_masked = mask_points(source, source_mask)
source.remove_array(name_ids)
source = source_masked
if source.n_points != np.count_nonzero(source_mask):
raise ValueError('Source mask is not fully connected.')
celoc = vtkCellLocator()
celoc.SetDataSet(source.VTKObject)
celoc.BuildLocator()
tp = me.get_points(target, mask=target_mask)
n_pts = tp.shape[0]
weights = np.empty((n_pts, 3))
pids = np.empty((n_pts, 3), dtype=np.int64)
for i, p in enumerate(tp):
celoc.FindClosestPoint(p, close_pt, c, cid, subcid, dist)
c.EvaluatePosition(close_pt, close_pt, subcid, pcoord, dist,
weights[i])
pids[i] = [c.GetPointIds().GetId(k) for k in range(3)]
if source_mask is not None:
gids = source.get_array(name_ids, at='p')
pids = np.unique(gids, return_inverse=True)[1][pids]
return pids, weights