【发布时间】:2019-07-26 00:44:48
【问题描述】:
我有两个 VTK 多数据对象,其中包含要检查交叉点的点数据。本质上,我想将这些点做成多边形,然后使用它。
我被告知这样做的方法是convert the point data into a triangular mesh,然后使用vtkIntersectionPolyDataFilter 进行检查。这是我目前拥有的:
def convert_pts_to_mesh(polydata):
aCellArray = vtk.vtkCellArray()
boundary = vtk.vtkPolyData()
boundary.SetPoints(polydata.GetPoints())
boundary.SetPolys(aCellArray)
delaunay = vtk.vtkDelaunay2D()
delaunay.SetInputData(polydata)
delaunay.SetSourceData(boundary)
delaunay.Update()
result_polydata = delaunay.GetOutput()
# print("result_polydata:")
# print(result_polydata)
return result_polydata
...
contour1 = ... # Source of polydata point object
contour2 = ... # Source of polydata point object
# Convert them to triangle meshes.
result_polydata1 = convert_pts_to_mesh(contour1)
result_polydata2 = convert_pts_to_mesh(contour2)
intersection_operation = vtk.vtkIntersectionPolyDataFilter()
intersection_operation.SetInputData(0, result_polydata1)
intersection_operation.SetInputData(1, result_polydata2)
intersection_operation.Update()
print("# of crosses: " + str(intersection_operation.GetNumberOfIntersectionPoints()))
但是,这会吐出我认为与 intersection_operation.Update() 调用中的失败有关的错误。
#121.040# [VtkError] ERROR: ERROR: In /usr/local/sv/ext/2019.02/release/gl2/src/vtk-8.1.1/Common/DataModel/vtkPointLocator.cxx, line 867
vtkPointLocator (0x555d26925800): No points to subdivide
!121.041! [VtkGenericWarning] WARNING: Generic Warning: In /usr/local/sv/ext/2019.02/release/gl2/src/vtk-8.1.1/Filters/General/vtkIntersectionPolyDataFilter.cxx, line 2518
No Intersection between objects
# of crosses: 0
事实上,错误提到了细分点,我尝试输入 contour1 和 contour2 对象,但随后在 SetInputData 行上出错:
!126.179! [VtkGenericWarning] WARNING: Generic Warning: In /usr/local/sv/ext/2019.02/release/gl2/src/vtk-8.1.1/Common/Core/vtkMath.cxx, line 779
vtkMath::Jacobi: Error extracting eigenfunctions
我不知道从哪里开始,Delaunay 和 IntersectonPolyDataFilter 上的 VTK 文档对我来说并不是最有用的。
【问题讨论】: