我正在尝试使用 PyVista python 包找到多点渐变曲线和三角曲面之间的交点。我已经尝试过常规折线并将折线制作成管以进行交叉计算。出于某种原因,PV 返回网格之间没有交集。我已经在视觉上确认了网格之间存在交集。我试图将折线生成为三角网格,然后检查这两个网格之间的交点。这行得通,但不幸的是,三角测量将我的折线扭曲到无法使用的程度。有人可以看看并告诉我我做错了什么吗?这是我创建折线点管的代码:
import pyvista as pv
import pandas as pd
import numpy as np
# Loading in a xyz surface file and cleaning it up.
surface_file = surface_file_location
surf_df = pd.read_csv(surface_file,names = ['x','y','z','column','row'],delim_whitespace=True, skiprows = 20)
surf_df.drop(['column','row'], inplace = True, axis = 1)
x_s = surf_df['x'].to_numpy()
y_s = surf_df['y'].to_numpy()
z_s = surf_df['z'].to_numpy()
points = np.c_[x_s.reshape(-1), y_s.reshape(-1), z_s.reshape(-1)]
cloud = pv.PolyData(points,n_faces=0)
tsurf = cloud.delaunay_2d()
#Loading in the polyline data and cleaning it up
polyline_df = polyline_location
polyline_df = polyline_df.filter(['x','y','z'])
x_s = polyline_df['x'].to_numpy(dtype="float32")
y_s = polyline_df['y'].to_numpy(dtype="float32")
z_s = polyline_df['z'].to_numpy(dtype="float32")
points = np.column_stack((x_s, y_s, z_s))
def polyline_from_points(points):
poly = pv.PolyData()
poly.points = points
the_cell = np.arange(0, len(points), dtype=np.int_)
the_cell = np.insert(the_cell, 0, len(points))
poly.lines = the_cell
return poly
polyline = polyline_from_points(points)
polyline["scalars"] = np.arange(polyline.n_points)
tube = polyline.tube(radius=100)
#calling the intersection function on the polyline
tube.intersection(tsurf)
如果我可以提供任何进一步的细节,请告诉我。