UNPKG

@thi.ng/quad-edge

Version:

Quadedge data structure after Guibas & Stolfi

114 lines 3.26 kB
/** * Type alias for a 4-tuple of {@link Edge} instances. */ export type QuadEdge<T> = [Edge<T>, Edge<T>, Edge<T>, Edge<T>]; /** * Main edge / quadedge factory function. Use this in preference of direct * invocation of the {@link Edge} constructor. * * Creates new {@link QuadEdge} with 4 child edges and returns the first * child/primary edge. If `src` and `dest` are given, they will be associated * with that new edge as end points. * * @remarks * The given `id` MUST be a multiple of 4. * * @param id - * @param src - * @param dest - */ export declare function defEdge<T>(id: number): Edge<T>; export declare function defEdge<T>(id: number, src: T, dest: T): Edge<T>; /** * Quad-edge implementation after Guibas & Stolfi. Based on C++ versions by Paul * Heckbert, Dani Lischinski et al: * * References: * * - http://www.cs.cmu.edu/afs/andrew/scs/cs/15-463/2001/pub/src/a2/quadedge.html * - http://www.cs.cmu.edu/afs/andrew/scs/cs/15-463/2001/pub/src/a2/lischinski/114.ps */ export declare class Edge<T> { id: number; parent: QuadEdge<T>; origin: T; constructor(parent: QuadEdge<T>, id: number); /** * Next CCW edge from this edge's origin. */ onext: Edge<T>; /** * Next CW edge from this edge's origin. */ get oprev(): Edge<T>; /** * Dual of this edge, right -> left. */ get rot(): Edge<T>; /** * Dual of this edge, left -> right. * I.e same as `this.rot.sym` */ get invrot(): Edge<T>; /** * Symmetric partner edge of this edge, from dest -> src. * I.e. `this === this.sym.sym` */ get sym(): Edge<T>; /** * Next CCW edge to this edge's dest. */ get dnext(): Edge<T>; /** * Next CW edge to this edge's dest. */ get dprev(): Edge<T>; /** * Next CCW edge around the left face (dual vertex) from this edge's * dest. */ get lnext(): Edge<T>; /** * Next CCW edge around the left face (dual vertex) to this edge's * origin. */ get lprev(): Edge<T>; /** * Next CCW edge around the right face (dual vertex) to this edge's * dest. */ get rnext(): Edge<T>; /** * Next CCW edge around the right face (dual vertex) to this edge's * origin. */ get rprev(): Edge<T>; /** * Returns this edge's dest vertex. I.e. `this.sym.origin` */ get dest(): T; /** * Sets the origin & dest vertices of this edge (in other words, the * origins of this edge and `this.sym`). * * @param o - * @param d - */ setEnds(o: T, d: T): void; connect(e: Edge<T>, id: number): Edge<T>; swap(): void; remove(): void; /** * Modifies the edge rings around the origins of this edge and `e`, * as well as, independently, the edge rings of both edges' left * dual vertex. In each case, if the rings are separate, this * operator will join them and if both rings are the same ring, they * will be split / separated. Therefore, splice` is it's own reverse * operator and the only operator needed to edit quad edge * topologies. * * @param e - */ splice(e: Edge<T>): Edge<T>; } //# sourceMappingURL=index.d.ts.map