code: def get_next_triangle(mesh, T, plane, intersection, dist_tol):
      
      if intersection[0] == INTERSECT_EDGE:
          tris = mesh.triangles_for_edge(intersection[2])
      elif intersection[0] == INTERSECT_VERTEX:
          tris = mesh.triangles_for_vert(intersection[2])
      else:
          assert False, 'Invalid intersection[0] value : %d' % intersection[0]
  
      # Knowing where we come from is not enough. If an edge of the triangle
      # lies exactly on the plane, i.e. :
      #
      #   /t1\
      # -v1---v2-
      #   \t2/
      #
      # With v1, v2 being the vertices and t1, t2 being the triangles, then
      # if you just try to go to the next connected triangle that intersect,
      # you can visit v1 -> t1 -> v2 -> t2 -> v1 .
      # Therefore, we need to limit the new candidates to the set of unvisited
      # triangles and once we've visited a triangle and decided on a next one,
      # remove all the neighbors of the visited triangle so we don't come
      # back to it
  
      T = set(T)
      for tid in tris:
          if tid in T:
              intersections = compute_triangle_plane_intersections(
                      mesh, tid, plane, dist_tol)
              if len(intersections) == 2:
                  T = T.difference(tris)
                  return tid, intersections, T
      return None, [], T
docs: Returns the next triangle to visit given the intersection and
      the list of unvisited triangles (T)
  
      We look for a triangle that is cut by the plane (2 intersections) as
      opposed to one that only touch the plane (1 vertex intersection)