import { tm_face_kill } from "./tm_face_kill.js";
import { tm_kill_only_edge } from "./tm_kill_only_edge.js";

/**
 * Remove edge and all faces that use it
 * NOTE: Loosely based on blender's code:  https://github.com/blender/blender/blob/594f47ecd2d5367ca936cf6fc6ec8168c2b360d0/source/blender/bmesh/intern/bmesh_core.c#L987
 * @param {TopoMesh} mesh
 * @param {TopoEdge} edge
 */
export function tm_edge_kill(mesh, edge) {

    const faces = edge.faces;
    const face_count = faces.length;

    for (let i = face_count - 1; i >= 0; i--) {
        tm_face_kill(mesh, faces[i]);
    }

    edge.unlink();

    tm_kill_only_edge(mesh, edge);
}


