import { HalfEdge, HalfEdgeGraph, HalfEdgeMask, HalfEdgeToBooleanFunction, HalfEdgeToNumberFunction } from "./Graph"; import { SignedDataSummary } from "./SignedDataSummary"; /** * Interface for an object that executes boolean tests on edges. * @internal */ export interface HalfEdgeTestObject { testEdge(h: HalfEdge): boolean; } /** * Class to test match of half edge mask. * @internal */ export declare class HalfEdgeMaskTester { private _targetMask; private _targetValue; /** * Constructor * @param mask mask to test in `testEdge` function * @param targetValue value to match for true return */ constructor(mask: HalfEdgeMask, targetValue?: boolean); /** Return true if the value of the targetMask matches the targetValue. */ testEdge(edge: HalfEdge): boolean; } /** * Class for different types of searches for HalfEdgeGraph. * @internal */ export declare class HalfEdgeGraphSearch { /** * Static method for face area computation -- useful as function parameter in `collectFaceAreaSummary`. * * This simply calls `node.signedFaceArea()` * @param node instance for signedFaceArea call. */ static signedFaceArea(node: HalfEdge): number; /** * Return a summary of face data (e.g., area) as computed by the callback on the faces of the graph. * * Callers with curved edge graphs must supply their own area function. * @param source graph or array of nodes to examine. * @param collectAllNodes flag to pass to the `SignedDataSummary` constructor to control collection of nodes. * @param areaFunction function to obtain area (or other numeric value). Default computes polygonal face area. */ static collectFaceAreaSummary(source: HalfEdgeGraph | HalfEdge[], collectAllNodes?: boolean, areaFunction?: HalfEdgeToNumberFunction): SignedDataSummary; /** * Search the graph for the face with the most negative area. * * If the graph has exactly one connected component, this is its outer face. * @param oneCandidateNodePerFace graph or an array containing one node from each face to be considered. * @returns node on the negative area face with largest absolute area, or `undefined` if no negative area face. */ static findMinimumAreaFace(oneCandidateNodePerFace: HalfEdgeGraph | HalfEdge[], faceAreaFunction?: HalfEdgeToNumberFunction): HalfEdge | undefined; /** * Test if the graph is triangulated. * * Return `false` if: * * number of positive area faces with more than 3 edges is larger than `numPositiveExceptionsAllowed`. * * graph has more than 1 negative area face when `allowMultipleNegativeAreaFaces` is `false`. * * 2-edge faces are ignored. */ static isTriangulatedCCW(source: HalfEdgeGraph | HalfEdge[], allowMultipleNegativeAreaFaces?: boolean, numPositiveExceptionsAllowed?: number): boolean; /** * Process a face during graph traversal. * @param faceSeed a node in the face. * @param mask mask to set on each node of the face. * @param allNodeStack array appended with each node of the face. * @param onePerFaceStack array appended with `faceSeed`. */ private static pushAndMaskAllNodesInFace; /** * Traverse (via Depth First Search) to all accessible faces from the given seed. * @param faceSeed first node to start the traverse. * @param visitMask mask applied to all faces as visited. * @param parityEdgeTester function to test if an edge is adjacent to two faces of opposite parity, e.g., a boundary * edge that separates an "interior" face and an "exterior" face. If `parityEdgeTester` is not supplied and `parityMask` * is supplied, the default parity rule is to alternate parity state in a "bullseye" pattern starting at the seed face, * with each successive concentric ring of faces at constant topological distance from the seed face receiving the * opposite parity state of the previous ring. * @param parityMask mask to apply to the first face and faces that share the same parity as the first face, as * determined by the parity rule. If this is `NULL_MASK`, there is no record of parity. If (non-null) parity mask * is given, on return it is entirely set or entirely clear around each face. * @returns an array that contains one representative node in each face of the connected component. */ private static parityFloodFromSeed; /** * * Correct the parity mask in the faces of a component. * * It is assumed that the parity mask is applied _consistently_ throughout the supplied faces, but maybe * not _correctly_. * * A consistently applied parity mask is "correct" if it is set on the negative area ("exterior") face of * a connected component. * * This method finds a face with negative area and toggles the mask throughout the input faces if this face * lacks the parity mask. * * In a properly merged planar subdivision there should be only one true negative area face per component. */ private static correctParityInSingleComponent; /** Apply `correctParityInSingleComponent` to each array in components (quick exit if `parityMask` is `NULL_MASK`). */ private static correctParityInComponentArrays; /** * Collect connected components of the graph (via Depth First Search). * @param graph graph to inspect. * @param parityEdgeTester (optional) function to test if an edge is adjacent to two faces of opposite parity, * e.g., a boundary edge that separates an "interior" face and an "exterior" face. If `parityEdgeTester` is not * supplied and `parityMask` is supplied, the default parity rule is to alternate parity state in a "bullseye" * pattern starting at the seed face, with each successive concentric ring of faces at constant topological * distance from the seed face receiving the opposite parity state of the previous ring. * @param parityMask (optional) mask to apply to the first face and faces that share the same parity as the * first face, as determined by the parity rule. If this is `NULL_MASK` (default), there is no record of parity. * If (non-null) parity mask is given, on return it is entirely set or entirely clear around each face. * @returns the components of the graph, each component represented by an array of nodes, one node per face * of the component. In other words, entry [i][j] is a HalfEdge in the j_th face loop of the i_th component. */ static collectConnectedComponentsWithExteriorParityMasks(graph: HalfEdgeGraph, parityEdgeTester: HalfEdgeTestObject | undefined, parityMask?: HalfEdgeMask): HalfEdge[][]; /** * Breadth-first search through the connected component defined by `seed` and `ignoreMask`. * @param seed a HalfEdge in the component from which to start the search. * @param visitMask a mask to apply to visited nodes. Assumed cleared throughout component before first call. * @param ignoreMask (optional) mask preset on faces that are to be treated as _outside_ the component. * Default value is `HalfEdgeMask.EXTERIOR` to ignore exterior faces. * Pass `HalfEdgeMask.NULL_MASK` to process all faces of the component. * Note that if `ignoreMask` is set on both sides of an edge, both adjacent faces will be ignored; thus it * is generally more useful if set on only one side of an edge. * @param maxFaceCount (optional) maximum number of faces to search in the component. If nonpositive or * `undefined`, `Infinity` is used. * @param result optional array to append with HalfEdges and return as the `faces` array. This array is not * emptied first, so callers can send it into a subsequent call to continue searching the component at `nextSeed`. * @returns `faces` consists of one edge per face of the component; `nextSeed` is the seed at which to start * the next call if `maxFaceCount` is exceeded (otherwise it is `undefined`). */ static exploreComponent(seed: HalfEdge, visitMask: HalfEdgeMask, ignoreMask?: HalfEdgeMask, maxFaceCount?: number, result?: HalfEdge[]): { faces: HalfEdge[]; nextSeed: HalfEdge | undefined; }; /** * Collect connected components of the graph (via Breadth First Search). * @param graph graph to inspect. * @param maxFaceCount (optional) maximum number of faces in each component. Should be positive; otherwise * `Infinity` is used. * @param ignoreMask (optional) mask preset on faces to ignore. Default value is `HalfEdgeMask.EXTERIOR` to ignore * exterior faces. Pass `HalfEdgeMask.NULL_MASK` to process all faces. * @returns the components of the graph, each component represented by an array of nodes, one node per face * of the component. In other words, entry [i][j] is a HalfEdge in the j_th face loop of the i_th component. */ static collectConnectedComponents(graph: HalfEdgeGraph, maxFaceCount?: number, ignoreMask?: HalfEdgeMask): HalfEdge[][]; /** * Test if test point (xTest,yTest) is inside/outside a face or on an edge. * * NOTE: a point outside the graph (in the exterior face) returns -1. * @param seedNode any node on the face loop. * @param xTest x coordinate of the test point. * @param yTest y coordinate of the test point. * @returns 0 if ON, 1 if IN, -1 if OUT. */ static pointInOrOnFaceXY(seedNode: HalfEdge, xTest: number, yTest: number): number; /** * Collect boundary edges starting from `seed`. * * If `seed` is not a boundary node or is already visited, the function exists early. * @param seed start node. * @param visitMask mask to set on processed nodes. * @param isBoundaryEdge function to test if an edge in a boundary edge. * @param announceEdgeInBoundary callback invoked on each edge in the boundary loop in order. The counter is zero * for the first edge, and incremented with each successive edge. */ static collectExtendedBoundaryLoopFromSeed(seed: HalfEdge, visitMask: HalfEdgeMask, isBoundaryEdge: HalfEdgeToBooleanFunction, announceEdgeInBoundary: (edge: HalfEdge, counter: number) => void): void; /** * Collect boundary edges in the graph. * * A boundary edge is defined by `exteriorMask` being set on only its "exterior" edge mate. * * Each boundary edge is identified in the output by its edge mate that lacks `exteriorMask`. * * Each inner array is ordered in the output so that its boundary edges form a connected path. If `exteriorMask` * is preset consistently around each "exterior" face, these paths are loops. * @param graph the graph to query * @param exteriorMask mask preset on exactly one side of boundary edges * @returns array of boundary loops, each loop an array of the unmasked mates of boundary edges */ static collectExtendedBoundaryLoopsInGraph(graph: HalfEdgeGraph, exteriorMask: HalfEdgeMask): HalfEdge[][]; } //# sourceMappingURL=HalfEdgeGraphSearch.d.ts.map