簡體   English   中英

如何在 vtk 中初始化三角形網格

[英]How to initialize a triangular mesh in vtk

我需要根據我擁有的點列表在 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)

哪個不能正確識別每個三角形。 我該如何解決這個問題?

每個 InsertNextPoint 返回一個 vtkIdType。 這些是應該 go 進入三角形 SetID 的第二個參數的數字。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM