[英]Initialize triangular mesh in e.g. VTK based on np array with coordinates of vertices and np array with triangles
[英]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.