code: def slice_triangle_plane(verts, tri, plane_orig, plane_norm):
      
      dists = [point_to_plane_dist(p, plane_orig, plane_norm)
               for p in verts[tri]]
  
      if np.sign(dists[0]) == np.sign(dists[1]) \
              and np.sign(dists[1]) == np.sign(dists[2]):
          # Triangle is on one side of the plane
          return []
  
      # Iterate through the edges, cutting the ones that intersect
      intersect_points = []
      for fi in range(3):
          v1 = verts[tri[fi]]
          d1 = dists[fi]
          v2 = verts[tri[(fi + 1) % 3]]
          d2 = dists[(fi + 1) % 3]
  
          if d1 * d2 < 0:
              # intersection factor (between 0 and 1)
              # here is a nice drawing :
              # https://ravehgonen.files.wordpress.com/2013/02/slide8.png
              s = d1 / (d1 - d2)
              vdir = v2 - v1
              intersect_points.append(v1 + vdir * s)
          elif np.fabs(d1) < 1e-5:
              # point on plane
              intersect_points.append(v1)
  
      return intersect_points
docs: Args:
          verts : the vertices of the mesh
          tri: the face to cut
          plane_orig: origin of the plane
          plane_norm: normal to the plane