text: #!/usr/bin/env python
  
  # noinspection PyUnresolvedReferences
  import vtkmodules.vtkInteractionStyle
  # noinspection PyUnresolvedReferences
  import vtkmodules.vtkRenderingOpenGL2
  from vtkmodules.vtkCommonColor import vtkNamedColors
  from vtkmodules.vtkCommonCore import vtkPoints
  from vtkmodules.vtkCommonDataModel import (
      vtkCellArray,
      vtkPolyData,
      vtkPolygon
  )
  from vtkmodules.vtkRenderingCore import (
      vtkActor,
      vtkPolyDataMapper,
      vtkRenderWindow,
      vtkRenderWindowInteractor,
      vtkRenderer
  )
  
  
  def main():
      colors = vtkNamedColors()
  
      # Setup four points
      points = vtkPoints()
      points.InsertNextPoint(0.0, 0.0, 0.0)
      points.InsertNextPoint(1.0, 0.0, 0.0)
      points.InsertNextPoint(1.0, 1.0, 0.0)
      points.InsertNextPoint(0.0, 1.0, 0.0)
  
      # Create the polygon
      polygon = vtkPolygon()
      polygon.GetPointIds().SetNumberOfIds(4)  # make a quad
      polygon.GetPointIds().SetId(0, 0)
      polygon.GetPointIds().SetId(1, 1)
      polygon.GetPointIds().SetId(2, 2)
      polygon.GetPointIds().SetId(3, 3)
  
      # Add the polygon to a list of polygons
      polygons = vtkCellArray()
      polygons.InsertNextCell(polygon)
  
      # Create a PolyData
      polygonPolyData = vtkPolyData()
      polygonPolyData.SetPoints(points)
      polygonPolyData.SetPolys(polygons)
  
      # Create a mapper and actor
      mapper = vtkPolyDataMapper()
      mapper.SetInputData(polygonPolyData)
  
      actor = vtkActor()
      actor.SetMapper(mapper)
      actor.GetProperty().SetColor(colors.GetColor3d('Silver'))
  
      # Visualize
      renderer = vtkRenderer()
      renderWindow = vtkRenderWindow()
      renderWindow.SetWindowName('Polygon')
      renderWindow.AddRenderer(renderer)
      renderWindowInteractor = vtkRenderWindowInteractor()
      renderWindowInteractor.SetRenderWindow(renderWindow)
  
      renderer.AddActor(actor)
      renderer.SetBackground(colors.GetColor3d('Salmon'))
      renderWindow.Render()
      renderWindowInteractor.Start()
  
  
  if __name__ == '__main__':
      main()
  