@itwin/core-geometry 3.3.0-dev.7 → 3.3.0-dev.70

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.
Files changed (140) hide show
  1. package/CHANGELOG.md +33 -1
  2. package/lib/cjs/curve/Arc3d.d.ts +13 -2
  3. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  4. package/lib/cjs/curve/Arc3d.js +21 -3
  5. package/lib/cjs/curve/Arc3d.js.map +1 -1
  6. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +36 -2
  7. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  8. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +157 -7
  9. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  10. package/lib/cjs/curve/CurveCollection.d.ts +2 -0
  11. package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
  12. package/lib/cjs/curve/CurveCollection.js +8 -0
  13. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  14. package/lib/cjs/curve/CurvePrimitive.d.ts +23 -0
  15. package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
  16. package/lib/cjs/curve/CurvePrimitive.js +65 -0
  17. package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
  18. package/lib/cjs/curve/LineSegment3d.d.ts +5 -0
  19. package/lib/cjs/curve/LineSegment3d.d.ts.map +1 -1
  20. package/lib/cjs/curve/LineSegment3d.js +21 -0
  21. package/lib/cjs/curve/LineSegment3d.js.map +1 -1
  22. package/lib/cjs/curve/LineString3d.d.ts +2 -0
  23. package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
  24. package/lib/cjs/curve/LineString3d.js +28 -0
  25. package/lib/cjs/curve/LineString3d.js.map +1 -1
  26. package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts +2 -5
  27. package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
  28. package/lib/cjs/curve/spiral/DirectSpiral3d.js +5 -7
  29. package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
  30. package/lib/cjs/curve/spiral/IntegratedSpiral3d.d.ts +0 -3
  31. package/lib/cjs/curve/spiral/IntegratedSpiral3d.d.ts.map +1 -1
  32. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js +0 -4
  33. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  34. package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts +7 -0
  35. package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
  36. package/lib/cjs/curve/spiral/TransitionSpiral3d.js +17 -0
  37. package/lib/cjs/curve/spiral/TransitionSpiral3d.js.map +1 -1
  38. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +1 -1
  39. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  40. package/lib/cjs/geometry3d/Point3dVector3d.js +2 -3
  41. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  42. package/lib/cjs/geometry3d/PolygonOps.d.ts +8 -2
  43. package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
  44. package/lib/cjs/geometry3d/PolygonOps.js +40 -3
  45. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  46. package/lib/cjs/geometry3d/Range.d.ts +12 -0
  47. package/lib/cjs/geometry3d/Range.d.ts.map +1 -1
  48. package/lib/cjs/geometry3d/Range.js +32 -0
  49. package/lib/cjs/geometry3d/Range.js.map +1 -1
  50. package/lib/cjs/geometry3d/Transform.d.ts +1 -1
  51. package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
  52. package/lib/cjs/geometry3d/Transform.js +1 -1
  53. package/lib/cjs/geometry3d/Transform.js.map +1 -1
  54. package/lib/cjs/geometry3d/XYZProps.d.ts +10 -3
  55. package/lib/cjs/geometry3d/XYZProps.d.ts.map +1 -1
  56. package/lib/cjs/geometry3d/XYZProps.js +21 -0
  57. package/lib/cjs/geometry3d/XYZProps.js.map +1 -1
  58. package/lib/cjs/polyface/PolyfaceClip.d.ts.map +1 -1
  59. package/lib/cjs/polyface/PolyfaceClip.js +1 -1
  60. package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
  61. package/lib/cjs/polyface/PolyfaceQuery.d.ts +4 -2
  62. package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
  63. package/lib/cjs/polyface/PolyfaceQuery.js +10 -6
  64. package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
  65. package/lib/cjs/topology/Merging.js +3 -3
  66. package/lib/cjs/topology/Merging.js.map +1 -1
  67. package/lib/cjs/topology/Triangulation.d.ts +1 -3
  68. package/lib/cjs/topology/Triangulation.d.ts.map +1 -1
  69. package/lib/cjs/topology/Triangulation.js +31 -21
  70. package/lib/cjs/topology/Triangulation.js.map +1 -1
  71. package/lib/esm/curve/Arc3d.d.ts +13 -2
  72. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  73. package/lib/esm/curve/Arc3d.js +22 -4
  74. package/lib/esm/curve/Arc3d.js.map +1 -1
  75. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +36 -2
  76. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  77. package/lib/esm/curve/CurveChainWithDistanceIndex.js +157 -7
  78. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  79. package/lib/esm/curve/CurveCollection.d.ts +2 -0
  80. package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
  81. package/lib/esm/curve/CurveCollection.js +8 -0
  82. package/lib/esm/curve/CurveCollection.js.map +1 -1
  83. package/lib/esm/curve/CurvePrimitive.d.ts +23 -0
  84. package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
  85. package/lib/esm/curve/CurvePrimitive.js +65 -0
  86. package/lib/esm/curve/CurvePrimitive.js.map +1 -1
  87. package/lib/esm/curve/LineSegment3d.d.ts +5 -0
  88. package/lib/esm/curve/LineSegment3d.d.ts.map +1 -1
  89. package/lib/esm/curve/LineSegment3d.js +21 -0
  90. package/lib/esm/curve/LineSegment3d.js.map +1 -1
  91. package/lib/esm/curve/LineString3d.d.ts +2 -0
  92. package/lib/esm/curve/LineString3d.d.ts.map +1 -1
  93. package/lib/esm/curve/LineString3d.js +28 -0
  94. package/lib/esm/curve/LineString3d.js.map +1 -1
  95. package/lib/esm/curve/spiral/DirectSpiral3d.d.ts +2 -5
  96. package/lib/esm/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
  97. package/lib/esm/curve/spiral/DirectSpiral3d.js +5 -7
  98. package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
  99. package/lib/esm/curve/spiral/IntegratedSpiral3d.d.ts +0 -3
  100. package/lib/esm/curve/spiral/IntegratedSpiral3d.d.ts.map +1 -1
  101. package/lib/esm/curve/spiral/IntegratedSpiral3d.js +0 -4
  102. package/lib/esm/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  103. package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts +7 -0
  104. package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
  105. package/lib/esm/curve/spiral/TransitionSpiral3d.js +17 -0
  106. package/lib/esm/curve/spiral/TransitionSpiral3d.js.map +1 -1
  107. package/lib/esm/geometry3d/Point3dVector3d.d.ts +1 -1
  108. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  109. package/lib/esm/geometry3d/Point3dVector3d.js +2 -3
  110. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  111. package/lib/esm/geometry3d/PolygonOps.d.ts +8 -2
  112. package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
  113. package/lib/esm/geometry3d/PolygonOps.js +40 -3
  114. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  115. package/lib/esm/geometry3d/Range.d.ts +12 -0
  116. package/lib/esm/geometry3d/Range.d.ts.map +1 -1
  117. package/lib/esm/geometry3d/Range.js +32 -0
  118. package/lib/esm/geometry3d/Range.js.map +1 -1
  119. package/lib/esm/geometry3d/Transform.d.ts +1 -1
  120. package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
  121. package/lib/esm/geometry3d/Transform.js +1 -1
  122. package/lib/esm/geometry3d/Transform.js.map +1 -1
  123. package/lib/esm/geometry3d/XYZProps.d.ts +10 -3
  124. package/lib/esm/geometry3d/XYZProps.d.ts.map +1 -1
  125. package/lib/esm/geometry3d/XYZProps.js +20 -1
  126. package/lib/esm/geometry3d/XYZProps.js.map +1 -1
  127. package/lib/esm/polyface/PolyfaceClip.d.ts.map +1 -1
  128. package/lib/esm/polyface/PolyfaceClip.js +1 -1
  129. package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
  130. package/lib/esm/polyface/PolyfaceQuery.d.ts +4 -2
  131. package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
  132. package/lib/esm/polyface/PolyfaceQuery.js +10 -6
  133. package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
  134. package/lib/esm/topology/Merging.js +3 -3
  135. package/lib/esm/topology/Merging.js.map +1 -1
  136. package/lib/esm/topology/Triangulation.d.ts +1 -3
  137. package/lib/esm/topology/Triangulation.d.ts.map +1 -1
  138. package/lib/esm/topology/Triangulation.js +31 -21
  139. package/lib/esm/topology/Triangulation.js.map +1 -1
  140. package/package.json +7 -7
