0

我需要根据我拥有的点列表在 vtk 上创建一个三角形网格。这些点存储在sphere下,这是一个 nx9 numpy 数组,其中每一行代表组成一个三角形的三个点。现在我正在这样做:

points = vtk.vtkPoints()
triangles = vtk.vtkCellArray()
polydata = vtk.vtkPolyData()

for i in range(len(sphere)):
    points.InsertNextPoint(sphere[i][:3])
    points.InsertNextPoint(sphere[i][3:6])
    points.InsertNextPoint(sphere[i][6:9])

    triangle = vtk.vtkTriangle()
    triangle.GetPointIds().SetId(0,0)
    triangle.GetPointIds().SetId(1,1)
    triangle.GetPointIds().SetId(2,2)

    triangles.InsertNextCell(triangle)

polydata.SetPoints(points)
polydata.SetPolys(triangles)

哪个不能正确识别每个三角形。我该如何解决这个问题?

4

1 回答 1

1

每个 InsertNextPoint 返回一个 vtkIdType。这些是应该进入三角形 SetID 的第二个参数的数字。

于 2021-05-17T21:24:19.610 回答