import { LineStringDataVariant, MultiLineStringDataVariant } from "../geometry3d/IndexedXYZCollection"; import { Point3d } from "../geometry3d/Point3dVector3d"; import { HalfEdge, HalfEdgeGraph, HalfEdgeMask } from "./Graph"; import { MarkedEdgeSet } from "./HalfEdgeMarkSet"; import { InsertedVertexZOptions } from "./InsertAndRetriangulateContext"; /** * Static methods for triangulating polygons and points. * * Tolerances and tolerance usage are currently inconsistent, and not exposed to callers. * * @internal */ export declare class Triangulator { /** Given the six nodes that make up two bordering triangles, "pinch" and relocate the nodes to flip them * * The shared edge mates are c and e. * * (abc) are a triangle in CCW order * * (dfe) are a triangle in CCW order. (Note: dfe instead of def!!) */ private static flipEdgeBetweenTriangles; /** * Given a node in triangle A on the edge shared by triangle B, test whether the far vertex of B lies inside the circumcircle of A. * @param nodeA node on the shared edge between triangles A and B. * @return The following are equivalent: * * return true * * the computed determinant is strongly positive (greater than epsilon) * * the far vertex of B lies strictly inside the circumcircle of A * * the quad AB fails the Delaunay condition * * the quad CD obtained from AB by switching to the other diagonal satisfies the Delaunay condition * * to satisfy Delaunay, the caller should flip the diagonal of AB (obtaining CD) */ static computeCircumcircleDeterminantIsStrongPositive(nodeA: HalfEdge): boolean; /** * * Visit each node of the graph array * * If a flip would be possible, test the results of flipping using circumcircle condition * * If revealed to be an improvement, conduct the flip, mark involved nodes as unvisited, and repeat until all nodes are visited. * * @returns number of edges flipped. */ static flipTriangles(graph: HalfEdgeGraph): number; /** * * Visit each node of the graph array * * If a flip would be possible, test the results of flipping using circumcircle condition * * If revealed to be an improvement, conduct the flip, mark involved nodes as unvisited, and repeat until all nodes are visited */ static flipTrianglesInEdgeSet(graph: HalfEdgeGraph, edgeSet: MarkedEdgeSet): number; /** * Create a graph from an xy-triangulation of the given points. The triangulation is Delaunay. * * The outer boundary of the graph is the xy-convex hull of the points; it is marked `HalfEdgeMask.EXTERIOR`. * @param points the points to triangulate. * @param zRule optional rule for updating the z-coordinate of an existing vertex when an xy-duplicate point is * inserted into the graph. Default is `InsertedVertexZOptions.ReplaceIfLarger`. * @param pointTolerance optional xy-distance tolerance for equating vertices. Default is `Geometry.smallMetricDistance`. */ static createTriangulatedGraphFromPoints(points: Point3d[], zRule?: InsertedVertexZOptions, pointTolerance?: number): HalfEdgeGraph | undefined; /** * * Only one outer loop permitted. * * Largest area loop is assumed outer. * @param loops an array of loops * @returns triangulated graph, or undefined if bad data. */ static createTriangulatedGraphFromLoops(loops: LineStringDataVariant[]): HalfEdgeGraph | undefined; /** * Triangulate all positive area faces of a (planar) graph. * * Area is computed using `HalfEdge.signedFaceArea`, which ignores z-coordinates. * @returns whether all indicated faces were triangulated successfully * @see [[triangulateAllInteriorFaces]] */ static triangulateAllPositiveAreaFaces(graph: HalfEdgeGraph): boolean; private static _workTransform?; /** * Triangulate all interior faces of a graph. * * A random node is checked for each face; if it has the `HalfEdgeMask.EXTERIOR` mask, the face is ignored. * @param useLocalCoords whether to transform each face into local coords before triangulating. * This is useful if the graph has z-coordinates. * @param noFlips if false (default) perform edge-flipping after each ear cut for better aspect ratio. * Ignored if `useLocalCoords` is true, in which case flipping is not performed to avoid out-of-plane effects. * @returns whether all indicated faces were triangulated successfully * @see [[triangulateAllPositiveAreaFaces]] */ static triangulateAllInteriorFaces(graph: HalfEdgeGraph, useLocalCoords?: boolean, noFlips?: boolean): boolean; /** * Triangulate the polygon made up of by a series of points. The triangulation is Delaunay. * * The loop may be either CCW or CW -- CCW order will be used for triangles. * * To triangulate a polygon with holes, use createTriangulatedGraphFromLoops. */ static createTriangulatedGraphFromSingleLoop(data: LineStringDataVariant): HalfEdgeGraph | undefined; /** * cautiously split the edge starting at baseNode. * * If baseNode is null, create a trivial loop with the single vertex at xy * * if xy is distinct from the coordinates at both baseNode and its successor, insert xy as a new node within that edge. * * also include z coordinate if present. */ private static interiorEdgeSplit; /** Return length of data without wraparound point(s), if present */ private static getUnwrappedLength; /** Create a loop from coordinates. * * Return a pointer to any node on the loop. * * no masking or other markup is applied. */ static directCreateFaceLoopFromCoordinates(graph: HalfEdgeGraph, data: LineStringDataVariant): HalfEdge | undefined; /** Create chains from coordinates. * * Return array of pointers to base node of the chains. * * no masking or other markup is applied (save id). * @param graph New edges are built in this graph * @param data coordinate data * @param id id to attach to (both side of all) edges */ static directCreateChainsFromCoordinates(graph: HalfEdgeGraph, data: MultiLineStringDataVariant, id?: number): HalfEdge[]; /** * @param graph the containing graph * @param base The last node of a newly created loop. (i.e. its `faceSuccessor` has the start xy) * @param returnPositiveAreaLoop if true, return the start node on the side with positive area. otherwise return the left side as given. * @param maskForBothSides mask to apply on both sides. * @param maskForOtherSide mask to apply to the "other" side of the loop. * @return the loop's start node or its vertex successor, chosen to be the positive or negative loop per request. */ private static maskAndOrientNewFaceLoop; /** * Create a circular doubly linked list of internal and external nodes from polygon points in the specified winding order. * * This applies the masks used by typical applications: * * HalfEdgeMask.BOUNDARY on both sides. * * HalfEdgeMask.PRIMARY_EDGE on both sides. * * Use [[createFaceLoopFromCoordinatesAndMasks]] for detailed control of masks. */ static createFaceLoopFromCoordinates(graph: HalfEdgeGraph, data: LineStringDataVariant, returnPositiveAreaLoop: boolean, markExterior: boolean): HalfEdge | undefined; /** * create a circular doubly linked list of internal and external nodes from polygon points. * * Optionally jump to the "other" side so the returned loop has positive area * @param graph graph to receive the new edges * @param data array with x,y coordinates * @param returnPositiveAreaLoop if false, return an edge proceeding around the loop in the order given. If true, compute the loop area and flip return the side with positive area. * @param maskForBothSides mask to apply on both sides. * @param maskForOtherSide mask to apply on the "other" side from the returned loop. */ static createFaceLoopFromCoordinatesAndMasks(graph: HalfEdgeGraph, data: LineStringDataVariant, returnPositiveAreaLoop: boolean, maskForBothSides: HalfEdgeMask, maskForOtherSide: HalfEdgeMask): HalfEdge | undefined; /** Cut off an ear, forming a new face loop of nodes * @param ear the vertex being cut off. * * Form two new nodes, alpha and beta, which have the coordinates one step away from the ear vertex. * * Reassigns the pointers such that beta is left behind with the new face created * * Reassigns the pointers such that alpha becomes the resulting missing node from the remaining polygon * * Reassigns prevZ and nextZ pointers */ private static joinNeighborsOfEar; private static isInteriorTriangle; /** * Perform 0, 1, or more edge flips to improve aspect ratio just behind an ear that was just cut. * @param ear the triangle corner which just served as the ear node. * @returns the node at the back corner after flipping, "appropriately positioned" for the usual advance to `ear.faceSuccessor.edgeMate.faceSuccessor`. */ private static doPostCutFlips; /** * Main ear slicing loop which triangulates the face starting at `ear`. * @param graph containing graph to receive new edges * @param ear sector at which to start triangulation of the containing face. * @param noFlips if false (default) perform edge-flipping after each ear cut for better aspect ratio. * Pass true if your graph isn't planar; otherwise, an edge can be flipped out of plane if the neighboring triangle is non-coplanar. */ private static triangulateSingleFace; /** @internal */ private static sDebugGraph; /** @internal */ private static sEnableDebugGraphCapture; /** * * returns the (possibly undefined) debug graph. * * sets the debug graph to undefined. * * disables subsequent saving. * @internal */ static claimDebugGraph(): HalfEdgeGraph | undefined; /** Call (from within the triangulator) to announce a graph to be saved for debug. * * If debug graph capture is not enabled, do nothing. * * If debug graph capture is enabled, save this graph. * * This is called by internal steps at point of failure to preserve the failing graph for unit test examination. * @internal */ static setDebugGraph(graph: HalfEdgeGraph | undefined): void; /** * * Clear the debug graph * * Set capture enabled to indicated value. * * Intended use: * * By default "enabled" is false so there is no activity in the debug graph. * * A unit test which needs to see graph after failure calls clearAndEnableDebugGraphCapture (true) * * run the triangulation step * * call claimDebugGraph. * * claimDebugGraph reverts everything to default no-capture state. * @internal */ static clearAndEnableDebugGraphCapture(value: boolean): void; /** * Whether a and b are in same vertex loop, or at the same xy location. * @internal */ private static findAroundOrAtVertex; private static _edgeInterval; private static _earRange; private static _edgeRange; private static _planes; /** Check whether a polygon node forms a valid ear with adjacent nodes */ private static isEar; /** link holeLoopNodes[1], holeLoopNodes[2] etc into the outer loop, producing a single-ring polygon without holes * */ private static spliceLeftMostNodesOfHoles; /** For use in sorting -- return (signed) difference (a.x - b.x) */ private static compareX; /** find a bridge between vertices that connects hole with an outer ring and and link it */ private static eliminateHole; /** * David Eberly algorithm for finding a bridge between hole and outer polygon: * https://www.geometrictools.com/Documentation/TriangulationByEarClipping.pdf */ private static findHoleBridge; private static getLeftmost; /** * Check if a point lies within or on a triangle. * * In other words, the areas of the 3 triangles formed by an edge of abc and p all have zero or positive area. */ private static pointInTriangle; /** Check if node p lies strictly inside the triangle abc. */ private static nodeInTriangle; /** signed area of a triangle * EDL 2/21 This is negative of usual CCW area. Beware in callers !!! * (This originates in classic earcut code.) */ private static signedCWTriangleArea; /** signed area of a triangle, with small positive corrected to zero by relTol */ private static signedTolerancedCCWTriangleArea; /** check if two points are equal */ private static isAlmostEqualXAndYXY; /** check if a b is inside the sector around a */ private static locallyInside; /** * link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; * if one belongs to the outer ring and another to a hole, it merges it into a single ring * * Returns the base of the new edge at the "a" end. * * "a" and "b" still represent the same physical pieces of edges * @returns Returns the (base of) the new half edge, at the "a" end. */ private static splitFace; /** * Triangulate a single face with (linear time) logic applicable only if the lowNode is the lowest node. * @returns false if any monotonicity condition is violated. */ static triangulateSingleMonotoneFace(graph: HalfEdgeGraph, start: HalfEdge): boolean; } //# sourceMappingURL=Triangulation.d.ts.map