import { LineSegment3d } from "../curve/LineSegment3d"; import { Point2d, Vector2d } from "../geometry3d/Point2dVector2d"; import { Point3d, Vector3d } from "../geometry3d/Point3dVector3d"; import { Transform } from "../geometry3d/Transform"; import { WritableXYAndZ, XAndY, XYAndZ } from "../geometry3d/XYZProps"; /** * * Each node of the graph has a mask member. * * The mask member is a number which is used as set of single bit boolean values. * * Particular meanings of the various bits are HIGHLY application dependent. * * The EXTERIOR mask bit is widely used to mark nodes that are "outside" the active areas * * The PRIMARY_EDGE bit is widely used to indicate linework created directly from input data, hence protected from * triangle edge flipping. * * The BOUNDARY bit is widely used to indicate that crossing this edge is a transition from outside to inside. * * VISITED is used locally in many searches. * * Never use VISITED unless the search logic is highly self contained. * @internal */ export declare enum HalfEdgeMask { /** * Mask commonly set consistently around exterior faces. * * A boundary edge with interior to one side, exterior to the other, will have EXTERIOR only on the outside. * * An edge inserted "within a purely exterior face" can have EXTERIOR on both sides. * * An interior edge (such as added during triangulation) will have no EXTERIOR bits. */ EXTERIOR = 1, /** * Mask commonly set (on both sides) of original geometry edges that are transition from outside to inside. * * At the moment of creating an edge from primary user boundary loop coordinates, the fact that an edge is BOUNDARY * is often clear even though there is uncertainty about which side should be EXTERIOR. */ BOUNDARY_EDGE = 2, /** * Mask commonly set (on both sides) of original geometry edges, but NOT indicating that the edge is certainly a * boundary between outside and inside. * * For instance, if geometry is provided as stray sticks (not loops), it can be marked PRIMARY_EDGE but neither * BOUNDARY_EDGE nor EXTERIOR_EDGE. */ PRIMARY_EDGE = 4, /** Mask set on both sides of a bridge edge added by algorithms to join loops. */ BRIDGE_EDGE = 8, /** Mask set on both sides of an edge added during graph regularization. */ REGULARIZED_EDGE = 16, /** Mask applied to triangles by earcut triangulator. */ TRIANGULATED_FACE = 256, /** Mask applied in a face with 2 edges. */ NULL_FACE = 512, /** Temporary mask used for low level searches to identify previously-visited nodes. */ VISITED = 65536, /** No mask bits. */ NULL_MASK = 0, /** The "upper 12" bits of 32 bit integer reserved for grab/drop. */ ALL_GRAB_DROP_MASKS = 4293918720, /** All mask bits */ ALL_MASK = 4294967295 } /** * Function signature for function of one node with no return type restrictions. * @internal */ export type HalfEdgeFunction = (node: HalfEdge) => any; /** * Function signature for function of one node, returning a number. * @internal */ export type HalfEdgeToNumberFunction = (node: HalfEdge) => number; /** * Function signature for function of one node, returning a boolean. * @internal */ export type HalfEdgeToBooleanFunction = (node: HalfEdge) => boolean; /** * Function signature for function of a node and a mask, returning a boolean. * @internal */ export type HalfEdgeAndMaskToBooleanFunction = (node: HalfEdge, mask: HalfEdgeMask) => boolean; /** * Function signature for function of a graph and a node, returning a boolean. * @internal */ export type GraphHalfEdgeFunction = (graph: HalfEdgeGraph, node: HalfEdge) => boolean; /** * Non-topological data members in a half edge. * These are not part of adjacency and masking logic. * Member fields for a half edge (which is also commonly called a node). * @internal */ export interface HalfEdgeUserData extends WritableXYAndZ { /** Angle used for sort-around-vertex. */ sortAngle?: number; /** Numeric value for application-specific tagging (e.g. sorting). */ sortData?: number; /** * Application-specific data for the edge identifier. * * Edge split operations are expected to copy this to new sub-edges. */ edgeTag?: any; /** * Application-specific data for the face loop. * * Face split operations are expected to copy this to new nodes in the face. */ faceTag?: any; } /** * A HalfEdge is "one side of an edge" in a structure of faces, edges and vertices. From a node there are * navigational links to: * * "faceSuccessor" -- the next half edge in a loop around a face. * * "facePredecessor" -- the previous half edge in a loop around a face. * * "edgeMate" -- the node's partner on the other side of the edge. * * The next, prev, and mate are the essential connectivity. Additional node content is for application-specific * uses. The most useful ones are: * * x,y -- coordinates in the xy plane * * z -- z coordinate. This is normally ignored during planar setup, but used for output. * * maskBits -- an integer value manipulated as individual bits. * * In properly connected planar graph, interior face loops are counterclockwise. But that property (along with * expected masking) is a result of extensive validation of inputs, and is not true in intermediate phases of * graph manipulation. * @internal */ export declare class HalfEdge implements HalfEdgeUserData { /** Vertex index in some parent object's numbering. */ i: number; /** * Bitmask bits, used to set multiple flags on a node, indicating e.g., nodes on boundary edges, or in * an exterior face, or nodes visited during graph computations. * * See [[HalfEdgeMask]] for mask values. */ maskBits: number; /** Vertex x coordinate. */ x: number; /** Vertex y coordinate. */ y: number; /** Vertex z coordinate. */ z: number; /** Angle used for sort-around-vertex */ sortAngle?: number; /** Numeric value for application-specific tagging (e.g. sorting) */ sortData?: number; /** * Application-specific data for the edge identifier. * * edge split operations are expected to copy this to new sub-edges. */ edgeTag?: any; /** * Application-specific data for the face loop. * * Face split operations are expected to copy this to new nodes in the face. */ faceTag?: any; private _id; /** Immutable ID assigned sequentially during construction --- useful for debugging. */ get id(): number; private _facePredecessor; private _faceSuccessor; private _edgeMate; /** Previous half edge "around the face" */ get facePredecessor(): HalfEdge; /** Next half edge "around the face" */ get faceSuccessor(): HalfEdge; /** Half edge on the other side of this edge. */ get edgeMate(): HalfEdge; /** HalfEdge ids are sequentially assigned per session (not per graph!). */ private static _totalNodesCreated; private constructor(); /** * Take numStep face steps and return y coordinate. * * Positive steps are through faceSuccessor. * * Negative steps are through facePredecessor. */ faceStepY(numStep: number): number; /** * Create 2 half edges. * * The two edges are joined as edgeMate pair. * * The two edges are a 2-half-edge face loop in both the faceSuccessor and facePredecessor directions. * @returns the reference to the first half edge created. */ static createHalfEdgePair(heArray: HalfEdge[] | undefined): HalfEdge; /** * * Create 2 half edges. * * The two edges are joined as edgeMate pair. * * The two edges are a 2-half-edge face loop in both the faceSuccessor and facePredecessor directions. * * Properties x,y,z,i are inserted in each half edge. * @returns the reference to the first half edge created, set with "A" properties. */ static createHalfEdgePairWithCoordinates(xA: number | undefined, yA: number | undefined, zA: number | undefined, iA: number | undefined, xB: number | undefined, yB: number | undefined, zB: number | undefined, iB: number | undefined, heArray: HalfEdge[] | undefined): HalfEdge; /** * * Set heA <==> heB pointer relation through heA._faceSuccessor and heB._facePredecessor. * * This changes heA._faceSuccessor and heB._facePredecessor, but not heA._facePredecessor and heB._faceSuccessor. * * This must always be done with another call to setFaceLinks(heB,heA) in order to re-establish the entire * double-linked list. */ private static setFaceLinks; /** set heA <==> heB pointer relation edgeMate. */ private static setEdgeMates; /** * Create a new vertex within the edge beginning at `baseA`. * * This creates two new nodes in their own vertex loop. * * If the base is `undefined`, create a single-edge loop. * * Existing nodes stay in their face and vertex loops and retain xyz and i values. * * Unlike [[pinch]], this breaks the edgeMate pairing of the input edge: * each node of the input edge gets a new node as its edge mate. * * On each side of the edge, if edgeTag is present, it is copied to the new node on that side. * @returns reference to the half edge created, the new face successor of `baseA`. */ static splitEdge(baseA: undefined | HalfEdge, xA: number | undefined, yA: number | undefined, zA: number | undefined, iA: number | undefined, heArray: HalfEdge[] | undefined): HalfEdge; /** * Reverse of [[splitEdge]]: remove the vertex at `doomed` and merge its two incident edges. * @param doomed one of two nodes added by [[splitEdge]]. These nodes should form a vertex loop of two nodes. * On successful return this node and its mate are isolated. * @param checkParallel whether to check that the doomed edge and the preceding edge in its face loop are parallel. * When passing `true` the assumption is that edge geometry is linear. If nonlinear edge geometry is attached, the * caller should a) verify that the geometry on either side of the doomed vertex can be merged, and if so, they * should b) call this method passing `false`, and c) adjust the geometry of the returned edge and its edge mate * as appropriate. * @returns the former (surviving) face predecessor of `doomed`, or undefined if the edge can't be healed. */ static healEdge(doomed: HalfEdge, checkParallel?: boolean): HalfEdge | undefined; /** * Create a new sliver face "inside" an existing edge. * * This creates two nodes that are each face predecessor and successor to the other. * * Existing nodes stay in their face and vertex loops and retain xyz and i values. * * Unlike [[pinch]], this breaks the edgeMate pairing of the input edge: * each node of the input edge gets a new node as its edge mate. * * New nodes get the xyz and i values shared by the nodes in the vertex loops into which they are placed. * * New nodes' faceTag and edgeTag are `undefined`. * @returns reference to the half edge created in the vertex loop of baseA. */ static splitEdgeCreateSliverFace(baseA: HalfEdge, heArray: HalfEdge[] | undefined): HalfEdge; /** Masks copied when an edge is split. */ private static _edgePropertyMasks; /** * Copy "edge based" content of `fromNode` to `toNode`: * * edgeTag * * edge masks */ static transferEdgeProperties(fromNode: HalfEdge, toNode: HalfEdge): void; /** Return the next half edge around this vertex in the CCW direction. */ get vertexSuccessor(): HalfEdge; /** Return the next half edge around this vertex in the CW direction. */ get vertexPredecessor(): HalfEdge; /** * Set mask bits on this HalfEdge. * @param mask mask bits to apply */ setMask(mask: HalfEdgeMask): void; /** * Get mask bits from this HalfEdge. * @param mask mask bits to query */ getMask(mask: HalfEdgeMask): number; /** * Clear mask bits from this HalfEdge. * @param mask mask bits to clear */ clearMask(mask: HalfEdgeMask): void; /** Set or clear mask bits from this HalfEdge. * @param mask mask bits * @param clear whether to clear the mask. Default is false (set the mask). */ applyMask(mask: HalfEdgeMask, clear?: boolean): void; /** * Set a mask at all nodes around a vertex. * @param mask mask to apply to the half edges around this HalfEdge's vertex loop. */ setMaskAroundVertex(mask: HalfEdgeMask): void; /** Set x,y,z at all nodes around a vertex. */ setXYZAroundVertex(x: number, y: number, z: number): void; /** * Apply a mask to all edges around a face. * @param mask mask to apply to the half edges around this HalfEdge's face loop. */ setMaskAroundFace(mask: HalfEdgeMask): void; /** * Apply a mask to both sides of an edge. * @param mask mask to apply to this edge and its edgeMate. */ setMaskAroundEdge(mask: HalfEdgeMask): void; /** * Clear a mask on both sides of an edge. * @param mask mask to clear on this edge and its edgeMate. */ clearMaskAroundEdge(mask: HalfEdgeMask): void; /** Returns the number of edges around this face. */ countEdgesAroundFace(): number; /** Return true if `other` node is in the vertex loop around `this` node. */ findAroundVertex(other: HalfEdge): boolean; /** Return true if `other` node is in the face loop around `this` node. */ findAroundFace(other: HalfEdge): boolean; /** * Returns whether the mask is set or unset on all nodes of the face loop. * @param mask the mask to check. * @param value true for mask set and false for mask unset. */ isMaskedAroundFace(mask: HalfEdgeMask, value?: boolean): boolean; /** * Apply a mask and edgeTag to all edges around a face. Optionally apply it to all edge mates. * @param mask mask to apply. * @param tag edgeTag to apply * @param applyToMate If true, also apply the tag to the edge mates around the face. */ setMaskAndEdgeTagAroundFace(mask: HalfEdgeMask, tag: any, applyToMate?: boolean): void; /** Returns the number of edges around vertex. */ countEdgesAroundVertex(): number; /** * Returns the number of nodes that match (or do not match) the given mask value around this face loop. * @param mask the mask to check. * @param value true for mask match and false for mask not match. Default is `true`. */ countMaskAroundFace(mask: HalfEdgeMask, value?: boolean): number; /** * Returns the number of nodes that match (or do not match) the given mask value around this vertex loop. * @param mask the mask to check. * @param value true for mask match and false for mask not match. */ countMaskAroundVertex(mask: HalfEdgeMask, value?: boolean): number; /** * Returns the first node that matches (or does not match) the given mask value around this vertex loop, starting * with the instance node and proceeding via `vertexSuccessor`. * @param mask the mask to check. * @param value true for mask match and false for mask not match. Default is `true`. * @param reverse if true, search in reverse order via `vertexPredecessor`. Default is `false`. */ findMaskAroundVertex(mask: HalfEdgeMask, value?: boolean, reverse?: boolean): HalfEdge | undefined; /** * Returns the first node that matches (or does not match) the given mask value around this face loop, starting * with the instance node and proceeding via face successors. * @param mask the mask to check. * @param value true for mask match and false for mask not match. Default is `true`. */ findMaskAroundFace(mask: HalfEdgeMask, value?: boolean): HalfEdge | undefined; /** * Returns the first node that matches (or does not match) the given mask value around this edge, starting * with the instance node and then checking its edge mate. * @param mask the mask to check. * @param value true for mask match and false for mask not match. */ findMaskAroundEdge(mask: HalfEdgeMask, value?: boolean): HalfEdge | undefined; /** * Set a mask and return prior value. * @param mask mask to apply. */ testAndSetMask(mask: HalfEdgeMask): number; /** * Set `this.x`, `this.y`, `this.z` from `node.x`, `node.y`, `node.z`. * @param node node containing xyz. */ setXYZFrom(node: HalfEdge): void; /** * Set `this.x`, `this.y`, `this.z` from `xyz.x`, `xyz.y`, `xyz.z`. * @param node source with x,y,z properties */ setXYZ(xyz: XYAndZ): void; /** * Test if any of the `mask` bits are set in the node's bitMask. * @return true (as a simple boolean, not a mask) if any bits of the `mask` match bits of the node's bitMask. */ isMaskSet(mask: HalfEdgeMask): boolean; /** * Static method to test if any of the `mask` bits are set in the `node`'s bitMask. * * This is used as filter in searches. * @returns `node.isMaskSet(mask)` */ static filterIsMaskOn(node: HalfEdge, mask: HalfEdgeMask): boolean; /** * Static method to test if any of the `mask` bits are set in the `node`'s bitMask. * * This is used as filter in searches. * @returns `!node.isMaskSet(mask)` */ static filterIsMaskOff(node: HalfEdge, mask: HalfEdgeMask): boolean; /** * Create an edge with initial id,x,y at each end. * @param x0 x coordinate for first node. * @param y0 y coordinate for first node. * @param x1 x coordinate for second node. * @param y1 y coordinate for second node. * @returns the reference to the new node at (x0,y0). */ static createEdgeXYXY(x0: number, y0: number, x1: number, y1: number): HalfEdge; /** *"Pinch" is the universal operator for manipulating a node's next and previous pointers. * * It is its own inverse: applying it twice on the same inputs (i.e., `pinch(a,b); pinch(a,b);`) gets back to * where you started. * * If the inputs are in different face loops, the loops join to one face loop after the pinch. * * If the inputs are in the same face loop, the loop splits into two face loops after the pinch. */ static pinch(nodeA: HalfEdge, nodeB: HalfEdge): void; /** Return whether the edge is dangling at its base. */ get isDangling(): boolean; /** * Pinch this half edge out of its base vertex loop. * @return the surviving HalfEdge in the vertex loop or `undefined` if the instance HalfEdge is already dangling. */ yankFromVertexLoop(): HalfEdge | undefined; /** * Turn all pointers to `undefined` so garbage collector can reuse the object. * * This is to be called only by a Graph object that is being decommissioned. */ decommission(): void; /** Return the node. This identity function is useful as the NodeFunction in collector methods. */ static nodeToSelf(node: HalfEdge): any; /** Return the id of a node. Useful for collector methods. */ static nodeToId(node: HalfEdge): number; /** Return the id of a node as string. Useful for collector methods. */ static nodeToIdString(node: HalfEdge): string; /** Return the [id, mask, [x,y]] of a node. Useful for collector methods. */ static nodeToIdMaskXY(node: HalfEdge): { id: number; mask: string; xy: number[]; }; /** Return the [id, mask, [x,y]] of a node as string. Useful for collector methods. */ static nodeToIdXYString(node: HalfEdge): string; /** Return the [id, [x,y,z]] of a node as string. Useful for collector methods. */ static nodeToIdXYZString(node: HalfEdge): string; /** * Create a string representation of the mask. * * Null mask is empty string. * * Appended characters B,P,X,N are for BOUNDARY_EDGE, PRIMARY_EDGE, EXTERIOR, and NULL_FACE mask bits. */ static nodeToMaskString(node: HalfEdge): string; /** Return [x,y] with coordinates of node. */ static nodeToXY(node: HalfEdge): number[]; /** Return Vector2d from `this` to face successor (with only xy coordinates). */ vectorToFaceSuccessorXY(result?: Vector2d): Vector2d; /** Return Vector3d from `this` to face successor. */ vectorToFaceSuccessor(result?: Vector3d): Vector3d; /** Return Vector3d from `this` to face successor. */ vectorToFacePredecessor(result?: Vector3d): Vector3d; /** * Test if `spaceNode` is in the sector of `sectorNode`. * * The sector at `sectorNode` is defined by two rays starting at `sectorNode` and extending along the edges * owned by `sectorNode` and its face predecessor. * * In general, this method returns `true` if the coordinates of `spaceNode` are _strictly_ inside this sector * (not on the rays). * * Interpretation is whether a viewer at `sectorNode` can see `spaceNode` between the two rays. * * Degenerate sectors of 180 or 360 degrees have special handling. */ static isNodeVisibleInSector(spaceNode: HalfEdge, sectorNode: HalfEdge): boolean; /** Returns 2D cross product of vectors from `base` to `targetA` and from `base` to `targetB`. */ static crossProductXYToTargets(base: HalfEdge, targetA: HalfEdge, targetB: HalfEdge): number; /** Returns 2D dot product of vectors from `baseA` to `targetA` and from `baseB` to `targetB`. */ static dotProductNodeToNodeVectorsXY(baseA: HalfEdge, targetA: HalfEdge, baseB: HalfEdge, targetB: HalfEdge): number; /** Return 2D cross product of vectors from `nodeA` to `nodeB` and from `nodeB` to `nodeC`. */ static crossProductXYAlongChain(nodeA: HalfEdge, nodeB: HalfEdge, nodeC: HalfEdge): number; /** * Compute whether the sector defined by the chain of nodes is convex. * * This function is determining if, in the traversal of the HalfEdges in a face loop, a corner makes a left turn * (convex) or a right turn (not-convex). Note that if we have a convex face, then to traverse it in ccw orientation, * we always do left turns. However, if the face is not convex, we make both left and right turns. * * This computation ignores z-coordinates and connectivity, so the nodes are not required to be in the same face loop. * @param nodeA the first node in the chain, nominally the face predecessor of nodeB. * @param nodeB the second node in the chain; the node at the sector vertex. * @param nodeC the third node in the chain, nominally the face successor of nodeB. * @param signedAreaTol optional signed area tolerance to use in test for parallel vectors. Typically this is a * fraction of the sector's face's signed area. We can't compute area here, so if `undefined`, zero tolerance is used. * @returns true iff the sector is convex. A degenerate sector, where the incident edges overlap, returns false. */ static isSectorConvex(nodeA: HalfEdge, nodeB: HalfEdge, nodeC: HalfEdge, signedAreaTol?: number): boolean; /** * Compute whether the sector at this node is convex. * * This function is determining if, in the traversal of the HalfEdges in a face loop, a corner makes a left turn * (convex) or a right turn (not-convex). Note that if we have a convex face, then to traverse it in ccw orientation, * we always do left turns. However, if the face is not convex, we make both left and right turns. * * This computation ignores z-coordinates. * @param signedAreaTol optional signed area tolerance to use in test for parallel vectors. If `undefined`, a fraction * (`Geometry.smallMetricDistanceSquared`) of the computed signed area is used. Pass 0 to skip toleranced computation. * @returns true iff the sector is convex. A degenerate sector, where the incident edges overlap, returns false. */ isSectorConvex(signedAreaTol?: number): boolean; /** * Compute whether this face is convex. * * Note that if we have a convex face, then to traverse it in ccw orientation, we always do left turns. * However, if the face is not convex, we make both left and right turns. * * This computation ignores z-coordinates. * @param tolerance optional relative tolerance to use in test for parallel vectors. Default value is * `Geometry.smallMetricDistanceSquared`. Pass 0 to skip toleranced computation. * @returns true iff this face is convex. */ isFaceConvex(tolerance?: number): boolean; /** Isolate the edge from the graph by yanking each end from its vertex loop. */ isolateEdge(): void; /** * Specify whether this edge is isolated from the rest of the graph. * * Both edge mates of an isolated edge return true for [[isDangling]]. */ get isIsolatedEdge(): boolean; /** Return true if `this` is lexically below `other`. We compare y first, then x, and ignore z. */ belowYX(other: HalfEdge): boolean; /** Returns `true` if the node does NOT have `Mask.EXTERIOR_MASK` set. */ static testNodeMaskNotExterior(node: HalfEdge): boolean; /** Returns `true` if the edge mate has `Mask.EXTERIOR_MASK` set. */ static testMateMaskExterior(node: HalfEdge): boolean; /** * Returns radians between this edge and its face predecessor edge, using all three coordinates x,y,z and * given normal to resolve sweep direction. * * The returned angle is non-negative: 0 <= radians < 2*PI. */ static sectorSweepRadiansXYZ(node: HalfEdge, normal: Vector3d): number; /** Returns true if the face has positive area in xy parts. */ static testFacePositiveAreaXY(node: HalfEdge): boolean; /** Return true if x and y coordinates of `this` and `other` are exactly equal .*/ isEqualXY(other: XAndY | HalfEdge): boolean; /** Return distance between xy coordinates of `this` and `other` node. */ distanceXY(other: HalfEdge): number; /** Return distance between xyz coordinates of `this` and `other` node. */ distanceXYZ(other: HalfEdge): number; /** * Search around the instance's face loop for nodes with the specified mask value. * * Returned nodes satisfy `node.isMaskSet(mask) === value`. * @param mask target mask. * @param value target boolean value for mask on half edges (default `true`). * @param result optional array to be cleared, populated with masked nodes, and returned. * @return array of masked half edges */ collectMaskedEdgesAroundFace(mask: HalfEdgeMask, value?: boolean, result?: HalfEdge[]): HalfEdge[]; /** * Announce edges in the face loop, starting with the instance and proceeding in a `faceSuccessor` traversal. * @param announceEdge function to call at each edge */ announceEdgesInFace(announceEdge: HalfEdgeFunction): void; /** * Announce edges in the super face loop, starting with the instance. * * A super face admits a `faceSuccessor` traversal where the next edge at the far vertex is the first edge not skipped * in a `vertexPredecessor` traversal of the far vertex loop. * @param skipEdge mask preset on edges to skip, or a function that is called to decide whether to skip an edge. * @param announceEdge function that is called at each edge that is not skipped. Generally, it is best not to set a * visited mask in this callback if `skipEdge` checks this mask; instead, the caller should capture the announced edges * and set the visited mask on them after this method returns. * @param announceSkipped optional function that is called at each edge that is skipped. * @return whether a super face was found, or `false` if the traversal fails to return to the instance vertex. */ announceEdgesInSuperFace(skipEdge: HalfEdgeMask | HalfEdgeToBooleanFunction, announceEdge: HalfEdgeFunction, announceSkipped?: HalfEdgeFunction): boolean; /** * Evaluate `f(node)` at each node around `this` node's face loop. Collect the function values. * @param f optional node function. If `undefined`, collect the nodes themselves. * @returns the array of function values. */ collectAroundFace(f?: HalfEdgeFunction): any[]; /** * Search around `this` node's vertex loop for nodes with the specified mask value. * * Returned nodes satisfy `node.isMaskSet(mask) === value`. * @param mask target mask. * @param value target boolean value for mask on half edges. * @param result optional array to be cleared and receive masked nodes. */ collectMaskedEdgesAroundVertex(mask: HalfEdgeMask, value?: boolean, result?: HalfEdge[]): HalfEdge[]; /** * Evaluate `f(node)` at each node around `this` node's vertex loop. Collect the function values. * @param f optional node function. If `undefined`, collect the nodes themselves. * @returns the array of function values. */ collectAroundVertex(f?: HalfEdgeFunction): any[]; /** * Announce edges in the vertex loop, starting with the instance and proceeding in a `vertexSuccessor` traversal. * @param announceEdge function to call at each edge */ announceEdgesAroundVertex(announceEdge: HalfEdgeFunction): void; /** * Evaluate `f(node)` at each node around `this` node's face loop. Sum the function values. * @param f node to number function. * @returns the sum of function values. */ sumAroundFace(f: HalfEdgeToNumberFunction): number; /** * Evaluate `f(node)` at each node around `this` node's vertex loop. Sum the function values. * @param f node to number function. * @returns the sum of function values. */ sumAroundVertex(f: HalfEdgeToNumberFunction): number; /** Clear the given mask bits for all nodes in `this` node's face loop. */ clearMaskAroundFace(mask: HalfEdgeMask): void; /** Clear out the given mask bits for all nodes in `this` node's vertex loop. */ clearMaskAroundVertex(mask: HalfEdgeMask): void; /** * Compute the signed xy area of `this` node's face. * * A positive area is counterclockwise. * * A negative area is clockwise. * @returns signed area of `this` node's face. */ signedFaceArea(): number; /** * Interpolate xy coordinates between `this` node and its face successor. * @param fraction fractional position along this edge. * @param result optional point to populate and return. */ fractionToPoint2d(fraction: number, result?: Point2d): Point2d; /** * Interpolate xyz coordinates between `this` node and its face successor. * @param fraction fractional position along this edge. * @param result optional point to populate and return. */ fractionToPoint3d(fraction: number, result?: Point3d): Point3d; /** * Interpolate xy coordinates at `fractionAlong` between this node and its face successor. Then shift perpendicular * to the left of this edge by `fractionPerpendicular`. * @param fractionAlong fractional position along this edge. * @param fractionPerpendicular fractional position along the left perpendicular with the same length as this edge. * @param result optional xy coordinates. */ fractionAlongAndPerpendicularToPoint2d(fractionAlong: number, fractionPerpendicular: number, result?: Point2d): Point2d; /** Return the 3d coordinates at this half edge. */ getPoint3d(result?: Point3d): Point3d; /** Return the 2d coordinates at this half edge. */ getPoint2d(result?: Point2d): Point2d; /** Return a 3d vector from start to end of this half edge. */ getVector3dAlongEdge(result?: Vector3d): Vector3d; /** Return a 2d vector from start to end of this half edge. */ getVector2dAlongEdge(result?: Vector2d): Vector2d; /** * Return the interpolated x coordinate between `this` node and its face successor. * @param fraction fractional position along this edge. */ fractionToX(fraction: number): number; /** * Return the interpolated y coordinate between `this` node and its face successor. * @param fraction fractional position along this edge. */ fractionToY(fraction: number): number; /** * Return the interpolated z coordinate between `this` node and its face successor. * @param fraction fractional position along this edge. */ fractionToZ(fraction: number): number; /** * Compute fractional coordinates of the intersection of edges from given base nodes. * * If parallel or colinear, return `undefined`. * * If (possibly extended) lines intersect, return the fractions of intersection as x,y in the result. * @param nodeA0 base node of edge A. * @param nodeB0 base node of edge B. * @param result optional preallocated result. */ static transverseIntersectionFractions(nodeA0: HalfEdge, nodeB0: HalfEdge, result?: Vector2d): Vector2d | undefined; /** * Compute fractional position (possibly outside 0..1) of the intersection of a horizontal line with an edge. * * If the edge is horizontal with (approximate) identical y, return the base node. * * If the edge is horizontal with different y, return `undefined`. * @param node0 base node of edge. * @param y y coordinate of the horizontal line. */ static horizontalScanFraction(node0: HalfEdge, y: number): number | undefined | HalfEdge; /** * Compute fractional position (inside 0..1) of the intersection of a horizontal line with an edge. * * If fractional position is outside 0..1, return `undefined`. * * If the edge is horizontal return `undefined` (no test for horizontal at y). * @param node0 base node of edge. * @param y y coordinate of the horizontal line. */ static horizontalScanFraction01(node0: HalfEdge, y: number): number | undefined; /** * Copy various data from source to `this`. * @param source source half edge. * @param copyXYZ true to copy xyz coordinates. * @param copyVertexData true to copy data belonging to the vertex (i.e. the `i` member). * @param copyEdgeData true to copy data belonging to the edge (i.e. edge masks, `edgeTag`). * @param copyFaceData true to copy `faceTag`. */ copyDataFrom(source: HalfEdge, copyXYZ: boolean, copyVertexData: boolean, copyEdgeData: boolean, copyFaceData: boolean): void; /** * Is the instance's face loop a split-washer type face? * * A split-washer face contains at least one bridge edge. * * A bridge edge and its edge mate have the same `bridgeMask` and live in the same face loop. * * By connecting hole/outer loops with bridge edges, a split-washer face can represent a parity region. * @param bridgeMask mask preset on bridge edges (default is [[HalfEdgeMask.BRIDGE_EDGE]]). */ isSplitWasherFace(bridgeMask?: HalfEdgeMask): boolean; } /** * A HalfEdgeGraph has: * * An array of (pointers to) HalfEdge objects. * * A pool of masks for grab/drop used by algorithms. * @internal */ export declare class HalfEdgeGraph { /** Simple array with pointers to all the half edges in the graph. */ allHalfEdges: HalfEdge[]; private _maskManager; constructor(); /** * Ask for a mask (from the graph's free pool) for caller's use. * @param clearInAllHalfEdges optionally clear the mask throughout the graph (default `true`). */ grabMask(clearInAllHalfEdges?: boolean): HalfEdgeMask; /** Return `mask` to the free pool. */ dropMask(mask: HalfEdgeMask): void; /** Whether there is a mask available to grab. */ get hasFreeMask(): boolean; /** * Create 2 half edges forming 2 vertices, 1 edge, and 1 face. * * The two half edges are joined as edgeMate pair. * * The two half edges are a 2-half-edge face loop in both the faceSuccessor and facePredecessor directions. * * The two half edges are added to the graph's HalfEdge set. * @returns pointer to the first half edge created. */ createEdgeXYZXYZ(xA?: number, yA?: number, zA?: number, iA?: number, xB?: number, yB?: number, zB?: number, iB?: number): HalfEdge; /** * Create 2 half edges forming 2 vertices, 1 edge, and 1 face. * * The two half edges are joined as edgeMate pair. * * The two half edges are a 2-half-edge face loop in both the faceSuccessor and facePredecessor directions. * * The two half edges are added to the graph's HalfEdge set. * * Coordinates are set to zero. * @param iA `i` property of the first created HalfEdge * @param iB `i` property of the second created HalfEdge * @returns pointer to the first half edge created, with `i` property set to iA. */ createEdgeIdId(iA?: number, iB?: number): HalfEdge; /** * Create an edge from coordinates x,y,z connected to the graph at the vertex of the given `node`. * @returns pointer to the dangling node at x,y,z. */ createEdgeXYZHalfEdge(xA: number | undefined, yA: number | undefined, zA: number | undefined, iA: number | undefined, node: HalfEdge, iB?: number): HalfEdge; /** * Create an edge from the vertex of `nodeA` to the vertex of `nodeB`. * @returns pointer to the new half edge at the vertex of `nodeA`. */ createEdgeHalfEdgeHalfEdge(nodeA: HalfEdge, idA: number, nodeB: HalfEdge, idB?: number): HalfEdge; /** * Create 2 half edges forming 2 vertices, 1 edge, and 1 face * * The two half edges are joined as edgeMate pair. * * The two half edges are a 2-half-edge face loop in both the faceSuccessor and facePredecessor directions. * * The two half edges are added to the graph's HalfEdge set. * @returns pointer to the first half edge created, with coordinates `xyz0`. */ createEdgeXYAndZ(xyz0: XYAndZ, id0: number, xyz1: XYAndZ, id1: number): HalfEdge; /** * Create a new vertex within the edge beginning at `base`. * * This creates two new nodes in their own vertex loop. * * If the base is `undefined`, create a single-edge loop. * * Existing nodes stay in their face and vertex loops and retain xyz and i values. * * Unlike [[pinch]], this breaks the edgeMate pairing of the input edge: * each node of the input edge gets a new node as its edge mate. * * On each side of the edge, if edgeTag is present, it is copied to the new node on that side. * @returns reference to the half edge created, the new face successor of `base`. */ splitEdge(base: undefined | HalfEdge, xA?: number, yA?: number, zA?: number, iA?: number): HalfEdge; /** * Create a new sliver face "inside" an existing edge. * * This creates two nodes that are each face predecessor and successor to the other. * * Existing nodes stay in their face and vertex loops and retain xyz and i values. * * Unlike [[pinch]], this breaks the edgeMate pairing of the input edge: * each node of the input edge gets a new node as its edge mate. * * New nodes get the xyz and i values shared by the nodes in the vertex loops into which they are placed. * * New nodes' faceTag and edgeTag are `undefined`. * @returns reference to the half edge created in the vertex loop of baseA. */ splitEdgeCreateSliverFace(base: HalfEdge): HalfEdge; /** * Create a new vertex within the edge beginning at `base`, with coordinates specified by a fraction along the edge. * * This creates two new nodes in their own vertex loop. * * Existing nodes stay in their face and vertex loops and retain xyz and i values. * * Unlike [[pinch]], this breaks the edgeMate pairing of the input edge: * each node of the input edge gets a new node as its edge mate. * * On each side of the edge, if edgeTag is present, it is copied to the new node on that side. * @returns reference to the half edge created, the new face successor of `base`. */ splitEdgeAtFraction(base: HalfEdge, fraction: number): HalfEdge; /** * This is a destructor-like action that eliminates all inter-connections among the graph's nodes. * After this is called, the graph is unusable. */ decommission(): void; /** * Create two nodes of a new edge. * @param x0 x-coordinate of the start node. * @param y0 y-coordinate of the start node. * @param x1 x-coordinate of the end node. * @param y1 y-coordinate of the end node. * @param edgeTag0 (optional) edge tag for the start node. * @param edgeTag1 (optional) edge tag for the end node. * @param faceTag0 (optional) face tag for the start node. * @param faceTag1 (optional) face tag for the end node. * @returns the reference to the new node at (x0,y0). */ addEdgeXY(x0: number, y0: number, x1: number, y1: number, edgeTag0?: number, edgeTag1?: number, faceTag0?: number, faceTag1?: number): HalfEdge; /** Clear selected `mask` bits in all nodes of the graph. */ clearMask(mask: HalfEdgeMask): void; /** Set selected `mask` bits in all nodes of the graph. */ setMask(mask: HalfEdgeMask): void; /** Toggle selected `mask` bits in all nodes of the graph. */ reverseMask(mask: HalfEdgeMask): void; /** * Return the number of nodes that have a specified mask bit set. * @param mask mask to count */ countMask(mask: HalfEdgeMask): number; /** * Return an array of LineSegment3d. * * The array has one segment per edge. * * The coordinates are taken from a node and its face successor. * * On each edge, the line segment starts at the HalfEdge with lower ID than its edgeMate. */ collectSegments(): LineSegment3d[]; /** Returns the number of vertex loops in a graph structure. */ countVertexLoops(): number; /** Returns the number of face loops in a graph structure. */ countFaceLoops(): number; /** Returns the number of face loops satisfying a filter function with mask argument. */ countFaceLoopsWithMaskFilter(filter: HalfEdgeAndMaskToBooleanFunction, mask: HalfEdgeMask): number; /** Returns an array of nodes, where each node represents a starting point of a vertex loop. */ collectVertexLoops(): HalfEdge[]; /** Returns an array of nodes, where each node represents a starting point of a face loop. */ collectFaceLoops(): HalfEdge[]; /** * Visit each vertex loop of the graph once. * * Call the `announceVertex` function. * * Continue search if `announceVertex(graph, node)` returns `true`. * * Terminate search if `announceVertex(graph, node)` returns `false`. * @param announceVertex function to apply at one node of each vertex. */ announceVertexLoops(announceVertex: GraphHalfEdgeFunction): void; /** * Visit each facet of the graph once. * * Call the `announceFace` function. * * Continue search if `announceFace(graph, node)` returns `true`. * * Terminate search if `announceFace(graph, node)` returns `false`. * @param announceFace function to apply at one node of each face. */ announceFaceLoops(announceFace: GraphHalfEdgeFunction): void; /** * Visit each edge of the graph once. * * Call the `announceEdge` function. * * The edge mate will NOT appear in an announceEdge call. * * Continue search if `announceEdge(graph, node)` returns `true`. * * Terminate search if `announceEdge(graph, node)` returns `false`. * @param announceEdge function to apply at one node of each edge. */ announceEdges(announceEdge: GraphHalfEdgeFunction): void; /** * Visit each half edge (node) of the graph once. * * Call the `announceNode` function. * * Continue search if `announceNode(graph, node)` returns `true`. * * Terminate search if `announceNode(graph, node)` returns `false`. * @param announceNode function to apply at each node. */ announceNodes(announceNode: GraphHalfEdgeFunction): void; /** Return the number of nodes in the graph. */ countNodes(): number; /** Apply transform to the xyz coordinates in the graph. */ transformInPlace(transform: Transform): void; /** * Disconnect and delete all nodes that satisfy a filter condition. * @param deleteThisNode returns true to delete the corresponding node. Should act symmetrically on the edgeMate. * @returns the number of nodes deleted (twice the number of deleted edges). */ yankAndDeleteEdges(deleteThisNode: HalfEdgeFunction): number; /** * Delete all isolated edges. * @return the number of nodes deleted (twice the number of deleted edges). */ deleteIsolatedEdges(): number; /** * Construct a map from id to vertex index. * * For a given HalfEdge `e`, the key is `e.id` and the value is the minimum index in `graph.allHalfEdges` of all edges in the vertex loop of `e`. */ constructIdToVertexIndexMap(): Map; /** * Construct a map from id to face index. * * For a given HalfEdge `e`, the key is `e.id` and the value is the minimum index in `graph.allHalfEdges` of all edges in the face loop of `e`. */ constructIdToFaceIndexMap(): Map; } //# sourceMappingURL=Graph.d.ts.map