@itwin/core-geometry 3.4.0-dev.55 → 3.4.0-dev.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.js +16 -4
- package/lib/cjs/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.d.ts +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
- package/lib/cjs/numerics/ClusterableArray.d.ts +4 -4
- package/lib/cjs/numerics/ClusterableArray.js +5 -5
- package/lib/cjs/numerics/ClusterableArray.js.map +1 -1
- package/lib/cjs/topology/Graph.d.ts +3 -3
- package/lib/cjs/topology/Graph.d.ts.map +1 -1
- package/lib/cjs/topology/Graph.js +2 -2
- package/lib/cjs/topology/Graph.js.map +1 -1
- package/lib/cjs/topology/Merging.d.ts +5 -1
- package/lib/cjs/topology/Merging.d.ts.map +1 -1
- package/lib/cjs/topology/Merging.js +27 -15
- package/lib/cjs/topology/Merging.js.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.js +16 -4
- package/lib/esm/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.d.ts +1 -1
- package/lib/esm/geometry3d/AngleSweep.js +1 -1
- package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
- package/lib/esm/numerics/ClusterableArray.d.ts +4 -4
- package/lib/esm/numerics/ClusterableArray.js +5 -5
- package/lib/esm/numerics/ClusterableArray.js.map +1 -1
- package/lib/esm/topology/Graph.d.ts +3 -3
- package/lib/esm/topology/Graph.d.ts.map +1 -1
- package/lib/esm/topology/Graph.js +2 -2
- package/lib/esm/topology/Graph.js.map +1 -1
- package/lib/esm/topology/Merging.d.ts +5 -1
- package/lib/esm/topology/Merging.d.ts.map +1 -1
- package/lib/esm/topology/Merging.js +27 -15
- package/lib/esm/topology/Merging.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Merging.js","sourceRoot":"","sources":["../../../src/topology/Merging.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAQ/F,0CAAuC;AACvC,+CAA4C;AAC5C,mEAAkE;AAClE,+CAA8C;AAC9C,mEAAgE;AAChE,yDAAsD;AACtD,mCAAgE;AAChE,mEAAgF;AAChF,qDAAyD;AACzD,mDAA2E;AAE3E,MAAa,cAAc;IAOzB;QANO,cAAS,GAAG,CAAC,CAAC;QACd,wBAAmB,GAAG,CAAC,CAAC;QACxB,aAAQ,GAAG,CAAC,CAAC;QACb,cAAS,GAAG,CAAC,CAAC;QACd,YAAO,GAAG,CAAC,CAAC;QACZ,YAAO,GAAG,CAAC,CAAC;IAEnB,CAAC;CACF;AATD,wCASC;AACD;;GAEG;AACH,MAAa,0BAA0B;IAKrC,YAAmB,KAAa,EAAE,GAAW,EAAE,IAAc,EAAE,OAAgB;QAC7E,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,iBAAiB,GAAG,GAAG,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAXD,gEAWC;AAID;;;GAGG;AACH,MAAa,gBAAgB;IAE3B,iFAAiF;IAC1E,MAAM,CAAC,gBAAgB,CAAC,CAAW,EAAE,CAAW;QACrD,YAAY;QACZ,4CAA4C;QAC5C,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACX,OAAO,CAAC,CAAC,CAAC;aACP,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAChB,OAAO,CAAC,CAAC;QACX,YAAY;QACZ,4CAA4C;QAC5C,IAAI,CAAC,CAA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MAAM,CAAC,CAAC;QACjF,KAAK,MAAM,IAAI,IAAI,UAAU;YAC3B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAE/B,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,UAAU,EAAE;YACd,MAAM,OAAO,GAAG,IAAI,sCAAqB,CAAC,KAAK,CAAC,CAAC;YACjD,OAAO,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACrC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CAEF;AA3UD,gDA2UC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Topology\n */\n\nimport { CurveLocationDetail } from \"../curve/CurveLocationDetail\";\nimport { LineSegment3d } from \"../curve/LineSegment3d\";\nimport { Geometry } from \"../Geometry\";\nimport { Angle } from \"../geometry3d/Angle\";\nimport { Point2d, Vector2d } from \"../geometry3d/Point2dVector2d\";\nimport { Range3d } from \"../geometry3d/Range\";\nimport { ClusterableArray } from \"../numerics/ClusterableArray\";\nimport { SmallSystem } from \"../numerics/Polynomials\";\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask } from \"./Graph\";\nimport { HalfEdgePriorityQueueWithPartnerArray } from \"./HalfEdgePriorityQueue\";\nimport { RegularizationContext } from \"./RegularizeFace\";\nimport { MultiLineStringDataVariant, Triangulator } from \"./Triangulation\";\n\nexport class GraphSplitData {\n public numUpEdge = 0;\n public numIntersectionTest = 0;\n public numSplit = 0;\n public numPopOut = 0;\n public numA0B0 = 0;\n public numA0B1 = 0;\n public constructor() {\n }\n}\n/**\n * Structure for data used when sorting outbound edges \"around a node\"\n */\nexport class VertexNeighborhoodSortData {\n public index: number;\n public radiusOfCurvature: number;\n public node: HalfEdge;\n public radians?: number;\n public constructor(index: number, key: number, node: HalfEdge, radians?: number) {\n this.index = index;\n this.radiusOfCurvature = key;\n this.node = node;\n this.radians = radians;\n }\n}\n\n/** Function signature for announcing a vertex neighborhood during sorting. */\nexport type AnnounceVertexNeighborhoodSortData = (data: VertexNeighborhoodSortData[]) => any;\n/**\n * * Assorted methods used in algorithms on HalfEdgeGraph.\n * @internal\n */\nexport class HalfEdgeGraphOps {\n\n /** Compare function for sorting with primary y compare, secondary x compare. */\n public static compareNodesYXUp(a: HalfEdge, b: HalfEdge) {\n // Check y's\n // if (!Geometry.isSameCoordinate(a.y, b.y))\n if (a.y < b.y)\n return -1;\n else if (a.y > b.y)\n return 1;\n // Check x's\n // if (!Geometry.isSameCoordinate(a.x, b.x))\n if (a.x < b.x)\n return -1;\n else if (a.x > b.x)\n return 1;\n return 0;\n }\n\n /** Return true if nodeB (a) is lower than both its neighbors and (b) inflects as a downward peak (rather than an upward trough) */\n public static isDownPeak(nodeB: HalfEdge) {\n const nodeA = nodeB.facePredecessor;\n const nodeC = nodeB.faceSuccessor;\n return this.compareNodesYXUp(nodeB, nodeA) < 0\n && this.compareNodesYXUp(nodeB, nodeC) < 0\n && this.crossProductToTargets(nodeB, nodeA, nodeC) > 0;\n }\n\n /** return the cross product of vectors from base to targetA and base to targetB\n * @param base base vertex of both vectors.\n * @param targetA target vertex of first vector\n * @param targetB target vertex of second vector\n */\n public static crossProductToTargets(base: HalfEdge, targetA: HalfEdge, targetB: HalfEdge): number {\n return Geometry.crossProductXYXY(targetA.x - base.x, targetA.y - base.y, targetB.x - base.x, targetB.y - base.y);\n }\n\n // ---------------------------------------------------------------------------------------------------------------------\n // ----------------------------------------------------------------------------------------------------------------------\n\n public static graphRange(graph: HalfEdgeGraph): Range3d {\n const range = Range3d.create();\n for (const node of graph.allHalfEdges) {\n range.extendXYZ(node.x, node.y, node.z);\n }\n return range;\n }\n /** Returns an array of all nodes (both ends) of edges created from segments. */\n public static segmentArrayToGraphEdges(segments: LineSegment3d[], returnGraph: HalfEdgeGraph, mask: HalfEdgeMask): HalfEdge[] {\n const result = [];\n let idxCounter = 0;\n\n // Push the endpoints of each segment onto arr[] in the form {(x, y, theta), Node}\n for (const segment of segments) {\n\n const node0 = returnGraph.createEdgeXYZXYZ(\n segment.point0Ref.x, segment.point0Ref.y, segment.point0Ref.z,\n idxCounter,\n segment.point1Ref.x, segment.point1Ref.y, segment.point1Ref.z,\n idxCounter + 1);\n\n const node1 = node0.edgeMate;\n idxCounter += 2;\n\n node0.setMaskAroundFace(mask); // Original given coordinates must be part of boundary\n result.push(node0);\n result.push(node1);\n }\n\n return result;\n }\n\n /**\n * * Visit all nodes in `graph`.\n * * invoke `pinch(node, vertexPredecessor)`\n * * this leaves the graph as isolated edges.\n * @param graph graph to modify\n */\n public static isolateAllEdges(graph: HalfEdgeGraph) {\n for (const nodeA of graph.allHalfEdges) {\n const nodeB = nodeA.vertexPredecessor;\n HalfEdge.pinch(nodeA, nodeB);\n }\n }\n\n /**\n * Compute convexity of a sector of a super-face.\n * @param base node whose edge is to be tested for removal\n * @param ignore edges with this mask (on either side) are ignored for the purposes of computing convexity\n * @param barrier edges with this mask (on either side) will not be removed\n * @return whether removing the edge at base would create a convex sector in the super-face\n */\n private static isSectorConvexAfterEdgeRemoval(base: HalfEdge, ignore: HalfEdgeMask, barrier: HalfEdgeMask): boolean {\n let vs = base;\n do { // loop ccw around vertex looking for a super-face predecessor\n if (vs.isMaskSet(barrier) || vs.edgeMate.isMaskSet(barrier))\n break;\n vs = vs.vertexSuccessor;\n } while (vs !== base && vs.isMaskSet(ignore));\n if (vs === base)\n return false;\n let vp = base;\n do { // loop cw around vertex looking for a super-face successor\n if (vp.isMaskSet(barrier) || vp.edgeMate.isMaskSet(barrier))\n break;\n vp = vp.vertexPredecessor;\n } while (vp !== base && vp.isMaskSet(ignore));\n if (vp === base)\n return false;\n return HalfEdge.isSectorConvex(vs.edgeMate, base, vp.faceSuccessor);\n }\n\n /**\n * Mask edges between faces if the union of the faces is convex.\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\n * Best results when input faces are convex.\n * @param graph graph to examine and mark\n * @param mark the mask used to mark (both sides of) removable edges\n * @param barrier edges with this mask (on either side) will not be marked. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\n * @return number of edges masked (half the number of HalfEdges masked)\n */\n public static markRemovableEdgesToExpandConvexFaces(graph: HalfEdgeGraph, mark: HalfEdgeMask, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): number {\n if (HalfEdgeMask.NULL_MASK === mark)\n return 0;\n const visit = graph.grabMask(true);\n let numMarked = 0;\n for (const node of graph.allHalfEdges) {\n if (!node.isMaskSet(visit)) {\n if (!node.isMaskSet(barrier) && !node.edgeMate.isMaskSet(barrier)) {\n if (this.isSectorConvexAfterEdgeRemoval(node, mark, barrier) && this.isSectorConvexAfterEdgeRemoval(node.edgeMate, mark, barrier)) {\n node.setMaskAroundEdge(mark);\n ++numMarked;\n }\n }\n }\n node.setMaskAroundEdge(visit);\n }\n return numMarked;\n }\n\n /**\n * Collect edges between faces if the union of the faces is convex.\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\n * Best results when input faces are convex.\n * @param graph graph to examine\n * @param barrier edges with this mask (on either side) will not be collected. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\n * @return one HalfEdge per removable edge\n */\n public static collectRemovableEdgesToExpandConvexFaces(graph: HalfEdgeGraph, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): HalfEdge[] | undefined {\n const removable: HalfEdge[] = [];\n const mark = graph.grabMask(true);\n if (0 < this.markRemovableEdgesToExpandConvexFaces(graph, mark, barrier)) {\n const visited = graph.grabMask(true);\n for (const node of graph.allHalfEdges) {\n if (node.isMaskSet(mark) && !node.isMaskSet(visited)) {\n node.setMaskAroundEdge(visited);\n removable.push(node);\n }\n }\n graph.dropMask(visited);\n }\n graph.dropMask(mark);\n return removable;\n }\n\n /**\n * Remove edges between faces if the union of the faces is convex.\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\n * Best results when input faces are convex.\n * @param graph graph to modify\n * @param barrier edges with this mask (on either side) will not be removed. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\n * @return number of edges deleted\n */\n public static expandConvexFaces(graph: HalfEdgeGraph, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): number {\n const mark = graph.grabMask(true);\n const numRemovedEdges = this.markRemovableEdgesToExpandConvexFaces(graph, mark, barrier);\n if (numRemovedEdges > 0)\n graph.yankAndDeleteEdges((node: HalfEdge) => node.getMask(mark));\n graph.dropMask(mark);\n return numRemovedEdges;\n }\n\n /**\n * Test desired faces for convexity.\n * @param graph graph to examine\n * @param avoid faces with this mask will not be examined. Defaults to HalfEdgeMask.EXTERIOR.\n * @return whether every face in the graph is convex\n */\n public static isEveryFaceConvex(graph: HalfEdgeGraph, avoid: HalfEdgeMask = HalfEdgeMask.EXTERIOR): boolean {\n const allFaces = graph.collectFaceLoops();\n for (const node of allFaces) {\n if (node.isMaskedAroundFace(avoid))\n continue;\n if (!node.isFaceConvex())\n return false;\n }\n return true;\n }\n}\n\n/**\n * @internal\n */\nexport class HalfEdgeGraphMerge {\n // return kC <= kB such that stored angles (at extra data index 0 !) kA<=k<kC match.\n // * Note that the usual case (when angle at kA is not repeated) is kA+1 === kC\n public static getCommonThetaEndIndex(clusters: ClusterableArray, order: Uint32Array, kA: number, kB: number): number{\n let kC = kA + 1;\n const thetaA = clusters.getExtraData(order[kA], 0);\n while (kC < kB) {\n const thetaB = clusters.getExtraData(order[kC], 0);\n if (!Angle.isAlmostEqualRadiansAllowPeriodShift(thetaA, thetaB)) {\n return kC;\n }\n kC++;\n }\n return kC;\n }\n private static _announceVertexNeighborhoodFunction?: AnnounceVertexNeighborhoodSortData;\n/**\n * public property setter for a function to be called with sorted edge data around a vertex.\n */\n public static set announceVertexNeighborhoodFunction(func: AnnounceVertexNeighborhoodSortData | undefined) { this._announceVertexNeighborhoodFunction = func; }\n private static doAnnounceVertexNeighborhood(clusters: ClusterableArray, order: Uint32Array, allNodes: HalfEdge[], k0: number, k1: number) {\n if (this._announceVertexNeighborhoodFunction) {\n const sortData: VertexNeighborhoodSortData[] = [];\n // build and share the entire vertex order\n for (let k = k0; k < k1; k++){\n const index = clusters.getExtraData(order[k], 1);\n const theta = clusters.getExtraData(order[k], 0);\n const node = allNodes[index];\n const signedDistance = this.curvatureSortKey(node);\n sortData.push(new VertexNeighborhoodSortData(order[k], signedDistance, node, theta));\n }\n this._announceVertexNeighborhoodFunction(sortData);\n }\n\n }\n // assumptions about cluster array:\n // * data order is: x,y,theta, nodeIndex\n // * theta and nodeIndex are the \"extra\" data.\n // * only want to do anything here when curves are present.\n // * k0<=k<k1 are around a vertex\n // * These are sorted by theta.\n private static secondarySortAroundVertex(clusters: ClusterableArray, order: Uint32Array, allNodes: HalfEdge[], k0: number, k1: number) {\n const sortData: VertexNeighborhoodSortData[] = [];\n\n for (let k = k0; k < k1;) {\n const kB = this.getCommonThetaEndIndex(clusters, order,k, k1);\n if (k + 1 < kB) {\n sortData.length = 0;\n for (let kA = k; kA < kB; kA++) {\n const index = clusters.getExtraData(order[kA], 1);\n const node = allNodes[index];\n const signedDistance = this.curvatureSortKey(node);\n sortData.push(new VertexNeighborhoodSortData(order[kA], signedDistance, node));\n }\n sortData.sort((a: VertexNeighborhoodSortData, b: VertexNeighborhoodSortData) => (a.radiusOfCurvature - b.radiusOfCurvature));\n for (let i = 0; i < sortData.length; i++){\n order[k + i] = sortData[i].index;\n }\n }\n k = kB;\n }\n }\n // Return the sort key for sorting by curvature.\n // This is the signed distance from the curve to center of curvature.\n // This should need to be upgraded to account for higher derivatives in the case of higher-than-tangent match.\n private static curvatureSortKey(node: HalfEdge): number {\n const cld = node.edgeTag as CurveLocationDetail;\n if (cld !== undefined) {\n const fraction = cld.fraction;\n const curve = cld.curve;\n if (curve) {\n let radius = curve.fractionToSignedXYRadiusOfCurvature(fraction);\n if (node.sortData !== undefined && node.sortData < 0)\n radius = -radius;\n return radius;\n }\n }\n return 0.0;\n }\n /** Simplest merge algorithm:\n * * collect array of (x,y,theta) at all nodes\n * * lexical sort of the array.\n * * twist all vertices together.\n * * This effectively creates valid face loops for a planar subdivision if there are no edge crossings.\n * * If there are edge crossings, the graph can be a (highly complicated) Klein bottle topology.\n * * Mask.NULL_FACE is cleared throughout and applied within null faces.\n */\n public static clusterAndMergeXYTheta(graph: HalfEdgeGraph, outboundRadiansFunction?: (he: HalfEdge) => number) {\n const allNodes = graph.allHalfEdges;\n const numNodes = allNodes.length;\n graph.clearMask(HalfEdgeMask.NULL_FACE);\n const clusters = new ClusterableArray(2, 2, numNodes); // data order: x,y,theta, nodeIndex. But theta is not set in first round.\n for (let i = 0; i < numNodes; i++) {\n const nodeA = allNodes[i];\n const xA = nodeA.x;\n const yA = nodeA.y;\n HalfEdge.pinch(nodeA, nodeA.vertexSuccessor); // pull it out of its current vertex loop.\n clusters.addDirect(xA, yA, 0.0, i);\n }\n const order = clusters.clusterIndicesLexical();\n let k0 = 0;\n const numK = order.length;\n for (let k1 = 0; k1 < numK; k1++) {\n if (order[k1] === ClusterableArray.clusterTerminator) {\n // nodes identified in order[k0]..order[k1] are properly sorted around a vertex.\n if (k1 > k0) {\n const iA = clusters.getExtraData(order[k0], 1);\n const nodeA0 = allNodes[iA];\n for (let k = k0 + 1; k < k1; k++) {\n const iB = clusters.getExtraData(order[k], 1);\n const nodeB = allNodes[iB];\n nodeB.x = nodeA0.x;\n nodeB.y = nodeA0.y;\n }\n }\n k0 = k1 + 1;\n }\n }\n // NOW\n // 1) There are identical coordinates at all nodes around each vertex loop.\n // 2) Hence ready do sort (at each vertex) by theta.\n\n // insert theta as extra data in the sort table . . .\n for (const clusterTableIndex of order) {\n if (clusterTableIndex !== ClusterableArray.clusterTerminator) {\n const nodeA = allNodes[clusterTableIndex];\n const nodeB = nodeA.faceSuccessor;\n let radians = outboundRadiansFunction ? outboundRadiansFunction(nodeA) : Math.atan2(nodeB.y - nodeA.y, nodeB.x - nodeA.x);\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(radians, -Math.PI))\n radians = Math.PI;\n clusters.setExtraData(clusterTableIndex, 0, radians);\n }\n }\n clusters.sortSubsetsBySingleKey(order, 2);\n const unmatchedNullFaceNodes: HalfEdge[] = [];\n k0 = 0;\n let thetaA, thetaB;\n // eslint-disable-next-line no-console\n // console.log(\"START VERTEX LINKS\");\n\n // now pinch each neighboring pair together\n for (let k1 = 0; k1 < numK; k1++) {\n if (order[k1] === ClusterableArray.clusterTerminator) {\n // nodes identified in order[k0]..order[k1] are properly sorted around a vertex.\n if (k1 > k0) {\n // const xy = clusters.getPoint2d(order[k0]);\n // eslint-disable-next-line no-console\n // console.log({ k0, k1, x: xy.x, y: xy.y });\n if (k1 > k0 + 1)\n this.secondarySortAroundVertex(clusters, order, allNodes, k0, k1);\n this.doAnnounceVertexNeighborhood(clusters, order, allNodes, k0, k1);\n const iA = clusters.getExtraData(order[k0], 1);\n thetaA = clusters.getExtraData(order[k0], 0);\n const nodeA0 = allNodes[iA];\n let nodeA = nodeA0;\n for (let k = k0 + 1; k < k1; k++) {\n const iB = clusters.getExtraData(order[k], 1);\n thetaB = clusters.getExtraData(order[k], 0);\n const nodeB = allNodes[iB];\n if (nodeA.isMaskSet(HalfEdgeMask.NULL_FACE)) {\n // nope, this edge was flagged and pinched from the other end.\n const j = unmatchedNullFaceNodes.findIndex((node: HalfEdge) => nodeA === node);\n if (j >= 0) {\n unmatchedNullFaceNodes[j] = unmatchedNullFaceNodes[unmatchedNullFaceNodes.length - 1];\n unmatchedNullFaceNodes.pop();\n }\n nodeA = nodeB;\n thetaA = thetaB;\n } else if (nodeB.isMaskSet(HalfEdgeMask.NULL_FACE)) {\n const j = unmatchedNullFaceNodes.findIndex((node: HalfEdge) => nodeB === node);\n if (j >= 0) {\n unmatchedNullFaceNodes[j] = unmatchedNullFaceNodes[unmatchedNullFaceNodes.length - 1];\n unmatchedNullFaceNodes.pop();\n }\n // NO leave nodeA and thetaA ignore nodeB -- later step will get the outside of its banana.\n } else {\n HalfEdge.pinch(nodeA, nodeB);\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(thetaA, thetaB)) {\n const nodeA1 = nodeA.faceSuccessor;\n const nodeB1 = nodeB.edgeMate;\n // WE TRUST -- nodeA1 and node B1 must have identical xy.\n // pinch them together and mark the face loop as null ..\n HalfEdge.pinch(nodeA1, nodeB1);\n nodeA.setMask(HalfEdgeMask.NULL_FACE);\n nodeB1.setMask(HalfEdgeMask.NULL_FACE);\n unmatchedNullFaceNodes.push(nodeB1);\n }\n nodeA = nodeB;\n thetaA = thetaB;\n }\n }\n }\n k0 = k1 + 1;\n }\n }\n }\n\n private static buildVerticalSweepPriorityQueue(graph: HalfEdgeGraph): HalfEdgePriorityQueueWithPartnerArray {\n const sweepHeap = new HalfEdgePriorityQueueWithPartnerArray();\n for (const p of graph.allHalfEdges) {\n\n if (HalfEdgeGraphOps.compareNodesYXUp(p, p.faceSuccessor) < 0) {\n sweepHeap.priorityQueue.push(p);\n }\n }\n return sweepHeap;\n }\n private static snapFractionToNode(xy: Point2d, fraction: number, node: HalfEdge, nodeFraction: number): number{\n if (Geometry.isSameCoordinate(xy.x, node.x) && Geometry.isSameCoordinate(xy.y, node.y))\n return nodeFraction;\n return fraction;\n}\n private static computeIntersectionFractionsOnEdges(nodeA0: HalfEdge, nodeB0: HalfEdge, fractions: Vector2d, pointA: Point2d, pointB: Point2d): boolean {\n const nodeA1 = nodeA0.faceSuccessor;\n const ax0 = nodeA0.x;\n const ay0 = nodeA0.y;\n const ux = nodeA1.x - ax0;\n const uy = nodeA1.y - ay0;\n const nodeB1 = nodeB0.faceSuccessor;\n const bx0 = nodeB0.x;\n const by0 = nodeB0.y;\n const vx = nodeB1.x - bx0;\n const vy = nodeB1.y - by0;\n // cspell:word lineSegmentXYUVTransverseIntersectionUnbounded\n if (SmallSystem.lineSegmentXYUVTransverseIntersectionUnbounded(ax0, ay0, ux, uy,\n bx0, by0, vx, vy, fractions)) {\n pointA.x = ax0 + fractions.x * ux;\n pointA.y = ay0 + fractions.x * uy;\n pointB.x = bx0 + fractions.y * vx;\n pointB.y = by0 + fractions.y * vy;\n fractions.x = this.snapFractionToNode(pointA, fractions.x, nodeA0, 0.0);\n fractions.x = this.snapFractionToNode(pointA, fractions.x, nodeA1, 1.0);\n fractions.y = this.snapFractionToNode(pointB, fractions.y, nodeB0, 0.0);\n fractions.y = this.snapFractionToNode(pointB, fractions.y, nodeB1, 1.0);\n return Geometry.isIn01(fractions.x) && Geometry.isIn01(fractions.y);\n }\n return false;\n }\n /**\n * Split edges at intersections.\n * * This is a large operation.\n * @param graph\n */\n public static splitIntersectingEdges(graph: HalfEdgeGraph): GraphSplitData {\n const data = new GraphSplitData();\n const sweepHeap = this.buildVerticalSweepPriorityQueue(graph);\n let nodeA0, nodeB1;\n const smallFraction = 1.0e-8;\n const largeFraction = 1.0 - smallFraction;\n let i;\n const fractions = Vector2d.create();\n const pointA = Point2d.create();\n const pointB = Point2d.create();\n let nodeB0;\n const popTolerance = Geometry.smallMetricDistance;\n while (undefined !== (nodeA0 = sweepHeap.priorityQueue.pop())) {\n data.numUpEdge++;\n const n0 = sweepHeap.activeEdges.length;\n sweepHeap.removeArrayMembersWithY1Below(nodeA0.y - popTolerance);\n data.numPopOut += n0 - sweepHeap.activeEdges.length;\n for (i = 0; i < sweepHeap.activeEdges.length; i++) {\n nodeB0 = sweepHeap.activeEdges[i];\n nodeB1 = nodeB0.faceSuccessor;\n // const nodeB1 = nodeB0.faceSuccessor;\n if (Geometry.isSameCoordinateXY(nodeA0.x, nodeA0.y, nodeB0.x, nodeB0.y)) {\n data.numA0B0++;\n } else if (Geometry.isSameCoordinateXY(nodeB1.x, nodeB1.y, nodeA0.x, nodeA0.y)) {\n data.numA0B1++;\n } else {\n data.numIntersectionTest++;\n if (this.computeIntersectionFractionsOnEdges(nodeA0, nodeB0, fractions, pointA, pointB)) {\n if (fractions.x > smallFraction && fractions.x < largeFraction) {\n const nodeC0 = graph.splitEdgeAtFraction(nodeA0, fractions.x);\n sweepHeap.priorityQueue.push(nodeC0); // The upper portion will be reviewed as a nodeA0 later !!!\n data.numSplit++;\n }\n if (fractions.y > smallFraction && fractions.y < largeFraction) {\n const nodeD0 = graph.splitEdgeAtFraction(nodeB0, fractions.y);\n sweepHeap.priorityQueue.push(nodeD0); // The upper portion will be reviewed as a nodeA0 later !!!\n data.numSplit++;\n }\n // existing nodeA0 and its shortened edge remain for further intersections\n }\n }\n }\n sweepHeap.activeEdges.push(nodeA0);\n }\n return data;\n }\n\n /**\n * Returns a graph structure formed from the given LineSegment array\n *\n * * Find all intersections among segments, and split them if necessary\n * * Record endpoints of every segment in the form X, Y, Theta; This information is stored as a new node and sorted to match up\n * vertices.\n * * For vertices that match up, pinch the nodes to create vertex loops, which in closed objects, will also eventually form face\n * loops\n */\n public static formGraphFromSegments(lineSegments: LineSegment3d[]): HalfEdgeGraph {\n // Structure of an index of the array: { xyTheta: Point3d, node: Node }\n const graph = new HalfEdgeGraph();\n HalfEdgeGraphOps.segmentArrayToGraphEdges(lineSegments, graph, HalfEdgeMask.BOUNDARY_EDGE);\n this.splitIntersectingEdges(graph);\n this.clusterAndMergeXYTheta(graph);\n\n return graph;\n }\n\n /**\n * * Input is random linestrings, not necessarily loops\n * * Graph gets full splitEdges, regularize, and triangulate.\n * @returns triangulated graph, or undefined if bad data.\n */\n public static formGraphFromChains(chains: MultiLineStringDataVariant, regularize: boolean = true, mask: HalfEdgeMask = HalfEdgeMask.PRIMARY_EDGE): HalfEdgeGraph | undefined {\n if (chains.length < 1)\n return undefined;\n const graph = new HalfEdgeGraph();\n const chainSeeds = Triangulator.directCreateChainsFromCoordinates(graph, chains);\n for (const seed of chainSeeds)\n seed.setMaskAroundFace(mask);\n\n this.splitIntersectingEdges(graph);\n this.clusterAndMergeXYTheta(graph);\n if (regularize) {\n const context = new RegularizationContext(graph);\n context.regularizeGraph(true, true);\n }\n return graph;\n }\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Merging.js","sourceRoot":"","sources":["../../../src/topology/Merging.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAQ/F,0CAAuC;AACvC,+CAA4C;AAC5C,mEAAkE;AAClE,+CAA8C;AAC9C,mEAAgE;AAChE,yDAAsD;AACtD,mCAAgE;AAChE,mEAAgF;AAChF,qDAAyD;AACzD,mDAA2E;AAE3E,MAAa,cAAc;IAOzB;QANO,cAAS,GAAG,CAAC,CAAC;QACd,wBAAmB,GAAG,CAAC,CAAC;QACxB,aAAQ,GAAG,CAAC,CAAC;QACb,cAAS,GAAG,CAAC,CAAC;QACd,YAAO,GAAG,CAAC,CAAC;QACZ,YAAO,GAAG,CAAC,CAAC;IAEnB,CAAC;CACF;AATD,wCASC;AACD;;GAEG;AACH,MAAa,0BAA0B;IAKrC,YAAmB,KAAa,EAAE,GAAW,EAAE,IAAc,EAAE,OAAgB;QAC7E,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,iBAAiB,GAAG,GAAG,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAXD,gEAWC;AAID;;;GAGG;AACH,MAAa,gBAAgB;IAE3B,iFAAiF;IAC1E,MAAM,CAAC,gBAAgB,CAAC,CAAW,EAAE,CAAW;QACrD,YAAY;QACZ,4CAA4C;QAC5C,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACX,OAAO,CAAC,CAAC,CAAC;aACP,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAChB,OAAO,CAAC,CAAC;QACX,YAAY;QACZ,4CAA4C;QAC5C,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACX,OAAO,CAAC,CAAC,CAAC;aACP,IAAI,CAAC,CAAC,CAA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,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,mBAAmB,CAAC,MAAkC,EAAE,aAAsB,IAAI,EAAE,OAAqB,oBAAY,CAAC,YAAY;QAC9I,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YACnB,OAAO,SAAS,CAAC;QACnB,MAAM,KAAK,GAAG,IAAI,qBAAa,EAAE,CAAC;QAClC,MAAM,UAAU,GAAG,4BAAY,CAAC,iCAAiC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACjF,KAAK,MAAM,IAAI,IAAI,UAAU;YAC3B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAE/B,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,UAAU,EAAE;YACd,MAAM,OAAO,GAAG,IAAI,sCAAqB,CAAC,KAAK,CAAC,CAAC;YACjD,OAAO,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACrC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CAEF;AAxVD,gDAwVC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Topology\n */\n\nimport { CurveLocationDetail } from \"../curve/CurveLocationDetail\";\nimport { LineSegment3d } from \"../curve/LineSegment3d\";\nimport { Geometry } from \"../Geometry\";\nimport { Angle } from \"../geometry3d/Angle\";\nimport { Point2d, Vector2d } from \"../geometry3d/Point2dVector2d\";\nimport { Range3d } from \"../geometry3d/Range\";\nimport { ClusterableArray } from \"../numerics/ClusterableArray\";\nimport { SmallSystem } from \"../numerics/Polynomials\";\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask } from \"./Graph\";\nimport { HalfEdgePriorityQueueWithPartnerArray } from \"./HalfEdgePriorityQueue\";\nimport { RegularizationContext } from \"./RegularizeFace\";\nimport { MultiLineStringDataVariant, Triangulator } from \"./Triangulation\";\n\nexport class GraphSplitData {\n public numUpEdge = 0;\n public numIntersectionTest = 0;\n public numSplit = 0;\n public numPopOut = 0;\n public numA0B0 = 0;\n public numA0B1 = 0;\n public constructor() {\n }\n}\n/**\n * Structure for data used when sorting outbound edges \"around a node\"\n */\nexport class VertexNeighborhoodSortData {\n public index: number;\n public radiusOfCurvature: number;\n public node: HalfEdge;\n public radians?: number;\n public constructor(index: number, key: number, node: HalfEdge, radians?: number) {\n this.index = index;\n this.radiusOfCurvature = key;\n this.node = node;\n this.radians = radians;\n }\n}\n\n/** Function signature for announcing a vertex neighborhood during sorting. */\nexport type AnnounceVertexNeighborhoodSortData = (data: VertexNeighborhoodSortData[]) => any;\n/**\n * * Assorted methods used in algorithms on HalfEdgeGraph.\n * @internal\n */\nexport class HalfEdgeGraphOps {\n\n /** Compare function for sorting with primary y compare, secondary x compare. */\n public static compareNodesYXUp(a: HalfEdge, b: HalfEdge) {\n // Check y's\n // if (!Geometry.isSameCoordinate(a.y, b.y))\n if (a.y < b.y)\n return -1;\n else if (a.y > b.y)\n return 1;\n // Check x's\n // if (!Geometry.isSameCoordinate(a.x, b.x))\n if (a.x < b.x)\n return -1;\n else if (a.x > b.x)\n return 1;\n return 0;\n }\n\n /** Return true if nodeB (a) is lower than both its neighbors and (b) inflects as a downward peak (rather than an upward trough) */\n public static isDownPeak(nodeB: HalfEdge) {\n const nodeA = nodeB.facePredecessor;\n const nodeC = nodeB.faceSuccessor;\n return this.compareNodesYXUp(nodeB, nodeA) < 0\n && this.compareNodesYXUp(nodeB, nodeC) < 0\n && this.crossProductToTargets(nodeB, nodeA, nodeC) > 0;\n }\n\n /** return the cross product of vectors from base to targetA and base to targetB\n * @param base base vertex of both vectors.\n * @param targetA target vertex of first vector\n * @param targetB target vertex of second vector\n */\n public static crossProductToTargets(base: HalfEdge, targetA: HalfEdge, targetB: HalfEdge): number {\n return Geometry.crossProductXYXY(targetA.x - base.x, targetA.y - base.y, targetB.x - base.x, targetB.y - base.y);\n }\n\n // ---------------------------------------------------------------------------------------------------------------------\n // ----------------------------------------------------------------------------------------------------------------------\n\n public static graphRange(graph: HalfEdgeGraph): Range3d {\n const range = Range3d.create();\n for (const node of graph.allHalfEdges) {\n range.extendXYZ(node.x, node.y, node.z);\n }\n return range;\n }\n /** Returns an array of all nodes (both ends) of edges created from segments. */\n public static segmentArrayToGraphEdges(segments: LineSegment3d[], returnGraph: HalfEdgeGraph, mask: HalfEdgeMask): HalfEdge[] {\n const result = [];\n let idxCounter = 0;\n\n // Push the endpoints of each segment onto arr[] in the form {(x, y, theta), Node}\n for (const segment of segments) {\n\n const node0 = returnGraph.createEdgeXYZXYZ(\n segment.point0Ref.x, segment.point0Ref.y, segment.point0Ref.z,\n idxCounter,\n segment.point1Ref.x, segment.point1Ref.y, segment.point1Ref.z,\n idxCounter + 1);\n\n const node1 = node0.edgeMate;\n idxCounter += 2;\n\n node0.setMaskAroundFace(mask); // Original given coordinates must be part of boundary\n result.push(node0);\n result.push(node1);\n }\n\n return result;\n }\n\n /**\n * * Visit all nodes in `graph`.\n * * invoke `pinch(node, vertexPredecessor)`\n * * this leaves the graph as isolated edges.\n * @param graph graph to modify\n */\n public static isolateAllEdges(graph: HalfEdgeGraph) {\n for (const nodeA of graph.allHalfEdges) {\n const nodeB = nodeA.vertexPredecessor;\n HalfEdge.pinch(nodeA, nodeB);\n }\n }\n\n /**\n * Compute convexity of a sector of a super-face.\n * @param base node whose edge is to be tested for removal\n * @param ignore edges with this mask (on either side) are ignored for the purposes of computing convexity\n * @param barrier edges with this mask (on either side) will not be removed\n * @return whether removing the edge at base would create a convex sector in the super-face\n */\n private static isSectorConvexAfterEdgeRemoval(base: HalfEdge, ignore: HalfEdgeMask, barrier: HalfEdgeMask): boolean {\n let vs = base;\n do { // loop ccw around vertex looking for a super-face predecessor\n if (vs.isMaskSet(barrier) || vs.edgeMate.isMaskSet(barrier))\n break;\n vs = vs.vertexSuccessor;\n } while (vs !== base && vs.isMaskSet(ignore));\n if (vs === base)\n return false;\n let vp = base;\n do { // loop cw around vertex looking for a super-face successor\n if (vp.isMaskSet(barrier) || vp.edgeMate.isMaskSet(barrier))\n break;\n vp = vp.vertexPredecessor;\n } while (vp !== base && vp.isMaskSet(ignore));\n if (vp === base)\n return false;\n return HalfEdge.isSectorConvex(vs.edgeMate, base, vp.faceSuccessor);\n }\n\n /**\n * Mask edges between faces if the union of the faces is convex.\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\n * Best results when input faces are convex.\n * @param graph graph to examine and mark\n * @param mark the mask used to mark (both sides of) removable edges\n * @param barrier edges with this mask (on either side) will not be marked. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\n * @return number of edges masked (half the number of HalfEdges masked)\n */\n public static markRemovableEdgesToExpandConvexFaces(graph: HalfEdgeGraph, mark: HalfEdgeMask, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): number {\n if (HalfEdgeMask.NULL_MASK === mark)\n return 0;\n const visit = graph.grabMask(true);\n let numMarked = 0;\n for (const node of graph.allHalfEdges) {\n if (!node.isMaskSet(visit)) {\n if (!node.isMaskSet(barrier) && !node.edgeMate.isMaskSet(barrier)) {\n if (this.isSectorConvexAfterEdgeRemoval(node, mark, barrier) && this.isSectorConvexAfterEdgeRemoval(node.edgeMate, mark, barrier)) {\n node.setMaskAroundEdge(mark);\n ++numMarked;\n }\n }\n }\n node.setMaskAroundEdge(visit);\n }\n return numMarked;\n }\n\n /**\n * Collect edges between faces if the union of the faces is convex.\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\n * Best results when input faces are convex.\n * @param graph graph to examine\n * @param barrier edges with this mask (on either side) will not be collected. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\n * @return one HalfEdge per removable edge\n */\n public static collectRemovableEdgesToExpandConvexFaces(graph: HalfEdgeGraph, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): HalfEdge[] | undefined {\n const removable: HalfEdge[] = [];\n const mark = graph.grabMask(true);\n if (0 < this.markRemovableEdgesToExpandConvexFaces(graph, mark, barrier)) {\n const visited = graph.grabMask(true);\n for (const node of graph.allHalfEdges) {\n if (node.isMaskSet(mark) && !node.isMaskSet(visited)) {\n node.setMaskAroundEdge(visited);\n removable.push(node);\n }\n }\n graph.dropMask(visited);\n }\n graph.dropMask(mark);\n return removable;\n }\n\n /**\n * Remove edges between faces if the union of the faces is convex.\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\n * Best results when input faces are convex.\n * @param graph graph to modify\n * @param barrier edges with this mask (on either side) will not be removed. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\n * @return number of edges deleted\n */\n public static expandConvexFaces(graph: HalfEdgeGraph, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): number {\n const mark = graph.grabMask(true);\n const numRemovedEdges = this.markRemovableEdgesToExpandConvexFaces(graph, mark, barrier);\n if (numRemovedEdges > 0)\n graph.yankAndDeleteEdges((node: HalfEdge) => node.getMask(mark));\n graph.dropMask(mark);\n return numRemovedEdges;\n }\n\n /**\n * Test desired faces for convexity.\n * @param graph graph to examine\n * @param avoid faces with this mask will not be examined. Defaults to HalfEdgeMask.EXTERIOR.\n * @return whether every face in the graph is convex\n */\n public static isEveryFaceConvex(graph: HalfEdgeGraph, avoid: HalfEdgeMask = HalfEdgeMask.EXTERIOR): boolean {\n const allFaces = graph.collectFaceLoops();\n for (const node of allFaces) {\n if (node.isMaskedAroundFace(avoid))\n continue;\n if (!node.isFaceConvex())\n return false;\n }\n return true;\n }\n}\n\n/**\n * @internal\n */\nexport class HalfEdgeGraphMerge {\n // return kC such that all angles k are equal, with kA <= k < kC <= kB.\n // * Assume: angles k are stored at extra data index 0.\n // * Note that the usual case (when angle at kA is not repeated) is kA+1 === kC\n public static getCommonThetaEndIndex(clusters: ClusterableArray, order: Uint32Array, kA: number, kB: number): number{\n let kC = kA + 1;\n const thetaA = clusters.getExtraData(order[kA], 0);\n while (kC < kB) {\n const thetaB = clusters.getExtraData(order[kC], 0);\n if (!Angle.isAlmostEqualRadiansAllowPeriodShift(thetaA, thetaB)) {\n return kC;\n }\n kC++;\n }\n return kC;\n }\n private static _announceVertexNeighborhoodFunction?: AnnounceVertexNeighborhoodSortData;\n/**\n * public property setter for a function to be called with sorted edge data around a vertex.\n */\n public static set announceVertexNeighborhoodFunction(func: AnnounceVertexNeighborhoodSortData | undefined) { this._announceVertexNeighborhoodFunction = func; }\n private static doAnnounceVertexNeighborhood(clusters: ClusterableArray, order: Uint32Array, allNodes: HalfEdge[], k0: number, k1: number) {\n if (this._announceVertexNeighborhoodFunction) {\n const sortData: VertexNeighborhoodSortData[] = [];\n // build and share the entire vertex order\n for (let k = k0; k < k1; k++){\n const index = clusters.getExtraData(order[k], 1);\n const theta = clusters.getExtraData(order[k], 0);\n const node = allNodes[index];\n const signedDistance = this.curvatureSortKey(node);\n sortData.push(new VertexNeighborhoodSortData(order[k], signedDistance, node, theta));\n }\n this._announceVertexNeighborhoodFunction(sortData);\n }\n\n }\n // assumptions about cluster array:\n // * data order is: x,y,theta,nodeIndex\n // * theta and nodeIndex are the \"extra\" data.\n // * only want to do anything here when curves are present.\n // * k0<=k<k1 are around a vertex\n // * These are sorted by theta.\n private static secondarySortAroundVertex(clusters: ClusterableArray, order: Uint32Array, allNodes: HalfEdge[], k0: number, k1: number) {\n const sortData: VertexNeighborhoodSortData[] = [];\n\n for (let k = k0; k < k1;) {\n const kB = this.getCommonThetaEndIndex(clusters, order,k, k1);\n if (k + 1 < kB) {\n sortData.length = 0;\n for (let kA = k; kA < kB; kA++) {\n const index = clusters.getExtraData(order[kA], 1);\n const node = allNodes[index];\n const signedDistance = this.curvatureSortKey(node);\n sortData.push(new VertexNeighborhoodSortData(order[kA], signedDistance, node));\n }\n sortData.sort((a: VertexNeighborhoodSortData, b: VertexNeighborhoodSortData) => (a.radiusOfCurvature - b.radiusOfCurvature));\n for (let i = 0; i < sortData.length; i++){\n order[k + i] = sortData[i].index;\n }\n }\n k = kB;\n }\n }\n /** Return the sort key for sorting by curvature.\n * * This is the signed distance from the curve at the edge start, to center of curvature.\n * * NOTE: Currently does not account for higher derivatives in the case of higher-than-tangent match.\n */\n public static curvatureSortKey(node: HalfEdge): number {\n const cld = node.edgeTag as CurveLocationDetail;\n if (cld !== undefined) {\n const fraction = cld.fraction;\n const curve = cld.curve;\n if (curve) {\n let radius = curve.fractionToSignedXYRadiusOfCurvature(fraction);\n if (node.sortData !== undefined && node.sortData < 0)\n radius = -radius;\n return radius;\n }\n }\n return 0.0;\n }\n /** Simplest merge algorithm:\n * * collect array of (x,y,theta) at all nodes\n * * lexical sort of the array.\n * * twist all vertices together.\n * * This effectively creates valid face loops for a planar subdivision if there are no edge crossings.\n * * If there are edge crossings, the graph can be a (highly complicated) Klein bottle topology.\n * * Mask.NULL_FACE is cleared throughout and applied within null faces.\n */\n public static clusterAndMergeXYTheta(graph: HalfEdgeGraph, outboundRadiansFunction?: (he: HalfEdge) => number) {\n const allNodes = graph.allHalfEdges;\n const numNodes = allNodes.length;\n graph.clearMask(HalfEdgeMask.NULL_FACE);\n const clusters = new ClusterableArray(2, 2, numNodes); // data order: x,y,theta,nodeIndex. But theta is not set in first round.\n for (let i = 0; i < numNodes; i++) {\n const nodeA = allNodes[i];\n const xA = nodeA.x;\n const yA = nodeA.y;\n HalfEdge.pinch(nodeA, nodeA.vertexSuccessor); // pull it out of its current vertex loop.\n clusters.addDirect(xA, yA, 0.0, i);\n }\n const clusterTol = Geometry.smallMetricDistance;\n const order = clusters.clusterIndicesLexical(clusterTol);\n let k0 = 0;\n const numK = order.length;\n for (let k1 = 0; k1 < numK; k1++) {\n if (order[k1] === ClusterableArray.clusterTerminator) {\n // nodes identified in order[k0]..order[k1-1] are at a vertex cluster; equate their xy\n if (k1 > k0) {\n const iA = clusters.getExtraData(order[k0], 1);\n const nodeA0 = allNodes[iA];\n for (let k = k0 + 1; k < k1; k++) {\n const iB = clusters.getExtraData(order[k], 1);\n const nodeB = allNodes[iB];\n nodeB.x = nodeA0.x;\n nodeB.y = nodeA0.y;\n }\n }\n k0 = k1 + 1;\n }\n }\n // NOW\n // 1) There are identical coordinates at all nodes around each vertex loop.\n // 2) Hence ready do sort (at each vertex) by theta.\n\n // insert theta as extra data in the sort table . . .\n for (const clusterTableIndex of order) {\n if (clusterTableIndex !== ClusterableArray.clusterTerminator) {\n const nodeA = allNodes[clusterTableIndex];\n const nodeB = nodeA.faceSuccessor;\n let radians = outboundRadiansFunction ? outboundRadiansFunction(nodeA) : Math.atan2(nodeB.y - nodeA.y, nodeB.x - nodeA.x);\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(radians, -Math.PI))\n radians = Math.PI;\n clusters.setExtraData(clusterTableIndex, 0, radians);\n }\n }\n clusters.sortSubsetsBySingleKey(order, 2);\n const unmatchedNullFaceNodes: HalfEdge[] = [];\n k0 = 0;\n let thetaA, thetaB;\n // eslint-disable-next-line no-console\n // console.log(\"START VERTEX LINKS\");\n\n // now pinch each neighboring pair together\n for (let k1 = 0; k1 < numK; k1++) {\n if (order[k1] === ClusterableArray.clusterTerminator) {\n // nodes identified in order[k0]..order[k1-1] are properly sorted around a vertex.\n if (k1 > k0) {\n // const xy = clusters.getPoint2d(order[k0]);\n // eslint-disable-next-line no-console\n // console.log({ k0, k1, x: xy.x, y: xy.y });\n if (k1 > k0 + 1)\n this.secondarySortAroundVertex(clusters, order, allNodes, k0, k1);\n this.doAnnounceVertexNeighborhood(clusters, order, allNodes, k0, k1);\n const iA = clusters.getExtraData(order[k0], 1);\n thetaA = clusters.getExtraData(order[k0], 0);\n const nodeA0 = allNodes[iA];\n let nodeA = nodeA0;\n for (let k = k0 + 1; k < k1; k++) {\n const iB = clusters.getExtraData(order[k], 1);\n thetaB = clusters.getExtraData(order[k], 0);\n const nodeB = allNodes[iB];\n if (nodeA.isMaskSet(HalfEdgeMask.NULL_FACE)) {\n // nope, this edge was flagged and pinched from the other end.\n const j = unmatchedNullFaceNodes.findIndex((node: HalfEdge) => nodeA === node);\n if (j >= 0) {\n unmatchedNullFaceNodes[j] = unmatchedNullFaceNodes[unmatchedNullFaceNodes.length - 1];\n unmatchedNullFaceNodes.pop();\n }\n nodeA = nodeB;\n thetaA = thetaB;\n } else if (nodeB.isMaskSet(HalfEdgeMask.NULL_FACE)) {\n const j = unmatchedNullFaceNodes.findIndex((node: HalfEdge) => nodeB === node);\n if (j >= 0) {\n unmatchedNullFaceNodes[j] = unmatchedNullFaceNodes[unmatchedNullFaceNodes.length - 1];\n unmatchedNullFaceNodes.pop();\n }\n // NO leave nodeA and thetaA ignore nodeB -- later step will get the outside of its banana.\n } else {\n HalfEdge.pinch(nodeA, nodeB);\n\n // Detect null face using the heuristic:\n // * near vertex angles are same (periodic, toleranced)\n // * far vertex is clustered (exactly equal)\n // * near vertex curvatures are same (toleranced)\n // Note that near vertex is already clustered.\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(thetaA, thetaB)) {\n const nodeA1 = nodeA.faceSuccessor;\n const nodeB1 = nodeB.edgeMate;\n if (nodeA1.isEqualXY(nodeB1)) {\n const cA = this.curvatureSortKey(nodeA);\n const cB = this.curvatureSortKey(nodeB);\n if (Geometry.isSameCoordinate(cA, cB, clusterTol)) { // rule out banana\n HalfEdge.pinch(nodeA1, nodeB1);\n nodeA.setMask(HalfEdgeMask.NULL_FACE);\n nodeB1.setMask(HalfEdgeMask.NULL_FACE);\n unmatchedNullFaceNodes.push(nodeB1);\n }\n }\n }\n nodeA = nodeB;\n thetaA = thetaB;\n }\n }\n }\n k0 = k1 + 1;\n }\n }\n }\n\n private static buildVerticalSweepPriorityQueue(graph: HalfEdgeGraph): HalfEdgePriorityQueueWithPartnerArray {\n const sweepHeap = new HalfEdgePriorityQueueWithPartnerArray();\n for (const p of graph.allHalfEdges) {\n\n if (HalfEdgeGraphOps.compareNodesYXUp(p, p.faceSuccessor) < 0) {\n sweepHeap.priorityQueue.push(p);\n }\n }\n return sweepHeap;\n }\n private static snapFractionToNode(xy: Point2d, fraction: number, node: HalfEdge, nodeFraction: number): number{\n if (Geometry.isSameCoordinate(xy.x, node.x) && Geometry.isSameCoordinate(xy.y, node.y))\n return nodeFraction;\n return fraction;\n}\n private static computeIntersectionFractionsOnEdges(nodeA0: HalfEdge, nodeB0: HalfEdge, fractions: Vector2d, pointA: Point2d, pointB: Point2d): boolean {\n const nodeA1 = nodeA0.faceSuccessor;\n const ax0 = nodeA0.x;\n const ay0 = nodeA0.y;\n const ux = nodeA1.x - ax0;\n const uy = nodeA1.y - ay0;\n const nodeB1 = nodeB0.faceSuccessor;\n const bx0 = nodeB0.x;\n const by0 = nodeB0.y;\n const vx = nodeB1.x - bx0;\n const vy = nodeB1.y - by0;\n // cspell:word lineSegmentXYUVTransverseIntersectionUnbounded\n if (SmallSystem.lineSegmentXYUVTransverseIntersectionUnbounded(ax0, ay0, ux, uy,\n bx0, by0, vx, vy, fractions)) {\n pointA.x = ax0 + fractions.x * ux;\n pointA.y = ay0 + fractions.x * uy;\n pointB.x = bx0 + fractions.y * vx;\n pointB.y = by0 + fractions.y * vy;\n fractions.x = this.snapFractionToNode(pointA, fractions.x, nodeA0, 0.0);\n fractions.x = this.snapFractionToNode(pointA, fractions.x, nodeA1, 1.0);\n fractions.y = this.snapFractionToNode(pointB, fractions.y, nodeB0, 0.0);\n fractions.y = this.snapFractionToNode(pointB, fractions.y, nodeB1, 1.0);\n return Geometry.isIn01(fractions.x) && Geometry.isIn01(fractions.y);\n }\n return false;\n }\n /**\n * Split edges at intersections.\n * * This is a large operation.\n * @param graph\n */\n public static splitIntersectingEdges(graph: HalfEdgeGraph): GraphSplitData {\n const data = new GraphSplitData();\n const sweepHeap = this.buildVerticalSweepPriorityQueue(graph);\n let nodeA0, nodeB1;\n const smallFraction = 1.0e-8;\n const largeFraction = 1.0 - smallFraction;\n let i;\n const fractions = Vector2d.create();\n const pointA = Point2d.create();\n const pointB = Point2d.create();\n let nodeB0;\n const popTolerance = Geometry.smallMetricDistance;\n while (undefined !== (nodeA0 = sweepHeap.priorityQueue.pop())) {\n data.numUpEdge++;\n const n0 = sweepHeap.activeEdges.length;\n sweepHeap.removeArrayMembersWithY1Below(nodeA0.y - popTolerance);\n data.numPopOut += n0 - sweepHeap.activeEdges.length;\n for (i = 0; i < sweepHeap.activeEdges.length; i++) {\n nodeB0 = sweepHeap.activeEdges[i];\n nodeB1 = nodeB0.faceSuccessor;\n // const nodeB1 = nodeB0.faceSuccessor;\n if (Geometry.isSameCoordinateXY(nodeA0.x, nodeA0.y, nodeB0.x, nodeB0.y)) {\n data.numA0B0++;\n } else if (Geometry.isSameCoordinateXY(nodeB1.x, nodeB1.y, nodeA0.x, nodeA0.y)) {\n data.numA0B1++;\n } else {\n data.numIntersectionTest++;\n if (this.computeIntersectionFractionsOnEdges(nodeA0, nodeB0, fractions, pointA, pointB)) {\n if (fractions.x > smallFraction && fractions.x < largeFraction) {\n const nodeC0 = graph.splitEdgeAtFraction(nodeA0, fractions.x);\n sweepHeap.priorityQueue.push(nodeC0); // The upper portion will be reviewed as a nodeA0 later !!!\n data.numSplit++;\n }\n if (fractions.y > smallFraction && fractions.y < largeFraction) {\n const nodeD0 = graph.splitEdgeAtFraction(nodeB0, fractions.y);\n sweepHeap.priorityQueue.push(nodeD0); // The upper portion will be reviewed as a nodeA0 later !!!\n data.numSplit++;\n }\n // existing nodeA0 and its shortened edge remain for further intersections\n }\n }\n }\n sweepHeap.activeEdges.push(nodeA0);\n }\n return data;\n }\n\n /**\n * Returns a graph structure formed from the given LineSegment array\n *\n * * Find all intersections among segments, and split them if necessary\n * * Record endpoints of every segment in the form X, Y, Theta; This information is stored as a new node and sorted to match up\n * vertices.\n * * For vertices that match up, pinch the nodes to create vertex loops, which in closed objects, will also eventually form face\n * loops\n */\n public static formGraphFromSegments(lineSegments: LineSegment3d[]): HalfEdgeGraph {\n // Structure of an index of the array: { xyTheta: Point3d, node: Node }\n const graph = new HalfEdgeGraph();\n HalfEdgeGraphOps.segmentArrayToGraphEdges(lineSegments, graph, HalfEdgeMask.BOUNDARY_EDGE);\n this.splitIntersectingEdges(graph);\n this.clusterAndMergeXYTheta(graph);\n\n return graph;\n }\n\n /**\n * * Input is random linestrings, not necessarily loops\n * * Graph gets full splitEdges, regularize, and triangulate.\n * @returns triangulated graph, or undefined if bad data.\n */\n public static formGraphFromChains(chains: MultiLineStringDataVariant, regularize: boolean = true, mask: HalfEdgeMask = HalfEdgeMask.PRIMARY_EDGE): HalfEdgeGraph | undefined {\n if (chains.length < 1)\n return undefined;\n const graph = new HalfEdgeGraph();\n const chainSeeds = Triangulator.directCreateChainsFromCoordinates(graph, chains);\n for (const seed of chainSeeds)\n seed.setMaskAroundFace(mask);\n\n this.splitIntersectingEdges(graph);\n this.clusterAndMergeXYTheta(graph);\n if (regularize) {\n const context = new RegularizationContext(graph);\n context.regularizeGraph(true, true);\n }\n return graph;\n }\n\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlanarSubdivision.d.ts","sourceRoot":"","sources":["../../../../src/curve/Query/PlanarSubdivision.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PlanarSubdivision.d.ts","sourceRoot":"","sources":["../../../../src/curve/Query/PlanarSubdivision.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG/D,OAAO,EAAuB,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAsB,WAAW,EAAE,MAAM,SAAS,CAAC;AAqDhE;;GAEG;AACH,qBAAa,iBAAiB;WACd,qBAAqB,CAAC,WAAW,EAAE,cAAc,EAAE,EAAE,QAAQ,EAAE,uBAAuB,EAAE,GAAG,aAAa;IA+BxH;;;;;;;;;OASG;IACD,OAAO,CAAC,MAAM,CAAC,WAAW;WAeZ,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,GAAE,MAAgB,GAAG,MAAM;WAepG,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAC/C,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,IAAI;IAsB7E,OAAO,CAAC,MAAM,CAAC,UAAU;IAYzB,OAAO,CAAC,MAAM,CAAC,eAAe;WAWhB,oCAAoC,CAAC,KAAK,EAAE,aAAa,EAAE,iBAAiB,GAAE,MAAgB,GAAG,WAAW,EAAE;CAmC7H"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { Geometry } from "../../Geometry";
|
|
1
6
|
import { HalfEdgeGraph } from "../../topology/Graph";
|
|
2
7
|
import { HalfEdgeGraphSearch } from "../../topology/HalfEdgeGraphSearch";
|
|
3
8
|
import { HalfEdgeGraphMerge } from "../../topology/Merging";
|
|
@@ -152,12 +157,19 @@ export class PlanarSubdivision {
|
|
|
152
157
|
} while (he !== faceSeed);
|
|
153
158
|
return loop;
|
|
154
159
|
}
|
|
155
|
-
//
|
|
156
|
-
// In a line-only graph, this is a null-area face.
|
|
160
|
+
// Return true if there are only two edges in the face loop, and their start curvatures are the same.
|
|
157
161
|
static isNullFace(he) {
|
|
158
|
-
|
|
162
|
+
const faceHasTwoEdges = (he.faceSuccessor.faceSuccessor === he);
|
|
163
|
+
let faceIsBanana = false;
|
|
164
|
+
if (faceHasTwoEdges) {
|
|
165
|
+
const c0 = HalfEdgeGraphMerge.curvatureSortKey(he);
|
|
166
|
+
const c1 = HalfEdgeGraphMerge.curvatureSortKey(he.faceSuccessor.edgeMate);
|
|
167
|
+
if (!Geometry.isSameCoordinate(c0, c1)) // default tol!
|
|
168
|
+
faceIsBanana = true; // heuristic: we could also check end curvatures, and/or higher derivatives...
|
|
169
|
+
}
|
|
170
|
+
return faceHasTwoEdges && !faceIsBanana;
|
|
159
171
|
}
|
|
160
|
-
// Look
|
|
172
|
+
// Look across edge mates (possibly several) for a nonnull mate face.
|
|
161
173
|
static nonNullEdgeMate(_graph, e) {
|
|
162
174
|
if (this.isNullFace(e))
|
|
163
175
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlanarSubdivision.js","sourceRoot":"","sources":["../../../../src/curve/Query/PlanarSubdivision.ts"],"names":[],"mappings":"AAKA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAA2B,MAAM,wBAAwB,CAAC;AAEtF,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAe,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;GAEG;AAEH,MAAM,+CAA+C;IAArD;QACS,oBAAe,GAAG,IAAI,GAAG,EAA6C,CAAC;QAC9E,yDAAyD;QAClD,qBAAgB,GAAG,IAAI,GAAG,EAA0B,CAAC;QACpD,0BAAqB,GAAW,CAAC,CAAC;IA4B5C,CAAC;IA3BQ,oBAAoB,CAAC,SAAqC;QAC/D,IAAI,SAAS,KAAK,SAAS,EAAE;YAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACnD,IAAI,KAAK,KAAK,SAAS,EAAE;gBACvB,IAAI,CAAC,gBAAgB,CAAC,G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AAG,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,kBAAkB,CAAC,IAA6B,EAAE,KAAqB;IAC9E,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B,OAAO,SAAS,CAAC;AACnB,CAAC;AACD,SAAS,gBAAgB,CAAC,IAA6B,EAAE,KAAqB;IAC5E,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\nimport { HalfEdge, HalfEdgeGraph } from \"../../topology/Graph\";\nimport { HalfEdgeGraphSearch } from \"../../topology/HalfEdgeGraphSearch\";\nimport { HalfEdgeGraphMerge } from \"../../topology/Merging\";\nimport { CurveLocationDetail, CurveLocationDetailPair } from \"../CurveLocationDetail\";\nimport { CurvePrimitive } from \"../CurvePrimitive\";\nimport { Loop, LoopCurveLoopCurve, SignedLoops } from \"../Loop\";\nimport { RegionOps } from \"../RegionOps\";\n\n/** @packageDocumentation\n * @module Curve\n */\n\nclass MapCurvePrimitiveToCurveLocatioNDetailPairArray {\n public primitiveToPair = new Map<CurvePrimitive, CurveLocationDetailPair[]>();\n // index assigned to this primitive for this calculation.\n public primitiveToIndex = new Map<CurvePrimitive, number>();\n private _numIndexedPrimitives: number = 0;\n public assignPrimitiveIndex(primitive: CurvePrimitive | undefined) {\n if (primitive !== undefined) {\n const index = this.primitiveToIndex.get(primitive);\n if (index === undefined) {\n this.primitiveToIndex.set(primitive, this._numIndexedPrimitives++);\n }\n }\n }\n public insertPrimitiveToPair(primitive: CurvePrimitive | undefined, pair: CurveLocationDetailPair) {\n if (primitive) {\n const priorPairs = this.primitiveToPair.get(primitive);\n this.assignPrimitiveIndex(primitive);\n if (!priorPairs) {\n this.primitiveToPair.set(primitive, [pair]);\n } else {\n priorPairs.push(pair);\n }\n }\n }\n public insertPair(pair: CurveLocationDetailPair) {\n const primitiveA = pair.detailA.curve;\n if (primitiveA)\n this.insertPrimitiveToPair(primitiveA, pair);\n const primitiveB = pair.detailB.curve;\n if (primitiveB)\n this.insertPrimitiveToPair(primitiveB, pair);\n }\n}\n/*\n function getDetailString(detail: CurveLocationDetail | undefined): string {\n if (!detail)\n return \"{}\";\n else return tagString(\"primitive\", this.primitiveToIndex.get(detail.curve!)) + tagString(\"f0\", detail.fraction) + tagString(\"f1\", detail.fraction1);\n }\n}\nfunction tagString(name: string, value: number | undefined): string {\n if (value !== undefined)\n return \"(\" + name + \" \" + value + \")\";\n return \"\";\n}\n*/\n/**\n * @internal\n */\nexport class PlanarSubdivision {\n public static assembleHalfEdgeGraph(_primitives: CurvePrimitive[], allPairs: CurveLocationDetailPair[]): HalfEdgeGraph {\n const detailByPrimitive = new MapCurvePrimitiveToCurveLocatioNDetailPairArray(); // map from key CurvePrimitive to CurveLocationDetailPair.\n for (const p of _primitives)\n detailByPrimitive.assignPrimitiveIndex(p);\n for (const pair of allPairs) {\n detailByPrimitive.insertPair(pair);\n }\n const graph = new HalfEdgeGraph();\n for (const entry of detailByPrimitive.primitiveToPair.entries()) {\n const p = entry[0];\n const details = entry[1];\n details.sort((pairA: CurveLocationDetailPair, pairB: CurveLocationDetailPair) => {\n const fractionA = getFractionOnCurve(pairA, p);\n const fractionB = getFractionOnCurve(pairB, p);\n if (fractionA === undefined || fractionB === undefined)\n return -1000.0;\n return fractionA - fractionB;\n });\n let detail0 = getDetailOnCurve(details[0], p)!;\n this.addHalfEdge(graph, p, p.startPoint (), 0.0, detail0.point, detail0.fraction);\n for (let i = 1; i < details.length; i++) {\n // create (both sides of) a graph edge . . .\n const detail1 = getDetailOnCurve(details[i], p)!;\n this.addHalfEdge(graph, p, detail0.point, detail0.fraction, detail1.point, detail1.fraction);\n detail0 = detail1;\n }\n this.addHalfEdge(graph, p, detail0.point, detail0.fraction, p.endPoint(), 1.0);\n }\n HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph, (he: HalfEdge) => he.sortAngle!);\n return graph;\n }\n/**\n * Create a pair of mated half edges referencing an interval of a primitive\n * * no action if start and end points are identical.\n * @param graph containing graph.\n * @param p the curve\n * @param fraction0 starting fraction\n * @param point0 start point\n * @param fraction1 end fraction\n * @param point1 end point\n */\n private static addHalfEdge(graph: HalfEdgeGraph, p: CurvePrimitive, point0: Point3d, fraction0: number, point1: Point3d, fraction1: number) {\n if (!point0.isAlmostEqual (point1)){\n const halfEdge = graph.createEdgeXYAndZ(point0, 0, point1, 0);\n const detail01 = CurveLocationDetail.createCurveEvaluatedFractionFraction(p, fraction0, fraction1);\n const mate = halfEdge.edgeMate;\n halfEdge.edgeTag = detail01;\n halfEdge.sortData = 1.0;\n mate.edgeTag = detail01;\n mate.sortData = -1.0;\n halfEdge.sortAngle = sortAngle(detail01.curve!, detail01.fraction, false);\n mate.sortAngle = sortAngle(detail01.curve!, detail01.fraction1!, true);\n }\n }\n// based on computed (and toleranced) area, push the loop (pointer) onto the appropriate array of positive, negative, or sliver loops.\n // return the area (forced to zero if within tolerance)\n public static collectSignedLoop(loop: Loop, signedAreas: SignedLoops, zeroAreaTolerance: number = 1.0e-10): number{\n let area = RegionOps.computeXYArea(loop);\n if (area === undefined)\n area = 0;\n if (Math.abs(area) < zeroAreaTolerance)\n area = 0.0;\n (loop as any).computedAreaInPlanarSubdivision = area;\n if (area > 0)\n signedAreas.positiveAreaLoops.push(loop);\n else if (area < 0)\n signedAreas.negativeAreaLoops.push(loop);\n else\n signedAreas.slivers.push(loop);\n return area;\n }\n public static createLoopInFace(faceSeed: HalfEdge,\n announce?: (he: HalfEdge, curve: CurvePrimitive, loop: Loop) => void): Loop {\n let he = faceSeed;\n const loop = Loop.create();\n do {\n const detail = he.edgeTag as CurveLocationDetail;\n if (detail) {\n let curve;\n if (he.sortData! > 0)\n curve = detail.curve!.clonePartialCurve(detail.fraction, detail.fraction1!);\n else\n curve = detail.curve!.clonePartialCurve(detail.fraction1!, detail.fraction);\n if (curve) {\n if (announce !== undefined)\n announce(he, curve, loop);\n loop.tryAddChild(curve);\n }\n }\n he = he.faceSuccessor;\n } while (he !== faceSeed);\n return loop;\n }\n// return true if there are only two edges.\n // In a line-only graph, this is a null-area face.\n private static isNullFace(he: HalfEdge): boolean {\n return he.faceSuccessor.faceSuccessor === he;\n }\n // Look across edge mates (possibly several) for a nonnull mate face.\n private static nonNullEdgeMate(_graph: HalfEdgeGraph, e: HalfEdge): HalfEdge | undefined {\n if (this.isNullFace (e))\n return undefined;\n let e1 = e.edgeMate;\n while (this.isNullFace(e1)){\n e1 = e1.faceSuccessor.edgeMate;\n if (e1 === e)\n return undefined;\n }\n return e1;\n }\n public static collectSignedLoopSetsInHalfEdgeGraph(graph: HalfEdgeGraph, zeroAreaTolerance: number = 1.0e-10): SignedLoops[] {\n const q = HalfEdgeGraphSearch.collectConnectedComponentsWithExteriorParityMasks(graph, undefined);\n const result: SignedLoops[] = [];\n const edgeMap = new Map<HalfEdge, LoopCurveLoopCurve>();\n for (const faceSeeds of q) {\n const componentAreas: SignedLoops = { positiveAreaLoops: [], negativeAreaLoops: [], slivers: [] };\n const edges: LoopCurveLoopCurve[] = [];\n for (const faceSeed of faceSeeds) {\n const loop = this.createLoopInFace(faceSeed, (he: HalfEdge, curveC: CurvePrimitive, loopC: Loop) => {\n if (this.isNullFace(he)) {\n // Ignore all edges of null faces.\n } else {\n const mate = this.nonNullEdgeMate(graph, he);\n if (mate !== undefined){\n const e = edgeMap.get(mate);\n if (e === undefined) {\n // Record this as loopA,edgeA of a shared edge to be completed later from the other side of the edge\n const e1 = new LoopCurveLoopCurve(loopC, curveC, undefined, undefined);\n edgeMap.set(he, e1);\n } else if (e instanceof LoopCurveLoopCurve) {\n e.setB(loopC, curveC);\n edges.push(e);\n edgeMap.delete(mate);\n }\n }\n }\n });\n this.collectSignedLoop(loop, componentAreas, zeroAreaTolerance);\n }\n componentAreas.edges = edges;\n result.push(componentAreas);\n edgeMap.clear();\n }\n return result;\n }\n}\n\nfunction sortAngle(curve: CurvePrimitive, fraction: number, reverse: boolean): number {\n const ray = curve.fractionToPointAndDerivative(fraction);\n const s = reverse ? -1.0 : 1.0;\n return Math.atan2(s * ray.direction.y, s * ray.direction.x);\n}\n\nfunction getFractionOnCurve(pair: CurveLocationDetailPair, curve: CurvePrimitive): number | undefined {\n if (pair.detailA.curve === curve)\n return pair.detailA.fraction;\n if (pair.detailB.curve === curve)\n return pair.detailB.fraction;\n return undefined;\n}\nfunction getDetailOnCurve(pair: CurveLocationDetailPair, curve: CurvePrimitive): CurveLocationDetail | undefined {\n if (pair.detailA.curve === curve)\n return pair.detailA;\n if (pair.detailB.curve === curve)\n return pair.detailB;\n return undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PlanarSubdivision.js","sourceRoot":"","sources":["../../../../src/curve/Query/PlanarSubdivision.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAA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Q,CAAC;IAC/B,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B,OAAO,SAAS,CAAC;AACnB,CAAC;AACD,SAAS,gBAAgB,CAAC,IAA6B,EAAE,KAAqB;IAC5E,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { Geometry } from \"../../Geometry\";\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\nimport { HalfEdge, HalfEdgeGraph } from \"../../topology/Graph\";\nimport { HalfEdgeGraphSearch } from \"../../topology/HalfEdgeGraphSearch\";\nimport { HalfEdgeGraphMerge } from \"../../topology/Merging\";\nimport { CurveLocationDetail, CurveLocationDetailPair } from \"../CurveLocationDetail\";\nimport { CurvePrimitive } from \"../CurvePrimitive\";\nimport { Loop, LoopCurveLoopCurve, SignedLoops } from \"../Loop\";\nimport { RegionOps } from \"../RegionOps\";\n\n/** @packageDocumentation\n * @module Curve\n */\n\nclass MapCurvePrimitiveToCurveLocatioNDetailPairArray {\n public primitiveToPair = new Map<CurvePrimitive, CurveLocationDetailPair[]>();\n // index assigned to this primitive for this calculation.\n public primitiveToIndex = new Map<CurvePrimitive, number>();\n private _numIndexedPrimitives: number = 0;\n public assignPrimitiveIndex(primitive: CurvePrimitive | undefined) {\n if (primitive !== undefined) {\n const index = this.primitiveToIndex.get(primitive);\n if (index === undefined) {\n this.primitiveToIndex.set(primitive, this._numIndexedPrimitives++);\n }\n }\n }\n public insertPrimitiveToPair(primitive: CurvePrimitive | undefined, pair: CurveLocationDetailPair) {\n if (primitive) {\n const priorPairs = this.primitiveToPair.get(primitive);\n this.assignPrimitiveIndex(primitive);\n if (!priorPairs) {\n this.primitiveToPair.set(primitive, [pair]);\n } else {\n priorPairs.push(pair);\n }\n }\n }\n public insertPair(pair: CurveLocationDetailPair) {\n const primitiveA = pair.detailA.curve;\n if (primitiveA)\n this.insertPrimitiveToPair(primitiveA, pair);\n const primitiveB = pair.detailB.curve;\n if (primitiveB)\n this.insertPrimitiveToPair(primitiveB, pair);\n }\n}\n/*\n function getDetailString(detail: CurveLocationDetail | undefined): string {\n if (!detail)\n return \"{}\";\n else return tagString(\"primitive\", this.primitiveToIndex.get(detail.curve!)) + tagString(\"f0\", detail.fraction) + tagString(\"f1\", detail.fraction1);\n }\n}\nfunction tagString(name: string, value: number | undefined): string {\n if (value !== undefined)\n return \"(\" + name + \" \" + value + \")\";\n return \"\";\n}\n*/\n/**\n * @internal\n */\nexport class PlanarSubdivision {\n public static assembleHalfEdgeGraph(_primitives: CurvePrimitive[], allPairs: CurveLocationDetailPair[]): HalfEdgeGraph {\n const detailByPrimitive = new MapCurvePrimitiveToCurveLocatioNDetailPairArray(); // map from key CurvePrimitive to CurveLocationDetailPair.\n for (const p of _primitives)\n detailByPrimitive.assignPrimitiveIndex(p);\n for (const pair of allPairs) {\n detailByPrimitive.insertPair(pair);\n }\n const graph = new HalfEdgeGraph();\n for (const entry of detailByPrimitive.primitiveToPair.entries()) {\n const p = entry[0];\n const details = entry[1];\n details.sort((pairA: CurveLocationDetailPair, pairB: CurveLocationDetailPair) => {\n const fractionA = getFractionOnCurve(pairA, p);\n const fractionB = getFractionOnCurve(pairB, p);\n if (fractionA === undefined || fractionB === undefined)\n return -1000.0;\n return fractionA - fractionB;\n });\n let detail0 = getDetailOnCurve(details[0], p)!;\n this.addHalfEdge(graph, p, p.startPoint (), 0.0, detail0.point, detail0.fraction);\n for (let i = 1; i < details.length; i++) {\n // create (both sides of) a graph edge . . .\n const detail1 = getDetailOnCurve(details[i], p)!;\n this.addHalfEdge(graph, p, detail0.point, detail0.fraction, detail1.point, detail1.fraction);\n detail0 = detail1;\n }\n this.addHalfEdge(graph, p, detail0.point, detail0.fraction, p.endPoint(), 1.0);\n }\n HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph, (he: HalfEdge) => he.sortAngle!);\n return graph;\n }\n/**\n * Create a pair of mated half edges referencing an interval of a primitive\n * * no action if start and end points are identical.\n * @param graph containing graph.\n * @param p the curve\n * @param fraction0 starting fraction\n * @param point0 start point\n * @param fraction1 end fraction\n * @param point1 end point\n */\n private static addHalfEdge(graph: HalfEdgeGraph, p: CurvePrimitive, point0: Point3d, fraction0: number, point1: Point3d, fraction1: number) {\n if (!point0.isAlmostEqual (point1)){\n const halfEdge = graph.createEdgeXYAndZ(point0, 0, point1, 0);\n const detail01 = CurveLocationDetail.createCurveEvaluatedFractionFraction(p, fraction0, fraction1);\n const mate = halfEdge.edgeMate;\n halfEdge.edgeTag = detail01;\n halfEdge.sortData = 1.0;\n mate.edgeTag = detail01;\n mate.sortData = -1.0;\n halfEdge.sortAngle = sortAngle(detail01.curve!, detail01.fraction, false);\n mate.sortAngle = sortAngle(detail01.curve!, detail01.fraction1!, true);\n }\n }\n// based on computed (and toleranced) area, push the loop (pointer) onto the appropriate array of positive, negative, or sliver loops.\n // return the area (forced to zero if within tolerance)\n public static collectSignedLoop(loop: Loop, signedAreas: SignedLoops, zeroAreaTolerance: number = 1.0e-10): number{\n let area = RegionOps.computeXYArea(loop);\n if (area === undefined)\n area = 0;\n if (Math.abs(area) < zeroAreaTolerance)\n area = 0.0;\n (loop as any).computedAreaInPlanarSubdivision = area;\n if (area > 0)\n signedAreas.positiveAreaLoops.push(loop);\n else if (area < 0)\n signedAreas.negativeAreaLoops.push(loop);\n else\n signedAreas.slivers.push(loop);\n return area;\n }\n public static createLoopInFace(faceSeed: HalfEdge,\n announce?: (he: HalfEdge, curve: CurvePrimitive, loop: Loop) => void): Loop {\n let he = faceSeed;\n const loop = Loop.create();\n do {\n const detail = he.edgeTag as CurveLocationDetail;\n if (detail) {\n let curve;\n if (he.sortData! > 0)\n curve = detail.curve!.clonePartialCurve(detail.fraction, detail.fraction1!);\n else\n curve = detail.curve!.clonePartialCurve(detail.fraction1!, detail.fraction);\n if (curve) {\n if (announce !== undefined)\n announce(he, curve, loop);\n loop.tryAddChild(curve);\n }\n }\n he = he.faceSuccessor;\n } while (he !== faceSeed);\n return loop;\n }\n // Return true if there are only two edges in the face loop, and their start curvatures are the same.\n private static isNullFace(he: HalfEdge): boolean {\n const faceHasTwoEdges = (he.faceSuccessor.faceSuccessor === he);\n let faceIsBanana = false;\n if (faceHasTwoEdges) {\n const c0 = HalfEdgeGraphMerge.curvatureSortKey(he);\n const c1 = HalfEdgeGraphMerge.curvatureSortKey(he.faceSuccessor.edgeMate);\n if (!Geometry.isSameCoordinate(c0, c1)) // default tol!\n faceIsBanana = true; // heuristic: we could also check end curvatures, and/or higher derivatives...\n }\n return faceHasTwoEdges && !faceIsBanana;\n }\n // Look across edge mates (possibly several) for a nonnull mate face.\n private static nonNullEdgeMate(_graph: HalfEdgeGraph, e: HalfEdge): HalfEdge | undefined {\n if (this.isNullFace (e))\n return undefined;\n let e1 = e.edgeMate;\n while (this.isNullFace(e1)){\n e1 = e1.faceSuccessor.edgeMate;\n if (e1 === e)\n return undefined;\n }\n return e1;\n }\n public static collectSignedLoopSetsInHalfEdgeGraph(graph: HalfEdgeGraph, zeroAreaTolerance: number = 1.0e-10): SignedLoops[] {\n const q = HalfEdgeGraphSearch.collectConnectedComponentsWithExteriorParityMasks(graph, undefined);\n const result: SignedLoops[] = [];\n const edgeMap = new Map<HalfEdge, LoopCurveLoopCurve>();\n for (const faceSeeds of q) {\n const componentAreas: SignedLoops = { positiveAreaLoops: [], negativeAreaLoops: [], slivers: [] };\n const edges: LoopCurveLoopCurve[] = [];\n for (const faceSeed of faceSeeds) {\n const loop = this.createLoopInFace(faceSeed, (he: HalfEdge, curveC: CurvePrimitive, loopC: Loop) => {\n if (this.isNullFace(he)) {\n // Ignore all edges of null faces.\n } else {\n const mate = this.nonNullEdgeMate(graph, he);\n if (mate !== undefined){\n const e = edgeMap.get(mate);\n if (e === undefined) {\n // Record this as loopA,edgeA of a shared edge to be completed later from the other side of the edge\n const e1 = new LoopCurveLoopCurve(loopC, curveC, undefined, undefined);\n edgeMap.set(he, e1);\n } else if (e instanceof LoopCurveLoopCurve) {\n e.setB(loopC, curveC);\n edges.push(e);\n edgeMap.delete(mate);\n }\n }\n }\n });\n this.collectSignedLoop(loop, componentAreas, zeroAreaTolerance);\n }\n componentAreas.edges = edges;\n result.push(componentAreas);\n edgeMap.clear();\n }\n return result;\n }\n}\n\nfunction sortAngle(curve: CurvePrimitive, fraction: number, reverse: boolean): number {\n const ray = curve.fractionToPointAndDerivative(fraction);\n const s = reverse ? -1.0 : 1.0;\n return Math.atan2(s * ray.direction.y, s * ray.direction.x);\n}\n\nfunction getFractionOnCurve(pair: CurveLocationDetailPair, curve: CurvePrimitive): number | undefined {\n if (pair.detailA.curve === curve)\n return pair.detailA.fraction;\n if (pair.detailB.curve === curve)\n return pair.detailB.fraction;\n return undefined;\n}\nfunction getDetailOnCurve(pair: CurveLocationDetailPair, curve: CurvePrimitive): CurveLocationDetail | undefined {\n if (pair.detailA.curve === curve)\n return pair.detailA;\n if (pair.detailB.curve === curve)\n return pair.detailB;\n return undefined;\n}\n"]}
|
|
@@ -82,7 +82,7 @@ export declare class AngleSweep implements BeJSONFunctions {
|
|
|
82
82
|
/** Reverse the start and end angle in place. */
|
|
83
83
|
reverseInPlace(): void;
|
|
84
84
|
/** return a sweep for the "other" part of the circe.
|
|
85
|
-
* @param
|
|
85
|
+
* @param reverseDirection true to retain the start and move backwards, false to more forwards.
|
|
86
86
|
*/
|
|
87
87
|
cloneComplement(reverseDirection?: boolean, result?: AngleSweep): AngleSweep;
|
|
88
88
|
/** Restrict start and end angles into the range (-90,+90) in degrees. */
|
|
@@ -121,7 +121,7 @@ export class AngleSweep {
|
|
|
121
121
|
/** Reverse the start and end angle in place. */
|
|
122
122
|
reverseInPlace() { const a = this._radians0; this._radians0 = this._radians1; this._radians1 = a; }
|
|
123
123
|
/** return a sweep for the "other" part of the circe.
|
|
124
|
-
* @param
|
|
124
|
+
* @param reverseDirection true to retain the start and move backwards, false to more forwards.
|
|
125
125
|
*/
|
|
126
126
|
cloneComplement(reverseDirection = false, result) {
|
|
127
127
|
const s = this.sweepRadians >= 0 ? 2.0 : -2.0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AngleSweep.js","sourceRoot":"","sources":["../../../src/geometry3d/AngleSweep.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAoC,QAAQ,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,UAAU;IA+BrB;;;;;;;;;OASG;IACH,YAAoB,eAAuB,CAAC,EAAE,aAAqB,CAAC,IAAI,IAAI,CAAC,SAAS,GAAG,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC;IAtCrI,iEAAiE;IACjE,IAAW,YAAY,KAAK,OAAO,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC5E,+DAA+D;IAC/D,IAAW,UAAU,KAAK,OAAO,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC1E,8DAA8D;IAC9D,IAAW,YAAY,KAAK,OAAO,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC7F,iEAAiE;IACjE,IAAW,YAAY,KAAK,OAAO,IAAI,C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,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;eAC7E,KAAK,CAAC,iCAAiC,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;IACnH,CAAC;IACD,uGAAuG;IAChG,0BAA0B,CAAC,KAAiB;QACjD,OAAO,KAAK,CAAC,iCAAiC,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;eAC1E,KAAK,CAAC,iCAAiC,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;IACnH,CAAC;IACD;;;;;;OAMG;IACI,aAAa,CAAC,KAAiB,IAAa,OAAO,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;CACpG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module CartesianGeometry\n */\n\nimport { AngleSweepProps, BeJSONFunctions, Geometry } from \"../Geometry\";\nimport { Angle } from \"./Angle\";\nimport { GrowableFloat64Array } from \"./GrowableFloat64Array\";\n\n/**\n * An `AngleSweep` is a pair of angles at start and end of an interval.\n *\n * * For stroking purposes, the \"included interval\" is all angles numerically reached by theta = start + f*(end-start), where f is between 0 and 1.\n * * This stroking formula is simple numbers -- 2PI shifts are not involved.\n * * 2PI shifts do become important in the reverse mapping of an angle to a fraction.\n * * If (start < end) the angle proceeds CCW around the unit circle.\n * * If (end < start) the angle proceeds CW around the unit circle.\n * * Angles beyond 360 are fine as endpoints.\n * * (350,370) covers the same unit angles as (-10,10).\n * * (370,350) covers the same unit angles as (10,-10).\n * @public\n */\nexport class AngleSweep implements BeJSONFunctions {\n private _radians0: number;\n private _radians1: number;\n /** Read-property for degrees at the start of this AngleSweep. */\n public get startDegrees() { return Angle.radiansToDegrees(this._radians0); }\n /** Read-property for degrees at the end of this AngleSweep. */\n public get endDegrees() { return Angle.radiansToDegrees(this._radians1); }\n /** Read-property for signed start-to-end sweep in degrees. */\n public get sweepDegrees() { return Angle.radiansToDegrees(this._radians1 - this._radians0); }\n /** Read-property for degrees at the start of this AngleSweep. */\n public get startRadians() { return this._radians0; }\n /** Read-property for degrees at the end of this AngleSweep. */\n public get endRadians() { return this._radians1; }\n /** Read-property for signed start-to-end sweep in radians. */\n public get sweepRadians() { return this._radians1 - this._radians0; }\n /** Return the (strongly typed) start angle */\n public get startAngle() { return Angle.createRadians(this._radians0); }\n /** Return the (strongly typed) end angle */\n public get endAngle() { return Angle.createRadians(this._radians1); }\n /** Create a sweep as one of\n * * A clone of a given sweep\n * * 0 to given angle\n * * full circle if no arg given (sweep 0 to 360 degrees)\n */\n public static create(data?: AngleSweep | Angle): AngleSweep {\n if (data instanceof AngleSweep)\n return data.clone();\n if (data instanceof Angle)\n return new AngleSweep(0, data.radians);\n return AngleSweep.create360();\n }\n /** (private) constructor with start and end angles in radians.\n * * Use explicitly named static methods to clarify intent and units of inputs:\n *\n * * createStartEndRadians (startRadians:number, endRadians:number)\n * * createStartEndDegrees (startDegrees:number, endDegrees:number)\n * * createStartEnd (startAngle:Angle, endAngle:Angle)\n * * createStartSweepRadians (startRadians:number, sweepRadians:number)\n * * createStartSweepDegrees (startDegrees:number, sweepDegrees:number)\n * * createStartSweep (startAngle:Angle, sweepAngle:Angle)\n */\n private constructor(startRadians: number = 0, endRadians: number = 0) { this._radians0 = startRadians; this._radians1 = endRadians; }\n /** create an AngleSweep from start and end angles given in radians. */\n public static createStartEndRadians(startRadians: number = 0, endRadians: number = 2.0 * Math.PI, result?: AngleSweep): AngleSweep {\n result = result ? result : new AngleSweep();\n result.setStartEndRadians(startRadians, endRadians);\n return result;\n }\n /** Return the angle obtained by subtracting radians from this angle. */\n public cloneMinusRadians(radians: number): AngleSweep { return new AngleSweep(this._radians0 - radians, this._radians1 - radians); }\n /** create an AngleSweep from start and end angles given in degrees. */\n public static createStartEndDegrees(startDegrees: number = 0, endDegrees: number = 360, result?: AngleSweep): AngleSweep {\n return AngleSweep.createStartEndRadians(Angle.degreesToRadians(startDegrees), Angle.degreesToRadians(endDegrees), result);\n }\n /** create an angle sweep from strongly typed start and end angles */\n public static createStartEnd(startAngle: Angle, endAngle: Angle, result?: AngleSweep): AngleSweep {\n result = result ? result : new AngleSweep();\n result.setStartEndRadians(startAngle.radians, endAngle.radians);\n return result;\n }\n /** Create an angle sweep with limits given as (strongly typed) angles for start and sweep */\n public static createStartSweep(startAngle: Angle, sweepAngle: Angle, result?: AngleSweep): AngleSweep {\n return AngleSweep.createStartSweepRadians(startAngle.radians, sweepAngle.radians, result);\n }\n /** Return a sweep with limits interpolated between this and other. */\n public interpolate(fraction: number, other: AngleSweep): AngleSweep {\n return new AngleSweep(Geometry.interpolate(this._radians0, fraction, other._radians0), Geometry.interpolate(this._radians1, fraction, other._radians1));\n }\n /** create an AngleSweep from start and end angles given in radians. */\n public static createStartSweepRadians(startRadians: number = 0, sweepRadians: number = Math.PI, result?: AngleSweep): AngleSweep {\n result = result ? result : new AngleSweep();\n result.setStartEndRadians(startRadians, startRadians + sweepRadians);\n return result;\n }\n /** create an AngleSweep from start and sweep given in degrees. */\n public static createStartSweepDegrees(startDegrees: number = 0, sweepDegrees: number = 360, result?: AngleSweep): AngleSweep {\n return AngleSweep.createStartEndRadians(Angle.degreesToRadians(startDegrees), Angle.degreesToRadians(startDegrees + sweepDegrees), result);\n }\n /** directly set the start and end angles in radians */\n public setStartEndRadians(startRadians: number = 0, endRadians: number = 2.0 * Math.PI) {\n const delta = endRadians - startRadians;\n if (Angle.isFullCircleRadians(delta)) {\n endRadians = startRadians + (delta > 0 ? 2.0 : -2.0) * Math.PI;\n }\n this._radians0 = startRadians;\n this._radians1 = endRadians;\n }\n /** directly set the start and end angles in degrees */\n public setStartEndDegrees(startDegrees: number = 0, endDegrees: number = 360.0) {\n this.setStartEndRadians(Angle.degreesToRadians(startDegrees), Angle.degreesToRadians(endDegrees));\n }\n /** copy from other AngleSweep. */\n public setFrom(other: AngleSweep) { this._radians0 = other._radians0; this._radians1 = other._radians1; }\n /** create a full circle sweep (CCW). startRadians defaults to 0 */\n public static create360(startRadians?: number): AngleSweep {\n startRadians = startRadians ? startRadians : 0.0;\n return new AngleSweep(startRadians, startRadians + 2.0 * Math.PI);\n }\n /** create a sweep from the south pole to the north pole. */\n public static createFullLatitude() { return AngleSweep.createStartEndRadians(-0.5 * Math.PI, 0.5 * Math.PI); }\n /** Reverse the start and end angle in place. */\n public reverseInPlace() { const a = this._radians0; this._radians0 = this._radians1; this._radians1 = a; }\n /** return a sweep for the \"other\" part of the circe.\n * @param reverse true to retain the start and move backwards, false to more forwards.\n */\n public cloneComplement(reverseDirection: boolean = false, result?: AngleSweep): AngleSweep {\n const s = this.sweepRadians >= 0 ? 2.0 : -2.0;\n if (reverseDirection)\n return AngleSweep.createStartEndRadians(this.startRadians, this.endRadians - s * Math.PI, result);\n else\n return AngleSweep.createStartEndRadians(this.endRadians, this.startRadians + s * Math.PI, result);\n }\n /** Restrict start and end angles into the range (-90,+90) in degrees. */\n public capLatitudeInPlace() {\n const limit = 0.5 * Math.PI;\n this._radians0 = Geometry.clampToStartEnd(this._radians0, -limit, limit);\n this._radians1 = Geometry.clampToStartEnd(this._radians1, -limit, limit);\n }\n /** Ask if the sweep is counterclockwise, i.e. positive sweep */\n public get isCCW(): boolean { return this._radians1 >= this._radians0; }\n /** Ask if the sweep is a full circle. */\n public get isFullCircle(): boolean { return Angle.isFullCircleRadians(this.sweepRadians); }\n /** Ask if the sweep is a full sweep from south pole to north pole. */\n public get isFullLatitudeSweep(): boolean {\n const a = Math.PI * 0.5;\n return Angle.isAlmostEqualRadiansNoPeriodShift(this._radians0, -a)\n && Angle.isAlmostEqualRadiansNoPeriodShift(this._radians1, a);\n }\n /** return a clone of this sweep. */\n public clone(): AngleSweep { return new AngleSweep(this._radians0, this._radians1); }\n /** Convert fractional position in the sweep to radians. */\n public fractionToRadians(fraction: number) {\n return fraction < 0.5 ?\n this._radians0 + fraction * (this._radians1 - this._radians0)\n : this._radians1 + (fraction - 1.0) * (this._radians1 - this._radians0);\n }\n /** Convert fractional position in the sweep to strongly typed Angle object. */\n public fractionToAngle(fraction: number) {\n return Angle.createRadians(this.fractionToRadians(fraction));\n }\n /** return 2PI divided by the sweep radians (i.e. 360 degrees divided by sweep angle).\n * This is the number of fractional intervals required to cover a whole circle.\n */\n public fractionPeriod(): number {\n return Geometry.safeDivideFraction(Math.PI * 2.0, Math.abs(this._radians1 - this._radians0), 1.0);\n }\n /** return the fractionalized position of the angle,\n * computed without consideration of 2PI period.\n * That is, an angle that is numerically much beyond than the end angle\n * will produce a large fraction and an angle much beyond the start angle\n * will produce a large negative fraction.\n *\n */\n public angleToUnboundedFraction(theta: Angle): number {\n return Geometry.safeDivideFraction(theta.radians - this._radians0, this._radians1 - this._radians0, 1.0);\n }\n /** map an angle to a fractional coordinate which is:\n *\n * * the start angle is at fraction 0\n * * the end angle is at fraction 1\n * * interior angles are between 0 and 1\n * * all exterior angles are at fractions greater than 1\n * * the periodic jump is at full wraparound to the start angle\n */\n public angleToPositivePeriodicFraction(theta: Angle): number { return this.radiansToPositivePeriodicFraction(theta.radians); }\n /**\n * Convert each value in an array from radians to fraction.\n * @param data array that is input as radians, output as fractions\n */\n public radiansArrayToPositivePeriodicFractions(data: GrowableFloat64Array) {\n const n = data.length;\n for (let i = 0; i < n; i++) {\n data.reassign(i, this.radiansToPositivePeriodicFraction(data.atUncheckedIndex(i)));\n }\n }\n /**\n * Convert a radians value to a fraction that is always positive and can wrap. See `angleToPositivePeriodicFraction` for detailed description.\n * @param radians\n */\n public radiansToPositivePeriodicFraction(radians: number, zeroSweepDefault: number = 0.0): number {\n return AngleSweep.radiansToPositivePeriodicFractionStartEnd(radians, this._radians0, this._radians1, zeroSweepDefault);\n }\n /**\n * Convert a radians value to a fraction that is always positive and can wrap. See `angleToPositivePeriodicFraction` for detailed description.\n * @param radians\n */\n public static radiansToPositivePeriodicFractionStartEnd(radians: number, radians0: number, radians1: number, zeroSweepDefault: number = 0.0): number {\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(radians, radians0))\n return 0.0;\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(radians, radians1))\n return 1.0;\n const sweep = radians1 - radians0;\n const delta = radians - radians0;\n if (sweep > 0) {\n const delta1 = Angle.adjustRadians0To2Pi(delta);\n const fraction1 = Geometry.safeDivideFraction(delta1, sweep, zeroSweepDefault);\n return fraction1;\n }\n const delta2 = Angle.adjustRadians0To2Pi(-delta);\n const fraction2 = Geometry.safeDivideFraction(delta2, -sweep, zeroSweepDefault);\n return fraction2;\n }\n /** map an angle to a fractional coordinate which is:\n *\n * * the start angle is at fraction 0\n * * the end angle is at fraction 1\n * * interior angles are between 0 and 1\n * * small negative for angles just \"before\" the start angle\n * * more than one for angles just \"after\" the end angle\n * * the periodic jump is at the middle of the \"outside\" interval\n */\n public angleToSignedPeriodicFraction(theta: Angle): number {\n return this.radiansToSignedPeriodicFraction(theta.radians);\n }\n /**\n * Convert a radians value to a fraction, allowing wraparound. See `angleToSignedPeriodicFraction` for detailed description.\n */\n public radiansToSignedPeriodicFraction(radians: number): number {\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(radians, this._radians0))\n return 0.0;\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(radians, this._radians1))\n return 1.0;\n const sweep = this._radians1 - this._radians0;\n // measure from middle of interval ...\n const delta = radians - this._radians0 - 0.5 * sweep;\n if (sweep > 0) {\n const delta1 = Angle.adjustRadiansMinusPiPlusPi(delta);\n const fraction1 = 0.5 + Geometry.safeDivideFraction(delta1, sweep, 0.0);\n return fraction1;\n }\n const delta2 = Angle.adjustRadiansMinusPiPlusPi(-delta);\n const fraction = 0.5 + Geometry.safeDivideFraction(delta2, -sweep, 0.0);\n return fraction;\n }\n /** test if an angle is within the sweep */\n public isAngleInSweep(angle: Angle): boolean { return this.isRadiansInSweep(angle.radians); }\n /** test if radians are within sweep */\n public isRadiansInSweep(radians: number, allowPeriodShift: boolean = true): boolean {\n return AngleSweep.isRadiansInStartEnd(radians, this.startRadians, this.endRadians, allowPeriodShift);\n }\n /** test if radians are within sweep */\n public static isRadiansInStartEnd(radians: number, radians0: number, radians1: number, allowPeriodShift: boolean = true): boolean {\n // quick out for simple inside ...\n const delta0 = radians - radians0;\n const delta1 = radians - radians1;\n if (delta0 * delta1 <= 0.0)\n return true;\n\n if (radians0 === radians1)\n return allowPeriodShift ? Angle.isAlmostEqualRadiansAllowPeriodShift(radians, radians0) : Angle.isAlmostEqualRadiansNoPeriodShift(radians, radians0);\n return allowPeriodShift ? this.radiansToPositivePeriodicFractionStartEnd(radians, radians0, radians1, 1000.0) <= 1.0 : false;\n }\n\n /** set this AngleSweep from various sources:\n *\n * * if json is undefined, a full-circle sweep is returned.\n * * If json is an AngleSweep object it is cloned\n * * If json is an array of 2 numbers, those numbers are start and end angles in degrees.\n * * If `json.degrees` is an array of 2 numbers, those numbers are start and end angles in degrees.\n * * If `json.radians` is an array of 2 numbers, those numbers are start and end angles in radians.\n */\n public setFromJSON(json?: any) {\n if (!json)\n this.setStartEndRadians(); // default full circle\n else if (json instanceof AngleSweep)\n this.setFrom(json);\n else if (Geometry.isNumberArray(json.degrees, 2))\n this.setStartEndDegrees(json.degrees[0], json.degrees[1]);\n else if (Geometry.isNumberArray(json.radians, 2))\n this.setStartEndRadians(json.radians[0], json.radians[1]);\n else if (Geometry.isNumberArray(json, 2))\n this.setStartEndDegrees(json[0], json[1]);\n }\n /** create an AngleSweep from a json object. */\n public static fromJSON(json?: AngleSweepProps) {\n const result = AngleSweep.create360();\n result.setFromJSON(json);\n return result;\n }\n /**\n * Convert an AngleSweep to a JSON object.\n * @return {*} {degrees: [startAngleInDegrees, endAngleInDegrees}\n */\n public toJSON(): any {\n // return { degrees: [this.startDegrees, this.endDegrees] };\n return [this.startDegrees, this.endDegrees];\n }\n /** test if start and end angles match, with explicit name to clarify that there is no test for 360-degree shifts. */\n public isAlmostEqualAllowPeriodShift(other: AngleSweep): boolean {\n return Angle.isAlmostEqualRadiansAllowPeriodShift(this._radians0, other._radians0)\n && Angle.isAlmostEqualRadiansNoPeriodShift(this._radians1 - this._radians0, other._radians1 - other._radians0);\n }\n /** test if start and end angles match, explicit name to clarify that 360-degree shifts are allowed. */\n public isAlmostEqualNoPeriodShift(other: AngleSweep): boolean {\n return Angle.isAlmostEqualRadiansNoPeriodShift(this._radians0, other._radians0)\n && Angle.isAlmostEqualRadiansNoPeriodShift(this._radians1 - this._radians0, other._radians1 - other._radians0);\n }\n /** test if start and end angles match with radians tolerance.\n * * This is equivalent to isAlmostEqualNoPeriodShift.\n * * it is present for consistency with other classes\n * * It is recommended that all callers use one of he longer names to be clear of their intentions:\n * * * isAlmostEqualAllowPeriodShift\n * * * isAlmostEqualRadiansNoPeriodShift\n */\n public isAlmostEqual(other: AngleSweep): boolean { return this.isAlmostEqualNoPeriodShift(other); }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AngleSweep.js","sourceRoot":"","sources":["../../../src/geometry3d/AngleSweep.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAoC,QAAQ,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,UAAU;IA+BrB;;;;;;;;;OASG;IACH,YAAoB,eAAuB,CAAC,EAAE,aAAqB,CAAC,IAAI,IAAI,CAAC,SAAS,GAAG,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC;IAtCrI,iEAAiE;IACjE,IAAW,YAAY,KAAK,OAAO,KAAK,CAAC,gBAAgB,CAAC,IAAI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B;QAC3C,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;QACtC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACzB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD;;;OAGG;IACI,MAAM;QACX,4DAA4D;QAC5D,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC9C,CAAC;IACD,qHAAqH;IAC9G,6BAA6B,CAAC,KAAiB;QACpD,OAAO,KAAK,CAAC,oCAAoC,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;eAC7E,KAAK,CAAC,iCAAiC,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;IACnH,CAAC;IACD,uGAAuG;IAChG,0BAA0B,CAAC,KAAiB;QACjD,OAAO,KAAK,CAAC,iCAAiC,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;eAC1E,KAAK,CAAC,iCAAiC,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;IACnH,CAAC;IACD;;;;;;OAMG;IACI,aAAa,CAAC,KAAiB,IAAa,OAAO,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;CACpG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module CartesianGeometry\n */\n\nimport { AngleSweepProps, BeJSONFunctions, Geometry } from \"../Geometry\";\nimport { Angle } from \"./Angle\";\nimport { GrowableFloat64Array } from \"./GrowableFloat64Array\";\n\n/**\n * An `AngleSweep` is a pair of angles at start and end of an interval.\n *\n * * For stroking purposes, the \"included interval\" is all angles numerically reached by theta = start + f*(end-start), where f is between 0 and 1.\n * * This stroking formula is simple numbers -- 2PI shifts are not involved.\n * * 2PI shifts do become important in the reverse mapping of an angle to a fraction.\n * * If (start < end) the angle proceeds CCW around the unit circle.\n * * If (end < start) the angle proceeds CW around the unit circle.\n * * Angles beyond 360 are fine as endpoints.\n * * (350,370) covers the same unit angles as (-10,10).\n * * (370,350) covers the same unit angles as (10,-10).\n * @public\n */\nexport class AngleSweep implements BeJSONFunctions {\n private _radians0: number;\n private _radians1: number;\n /** Read-property for degrees at the start of this AngleSweep. */\n public get startDegrees() { return Angle.radiansToDegrees(this._radians0); }\n /** Read-property for degrees at the end of this AngleSweep. */\n public get endDegrees() { return Angle.radiansToDegrees(this._radians1); }\n /** Read-property for signed start-to-end sweep in degrees. */\n public get sweepDegrees() { return Angle.radiansToDegrees(this._radians1 - this._radians0); }\n /** Read-property for degrees at the start of this AngleSweep. */\n public get startRadians() { return this._radians0; }\n /** Read-property for degrees at the end of this AngleSweep. */\n public get endRadians() { return this._radians1; }\n /** Read-property for signed start-to-end sweep in radians. */\n public get sweepRadians() { return this._radians1 - this._radians0; }\n /** Return the (strongly typed) start angle */\n public get startAngle() { return Angle.createRadians(this._radians0); }\n /** Return the (strongly typed) end angle */\n public get endAngle() { return Angle.createRadians(this._radians1); }\n /** Create a sweep as one of\n * * A clone of a given sweep\n * * 0 to given angle\n * * full circle if no arg given (sweep 0 to 360 degrees)\n */\n public static create(data?: AngleSweep | Angle): AngleSweep {\n if (data instanceof AngleSweep)\n return data.clone();\n if (data instanceof Angle)\n return new AngleSweep(0, data.radians);\n return AngleSweep.create360();\n }\n /** (private) constructor with start and end angles in radians.\n * * Use explicitly named static methods to clarify intent and units of inputs:\n *\n * * createStartEndRadians (startRadians:number, endRadians:number)\n * * createStartEndDegrees (startDegrees:number, endDegrees:number)\n * * createStartEnd (startAngle:Angle, endAngle:Angle)\n * * createStartSweepRadians (startRadians:number, sweepRadians:number)\n * * createStartSweepDegrees (startDegrees:number, sweepDegrees:number)\n * * createStartSweep (startAngle:Angle, sweepAngle:Angle)\n */\n private constructor(startRadians: number = 0, endRadians: number = 0) { this._radians0 = startRadians; this._radians1 = endRadians; }\n /** create an AngleSweep from start and end angles given in radians. */\n public static createStartEndRadians(startRadians: number = 0, endRadians: number = 2.0 * Math.PI, result?: AngleSweep): AngleSweep {\n result = result ? result : new AngleSweep();\n result.setStartEndRadians(startRadians, endRadians);\n return result;\n }\n /** Return the angle obtained by subtracting radians from this angle. */\n public cloneMinusRadians(radians: number): AngleSweep { return new AngleSweep(this._radians0 - radians, this._radians1 - radians); }\n /** create an AngleSweep from start and end angles given in degrees. */\n public static createStartEndDegrees(startDegrees: number = 0, endDegrees: number = 360, result?: AngleSweep): AngleSweep {\n return AngleSweep.createStartEndRadians(Angle.degreesToRadians(startDegrees), Angle.degreesToRadians(endDegrees), result);\n }\n /** create an angle sweep from strongly typed start and end angles */\n public static createStartEnd(startAngle: Angle, endAngle: Angle, result?: AngleSweep): AngleSweep {\n result = result ? result : new AngleSweep();\n result.setStartEndRadians(startAngle.radians, endAngle.radians);\n return result;\n }\n /** Create an angle sweep with limits given as (strongly typed) angles for start and sweep */\n public static createStartSweep(startAngle: Angle, sweepAngle: Angle, result?: AngleSweep): AngleSweep {\n return AngleSweep.createStartSweepRadians(startAngle.radians, sweepAngle.radians, result);\n }\n /** Return a sweep with limits interpolated between this and other. */\n public interpolate(fraction: number, other: AngleSweep): AngleSweep {\n return new AngleSweep(Geometry.interpolate(this._radians0, fraction, other._radians0), Geometry.interpolate(this._radians1, fraction, other._radians1));\n }\n /** create an AngleSweep from start and end angles given in radians. */\n public static createStartSweepRadians(startRadians: number = 0, sweepRadians: number = Math.PI, result?: AngleSweep): AngleSweep {\n result = result ? result : new AngleSweep();\n result.setStartEndRadians(startRadians, startRadians + sweepRadians);\n return result;\n }\n /** create an AngleSweep from start and sweep given in degrees. */\n public static createStartSweepDegrees(startDegrees: number = 0, sweepDegrees: number = 360, result?: AngleSweep): AngleSweep {\n return AngleSweep.createStartEndRadians(Angle.degreesToRadians(startDegrees), Angle.degreesToRadians(startDegrees + sweepDegrees), result);\n }\n /** directly set the start and end angles in radians */\n public setStartEndRadians(startRadians: number = 0, endRadians: number = 2.0 * Math.PI) {\n const delta = endRadians - startRadians;\n if (Angle.isFullCircleRadians(delta)) {\n endRadians = startRadians + (delta > 0 ? 2.0 : -2.0) * Math.PI;\n }\n this._radians0 = startRadians;\n this._radians1 = endRadians;\n }\n /** directly set the start and end angles in degrees */\n public setStartEndDegrees(startDegrees: number = 0, endDegrees: number = 360.0) {\n this.setStartEndRadians(Angle.degreesToRadians(startDegrees), Angle.degreesToRadians(endDegrees));\n }\n /** copy from other AngleSweep. */\n public setFrom(other: AngleSweep) { this._radians0 = other._radians0; this._radians1 = other._radians1; }\n /** create a full circle sweep (CCW). startRadians defaults to 0 */\n public static create360(startRadians?: number): AngleSweep {\n startRadians = startRadians ? startRadians : 0.0;\n return new AngleSweep(startRadians, startRadians + 2.0 * Math.PI);\n }\n /** create a sweep from the south pole to the north pole. */\n public static createFullLatitude() { return AngleSweep.createStartEndRadians(-0.5 * Math.PI, 0.5 * Math.PI); }\n /** Reverse the start and end angle in place. */\n public reverseInPlace() { const a = this._radians0; this._radians0 = this._radians1; this._radians1 = a; }\n /** return a sweep for the \"other\" part of the circe.\n * @param reverseDirection true to retain the start and move backwards, false to more forwards.\n */\n public cloneComplement(reverseDirection: boolean = false, result?: AngleSweep): AngleSweep {\n const s = this.sweepRadians >= 0 ? 2.0 : -2.0;\n if (reverseDirection)\n return AngleSweep.createStartEndRadians(this.startRadians, this.endRadians - s * Math.PI, result);\n else\n return AngleSweep.createStartEndRadians(this.endRadians, this.startRadians + s * Math.PI, result);\n }\n /** Restrict start and end angles into the range (-90,+90) in degrees. */\n public capLatitudeInPlace() {\n const limit = 0.5 * Math.PI;\n this._radians0 = Geometry.clampToStartEnd(this._radians0, -limit, limit);\n this._radians1 = Geometry.clampToStartEnd(this._radians1, -limit, limit);\n }\n /** Ask if the sweep is counterclockwise, i.e. positive sweep */\n public get isCCW(): boolean { return this._radians1 >= this._radians0; }\n /** Ask if the sweep is a full circle. */\n public get isFullCircle(): boolean { return Angle.isFullCircleRadians(this.sweepRadians); }\n /** Ask if the sweep is a full sweep from south pole to north pole. */\n public get isFullLatitudeSweep(): boolean {\n const a = Math.PI * 0.5;\n return Angle.isAlmostEqualRadiansNoPeriodShift(this._radians0, -a)\n && Angle.isAlmostEqualRadiansNoPeriodShift(this._radians1, a);\n }\n /** return a clone of this sweep. */\n public clone(): AngleSweep { return new AngleSweep(this._radians0, this._radians1); }\n /** Convert fractional position in the sweep to radians. */\n public fractionToRadians(fraction: number) {\n return fraction < 0.5 ?\n this._radians0 + fraction * (this._radians1 - this._radians0)\n : this._radians1 + (fraction - 1.0) * (this._radians1 - this._radians0);\n }\n /** Convert fractional position in the sweep to strongly typed Angle object. */\n public fractionToAngle(fraction: number) {\n return Angle.createRadians(this.fractionToRadians(fraction));\n }\n /** return 2PI divided by the sweep radians (i.e. 360 degrees divided by sweep angle).\n * This is the number of fractional intervals required to cover a whole circle.\n */\n public fractionPeriod(): number {\n return Geometry.safeDivideFraction(Math.PI * 2.0, Math.abs(this._radians1 - this._radians0), 1.0);\n }\n /** return the fractionalized position of the angle,\n * computed without consideration of 2PI period.\n * That is, an angle that is numerically much beyond than the end angle\n * will produce a large fraction and an angle much beyond the start angle\n * will produce a large negative fraction.\n *\n */\n public angleToUnboundedFraction(theta: Angle): number {\n return Geometry.safeDivideFraction(theta.radians - this._radians0, this._radians1 - this._radians0, 1.0);\n }\n /** map an angle to a fractional coordinate which is:\n *\n * * the start angle is at fraction 0\n * * the end angle is at fraction 1\n * * interior angles are between 0 and 1\n * * all exterior angles are at fractions greater than 1\n * * the periodic jump is at full wraparound to the start angle\n */\n public angleToPositivePeriodicFraction(theta: Angle): number { return this.radiansToPositivePeriodicFraction(theta.radians); }\n /**\n * Convert each value in an array from radians to fraction.\n * @param data array that is input as radians, output as fractions\n */\n public radiansArrayToPositivePeriodicFractions(data: GrowableFloat64Array) {\n const n = data.length;\n for (let i = 0; i < n; i++) {\n data.reassign(i, this.radiansToPositivePeriodicFraction(data.atUncheckedIndex(i)));\n }\n }\n /**\n * Convert a radians value to a fraction that is always positive and can wrap. See `angleToPositivePeriodicFraction` for detailed description.\n * @param radians\n */\n public radiansToPositivePeriodicFraction(radians: number, zeroSweepDefault: number = 0.0): number {\n return AngleSweep.radiansToPositivePeriodicFractionStartEnd(radians, this._radians0, this._radians1, zeroSweepDefault);\n }\n /**\n * Convert a radians value to a fraction that is always positive and can wrap. See `angleToPositivePeriodicFraction` for detailed description.\n * @param radians\n */\n public static radiansToPositivePeriodicFractionStartEnd(radians: number, radians0: number, radians1: number, zeroSweepDefault: number = 0.0): number {\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(radians, radians0))\n return 0.0;\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(radians, radians1))\n return 1.0;\n const sweep = radians1 - radians0;\n const delta = radians - radians0;\n if (sweep > 0) {\n const delta1 = Angle.adjustRadians0To2Pi(delta);\n const fraction1 = Geometry.safeDivideFraction(delta1, sweep, zeroSweepDefault);\n return fraction1;\n }\n const delta2 = Angle.adjustRadians0To2Pi(-delta);\n const fraction2 = Geometry.safeDivideFraction(delta2, -sweep, zeroSweepDefault);\n return fraction2;\n }\n /** map an angle to a fractional coordinate which is:\n *\n * * the start angle is at fraction 0\n * * the end angle is at fraction 1\n * * interior angles are between 0 and 1\n * * small negative for angles just \"before\" the start angle\n * * more than one for angles just \"after\" the end angle\n * * the periodic jump is at the middle of the \"outside\" interval\n */\n public angleToSignedPeriodicFraction(theta: Angle): number {\n return this.radiansToSignedPeriodicFraction(theta.radians);\n }\n /**\n * Convert a radians value to a fraction, allowing wraparound. See `angleToSignedPeriodicFraction` for detailed description.\n */\n public radiansToSignedPeriodicFraction(radians: number): number {\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(radians, this._radians0))\n return 0.0;\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(radians, this._radians1))\n return 1.0;\n const sweep = this._radians1 - this._radians0;\n // measure from middle of interval ...\n const delta = radians - this._radians0 - 0.5 * sweep;\n if (sweep > 0) {\n const delta1 = Angle.adjustRadiansMinusPiPlusPi(delta);\n const fraction1 = 0.5 + Geometry.safeDivideFraction(delta1, sweep, 0.0);\n return fraction1;\n }\n const delta2 = Angle.adjustRadiansMinusPiPlusPi(-delta);\n const fraction = 0.5 + Geometry.safeDivideFraction(delta2, -sweep, 0.0);\n return fraction;\n }\n /** test if an angle is within the sweep */\n public isAngleInSweep(angle: Angle): boolean { return this.isRadiansInSweep(angle.radians); }\n /** test if radians are within sweep */\n public isRadiansInSweep(radians: number, allowPeriodShift: boolean = true): boolean {\n return AngleSweep.isRadiansInStartEnd(radians, this.startRadians, this.endRadians, allowPeriodShift);\n }\n /** test if radians are within sweep */\n public static isRadiansInStartEnd(radians: number, radians0: number, radians1: number, allowPeriodShift: boolean = true): boolean {\n // quick out for simple inside ...\n const delta0 = radians - radians0;\n const delta1 = radians - radians1;\n if (delta0 * delta1 <= 0.0)\n return true;\n\n if (radians0 === radians1)\n return allowPeriodShift ? Angle.isAlmostEqualRadiansAllowPeriodShift(radians, radians0) : Angle.isAlmostEqualRadiansNoPeriodShift(radians, radians0);\n return allowPeriodShift ? this.radiansToPositivePeriodicFractionStartEnd(radians, radians0, radians1, 1000.0) <= 1.0 : false;\n }\n\n /** set this AngleSweep from various sources:\n *\n * * if json is undefined, a full-circle sweep is returned.\n * * If json is an AngleSweep object it is cloned\n * * If json is an array of 2 numbers, those numbers are start and end angles in degrees.\n * * If `json.degrees` is an array of 2 numbers, those numbers are start and end angles in degrees.\n * * If `json.radians` is an array of 2 numbers, those numbers are start and end angles in radians.\n */\n public setFromJSON(json?: any) {\n if (!json)\n this.setStartEndRadians(); // default full circle\n else if (json instanceof AngleSweep)\n this.setFrom(json);\n else if (Geometry.isNumberArray(json.degrees, 2))\n this.setStartEndDegrees(json.degrees[0], json.degrees[1]);\n else if (Geometry.isNumberArray(json.radians, 2))\n this.setStartEndRadians(json.radians[0], json.radians[1]);\n else if (Geometry.isNumberArray(json, 2))\n this.setStartEndDegrees(json[0], json[1]);\n }\n /** create an AngleSweep from a json object. */\n public static fromJSON(json?: AngleSweepProps) {\n const result = AngleSweep.create360();\n result.setFromJSON(json);\n return result;\n }\n /**\n * Convert an AngleSweep to a JSON object.\n * @return {*} {degrees: [startAngleInDegrees, endAngleInDegrees}\n */\n public toJSON(): any {\n // return { degrees: [this.startDegrees, this.endDegrees] };\n return [this.startDegrees, this.endDegrees];\n }\n /** test if start and end angles match, with explicit name to clarify that there is no test for 360-degree shifts. */\n public isAlmostEqualAllowPeriodShift(other: AngleSweep): boolean {\n return Angle.isAlmostEqualRadiansAllowPeriodShift(this._radians0, other._radians0)\n && Angle.isAlmostEqualRadiansNoPeriodShift(this._radians1 - this._radians0, other._radians1 - other._radians0);\n }\n /** test if start and end angles match, explicit name to clarify that 360-degree shifts are allowed. */\n public isAlmostEqualNoPeriodShift(other: AngleSweep): boolean {\n return Angle.isAlmostEqualRadiansNoPeriodShift(this._radians0, other._radians0)\n && Angle.isAlmostEqualRadiansNoPeriodShift(this._radians1 - this._radians0, other._radians1 - other._radians0);\n }\n /** test if start and end angles match with radians tolerance.\n * * This is equivalent to isAlmostEqualNoPeriodShift.\n * * it is present for consistency with other classes\n * * It is recommended that all callers use one of he longer names to be clear of their intentions:\n * * * isAlmostEqualAllowPeriodShift\n * * * isAlmostEqualRadiansNoPeriodShift\n */\n public isAlmostEqual(other: AngleSweep): boolean { return this.isAlmostEqualNoPeriodShift(other); }\n}\n"]}
|
|
@@ -56,7 +56,7 @@ export declare class ClusterableArray extends GrowableBlockedArray {
|
|
|
56
56
|
*
|
|
57
57
|
* ** simple coordinate blocks (x,y) or (x,y,z) would work fine but have occasional performance problems because points with same x would generate big blocks of
|
|
58
58
|
* candidates for clusters.
|
|
59
|
-
* ** The usual solution is to u value which is a dot product along some skew direction and have the blocks contain (u,x,y) or (u,x,y,z) for 2d versus 3d.
|
|
59
|
+
* ** The usual solution is to sort by u value, which is a dot product along some skew direction, and have the blocks contain (u,x,y) or (u,x,y,z) for 2d versus 3d.
|
|
60
60
|
* ** apply setupPrimaryClusterSort to prepare that!!!
|
|
61
61
|
* * After a simple lexical sort, consecutive blocks that are within tolerance in the 0 component
|
|
62
62
|
* are inspected. Within that candidate set, all blocks that are within tolerance for ALL components are clustered.
|
|
@@ -88,9 +88,9 @@ export declare class ClusterableArray extends GrowableBlockedArray {
|
|
|
88
88
|
*/
|
|
89
89
|
createIndexClusterToClusterStart(clusteredBlocks: Uint32Array): Uint32Array;
|
|
90
90
|
/**
|
|
91
|
-
* Sort terminator-delimited subsets of an array of indices into the table, using a single
|
|
92
|
-
* @param blockedIndices
|
|
93
|
-
* @param
|
|
91
|
+
* Sort terminator-delimited subsets of an array of indices into the table, using a single data value as sort key.
|
|
92
|
+
* @param blockedIndices indices, organized as blocks of good indices terminated by the clusterTerminator. Each block is individually sorted on return.
|
|
93
|
+
* @param dataIndex index of the data key, e.g., if the sort key is the first extraData (angle) after x and y coordinate data, pass dataIndex = 2.
|
|
94
94
|
*/
|
|
95
95
|
sortSubsetsBySingleKey(blockedIndices: Uint32Array, dataIndex: number): void;
|
|
96
96
|
/**
|
|
@@ -120,7 +120,7 @@ export class ClusterableArray extends GrowableBlockedArray {
|
|
|
120
120
|
*
|
|
121
121
|
* ** simple coordinate blocks (x,y) or (x,y,z) would work fine but have occasional performance problems because points with same x would generate big blocks of
|
|
122
122
|
* candidates for clusters.
|
|
123
|
-
* ** The usual solution is to u value which is a dot product along some skew direction and have the blocks contain (u,x,y) or (u,x,y,z) for 2d versus 3d.
|
|
123
|
+
* ** The usual solution is to sort by u value, which is a dot product along some skew direction, and have the blocks contain (u,x,y) or (u,x,y,z) for 2d versus 3d.
|
|
124
124
|
* ** apply setupPrimaryClusterSort to prepare that!!!
|
|
125
125
|
* * After a simple lexical sort, consecutive blocks that are within tolerance in the 0 component
|
|
126
126
|
* are inspected. Within that candidate set, all blocks that are within tolerance for ALL components are clustered.
|
|
@@ -278,9 +278,9 @@ export class ClusterableArray extends GrowableBlockedArray {
|
|
|
278
278
|
return clusterToClusterStart;
|
|
279
279
|
}
|
|
280
280
|
/**
|
|
281
|
-
* Sort terminator-delimited subsets of an array of indices into the table, using a single
|
|
282
|
-
* @param blockedIndices
|
|
283
|
-
* @param
|
|
281
|
+
* Sort terminator-delimited subsets of an array of indices into the table, using a single data value as sort key.
|
|
282
|
+
* @param blockedIndices indices, organized as blocks of good indices terminated by the clusterTerminator. Each block is individually sorted on return.
|
|
283
|
+
* @param dataIndex index of the data key, e.g., if the sort key is the first extraData (angle) after x and y coordinate data, pass dataIndex = 2.
|
|
284
284
|
*/
|
|
285
285
|
sortSubsetsBySingleKey(blockedIndices, dataIndex) {
|
|
286
286
|
const dataOffset = 1 + dataIndex;
|
|
@@ -290,7 +290,7 @@ export class ClusterableArray extends GrowableBlockedArray {
|
|
|
290
290
|
const numK = blockedIndices.length;
|
|
291
291
|
for (let kEnd = 0; kEnd < numK; kEnd++) {
|
|
292
292
|
if (blockedIndices[kEnd] === ClusterableArray.clusterTerminator) {
|
|
293
|
-
// sort blockedIndices[kBegin
|
|
293
|
+
// bubble sort blockedIndices[kBegin <= k < kEnd].
|
|
294
294
|
// (search for minimum remaining, swap . . )
|
|
295
295
|
for (let k0 = kBegin; k0 + 1 < kEnd; k0++) {
|
|
296
296
|
key0 = this.getWithinBlock(blockedIndices[k0], dataOffset);
|