[英]How to initialize a triangular mesh in vtk
I need to create a triangular mesh on vtk from a list of points that I have.我需要根据我拥有的点列表在 vtk 上创建一个三角形网格。 The points are stored under sphere , which is a nx9 numpy array where each row represents the three points that make up one triangle.
这些点存储在sphere下,这是一个 nx9 numpy 数组,其中每一行代表组成一个三角形的三个点。 Right now I am doing this:
现在我正在这样做:
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)
Which does not properly identify each triangle.哪个不能正确识别每个三角形。 How do I solve this issue?
我该如何解决这个问题?
Each InsertNextPoint returns a vtkIdType.每个 InsertNextPoint 返回一个 vtkIdType。 Those are the numbers that should go into the 2nd parameter of the triangle's SetID.
这些是应该 go 进入三角形 SetID 的第二个参数的数字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.