docs: def compute_triangle_plane_intersections(mesh, tid, plane, dist_tol=1e-8):
      """
      Compute the intersection between a triangle and a plane
  
      Returns a list of intersections in the form
          (INTERSECT_EDGE, <intersection point>, <edge>) for edges intersection
          (INTERSECT_VERTEX, <intersection point>, <vertex index>) for vertices
  
  
      This return between 0 and 2 intersections :
      - 0 : the plane does not intersect the plane
      - 1 : one of the triangle's vertices lies on the plane (so it just
            "touches" the plane without really intersecting)
      - 2 : the plane slice the triangle in two parts (either vertex-edge,
            vertex-vertex or edge-edge)
      """
      # TODO: Use a distance cache
      dists = {vid: point_to_plane_dist(mesh.verts[vid], plane)
               for vid in mesh.tris[tid]}
      # TODO: Use an edge intersection cache (we currently compute each edge
      # intersection twice : once for each tri)
  
      # This is to avoid registering the same vertex intersection twice
      # from two different edges
      vert_intersect = {vid: False for vid in dists.keys()}
  
      # Iterate through the edges, cutting the ones that intersect
      intersections = []
      for e in mesh.edges_for_triangle(tid):
          v1 = mesh.verts[e[0]]
          d1 = dists[e[0]]
          v2 = mesh.verts[e[1]]
          d2 = dists[e[1]]
  
          if np.fabs(d1) < dist_tol:
              # Avoid creating the vertex intersection twice
              if not vert_intersect[e[0]]:
                  # point on plane
                  intersections.append((INTERSECT_VERTEX, v1, e[0]))
                  vert_intersect[e[0]] = True
          if np.fabs(d2) < dist_tol:
              if not vert_intersect[e[1]]:
                  # point on plane
                  intersections.append((INTERSECT_VERTEX, v2, e[1]))
                  vert_intersect[e[1]] = True
  
          # If vertices are on opposite sides of the plane, we have an edge
          # intersection
          if d1 * d2 < 0:
              # Due to numerical accuracy, we could have both a vertex intersect
              # and an edge intersect on the same vertex, which is impossible
              if not vert_intersect[e[0]] and not vert_intersect[e[1]]:
                  # intersection factor (between 0 and 1)
                  # here is a nice drawing :
                  # https://ravehgonen.files.wordpress.com/2013/02/slide8.png
                  # keep in mind d1, d2 are *signed* distances (=> d1 - d2)
                  s = d1 / (d1 - d2)
                  vdir = v2 - v1
                  ipos = v1 + vdir * s
                  intersections.append((INTERSECT_EDGE, ipos, e))
  
      return intersections