【问题标题】:How to initialize a triangular mesh in vtk如何在 vtk 中初始化三角形网格
【发布时间】:2021-05-17 07:11:55
【问题描述】:

我需要根据我拥有的点列表在 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)

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

【问题讨论】:

    标签: python numpy vtk triangular numpy-stl


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-25
      • 1970-01-01
      • 2014-10-09
      • 1970-01-01
      • 2020-12-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多