import vtk
points = vtk.vtkPoints()
points.InsertNextPoint(0, 0, 0)
points.InsertNextPoint(1, 0, 0)
points.InsertNextPoint(0, 1, 0)
points.InsertNextPoint(0, 0, 1)
points.InsertNextPoint(0, 1, 1)
vertices = vtk.vtkCellArray()
numPoints = points.GetNumberOfPoints()
for i in range(numPoints):
vertices.InsertNextCell(1)
vertices.InsertCellPoint(i)
polydata = vtk.vtkPolyData()
polydata.SetPoints(points)
polydata.SetVerts(vertices)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(polydata)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
renderer = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(renderer)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
renderer.AddActor(actor)
renderer.SetBackground(0, 0.25, 0)
renWin.Render()
iren.Start()
效果如下,
大体看了一下是生成一个点云对象,然后手动往里面加几个点,然后可视化;
还不熟悉;有时间继续;