-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
I am attempting to run a signed heat geodesic distance but failing because of a:
"RuntimeError: Each curve segment must be contained within a single face." Error
The current code looks like this
V, F = mesh_to_VF(mesh)
curves = polylines_to_bary_curves(mesh, polylines)
is_signed = coerce_is_signed(signed if 'signed' in globals() else True, len(curves))
pts_unsigned = sanitize_points_list(source_vertices if 'source_vertices' in globals() else None, V.shape[0])
solver = pp3d.MeshSignedHeatSolver(V, F)
dist = solver.compute_distance(curves, is_signed, pts_unsigned)
dist = np.asarray(dist, dtype=float).ravel().tolist()
I am running this in rhino/grasshopper so the generation of the curves list looks like this:
def _bary_from_meshpoint(mp):
"""
Extract (face_index, [b0, b1, b2]) from a Rhino MeshPoint.
"""
if mp is None or mp.FaceIndex < 0:
raise ValueError("Invalid MeshPoint (no face hit).")
fi = int(mp.FaceIndex)
T = list(mp.T) # MeshPoint.T is double[]; convert to a Python list
T = T[:3]
return fi, T
def polylines_to_bary_curves(m, polys):
"""Project each polyline vertex to mesh and encode as (face_index, [b0,b1,b2]) tuples."""
curves = []
if not polys:
return curves
for obj in polys:
# Ensure we have an rg.Polyline to iterate
pl = None
if isinstance(obj, rg.Polyline):
pl = obj
elif isinstance(obj, rg.PolylineCurve):
pl = obj.ToPolyline()
if pl is None or pl.Count == 0:
continue
nodes = []
for i in range(pl.Count):
p = pl[i] # Polyline supports indexer access
mp = m.ClosestMeshPoint(p, 1e30)
if mp is None or mp.FaceIndex < 0:
continue
fi, b = _bary_from_meshpoint(mp)
nodes.append((fi, b))
if nodes:
curves.append(nodes)
return curves
does anyone know where this error is coming from and how to address it?
Metadata
Metadata
Assignees
Labels
No labels