from vtk import * pts = vtkPoints() polys = vtkCellArray() pd = vtkPolyData() pd.SetPoints(pts) pd.SetPolys(polys) pts.InsertNextPoint(0.0,0.0,0.0) pts.InsertNextPoint(100.0,0.0,0.0) pts.InsertNextPoint(100.0,100.0,0.0) pts.InsertNextPoint(0.0,100.0,0.0) pts.InsertNextPoint(25.0,35.0,0.0) pts.InsertNextPoint(65.0,25.0,0.0) pts.InsertNextPoint(75.0,65.0,0.0) pts.InsertNextPoint(35.0,75.0,0.0) pts.InsertNextPoint(15.0,5.0,0.0) pts.InsertNextPoint(30.0,15.0,0.0) pts.InsertNextPoint(20.0,30.0,0.0) pts.InsertNextPoint(5.0,20.0,0.0) # define contours # outer polys.InsertNextCell(4) polys.InsertCellPoint(0) polys.InsertCellPoint(1) polys.InsertCellPoint(2) polys.InsertCellPoint(3) # inner polys.InsertNextCell(4) polys.InsertCellPoint(4) polys.InsertCellPoint(5) polys.InsertCellPoint(6) polys.InsertCellPoint(7) # inner polys.InsertNextCell(4) polys.InsertCellPoint(8) polys.InsertCellPoint(9) polys.InsertCellPoint(10) polys.InsertCellPoint(11) gtf = vtkGLUTesselatorTriangleFilter() gtf.SetInput(pd) pdm = vtkPolyDataMapper() pdm.SetInput(gtf.GetOutput()) actor = vtkActor() actor.SetMapper(pdm) actor.GetProperty().SetColor(0,0,1) ren = vtkRenderer() renwin = vtkRenderWindow() renwin.AddRenderer(ren) iren = vtkRenderWindowInteractor() iren.SetRenderWindow(renwin) ren.AddActor(actor) ren.SetBackground(1,1,1) renwin.SetSize(600,600) iren.Initialize renwin.Render() iren.Start()