@@ -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;Q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W,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACpC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,qBAAqB,CAAC,YAA6B;QAC/D,uEAAuE;QACvE,MAAM,KAAK,GAAG,IAAI,qBAAa,EAAE,CAAC;QAClC,gBAAgB,CAAC,wBAAwB,CAAC,YAAY,EAAE,KAAK,EAAE,oBAAY,CAAC,aAAa,CAAC,CAAC;QAC3F,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QAEnC,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;AA3UD,gDA2UC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Topology\r\n */\r\n\r\nimport { CurveLocationDetail } from \"../curve/CurveLocationDetail\";\r\nimport { LineSegment3d } from \"../curve/LineSegment3d\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Angle } from \"../geometry3d/Angle\";\r\nimport { Point2d, Vector2d } from \"../geometry3d/Point2dVector2d\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { ClusterableArray } from \"../numerics/ClusterableArray\";\r\nimport { SmallSystem } from \"../numerics/Polynomials\";\r\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask } from \"./Graph\";\r\nimport { HalfEdgePriorityQueueWithPartnerArray } from \"./HalfEdgePriorityQueue\";\r\nimport { RegularizationContext } from \"./RegularizeFace\";\r\nimport { MultiLineStringDataVariant, Triangulator } from \"./Triangulation\";\r\n\r\nexport class GraphSplitData {\r\n public numUpEdge = 0;\r\n public numIntersectionTest = 0;\r\n public numSplit = 0;\r\n public numPopOut = 0;\r\n public numA0B0 = 0;\r\n public numA0B1 = 0;\r\n public constructor() {\r\n }\r\n}\r\n/**\r\n * Structure for data used when sorting outbound edges \"around a node\"\r\n */\r\nexport class VertexNeighborhoodSortData {\r\n public index: number;\r\n public radiusOfCurvature: number;\r\n public node: HalfEdge;\r\n public radians?: number;\r\n public constructor(index: number, key: number, node: HalfEdge, radians?: number) {\r\n this.index = index;\r\n this.radiusOfCurvature = key;\r\n this.node = node;\r\n this.radians = radians;\r\n }\r\n}\r\n\r\n/** Function signature for announcing a vertex neighborhood during sorting. */\r\nexport type AnnounceVertexNeighborhoodSortData = (data: VertexNeighborhoodSortData[]) => any;\r\n/**\r\n * * Assorted methods used in algorithms on HalfEdgeGraph.\r\n * @internal\r\n */\r\nexport class HalfEdgeGraphOps {\r\n\r\n /** Compare function for sorting with primary y compare, secondary x compare. */\r\n public static compareNodesYXUp(a: HalfEdge, b: HalfEdge) {\r\n // Check y's\r\n // if (!Geometry.isSameCoordinate(a.y, b.y))\r\n if (a.y < b.y)\r\n return -1;\r\n else if (a.y > b.y)\r\n return 1;\r\n // Check x's\r\n // if (!Geometry.isSameCoordinate(a.x, b.x))\r\n if (a.x < b.x)\r\n return -1;\r\n else if (a.x > b.x)\r\n return 1;\r\n return 0;\r\n }\r\n\r\n /** Return true if nodeB (a) is lower than both its neighbors and (b) inflects as a downward peak (rather than an upward trough) */\r\n public static isDownPeak(nodeB: HalfEdge) {\r\n const nodeA = nodeB.facePredecessor;\r\n const nodeC = nodeB.faceSuccessor;\r\n return this.compareNodesYXUp(nodeB, nodeA) < 0\r\n && this.compareNodesYXUp(nodeB, nodeC) < 0\r\n && this.crossProductToTargets(nodeB, nodeA, nodeC) > 0;\r\n }\r\n\r\n /** return the cross product of vectors from base to targetA and base to targetB\r\n * @param base base vertex of both vectors.\r\n * @param targetA target vertex of first vector\r\n * @param targetB target vertex of second vector\r\n */\r\n public static crossProductToTargets(base: HalfEdge, targetA: HalfEdge, targetB: HalfEdge): number {\r\n return Geometry.crossProductXYXY(targetA.x - base.x, targetA.y - base.y, targetB.x - base.x, targetB.y - base.y);\r\n }\r\n\r\n // ---------------------------------------------------------------------------------------------------------------------\r\n // ----------------------------------------------------------------------------------------------------------------------\r\n\r\n public static graphRange(graph: HalfEdgeGraph): Range3d {\r\n const range = Range3d.create();\r\n for (const node of graph.allHalfEdges) {\r\n range.extendXYZ(node.x, node.y, node.z);\r\n }\r\n return range;\r\n }\r\n /** Returns an array of all nodes (both ends) of edges created from segments. */\r\n public static segmentArrayToGraphEdges(segments: LineSegment3d[], returnGraph: HalfEdgeGraph, mask: HalfEdgeMask): HalfEdge[] {\r\n const result = [];\r\n let idxCounter = 0;\r\n\r\n // Push the endpoints of each segment onto arr[] in the form {(x, y, theta), Node}\r\n for (const segment of segments) {\r\n\r\n const node0 = returnGraph.createEdgeXYZXYZ(\r\n segment.point0Ref.x, segment.point0Ref.y, segment.point0Ref.z,\r\n idxCounter,\r\n segment.point1Ref.x, segment.point1Ref.y, segment.point1Ref.z,\r\n idxCounter + 1);\r\n\r\n const node1 = node0.edgeMate;\r\n idxCounter += 2;\r\n\r\n node0.setMaskAroundFace(mask); // Original given coordinates must be part of boundary\r\n result.push(node0);\r\n result.push(node1);\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * * Visit all nodes in `graph`.\r\n * * invoke `pinch(node, vertexPredecessor)`\r\n * * this leaves the graph as isolated edges.\r\n * @param graph graph to modify\r\n */\r\n public static isolateAllEdges(graph: HalfEdgeGraph) {\r\n for (const nodeA of graph.allHalfEdges) {\r\n const nodeB = nodeA.vertexPredecessor;\r\n HalfEdge.pinch(nodeA, nodeB);\r\n }\r\n }\r\n\r\n /**\r\n * Compute convexity of a sector of a super-face.\r\n * @param base node whose edge is to be tested for removal\r\n * @param ignore edges with this mask (on either side) are ignored for the purposes of computing convexity\r\n * @param barrier edges with this mask (on either side) will not be removed\r\n * @return whether removing the edge at base would create a convex sector in the super-face\r\n */\r\n private static isSectorConvexAfterEdgeRemoval(base: HalfEdge, ignore: HalfEdgeMask, barrier: HalfEdgeMask): boolean {\r\n let vs = base;\r\n do { // loop ccw around vertex looking for a super-face predecessor\r\n if (vs.isMaskSet(barrier) || vs.edgeMate.isMaskSet(barrier))\r\n break;\r\n vs = vs.vertexSuccessor;\r\n } while (vs !== base && vs.isMaskSet(ignore));\r\n if (vs === base)\r\n return false;\r\n let vp = base;\r\n do { // loop cw around vertex looking for a super-face successor\r\n if (vp.isMaskSet(barrier) || vp.edgeMate.isMaskSet(barrier))\r\n break;\r\n vp = vp.vertexPredecessor;\r\n } while (vp !== base && vp.isMaskSet(ignore));\r\n if (vp === base)\r\n return false;\r\n return HalfEdge.isSectorConvex(vs.edgeMate, base, vp.faceSuccessor);\r\n }\r\n\r\n /**\r\n * Mask edges between faces if the union of the faces is convex.\r\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\r\n * Best results when input faces are convex.\r\n * @param graph graph to examine and mark\r\n * @param mark the mask used to mark (both sides of) removable edges\r\n * @param barrier edges with this mask (on either side) will not be marked. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\r\n * @return number of edges masked (half the number of HalfEdges masked)\r\n */\r\n public static markRemovableEdgesToExpandConvexFaces(graph: HalfEdgeGraph, mark: HalfEdgeMask, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): number {\r\n if (HalfEdgeMask.NULL_MASK === mark)\r\n return 0;\r\n const visit = graph.grabMask(true);\r\n let numMarked = 0;\r\n for (const node of graph.allHalfEdges) {\r\n if (!node.isMaskSet(visit)) {\r\n if (!node.isMaskSet(barrier) && !node.edgeMate.isMaskSet(barrier)) {\r\n if (this.isSectorConvexAfterEdgeRemoval(node, mark, barrier) && this.isSectorConvexAfterEdgeRemoval(node.edgeMate, mark, barrier)) {\r\n node.setMaskAroundEdge(mark);\r\n ++numMarked;\r\n }\r\n }\r\n }\r\n node.setMaskAroundEdge(visit);\r\n }\r\n return numMarked;\r\n }\r\n\r\n /**\r\n * Collect edges between faces if the union of the faces is convex.\r\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\r\n * Best results when input faces are convex.\r\n * @param graph graph to examine\r\n * @param barrier edges with this mask (on either side) will not be collected. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\r\n * @return one HalfEdge per removable edge\r\n */\r\n public static collectRemovableEdgesToExpandConvexFaces(graph: HalfEdgeGraph, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): HalfEdge[] | undefined {\r\n const removable: HalfEdge[] = [];\r\n const mark = graph.grabMask(true);\r\n if (0 < this.markRemovableEdgesToExpandConvexFaces(graph, mark, barrier)) {\r\n const visited = graph.grabMask(true);\r\n for (const node of graph.allHalfEdges) {\r\n if (node.isMaskSet(mark) && !node.isMaskSet(visited)) {\r\n node.setMaskAroundEdge(visited);\r\n removable.push(node);\r\n }\r\n }\r\n graph.dropMask(visited);\r\n }\r\n graph.dropMask(mark);\r\n return removable;\r\n }\r\n\r\n /**\r\n * Remove edges between faces if the union of the faces is convex.\r\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\r\n * Best results when input faces are convex.\r\n * @param graph graph to modify\r\n * @param barrier edges with this mask (on either side) will not be removed. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\r\n * @return number of edges deleted\r\n */\r\n public static expandConvexFaces(graph: HalfEdgeGraph, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): number {\r\n const mark = graph.grabMask(true);\r\n const numRemovedEdges = this.markRemovableEdgesToExpandConvexFaces(graph, mark, barrier);\r\n if (numRemovedEdges > 0)\r\n graph.yankAndDeleteEdges((node: HalfEdge) => node.getMask(mark));\r\n graph.dropMask(mark);\r\n return numRemovedEdges;\r\n }\r\n\r\n /**\r\n * Test desired faces for convexity.\r\n * @param graph graph to examine\r\n * @param avoid faces with this mask will not be examined. Defaults to HalfEdgeMask.EXTERIOR.\r\n * @return whether every face in the graph is convex\r\n */\r\n public static isEveryFaceConvex(graph: HalfEdgeGraph, avoid: HalfEdgeMask = HalfEdgeMask.EXTERIOR): boolean {\r\n const allFaces = graph.collectFaceLoops();\r\n for (const node of allFaces) {\r\n if (node.isMaskedAroundFace(avoid))\r\n continue;\r\n if (!node.isFaceConvex())\r\n return false;\r\n }\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class HalfEdgeGraphMerge {\r\n // return k2 <= kB such that stored angles (at extra data index 0 !) kA<=k<kC match.\r\n // * Note that the usual case (when angle at k0 is not repeated) is k0+1 === kC\r\n public static getCommonThetaEndIndex(clusters: ClusterableArray, order: Uint32Array, kA: number, kB: number): number{\r\n let kC = kA + 1;\r\n const thetaA = clusters.getExtraData(order[kA], 0);\r\n while (kC < kB) {\r\n const thetaB = clusters.getExtraData(order[kC], 0);\r\n if (!Angle.isAlmostEqualRadiansAllowPeriodShift(thetaA, thetaB)) {\r\n return kC;\r\n }\r\n kC++;\r\n }\r\n return kC;\r\n }\r\n private static _announceVertexNeighborhoodFunction?: AnnounceVertexNeighborhoodSortData;\r\n/**\r\n * public property setter for a function to be called with sorted edge data around a vertex.\r\n */\r\n public static set announceVertexNeighborhoodFunction(func: AnnounceVertexNeighborhoodSortData | undefined) { this._announceVertexNeighborhoodFunction = func; }\r\n private static doAnnounceVertexNeighborhood(clusters: ClusterableArray, order: Uint32Array, allNodes: HalfEdge[], k0: number, k1: number) {\r\n if (this._announceVertexNeighborhoodFunction) {\r\n const sortData: VertexNeighborhoodSortData[] = [];\r\n // build and share the entire vertex order\r\n for (let k = k0; k < k1; k++){\r\n const index = clusters.getExtraData(order[k], 1);\r\n const theta = clusters.getExtraData(order[k], 0);\r\n const node = allNodes[index];\r\n const signedDistance = this.curvatureSortKey(node);\r\n sortData.push(new VertexNeighborhoodSortData(order[k], signedDistance, node, theta));\r\n }\r\n this._announceVertexNeighborhoodFunction(sortData);\r\n }\r\n\r\n }\r\n // assumptions about cluster array:\r\n // * data order is: x,y,theta, nodeIndex\r\n // * theta and nodeIndex are the \"extra\" data.\r\n // * only want to do anything here when curves are present.\r\n // * k0<=k<k1 are around a vertex\r\n // * These are sorted by theta.\r\n private static secondarySortAroundVertex(clusters: ClusterableArray, order: Uint32Array, allNodes: HalfEdge[], k0: number, k1: number) {\r\n const sortData: VertexNeighborhoodSortData[] = [];\r\n\r\n for (let k = k0; k < k1;) {\r\n const kB = this.getCommonThetaEndIndex(clusters, order,k, k1);\r\n if (k + 1 < kB) {\r\n sortData.length = 0;\r\n for (let kA = k; kA < kB; kA++) {\r\n const index = clusters.getExtraData(order[kA], 1);\r\n const node = allNodes[index];\r\n const signedDistance = this.curvatureSortKey(node);\r\n sortData.push(new VertexNeighborhoodSortData(order[kA], signedDistance, node));\r\n }\r\n sortData.sort((a: VertexNeighborhoodSortData, b: VertexNeighborhoodSortData) => (a.radiusOfCurvature - b.radiusOfCurvature));\r\n for (let i = 0; i < sortData.length; i++){\r\n order[k + i] = sortData[i].index;\r\n }\r\n }\r\n k = kB;\r\n }\r\n }\r\n // Return the sort key for sorting by curvature.\r\n // This is the signed distance from the curve to center of curvature.\r\n // This should need to be upgraded to account for higher derivatives in the case of higher-than-tangent match.\r\n private static curvatureSortKey(node: HalfEdge): number {\r\n const cld = node.edgeTag as CurveLocationDetail;\r\n if (cld !== undefined) {\r\n const fraction = cld.fraction;\r\n const curve = cld.curve;\r\n if (curve) {\r\n let radius = curve.fractionToSignedXYRadiusOfCurvature(fraction);\r\n if (node.sortData !== undefined && node.sortData < 0)\r\n radius = -radius;\r\n return radius;\r\n }\r\n }\r\n return 0.0;\r\n }\r\n /** Simplest merge algorithm:\r\n * * collect array of (x,y,theta) at all nodes\r\n * * lexical sort of the array.\r\n * * twist all vertices together.\r\n * * This effectively creates valid face loops for a planar subdivision if there are no edge crossings.\r\n * * If there are edge crossings, the graph can be a (highly complicated) Klein bottle topology.\r\n * * Mask.NULL_FACE is cleared throughout and applied within null faces.\r\n */\r\n public static clusterAndMergeXYTheta(graph: HalfEdgeGraph, outboundRadiansFunction?: (he: HalfEdge) => number) {\r\n const allNodes = graph.allHalfEdges;\r\n const numNodes = allNodes.length;\r\n graph.clearMask(HalfEdgeMask.NULL_FACE);\r\n const clusters = new ClusterableArray(2, 2, numNodes); // data order: x,y,theta, nodeIndex. But theta is not set in first round.\r\n for (let i = 0; i < numNodes; i++) {\r\n const nodeA = allNodes[i];\r\n const xA = nodeA.x;\r\n const yA = nodeA.y;\r\n HalfEdge.pinch(nodeA, nodeA.vertexSuccessor); // pull it out of its current vertex loop.\r\n clusters.addDirect(xA, yA, 0.0, i);\r\n }\r\n const order = clusters.clusterIndicesLexical();\r\n let k0 = 0;\r\n const numK = order.length;\r\n for (let k1 = 0; k1 < numK; k1++) {\r\n if (order[k1] === ClusterableArray.clusterTerminator) {\r\n // nodes identified in order[k0]..order[k1] are properly sorted around a vertex.\r\n if (k1 > k0) {\r\n const iA = clusters.getExtraData(order[k0], 1);\r\n const nodeA0 = allNodes[iA];\r\n for (let k = k0 + 1; k < k1; k++) {\r\n const iB = clusters.getExtraData(order[k], 1);\r\n const nodeB = allNodes[iB];\r\n nodeB.x = nodeA0.x;\r\n nodeB.y = nodeA0.y;\r\n }\r\n }\r\n k0 = k1 + 1;\r\n }\r\n }\r\n // NOW\r\n // 1) There are identical coordinates at all nodes around each vertex loop.\r\n // 2) Hence ready do sort (at each vertex) by theta.\r\n\r\n // insert theta as extra data in the sort table . . .\r\n for (const clusterTableIndex of order) {\r\n if (clusterTableIndex !== ClusterableArray.clusterTerminator) {\r\n const nodeA = allNodes[clusterTableIndex];\r\n const nodeB = nodeA.faceSuccessor;\r\n let radians = outboundRadiansFunction ? outboundRadiansFunction(nodeA) : Math.atan2(nodeB.y - nodeA.y, nodeB.x - nodeA.x);\r\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(radians, -Math.PI))\r\n radians = Math.PI;\r\n clusters.setExtraData(clusterTableIndex, 0, radians);\r\n }\r\n }\r\n clusters.sortSubsetsBySingleKey(order, 2);\r\n const unmatchedNullFaceNodes: HalfEdge[] = [];\r\n k0 = 0;\r\n let thetaA, thetaB;\r\n // eslint-disable-next-line no-console\r\n // console.log(\"START VERTEX LINKS\");\r\n\r\n // now pinch each neighboring pair together\r\n for (let k1 = 0; k1 < numK; k1++) {\r\n if (order[k1] === ClusterableArray.clusterTerminator) {\r\n // nodes identified in order[k0]..order[k1] are properly sorted around a vertex.\r\n if (k1 > k0) {\r\n // const xy = clusters.getPoint2d(order[k0]);\r\n // eslint-disable-next-line no-console\r\n // console.log({ k0, k1, x: xy.x, y: xy.y });\r\n if (k1 > k0 + 1)\r\n this.secondarySortAroundVertex(clusters, order, allNodes, k0, k1);\r\n this.doAnnounceVertexNeighborhood(clusters, order, allNodes, k0, k1);\r\n const iA = clusters.getExtraData(order[k0], 1);\r\n thetaA = clusters.getExtraData(order[k0], 0);\r\n const nodeA0 = allNodes[iA];\r\n let nodeA = nodeA0;\r\n for (let k = k0 + 1; k < k1; k++) {\r\n const iB = clusters.getExtraData(order[k], 1);\r\n thetaB = clusters.getExtraData(order[k], 0);\r\n const nodeB = allNodes[iB];\r\n if (nodeA.isMaskSet(HalfEdgeMask.NULL_FACE)) {\r\n // nope, this edge was flagged and pinched from the other end.\r\n const j = unmatchedNullFaceNodes.findIndex((node: HalfEdge) => nodeA === node);\r\n if (j >= 0) {\r\n unmatchedNullFaceNodes[j] = unmatchedNullFaceNodes[unmatchedNullFaceNodes.length - 1];\r\n unmatchedNullFaceNodes.pop();\r\n }\r\n nodeA = nodeB;\r\n thetaA = thetaB;\r\n } else if (nodeB.isMaskSet(HalfEdgeMask.NULL_FACE)) {\r\n const j = unmatchedNullFaceNodes.findIndex((node: HalfEdge) => nodeA === node);\r\n if (j >= 0) {\r\n unmatchedNullFaceNodes[j] = unmatchedNullFaceNodes[unmatchedNullFaceNodes.length - 1];\r\n unmatchedNullFaceNodes.pop();\r\n }\r\n // NO leave nodeA and thetaA ignore nodeB -- later step will get the outside of its banana.\r\n } else {\r\n HalfEdge.pinch(nodeA, nodeB);\r\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(thetaA, thetaB)) {\r\n const nodeA1 = nodeA.faceSuccessor;\r\n const nodeB1 = nodeB.edgeMate;\r\n // WE TRUST -- nodeA1 and node B1 must have identical xy.\r\n // pinch them together and mark the face loop as null ..\r\n HalfEdge.pinch(nodeA1, nodeB1);\r\n nodeA.setMask(HalfEdgeMask.NULL_FACE);\r\n nodeB1.setMask(HalfEdgeMask.NULL_FACE);\r\n unmatchedNullFaceNodes.push(nodeB1);\r\n }\r\n nodeA = nodeB;\r\n thetaA = thetaB;\r\n }\r\n }\r\n }\r\n k0 = k1 + 1;\r\n }\r\n }\r\n }\r\n\r\n private static buildVerticalSweepPriorityQueue(graph: HalfEdgeGraph): HalfEdgePriorityQueueWithPartnerArray {\r\n const sweepHeap = new HalfEdgePriorityQueueWithPartnerArray();\r\n for (const p of graph.allHalfEdges) {\r\n\r\n if (HalfEdgeGraphOps.compareNodesYXUp(p, p.faceSuccessor) < 0) {\r\n sweepHeap.priorityQueue.push(p);\r\n }\r\n }\r\n return sweepHeap;\r\n }\r\n private static snapFractionToNode(xy: Point2d, fraction: number, node: HalfEdge, nodeFraction: number): number{\r\n if (Geometry.isSameCoordinate(xy.x, node.x) && Geometry.isSameCoordinate(xy.y, node.y))\r\n return nodeFraction;\r\n return fraction;\r\n}\r\n private static computeIntersectionFractionsOnEdges(nodeA0: HalfEdge, nodeB0: HalfEdge, fractions: Vector2d, pointA: Point2d, pointB: Point2d): boolean {\r\n const nodeA1 = nodeA0.faceSuccessor;\r\n const ax0 = nodeA0.x;\r\n const ay0 = nodeA0.y;\r\n const ux = nodeA1.x - ax0;\r\n const uy = nodeA1.y - ay0;\r\n const nodeB1 = nodeB0.faceSuccessor;\r\n const bx0 = nodeB0.x;\r\n const by0 = nodeB0.y;\r\n const vx = nodeB1.x - bx0;\r\n const vy = nodeB1.y - by0;\r\n // cspell:word lineSegmentXYUVTransverseIntersectionUnbounded\r\n if (SmallSystem.lineSegmentXYUVTransverseIntersectionUnbounded(ax0, ay0, ux, uy,\r\n bx0, by0, vx, vy, fractions)) {\r\n pointA.x = ax0 + fractions.x * ux;\r\n pointA.y = ay0 + fractions.x * uy;\r\n pointB.x = bx0 + fractions.y * vx;\r\n pointB.y = by0 + fractions.y * vy;\r\n fractions.x = this.snapFractionToNode(pointA, fractions.x, nodeA0, 0.0);\r\n fractions.x = this.snapFractionToNode(pointA, fractions.x, nodeA1, 1.0);\r\n fractions.y = this.snapFractionToNode(pointB, fractions.y, nodeB0, 0.0);\r\n fractions.y = this.snapFractionToNode(pointB, fractions.y, nodeB1, 1.0);\r\n return Geometry.isIn01(fractions.x) && Geometry.isIn01(fractions.y);\r\n }\r\n return false;\r\n }\r\n /**\r\n * Split edges at intersections.\r\n * * This is a large operation.\r\n * @param graph\r\n */\r\n public static splitIntersectingEdges(graph: HalfEdgeGraph): GraphSplitData {\r\n const data = new GraphSplitData();\r\n const sweepHeap = this.buildVerticalSweepPriorityQueue(graph);\r\n let nodeA0, nodeB1;\r\n const smallFraction = 1.0e-8;\r\n const largeFraction = 1.0 - smallFraction;\r\n let i;\r\n const fractions = Vector2d.create();\r\n const pointA = Point2d.create();\r\n const pointB = Point2d.create();\r\n let nodeB0;\r\n const popTolerance = Geometry.smallMetricDistance;\r\n while (undefined !== (nodeA0 = sweepHeap.priorityQueue.pop())) {\r\n data.numUpEdge++;\r\n const n0 = sweepHeap.activeEdges.length;\r\n sweepHeap.removeArrayMembersWithY1Below(nodeA0.y - popTolerance);\r\n data.numPopOut += n0 - sweepHeap.activeEdges.length;\r\n for (i = 0; i < sweepHeap.activeEdges.length; i++) {\r\n nodeB0 = sweepHeap.activeEdges[i];\r\n nodeB1 = nodeB0.faceSuccessor;\r\n // const nodeB1 = nodeB0.faceSuccessor;\r\n if (Geometry.isSameCoordinateXY(nodeA0.x, nodeA0.y, nodeB0.x, nodeB0.y)) {\r\n data.numA0B0++;\r\n } else if (Geometry.isSameCoordinateXY(nodeB1.x, nodeB1.y, nodeA0.x, nodeA0.y)) {\r\n data.numA0B1++;\r\n } else {\r\n data.numIntersectionTest++;\r\n if (this.computeIntersectionFractionsOnEdges(nodeA0, nodeB0, fractions, pointA, pointB)) {\r\n if (fractions.x > smallFraction && fractions.x < largeFraction) {\r\n const nodeC0 = graph.splitEdgeAtFraction(nodeA0, fractions.x);\r\n sweepHeap.priorityQueue.push(nodeC0); // The upper portion will be reviewed as a nodeA0 later !!!\r\n data.numSplit++;\r\n }\r\n if (fractions.y > smallFraction && fractions.y < largeFraction) {\r\n const nodeD0 = graph.splitEdgeAtFraction(nodeB0, fractions.y);\r\n sweepHeap.priorityQueue.push(nodeD0); // The upper portion will be reviewed as a nodeA0 later !!!\r\n data.numSplit++;\r\n }\r\n // existing nodeA0 and its shortened edge remain for further intersections\r\n }\r\n }\r\n }\r\n sweepHeap.activeEdges.push(nodeA0);\r\n }\r\n return data;\r\n }\r\n\r\n /**\r\n * Returns a graph structure formed from the given LineSegment array\r\n *\r\n * * Find all intersections among segments, and split them if necessary\r\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\r\n * vertices.\r\n * * For vertices that match up, pinch the nodes to create vertex loops, which in closed objects, will also eventually form face\r\n * loops\r\n */\r\n public static formGraphFromSegments(lineSegments: LineSegment3d[]): HalfEdgeGraph {\r\n // Structure of an index of the array: { xyTheta: Point3d, node: Node }\r\n const graph = new HalfEdgeGraph();\r\n HalfEdgeGraphOps.segmentArrayToGraphEdges(lineSegments, graph, HalfEdgeMask.BOUNDARY_EDGE);\r\n this.splitIntersectingEdges(graph);\r\n this.clusterAndMergeXYTheta(graph);\r\n\r\n return graph;\r\n }\r\n\r\n /**\r\n * * Input is random linestrings, not necessarily loops\r\n * * Graph gets full splitEdges, regularize, and triangulate.\r\n * @returns triangulated graph, or undefined if bad data.\r\n */\r\n public static formGraphFromChains(chains: MultiLineStringDataVariant, regularize: boolean = true, mask: HalfEdgeMask = HalfEdgeMask.PRIMARY_EDGE): HalfEdgeGraph | undefined {\r\n if (chains.length < 1)\r\n return undefined;\r\n const graph = new HalfEdgeGraph();\r\n const chainSeeds = Triangulator.directCreateChainsFromCoordinates(graph, chains);\r\n for (const seed of chainSeeds)\r\n seed.setMaskAroundFace(mask);\r\n\r\n this.splitIntersectingEdges(graph);\r\n this.clusterAndMergeXYTheta(graph);\r\n if (regularize) {\r\n const context = new RegularizationContext(graph);\r\n context.regularizeGraph(true, true);\r\n }\r\n return graph;\r\n }\r\n\r\n}\r\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;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/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Topology\r\n */\r\n\r\nimport { CurveLocationDetail } from \"../curve/CurveLocationDetail\";\r\nimport { LineSegment3d } from \"../curve/LineSegment3d\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Angle } from \"../geometry3d/Angle\";\r\nimport { Point2d, Vector2d } from \"../geometry3d/Point2dVector2d\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { ClusterableArray } from \"../numerics/ClusterableArray\";\r\nimport { SmallSystem } from \"../numerics/Polynomials\";\r\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask } from \"./Graph\";\r\nimport { HalfEdgePriorityQueueWithPartnerArray } from \"./HalfEdgePriorityQueue\";\r\nimport { RegularizationContext } from \"./RegularizeFace\";\r\nimport { MultiLineStringDataVariant, Triangulator } from \"./Triangulation\";\r\n\r\nexport class GraphSplitData {\r\n public numUpEdge = 0;\r\n public numIntersectionTest = 0;\r\n public numSplit = 0;\r\n public numPopOut = 0;\r\n public numA0B0 = 0;\r\n public numA0B1 = 0;\r\n public constructor() {\r\n }\r\n}\r\n/**\r\n * Structure for data used when sorting outbound edges \"around a node\"\r\n */\r\nexport class VertexNeighborhoodSortData {\r\n public index: number;\r\n public radiusOfCurvature: number;\r\n public node: HalfEdge;\r\n public radians?: number;\r\n public constructor(index: number, key: number, node: HalfEdge, radians?: number) {\r\n this.index = index;\r\n this.radiusOfCurvature = key;\r\n this.node = node;\r\n this.radians = radians;\r\n }\r\n}\r\n\r\n/** Function signature for announcing a vertex neighborhood during sorting. */\r\nexport type AnnounceVertexNeighborhoodSortData = (data: VertexNeighborhoodSortData[]) => any;\r\n/**\r\n * * Assorted methods used in algorithms on HalfEdgeGraph.\r\n * @internal\r\n */\r\nexport class HalfEdgeGraphOps {\r\n\r\n /** Compare function for sorting with primary y compare, secondary x compare. */\r\n public static compareNodesYXUp(a: HalfEdge, b: HalfEdge) {\r\n // Check y's\r\n // if (!Geometry.isSameCoordinate(a.y, b.y))\r\n if (a.y < b.y)\r\n return -1;\r\n else if (a.y > b.y)\r\n return 1;\r\n // Check x's\r\n // if (!Geometry.isSameCoordinate(a.x, b.x))\r\n if (a.x < b.x)\r\n return -1;\r\n else if (a.x > b.x)\r\n return 1;\r\n return 0;\r\n }\r\n\r\n /** Return true if nodeB (a) is lower than both its neighbors and (b) inflects as a downward peak (rather than an upward trough) */\r\n public static isDownPeak(nodeB: HalfEdge) {\r\n const nodeA = nodeB.facePredecessor;\r\n const nodeC = nodeB.faceSuccessor;\r\n return this.compareNodesYXUp(nodeB, nodeA) < 0\r\n && this.compareNodesYXUp(nodeB, nodeC) < 0\r\n && this.crossProductToTargets(nodeB, nodeA, nodeC) > 0;\r\n }\r\n\r\n /** return the cross product of vectors from base to targetA and base to targetB\r\n * @param base base vertex of both vectors.\r\n * @param targetA target vertex of first vector\r\n * @param targetB target vertex of second vector\r\n */\r\n public static crossProductToTargets(base: HalfEdge, targetA: HalfEdge, targetB: HalfEdge): number {\r\n return Geometry.crossProductXYXY(targetA.x - base.x, targetA.y - base.y, targetB.x - base.x, targetB.y - base.y);\r\n }\r\n\r\n // ---------------------------------------------------------------------------------------------------------------------\r\n // ----------------------------------------------------------------------------------------------------------------------\r\n\r\n public static graphRange(graph: HalfEdgeGraph): Range3d {\r\n const range = Range3d.create();\r\n for (const node of graph.allHalfEdges) {\r\n range.extendXYZ(node.x, node.y, node.z);\r\n }\r\n return range;\r\n }\r\n /** Returns an array of all nodes (both ends) of edges created from segments. */\r\n public static segmentArrayToGraphEdges(segments: LineSegment3d[], returnGraph: HalfEdgeGraph, mask: HalfEdgeMask): HalfEdge[] {\r\n const result = [];\r\n let idxCounter = 0;\r\n\r\n // Push the endpoints of each segment onto arr[] in the form {(x, y, theta), Node}\r\n for (const segment of segments) {\r\n\r\n const node0 = returnGraph.createEdgeXYZXYZ(\r\n segment.point0Ref.x, segment.point0Ref.y, segment.point0Ref.z,\r\n idxCounter,\r\n segment.point1Ref.x, segment.point1Ref.y, segment.point1Ref.z,\r\n idxCounter + 1);\r\n\r\n const node1 = node0.edgeMate;\r\n idxCounter += 2;\r\n\r\n node0.setMaskAroundFace(mask); // Original given coordinates must be part of boundary\r\n result.push(node0);\r\n result.push(node1);\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * * Visit all nodes in `graph`.\r\n * * invoke `pinch(node, vertexPredecessor)`\r\n * * this leaves the graph as isolated edges.\r\n * @param graph graph to modify\r\n */\r\n public static isolateAllEdges(graph: HalfEdgeGraph) {\r\n for (const nodeA of graph.allHalfEdges) {\r\n const nodeB = nodeA.vertexPredecessor;\r\n HalfEdge.pinch(nodeA, nodeB);\r\n }\r\n }\r\n\r\n /**\r\n * Compute convexity of a sector of a super-face.\r\n * @param base node whose edge is to be tested for removal\r\n * @param ignore edges with this mask (on either side) are ignored for the purposes of computing convexity\r\n * @param barrier edges with this mask (on either side) will not be removed\r\n * @return whether removing the edge at base would create a convex sector in the super-face\r\n */\r\n private static isSectorConvexAfterEdgeRemoval(base: HalfEdge, ignore: HalfEdgeMask, barrier: HalfEdgeMask): boolean {\r\n let vs = base;\r\n do { // loop ccw around vertex looking for a super-face predecessor\r\n if (vs.isMaskSet(barrier) || vs.edgeMate.isMaskSet(barrier))\r\n break;\r\n vs = vs.vertexSuccessor;\r\n } while (vs !== base && vs.isMaskSet(ignore));\r\n if (vs === base)\r\n return false;\r\n let vp = base;\r\n do { // loop cw around vertex looking for a super-face successor\r\n if (vp.isMaskSet(barrier) || vp.edgeMate.isMaskSet(barrier))\r\n break;\r\n vp = vp.vertexPredecessor;\r\n } while (vp !== base && vp.isMaskSet(ignore));\r\n if (vp === base)\r\n return false;\r\n return HalfEdge.isSectorConvex(vs.edgeMate, base, vp.faceSuccessor);\r\n }\r\n\r\n /**\r\n * Mask edges between faces if the union of the faces is convex.\r\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\r\n * Best results when input faces are convex.\r\n * @param graph graph to examine and mark\r\n * @param mark the mask used to mark (both sides of) removable edges\r\n * @param barrier edges with this mask (on either side) will not be marked. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\r\n * @return number of edges masked (half the number of HalfEdges masked)\r\n */\r\n public static markRemovableEdgesToExpandConvexFaces(graph: HalfEdgeGraph, mark: HalfEdgeMask, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): number {\r\n if (HalfEdgeMask.NULL_MASK === mark)\r\n return 0;\r\n const visit = graph.grabMask(true);\r\n let numMarked = 0;\r\n for (const node of graph.allHalfEdges) {\r\n if (!node.isMaskSet(visit)) {\r\n if (!node.isMaskSet(barrier) && !node.edgeMate.isMaskSet(barrier)) {\r\n if (this.isSectorConvexAfterEdgeRemoval(node, mark, barrier) && this.isSectorConvexAfterEdgeRemoval(node.edgeMate, mark, barrier)) {\r\n node.setMaskAroundEdge(mark);\r\n ++numMarked;\r\n }\r\n }\r\n }\r\n node.setMaskAroundEdge(visit);\r\n }\r\n return numMarked;\r\n }\r\n\r\n /**\r\n * Collect edges between faces if the union of the faces is convex.\r\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\r\n * Best results when input faces are convex.\r\n * @param graph graph to examine\r\n * @param barrier edges with this mask (on either side) will not be collected. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\r\n * @return one HalfEdge per removable edge\r\n */\r\n public static collectRemovableEdgesToExpandConvexFaces(graph: HalfEdgeGraph, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): HalfEdge[] | undefined {\r\n const removable: HalfEdge[] = [];\r\n const mark = graph.grabMask(true);\r\n if (0 < this.markRemovableEdgesToExpandConvexFaces(graph, mark, barrier)) {\r\n const visited = graph.grabMask(true);\r\n for (const node of graph.allHalfEdges) {\r\n if (node.isMaskSet(mark) && !node.isMaskSet(visited)) {\r\n node.setMaskAroundEdge(visited);\r\n removable.push(node);\r\n }\r\n }\r\n graph.dropMask(visited);\r\n }\r\n graph.dropMask(mark);\r\n return removable;\r\n }\r\n\r\n /**\r\n * Remove edges between faces if the union of the faces is convex.\r\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\r\n * Best results when input faces are convex.\r\n * @param graph graph to modify\r\n * @param barrier edges with this mask (on either side) will not be removed. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\r\n * @return number of edges deleted\r\n */\r\n public static expandConvexFaces(graph: HalfEdgeGraph, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): number {\r\n const mark = graph.grabMask(true);\r\n const numRemovedEdges = this.markRemovableEdgesToExpandConvexFaces(graph, mark, barrier);\r\n if (numRemovedEdges > 0)\r\n graph.yankAndDeleteEdges((node: HalfEdge) => node.getMask(mark));\r\n graph.dropMask(mark);\r\n return numRemovedEdges;\r\n }\r\n\r\n /**\r\n * Test desired faces for convexity.\r\n * @param graph graph to examine\r\n * @param avoid faces with this mask will not be examined. Defaults to HalfEdgeMask.EXTERIOR.\r\n * @return whether every face in the graph is convex\r\n */\r\n public static isEveryFaceConvex(graph: HalfEdgeGraph, avoid: HalfEdgeMask = HalfEdgeMask.EXTERIOR): boolean {\r\n const allFaces = graph.collectFaceLoops();\r\n for (const node of allFaces) {\r\n if (node.isMaskedAroundFace(avoid))\r\n continue;\r\n if (!node.isFaceConvex())\r\n return false;\r\n }\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class HalfEdgeGraphMerge {\r\n // return kC <= kB such that stored angles (at extra data index 0 !) kA<=k<kC match.\r\n // * Note that the usual case (when angle at kA is not repeated) is kA+1 === kC\r\n public static getCommonThetaEndIndex(clusters: ClusterableArray, order: Uint32Array, kA: number, kB: number): number{\r\n let kC = kA + 1;\r\n const thetaA = clusters.getExtraData(order[kA], 0);\r\n while (kC < kB) {\r\n const thetaB = clusters.getExtraData(order[kC], 0);\r\n if (!Angle.isAlmostEqualRadiansAllowPeriodShift(thetaA, thetaB)) {\r\n return kC;\r\n }\r\n kC++;\r\n }\r\n return kC;\r\n }\r\n private static _announceVertexNeighborhoodFunction?: AnnounceVertexNeighborhoodSortData;\r\n/**\r\n * public property setter for a function to be called with sorted edge data around a vertex.\r\n */\r\n public static set announceVertexNeighborhoodFunction(func: AnnounceVertexNeighborhoodSortData | undefined) { this._announceVertexNeighborhoodFunction = func; }\r\n private static doAnnounceVertexNeighborhood(clusters: ClusterableArray, order: Uint32Array, allNodes: HalfEdge[], k0: number, k1: number) {\r\n if (this._announceVertexNeighborhoodFunction) {\r\n const sortData: VertexNeighborhoodSortData[] = [];\r\n // build and share the entire vertex order\r\n for (let k = k0; k < k1; k++){\r\n const index = clusters.getExtraData(order[k], 1);\r\n const theta = clusters.getExtraData(order[k], 0);\r\n const node = allNodes[index];\r\n const signedDistance = this.curvatureSortKey(node);\r\n sortData.push(new VertexNeighborhoodSortData(order[k], signedDistance, node, theta));\r\n }\r\n this._announceVertexNeighborhoodFunction(sortData);\r\n }\r\n\r\n }\r\n // assumptions about cluster array:\r\n // * data order is: x,y,theta, nodeIndex\r\n // * theta and nodeIndex are the \"extra\" data.\r\n // * only want to do anything here when curves are present.\r\n // * k0<=k<k1 are around a vertex\r\n // * These are sorted by theta.\r\n private static secondarySortAroundVertex(clusters: ClusterableArray, order: Uint32Array, allNodes: HalfEdge[], k0: number, k1: number) {\r\n const sortData: VertexNeighborhoodSortData[] = [];\r\n\r\n for (let k = k0; k < k1;) {\r\n const kB = this.getCommonThetaEndIndex(clusters, order,k, k1);\r\n if (k + 1 < kB) {\r\n sortData.length = 0;\r\n for (let kA = k; kA < kB; kA++) {\r\n const index = clusters.getExtraData(order[kA], 1);\r\n const node = allNodes[index];\r\n const signedDistance = this.curvatureSortKey(node);\r\n sortData.push(new VertexNeighborhoodSortData(order[kA], signedDistance, node));\r\n }\r\n sortData.sort((a: VertexNeighborhoodSortData, b: VertexNeighborhoodSortData) => (a.radiusOfCurvature - b.radiusOfCurvature));\r\n for (let i = 0; i < sortData.length; i++){\r\n order[k + i] = sortData[i].index;\r\n }\r\n }\r\n k = kB;\r\n }\r\n }\r\n // Return the sort key for sorting by curvature.\r\n // This is the signed distance from the curve to center of curvature.\r\n // This should need to be upgraded to account for higher derivatives in the case of higher-than-tangent match.\r\n private static curvatureSortKey(node: HalfEdge): number {\r\n const cld = node.edgeTag as CurveLocationDetail;\r\n if (cld !== undefined) {\r\n const fraction = cld.fraction;\r\n const curve = cld.curve;\r\n if (curve) {\r\n let radius = curve.fractionToSignedXYRadiusOfCurvature(fraction);\r\n if (node.sortData !== undefined && node.sortData < 0)\r\n radius = -radius;\r\n return radius;\r\n }\r\n }\r\n return 0.0;\r\n }\r\n /** Simplest merge algorithm:\r\n * * collect array of (x,y,theta) at all nodes\r\n * * lexical sort of the array.\r\n * * twist all vertices together.\r\n * * This effectively creates valid face loops for a planar subdivision if there are no edge crossings.\r\n * * If there are edge crossings, the graph can be a (highly complicated) Klein bottle topology.\r\n * * Mask.NULL_FACE is cleared throughout and applied within null faces.\r\n */\r\n public static clusterAndMergeXYTheta(graph: HalfEdgeGraph, outboundRadiansFunction?: (he: HalfEdge) => number) {\r\n const allNodes = graph.allHalfEdges;\r\n const numNodes = allNodes.length;\r\n graph.clearMask(HalfEdgeMask.NULL_FACE);\r\n const clusters = new ClusterableArray(2, 2, numNodes); // data order: x,y,theta, nodeIndex. But theta is not set in first round.\r\n for (let i = 0; i < numNodes; i++) {\r\n const nodeA = allNodes[i];\r\n const xA = nodeA.x;\r\n const yA = nodeA.y;\r\n HalfEdge.pinch(nodeA, nodeA.vertexSuccessor); // pull it out of its current vertex loop.\r\n clusters.addDirect(xA, yA, 0.0, i);\r\n }\r\n const order = clusters.clusterIndicesLexical();\r\n let k0 = 0;\r\n const numK = order.length;\r\n for (let k1 = 0; k1 < numK; k1++) {\r\n if (order[k1] === ClusterableArray.clusterTerminator) {\r\n // nodes identified in order[k0]..order[k1] are properly sorted around a vertex.\r\n if (k1 > k0) {\r\n const iA = clusters.getExtraData(order[k0], 1);\r\n const nodeA0 = allNodes[iA];\r\n for (let k = k0 + 1; k < k1; k++) {\r\n const iB = clusters.getExtraData(order[k], 1);\r\n const nodeB = allNodes[iB];\r\n nodeB.x = nodeA0.x;\r\n nodeB.y = nodeA0.y;\r\n }\r\n }\r\n k0 = k1 + 1;\r\n }\r\n }\r\n // NOW\r\n // 1) There are identical coordinates at all nodes around each vertex loop.\r\n // 2) Hence ready do sort (at each vertex) by theta.\r\n\r\n // insert theta as extra data in the sort table . . .\r\n for (const clusterTableIndex of order) {\r\n if (clusterTableIndex !== ClusterableArray.clusterTerminator) {\r\n const nodeA = allNodes[clusterTableIndex];\r\n const nodeB = nodeA.faceSuccessor;\r\n let radians = outboundRadiansFunction ? outboundRadiansFunction(nodeA) : Math.atan2(nodeB.y - nodeA.y, nodeB.x - nodeA.x);\r\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(radians, -Math.PI))\r\n radians = Math.PI;\r\n clusters.setExtraData(clusterTableIndex, 0, radians);\r\n }\r\n }\r\n clusters.sortSubsetsBySingleKey(order, 2);\r\n const unmatchedNullFaceNodes: HalfEdge[] = [];\r\n k0 = 0;\r\n let thetaA, thetaB;\r\n // eslint-disable-next-line no-console\r\n // console.log(\"START VERTEX LINKS\");\r\n\r\n // now pinch each neighboring pair together\r\n for (let k1 = 0; k1 < numK; k1++) {\r\n if (order[k1] === ClusterableArray.clusterTerminator) {\r\n // nodes identified in order[k0]..order[k1] are properly sorted around a vertex.\r\n if (k1 > k0) {\r\n // const xy = clusters.getPoint2d(order[k0]);\r\n // eslint-disable-next-line no-console\r\n // console.log({ k0, k1, x: xy.x, y: xy.y });\r\n if (k1 > k0 + 1)\r\n this.secondarySortAroundVertex(clusters, order, allNodes, k0, k1);\r\n this.doAnnounceVertexNeighborhood(clusters, order, allNodes, k0, k1);\r\n const iA = clusters.getExtraData(order[k0], 1);\r\n thetaA = clusters.getExtraData(order[k0], 0);\r\n const nodeA0 = allNodes[iA];\r\n let nodeA = nodeA0;\r\n for (let k = k0 + 1; k < k1; k++) {\r\n const iB = clusters.getExtraData(order[k], 1);\r\n thetaB = clusters.getExtraData(order[k], 0);\r\n const nodeB = allNodes[iB];\r\n if (nodeA.isMaskSet(HalfEdgeMask.NULL_FACE)) {\r\n // nope, this edge was flagged and pinched from the other end.\r\n const j = unmatchedNullFaceNodes.findIndex((node: HalfEdge) => nodeA === node);\r\n if (j >= 0) {\r\n unmatchedNullFaceNodes[j] = unmatchedNullFaceNodes[unmatchedNullFaceNodes.length - 1];\r\n unmatchedNullFaceNodes.pop();\r\n }\r\n nodeA = nodeB;\r\n thetaA = thetaB;\r\n } else if (nodeB.isMaskSet(HalfEdgeMask.NULL_FACE)) {\r\n const j = unmatchedNullFaceNodes.findIndex((node: HalfEdge) => nodeB === node);\r\n if (j >= 0) {\r\n unmatchedNullFaceNodes[j] = unmatchedNullFaceNodes[unmatchedNullFaceNodes.length - 1];\r\n unmatchedNullFaceNodes.pop();\r\n }\r\n // NO leave nodeA and thetaA ignore nodeB -- later step will get the outside of its banana.\r\n } else {\r\n HalfEdge.pinch(nodeA, nodeB);\r\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(thetaA, thetaB)) {\r\n const nodeA1 = nodeA.faceSuccessor;\r\n const nodeB1 = nodeB.edgeMate;\r\n // WE TRUST -- nodeA1 and node B1 must have identical xy.\r\n // pinch them together and mark the face loop as null ..\r\n HalfEdge.pinch(nodeA1, nodeB1);\r\n nodeA.setMask(HalfEdgeMask.NULL_FACE);\r\n nodeB1.setMask(HalfEdgeMask.NULL_FACE);\r\n unmatchedNullFaceNodes.push(nodeB1);\r\n }\r\n nodeA = nodeB;\r\n thetaA = thetaB;\r\n }\r\n }\r\n }\r\n k0 = k1 + 1;\r\n }\r\n }\r\n }\r\n\r\n private static buildVerticalSweepPriorityQueue(graph: HalfEdgeGraph): HalfEdgePriorityQueueWithPartnerArray {\r\n const sweepHeap = new HalfEdgePriorityQueueWithPartnerArray();\r\n for (const p of graph.allHalfEdges) {\r\n\r\n if (HalfEdgeGraphOps.compareNodesYXUp(p, p.faceSuccessor) < 0) {\r\n sweepHeap.priorityQueue.push(p);\r\n }\r\n }\r\n return sweepHeap;\r\n }\r\n private static snapFractionToNode(xy: Point2d, fraction: number, node: HalfEdge, nodeFraction: number): number{\r\n if (Geometry.isSameCoordinate(xy.x, node.x) && Geometry.isSameCoordinate(xy.y, node.y))\r\n return nodeFraction;\r\n return fraction;\r\n}\r\n private static computeIntersectionFractionsOnEdges(nodeA0: HalfEdge, nodeB0: HalfEdge, fractions: Vector2d, pointA: Point2d, pointB: Point2d): boolean {\r\n const nodeA1 = nodeA0.faceSuccessor;\r\n const ax0 = nodeA0.x;\r\n const ay0 = nodeA0.y;\r\n const ux = nodeA1.x - ax0;\r\n const uy = nodeA1.y - ay0;\r\n const nodeB1 = nodeB0.faceSuccessor;\r\n const bx0 = nodeB0.x;\r\n const by0 = nodeB0.y;\r\n const vx = nodeB1.x - bx0;\r\n const vy = nodeB1.y - by0;\r\n // cspell:word lineSegmentXYUVTransverseIntersectionUnbounded\r\n if (SmallSystem.lineSegmentXYUVTransverseIntersectionUnbounded(ax0, ay0, ux, uy,\r\n bx0, by0, vx, vy, fractions)) {\r\n pointA.x = ax0 + fractions.x * ux;\r\n pointA.y = ay0 + fractions.x * uy;\r\n pointB.x = bx0 + fractions.y * vx;\r\n pointB.y = by0 + fractions.y * vy;\r\n fractions.x = this.snapFractionToNode(pointA, fractions.x, nodeA0, 0.0);\r\n fractions.x = this.snapFractionToNode(pointA, fractions.x, nodeA1, 1.0);\r\n fractions.y = this.snapFractionToNode(pointB, fractions.y, nodeB0, 0.0);\r\n fractions.y = this.snapFractionToNode(pointB, fractions.y, nodeB1, 1.0);\r\n return Geometry.isIn01(fractions.x) && Geometry.isIn01(fractions.y);\r\n }\r\n return false;\r\n }\r\n /**\r\n * Split edges at intersections.\r\n * * This is a large operation.\r\n * @param graph\r\n */\r\n public static splitIntersectingEdges(graph: HalfEdgeGraph): GraphSplitData {\r\n const data = new GraphSplitData();\r\n const sweepHeap = this.buildVerticalSweepPriorityQueue(graph);\r\n let nodeA0, nodeB1;\r\n const smallFraction = 1.0e-8;\r\n const largeFraction = 1.0 - smallFraction;\r\n let i;\r\n const fractions = Vector2d.create();\r\n const pointA = Point2d.create();\r\n const pointB = Point2d.create();\r\n let nodeB0;\r\n const popTolerance = Geometry.smallMetricDistance;\r\n while (undefined !== (nodeA0 = sweepHeap.priorityQueue.pop())) {\r\n data.numUpEdge++;\r\n const n0 = sweepHeap.activeEdges.length;\r\n sweepHeap.removeArrayMembersWithY1Below(nodeA0.y - popTolerance);\r\n data.numPopOut += n0 - sweepHeap.activeEdges.length;\r\n for (i = 0; i < sweepHeap.activeEdges.length; i++) {\r\n nodeB0 = sweepHeap.activeEdges[i];\r\n nodeB1 = nodeB0.faceSuccessor;\r\n // const nodeB1 = nodeB0.faceSuccessor;\r\n if (Geometry.isSameCoordinateXY(nodeA0.x, nodeA0.y, nodeB0.x, nodeB0.y)) {\r\n data.numA0B0++;\r\n } else if (Geometry.isSameCoordinateXY(nodeB1.x, nodeB1.y, nodeA0.x, nodeA0.y)) {\r\n data.numA0B1++;\r\n } else {\r\n data.numIntersectionTest++;\r\n if (this.computeIntersectionFractionsOnEdges(nodeA0, nodeB0, fractions, pointA, pointB)) {\r\n if (fractions.x > smallFraction && fractions.x < largeFraction) {\r\n const nodeC0 = graph.splitEdgeAtFraction(nodeA0, fractions.x);\r\n sweepHeap.priorityQueue.push(nodeC0); // The upper portion will be reviewed as a nodeA0 later !!!\r\n data.numSplit++;\r\n }\r\n if (fractions.y > smallFraction && fractions.y < largeFraction) {\r\n const nodeD0 = graph.splitEdgeAtFraction(nodeB0, fractions.y);\r\n sweepHeap.priorityQueue.push(nodeD0); // The upper portion will be reviewed as a nodeA0 later !!!\r\n data.numSplit++;\r\n }\r\n // existing nodeA0 and its shortened edge remain for further intersections\r\n }\r\n }\r\n }\r\n sweepHeap.activeEdges.push(nodeA0);\r\n }\r\n return data;\r\n }\r\n\r\n /**\r\n * Returns a graph structure formed from the given LineSegment array\r\n *\r\n * * Find all intersections among segments, and split them if necessary\r\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\r\n * vertices.\r\n * * For vertices that match up, pinch the nodes to create vertex loops, which in closed objects, will also eventually form face\r\n * loops\r\n */\r\n public static formGraphFromSegments(lineSegments: LineSegment3d[]): HalfEdgeGraph {\r\n // Structure of an index of the array: { xyTheta: Point3d, node: Node }\r\n const graph = new HalfEdgeGraph();\r\n HalfEdgeGraphOps.segmentArrayToGraphEdges(lineSegments, graph, HalfEdgeMask.BOUNDARY_EDGE);\r\n this.splitIntersectingEdges(graph);\r\n this.clusterAndMergeXYTheta(graph);\r\n\r\n return graph;\r\n }\r\n\r\n /**\r\n * * Input is random linestrings, not necessarily loops\r\n * * Graph gets full splitEdges, regularize, and triangulate.\r\n * @returns triangulated graph, or undefined if bad data.\r\n */\r\n public static formGraphFromChains(chains: MultiLineStringDataVariant, regularize: boolean = true, mask: HalfEdgeMask = HalfEdgeMask.PRIMARY_EDGE): HalfEdgeGraph | undefined {\r\n if (chains.length < 1)\r\n return undefined;\r\n const graph = new HalfEdgeGraph();\r\n const chainSeeds = Triangulator.directCreateChainsFromCoordinates(graph, chains);\r\n for (const seed of chainSeeds)\r\n seed.setMaskAroundFace(mask);\r\n\r\n this.splitIntersectingEdges(graph);\r\n this.clusterAndMergeXYTheta(graph);\r\n if (regularize) {\r\n const context = new RegularizationContext(graph);\r\n context.regularizeGraph(true, true);\r\n }\r\n return graph;\r\n }\r\n\r\n}\r\n"]}
@@ -40,8 +40,6 @@ export declare class Triangulator {
40
40
  * * Return true if clearly positive
41
41
  * * Return false if clearly negative or almost zero.
42
42
  * @param nodeA node on the diagonal edge of candidate for edge flip.
43
- * @param if true, divide the determinant by the sum of absolute values of the cubic terms of the determinant.
44
- * @return the determinant as modified per comment (but undefined if the faces are not triangles as expected.)
45
43
  */
46
44
  static computeInCircleDeterminantIsStrongPositive(nodeA: HalfEdge): boolean;
47
45
  /**
@@ -135,7 +133,7 @@ export declare class Triangulator {
135
133
  private static joinNeighborsOfEar;
136
134
  private static isInteriorTriangle;
137
135
  /**
138
- * Perform 0, 1, or more edge flips to improve aspect ratio just behind an that was just cut.
136
+ * Perform 0, 1, or more edge flips to improve aspect ratio just behind an ear that was just cut.
139
137
  * @param ear the triangle corner which just served as the ear node.
140
138
  * @returns the node at the back corner after flipping."appropriately positioned" node for the usual advance to ear.faceSuccessor.edgeMate.faceSuccessor.
141
139
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Triangulation.d.ts","sourceRoot":"","sources":["../../../src/topology/Triangulation.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAIxD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD;;;GAGG;AACH,oBAAY,qBAAqB,GAAG,oBAAoB,GAAG,MAAM,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC;AAE3F;;;GAGG;AACH,oBAAY,0BAA0B,GAAG,qBAAqB,GAAG,qBAAqB,EAAE,CAAC;AAEzF;;;GAGG;AACH,qBAAa,YAAY;IAEvB;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAiBvC;;;;;;;;;;;;;;;;;OAiBG;WACW,0CAA0C,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO;IAiClF;;;;OAIG;WACW,aAAa,CAAC,KAAK,EAAE,aAAa,G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D,eAAe,IAAI,aAAa,GAAG,SAAS;IAM1D;;;;mBAIe;WACD,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS;IAC5D;;;;;;;;;mBASe;WACD,+BAA+B,CAAC,KAAK,EAAE,OAAO;IAM5D,OAAO,CAAC,MAAM,CAAC,aAAa,CAAwB;IACpD,OAAO,CAAC,MAAM,CAAC,SAAS,CAAwB;IAChD,OAAO,CAAC,MAAM,CAAC,UAAU,CAAwB;IACjD,OAAO,CAAC,MAAM,CAAC,OAAO,CAIpB;IACF,yEAAyE;IACzE,OAAO,CAAC,MAAM,CAAC,KAAK;IA0DpB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAYzC,mEAAmE;IACnE,OAAO,CAAC,MAAM,CAAC,QAAQ;IAIvB,2FAA2F;IAC3F,OAAO,CAAC,MAAM,CAAC,aAAa;IAQ5B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IA+D7B,OAAO,CAAC,MAAM,CAAC,WAAW;IAW1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAK9B,OAAO,CAAC,MAAM,CAAC,cAAc;IAK7B;;;MAGE;IACF,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAInC;MACE;IACF,OAAO,CAAC,MAAM,CAAC,+BAA+B;IAe9C,oCAAoC;IACpC,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAInC,iDAAiD;IACjD,OAAO,CAAC,MAAM,CAAC,aAAa;IAM5B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS;IAWxB;;;OAGG;WACW,6BAA6B,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO;CAuI5F"}
@@ -60,10 +60,15 @@ class Triangulator {
60
60
  * * Return true if clearly positive
61
61
  * * Return false if clearly negative or almost zero.
62
62
  * @param nodeA node on the diagonal edge of candidate for edge flip.
63
- * @param if true, divide the determinant by the sum of absolute values of the cubic terms of the determinant.
64
- * @return the determinant as modified per comment (but undefined if the faces are not triangles as expected.)
65
63
  */
66
64
  static computeInCircleDeterminantIsStrongPositive(nodeA) {
65
+ // Assume triangle A1,A2,B2 is ccw.
66
+ // Shift the triangle to the origin (by negated A coords).
67
+ // The Delaunay condition is computed by projecting the origin and the shifted triangle
68
+ // points up to the paraboloid z = x*x + y*y. Due to the radially symmetric convexity of
69
+ // this surface and the ccw orientation of this triangle, "A is inside triangle A1,A2,B2"
70
+ // is equivalent to "the volume of the parallelepiped formed by the projected points is
71
+ // negative, as computed by the triple product."
67
72
  const nodeA1 = nodeA.faceSuccessor;
68
73
  const nodeA2 = nodeA1.faceSuccessor;
69
74
  if (nodeA2.faceSuccessor !== nodeA)
@@ -88,7 +93,7 @@ class Triangulator {
88
93
  const q = Geometry_1.Geometry.tripleProduct(wx, wy, tx, vx, vy, ty, ux, uy, tz);
89
94
  if (q < 0)
90
95
  return false;
91
- const denom = Math.abs(wx * vy * tz) + Math.abs(wx * ty * ux) + Math.abs(tx * vx * uy)
96
+ const denom = Math.abs(wx * vy * tz) + Math.abs(wy * ty * ux) + Math.abs(tx * vx * uy)
92
97
  + Math.abs(wx * ty * uy) + Math.abs(wy * vx * tz) + Math.abs(tx * vy * ux);
93
98
  return q > 1.0e-12 * denom;
94
99
  }
@@ -276,7 +281,7 @@ class Triangulator {
276
281
  x = q.x;
277
282
  if (q.hasOwnProperty("y"))
278
283
  y = q.y;
279
- if (q.hasOwnProperty("y"))
284
+ if (q.hasOwnProperty("z"))
280
285
  z = q.z;
281
286
  }
282
287
  if (!baseNode)
@@ -389,18 +394,18 @@ class Triangulator {
389
394
  ear.setMaskAroundFace(Graph_1.HalfEdgeMask.TRIANGULATED_FACE);
390
395
  }
391
396
  static isInteriorTriangle(a) {
392
- if (!a.isMaskSet(Graph_1.HalfEdgeMask.TRIANGULATED_FACE))
397
+ if (!a.isMaskSet(Graph_1.HalfEdgeMask.TRIANGULATED_FACE) || a.isMaskSet(Graph_1.HalfEdgeMask.EXTERIOR))
393
398
  return false;
394
399
  const b = a.faceSuccessor;
395
- if (!b.isMaskSet(Graph_1.HalfEdgeMask.TRIANGULATED_FACE))
400
+ if (!b.isMaskSet(Graph_1.HalfEdgeMask.TRIANGULATED_FACE) || b.isMaskSet(Graph_1.HalfEdgeMask.EXTERIOR))
396
401
  return false;
397
402
  const c = b.faceSuccessor;
398
- if (!c.isMaskSet(Graph_1.HalfEdgeMask.TRIANGULATED_FACE))
403
+ if (!c.isMaskSet(Graph_1.HalfEdgeMask.TRIANGULATED_FACE) || c.isMaskSet(Graph_1.HalfEdgeMask.EXTERIOR))
399
404
  return false;
400
405
  return c.faceSuccessor === a;
401
406
  }
402
407
  /**
403
- * Perform 0, 1, or more edge flips to improve aspect ratio just behind an that was just cut.
408
+ * Perform 0, 1, or more edge flips to improve aspect ratio just behind an ear that was just cut.
404
409
  * @param ear the triangle corner which just served as the ear node.
405
410
  * @returns the node at the back corner after flipping."appropriately positioned" node for the usual advance to ear.faceSuccessor.edgeMate.faceSuccessor.
406
411
  */
@@ -415,18 +420,18 @@ class Triangulator {
415
420
  // after flip, node A moves to the vertex of D, and is the effective "ear", with the cap edge C A1
416
421
  // after flip, consider the A1 D (whose nodes are A1 and flipped A!!!)
417
422
  //
418
- //
419
- // . C0|
420
- // . |
421
- // . |
422
- // . ^|
423
- // . A0 ----> B0|
424
- // *=======================*
425
- // \ A1 <---- B1/
426
- // \ /
427
- // \ /
428
- // \ D1 /
429
- // *
423
+ // * *
424
+ // . C0| . / |
425
+ // . | . C0 /B1|
426
+ // . | . /v |
427
+ // . ^| . / |
428
+ // . A0 ----> B0| . / ^|
429
+ // *=======================* --> * A1 / B0*
430
+ // \ A1 <---- B1/ \ / /
431
+ // \ / \ / /
432
+ // \ / \ ^/ D1/
433
+ // \ D1 / \A0/ /
434
+ // * *
430
435
  let b0 = ear;
431
436
  let a0 = b0.facePredecessor;
432
437
  let b1 = a0.edgeMate;
@@ -467,8 +472,13 @@ class Triangulator {
467
472
  pred = ear === null || ear === void 0 ? void 0 : ear.facePredecessor;
468
473
  next = ear.faceSuccessor;
469
474
  next2 = next.faceSuccessor;
470
- if (next === ear || next2 === ear || next2.faceSuccessor === ear)
475
+ if (next === ear || next2 === ear)
471
476
  return true;
477
+ if (next2.faceSuccessor === ear) {
478
+ // if triangle, mask it so that its edges can potentially be flipped by doPostCutFlips()
479
+ ear.setMaskAroundFace(Graph_1.HalfEdgeMask.TRIANGULATED_FACE);
480
+ return true;
481
+ }
472
482
  // earcut does not support self intersections.
473
483
  // BUT .. maybe if we watch from the simplest case of next2 returning to pred it will catch some . . .
474
484
  // (no need to do flips -- we know it's already a triangle)