VTK/Examples/Python/TriangleCornerVertices
From KitwarePublic
< VTK | Examples(Redirected from Write the corners of a triangle to a file (+vertices) (python))
import vtk from vtk import * import hybrid from hybrid import * Points = vtk.vtkPoints() Vertices = vtk.vtkCellArray() id = Points.InsertNextPoint(1.0, 0.0, 0.0) Vertices.InsertNextCell(1) Vertices.InsertCellPoint(id) id = Points.InsertNextPoint(0.0, 0.0, 0.0) Vertices.InsertNextCell(1) Vertices.InsertCellPoint(id) id = Points.InsertNextPoint(0.0, 1.0, 0.0) Vertices.InsertNextCell(1) Vertices.InsertCellPoint(id) polydata = vtk.vtkPolyData() polydata.SetPoints(Points) polydata.SetVerts(Vertices) polydata.Modified() polydata.Update() writer = vtk.vtkXMLPolyDataWriter(); writer.SetFileName("TriangleVerts.vtp"); writer.SetInput(polydata); writer.Write();

