@itwin/core-geometry 5.0.0-dev.32 → 5.0.0-dev.34

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 (173) hide show
  1. package/lib/cjs/Constant.js +17 -17
  2. package/lib/cjs/Constant.js.map +1 -1
  3. package/lib/cjs/Geometry.js +35 -35
  4. package/lib/cjs/Geometry.js.map +1 -1
  5. package/lib/cjs/bspline/KnotVector.js +2 -2
  6. package/lib/cjs/bspline/KnotVector.js.map +1 -1
  7. package/lib/cjs/clipping/AlternatingConvexClipTree.js +2 -2
  8. package/lib/cjs/clipping/AlternatingConvexClipTree.js.map +1 -1
  9. package/lib/cjs/clipping/ClipPlane.js +1 -1
  10. package/lib/cjs/clipping/ClipPlane.js.map +1 -1
  11. package/lib/cjs/clipping/ClipUtils.js +1 -1
  12. package/lib/cjs/clipping/ClipUtils.js.map +1 -1
  13. package/lib/cjs/clipping/ClipVector.js +1 -1
  14. package/lib/cjs/clipping/ClipVector.js.map +1 -1
  15. package/lib/cjs/clipping/ConvexClipPlaneSet.js +3 -3
  16. package/lib/cjs/clipping/ConvexClipPlaneSet.js.map +1 -1
  17. package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.js +1 -1
  18. package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
  19. package/lib/cjs/curve/Arc3d.js +14 -14
  20. package/lib/cjs/curve/Arc3d.js.map +1 -1
  21. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +4 -4
  22. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  23. package/lib/cjs/curve/LineString3d.js +5 -5
  24. package/lib/cjs/curve/LineString3d.js.map +1 -1
  25. package/lib/cjs/curve/RegionOpsClassificationSweeps.js +1 -1
  26. package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
  27. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +5 -5
  28. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  29. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +13 -13
  30. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  31. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js +5 -5
  32. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
  33. package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.js +5 -5
  34. package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.js.map +1 -1
  35. package/lib/cjs/curve/internalContexts/PolygonOffsetContext.js +4 -4
  36. package/lib/cjs/curve/internalContexts/PolygonOffsetContext.js.map +1 -1
  37. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js +2 -2
  38. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  39. package/lib/cjs/geometry3d/Angle.js +16 -16
  40. package/lib/cjs/geometry3d/Angle.js.map +1 -1
  41. package/lib/cjs/geometry3d/Matrix3d.js +8 -8
  42. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  43. package/lib/cjs/geometry3d/OrderedRotationAngles.js +2 -2
  44. package/lib/cjs/geometry3d/OrderedRotationAngles.js.map +1 -1
  45. package/lib/cjs/geometry3d/PointHelpers.js +5 -5
  46. package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
  47. package/lib/cjs/geometry3d/PolygonOps.js +23 -23
  48. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  49. package/lib/cjs/geometry3d/PolylineCompressionByEdgeOffset.js +3 -3
  50. package/lib/cjs/geometry3d/PolylineCompressionByEdgeOffset.js.map +1 -1
  51. package/lib/cjs/geometry3d/Range.js +4 -4
  52. package/lib/cjs/geometry3d/Range.js.map +1 -1
  53. package/lib/cjs/numerics/ClusterableArray.js +13 -13
  54. package/lib/cjs/numerics/ClusterableArray.js.map +1 -1
  55. package/lib/cjs/numerics/PascalCoefficients.js +1 -1
  56. package/lib/cjs/numerics/PascalCoefficients.js.map +1 -1
  57. package/lib/cjs/numerics/PolarData.js +1 -1
  58. package/lib/cjs/numerics/PolarData.js.map +1 -1
  59. package/lib/cjs/numerics/Polynomials.js +26 -26
  60. package/lib/cjs/numerics/Polynomials.js.map +1 -1
  61. package/lib/cjs/numerics/Quadrature.js +20 -20
  62. package/lib/cjs/numerics/Quadrature.js.map +1 -1
  63. package/lib/cjs/polyface/BoxTopology.js +67 -67
  64. package/lib/cjs/polyface/BoxTopology.js.map +1 -1
  65. package/lib/cjs/polyface/GreedyTriangulationBetweenLineStrings.js +2 -2
  66. package/lib/cjs/polyface/GreedyTriangulationBetweenLineStrings.js.map +1 -1
  67. package/lib/cjs/polyface/PolyfaceBuilder.js +4 -4
  68. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  69. package/lib/cjs/polyface/PolyfaceData.js +5 -5
  70. package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
  71. package/lib/cjs/polyface/PolyfaceQuery.js +7 -7
  72. package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
  73. package/lib/cjs/polyface/multiclip/RangeSearch.js +5 -5
  74. package/lib/cjs/polyface/multiclip/RangeSearch.js.map +1 -1
  75. package/lib/cjs/serialization/BGFBReader.js +22 -22
  76. package/lib/cjs/serialization/BGFBReader.js.map +1 -1
  77. package/lib/cjs/serialization/GeometrySamples.js +107 -107
  78. package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
  79. package/lib/cjs/topology/ChainMerge.js +4 -4
  80. package/lib/cjs/topology/ChainMerge.js.map +1 -1
  81. package/lib/cjs/topology/Graph.js +5 -5
  82. package/lib/cjs/topology/Graph.js.map +1 -1
  83. package/lib/cjs/topology/HalfEdgeGraphSpineContext.js +2 -2
  84. package/lib/cjs/topology/HalfEdgeGraphSpineContext.js.map +1 -1
  85. package/lib/cjs/topology/Triangulation.js +11 -11
  86. package/lib/cjs/topology/Triangulation.js.map +1 -1
  87. package/lib/esm/Constant.js +17 -17
  88. package/lib/esm/Constant.js.map +1 -1
  89. package/lib/esm/Geometry.js +35 -35
  90. package/lib/esm/Geometry.js.map +1 -1
  91. package/lib/esm/bspline/KnotVector.js +2 -2
  92. package/lib/esm/bspline/KnotVector.js.map +1 -1
  93. package/lib/esm/clipping/AlternatingConvexClipTree.js +2 -2
  94. package/lib/esm/clipping/AlternatingConvexClipTree.js.map +1 -1
  95. package/lib/esm/clipping/ClipPlane.js +1 -1
  96. package/lib/esm/clipping/ClipPlane.js.map +1 -1
  97. package/lib/esm/clipping/ClipUtils.js +1 -1
  98. package/lib/esm/clipping/ClipUtils.js.map +1 -1
  99. package/lib/esm/clipping/ClipVector.js +1 -1
  100. package/lib/esm/clipping/ClipVector.js.map +1 -1
  101. package/lib/esm/clipping/ConvexClipPlaneSet.js +3 -3
  102. package/lib/esm/clipping/ConvexClipPlaneSet.js.map +1 -1
  103. package/lib/esm/clipping/UnionOfConvexClipPlaneSets.js +1 -1
  104. package/lib/esm/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
  105. package/lib/esm/curve/Arc3d.js +14 -14
  106. package/lib/esm/curve/Arc3d.js.map +1 -1
  107. package/lib/esm/curve/CurveChainWithDistanceIndex.js +4 -4
  108. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  109. package/lib/esm/curve/LineString3d.js +5 -5
  110. package/lib/esm/curve/LineString3d.js.map +1 -1
  111. package/lib/esm/curve/RegionOpsClassificationSweeps.js +1 -1
  112. package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
  113. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +5 -5
  114. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  115. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +13 -13
  116. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  117. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js +5 -5
  118. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
  119. package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.js +5 -5
  120. package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.js.map +1 -1
  121. package/lib/esm/curve/internalContexts/PolygonOffsetContext.js +4 -4
  122. package/lib/esm/curve/internalContexts/PolygonOffsetContext.js.map +1 -1
  123. package/lib/esm/curve/spiral/IntegratedSpiral3d.js +2 -2
  124. package/lib/esm/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  125. package/lib/esm/geometry3d/Angle.js +16 -16
  126. package/lib/esm/geometry3d/Angle.js.map +1 -1
  127. package/lib/esm/geometry3d/Matrix3d.js +8 -8
  128. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  129. package/lib/esm/geometry3d/OrderedRotationAngles.js +2 -2
  130. package/lib/esm/geometry3d/OrderedRotationAngles.js.map +1 -1
  131. package/lib/esm/geometry3d/PointHelpers.js +5 -5
  132. package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
  133. package/lib/esm/geometry3d/PolygonOps.js +23 -23
  134. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  135. package/lib/esm/geometry3d/PolylineCompressionByEdgeOffset.js +3 -3
  136. package/lib/esm/geometry3d/PolylineCompressionByEdgeOffset.js.map +1 -1
  137. package/lib/esm/geometry3d/Range.js +4 -4
  138. package/lib/esm/geometry3d/Range.js.map +1 -1
  139. package/lib/esm/numerics/ClusterableArray.js +13 -13
  140. package/lib/esm/numerics/ClusterableArray.js.map +1 -1
  141. package/lib/esm/numerics/PascalCoefficients.js +1 -1
  142. package/lib/esm/numerics/PascalCoefficients.js.map +1 -1
  143. package/lib/esm/numerics/PolarData.js +1 -1
  144. package/lib/esm/numerics/PolarData.js.map +1 -1
  145. package/lib/esm/numerics/Polynomials.js +26 -26
  146. package/lib/esm/numerics/Polynomials.js.map +1 -1
  147. package/lib/esm/numerics/Quadrature.js +20 -20
  148. package/lib/esm/numerics/Quadrature.js.map +1 -1
  149. package/lib/esm/polyface/BoxTopology.js +67 -67
  150. package/lib/esm/polyface/BoxTopology.js.map +1 -1
  151. package/lib/esm/polyface/GreedyTriangulationBetweenLineStrings.js +2 -2
  152. package/lib/esm/polyface/GreedyTriangulationBetweenLineStrings.js.map +1 -1
  153. package/lib/esm/polyface/PolyfaceBuilder.js +4 -4
  154. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  155. package/lib/esm/polyface/PolyfaceData.js +5 -5
  156. package/lib/esm/polyface/PolyfaceData.js.map +1 -1
  157. package/lib/esm/polyface/PolyfaceQuery.js +7 -7
  158. package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
  159. package/lib/esm/polyface/multiclip/RangeSearch.js +5 -5
  160. package/lib/esm/polyface/multiclip/RangeSearch.js.map +1 -1
  161. package/lib/esm/serialization/BGFBReader.js +22 -22
  162. package/lib/esm/serialization/BGFBReader.js.map +1 -1
  163. package/lib/esm/serialization/GeometrySamples.js +107 -107
  164. package/lib/esm/serialization/GeometrySamples.js.map +1 -1
  165. package/lib/esm/topology/ChainMerge.js +4 -4
  166. package/lib/esm/topology/ChainMerge.js.map +1 -1
  167. package/lib/esm/topology/Graph.js +5 -5
  168. package/lib/esm/topology/Graph.js.map +1 -1
  169. package/lib/esm/topology/HalfEdgeGraphSpineContext.js +2 -2
  170. package/lib/esm/topology/HalfEdgeGraphSpineContext.js.map +1 -1
  171. package/lib/esm/topology/Triangulation.js +11 -11
  172. package/lib/esm/topology/Triangulation.js.map +1 -1
  173. package/package.json +4 -4
