code: def saveVTK(self, filename):
          
          with open(filename, 'w') as f:
              f.write('# vtk DataFile Version 3.0\n')
              f.write('pycsg output\n')
              f.write('ASCII\n')
              f.write('DATASET POLYDATA\n')
          
              verts, cells, count = self.toVerticesAndPolygons()
  
              f.write('POINTS {0} float\n'.format(len(verts)))
              for v in verts:
                  f.write('{0} {1} {2}\n'.format(v[0], v[1], v[2]))
              numCells = len(cells)
              f.write('POLYGONS {0} {1}\n'.format(numCells, count + numCells))
              for cell in cells:
                  f.write('{0} '.format(len(cell)))
                  for index in cell:
                      f.write('{0} '.format(index))
                  f.write('\n')
docs: Save polygons in VTK file.