code: def save(self, filename, binary=True):
          
          filename = os.path.abspath(os.path.expanduser(filename))
          file_mode = True
          # Check filetype
          ftype = filename[-3:]
          if ftype == 'ply':
              writer = vtk.vtkPLYWriter()
          elif ftype == 'vtp':
              writer = vtk.vtkXMLPolyDataWriter()
              file_mode = False
              if binary:
                  writer.SetDataModeToBinary()
              else:
                  writer.SetDataModeToAscii()
          elif ftype == 'stl':
              writer = vtk.vtkSTLWriter()
          elif ftype == 'vtk':
              writer = vtk.vtkPolyDataWriter()
          else:
              raise Exception('Filetype must be either "ply", "stl", or "vtk"')
  
          writer.SetFileName(filename)
          writer.SetInputData(self)
          if binary and file_mode:
              writer.SetFileTypeToBinary()
          elif file_mode:
              writer.SetFileTypeToASCII()
          writer.Write()
docs: Writes a surface mesh to disk.
  
          Written file may be an ASCII or binary ply, stl, or vtk mesh file.
  
          Parameters
          ----------
          filename : str
              Filename of mesh to be written.  File type is inferred from
              the extension of the filename unless overridden with
              ftype.  Can be one of the following types (.ply, .stl,
              .vtk)
  
          binary : bool, optional
              Writes the file as binary when True and ASCII when False.
  
          Notes
          -----
          Binary files write much faster than ASCII and have a smaller
          file size.