@@ -412,6 +412,8 @@ export class AlternatingCCTreeNodeCurveClipper {
412
412
  isTopOfStackEmpty() {
413
413
  return this._topOfStack.length === 0;
414
414
  }
415
+ // Is re-used by method calls
416
+ static { this._fractionIntervals = []; }
415
417
  appendSingleClipToStack(planes, insideSegments) {
416
418
  const fractionIntervals = AlternatingCCTreeNodeCurveClipper._fractionIntervals;
417
419
  if (this._curve instanceof LineSegment3d) {
@@ -518,6 +520,4 @@ export class AlternatingCCTreeNodeCurveClipper {
518
520
  }
519
521
  }
520
522
  }
521
- // Is re-used by method calls
522
- AlternatingCCTreeNodeCurveClipper._fractionIntervals = [];
523
523
  //# sourceMappingURL=AlternatingConvexClipTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AlternatingConvexClipTree.js","sourceRoot":"","sources":["../../../src/clipping/AlternatingConvexClipTree.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG5C,OAAO,EAAW,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAkB,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,qBAAqB;IAOhC;QANO,WAAM,GAAc,EAAE,CAAC;QACvB,WAAM,GAAuB,kBAAkB,CAAC,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I,GAAG,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;YACvC,eAAe,CAAC,IAAI,CAAC,uBAAuB,CAAC,aAAa,CACxD,mBAAmB,CAAC,wBAAwB,CAAC,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,EAC7D,mBAAmB,CAAC,wBAAwB,CAAC,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,CAC9D,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IACD;;;OAGG;IACI,yBAAyB,CAAC,IAA2B,EAAE,KAAsB,EAClF,eAA0C,EAAE,gBAA2C;QACvF,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YAChC,IAAI,EAAE,YAAY,cAAc;gBAC9B,IAAI,CAAC,yBAAyB,CAAC,IAAI,EAAE,EAAE,EAAE,eAAe,EAAE,gBAAgB,CAAC,CAAC;iBACzE,IAAI,EAAE,YAAY,eAAe;gBACpC,IAAI,CAAC,yBAAyB,CAAC,IAAI,EAAE,EAAE,EAAE,eAAe,EAAE,gBAAgB,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;;AA9GD,6BAA6B;AACd,oDAAkB,GAAa,EAAE,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*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module CartesianGeometry\n */\n\nimport { BSplineCurve3d } from \"../bspline/BSplineCurve\";\nimport { Arc3d } from \"../curve/Arc3d\";\nimport { CurveCollection } from \"../curve/CurveCollection\";\nimport { CurveLocationDetail, CurveLocationDetailPair } from \"../curve/CurveLocationDetail\";\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\nimport { LineSegment3d } from \"../curve/LineSegment3d\";\nimport { LineString3d } from \"../curve/LineString3d\";\nimport { Angle } from \"../geometry3d/Angle\";\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\nimport { Point3dArray } from \"../geometry3d/PointHelpers\";\nimport { PolygonOps } from \"../geometry3d/PolygonOps\";\nimport { Range1d } from \"../geometry3d/Range\";\nimport { GrowableXYZArrayCache } from \"../geometry3d/ReusableObjectCache\";\nimport { Range1dArray } from \"../numerics/Range1dArray\";\nimport { ClipPlane } from \"./ClipPlane\";\nimport { ClipUtilities, PolygonClipper } from \"./ClipUtils\";\nimport { ConvexClipPlaneSet } from \"./ConvexClipPlaneSet\";\n\n/**\n * An AlternatingConvexClipTreeNode is a node in a tree structure in which\n * <ul>\n * <li>Each node contains a ConvexClipPlaneSet.\n * <li>Each node contains an array of children which are also AlternatingConvexClipTreeNode.\n * <li>The rule for an in/out decision is that a point is IN the subtree under a node if\n * <ul>\n * <li>It is IN the node's ConvexClipPlaneSet.\n * <li>It is NOT IN any of the children.\n * </ul>\n * <li>Applying \"NOT IN any of the children\" locally to children at each level means that the ConvexClipPlaneSet\n * at adjacent levels flip between being positive areas and holes.\n * <li>Use an AlternatingConvexClipTreeNodeBuilder to construct the tree from a polygon.\n * <li>It is possible for the root clip plane set to be empty. An empty clip plane set returns \"true\"\n * for all point tests, so the meaning is just that holes are to be subtracted from the rest\n * of space.\n * <li>Although the interpretation of in/out alternates with tree levels, the ConvexClipPlaneSets\n * at each level are all \"enclosing\" planes in the usual way.\n * </ul>\n */\nexport class AlternatingCCTreeNode implements PolygonClipper {\n public points: Point3d[] = [];\n public planes: ConvexClipPlaneSet = ConvexClipPlaneSet.createEmpty();\n public children: AlternatingCCTreeNode[] = [];\n public startIdx: number = -1; // Start index into the master array (not the local points array)\n public numPoints: number = -1; // Number of points used in the master array\n\n private constructor() { }\n\n /** Initialize this node with index data referencing the parent polygon. */\n public static createWithIndices(index0: number, numPoints: number, result?: AlternatingCCTreeNode): AlternatingCCTreeNode {\n result = result ? result : new AlternatingCCTreeNode();\n result.startIdx = index0;\n result.numPoints = numPoints;\n result.children.length = 0;\n return result;\n }\n /**\n * <ul>\n * <li>Build the tree for a polygon.\n * <li>Caller creates the root node with empty constructor AlternatingConvexClipTreeNode.\n * </ul>\n */\n public static createTreeForPolygon(points: Point3d[], result?: AlternatingCCTreeNode): AlternatingCCTreeNode {\n result = result ? result : new AlternatingCCTreeNode();\n result.empty();\n const builder = AlternatingCCTreeBuilder.createPointsRef(points);\n builder.buildHullTree(result); // <-- Currently ALWAYS returns true\n return result;\n }\n /** Build the outer convex hull with inlets as first level children. */\n public static createHullAndInletsForPolygon(points: Point3d[], result?: AlternatingCCTreeNode): AlternatingCCTreeNode {\n result = result ? result : new AlternatingCCTreeNode();\n result.empty();\n const builder = AlternatingCCTreeBuilder.createPointsRef(points);\n builder.buildHullAndInletsForPolygon(result); // <-- Currently ALWAYS returns true\n return result;\n }\n private extractLoopsGo(loops: Point3d[][]) {\n loops.push(Point3dArray.clonePoint3dArray(this.points));\n for (const c of this.children)\n c.extractLoopsGo(loops);\n }\n /**\n * Return an array with all the loops in the tree.\n * This loses the alternating structure of the tree, but the collection still matches well-formed polygons by\n * parity rules.\n */\n public extractLoops(): Point3d[][] {\n const loops: Point3d[][] = [];\n this.extractLoopsGo(loops);\n return loops;\n }\n /** Resets this AlternatingConvexClipTreeNode to a newly-created state. */\n public empty() {\n this.points.length = 0;\n this.planes.planes.length = 0;\n this.children.length = 0;\n this.startIdx = -1;\n this.numPoints = -1;\n }\n /** Creates a deep copy of this node (expensive - copies Geometry, and is recursive for children array). */\n public clone(result?: AlternatingCCTreeNode): AlternatingCCTreeNode {\n result = result ? result : new AlternatingCCTreeNode();\n for (const point of this.points)\n result.points.push(point.clone());\n result.planes = ConvexClipPlaneSet.createEmpty();\n for (const plane of this.planes.planes)\n result.planes.planes.push(plane.clone());\n for (const node of this.children)\n result.children.push(node.clone());\n result.startIdx = this.startIdx;\n result.numPoints = this.numPoints;\n return result;\n }\n /** Add a new child that has an empty plane set and given indices. */\n public addEmptyChild(index0: number, numPoints: number) {\n const newNode = AlternatingCCTreeNode.createWithIndices(index0, numPoints);\n this.children.push(newNode);\n }\n /** Add a plane to the ConvexClipPlaneSet. */\n public addPlane(plane: ClipPlane) {\n this.planes.addPlaneToConvexSet(plane);\n }\n /** Search with alternating in and out semantics. */\n public isPointOnOrInside(point: Point3d): boolean {\n const inRoot = this.planes.isPointOnOrInside(point, 0.0);\n if (!inRoot)\n return false;\n for (const child of this.children) {\n if (child.isPointOnOrInside(point))\n return false;\n }\n return true;\n }\n /**\n * Add an AlternatingConvexClipTreeNode as a child of this one -- i.e. a hole.\n * * The child pointer is pushed directly to the tree -- not cloned.\n */\n public captureConvexClipPlaneSetAsVoid(child: AlternatingCCTreeNode) {\n this.children.push(child);\n }\n /** Append start-end positions for curve intervals classified as inside or outside. */\n public appendCurvePrimitiveClipIntervals(\n curve: CurvePrimitive, insideIntervals: CurveLocationDetailPair[], outsideIntervals: CurveLocationDetailPair[],\n ): void {\n const clipper = new AlternatingCCTreeNodeCurveClipper();\n clipper.appendSingleClipPrimitive(this, curve, insideIntervals, outsideIntervals);\n }\n /** Append start-end positions for curve intervals classified as inside or outside. */\n public appendCurveCollectionClipIntervals(\n curves: CurveCollection, insideIntervals: CurveLocationDetailPair[], outsideIntervals: CurveLocationDetailPair[],\n ): void {\n const clipper = new AlternatingCCTreeNodeCurveClipper();\n clipper.appendCurveCollectionClip(this, curves, insideIntervals, outsideIntervals);\n }\n /**\n * @param xyz input polygon. This is not changed.\n * @param insideFragments Array to receive \"inside\" fragments. Each fragment is a GrowableXYZArray grabbed from\n * the cache. This is NOT cleared.\n * @param outsideFragments Array to receive \"outside\" fragments. Each fragment is a GrowableXYZArray grabbed\n * from the cache. This is NOT cleared.\n * @param arrayCache cache for reusable GrowableXYZArray.\n */\n public appendPolygonClip(\n xyz: IndexedXYZCollection,\n insideFragments: GrowableXYZArray[],\n outsideFragments: GrowableXYZArray[],\n arrayCache: GrowableXYZArrayCache,\n ): void {\n // At first level ..\n // newInside is subject to re-clip by children.\n // outside is definitively outside\n const oldOutsideCount = outsideFragments.length;\n const newInside = this.planes.clipInsidePushOutside(xyz, outsideFragments, arrayCache);\n if (newInside === undefined) {\n ClipUtilities.restoreSingletonInPlaceOfMultipleShards(outsideFragments, oldOutsideCount, xyz, arrayCache);\n } else {\n let carryForwardA = [newInside];\n let carryForwardB: GrowableXYZArray[] = [];\n let tempAB;\n let shard;\n for (const c of this.children) {\n carryForwardB.length = 0;\n while (undefined !== (shard = carryForwardA.pop())) {\n // Anything inside this child is truly outside ...\n c.appendPolygonClip(shard, outsideFragments, carryForwardB, arrayCache);\n arrayCache.dropToCache(shard);\n }\n tempAB = carryForwardB;\n carryForwardB = carryForwardA; // and that is empty\n carryForwardA = tempAB;\n }\n while (undefined !== (shard = carryForwardA.pop())) {\n insideFragments.push(shard);\n }\n }\n }\n public depth(): number {\n const myDepth = 1;\n let maxChildDepth = 0;\n for (const c of this.children) {\n maxChildDepth = Math.max(maxChildDepth, c.depth());\n }\n return myDepth + maxChildDepth;\n }\n}\n\n/**\n * Context structure for building an AlternatingConvexClipTreeNode from a polygon.\n * <ul>\n * <li> The polygon is copied to the local m_points structure.\n * <li> During construction, m_stack contains indices of a sequence of points with uniform concavity.\n * </ul>\n */\nexport class AlternatingCCTreeBuilder {\n private _points: Point3d[] = [];\n private _stack: number[] = [];\n\n private constructor() { }\n\n public static createPointsRef(points: Point3d[], result?: AlternatingCCTreeBuilder): AlternatingCCTreeBuilder {\n result = result ? result : new AlternatingCCTreeBuilder();\n result._points = points;\n if (PolygonOps.areaXY(points) < 0.0)\n result._points.reverse();\n if (result._points[result._points.length - 1].isAlmostEqualMetric(result._points[0]))\n result._points.pop();\n return result;\n }\n public get period(): number {\n return this._points.length;\n }\n public indexAfter(i: number) {\n return (i + 1) % this._points.length;\n }\n public indexBefore(i: number) {\n return (i + this._points.length - 1) % this._points.length;\n }\n public pushIndex(primaryPointIndex: number) {\n this._stack.push(primaryPointIndex);\n }\n private static cross(pointA: Point3d, pointB: Point3d, pointC: Point3d): number {\n return pointA.crossProductToPointsXY(pointB, pointC);\n }\n /*\n public isInsideTurn(pointA: Point3d, pointB: Point3d, pointC: Point3d, sign: number) {\n return sign * AlternatingCCTreeBuilder.cross(pointA, pointB, pointC) > 0;\n }\n */\n public cyclicStackPoint(cyclicIndex: number): Point3d { // SIGNED index -- but negatives must be in first 10 periods?\n let stackIndex: number;\n const stack = this._stack;\n if (cyclicIndex > 0)\n stackIndex = cyclicIndex;\n else\n stackIndex = cyclicIndex + 10 * stack.length;\n stackIndex = stackIndex % stack.length;\n return this._points[stack[stackIndex]];\n }\n public signFromStackTip(pointIndex: number, sign: number) {\n const pointA = this.cyclicStackPoint(-2);\n const pointB = this.cyclicStackPoint(-1);\n const pointC = this._points[pointIndex];\n return sign * AlternatingCCTreeBuilder.cross(pointA, pointB, pointC) >= 0.0 ? 1 : -1;\n }\n /*\n * Test of xyz is in the convex region bounded by stack points:\n * <ul>\n * <li>polygon[i0]..polygon[i1]\n * <li>polygon[j0]..polygon[j1]\n * <li>polygon[i0]..polygon[i1]\n * </ul>\n * with \"inside\" controlled by sign multiplier.\n public isConvexContinuation(point: Point3d, i0: number, i1: number, j0: number, j1: number, sign: number): boolean {\n const points = this.points;\n const stack = this.stack;\n return this.isInsideTurn(points[stack[i0]], points[stack[i1]], point, sign)\n && this.isInsideTurn(points[stack[i0]], points[stack[j0]], point, sign)\n && this.isInsideTurn(points[stack[j1]], points[stack[i1]], point, sign);\n }\n */\n public get indexOfMaxX() {\n let k = 0;\n const points = this._points;\n const nPoints = this._points.length;\n for (let i = 1; i < nPoints; i++) {\n if (points[i].x > points[k].x)\n k = i;\n }\n return k;\n }\n /** Pop from the stack until the sign condition is satisfied */\n public extendHullChain(k: number, sign: number, pushAfterPops: boolean) {\n while (this._stack.length > 1 && this.signFromStackTip(k, sign) < 0.0)\n this._stack.pop();\n if (pushAfterPops)\n this.pushIndex(k);\n }\n public collectHullChain(kStart: number, numK: number, sign: number) {\n this._stack.length = 0;\n if (numK > 2) {\n let k = kStart;\n for (let i = 0; i < numK; i++) {\n this.extendHullChain(k, sign, true);\n k = this.indexAfter(k);\n }\n }\n }\n public collectHullPointsInArray(points: Point3d[], kStart: number, numK: number, _sign: number) {\n points.length = 0;\n if (numK > 2) {\n let k = kStart;\n for (let i = 0; i < numK; i++) {\n points.push(this._points[k]);\n k = this.indexAfter(k);\n }\n }\n }\n private buildHullTreeGo(\n root: AlternatingCCTreeNode, isPositiveArea: boolean, recurseToChildren: boolean = true,\n ): boolean {\n this.collectHullChain(root.startIdx, root.numPoints, isPositiveArea ? 1.0 : -1.0);\n root.points.length = 0;\n const stack = this._stack;\n const points = this._points;\n const stackLen = stack.length;\n\n for (let i = 0; i < stackLen; i++) {\n const k0 = stack[i];\n root.points.push(points[k0]);\n if (i + 1 < stackLen) {\n let k1 = stack[i + 1];\n if (k1 === this.indexAfter(k0)) {\n // two original points in sequence -- need a clip plane right here!!!\n const plane = ClipPlane.createEdgeAndUpVector(\n points[k0], points[k1], Vector3d.create(0, 0, 1), Angle.createRadians(0),\n );\n if (plane !== undefined) {\n if (isPositiveArea)\n plane.negateInPlace();\n root.addPlane(plane);\n }\n } else {\n if (k1 < k0)\n k1 += this.period;\n root.addEmptyChild(k0, k1 - k0 + 1);\n }\n }\n }\n if (recurseToChildren) {\n for (const child of root.children)\n this.buildHullTreeGo(child, !isPositiveArea);\n } else {\n for (const child of root.children)\n this.collectHullPointsInArray(child.points, child.startIdx, child.numPoints, isPositiveArea ? -1.0 : 1.0);\n }\n return true; // Are there failure modes? What happens with crossing data?..\n }\n /**\n * <ul>\n * <li> Input a ClipTreeRoot that has start and count data\n * <li> Build the hull for that data range\n * <li> Store the hull points in the root\n * <li> Add children with start and count data\n * <li> Recursively move to children\n * </ul>\n */\n public buildHullAndInletsForPolygon(root: AlternatingCCTreeNode): boolean {\n AlternatingCCTreeNode.createWithIndices(this.indexOfMaxX, this.period + 1, root);\n return this.buildHullTreeGo(root, true, false);\n }\n /**\n * <ul>\n * <li> Input a ClipTreeRoot that has start and count data\n * <li> Build the hull for that data range\n * <li> Store the hull points in the root\n * <li> Add children with start and count data\n * <li> Recursively move to children\n * </ul>\n */\n public buildHullTree(root: AlternatingCCTreeNode): boolean {\n AlternatingCCTreeNode.createWithIndices(this.indexOfMaxX, this.period + 1, root);\n return this.buildHullTreeGo(root, true);\n }\n}\n\nexport class AlternatingCCTreeNodeCurveClipper {\n private _curve: CurvePrimitive | undefined;\n private _intervalStack: Range1d[][];\n private _stackDepth: number;\n\n public constructor() {\n this._stackDepth = 0;\n this._intervalStack = [];\n }\n\n private setCurveRef(curve: CurvePrimitive) { this._curve = curve; }\n private popSegmentFrame() {\n if (this._stackDepth > 0) {\n this._topOfStack.length = 0; // formality.\n this._stackDepth -= 1;\n }\n }\n private clearSegmentStack() {\n while (this._stackDepth > 0)\n this.popSegmentFrame(); // and that will reduce stack depth\n }\n private pushEmptySegmentFrame() {\n this._stackDepth += 1;\n while (this._intervalStack.length < this._stackDepth)\n this._intervalStack.push([]);\n this._topOfStack.length = 0;\n }\n private get _topOfStack(): Range1d[] { return this._intervalStack[this._stackDepth - 1]; }\n // set the top of the stack (as defined by stackDepth -- not array length)\n private set _topOfStack(value: Range1d[]) {\n const n = this._stackDepth;\n if (n > 0)\n this._intervalStack[n - 1] = value;\n }\n /** Access entry [topOfStack() - numSkip] */\n private stackEntry(numSkip: number): Range1d[] {\n if (numSkip <= this._stackDepth)\n return this._intervalStack[this._stackDepth - 1 - numSkip];\n else\n return [];\n }\n private isTopOfStackEmpty(): boolean {\n return this._topOfStack.length === 0;\n }\n // Is re-used by method calls\n private static _fractionIntervals: number[] = [];\n private appendSingleClipToStack(planes: ConvexClipPlaneSet, insideSegments: Range1d[]): boolean {\n const fractionIntervals = AlternatingCCTreeNodeCurveClipper._fractionIntervals;\n\n if (this._curve instanceof LineSegment3d) {\n const segment = this._curve;\n let f0: number;\n let f1: number;\n if (segment.announceClipIntervals(planes, (a0: number, a1: number, _cp: CurvePrimitive) => { f0 = a0; f1 = a1; })) {\n insideSegments.push(Range1d.createXX(f0!, f1!));\n }\n return true;\n\n } else if (this._curve instanceof Arc3d) {\n const arc = this._curve;\n fractionIntervals.length = 0;\n arc.announceClipIntervals(planes, (a0: number, a1: number, _cp: CurvePrimitive) => {\n fractionIntervals.push(a0); fractionIntervals.push(a1);\n });\n for (let i = 0; i < fractionIntervals.length; i += 2)\n insideSegments.push(Range1d.createXX(fractionIntervals[i], fractionIntervals[i + 1]));\n return true;\n\n } else if (this._curve instanceof LineString3d && (this._curve).points.length > 1) {\n const linestring = this._curve;\n let f0: number;\n let f1: number;\n const nPoints = linestring.points.length;\n const df = 1.0 / (nPoints - 1);\n for (let i = 0; i < nPoints - 1; i++) {\n const segment = LineSegment3d.create(linestring.points[i], linestring.points[i + 1]);\n if (segment.announceClipIntervals(planes, (a0: number, a1: number, _cp: CurvePrimitive) => { f0 = a0; f1 = a1; })) {\n insideSegments.push(Range1d.createXX((i + f0!) * df, (i + f1!) * df));\n }\n }\n return true;\n\n } else if (this._curve instanceof BSplineCurve3d) {\n const bcurve = this._curve;\n fractionIntervals.length = 0;\n bcurve.announceClipIntervals(planes, (a0: number, a1: number, _cp: CurvePrimitive) => {\n fractionIntervals.push(a0); fractionIntervals.push(a1);\n });\n for (let i = 0; i < fractionIntervals.length; i += 2)\n insideSegments.push(Range1d.createXX(fractionIntervals[i], fractionIntervals[i + 1]));\n return true;\n }\n\n return false;\n }\n /**\n * Run one level of recursion. On return, the stack is one level deeper than at entry and the new top of the stack\n * has clip for this node (expensive -- must clone items of arrays during \"swaps\").\n */\n private recurse(node: AlternatingCCTreeNode) {\n this.pushEmptySegmentFrame();\n this.appendSingleClipToStack(node.planes, this._topOfStack);\n Range1dArray.sort(this._topOfStack);\n if (this.isTopOfStackEmpty())\n return;\n for (const child of node.children) {\n this.recurse(child);\n if (!this.isTopOfStackEmpty()) {\n const ranges = Range1dArray.differenceSorted(this.stackEntry(1), this.stackEntry(0));\n this.popSegmentFrame();\n this._topOfStack = ranges;\n } else {\n this.popSegmentFrame();\n }\n if (this.isTopOfStackEmpty())\n break;\n }\n }\n /**\n * Modifies the insideIntervals array given in place.\n * Note: curve given is passed by reference and stored.\n */\n public appendSingleClipPrimitive(root: AlternatingCCTreeNode, curve: CurvePrimitive,\n insideIntervals: CurveLocationDetailPair[], _outsideIntervals: CurveLocationDetailPair[]) {\n this.setCurveRef(curve);\n this.clearSegmentStack();\n this.recurse(root);\n if (this._stackDepth !== 1)\n return;\n const intervals = this._topOfStack;\n for (const interval of intervals) {\n const f0 = interval.low;\n const f1 = interval.high;\n const xyz0 = curve.fractionToPoint(f0);\n const xyz1 = curve.fractionToPoint(f1);\n insideIntervals.push(CurveLocationDetailPair.createCapture(\n CurveLocationDetail.createCurveFractionPoint(curve, f0, xyz0),\n CurveLocationDetail.createCurveFractionPoint(curve, f1, xyz1),\n ));\n }\n this.popSegmentFrame();\n }\n /**\n * Modifies the insideIntervals array given in place.\n * Note: curve given is passed by reference and stored.\n */\n public appendCurveCollectionClip(root: AlternatingCCTreeNode, curve: CurveCollection,\n insideIntervals: CurveLocationDetailPair[], outsideIntervals: CurveLocationDetailPair[]) {\n for (const cp of curve.children) {\n if (cp instanceof CurvePrimitive)\n this.appendSingleClipPrimitive(root, cp, insideIntervals, outsideIntervals);\n else if (cp instanceof CurveCollection)\n this.appendCurveCollectionClip(root, cp, insideIntervals, outsideIntervals);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"AlternatingConvexClipTree.js","sourceRoot":"","sources":["../../../src/clipping/AlternatingConvexClipTree.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,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AsB,EAClF,eAA0C,EAAE,gBAA2C;QACvF,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YAChC,IAAI,EAAE,YAAY,cAAc;gBAC9B,IAAI,CAAC,yBAAyB,CAAC,IAAI,EAAE,EAAE,EAAE,eAAe,EAAE,gBAAgB,CAAC,CAAC;iBACzE,IAAI,EAAE,YAAY,eAAe;gBACpC,IAAI,CAAC,yBAAyB,CAAC,IAAI,EAAE,EAAE,EAAE,eAAe,EAAE,gBAAgB,CAAC,CAAC;QAChF,CAAC;IACH,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*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module CartesianGeometry\n */\n\nimport { BSplineCurve3d } from \"../bspline/BSplineCurve\";\nimport { Arc3d } from \"../curve/Arc3d\";\nimport { CurveCollection } from \"../curve/CurveCollection\";\nimport { CurveLocationDetail, CurveLocationDetailPair } from \"../curve/CurveLocationDetail\";\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\nimport { LineSegment3d } from \"../curve/LineSegment3d\";\nimport { LineString3d } from \"../curve/LineString3d\";\nimport { Angle } from \"../geometry3d/Angle\";\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\nimport { Point3dArray } from \"../geometry3d/PointHelpers\";\nimport { PolygonOps } from \"../geometry3d/PolygonOps\";\nimport { Range1d } from \"../geometry3d/Range\";\nimport { GrowableXYZArrayCache } from \"../geometry3d/ReusableObjectCache\";\nimport { Range1dArray } from \"../numerics/Range1dArray\";\nimport { ClipPlane } from \"./ClipPlane\";\nimport { ClipUtilities, PolygonClipper } from \"./ClipUtils\";\nimport { ConvexClipPlaneSet } from \"./ConvexClipPlaneSet\";\n\n/**\n * An AlternatingConvexClipTreeNode is a node in a tree structure in which\n * <ul>\n * <li>Each node contains a ConvexClipPlaneSet.\n * <li>Each node contains an array of children which are also AlternatingConvexClipTreeNode.\n * <li>The rule for an in/out decision is that a point is IN the subtree under a node if\n * <ul>\n * <li>It is IN the node's ConvexClipPlaneSet.\n * <li>It is NOT IN any of the children.\n * </ul>\n * <li>Applying \"NOT IN any of the children\" locally to children at each level means that the ConvexClipPlaneSet\n * at adjacent levels flip between being positive areas and holes.\n * <li>Use an AlternatingConvexClipTreeNodeBuilder to construct the tree from a polygon.\n * <li>It is possible for the root clip plane set to be empty. An empty clip plane set returns \"true\"\n * for all point tests, so the meaning is just that holes are to be subtracted from the rest\n * of space.\n * <li>Although the interpretation of in/out alternates with tree levels, the ConvexClipPlaneSets\n * at each level are all \"enclosing\" planes in the usual way.\n * </ul>\n */\nexport class AlternatingCCTreeNode implements PolygonClipper {\n public points: Point3d[] = [];\n public planes: ConvexClipPlaneSet = ConvexClipPlaneSet.createEmpty();\n public children: AlternatingCCTreeNode[] = [];\n public startIdx: number = -1; // Start index into the master array (not the local points array)\n public numPoints: number = -1; // Number of points used in the master array\n\n private constructor() { }\n\n /** Initialize this node with index data referencing the parent polygon. */\n public static createWithIndices(index0: number, numPoints: number, result?: AlternatingCCTreeNode): AlternatingCCTreeNode {\n result = result ? result : new AlternatingCCTreeNode();\n result.startIdx = index0;\n result.numPoints = numPoints;\n result.children.length = 0;\n return result;\n }\n /**\n * <ul>\n * <li>Build the tree for a polygon.\n * <li>Caller creates the root node with empty constructor AlternatingConvexClipTreeNode.\n * </ul>\n */\n public static createTreeForPolygon(points: Point3d[], result?: AlternatingCCTreeNode): AlternatingCCTreeNode {\n result = result ? result : new AlternatingCCTreeNode();\n result.empty();\n const builder = AlternatingCCTreeBuilder.createPointsRef(points);\n builder.buildHullTree(result); // <-- Currently ALWAYS returns true\n return result;\n }\n /** Build the outer convex hull with inlets as first level children. */\n public static createHullAndInletsForPolygon(points: Point3d[], result?: AlternatingCCTreeNode): AlternatingCCTreeNode {\n result = result ? result : new AlternatingCCTreeNode();\n result.empty();\n const builder = AlternatingCCTreeBuilder.createPointsRef(points);\n builder.buildHullAndInletsForPolygon(result); // <-- Currently ALWAYS returns true\n return result;\n }\n private extractLoopsGo(loops: Point3d[][]) {\n loops.push(Point3dArray.clonePoint3dArray(this.points));\n for (const c of this.children)\n c.extractLoopsGo(loops);\n }\n /**\n * Return an array with all the loops in the tree.\n * This loses the alternating structure of the tree, but the collection still matches well-formed polygons by\n * parity rules.\n */\n public extractLoops(): Point3d[][] {\n const loops: Point3d[][] = [];\n this.extractLoopsGo(loops);\n return loops;\n }\n /** Resets this AlternatingConvexClipTreeNode to a newly-created state. */\n public empty() {\n this.points.length = 0;\n this.planes.planes.length = 0;\n this.children.length = 0;\n this.startIdx = -1;\n this.numPoints = -1;\n }\n /** Creates a deep copy of this node (expensive - copies Geometry, and is recursive for children array). */\n public clone(result?: AlternatingCCTreeNode): AlternatingCCTreeNode {\n result = result ? result : new AlternatingCCTreeNode();\n for (const point of this.points)\n result.points.push(point.clone());\n result.planes = ConvexClipPlaneSet.createEmpty();\n for (const plane of this.planes.planes)\n result.planes.planes.push(plane.clone());\n for (const node of this.children)\n result.children.push(node.clone());\n result.startIdx = this.startIdx;\n result.numPoints = this.numPoints;\n return result;\n }\n /** Add a new child that has an empty plane set and given indices. */\n public addEmptyChild(index0: number, numPoints: number) {\n const newNode = AlternatingCCTreeNode.createWithIndices(index0, numPoints);\n this.children.push(newNode);\n }\n /** Add a plane to the ConvexClipPlaneSet. */\n public addPlane(plane: ClipPlane) {\n this.planes.addPlaneToConvexSet(plane);\n }\n /** Search with alternating in and out semantics. */\n public isPointOnOrInside(point: Point3d): boolean {\n const inRoot = this.planes.isPointOnOrInside(point, 0.0);\n if (!inRoot)\n return false;\n for (const child of this.children) {\n if (child.isPointOnOrInside(point))\n return false;\n }\n return true;\n }\n /**\n * Add an AlternatingConvexClipTreeNode as a child of this one -- i.e. a hole.\n * * The child pointer is pushed directly to the tree -- not cloned.\n */\n public captureConvexClipPlaneSetAsVoid(child: AlternatingCCTreeNode) {\n this.children.push(child);\n }\n /** Append start-end positions for curve intervals classified as inside or outside. */\n public appendCurvePrimitiveClipIntervals(\n curve: CurvePrimitive, insideIntervals: CurveLocationDetailPair[], outsideIntervals: CurveLocationDetailPair[],\n ): void {\n const clipper = new AlternatingCCTreeNodeCurveClipper();\n clipper.appendSingleClipPrimitive(this, curve, insideIntervals, outsideIntervals);\n }\n /** Append start-end positions for curve intervals classified as inside or outside. */\n public appendCurveCollectionClipIntervals(\n curves: CurveCollection, insideIntervals: CurveLocationDetailPair[], outsideIntervals: CurveLocationDetailPair[],\n ): void {\n const clipper = new AlternatingCCTreeNodeCurveClipper();\n clipper.appendCurveCollectionClip(this, curves, insideIntervals, outsideIntervals);\n }\n /**\n * @param xyz input polygon. This is not changed.\n * @param insideFragments Array to receive \"inside\" fragments. Each fragment is a GrowableXYZArray grabbed from\n * the cache. This is NOT cleared.\n * @param outsideFragments Array to receive \"outside\" fragments. Each fragment is a GrowableXYZArray grabbed\n * from the cache. This is NOT cleared.\n * @param arrayCache cache for reusable GrowableXYZArray.\n */\n public appendPolygonClip(\n xyz: IndexedXYZCollection,\n insideFragments: GrowableXYZArray[],\n outsideFragments: GrowableXYZArray[],\n arrayCache: GrowableXYZArrayCache,\n ): void {\n // At first level ..\n // newInside is subject to re-clip by children.\n // outside is definitively outside\n const oldOutsideCount = outsideFragments.length;\n const newInside = this.planes.clipInsidePushOutside(xyz, outsideFragments, arrayCache);\n if (newInside === undefined) {\n ClipUtilities.restoreSingletonInPlaceOfMultipleShards(outsideFragments, oldOutsideCount, xyz, arrayCache);\n } else {\n let carryForwardA = [newInside];\n let carryForwardB: GrowableXYZArray[] = [];\n let tempAB;\n let shard;\n for (const c of this.children) {\n carryForwardB.length = 0;\n while (undefined !== (shard = carryForwardA.pop())) {\n // Anything inside this child is truly outside ...\n c.appendPolygonClip(shard, outsideFragments, carryForwardB, arrayCache);\n arrayCache.dropToCache(shard);\n }\n tempAB = carryForwardB;\n carryForwardB = carryForwardA; // and that is empty\n carryForwardA = tempAB;\n }\n while (undefined !== (shard = carryForwardA.pop())) {\n insideFragments.push(shard);\n }\n }\n }\n public depth(): number {\n const myDepth = 1;\n let maxChildDepth = 0;\n for (const c of this.children) {\n maxChildDepth = Math.max(maxChildDepth, c.depth());\n }\n return myDepth + maxChildDepth;\n }\n}\n\n/**\n * Context structure for building an AlternatingConvexClipTreeNode from a polygon.\n * <ul>\n * <li> The polygon is copied to the local m_points structure.\n * <li> During construction, m_stack contains indices of a sequence of points with uniform concavity.\n * </ul>\n */\nexport class AlternatingCCTreeBuilder {\n private _points: Point3d[] = [];\n private _stack: number[] = [];\n\n private constructor() { }\n\n public static createPointsRef(points: Point3d[], result?: AlternatingCCTreeBuilder): AlternatingCCTreeBuilder {\n result = result ? result : new AlternatingCCTreeBuilder();\n result._points = points;\n if (PolygonOps.areaXY(points) < 0.0)\n result._points.reverse();\n if (result._points[result._points.length - 1].isAlmostEqualMetric(result._points[0]))\n result._points.pop();\n return result;\n }\n public get period(): number {\n return this._points.length;\n }\n public indexAfter(i: number) {\n return (i + 1) % this._points.length;\n }\n public indexBefore(i: number) {\n return (i + this._points.length - 1) % this._points.length;\n }\n public pushIndex(primaryPointIndex: number) {\n this._stack.push(primaryPointIndex);\n }\n private static cross(pointA: Point3d, pointB: Point3d, pointC: Point3d): number {\n return pointA.crossProductToPointsXY(pointB, pointC);\n }\n /*\n public isInsideTurn(pointA: Point3d, pointB: Point3d, pointC: Point3d, sign: number) {\n return sign * AlternatingCCTreeBuilder.cross(pointA, pointB, pointC) > 0;\n }\n */\n public cyclicStackPoint(cyclicIndex: number): Point3d { // SIGNED index -- but negatives must be in first 10 periods?\n let stackIndex: number;\n const stack = this._stack;\n if (cyclicIndex > 0)\n stackIndex = cyclicIndex;\n else\n stackIndex = cyclicIndex + 10 * stack.length;\n stackIndex = stackIndex % stack.length;\n return this._points[stack[stackIndex]];\n }\n public signFromStackTip(pointIndex: number, sign: number) {\n const pointA = this.cyclicStackPoint(-2);\n const pointB = this.cyclicStackPoint(-1);\n const pointC = this._points[pointIndex];\n return sign * AlternatingCCTreeBuilder.cross(pointA, pointB, pointC) >= 0.0 ? 1 : -1;\n }\n /*\n * Test of xyz is in the convex region bounded by stack points:\n * <ul>\n * <li>polygon[i0]..polygon[i1]\n * <li>polygon[j0]..polygon[j1]\n * <li>polygon[i0]..polygon[i1]\n * </ul>\n * with \"inside\" controlled by sign multiplier.\n public isConvexContinuation(point: Point3d, i0: number, i1: number, j0: number, j1: number, sign: number): boolean {\n const points = this.points;\n const stack = this.stack;\n return this.isInsideTurn(points[stack[i0]], points[stack[i1]], point, sign)\n && this.isInsideTurn(points[stack[i0]], points[stack[j0]], point, sign)\n && this.isInsideTurn(points[stack[j1]], points[stack[i1]], point, sign);\n }\n */\n public get indexOfMaxX() {\n let k = 0;\n const points = this._points;\n const nPoints = this._points.length;\n for (let i = 1; i < nPoints; i++) {\n if (points[i].x > points[k].x)\n k = i;\n }\n return k;\n }\n /** Pop from the stack until the sign condition is satisfied */\n public extendHullChain(k: number, sign: number, pushAfterPops: boolean) {\n while (this._stack.length > 1 && this.signFromStackTip(k, sign) < 0.0)\n this._stack.pop();\n if (pushAfterPops)\n this.pushIndex(k);\n }\n public collectHullChain(kStart: number, numK: number, sign: number) {\n this._stack.length = 0;\n if (numK > 2) {\n let k = kStart;\n for (let i = 0; i < numK; i++) {\n this.extendHullChain(k, sign, true);\n k = this.indexAfter(k);\n }\n }\n }\n public collectHullPointsInArray(points: Point3d[], kStart: number, numK: number, _sign: number) {\n points.length = 0;\n if (numK > 2) {\n let k = kStart;\n for (let i = 0; i < numK; i++) {\n points.push(this._points[k]);\n k = this.indexAfter(k);\n }\n }\n }\n private buildHullTreeGo(\n root: AlternatingCCTreeNode, isPositiveArea: boolean, recurseToChildren: boolean = true,\n ): boolean {\n this.collectHullChain(root.startIdx, root.numPoints, isPositiveArea ? 1.0 : -1.0);\n root.points.length = 0;\n const stack = this._stack;\n const points = this._points;\n const stackLen = stack.length;\n\n for (let i = 0; i < stackLen; i++) {\n const k0 = stack[i];\n root.points.push(points[k0]);\n if (i + 1 < stackLen) {\n let k1 = stack[i + 1];\n if (k1 === this.indexAfter(k0)) {\n // two original points in sequence -- need a clip plane right here!!!\n const plane = ClipPlane.createEdgeAndUpVector(\n points[k0], points[k1], Vector3d.create(0, 0, 1), Angle.createRadians(0),\n );\n if (plane !== undefined) {\n if (isPositiveArea)\n plane.negateInPlace();\n root.addPlane(plane);\n }\n } else {\n if (k1 < k0)\n k1 += this.period;\n root.addEmptyChild(k0, k1 - k0 + 1);\n }\n }\n }\n if (recurseToChildren) {\n for (const child of root.children)\n this.buildHullTreeGo(child, !isPositiveArea);\n } else {\n for (const child of root.children)\n this.collectHullPointsInArray(child.points, child.startIdx, child.numPoints, isPositiveArea ? -1.0 : 1.0);\n }\n return true; // Are there failure modes? What happens with crossing data?..\n }\n /**\n * <ul>\n * <li> Input a ClipTreeRoot that has start and count data\n * <li> Build the hull for that data range\n * <li> Store the hull points in the root\n * <li> Add children with start and count data\n * <li> Recursively move to children\n * </ul>\n */\n public buildHullAndInletsForPolygon(root: AlternatingCCTreeNode): boolean {\n AlternatingCCTreeNode.createWithIndices(this.indexOfMaxX, this.period + 1, root);\n return this.buildHullTreeGo(root, true, false);\n }\n /**\n * <ul>\n * <li> Input a ClipTreeRoot that has start and count data\n * <li> Build the hull for that data range\n * <li> Store the hull points in the root\n * <li> Add children with start and count data\n * <li> Recursively move to children\n * </ul>\n */\n public buildHullTree(root: AlternatingCCTreeNode): boolean {\n AlternatingCCTreeNode.createWithIndices(this.indexOfMaxX, this.period + 1, root);\n return this.buildHullTreeGo(root, true);\n }\n}\n\nexport class AlternatingCCTreeNodeCurveClipper {\n private _curve: CurvePrimitive | undefined;\n private _intervalStack: Range1d[][];\n private _stackDepth: number;\n\n public constructor() {\n this._stackDepth = 0;\n this._intervalStack = [];\n }\n\n private setCurveRef(curve: CurvePrimitive) { this._curve = curve; }\n private popSegmentFrame() {\n if (this._stackDepth > 0) {\n this._topOfStack.length = 0; // formality.\n this._stackDepth -= 1;\n }\n }\n private clearSegmentStack() {\n while (this._stackDepth > 0)\n this.popSegmentFrame(); // and that will reduce stack depth\n }\n private pushEmptySegmentFrame() {\n this._stackDepth += 1;\n while (this._intervalStack.length < this._stackDepth)\n this._intervalStack.push([]);\n this._topOfStack.length = 0;\n }\n private get _topOfStack(): Range1d[] { return this._intervalStack[this._stackDepth - 1]; }\n // set the top of the stack (as defined by stackDepth -- not array length)\n private set _topOfStack(value: Range1d[]) {\n const n = this._stackDepth;\n if (n > 0)\n this._intervalStack[n - 1] = value;\n }\n /** Access entry [topOfStack() - numSkip] */\n private stackEntry(numSkip: number): Range1d[] {\n if (numSkip <= this._stackDepth)\n return this._intervalStack[this._stackDepth - 1 - numSkip];\n else\n return [];\n }\n private isTopOfStackEmpty(): boolean {\n return this._topOfStack.length === 0;\n }\n // Is re-used by method calls\n private static _fractionIntervals: number[] = [];\n private appendSingleClipToStack(planes: ConvexClipPlaneSet, insideSegments: Range1d[]): boolean {\n const fractionIntervals = AlternatingCCTreeNodeCurveClipper._fractionIntervals;\n\n if (this._curve instanceof LineSegment3d) {\n const segment = this._curve;\n let f0: number;\n let f1: number;\n if (segment.announceClipIntervals(planes, (a0: number, a1: number, _cp: CurvePrimitive) => { f0 = a0; f1 = a1; })) {\n insideSegments.push(Range1d.createXX(f0!, f1!));\n }\n return true;\n\n } else if (this._curve instanceof Arc3d) {\n const arc = this._curve;\n fractionIntervals.length = 0;\n arc.announceClipIntervals(planes, (a0: number, a1: number, _cp: CurvePrimitive) => {\n fractionIntervals.push(a0); fractionIntervals.push(a1);\n });\n for (let i = 0; i < fractionIntervals.length; i += 2)\n insideSegments.push(Range1d.createXX(fractionIntervals[i], fractionIntervals[i + 1]));\n return true;\n\n } else if (this._curve instanceof LineString3d && (this._curve).points.length > 1) {\n const linestring = this._curve;\n let f0: number;\n let f1: number;\n const nPoints = linestring.points.length;\n const df = 1.0 / (nPoints - 1);\n for (let i = 0; i < nPoints - 1; i++) {\n const segment = LineSegment3d.create(linestring.points[i], linestring.points[i + 1]);\n if (segment.announceClipIntervals(planes, (a0: number, a1: number, _cp: CurvePrimitive) => { f0 = a0; f1 = a1; })) {\n insideSegments.push(Range1d.createXX((i + f0!) * df, (i + f1!) * df));\n }\n }\n return true;\n\n } else if (this._curve instanceof BSplineCurve3d) {\n const bcurve = this._curve;\n fractionIntervals.length = 0;\n bcurve.announceClipIntervals(planes, (a0: number, a1: number, _cp: CurvePrimitive) => {\n fractionIntervals.push(a0); fractionIntervals.push(a1);\n });\n for (let i = 0; i < fractionIntervals.length; i += 2)\n insideSegments.push(Range1d.createXX(fractionIntervals[i], fractionIntervals[i + 1]));\n return true;\n }\n\n return false;\n }\n /**\n * Run one level of recursion. On return, the stack is one level deeper than at entry and the new top of the stack\n * has clip for this node (expensive -- must clone items of arrays during \"swaps\").\n */\n private recurse(node: AlternatingCCTreeNode) {\n this.pushEmptySegmentFrame();\n this.appendSingleClipToStack(node.planes, this._topOfStack);\n Range1dArray.sort(this._topOfStack);\n if (this.isTopOfStackEmpty())\n return;\n for (const child of node.children) {\n this.recurse(child);\n if (!this.isTopOfStackEmpty()) {\n const ranges = Range1dArray.differenceSorted(this.stackEntry(1), this.stackEntry(0));\n this.popSegmentFrame();\n this._topOfStack = ranges;\n } else {\n this.popSegmentFrame();\n }\n if (this.isTopOfStackEmpty())\n break;\n }\n }\n /**\n * Modifies the insideIntervals array given in place.\n * Note: curve given is passed by reference and stored.\n */\n public appendSingleClipPrimitive(root: AlternatingCCTreeNode, curve: CurvePrimitive,\n insideIntervals: CurveLocationDetailPair[], _outsideIntervals: CurveLocationDetailPair[]) {\n this.setCurveRef(curve);\n this.clearSegmentStack();\n this.recurse(root);\n if (this._stackDepth !== 1)\n return;\n const intervals = this._topOfStack;\n for (const interval of intervals) {\n const f0 = interval.low;\n const f1 = interval.high;\n const xyz0 = curve.fractionToPoint(f0);\n const xyz1 = curve.fractionToPoint(f1);\n insideIntervals.push(CurveLocationDetailPair.createCapture(\n CurveLocationDetail.createCurveFractionPoint(curve, f0, xyz0),\n CurveLocationDetail.createCurveFractionPoint(curve, f1, xyz1),\n ));\n }\n this.popSegmentFrame();\n }\n /**\n * Modifies the insideIntervals array given in place.\n * Note: curve given is passed by reference and stored.\n */\n public appendCurveCollectionClip(root: AlternatingCCTreeNode, curve: CurveCollection,\n insideIntervals: CurveLocationDetailPair[], outsideIntervals: CurveLocationDetailPair[]) {\n for (const cp of curve.children) {\n if (cp instanceof CurvePrimitive)\n this.appendSingleClipPrimitive(root, cp, insideIntervals, outsideIntervals);\n else if (cp instanceof CurveCollection)\n this.appendCurveCollectionClip(root, cp, insideIntervals, outsideIntervals);\n }\n }\n}\n"]}
@@ -362,6 +362,7 @@ export class ClipPlane extends Plane3d {
362
362
  const gamma = this.velocity(arcVectors.vector90);
363
363
  AnalyticRoots.appendImplicitLineUnitCircleIntersections(alpha, beta, gamma, undefined, undefined, intersectionRadians);
364
364
  }
365
+ static { this._clipArcFractionArray = new GrowableFloat64Array(); }
365
366
  /**
366
367
  * Announce fractional intervals of arc clip.
367
368
  * * Each call to `announce(fraction0, fraction1, arc)` announces one interval that is inside the clip plane.
@@ -555,5 +556,4 @@ export class ClipPlane extends Plane3d {
555
556
  return spacePoint.plusXYZ(d * this._inwardNormal.x, d * this._inwardNormal.y, d * this._inwardNormal.z, result);
556
557
  }
557
558
  }
558
- ClipPlane._clipArcFractionArray = new GrowableFloat64Array();
559
559
  //# sourceMappingURL=ClipPlane.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClipPlane.js","sourceRoot":"","sources":["../../../src/clipping/ClipPlane.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAQ/F,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,oBAAoB,EA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MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD;;;;;;;;OAQG;IACI,iBAAiB,CACtB,GAAyB,EACzB,eAAmC,EACnC,gBAAoC,EACpC,UAAiC;QAEjC,MAAM,kBAAkB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QAChD,MAAM,SAAS,GAAG,UAAU,CAAC,aAAa,EAAE,CAAC;QAC7C,MAAM,UAAU,GAAG,UAAU,CAAC,aAAa,EAAE,CAAC;QAC9C,8BAA8B,CAAC,oCAAoC,CACjE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,kBAAkB,CACrD,CAAC;QACF,aAAa,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;QACvE,aAAa,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC,EAAE,gBAAgB,EAAE,UAAU,CAAC,CAAC;IAC3E,CAAC;IACD,6CAA6C;IACtC,mBAAmB,CAAC,UAAmB,EAAE,MAAgB;QAC9D,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QACrC,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAClH,CAAC;;AAxMc,+BAAqB,GAAG,IAAI,oBAAoB,EAAE,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*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module CartesianGeometry\n */\n\nimport { Arc3d } from \"../curve/Arc3d\";\nimport { AnnounceNumberNumberCurvePrimitive } from \"../curve/CurvePrimitive\";\nimport { AxisOrder, Geometry } from \"../Geometry\";\nimport { Angle } from \"../geometry3d/Angle\";\nimport { GrowableFloat64Array } from \"../geometry3d/GrowableFloat64Array\";\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\nimport { Matrix3d } from \"../geometry3d/Matrix3d\";\nimport { Plane3d } from \"../geometry3d/Plane3d\";\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\nimport { IndexedXYZCollectionPolygonOps } from \"../geometry3d/PolygonOps\";\nimport { Range1d, Range3d } from \"../geometry3d/Range\";\nimport { GrowableXYZArrayCache } from \"../geometry3d/ReusableObjectCache\";\nimport { Transform } from \"../geometry3d/Transform\";\nimport { XYZProps } from \"../geometry3d/XYZProps\";\nimport { Matrix4d } from \"../geometry4d/Matrix4d\";\nimport { Point4d } from \"../geometry4d/Point4d\";\nimport { AnalyticRoots } from \"../numerics/Polynomials\";\nimport { Clipper, ClipUtilities, PolygonClipper } from \"./ClipUtils\";\n\n/**\n * Wire format describing a [[ClipPlane]].\n * If either [[normal]] or [[dist]] are omitted, defaults to a normal of [[Vector3d.unitZ]] and a distance of zero.\n * @public\n */\nexport interface ClipPlaneProps {\n /** The plane's inward normal. */\n normal?: XYZProps;\n /** The plane's signed distance from the origin. */\n dist?: number;\n /** Defaults to `false`. */\n invisible?: boolean;\n /** Defaults to `false`. */\n interior?: boolean;\n}\n\n/**\n * A ClipPlane is a single plane represented as\n * * An inward unit normal (u,v,w)\n * * A signedDistance\n * More details can be found at docs/learning/geometry/Clipping.md\n *\n * Hence\n * * The halfspace function evaluation for \"point\" (x,y,z) is `(x,y,z) DOT (u,v,w) - signedDistance`.\n * * POSITIVE values of the halfspace function are \"inside\".\n * * ZERO value of the halfspace function is \"on\".\n * * NEGATIVE value of the halfspace function is \"outside\".\n * * A representative point on the plane is (signedDistance * u, signedDistance * v, signedDistance * w).\n * * Given a point on the plane and the inward normal of the plane, `signedDistance = point DOT normal`.\n * @public\n */\nexport class ClipPlane extends Plane3d implements Clipper, PolygonClipper {\n private _inwardNormal: Vector3d;\n /**\n * Construct a parallel plane through the origin.\n * * Move it to the actual position.\n * * _distanceFromOrigin is the distance it moved, with the (inward) normal direction as positive\n */\n private _distanceFromOrigin: number;\n private _invisible: boolean;\n private _interior: boolean;\n\n private constructor(normal: Vector3d, distance: number, invisible: boolean, interior: boolean) {\n super();\n this._invisible = invisible;\n this._interior = interior;\n this._inwardNormal = normal;\n this._distanceFromOrigin = distance;\n }\n /*\n private safeSetXYZDistance(nx: number, ny: number, nz: number, d: number) {\n this._inwardNormal.set(nx, ny, nz);\n this._distanceFromOrigin = d;\n }\n */\n /**\n * Return true if all members are almostEqual to corresponding members of other.\n * @param other clip plane to compare\n */\n public isAlmostEqual(other: ClipPlane): boolean {\n return Geometry.isSameCoordinate(this._distanceFromOrigin, other._distanceFromOrigin)\n && this._inwardNormal.isAlmostEqual(other._inwardNormal)\n && this._interior === other._interior\n && this._invisible === other._invisible;\n }\n /** Return a cloned plane */\n public clone(): ClipPlane {\n const result = new ClipPlane(this._inwardNormal.clone(), this._distanceFromOrigin, this._invisible, this._interior);\n return result;\n }\n /** Return a cloned plane with coordinate data negated. */\n public cloneNegated(): ClipPlane {\n const plane = new ClipPlane(this._inwardNormal.clone(), this._distanceFromOrigin, this._invisible, this._interior);\n plane.negateInPlace();\n return plane;\n }\n /** Create a ClipPlane from Plane3dByOriginAndUnitNormal. */\n public static createPlane(\n plane: Plane3dByOriginAndUnitNormal, invisible: boolean = false, interior: boolean = false, result?: ClipPlane,\n ): ClipPlane {\n const distance = plane.getNormalRef().dotProduct(plane.getOriginRef());\n if (result) {\n result._invisible = invisible;\n result._interior = interior;\n result._inwardNormal = plane.getNormalRef().clone();\n result._distanceFromOrigin = distance;\n return result;\n }\n return new ClipPlane(plane.getNormalRef().clone(), distance, invisible, interior);\n }\n /**\n * Create a ClipPlane with direct normal and signedDistance.\n * * The vector is normalized for storage.\n */\n public static createNormalAndDistance(\n normal: Vector3d, distance: number, invisible: boolean = false, interior: boolean = false, result?: ClipPlane,\n ): ClipPlane | undefined {\n const normalized = normal.normalize();\n if (normalized) {\n if (result) {\n result._invisible = invisible;\n result._interior = interior;\n result._inwardNormal = normalized;\n result._distanceFromOrigin = distance;\n }\n return new ClipPlane(normalized, distance, invisible, interior);\n }\n return undefined;\n }\n /**\n * Create a ClipPlane\n * * \"normal\" is the inward normal of the plane (it is internally normalized).\n * * \"point\" is any point of the plane.\n * * The stored distance for the plane is the dot product of the point with the normal (i.e. treat the point's xyz as\n * a vector from the origin.)\n */\n public static createNormalAndPoint(\n normal: Vector3d, point: Point3d, invisible: boolean = false, interior: boolean = false, result?: ClipPlane,\n ): ClipPlane | undefined {\n const normalized = normal.normalize();\n if (normalized) {\n const distance = normalized.dotProduct(point);\n if (result) {\n result._invisible = invisible;\n result._interior = interior;\n result._inwardNormal = normalized;\n result._distanceFromOrigin = distance;\n }\n return new ClipPlane(normalized, distance, invisible, interior);\n }\n return undefined;\n }\n /**\n * Create a clip plane\n * @param origin any point on the plane.\n * @param vectorA any vector in the plane\n * @param vectorB any vector in the plane\n * @return undefined if the vectors are not independent.\n * * The stored inward normal is vectorB.crossProduct(vectorA).\n * * That is, the vectors are considered as a right-handed pair when viewed from the outside.\n */\n public static createOriginAndVectors(\n origin: Point3d,\n vectorA: Vector3d,\n vectorB: Vector3d,\n invisible: boolean = false,\n interior: boolean = false,\n result?: ClipPlane,\n ): ClipPlane | undefined {\n const normalized = vectorB.crossProduct(vectorA);\n return this.createNormalAndPoint(normalized, origin, invisible, interior, result);\n }\n /**\n * Create a ClipPlane\n * * \"normal\" (normalX, normalY, normalZ) is the inward normal of the plane.\n * * \"point\" (originX,originY,originZ) is any point of the plane.\n * * The stored distance for the plane is the dot product of the point with the normal (i.e. treat the point's xyz\n * as a vector from the origin.)\n */\n public static createNormalAndPointXYZXYZ(\n normalX: number, normalY: number, normalZ: number,\n originX: number, originY: number, originZ: number,\n invisible: boolean = false, interior: boolean = false,\n result?: ClipPlane,\n ): ClipPlane | undefined {\n const q = Geometry.hypotenuseXYZ(normalX, normalY, normalZ);\n const r = Geometry.conditionalDivideFraction(1, q);\n if (r !== undefined) {\n if (result) {\n result._inwardNormal.set(normalX * r, normalY * r, normalZ * r);\n result._distanceFromOrigin = result._inwardNormal.dotProductXYZ(originX, originY, originZ);\n result._invisible = invisible;\n result._interior = interior;\n return result;\n }\n const normal = Vector3d.create(normalX * r, normalY * r, normalZ * r);\n return new ClipPlane(normal, normal.dotProductXYZ(originX, originY, originZ), invisible, interior);\n }\n return undefined;\n }\n /**\n * Return a json object of the form\n * `{\"normal\":[u,v,w],\"dist\":signedDistanceValue,\"interior\":true,\"invisible\":true}`\n */\n public toJSON(): ClipPlaneProps {\n const props: ClipPlaneProps = {\n normal: this.inwardNormalRef.toJSON(),\n dist: this.distance,\n };\n if (this.interior)\n props.interior = true;\n if (this.invisible)\n props.invisible = true;\n return props;\n }\n /** Parse json object to ClipPlane instance */\n public static fromJSON(json: ClipPlaneProps, result?: ClipPlane): ClipPlane | undefined {\n if (json && json.normal && undefined !== json.dist && Number.isFinite(json.dist))\n return ClipPlane.createNormalAndDistance(\n Vector3d.fromJSON(json.normal), json.dist, !!json.invisible, !!json.interior,\n );\n return ClipPlane.createNormalAndDistance(Vector3d.unitZ(), 0, false, false, result);\n }\n /** Set both the invisible and interior flags. */\n public setFlags(invisible: boolean, interior: boolean) {\n this._invisible = invisible;\n this._interior = interior;\n }\n /** Return the stored distanceFromOrigin property. */\n public get distance() {\n return this._distanceFromOrigin;\n }\n /** * Return the stored inward normal property. */\n public get inwardNormalRef(): Vector3d {\n return this._inwardNormal;\n }\n /** Return the \"interior\" property bit */\n public get interior() {\n return this._interior;\n }\n /** Return the \"invisible\" property bit. */\n public get invisible() {\n return this._invisible;\n }\n /**\n * Create a plane defined by two points, an up vector, and a tilt angle relative to the up vector.\n * @param point0 start point of the edge\n * @param point1 end point of the edge\n * @param upVector vector perpendicular to the plane\n * @param tiltAngle angle to tilt the plane around the edge in the direction of the up vector.\n * @param result optional preallocated plane\n */\n public static createEdgeAndUpVector(\n point0: Point3d, point1: Point3d, upVector: Vector3d, tiltAngle?: Angle, result?: ClipPlane,\n ): ClipPlane | undefined {\n const edgeVector = Vector3d.createFrom(point1.minus(point0));\n let normal = (upVector.crossProduct(edgeVector)).normalize();\n\n if (normal) {\n if (tiltAngle !== undefined && !tiltAngle.isAlmostZero) {\n const tiltNormal = Vector3d.createRotateVectorAroundVector(normal, edgeVector, tiltAngle);\n if (tiltNormal) {\n normal = tiltNormal.clone();\n }\n }\n normal.negate(normal);\n return ClipPlane.createNormalAndPoint(normal, point0, false, false, result);\n }\n return undefined;\n }\n /** Create a plane perpendicular to the edge between the xy parts of point0 and point1. */\n public static createEdgeXY(point0: Point3d, point1: Point3d, result?: ClipPlane): ClipPlane | undefined {\n const normal = Vector3d.create(point0.y - point1.y, point1.x - point0.x);\n if (normal.normalizeInPlace())\n return ClipPlane.createNormalAndPoint(normal, point0, false, false, result);\n return undefined;\n }\n /**\n * Return the Plane3d form of the plane.\n * * The plane origin is the point `distance * inwardNormal`\n * * The plane normal is the inward normal of the ClipPlane.\n */\n public getPlane3d(): Plane3dByOriginAndUnitNormal {\n const d = this._distanceFromOrigin;\n // normal should be normalized, will not return undefined\n return Plane3dByOriginAndUnitNormal.create(\n Point3d.create(this._inwardNormal.x * d, this._inwardNormal.y * d, this._inwardNormal.z * d),\n this._inwardNormal,\n )!;\n }\n /**\n * Return the Point4d d form of the plane.\n * * The homogeneous xyz are the inward normal xyz.\n * * The homogeneous weight is the negated ClipPlane distance.\n */\n public getPlane4d(): Point4d {\n return Point4d.create(\n this._inwardNormal.x, this._inwardNormal.y, this._inwardNormal.z, - this._distanceFromOrigin,\n );\n }\n /**\n * Set the plane from DPoint4d style plane.\n * * The saved plane has its direction normalized.\n * * This preserves the plane itself as a zero set but make plane evaluations act as true distances (even if the\n * plane coefficients are scaled otherwise).\n * @param plane the DPoint4d style plane.\n */\n public setPlane4d(plane: Point4d) {\n const a = Math.sqrt(plane.x * plane.x + plane.y * plane.y + plane.z * plane.z);\n const r = a === 0.0 ? 1.0 : 1.0 / a;\n this._inwardNormal.x = r * plane.x;\n this._inwardNormal.y = r * plane.y;\n this._inwardNormal.z = r * plane.z;\n this._distanceFromOrigin = -r * plane.w;\n }\n /**\n * Evaluate the altitude in weighted space, i.e. (dot product with inward normal) minus distance, with point.w\n * scale applied to distance.\n * @param point space point to test.\n */\n public weightedAltitude(point: Point4d): number {\n return point.x * this._inwardNormal.x\n + point.y * this._inwardNormal.y\n + point.z * this._inwardNormal.z\n - point.w * this._distanceFromOrigin;\n }\n /**\n * Evaluate the distance from the plane to a point in space, i.e. (dot product with inward normal) minus distance.\n * @param point space point to test.\n */\n public altitude(point: Point3d): number {\n return point.x * this._inwardNormal.x\n + point.y * this._inwardNormal.y\n + point.z * this._inwardNormal.z\n - this._distanceFromOrigin;\n }\n /**\n * Evaluate the distance from the plane to a point in space with point given as x,y,z, i.e. (dot product with\n * inward normal) minus distance.\n * @param point space point to test.\n */\n public altitudeXYZ(x: number, y: number, z: number): number {\n return x * this._inwardNormal.x\n + y * this._inwardNormal.y\n + z * this._inwardNormal.z\n - this._distanceFromOrigin;\n }\n /** Return the x component of the normal used to evaluate altitude. */\n public normalX(): number {\n return this._inwardNormal.x;\n }\n /** Return the x component of the normal used to evaluate altitude. */\n public normalY(): number {\n return this._inwardNormal.y;\n }\n /** Return the z component of the normal used to evaluate altitude. */\n public normalZ(): number {\n return this._inwardNormal.z;\n }\n /** Return the dot product of the plane normal with the vector (NOT using the plane's distanceFromOrigin). */\n public velocity(vector: Vector3d): number {\n return vector.x * this._inwardNormal.x + vector.y * this._inwardNormal.y + vector.z * this._inwardNormal.z;\n }\n /**\n * Return the dot product of the plane normal with the x,yz, vector components (NOT using the plane's\n * distanceFromOrigin).\n */\n public velocityXYZ(x: number, y: number, z: number): number {\n return x * this._inwardNormal.x + y * this._inwardNormal.y + z * this._inwardNormal.z;\n }\n /**\n * Return the dot product of the plane normal with the point (treating the point xyz as a vector, and NOT\n * using the plane's distanceFromOrigin).\n */\n public dotProductPlaneNormalPoint(point: Point3d): number {\n return point.x * this._inwardNormal.x + point.y * this._inwardNormal.y + point.z * this._inwardNormal.z;\n }\n /**\n * Return true if spacePoint is inside or on the plane, with tolerance applied to \"on\".\n * @param spacePoint point to test.\n * @param tolerance tolerance for considering \"near plane\" to be \"on plane\"\n */\n public isPointOnOrInside(spacePoint: Point3d, tolerance: number = Geometry.smallMetricDistance): boolean {\n let value = this.altitude(spacePoint);\n if (tolerance) { value += tolerance; }\n return value >= 0.0;\n }\n /**\n * Return true if spacePoint is strictly inside the halfspace, with tolerance applied to \"on\".\n * @param spacePoint point to test.\n * @param tolerance tolerance for considering \"near plane\" to be \"on plane\"\n */\n public isPointInside(point: Point3d, tolerance: number = Geometry.smallMetricDistance): boolean {\n let value = this.altitude(point);\n if (tolerance) { value -= tolerance; }\n return value > 0.0;\n }\n /**\n * Return true if spacePoint is strictly on the plane, within tolerance\n * @param spacePoint point to test.\n * @param tolerance tolerance for considering \"near plane\" to be \"on plane\"\n */\n public isPointOn(point: Point3d, tolerance: number = Geometry.smallMetricDistance): boolean {\n return Math.abs(this.altitude(point)) <= tolerance;\n }\n /**\n * Compute intersections of an (UNBOUNDED) arc with the plane. Append them (as radians) to a growing array.\n * @param arc arc to test. The angle limits of the arc are NOT considered.\n * @param intersectionRadians array to receive results\n */\n public appendIntersectionRadians(arc: Arc3d, intersectionRadians: GrowableFloat64Array) {\n const arcVectors = arc.toVectors();\n const alpha = this.altitude(arc.center);\n const beta = this.velocity(arcVectors.vector0);\n const gamma = this.velocity(arcVectors.vector90);\n AnalyticRoots.appendImplicitLineUnitCircleIntersections(\n alpha, beta, gamma, undefined, undefined, intersectionRadians,\n );\n }\n private static _clipArcFractionArray = new GrowableFloat64Array();\n /**\n * Announce fractional intervals of arc clip.\n * * Each call to `announce(fraction0, fraction1, arc)` announces one interval that is inside the clip plane.\n */\n public announceClippedArcIntervals(arc: Arc3d, announce?: AnnounceNumberNumberCurvePrimitive): boolean {\n const breaks = ClipPlane._clipArcFractionArray;\n breaks.clear();\n this.appendIntersectionRadians(arc, breaks);\n arc.sweep.radiansArrayToPositivePeriodicFractions(breaks);\n return ClipUtilities.selectIntervals01(arc, breaks, this, announce);\n }\n /**\n * Compute intersection of (unbounded) segment with the plane.\n * * If the ends are on the same side of the plane, return undefined.\n * * If the intersection is an endpoint or interior to the segment return the fraction.\n * * If both ends are on, return undefined.\n */\n public getBoundedSegmentSimpleIntersection(pointA: Point3d, pointB: Point3d): number | undefined {\n const h0 = this.altitude(pointA);\n const h1 = this.altitude(pointB);\n if (h0 * h1 > 0.0)\n return undefined;\n if (h0 === 0.0 && h1 === 0.0) {\n return undefined;\n }\n return - h0 / (h1 - h0);\n }\n /** Apply transform to the origin. Apply inverse transpose of the matrix part to th normal vector. */\n public transformInPlace(transform: Transform): boolean {\n const plane: Plane3dByOriginAndUnitNormal = this.getPlane3d();\n const matrix: Matrix3d = transform.matrix;\n const newPoint = transform.multiplyPoint3d(plane.getOriginRef());\n // Normal transforms as the inverse transpose of the matrix part\n // BTW: If the matrix is orthogonal, this is a long way to multiply by the matrix part (mumble grumble)\n const newNormal = matrix.multiplyInverseTranspose(plane.getNormalRef());\n if (!newNormal)\n return false;\n\n plane.set(newPoint, newNormal);\n const normalized = (plane.getNormalRef()).normalize();\n if (!normalized)\n return false;\n this._inwardNormal = normalized;\n this._distanceFromOrigin = this._inwardNormal.dotProduct(plane.getOriginRef());\n return true;\n }\n /** Set the invisible flag. Interpretation of this is up to the use code algorithms. */\n public setInvisible(invisible: boolean) {\n this._invisible = invisible;\n }\n /** Reverse the sign of all coefficients, so outside and inside reverse */\n public negateInPlace() {\n this._inwardNormal = this._inwardNormal.negate();\n this._distanceFromOrigin = - this._distanceFromOrigin;\n }\n /**\n * Move the plane INWARD by given distance\n * @param offset distance of shift inwards\n */\n public offsetDistance(offset: number) {\n this._distanceFromOrigin += offset;\n }\n /**\n * Clip a polygon to the inside or outside of the plane.\n * * Results with 2 or fewer points are ignored.\n * * Other than ensuring capacity in the arrays, there are no object allocations during execution of this function.\n * @param xyz input points.\n * @param work work buffer\n * @param tolerance tolerance for \"on plane\" decision.\n */\n public clipConvexPolygonInPlace(\n xyz: GrowableXYZArray,\n work: GrowableXYZArray,\n inside: boolean = true,\n tolerance: number = Geometry.smallMetricDistance,\n ) {\n return IndexedXYZCollectionPolygonOps.clipConvexPolygonInPlace(this, xyz, work, inside, tolerance);\n }\n /**\n * Multiply the ClipPlane's DPoint4d by matrix.\n * @param matrix matrix to apply.\n * @param invert if true, use in verse of the matrix.\n * @param transpose if true, use the transpose of the matrix (or inverse, per invert parameter)\n * @param matrix matrix to apply\n * @return false if unable to invert\n * * Note that if matrixA is applied to all of space, the matrix to send to this method to get a corresponding\n * effect on the plane is the inverse transpose of matrixA\n * * Callers that will apply the same matrix to many planes should pre-invert the matrix for efficiency.\n * * Both params default to true to get the full effect of transforming space.\n */\n public multiplyPlaneByMatrix4d(matrix: Matrix4d, invert: boolean = true, transpose: boolean = true): boolean {\n const plane: Point4d = this.getPlane4d();\n if (invert) {\n const inverse = matrix.createInverse();\n if (inverse)\n return this.multiplyPlaneByMatrix4d(inverse, false, transpose);\n return false;\n }\n if (transpose)\n matrix.multiplyTransposePoint4d(plane, plane);\n else\n matrix.multiplyPoint4d(plane, plane);\n this.setPlane4d(plane);\n return true;\n }\n /** Announce the interval (if any) where a line is within the clip plane half space. */\n public announceClippedSegmentIntervals(\n f0: number, f1: number, pointA: Point3d, pointB: Point3d, announce?: (fraction0: number, fraction1: number) => void,\n ): boolean {\n if (f1 < f0)\n return false;\n const h0 = - this.altitude(pointA);\n const h1 = - this.altitude(pointB);\n const delta = h1 - h0;\n const f = Geometry.conditionalDivideFraction(-h0, delta);\n if (f === undefined) { // The segment is parallel to the plane.\n if (h0 <= 0.0) { if (announce) announce(f0, f1); return true; }\n return false;\n }\n if (delta > 0) { // segment aims OUT\n if (f < f1) f1 = f;\n } else {\n // segment aims IN\n if (f > f0)\n f0 = f;\n }\n if (f1 < f0)\n return false;\n if (announce) announce(f0, f1);\n return true;\n }\n /**\n * Return a coordinate frame with\n * * origin at closest point to global origin\n * * z axis points in\n * * x and y are \"in plane\"\n */\n public getFrame(): Transform {\n const d = this._distanceFromOrigin;\n const origin = Point3d.create(this._inwardNormal.x * d, this._inwardNormal.y * d, this._inwardNormal.z * d);\n const matrix = Matrix3d.createRigidHeadsUp(this._inwardNormal, AxisOrder.ZXY);\n return Transform.createOriginAndMatrix(origin, matrix);\n }\n /**\n * Return the intersection of the plane with a range cube.\n * @param range\n * @param xyzOut intersection polygon. This is convex.\n */\n public intersectRange(range: Range3d, addClosurePoint: boolean = false): GrowableXYZArray | undefined {\n if (range.isNull)\n return undefined;\n const corners = range.corners();\n const frameOnPlane = this.getFrame();\n frameOnPlane.multiplyInversePoint3dArrayInPlace(corners);\n const localRange = Range3d.createArray(corners);\n if (localRange.low.z * localRange.high.z > 0.0)\n return undefined;\n // oversized polygon on local z= 0\n const xyzOut = new GrowableXYZArray();\n xyzOut.pushXYZ(localRange.low.x, localRange.low.y, 0);\n xyzOut.pushXYZ(localRange.high.x, localRange.low.y, 0);\n xyzOut.pushXYZ(localRange.high.x, localRange.high.y, 0);\n xyzOut.pushXYZ(localRange.low.x, localRange.high.y, 0);\n xyzOut.multiplyTransformInPlace(frameOnPlane);\n IndexedXYZCollectionPolygonOps.intersectRangeConvexPolygonInPlace(range, xyzOut);\n if (xyzOut.length === 0)\n return undefined;\n if (addClosurePoint)\n xyzOut.pushWrap(1);\n return xyzOut;\n }\n /**\n * Implement appendPolygonClip, as defined in interface PolygonClipper.\n * @param xyz convex polygon. This is not changed.\n * @param insideFragments Array to receive \"inside\" fragments. Each fragment is a GrowableXYZArray grabbed\n * from the cache. This is NOT cleared.\n * @param outsideFragments Array to receive \"outside\" fragments. Each fragment is a GrowableXYZArray grabbed\n * from the cache. This is NOT cleared.\n * @param arrayCache cache for reusable GrowableXYZArray.\n */\n public appendPolygonClip(\n xyz: IndexedXYZCollection,\n insideFragments: GrowableXYZArray[],\n outsideFragments: GrowableXYZArray[],\n arrayCache: GrowableXYZArrayCache,\n ): void {\n const perpendicularRange = Range1d.createNull();\n const newInside = arrayCache.grabFromCache();\n const newOutside = arrayCache.grabFromCache();\n IndexedXYZCollectionPolygonOps.splitConvexPolygonInsideOutsidePlane(\n this, xyz, newInside, newOutside, perpendicularRange,\n );\n ClipUtilities.captureOrDrop(newInside, 3, insideFragments, arrayCache);\n ClipUtilities.captureOrDrop(newOutside, 3, outsideFragments, arrayCache);\n }\n /** Project a point in space to the plane. */\n public projectPointToPlane(spacePoint: Point3d, result?: Point3d): Point3d {\n const d = -this.altitude(spacePoint);\n return spacePoint.plusXYZ(d * this._inwardNormal.x, d * this._inwardNormal.y, d * this._inwardNormal.z, result);\n }\n}\n"]}
1
+ {"version":3,"file":"ClipPlane.js","sourceRoot":"","sources":["../../../src/clipping/ClipPlane.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAQ/F,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,OA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,CAAC;QAC9C,8BAA8B,CAAC,oCAAoC,CACjE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,kBAAkB,CACrD,CAAC;QACF,aAAa,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;QACvE,aAAa,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC,EAAE,gBAAgB,EAAE,UAAU,CAAC,CAAC;IAC3E,CAAC;IACD,6CAA6C;IACtC,mBAAmB,CAAC,UAAmB,EAAE,MAAgB;QAC9D,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QACrC,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAClH,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*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module CartesianGeometry\n */\n\nimport { Arc3d } from \"../curve/Arc3d\";\nimport { AnnounceNumberNumberCurvePrimitive } from \"../curve/CurvePrimitive\";\nimport { AxisOrder, Geometry } from \"../Geometry\";\nimport { Angle } from \"../geometry3d/Angle\";\nimport { GrowableFloat64Array } from \"../geometry3d/GrowableFloat64Array\";\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\nimport { Matrix3d } from \"../geometry3d/Matrix3d\";\nimport { Plane3d } from \"../geometry3d/Plane3d\";\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\nimport { IndexedXYZCollectionPolygonOps } from \"../geometry3d/PolygonOps\";\nimport { Range1d, Range3d } from \"../geometry3d/Range\";\nimport { GrowableXYZArrayCache } from \"../geometry3d/ReusableObjectCache\";\nimport { Transform } from \"../geometry3d/Transform\";\nimport { XYZProps } from \"../geometry3d/XYZProps\";\nimport { Matrix4d } from \"../geometry4d/Matrix4d\";\nimport { Point4d } from \"../geometry4d/Point4d\";\nimport { AnalyticRoots } from \"../numerics/Polynomials\";\nimport { Clipper, ClipUtilities, PolygonClipper } from \"./ClipUtils\";\n\n/**\n * Wire format describing a [[ClipPlane]].\n * If either [[normal]] or [[dist]] are omitted, defaults to a normal of [[Vector3d.unitZ]] and a distance of zero.\n * @public\n */\nexport interface ClipPlaneProps {\n /** The plane's inward normal. */\n normal?: XYZProps;\n /** The plane's signed distance from the origin. */\n dist?: number;\n /** Defaults to `false`. */\n invisible?: boolean;\n /** Defaults to `false`. */\n interior?: boolean;\n}\n\n/**\n * A ClipPlane is a single plane represented as\n * * An inward unit normal (u,v,w)\n * * A signedDistance\n * More details can be found at docs/learning/geometry/Clipping.md\n *\n * Hence\n * * The halfspace function evaluation for \"point\" (x,y,z) is `(x,y,z) DOT (u,v,w) - signedDistance`.\n * * POSITIVE values of the halfspace function are \"inside\".\n * * ZERO value of the halfspace function is \"on\".\n * * NEGATIVE value of the halfspace function is \"outside\".\n * * A representative point on the plane is (signedDistance * u, signedDistance * v, signedDistance * w).\n * * Given a point on the plane and the inward normal of the plane, `signedDistance = point DOT normal`.\n * @public\n */\nexport class ClipPlane extends Plane3d implements Clipper, PolygonClipper {\n private _inwardNormal: Vector3d;\n /**\n * Construct a parallel plane through the origin.\n * * Move it to the actual position.\n * * _distanceFromOrigin is the distance it moved, with the (inward) normal direction as positive\n */\n private _distanceFromOrigin: number;\n private _invisible: boolean;\n private _interior: boolean;\n\n private constructor(normal: Vector3d, distance: number, invisible: boolean, interior: boolean) {\n super();\n this._invisible = invisible;\n this._interior = interior;\n this._inwardNormal = normal;\n this._distanceFromOrigin = distance;\n }\n /*\n private safeSetXYZDistance(nx: number, ny: number, nz: number, d: number) {\n this._inwardNormal.set(nx, ny, nz);\n this._distanceFromOrigin = d;\n }\n */\n /**\n * Return true if all members are almostEqual to corresponding members of other.\n * @param other clip plane to compare\n */\n public isAlmostEqual(other: ClipPlane): boolean {\n return Geometry.isSameCoordinate(this._distanceFromOrigin, other._distanceFromOrigin)\n && this._inwardNormal.isAlmostEqual(other._inwardNormal)\n && this._interior === other._interior\n && this._invisible === other._invisible;\n }\n /** Return a cloned plane */\n public clone(): ClipPlane {\n const result = new ClipPlane(this._inwardNormal.clone(), this._distanceFromOrigin, this._invisible, this._interior);\n return result;\n }\n /** Return a cloned plane with coordinate data negated. */\n public cloneNegated(): ClipPlane {\n const plane = new ClipPlane(this._inwardNormal.clone(), this._distanceFromOrigin, this._invisible, this._interior);\n plane.negateInPlace();\n return plane;\n }\n /** Create a ClipPlane from Plane3dByOriginAndUnitNormal. */\n public static createPlane(\n plane: Plane3dByOriginAndUnitNormal, invisible: boolean = false, interior: boolean = false, result?: ClipPlane,\n ): ClipPlane {\n const distance = plane.getNormalRef().dotProduct(plane.getOriginRef());\n if (result) {\n result._invisible = invisible;\n result._interior = interior;\n result._inwardNormal = plane.getNormalRef().clone();\n result._distanceFromOrigin = distance;\n return result;\n }\n return new ClipPlane(plane.getNormalRef().clone(), distance, invisible, interior);\n }\n /**\n * Create a ClipPlane with direct normal and signedDistance.\n * * The vector is normalized for storage.\n */\n public static createNormalAndDistance(\n normal: Vector3d, distance: number, invisible: boolean = false, interior: boolean = false, result?: ClipPlane,\n ): ClipPlane | undefined {\n const normalized = normal.normalize();\n if (normalized) {\n if (result) {\n result._invisible = invisible;\n result._interior = interior;\n result._inwardNormal = normalized;\n result._distanceFromOrigin = distance;\n }\n return new ClipPlane(normalized, distance, invisible, interior);\n }\n return undefined;\n }\n /**\n * Create a ClipPlane\n * * \"normal\" is the inward normal of the plane (it is internally normalized).\n * * \"point\" is any point of the plane.\n * * The stored distance for the plane is the dot product of the point with the normal (i.e. treat the point's xyz as\n * a vector from the origin.)\n */\n public static createNormalAndPoint(\n normal: Vector3d, point: Point3d, invisible: boolean = false, interior: boolean = false, result?: ClipPlane,\n ): ClipPlane | undefined {\n const normalized = normal.normalize();\n if (normalized) {\n const distance = normalized.dotProduct(point);\n if (result) {\n result._invisible = invisible;\n result._interior = interior;\n result._inwardNormal = normalized;\n result._distanceFromOrigin = distance;\n }\n return new ClipPlane(normalized, distance, invisible, interior);\n }\n return undefined;\n }\n /**\n * Create a clip plane\n * @param origin any point on the plane.\n * @param vectorA any vector in the plane\n * @param vectorB any vector in the plane\n * @return undefined if the vectors are not independent.\n * * The stored inward normal is vectorB.crossProduct(vectorA).\n * * That is, the vectors are considered as a right-handed pair when viewed from the outside.\n */\n public static createOriginAndVectors(\n origin: Point3d,\n vectorA: Vector3d,\n vectorB: Vector3d,\n invisible: boolean = false,\n interior: boolean = false,\n result?: ClipPlane,\n ): ClipPlane | undefined {\n const normalized = vectorB.crossProduct(vectorA);\n return this.createNormalAndPoint(normalized, origin, invisible, interior, result);\n }\n /**\n * Create a ClipPlane\n * * \"normal\" (normalX, normalY, normalZ) is the inward normal of the plane.\n * * \"point\" (originX,originY,originZ) is any point of the plane.\n * * The stored distance for the plane is the dot product of the point with the normal (i.e. treat the point's xyz\n * as a vector from the origin.)\n */\n public static createNormalAndPointXYZXYZ(\n normalX: number, normalY: number, normalZ: number,\n originX: number, originY: number, originZ: number,\n invisible: boolean = false, interior: boolean = false,\n result?: ClipPlane,\n ): ClipPlane | undefined {\n const q = Geometry.hypotenuseXYZ(normalX, normalY, normalZ);\n const r = Geometry.conditionalDivideFraction(1, q);\n if (r !== undefined) {\n if (result) {\n result._inwardNormal.set(normalX * r, normalY * r, normalZ * r);\n result._distanceFromOrigin = result._inwardNormal.dotProductXYZ(originX, originY, originZ);\n result._invisible = invisible;\n result._interior = interior;\n return result;\n }\n const normal = Vector3d.create(normalX * r, normalY * r, normalZ * r);\n return new ClipPlane(normal, normal.dotProductXYZ(originX, originY, originZ), invisible, interior);\n }\n return undefined;\n }\n /**\n * Return a json object of the form\n * `{\"normal\":[u,v,w],\"dist\":signedDistanceValue,\"interior\":true,\"invisible\":true}`\n */\n public toJSON(): ClipPlaneProps {\n const props: ClipPlaneProps = {\n normal: this.inwardNormalRef.toJSON(),\n dist: this.distance,\n };\n if (this.interior)\n props.interior = true;\n if (this.invisible)\n props.invisible = true;\n return props;\n }\n /** Parse json object to ClipPlane instance */\n public static fromJSON(json: ClipPlaneProps, result?: ClipPlane): ClipPlane | undefined {\n if (json && json.normal && undefined !== json.dist && Number.isFinite(json.dist))\n return ClipPlane.createNormalAndDistance(\n Vector3d.fromJSON(json.normal), json.dist, !!json.invisible, !!json.interior,\n );\n return ClipPlane.createNormalAndDistance(Vector3d.unitZ(), 0, false, false, result);\n }\n /** Set both the invisible and interior flags. */\n public setFlags(invisible: boolean, interior: boolean) {\n this._invisible = invisible;\n this._interior = interior;\n }\n /** Return the stored distanceFromOrigin property. */\n public get distance() {\n return this._distanceFromOrigin;\n }\n /** * Return the stored inward normal property. */\n public get inwardNormalRef(): Vector3d {\n return this._inwardNormal;\n }\n /** Return the \"interior\" property bit */\n public get interior() {\n return this._interior;\n }\n /** Return the \"invisible\" property bit. */\n public get invisible() {\n return this._invisible;\n }\n /**\n * Create a plane defined by two points, an up vector, and a tilt angle relative to the up vector.\n * @param point0 start point of the edge\n * @param point1 end point of the edge\n * @param upVector vector perpendicular to the plane\n * @param tiltAngle angle to tilt the plane around the edge in the direction of the up vector.\n * @param result optional preallocated plane\n */\n public static createEdgeAndUpVector(\n point0: Point3d, point1: Point3d, upVector: Vector3d, tiltAngle?: Angle, result?: ClipPlane,\n ): ClipPlane | undefined {\n const edgeVector = Vector3d.createFrom(point1.minus(point0));\n let normal = (upVector.crossProduct(edgeVector)).normalize();\n\n if (normal) {\n if (tiltAngle !== undefined && !tiltAngle.isAlmostZero) {\n const tiltNormal = Vector3d.createRotateVectorAroundVector(normal, edgeVector, tiltAngle);\n if (tiltNormal) {\n normal = tiltNormal.clone();\n }\n }\n normal.negate(normal);\n return ClipPlane.createNormalAndPoint(normal, point0, false, false, result);\n }\n return undefined;\n }\n /** Create a plane perpendicular to the edge between the xy parts of point0 and point1. */\n public static createEdgeXY(point0: Point3d, point1: Point3d, result?: ClipPlane): ClipPlane | undefined {\n const normal = Vector3d.create(point0.y - point1.y, point1.x - point0.x);\n if (normal.normalizeInPlace())\n return ClipPlane.createNormalAndPoint(normal, point0, false, false, result);\n return undefined;\n }\n /**\n * Return the Plane3d form of the plane.\n * * The plane origin is the point `distance * inwardNormal`\n * * The plane normal is the inward normal of the ClipPlane.\n */\n public getPlane3d(): Plane3dByOriginAndUnitNormal {\n const d = this._distanceFromOrigin;\n // normal should be normalized, will not return undefined\n return Plane3dByOriginAndUnitNormal.create(\n Point3d.create(this._inwardNormal.x * d, this._inwardNormal.y * d, this._inwardNormal.z * d),\n this._inwardNormal,\n )!;\n }\n /**\n * Return the Point4d d form of the plane.\n * * The homogeneous xyz are the inward normal xyz.\n * * The homogeneous weight is the negated ClipPlane distance.\n */\n public getPlane4d(): Point4d {\n return Point4d.create(\n this._inwardNormal.x, this._inwardNormal.y, this._inwardNormal.z, - this._distanceFromOrigin,\n );\n }\n /**\n * Set the plane from DPoint4d style plane.\n * * The saved plane has its direction normalized.\n * * This preserves the plane itself as a zero set but make plane evaluations act as true distances (even if the\n * plane coefficients are scaled otherwise).\n * @param plane the DPoint4d style plane.\n */\n public setPlane4d(plane: Point4d) {\n const a = Math.sqrt(plane.x * plane.x + plane.y * plane.y + plane.z * plane.z);\n const r = a === 0.0 ? 1.0 : 1.0 / a;\n this._inwardNormal.x = r * plane.x;\n this._inwardNormal.y = r * plane.y;\n this._inwardNormal.z = r * plane.z;\n this._distanceFromOrigin = -r * plane.w;\n }\n /**\n * Evaluate the altitude in weighted space, i.e. (dot product with inward normal) minus distance, with point.w\n * scale applied to distance.\n * @param point space point to test.\n */\n public weightedAltitude(point: Point4d): number {\n return point.x * this._inwardNormal.x\n + point.y * this._inwardNormal.y\n + point.z * this._inwardNormal.z\n - point.w * this._distanceFromOrigin;\n }\n /**\n * Evaluate the distance from the plane to a point in space, i.e. (dot product with inward normal) minus distance.\n * @param point space point to test.\n */\n public altitude(point: Point3d): number {\n return point.x * this._inwardNormal.x\n + point.y * this._inwardNormal.y\n + point.z * this._inwardNormal.z\n - this._distanceFromOrigin;\n }\n /**\n * Evaluate the distance from the plane to a point in space with point given as x,y,z, i.e. (dot product with\n * inward normal) minus distance.\n * @param point space point to test.\n */\n public altitudeXYZ(x: number, y: number, z: number): number {\n return x * this._inwardNormal.x\n + y * this._inwardNormal.y\n + z * this._inwardNormal.z\n - this._distanceFromOrigin;\n }\n /** Return the x component of the normal used to evaluate altitude. */\n public normalX(): number {\n return this._inwardNormal.x;\n }\n /** Return the x component of the normal used to evaluate altitude. */\n public normalY(): number {\n return this._inwardNormal.y;\n }\n /** Return the z component of the normal used to evaluate altitude. */\n public normalZ(): number {\n return this._inwardNormal.z;\n }\n /** Return the dot product of the plane normal with the vector (NOT using the plane's distanceFromOrigin). */\n public velocity(vector: Vector3d): number {\n return vector.x * this._inwardNormal.x + vector.y * this._inwardNormal.y + vector.z * this._inwardNormal.z;\n }\n /**\n * Return the dot product of the plane normal with the x,yz, vector components (NOT using the plane's\n * distanceFromOrigin).\n */\n public velocityXYZ(x: number, y: number, z: number): number {\n return x * this._inwardNormal.x + y * this._inwardNormal.y + z * this._inwardNormal.z;\n }\n /**\n * Return the dot product of the plane normal with the point (treating the point xyz as a vector, and NOT\n * using the plane's distanceFromOrigin).\n */\n public dotProductPlaneNormalPoint(point: Point3d): number {\n return point.x * this._inwardNormal.x + point.y * this._inwardNormal.y + point.z * this._inwardNormal.z;\n }\n /**\n * Return true if spacePoint is inside or on the plane, with tolerance applied to \"on\".\n * @param spacePoint point to test.\n * @param tolerance tolerance for considering \"near plane\" to be \"on plane\"\n */\n public isPointOnOrInside(spacePoint: Point3d, tolerance: number = Geometry.smallMetricDistance): boolean {\n let value = this.altitude(spacePoint);\n if (tolerance) { value += tolerance; }\n return value >= 0.0;\n }\n /**\n * Return true if spacePoint is strictly inside the halfspace, with tolerance applied to \"on\".\n * @param spacePoint point to test.\n * @param tolerance tolerance for considering \"near plane\" to be \"on plane\"\n */\n public isPointInside(point: Point3d, tolerance: number = Geometry.smallMetricDistance): boolean {\n let value = this.altitude(point);\n if (tolerance) { value -= tolerance; }\n return value > 0.0;\n }\n /**\n * Return true if spacePoint is strictly on the plane, within tolerance\n * @param spacePoint point to test.\n * @param tolerance tolerance for considering \"near plane\" to be \"on plane\"\n */\n public isPointOn(point: Point3d, tolerance: number = Geometry.smallMetricDistance): boolean {\n return Math.abs(this.altitude(point)) <= tolerance;\n }\n /**\n * Compute intersections of an (UNBOUNDED) arc with the plane. Append them (as radians) to a growing array.\n * @param arc arc to test. The angle limits of the arc are NOT considered.\n * @param intersectionRadians array to receive results\n */\n public appendIntersectionRadians(arc: Arc3d, intersectionRadians: GrowableFloat64Array) {\n const arcVectors = arc.toVectors();\n const alpha = this.altitude(arc.center);\n const beta = this.velocity(arcVectors.vector0);\n const gamma = this.velocity(arcVectors.vector90);\n AnalyticRoots.appendImplicitLineUnitCircleIntersections(\n alpha, beta, gamma, undefined, undefined, intersectionRadians,\n );\n }\n private static _clipArcFractionArray = new GrowableFloat64Array();\n /**\n * Announce fractional intervals of arc clip.\n * * Each call to `announce(fraction0, fraction1, arc)` announces one interval that is inside the clip plane.\n */\n public announceClippedArcIntervals(arc: Arc3d, announce?: AnnounceNumberNumberCurvePrimitive): boolean {\n const breaks = ClipPlane._clipArcFractionArray;\n breaks.clear();\n this.appendIntersectionRadians(arc, breaks);\n arc.sweep.radiansArrayToPositivePeriodicFractions(breaks);\n return ClipUtilities.selectIntervals01(arc, breaks, this, announce);\n }\n /**\n * Compute intersection of (unbounded) segment with the plane.\n * * If the ends are on the same side of the plane, return undefined.\n * * If the intersection is an endpoint or interior to the segment return the fraction.\n * * If both ends are on, return undefined.\n */\n public getBoundedSegmentSimpleIntersection(pointA: Point3d, pointB: Point3d): number | undefined {\n const h0 = this.altitude(pointA);\n const h1 = this.altitude(pointB);\n if (h0 * h1 > 0.0)\n return undefined;\n if (h0 === 0.0 && h1 === 0.0) {\n return undefined;\n }\n return - h0 / (h1 - h0);\n }\n /** Apply transform to the origin. Apply inverse transpose of the matrix part to th normal vector. */\n public transformInPlace(transform: Transform): boolean {\n const plane: Plane3dByOriginAndUnitNormal = this.getPlane3d();\n const matrix: Matrix3d = transform.matrix;\n const newPoint = transform.multiplyPoint3d(plane.getOriginRef());\n // Normal transforms as the inverse transpose of the matrix part\n // BTW: If the matrix is orthogonal, this is a long way to multiply by the matrix part (mumble grumble)\n const newNormal = matrix.multiplyInverseTranspose(plane.getNormalRef());\n if (!newNormal)\n return false;\n\n plane.set(newPoint, newNormal);\n const normalized = (plane.getNormalRef()).normalize();\n if (!normalized)\n return false;\n this._inwardNormal = normalized;\n this._distanceFromOrigin = this._inwardNormal.dotProduct(plane.getOriginRef());\n return true;\n }\n /** Set the invisible flag. Interpretation of this is up to the use code algorithms. */\n public setInvisible(invisible: boolean) {\n this._invisible = invisible;\n }\n /** Reverse the sign of all coefficients, so outside and inside reverse */\n public negateInPlace() {\n this._inwardNormal = this._inwardNormal.negate();\n this._distanceFromOrigin = - this._distanceFromOrigin;\n }\n /**\n * Move the plane INWARD by given distance\n * @param offset distance of shift inwards\n */\n public offsetDistance(offset: number) {\n this._distanceFromOrigin += offset;\n }\n /**\n * Clip a polygon to the inside or outside of the plane.\n * * Results with 2 or fewer points are ignored.\n * * Other than ensuring capacity in the arrays, there are no object allocations during execution of this function.\n * @param xyz input points.\n * @param work work buffer\n * @param tolerance tolerance for \"on plane\" decision.\n */\n public clipConvexPolygonInPlace(\n xyz: GrowableXYZArray,\n work: GrowableXYZArray,\n inside: boolean = true,\n tolerance: number = Geometry.smallMetricDistance,\n ) {\n return IndexedXYZCollectionPolygonOps.clipConvexPolygonInPlace(this, xyz, work, inside, tolerance);\n }\n /**\n * Multiply the ClipPlane's DPoint4d by matrix.\n * @param matrix matrix to apply.\n * @param invert if true, use in verse of the matrix.\n * @param transpose if true, use the transpose of the matrix (or inverse, per invert parameter)\n * @param matrix matrix to apply\n * @return false if unable to invert\n * * Note that if matrixA is applied to all of space, the matrix to send to this method to get a corresponding\n * effect on the plane is the inverse transpose of matrixA\n * * Callers that will apply the same matrix to many planes should pre-invert the matrix for efficiency.\n * * Both params default to true to get the full effect of transforming space.\n */\n public multiplyPlaneByMatrix4d(matrix: Matrix4d, invert: boolean = true, transpose: boolean = true): boolean {\n const plane: Point4d = this.getPlane4d();\n if (invert) {\n const inverse = matrix.createInverse();\n if (inverse)\n return this.multiplyPlaneByMatrix4d(inverse, false, transpose);\n return false;\n }\n if (transpose)\n matrix.multiplyTransposePoint4d(plane, plane);\n else\n matrix.multiplyPoint4d(plane, plane);\n this.setPlane4d(plane);\n return true;\n }\n /** Announce the interval (if any) where a line is within the clip plane half space. */\n public announceClippedSegmentIntervals(\n f0: number, f1: number, pointA: Point3d, pointB: Point3d, announce?: (fraction0: number, fraction1: number) => void,\n ): boolean {\n if (f1 < f0)\n return false;\n const h0 = - this.altitude(pointA);\n const h1 = - this.altitude(pointB);\n const delta = h1 - h0;\n const f = Geometry.conditionalDivideFraction(-h0, delta);\n if (f === undefined) { // The segment is parallel to the plane.\n if (h0 <= 0.0) { if (announce) announce(f0, f1); return true; }\n return false;\n }\n if (delta > 0) { // segment aims OUT\n if (f < f1) f1 = f;\n } else {\n // segment aims IN\n if (f > f0)\n f0 = f;\n }\n if (f1 < f0)\n return false;\n if (announce) announce(f0, f1);\n return true;\n }\n /**\n * Return a coordinate frame with\n * * origin at closest point to global origin\n * * z axis points in\n * * x and y are \"in plane\"\n */\n public getFrame(): Transform {\n const d = this._distanceFromOrigin;\n const origin = Point3d.create(this._inwardNormal.x * d, this._inwardNormal.y * d, this._inwardNormal.z * d);\n const matrix = Matrix3d.createRigidHeadsUp(this._inwardNormal, AxisOrder.ZXY);\n return Transform.createOriginAndMatrix(origin, matrix);\n }\n /**\n * Return the intersection of the plane with a range cube.\n * @param range\n * @param xyzOut intersection polygon. This is convex.\n */\n public intersectRange(range: Range3d, addClosurePoint: boolean = false): GrowableXYZArray | undefined {\n if (range.isNull)\n return undefined;\n const corners = range.corners();\n const frameOnPlane = this.getFrame();\n frameOnPlane.multiplyInversePoint3dArrayInPlace(corners);\n const localRange = Range3d.createArray(corners);\n if (localRange.low.z * localRange.high.z > 0.0)\n return undefined;\n // oversized polygon on local z= 0\n const xyzOut = new GrowableXYZArray();\n xyzOut.pushXYZ(localRange.low.x, localRange.low.y, 0);\n xyzOut.pushXYZ(localRange.high.x, localRange.low.y, 0);\n xyzOut.pushXYZ(localRange.high.x, localRange.high.y, 0);\n xyzOut.pushXYZ(localRange.low.x, localRange.high.y, 0);\n xyzOut.multiplyTransformInPlace(frameOnPlane);\n IndexedXYZCollectionPolygonOps.intersectRangeConvexPolygonInPlace(range, xyzOut);\n if (xyzOut.length === 0)\n return undefined;\n if (addClosurePoint)\n xyzOut.pushWrap(1);\n return xyzOut;\n }\n /**\n * Implement appendPolygonClip, as defined in interface PolygonClipper.\n * @param xyz convex polygon. This is not changed.\n * @param insideFragments Array to receive \"inside\" fragments. Each fragment is a GrowableXYZArray grabbed\n * from the cache. This is NOT cleared.\n * @param outsideFragments Array to receive \"outside\" fragments. Each fragment is a GrowableXYZArray grabbed\n * from the cache. This is NOT cleared.\n * @param arrayCache cache for reusable GrowableXYZArray.\n */\n public appendPolygonClip(\n xyz: IndexedXYZCollection,\n insideFragments: GrowableXYZArray[],\n outsideFragments: GrowableXYZArray[],\n arrayCache: GrowableXYZArrayCache,\n ): void {\n const perpendicularRange = Range1d.createNull();\n const newInside = arrayCache.grabFromCache();\n const newOutside = arrayCache.grabFromCache();\n IndexedXYZCollectionPolygonOps.splitConvexPolygonInsideOutsidePlane(\n this, xyz, newInside, newOutside, perpendicularRange,\n );\n ClipUtilities.captureOrDrop(newInside, 3, insideFragments, arrayCache);\n ClipUtilities.captureOrDrop(newOutside, 3, outsideFragments, arrayCache);\n }\n /** Project a point in space to the plane. */\n public projectPointToPlane(spacePoint: Point3d, result?: Point3d): Point3d {\n const d = -this.altitude(spacePoint);\n return spacePoint.plusXYZ(d * this._inwardNormal.x, d * this._inwardNormal.y, d * this._inwardNormal.z, result);\n }\n}\n"]}
@@ -74,6 +74,7 @@ export var ClipStatus;
74
74
  * @public
75
75
  */
76
76
  export class ClipUtilities {
77
+ static { this._selectIntervals01TestPoint = Point3d.create(); }
77
78
  /**
78
79
  * Augment the unsortedFractionsArray with 0 and 1
79
80
  * * sort
@@ -961,7 +962,6 @@ export class ClipUtilities {
961
962
  return UnionOfConvexClipPlaneSets.createConvexSets(newClippers);
962
963
  }
963
964
  }
964
- ClipUtilities._selectIntervals01TestPoint = Point3d.create();
965
965
  function moveFragments(fragments, destination, arrayCache) {
966
966
  if (destination === undefined)
967
967
  arrayCache.dropAllToCache(fragments);