@itwin/core-geometry 3.0.0-extension.0 → 3.1.0-dev.11

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 (213) hide show
  1. package/CHANGELOG.md +80 -1
  2. package/LICENSE.md +1 -1
  3. package/lib/cjs/Geometry.d.ts +6 -0
  4. package/lib/cjs/Geometry.d.ts.map +1 -1
  5. package/lib/cjs/Geometry.js.map +1 -1
  6. package/lib/cjs/bspline/BSplineCurve.d.ts +4 -0
  7. package/lib/cjs/bspline/BSplineCurve.d.ts.map +1 -1
  8. package/lib/cjs/bspline/BSplineCurve.js +39 -0
  9. package/lib/cjs/bspline/BSplineCurve.js.map +1 -1
  10. package/lib/cjs/bspline/BSplineCurveOps.d.ts +7 -0
  11. package/lib/cjs/bspline/BSplineCurveOps.d.ts.map +1 -1
  12. package/lib/cjs/bspline/BSplineCurveOps.js +21 -6
  13. package/lib/cjs/bspline/BSplineCurveOps.js.map +1 -1
  14. package/lib/cjs/bspline/BezierCurve3dH.d.ts.map +1 -1
  15. package/lib/cjs/bspline/BezierCurve3dH.js +7 -3
  16. package/lib/cjs/bspline/BezierCurve3dH.js.map +1 -1
  17. package/lib/cjs/bspline/InterpolationCurve3d.d.ts.map +1 -1
  18. package/lib/cjs/bspline/InterpolationCurve3d.js +12 -5
  19. package/lib/cjs/bspline/InterpolationCurve3d.js.map +1 -1
  20. package/lib/cjs/bspline/KnotVector.d.ts +2 -2
  21. package/lib/cjs/bspline/KnotVector.d.ts.map +1 -1
  22. package/lib/cjs/bspline/KnotVector.js +2 -2
  23. package/lib/cjs/bspline/KnotVector.js.map +1 -1
  24. package/lib/cjs/clipping/BooleanClipNode.d.ts +10 -5
  25. package/lib/cjs/clipping/BooleanClipNode.d.ts.map +1 -1
  26. package/lib/cjs/clipping/BooleanClipNode.js +13 -3
  27. package/lib/cjs/clipping/BooleanClipNode.js.map +1 -1
  28. package/lib/cjs/clipping/ClipPlane.d.ts +12 -0
  29. package/lib/cjs/clipping/ClipPlane.d.ts.map +1 -1
  30. package/lib/cjs/clipping/ClipPlane.js +12 -0
  31. package/lib/cjs/clipping/ClipPlane.js.map +1 -1
  32. package/lib/cjs/clipping/ClipUtils.d.ts +57 -9
  33. package/lib/cjs/clipping/ClipUtils.d.ts.map +1 -1
  34. package/lib/cjs/clipping/ClipUtils.js +191 -2
  35. package/lib/cjs/clipping/ClipUtils.js.map +1 -1
  36. package/lib/cjs/clipping/ClipVector.d.ts +7 -3
  37. package/lib/cjs/clipping/ClipVector.d.ts.map +1 -1
  38. package/lib/cjs/clipping/ClipVector.js +9 -4
  39. package/lib/cjs/clipping/ClipVector.js.map +1 -1
  40. package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts +1 -1
  41. package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
  42. package/lib/cjs/clipping/ConvexClipPlaneSet.js +4 -3
  43. package/lib/cjs/clipping/ConvexClipPlaneSet.js.map +1 -1
  44. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +1 -1
  45. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  46. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +2 -3
  47. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  48. package/lib/cjs/curve/CurveFactory.d.ts +12 -0
  49. package/lib/cjs/curve/CurveFactory.d.ts.map +1 -1
  50. package/lib/cjs/curve/CurveFactory.js +25 -0
  51. package/lib/cjs/curve/CurveFactory.js.map +1 -1
  52. package/lib/cjs/curve/CurvePrimitive.js +3 -0
  53. package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
  54. package/lib/cjs/curve/spiral/DirectSpiral3d.js +2 -2
  55. package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
  56. package/lib/cjs/curve/spiral/NormalizedTransition.d.ts +0 -1
  57. package/lib/cjs/curve/spiral/NormalizedTransition.d.ts.map +1 -1
  58. package/lib/cjs/curve/spiral/NormalizedTransition.js +0 -1
  59. package/lib/cjs/curve/spiral/NormalizedTransition.js.map +1 -1
  60. package/lib/cjs/geometry3d/FrameBuilder.d.ts.map +1 -1
  61. package/lib/cjs/geometry3d/FrameBuilder.js +20 -1
  62. package/lib/cjs/geometry3d/FrameBuilder.js.map +1 -1
  63. package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.d.ts +12 -0
  64. package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.d.ts.map +1 -1
  65. package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.js +12 -0
  66. package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.js.map +1 -1
  67. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +1 -11
  68. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  69. package/lib/cjs/geometry3d/Point3dVector3d.js +5 -25
  70. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  71. package/lib/cjs/geometry3d/PolygonOps.d.ts +2 -0
  72. package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
  73. package/lib/cjs/geometry3d/PolygonOps.js +7 -0
  74. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  75. package/lib/cjs/geometry3d/PolylineOps.d.ts +5 -0
  76. package/lib/cjs/geometry3d/PolylineOps.d.ts.map +1 -1
  77. package/lib/cjs/geometry3d/PolylineOps.js +21 -0
  78. package/lib/cjs/geometry3d/PolylineOps.js.map +1 -1
  79. package/lib/cjs/geometry3d/Ray3d.d.ts +10 -0
  80. package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
  81. package/lib/cjs/geometry3d/Ray3d.js +23 -0
  82. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  83. package/lib/cjs/geometry3d/Transform.d.ts +5 -0
  84. package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
  85. package/lib/cjs/geometry3d/Transform.js +7 -0
  86. package/lib/cjs/geometry3d/Transform.js.map +1 -1
  87. package/lib/cjs/geometry4d/Point4d.d.ts +12 -0
  88. package/lib/cjs/geometry4d/Point4d.d.ts.map +1 -1
  89. package/lib/cjs/geometry4d/Point4d.js +12 -0
  90. package/lib/cjs/geometry4d/Point4d.js.map +1 -1
  91. package/lib/cjs/serialization/GeometrySamples.d.ts +7 -0
  92. package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
  93. package/lib/cjs/serialization/GeometrySamples.js +27 -0
  94. package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
  95. package/lib/cjs/topology/HalfEdgeNodeXYZUV.d.ts +2 -0
  96. package/lib/cjs/topology/HalfEdgeNodeXYZUV.d.ts.map +1 -1
  97. package/lib/cjs/topology/HalfEdgeNodeXYZUV.js +4 -0
  98. package/lib/cjs/topology/HalfEdgeNodeXYZUV.js.map +1 -1
  99. package/lib/cjs/topology/HalfEdgePointInGraphSearch.js +1 -0
  100. package/lib/cjs/topology/HalfEdgePointInGraphSearch.js.map +1 -1
  101. package/lib/cjs/topology/HalfEdgePositionDetail.d.ts +17 -4
  102. package/lib/cjs/topology/HalfEdgePositionDetail.d.ts.map +1 -1
  103. package/lib/cjs/topology/HalfEdgePositionDetail.js +26 -5
  104. package/lib/cjs/topology/HalfEdgePositionDetail.js.map +1 -1
  105. package/lib/cjs/topology/InsertAndRetriangulateContext.d.ts.map +1 -1
  106. package/lib/cjs/topology/InsertAndRetriangulateContext.js +28 -2
  107. package/lib/cjs/topology/InsertAndRetriangulateContext.js.map +1 -1
  108. package/lib/esm/Geometry.d.ts +6 -0
  109. package/lib/esm/Geometry.d.ts.map +1 -1
  110. package/lib/esm/Geometry.js.map +1 -1
  111. package/lib/esm/bspline/BSplineCurve.d.ts +4 -0
  112. package/lib/esm/bspline/BSplineCurve.d.ts.map +1 -1
  113. package/lib/esm/bspline/BSplineCurve.js +39 -0
  114. package/lib/esm/bspline/BSplineCurve.js.map +1 -1
  115. package/lib/esm/bspline/BSplineCurveOps.d.ts +7 -0
  116. package/lib/esm/bspline/BSplineCurveOps.d.ts.map +1 -1
  117. package/lib/esm/bspline/BSplineCurveOps.js +21 -6
  118. package/lib/esm/bspline/BSplineCurveOps.js.map +1 -1
  119. package/lib/esm/bspline/BezierCurve3dH.d.ts.map +1 -1
  120. package/lib/esm/bspline/BezierCurve3dH.js +7 -3
  121. package/lib/esm/bspline/BezierCurve3dH.js.map +1 -1
  122. package/lib/esm/bspline/InterpolationCurve3d.d.ts.map +1 -1
  123. package/lib/esm/bspline/InterpolationCurve3d.js +12 -5
  124. package/lib/esm/bspline/InterpolationCurve3d.js.map +1 -1
  125. package/lib/esm/bspline/KnotVector.d.ts +2 -2
  126. package/lib/esm/bspline/KnotVector.d.ts.map +1 -1
  127. package/lib/esm/bspline/KnotVector.js +2 -2
  128. package/lib/esm/bspline/KnotVector.js.map +1 -1
  129. package/lib/esm/clipping/BooleanClipNode.d.ts +10 -5
  130. package/lib/esm/clipping/BooleanClipNode.d.ts.map +1 -1
  131. package/lib/esm/clipping/BooleanClipNode.js +13 -3
  132. package/lib/esm/clipping/BooleanClipNode.js.map +1 -1
  133. package/lib/esm/clipping/ClipPlane.d.ts +12 -0
  134. package/lib/esm/clipping/ClipPlane.d.ts.map +1 -1
  135. package/lib/esm/clipping/ClipPlane.js +12 -0
  136. package/lib/esm/clipping/ClipPlane.js.map +1 -1
  137. package/lib/esm/clipping/ClipUtils.d.ts +57 -9
  138. package/lib/esm/clipping/ClipUtils.d.ts.map +1 -1
  139. package/lib/esm/clipping/ClipUtils.js +191 -2
  140. package/lib/esm/clipping/ClipUtils.js.map +1 -1
  141. package/lib/esm/clipping/ClipVector.d.ts +7 -3
  142. package/lib/esm/clipping/ClipVector.d.ts.map +1 -1
  143. package/lib/esm/clipping/ClipVector.js +9 -4
  144. package/lib/esm/clipping/ClipVector.js.map +1 -1
  145. package/lib/esm/clipping/ConvexClipPlaneSet.d.ts +1 -1
  146. package/lib/esm/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
  147. package/lib/esm/clipping/ConvexClipPlaneSet.js +4 -3
  148. package/lib/esm/clipping/ConvexClipPlaneSet.js.map +1 -1
  149. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +1 -1
  150. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  151. package/lib/esm/curve/CurveChainWithDistanceIndex.js +2 -3
  152. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  153. package/lib/esm/curve/CurveFactory.d.ts +12 -0
  154. package/lib/esm/curve/CurveFactory.d.ts.map +1 -1
  155. package/lib/esm/curve/CurveFactory.js +25 -0
  156. package/lib/esm/curve/CurveFactory.js.map +1 -1
  157. package/lib/esm/curve/CurvePrimitive.js +3 -0
  158. package/lib/esm/curve/CurvePrimitive.js.map +1 -1
  159. package/lib/esm/curve/spiral/DirectSpiral3d.js +2 -2
  160. package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
  161. package/lib/esm/curve/spiral/NormalizedTransition.d.ts +0 -1
  162. package/lib/esm/curve/spiral/NormalizedTransition.d.ts.map +1 -1
  163. package/lib/esm/curve/spiral/NormalizedTransition.js +0 -1
  164. package/lib/esm/curve/spiral/NormalizedTransition.js.map +1 -1
  165. package/lib/esm/geometry3d/FrameBuilder.d.ts.map +1 -1
  166. package/lib/esm/geometry3d/FrameBuilder.js +20 -1
  167. package/lib/esm/geometry3d/FrameBuilder.js.map +1 -1
  168. package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.d.ts +12 -0
  169. package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.d.ts.map +1 -1
  170. package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.js +12 -0
  171. package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.js.map +1 -1
  172. package/lib/esm/geometry3d/Point3dVector3d.d.ts +1 -11
  173. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  174. package/lib/esm/geometry3d/Point3dVector3d.js +5 -25
  175. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  176. package/lib/esm/geometry3d/PolygonOps.d.ts +2 -0
  177. package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
  178. package/lib/esm/geometry3d/PolygonOps.js +7 -0
  179. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  180. package/lib/esm/geometry3d/PolylineOps.d.ts +5 -0
  181. package/lib/esm/geometry3d/PolylineOps.d.ts.map +1 -1
  182. package/lib/esm/geometry3d/PolylineOps.js +21 -0
  183. package/lib/esm/geometry3d/PolylineOps.js.map +1 -1
  184. package/lib/esm/geometry3d/Ray3d.d.ts +10 -0
  185. package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
  186. package/lib/esm/geometry3d/Ray3d.js +23 -0
  187. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  188. package/lib/esm/geometry3d/Transform.d.ts +5 -0
  189. package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
  190. package/lib/esm/geometry3d/Transform.js +7 -0
  191. package/lib/esm/geometry3d/Transform.js.map +1 -1
  192. package/lib/esm/geometry4d/Point4d.d.ts +12 -0
  193. package/lib/esm/geometry4d/Point4d.d.ts.map +1 -1
  194. package/lib/esm/geometry4d/Point4d.js +12 -0
  195. package/lib/esm/geometry4d/Point4d.js.map +1 -1
  196. package/lib/esm/serialization/GeometrySamples.d.ts +7 -0
  197. package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
  198. package/lib/esm/serialization/GeometrySamples.js +27 -0
  199. package/lib/esm/serialization/GeometrySamples.js.map +1 -1
  200. package/lib/esm/topology/HalfEdgeNodeXYZUV.d.ts +2 -0
  201. package/lib/esm/topology/HalfEdgeNodeXYZUV.d.ts.map +1 -1
  202. package/lib/esm/topology/HalfEdgeNodeXYZUV.js +4 -0
  203. package/lib/esm/topology/HalfEdgeNodeXYZUV.js.map +1 -1
  204. package/lib/esm/topology/HalfEdgePointInGraphSearch.js +1 -0
  205. package/lib/esm/topology/HalfEdgePointInGraphSearch.js.map +1 -1
  206. package/lib/esm/topology/HalfEdgePositionDetail.d.ts +17 -4
  207. package/lib/esm/topology/HalfEdgePositionDetail.d.ts.map +1 -1
  208. package/lib/esm/topology/HalfEdgePositionDetail.js +26 -5
  209. package/lib/esm/topology/HalfEdgePositionDetail.js.map +1 -1
  210. package/lib/esm/topology/InsertAndRetriangulateContext.d.ts.map +1 -1
  211. package/lib/esm/topology/InsertAndRetriangulateContext.js +28 -2
  212. package/lib/esm/topology/InsertAndRetriangulateContext.js.map +1 -1
  213. package/package.json +8 -9
@@ -1 +1 @@
1
- {"version":3,"file":"ConvexClipPlaneSet.js","sourceRoot":"","sources":["../../../src/clipping/ConvexClipPlaneSet.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAQ/F,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAE1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAW,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,8BAA8B,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAE,OAAO,EAAW,MAAM,qBAAqB,CAAC;AAKvD,OAAO,EAAE,SAAS,EAAkB,MAAM,aAAa,CAAC;AACxD,OAAO,EAAW,oBAAoB,EAAE,aAAa,EAAkB,MAAM,aAAa,CAAC;AAO3F;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAI7B,+CAA+C;IAC/C,+CAA+C;IAC/C,6DAA6D;IAC7D,YAAoB,MAAoB;QACtC,oBAAoB;QACpB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACtC,CAAC;IACD;;OAE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;YACpB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAE,CAAC,CAAC;QACnG,IAAI,KAAK,KAAK,SAAS;YACrB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,CAAE,CAAC,CAAC;IACxG,CAAC;IACD;;;;;;OAMG;IACI,iBAAiB,CACtB,GAAqB,EACrB,eAAmC,EACnC,gBAAoC,EACpC,UAAiC;QACjC,MAAM,SAAS,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,EAAE,gBAAgB,EAAE,UAAU,CAAC,CAAC;QAChF,IAAI,SAAS;YACX,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;;AA9rBD,iEAAiE;AAC1C,0BAAO,GAAG,IAAI,CAAC;AA4WvB,wCAAqB,GAAG,IAAI,oBAAoB,EAAE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { Arc3d } from \"../curve/Arc3d\";\r\nimport { AnnounceNumberNumber, AnnounceNumberNumberCurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport { Angle } from \"../geometry3d/Angle\";\r\nimport { GrowableFloat64Array } from \"../geometry3d/GrowableFloat64Array\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { Matrix3d } from \"../geometry3d/Matrix3d\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { IndexedXYZCollectionPolygonOps, PolygonOps } from \"../geometry3d/PolygonOps\";\r\nimport { Range1d, Range3d } from \"../geometry3d/Range\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { GrowableXYZArrayCache } from \"../geometry3d/ReusableObjectCache\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { Matrix4d } from \"../geometry4d/Matrix4d\";\r\nimport { ClipPlane, ClipPlaneProps } from \"./ClipPlane\";\r\nimport { Clipper, ClipPlaneContainment, ClipUtilities, PolygonClipper } from \"./ClipUtils\";\r\n\r\n/** Wire format describing a [[ConvexClipPlaneSet]].\r\n * @public\r\n */\r\nexport type ConvexClipPlaneSetProps = ClipPlaneProps[];\r\n\r\n/**\r\n * A ConvexClipPlaneSet is a collection of ClipPlanes, often used for bounding regions of space.\r\n * @public\r\n */\r\nexport class ConvexClipPlaneSet implements Clipper, PolygonClipper {\r\n /** Value acting as \"at infinity\" for coordinates along a ray. */\r\n public static readonly hugeVal = 1e37;\r\n private _planes: ClipPlane[];\r\n // private _parity: number; <--- Not yet used\r\n // public get parity() { return this._parity; }\r\n // public set parity(value: number) { this._parity = value; }\r\n private constructor(planes?: ClipPlane[]) {\r\n // this._parity = 1;\r\n this._planes = planes ? planes : [];\r\n }\r\n /** Return an array containing all the planes of the convex set.\r\n * * Note that this has no leading keyword identifying it as a ConvexClipPlaneSet.\r\n */\r\n public toJSON(): ConvexClipPlaneSetProps {\r\n const val: ClipPlaneProps[] = [];\r\n for (const plane of this._planes)\r\n val.push(plane.toJSON());\r\n\r\n return val;\r\n }\r\n\r\n /** Extract clip planes from a json array `[ clipPlane, clipPlane ]`.\r\n * * Non-clipPlane members are ignored.\r\n */\r\n public static fromJSON(json: ConvexClipPlaneSetProps | undefined, result?: ConvexClipPlaneSet): ConvexClipPlaneSet {\r\n result = result ? result : new ConvexClipPlaneSet();\r\n result._planes.length = 0;\r\n if (!Array.isArray(json))\r\n return result;\r\n\r\n for (const thisJson of json) {\r\n const plane = ClipPlane.fromJSON(thisJson);\r\n if (plane)\r\n result._planes.push(plane);\r\n }\r\n\r\n return result;\r\n }\r\n /**\r\n * Return true if all members are almostEqual to corresponding members of other. This includes identical order in array.\r\n * @param other clip plane to compare\r\n */\r\n public isAlmostEqual(other: ConvexClipPlaneSet): boolean {\r\n if (this._planes.length !== other._planes.length)\r\n return false;\r\n for (let i = 0; i < this._planes.length; i++)\r\n if (!this._planes[i].isAlmostEqual(other._planes[i]))\r\n return false;\r\n return true;\r\n }\r\n /** create from an array of planes.\r\n * * Each plane reference in the `planes` array is taken into the result.\r\n * * The input array itself is NOT taken into the result.\r\n */\r\n public static createPlanes(planes: (ClipPlane | Plane3dByOriginAndUnitNormal)[], result?: ConvexClipPlaneSet): ConvexClipPlaneSet {\r\n result = result ? result : new ConvexClipPlaneSet();\r\n for (const plane of planes) {\r\n if (plane instanceof ClipPlane) {\r\n result._planes.push(plane);\r\n } else if (plane instanceof Plane3dByOriginAndUnitNormal) {\r\n const clipPlane = ClipPlane.createPlane(plane);\r\n result._planes.push(clipPlane);\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Create new convex set using selected planes of a Range3d.\r\n * @param range range with coordinates\r\n * @param lowX true to clip at the low x plane\r\n * @param highX true to clip at the high x plane\r\n * @param lowY true to clip at the low y plane\r\n * @param highY true to clip at the high z plane\r\n * @param lowZ true to clip at the low z plane\r\n * @param highZ true to clip at the high z plane\r\n */\r\n public static createRange3dPlanes(range: Range3d,\r\n lowX: boolean = true, highX: boolean = true,\r\n lowY: boolean = true, highY: boolean = true,\r\n lowZ: boolean = true, highZ: boolean = true): ConvexClipPlaneSet {\r\n const result = ConvexClipPlaneSet.createEmpty();\r\n\r\n if (lowX)\r\n result.planes.push(ClipPlane.createNormalAndPointXYZXYZ(1, 0, 0, range.low.x, 0, 0)!);\r\n if (highX)\r\n result.planes.push(ClipPlane.createNormalAndPointXYZXYZ(-1, 0, 0, range.high.x, 0, 0)!);\r\n\r\n if (lowY)\r\n result.planes.push(ClipPlane.createNormalAndPointXYZXYZ(0, 1, 0, 0, range.low.y, 0)!);\r\n if (highY)\r\n result.planes.push(ClipPlane.createNormalAndPointXYZXYZ(0, -1, 0, 0, range.high.y, 0)!);\r\n\r\n if (lowZ)\r\n result.planes.push(ClipPlane.createNormalAndPointXYZXYZ(0, 0, 1, 0, 0, range.low.z)!);\r\n if (highZ)\r\n result.planes.push(ClipPlane.createNormalAndPointXYZXYZ(0, 0, -1, 0, 0, range.high.z)!);\r\n\r\n return result;\r\n }\r\n /** create an empty `ConvexClipPlaneSet` */\r\n public static createEmpty(result?: ConvexClipPlaneSet): ConvexClipPlaneSet {\r\n if (result) {\r\n result._planes.length = 0;\r\n return result;\r\n }\r\n return new ConvexClipPlaneSet();\r\n }\r\n /** negate all planes of the set. */\r\n public negateAllPlanes(): void {\r\n for (const plane of this._planes)\r\n plane.negateInPlace();\r\n }\r\n /** Create a convex clip plane set that clips to `x0 <= x <= x1` and `y0 <= y <= y1`.\r\n * * Note that there is no test for the usual ordering `x0 <= x1` or `y0 <= y1`.\r\n * * if the usual ordering is violated, the convex set is an empty set.\r\n */\r\n public static createXYBox(x0: number, y0: number, x1: number, y1: number, result?: ConvexClipPlaneSet): ConvexClipPlaneSet {\r\n result = result ? result : new ConvexClipPlaneSet();\r\n result._planes.length = 0;\r\n const clip0 = ClipPlane.createNormalAndDistance(Vector3d.create(-1, 0, 0), -x1, false, true);\r\n const clip1 = ClipPlane.createNormalAndDistance(Vector3d.create(1, 0, 0), x0, false, true);\r\n const clip2 = ClipPlane.createNormalAndDistance(Vector3d.create(0, -1, 0), -y1, false, true);\r\n const clip3 = ClipPlane.createNormalAndDistance(Vector3d.create(0, 1, 0), y0, false, true);\r\n if (clip0 && clip1 && clip2 && clip3) {\r\n result._planes.push(clip0, clip1, clip2, clip3);\r\n }\r\n return result;\r\n }\r\n /** Create a convex set containing a half space for each edge between points of a polyline.\r\n * * Caller is responsible for assuring the polyline is convex.\r\n * @param points array of points. Only xy parts are considered.\r\n * @param interior array whose boolean value is used as both the `interior` and `invisible` bits of the plane for the succeeding segment. If this array is not provided, both are false.\r\n * @param leftIsInside if true, the interior is \"to the left\" of the segments. If false, interior is \"to the right\"\r\n */\r\n public static createXYPolyLine(points: Point3d[], interior: boolean[] | undefined, leftIsInside: boolean, result?: ConvexClipPlaneSet): ConvexClipPlaneSet {\r\n result = result ? result : new ConvexClipPlaneSet();\r\n result._planes.length = 0;\r\n for (let i0 = 0; (i0 + 1) < points.length; i0++) {\r\n const edgeVector: Vector3d = Vector3d.createStartEnd(points[i0], points[i0 + 1]);\r\n const perp: Vector3d = edgeVector.unitPerpendicularXY();\r\n perp.z = 0.0;\r\n\r\n if (!leftIsInside)\r\n perp.scaleInPlace(-1.0);\r\n\r\n const perpNormalized = perp.normalize();\r\n if (perpNormalized) {\r\n const flag = interior !== undefined ? interior[i0] : false;\r\n const clip = ClipPlane.createNormalAndPoint(perp, points[i0], flag, flag);\r\n if (clip) {\r\n result._planes.push(clip);\r\n }\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Create a convexClipPlaneSet with planes whose \"inside\" normal is to the left of each segment.\r\n * @param points array of points.\r\n */\r\n public static createXYPolyLineInsideLeft(points: Point3d[], result?: ConvexClipPlaneSet): ConvexClipPlaneSet {\r\n result = result ? result : new ConvexClipPlaneSet();\r\n result._planes.length = 0;\r\n for (let i0 = 0; (i0 + 1) < points.length; i0++) {\r\n const edgeVector: Vector3d = Vector3d.createStartEnd(points[i0], points[i0 + 1]);\r\n const perp: Vector3d = edgeVector.unitPerpendicularXY();\r\n perp.z = 0.0;\r\n\r\n const perpNormalized = perp.normalize();\r\n if (perpNormalized) {\r\n const clip = ClipPlane.createNormalAndPoint(perp, points[i0], false, false);\r\n if (clip) { result._planes.push(clip); }\r\n }\r\n }\r\n return result;\r\n }\r\n /**\r\n * (re)set a plane and ConvexClipPlaneSet for a convex array, such as a convex facet used for xy clip.\r\n * * The planeOfPolygon is (re)initialized with the normal from 3 points, but not otherwise referenced.\r\n * * The ConvexClipPlaneSet is filled with outward normals of the facet edges as viewed to xy plane.\r\n * @param points\r\n * @param result\r\n */\r\n public static setPlaneAndXYLoopCCW(points: GrowableXYZArray, planeOfPolygon: ClipPlane, frustum: ConvexClipPlaneSet) {\r\n const i0 = points.length - 1;\r\n const n = points.length;\r\n let x0 = points.getXAtUncheckedPointIndex(i0);\r\n let y0 = points.getYAtUncheckedPointIndex(i0);\r\n let x1, y1, nx, ny;\r\n frustum._planes.length = 0;\r\n const z0 = points.getZAtUncheckedPointIndex(i0); // z for planes can stay fixed\r\n const planeNormal = points.crossProductIndexIndexIndex(0, 2, 1)!;\r\n ClipPlane.createNormalAndPointXYZXYZ(planeNormal.x, planeNormal.y, planeNormal.z, x0, y0, z0, false, false, planeOfPolygon);\r\n if (planeNormal.normalizeInPlace()) {\r\n for (let i1 = 0; i1 < n; i1++, x0 = x1, y0 = y1) {\r\n x1 = points.getXAtUncheckedPointIndex(i1);\r\n y1 = points.getYAtUncheckedPointIndex(i1);\r\n nx = -(y1 - y0);\r\n ny = x1 - x0;\r\n const clipper = ClipPlane.createNormalAndPointXYZXYZ(nx, ny, 0, x1, y1, z0);\r\n if (clipper)\r\n frustum._planes.push(clipper);\r\n }\r\n }\r\n }\r\n\r\n /** Deep clone of all planes. */\r\n public clone(result?: ConvexClipPlaneSet): ConvexClipPlaneSet {\r\n result = result ? result : new ConvexClipPlaneSet();\r\n result._planes.length = 0;\r\n for (const plane of this._planes)\r\n result._planes.push(plane.clone());\r\n return result;\r\n }\r\n /** Return the (reference to the) array of `ClipPlane` */\r\n public get planes(): ClipPlane[] {\r\n return this._planes;\r\n }\r\n\r\n /** Test if there is any intersection with a ray defined by origin and direction.\r\n * * Optionally record the range (null or otherwise) in caller-allocated result.\r\n * * If the ray is unbounded inside the clip, result can contain positive or negative \"Geometry.hugeCoordinate\" values\r\n * * If no result is provide, there are no object allocations.\r\n * @param result optional Range1d to receive parameters along the ray.\r\n */\r\n public hasIntersectionWithRay(ray: Ray3d, result?: Range1d): boolean {\r\n // form low and high values in locals that do not require allocation.\r\n // transfer to caller-supplied result at end\r\n let t0 = -Geometry.hugeCoordinate;\r\n let t1 = Geometry.hugeCoordinate;\r\n if (result)\r\n result.setNull();\r\n for (const plane of this._planes) {\r\n const vD = plane.velocity(ray.direction);\r\n const vN = plane.altitude(ray.origin);\r\n\r\n if (vD === 0.0) {\r\n // Ray is parallel... No need to continue testing if outside halfspace.\r\n if (vN < 0.0)\r\n return false; // and result is a null range.\r\n } else {\r\n const rayFraction = - vN / vD;\r\n if (vD < 0.0) {\r\n if (rayFraction < t1)\r\n t1 = rayFraction;\r\n } else {\r\n if (rayFraction > t0)\r\n t0 = rayFraction;\r\n }\r\n }\r\n }\r\n if (t1 < t0)\r\n return false; // and result is a null range.\r\n if (result) {\r\n result.extendX(t0);\r\n result.extendX(t1);\r\n }\r\n return true;\r\n }\r\n /**\r\n * Multiply all the ClipPlanes DPoint4d by matrix.\r\n * @param matrix matrix to apply.\r\n * @param invert if true, use in verse of the matrix.\r\n * @param transpose if true, use the transpose of the matrix (or inverse, per invert parameter)\r\n * * Note that if matrixA is applied to all of space, the matrix to send to this method to get a corresponding effect on the plane is the inverse transpose of matrixA\r\n * * Callers that will apply the same matrix to many planes should pre-invert the matrix for efficiency.\r\n * * Both params default to true to get the full effect of transforming space.\r\n * @param matrix matrix to apply\r\n */\r\n public multiplyPlanesByMatrix4d(matrix: Matrix4d, invert: boolean = true, transpose: boolean = true): boolean {\r\n if (invert) { // form inverse once here, reuse for all planes\r\n const inverse = matrix.createInverse();\r\n if (!inverse)\r\n return false;\r\n return this.multiplyPlanesByMatrix4d(inverse, false, transpose);\r\n }\r\n for (const plane of this._planes) {\r\n plane.multiplyPlaneByMatrix4d(matrix, false, transpose);\r\n }\r\n return true;\r\n }\r\n /** Return true if `point` satisfies `point.isPointInside` for all planes */\r\n public isPointInside(point: Point3d): boolean {\r\n for (const plane of this._planes) {\r\n if (!plane.isPointInside(point)) // Defaults to strict inside check. Other clipping classes may use \"on or inside\" check for the \"on\" case\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /** Return true if `point` satisfies `point.isPointOnOrInside` for all planes */\r\n public isPointOnOrInside(point: Point3d, tolerance: number): boolean {\r\n const interiorTolerance = Math.abs(tolerance); // Interior tolerance should always be positive. (TFS# 246598).\r\n for (const plane of this._planes) {\r\n if (!plane.isPointOnOrInside(point, (plane.interior ? interiorTolerance : tolerance)))\r\n return false;\r\n }\r\n return true;\r\n }\r\n /**\r\n * Test if a sphere is completely inside the convex set.\r\n * @param centerPoint center of sphere\r\n * @param radius radius of sphere.\r\n */\r\n public isSphereInside(centerPoint: Point3d, radius: number): boolean {\r\n const r1 = Math.abs(radius) + Geometry.smallMetricDistance;\r\n for (const plane of this._planes) {\r\n if (!plane.isPointOnOrInside(centerPoint, r1)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /** Find the parts of the line segment (if any) that is within the convex clip volume.\r\n * * The input fractional interval from fraction0 to fraction1 (increasing!!) is the active part to consider.\r\n * * To clip to the usual bounded line segment, starts with fractions (0,1).\r\n * If the clip volume is unbounded, the line interval may also be unbounded.\r\n * * An unbounded line portion will have fraction coordinates positive or negative Number.MAX_VALUE.\r\n * @param fraction0 fraction that is the initial lower fraction of the active interval. (e.g. 0.0 for bounded segment)\r\n * @param fraction1 fraction that is the initial upper fraction of the active interval. (e.g. 1.0 for bounded segment)\r\n * @param pointA segment start (fraction 0)\r\n * @param pointB segment end (fraction 1)\r\n * @param announce function to be called to announce a fraction interval that is within the convex clip volume.\r\n * @returns true if a segment was announced, false if entirely outside.\r\n */\r\n public announceClippedSegmentIntervals(f0: number, f1: number, pointA: Point3d, pointB: Point3d, announce?: AnnounceNumberNumber): boolean {\r\n let fraction: number | undefined;\r\n if (f1 < f0)\r\n return false;\r\n for (const plane of this._planes) {\r\n const hA = - plane.altitude(pointA);\r\n const hB = - plane.altitude(pointB);\r\n fraction = Geometry.conditionalDivideFraction(-hA, (hB - hA));\r\n if (fraction === undefined) {\r\n // LIne parallel to the plane. If positive, it is all OUT\r\n if (hA > 0.0)\r\n return false;\r\n } else if (hB > hA) { // STRICTLY moving outward\r\n if (fraction < f0)\r\n return false;\r\n if (fraction < f1)\r\n f1 = fraction;\r\n } else if (hA > hB) { // STRICTLY moving inward\r\n if (fraction > f1)\r\n return false;\r\n if (fraction > f0)\r\n f0 = fraction;\r\n } else {\r\n // Strictly equal evaluations\r\n if (hA > 0.0)\r\n return false;\r\n }\r\n }\r\n if (f1 >= f0) {\r\n if (announce)\r\n announce(f0, f1);\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n private static _clipArcFractionArray = new GrowableFloat64Array();\r\n /** Find fractional parts of the arc that are within this ClipPlaneSet, and announce each as\r\n * * `announce(fraction, fraction, curve)`\r\n */\r\n public announceClippedArcIntervals(arc: Arc3d, announce?: AnnounceNumberNumberCurvePrimitive): boolean {\r\n const breaks = ConvexClipPlaneSet._clipArcFractionArray;\r\n breaks.clear();\r\n for (const clipPlane of this.planes) {\r\n clipPlane.appendIntersectionRadians(arc, breaks);\r\n }\r\n arc.sweep.radiansArrayToPositivePeriodicFractions(breaks);\r\n return ClipUtilities.selectIntervals01(arc, breaks, this, announce);\r\n }\r\n /** Find the parts of the (unbounded) line segment (if any) that is within the convex clip volume.\r\n * @param pointA segment start (fraction 0)\r\n * @param pointB segment end (fraction 1)\r\n * @param announce function to be called to announce a fraction interval that is within the convex clip volume.\r\n * @returns true if a segment was announced, false if entirely outside.\r\n */\r\n public clipUnboundedSegment(pointA: Point3d, pointB: Point3d, announce?: AnnounceNumberNumber): boolean {\r\n return this.announceClippedSegmentIntervals(-Number.MAX_VALUE, Number.MAX_VALUE, pointA, pointB, announce);\r\n }\r\n /** transform each plane in place. */\r\n public transformInPlace(transform: Transform) {\r\n for (const plane of this._planes) {\r\n plane.transformInPlace(transform);\r\n }\r\n }\r\n\r\n /**\r\n * Clip a polygon to the inside of the convex set.\r\n * * Results with 2 or fewer points are ignored.\r\n * * Other than ensuring capacity in the arrays, there are no object allocations during execution of this function.\r\n * @param xyz input points.\r\n * @param work work buffer\r\n * @param tolerance tolerance for \"on plane\" decision.\r\n */\r\n public clipConvexPolygonInPlace(xyz: GrowableXYZArray, work: GrowableXYZArray, tolerance: number = Geometry.smallMetricDistance) {\r\n for (const plane of this._planes) {\r\n plane.clipConvexPolygonInPlace(xyz, work, true, tolerance);\r\n if (xyz.length < 3)\r\n return;\r\n }\r\n }\r\n /** Clip a convex polygon to (a single) inside part and (possibly many) outside parts.\r\n * @param xyz input polygon.\r\n * @param outsideFragments an array to receive (via push, with no preliminary clear) outside fragments\r\n * @param arrayCache cache for work arrays.\r\n * @return the surviving inside part (if any)\r\n */\r\n public clipInsidePushOutside(xyz: GrowableXYZArray,\r\n outsideFragments: GrowableXYZArray[] | undefined,\r\n arrayCache: GrowableXYZArrayCache): GrowableXYZArray | undefined {\r\n const perpendicularRange = Range1d.createNull();\r\n let newInside = arrayCache.grabFromCache();\r\n let newOutside = arrayCache.grabFromCache();\r\n let insidePart = arrayCache.grabFromCache(); // this is empty ...\r\n insidePart.pushFrom(xyz);\r\n // While looping through planes . .\r\n // the outside part for the current plane is definitely outside and can be stashed to the final outside\r\n // the inside part for the current plane passes forward to be further split by the remaining planes.\r\n for (const plane of this._planes) {\r\n IndexedXYZCollectionPolygonOps.splitConvexPolygonInsideOutsidePlane(plane, insidePart, newInside, newOutside, perpendicularRange);\r\n if (newOutside.length > 0) {\r\n // the newOutside fragment is definitely outside the ConvexClipPlaneSet\r\n if (outsideFragments) // save the definitely outside part as return data.\r\n ClipUtilities.captureOrDrop(newOutside, 3, outsideFragments, arrayCache);\r\n newOutside = arrayCache.grabFromCache();\r\n if (newInside.length === 0) {\r\n insidePart.length = 0;\r\n break;\r\n }\r\n // insideWork is changed ... swap it with insidePart\r\n arrayCache.dropToCache(insidePart);\r\n insidePart = newInside;\r\n newInside = arrayCache.grabFromCache();\r\n }\r\n // outside clip was empty .. insideWork is identical to insidePart .. let insidePart feed through to the next clipper.\r\n }\r\n // at break or fall out ...\r\n // ALWAYS drop `newInside` and `newOutside` to the cache\r\n arrayCache.dropToCache(newInside);\r\n arrayCache.dropToCache(newOutside);\r\n // if `insidePart` is alive, return it to caller. Otherwise drop it to cache and return undefined.\r\n if (insidePart.length > 0)\r\n return insidePart;\r\n arrayCache.dropToCache(insidePart);\r\n return undefined;\r\n }\r\n /** Returns 1, 2, or 3 based on whether point array is strongly inside, ambiguous, or strongly outside respectively.\r\n * * This has a peculiar expected use case as a very fast pre-filter for more precise clipping.\r\n * * The expected point set is for a polygon.\r\n * * Hence any clipping will eventually have to consider the lines between the points.\r\n * * This method looks for the special case of a single clip plane that has all the points outside.\r\n * * In this case the whole polygon must be outside.\r\n * * Note that this does not detect a polygon that is outside but \"crosses a corner\" -- it is mixed with respect to\r\n * multiple planes.\r\n */\r\n public classifyPointContainment(points: Point3d[], onIsOutside: boolean): ClipPlaneContainment {\r\n let allInside = true;\r\n const onTolerance = onIsOutside ? 1.0e-8 : -1.0e-8;\r\n const interiorTolerance = 1.0e-8; // Interior tolerance should always be positive\r\n\r\n for (const plane of this._planes) {\r\n let nOutside = 0;\r\n for (const point of points) {\r\n if (plane.altitude(point) < (plane.interior ? interiorTolerance : onTolerance)) {\r\n nOutside++;\r\n allInside = false;\r\n }\r\n }\r\n\r\n if (nOutside === points.length)\r\n return ClipPlaneContainment.StronglyOutside;\r\n }\r\n\r\n return allInside ? ClipPlaneContainment.StronglyInside : ClipPlaneContainment.Ambiguous;\r\n }\r\n\r\n /**\r\n * * Create a convex clip set for a polygon swept with possible tilt angle.\r\n * * planes are constructed by ClipPlane.createEdgeAndUpVector, using successive points from the array.\r\n * * If the first and last points match, the polygon area is checked. If the area is negative, points are used in reverse order.\r\n * * If first and last points do not match, points are used in order given\r\n * @param points polygon points. (Closure point optional)\r\n * @param upVector primary sweep direction, as applied by ClipPlane.createEdgeAndUpVector\r\n * @param tiltAngle angle to tilt sweep planes away from the sweep direction.\r\n */\r\n public static createSweptPolyline(points: Point3d[], upVector: Vector3d, tiltAngle?: Angle): ConvexClipPlaneSet | undefined {\r\n const result = ConvexClipPlaneSet.createEmpty();\r\n let reverse = false;\r\n if (points.length > 3 && points[0].isAlmostEqual(points[points.length - 1])) {\r\n const polygonNormal: Vector3d = PolygonOps.areaNormal(points);\r\n const normalDot = polygonNormal.dotProduct(upVector);\r\n if (normalDot > 0.0)\r\n reverse = true;\r\n }\r\n for (let i = 0; (i + 1) < points.length; i++) {\r\n if (reverse) {\r\n const toAdd = ClipPlane.createEdgeAndUpVector(points[i + 1], points[i], upVector, tiltAngle);\r\n if (toAdd) { // clipPlane creation could result in undefined\r\n result.addPlaneToConvexSet(toAdd);\r\n } else {\r\n return undefined;\r\n }\r\n } else {\r\n const toAdd = ClipPlane.createEdgeAndUpVector(points[i], points[i + 1], upVector, tiltAngle);\r\n if (toAdd) { // clipPlane creation could result in undefined\r\n result.addPlaneToConvexSet(toAdd);\r\n } else {\r\n return undefined;\r\n }\r\n }\r\n }\r\n return result;\r\n }\r\n /**\r\n * Add a plane to the convex set.\r\n * @param plane plane to add\r\n */\r\n public addPlaneToConvexSet(plane: ClipPlane | Plane3dByOriginAndUnitNormal| undefined) {\r\n if (plane instanceof ClipPlane)\r\n this._planes.push(plane);\r\n else if (plane instanceof Plane3dByOriginAndUnitNormal)\r\n this._planes.push(ClipPlane.createPlane(plane));\r\n }\r\n /**\r\n * test many points. Distribute them to arrays depending on in/out result.\r\n * @param points points to test\r\n * @param inOrOn points that are in or on the set\r\n * @param out points that are out.\r\n */\r\n public clipPointsOnOrInside(points: Point3d[], inOrOn: Point3d[], out: Point3d[]) {\r\n inOrOn.length = 0;\r\n out.length = 0;\r\n for (const xyz of points) {\r\n if (this.isPointOnOrInside(xyz, 0.0)) {\r\n inOrOn.push(xyz);\r\n } else {\r\n out.push(xyz);\r\n }\r\n }\r\n }\r\n /**\r\n * Clip a polygon to the planes of the clip plane set.\r\n * * For a convex input polygon, the output is another convex polygon.\r\n * * For a non-convex input, the output may have double-back edges along plane intersections. This is still a valid clip in a parity sense.\r\n * * The containingPlane parameter allows callers within ConvexClipPlane set to bypass planes known to contain the polygon\r\n * @param input input polygon, usually convex.\r\n * @param output output polygon\r\n * @param work work array.\r\n * @param containingPlane if this plane is found in the convex set, it is NOT applied.\r\n */\r\n public polygonClip(input: GrowableXYZArray | Point3d[], output: GrowableXYZArray, work: GrowableXYZArray, planeToSkip?: ClipPlane) {\r\n if (input instanceof GrowableXYZArray)\r\n input.clone(output);\r\n else\r\n GrowableXYZArray.create(input, output);\r\n\r\n for (const plane of this._planes) {\r\n if (planeToSkip === plane)\r\n continue;\r\n if (output.length === 0)\r\n break;\r\n plane.clipConvexPolygonInPlace(output, work);\r\n }\r\n }\r\n /**\r\n * * Define new planes in this ConvexClipPlaneSet so it clips to the inside of a polygon.\r\n * * always create planes for the swept edges of the polygon\r\n * * optionally (with nonzero sideSelect) create a cap plane using the polygon normal.\r\n * @param points Points of a bounding polygon\r\n * @param sweepDirection direction to sweep.\r\n * @param sideSelect 0 to have no cap polygon, 1 if the sweep vector side is in, -1 if sweep vector side is out.\r\n */\r\n public reloadSweptPolygon(points: Point3d[], sweepDirection: Vector3d, sideSelect: number): number {\r\n this._planes.length = 0;\r\n const n = points.length;\r\n if (n <= 2)\r\n return 0;\r\n\r\n const planeNormal: Vector3d = PolygonOps.areaNormal(points);\r\n const isCCW = sweepDirection.dotProduct(planeNormal) > 0.0;\r\n\r\n const delta = isCCW ? 1 : n - 1;\r\n for (let i = 0; i < n; i++) {\r\n const i1 = (i + delta) % n;\r\n const xyz0: Point3d = points[i];\r\n const xyz1: Point3d = points[i1];\r\n if (xyz0.isAlmostEqual(xyz1))\r\n continue;\r\n const edgeVector: Vector3d = Vector3d.createStartEnd(xyz0, xyz1);\r\n const inwardNormal: Vector3d = Vector3d.createCrossProduct(sweepDirection.x, sweepDirection.y, sweepDirection.z,\r\n edgeVector.x, edgeVector.y, edgeVector.z);\r\n const inwardNormalNormalized = inwardNormal.normalize();\r\n let distance;\r\n if (inwardNormalNormalized) { // Should never fail... simply a check due to the format of the normalize function return\r\n distance = inwardNormalNormalized.dotProduct(xyz0);\r\n const clipToAdd = ClipPlane.createNormalAndDistance(inwardNormalNormalized, distance, false, false);\r\n if (clipToAdd) { this._planes.push(clipToAdd); } // clipPlane creation could result in undefined\r\n }\r\n }\r\n if (sideSelect !== 0.0) {\r\n let planeNormalNormalized = planeNormal.normalize();\r\n if (planeNormalNormalized) { // Again.. should never fail\r\n const a = sweepDirection.dotProduct(planeNormalNormalized) * sideSelect;\r\n if (a < 0.0)\r\n planeNormalNormalized = planeNormalNormalized.negate();\r\n const xyz0: Point3d = points[0];\r\n const distance = planeNormalNormalized.dotProduct(xyz0);\r\n const clipToAdd = ClipPlane.createNormalAndDistance(planeNormalNormalized, distance, false, false);\r\n if (clipToAdd) { this._planes.push(clipToAdd); } // clipPlane creation could result in undefined\r\n }\r\n }\r\n return isCCW ? 1 : -1;\r\n }\r\n\r\n /**\r\n * Compute intersections among all combinations of 3 planes in the convex set.\r\n * * optionally throw out points that are not in the set.\r\n * * optionally push the points in the caller-supplied point array.\r\n * * optionally extend a caller supplied range.\r\n * * In the common case where the convex set is (a) a slab or (b) a view frustum, there will be 8 points and the range is the range of the convex set.\r\n * * If the convex set is unbounded, the range only contains the range of the accepted (corner) points, and the range is not a representative of the \"range of all points in the set\" .\r\n * @param transform (optional) transform to apply to the points.\r\n * @param points (optional) array to which computed points are to be added.\r\n * @param range (optional) range to be extended by the computed points\r\n * @param transform (optional) transform to apply to the accepted points.\r\n * @param testContainment if true, test each point to see if it is within the convex set. (Send false if confident that the convex set is rectilinear set such as a slab. Send true if chiseled corners are possible)\r\n * @returns number of points.\r\n */\r\n public computePlanePlanePlaneIntersections(points: Point3d[] | undefined, rangeToExtend: Range3d | undefined, transform?: Transform, testContainment: boolean = true): number {\r\n\r\n const normalRows = Matrix3d.createIdentity();\r\n const allPlanes = this._planes;\r\n const n = allPlanes.length;\r\n let numPoints = 0; // explicitly count points -- can't wait to end for points.length because it may be an optional output.\r\n for (let i = 0; i < n; i++) {\r\n for (let j = i + 1; j < n; j++)\r\n for (let k = j + 1; k < n; k++) {\r\n Matrix3d.createRowValues(\r\n allPlanes[i].inwardNormalRef.x, allPlanes[i].inwardNormalRef.y, allPlanes[i].inwardNormalRef.z,\r\n allPlanes[j].inwardNormalRef.x, allPlanes[j].inwardNormalRef.y, allPlanes[j].inwardNormalRef.z,\r\n allPlanes[k].inwardNormalRef.x, allPlanes[k].inwardNormalRef.y, allPlanes[k].inwardNormalRef.z,\r\n normalRows);\r\n if (normalRows.computeCachedInverse(false)) {\r\n const xyz = normalRows.multiplyInverseXYZAsPoint3d(allPlanes[i].distance, allPlanes[j].distance, allPlanes[k].distance)!;\r\n if (!testContainment || this.isPointOnOrInside(xyz, Geometry.smallMetricDistance)) {\r\n numPoints++;\r\n if (transform)\r\n transform.multiplyPoint3d(xyz, xyz);\r\n if (points)\r\n points.push(xyz);\r\n if (rangeToExtend)\r\n rangeToExtend.extendPoint(xyz);\r\n }\r\n }\r\n }\r\n }\r\n return numPoints;\r\n }\r\n /**\r\n * Set the `invisible` property on each plane of the convex set.\r\n * @param invisible value to store\r\n */\r\n public setInvisible(invisible: boolean) {\r\n for (const plane of this._planes) {\r\n plane.setInvisible(invisible);\r\n }\r\n }\r\n /**\r\n * Add planes for z-direction clip between low and high z levels.\r\n * @param invisible value to apply to the `invisible` bit for the new planes\r\n * @param zLow low z value. The plane clips out points with z below this.\r\n * @param zHigh high z value. The plane clips out points with z above this.\r\n */\r\n public addZClipPlanes(invisible: boolean, zLow?: number, zHigh?: number) {\r\n if (zLow !== undefined)\r\n this._planes.push(ClipPlane.createNormalAndDistance(Vector3d.create(0, 0, 1), zLow, invisible)!);\r\n if (zHigh !== undefined)\r\n this._planes.push(ClipPlane.createNormalAndDistance(Vector3d.create(0, 0, -1), -zHigh, invisible)!);\r\n }\r\n /** Implement appendPolygonClip, as defined in interface PolygonClipper. /**\r\n *\r\n * @param xyz input polygon. This is not changed.\r\n * @param insideFragments Array to receive \"inside\" fragments. Each fragment is a GrowableXYZArray grabbed from the cache. This is NOT cleared.\r\n * @param outsideFragments Array to receive \"outside\" fragments. Each fragment is a GrowableXYZArray grabbed from the cache. This is NOT cleared.\r\n * @param arrayCache cache for reusable GrowableXYZArray.\r\n */\r\n public appendPolygonClip(\r\n xyz: GrowableXYZArray,\r\n insideFragments: GrowableXYZArray[],\r\n outsideFragments: GrowableXYZArray[],\r\n arrayCache: GrowableXYZArrayCache): void {\r\n const newInside = this.clipInsidePushOutside(xyz, outsideFragments, arrayCache);\r\n if (newInside)\r\n insideFragments.push(newInside);\r\n }\r\n\r\n // FUNCTIONS SKIPPED DUE TO BSPLINES, VU, OR NON-USAGE IN NATIVE CODE----------------------------------------------------------------\r\n\r\n // Uses bsplines... skipping for now:\r\n // public convexAppendIntervalsFromBspline();\r\n\r\n // Uses pushing and clearing from/to a cache and added functionality for arrays. . . skipping for now\r\n // public convexPolygonClipInsideOutside(input: Point3d[], inside: Point3d[], outside: Point3d[], work1: Point3d[], work2: Point3d[],\r\n // clearOutside: boolean, distanceTolerance: number)\r\n}\r\n"]}
1
+ {"version":3,"file":"ConvexClipPlaneSet.js","sourceRoot":"","sources":["../../../src/clipping/ConvexClipPlaneSet.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAQ/F,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAE1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,QAAQ,EA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AC;QAChF,IAAI,SAAS;YACX,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;;AA/rBD,iEAAiE;AAC1C,0BAAO,GAAG,IAAI,CAAC;AA6WvB,wCAAqB,GAAG,IAAI,oBAAoB,EAAE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { Arc3d } from \"../curve/Arc3d\";\r\nimport { AnnounceNumberNumber, AnnounceNumberNumberCurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport { Angle } from \"../geometry3d/Angle\";\r\nimport { GrowableFloat64Array } from \"../geometry3d/GrowableFloat64Array\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { Matrix3d } from \"../geometry3d/Matrix3d\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { IndexedXYZCollectionPolygonOps, PolygonOps } from \"../geometry3d/PolygonOps\";\r\nimport { Range1d, Range3d } from \"../geometry3d/Range\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { GrowableXYZArrayCache } from \"../geometry3d/ReusableObjectCache\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { Matrix4d } from \"../geometry4d/Matrix4d\";\r\nimport { ClipPlane, ClipPlaneProps } from \"./ClipPlane\";\r\nimport { Clipper, ClipPlaneContainment, ClipUtilities, PolygonClipper } from \"./ClipUtils\";\r\n\r\n/** Wire format describing a [[ConvexClipPlaneSet]].\r\n * @public\r\n */\r\nexport type ConvexClipPlaneSetProps = ClipPlaneProps[];\r\n\r\n/**\r\n * A ConvexClipPlaneSet is a collection of ClipPlanes, often used for bounding regions of space.\r\n * @public\r\n */\r\nexport class ConvexClipPlaneSet implements Clipper, PolygonClipper {\r\n /** Value acting as \"at infinity\" for coordinates along a ray. */\r\n public static readonly hugeVal = 1e37;\r\n private _planes: ClipPlane[];\r\n // private _parity: number; <--- Not yet used\r\n // public get parity() { return this._parity; }\r\n // public set parity(value: number) { this._parity = value; }\r\n private constructor(planes?: ClipPlane[]) {\r\n // this._parity = 1;\r\n this._planes = planes ? planes : [];\r\n }\r\n /** Return an array containing all the planes of the convex set.\r\n * * Note that this has no leading keyword identifying it as a ConvexClipPlaneSet.\r\n */\r\n public toJSON(): ConvexClipPlaneSetProps {\r\n const val: ClipPlaneProps[] = [];\r\n for (const plane of this._planes)\r\n val.push(plane.toJSON());\r\n\r\n return val;\r\n }\r\n\r\n /** Extract clip planes from a json array `[ clipPlane, clipPlane ]`.\r\n * * Non-clipPlane members are ignored.\r\n */\r\n public static fromJSON(json: ConvexClipPlaneSetProps | undefined, result?: ConvexClipPlaneSet): ConvexClipPlaneSet {\r\n result = result ? result : new ConvexClipPlaneSet();\r\n result._planes.length = 0;\r\n if (!Array.isArray(json))\r\n return result;\r\n\r\n for (const thisJson of json) {\r\n const plane = ClipPlane.fromJSON(thisJson);\r\n if (plane)\r\n result._planes.push(plane);\r\n }\r\n\r\n return result;\r\n }\r\n /**\r\n * Return true if all members are almostEqual to corresponding members of other. This includes identical order in array.\r\n * @param other clip plane to compare\r\n */\r\n public isAlmostEqual(other: ConvexClipPlaneSet): boolean {\r\n if (this._planes.length !== other._planes.length)\r\n return false;\r\n for (let i = 0; i < this._planes.length; i++)\r\n if (!this._planes[i].isAlmostEqual(other._planes[i]))\r\n return false;\r\n return true;\r\n }\r\n /** create from an array of planes.\r\n * * Each plane reference in the `planes` array is taken into the result.\r\n * * The input array itself is NOT taken into the result.\r\n */\r\n public static createPlanes(planes: (ClipPlane | Plane3dByOriginAndUnitNormal)[], result?: ConvexClipPlaneSet): ConvexClipPlaneSet {\r\n result = result ? result : new ConvexClipPlaneSet();\r\n for (const plane of planes) {\r\n if (plane instanceof ClipPlane) {\r\n result._planes.push(plane);\r\n } else if (plane instanceof Plane3dByOriginAndUnitNormal) {\r\n const clipPlane = ClipPlane.createPlane(plane);\r\n result._planes.push(clipPlane);\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Create new convex set using selected planes of a Range3d.\r\n * @param range range with coordinates\r\n * @param lowX true to clip at the low x plane\r\n * @param highX true to clip at the high x plane\r\n * @param lowY true to clip at the low y plane\r\n * @param highY true to clip at the high z plane\r\n * @param lowZ true to clip at the low z plane\r\n * @param highZ true to clip at the high z plane\r\n */\r\n public static createRange3dPlanes(range: Range3d,\r\n lowX: boolean = true, highX: boolean = true,\r\n lowY: boolean = true, highY: boolean = true,\r\n lowZ: boolean = true, highZ: boolean = true): ConvexClipPlaneSet {\r\n const result = ConvexClipPlaneSet.createEmpty();\r\n\r\n if (lowX)\r\n result.planes.push(ClipPlane.createNormalAndPointXYZXYZ(1, 0, 0, range.low.x, 0, 0)!);\r\n if (highX)\r\n result.planes.push(ClipPlane.createNormalAndPointXYZXYZ(-1, 0, 0, range.high.x, 0, 0)!);\r\n\r\n if (lowY)\r\n result.planes.push(ClipPlane.createNormalAndPointXYZXYZ(0, 1, 0, 0, range.low.y, 0)!);\r\n if (highY)\r\n result.planes.push(ClipPlane.createNormalAndPointXYZXYZ(0, -1, 0, 0, range.high.y, 0)!);\r\n\r\n if (lowZ)\r\n result.planes.push(ClipPlane.createNormalAndPointXYZXYZ(0, 0, 1, 0, 0, range.low.z)!);\r\n if (highZ)\r\n result.planes.push(ClipPlane.createNormalAndPointXYZXYZ(0, 0, -1, 0, 0, range.high.z)!);\r\n\r\n return result;\r\n }\r\n /** create an empty `ConvexClipPlaneSet` */\r\n public static createEmpty(result?: ConvexClipPlaneSet): ConvexClipPlaneSet {\r\n if (result) {\r\n result._planes.length = 0;\r\n return result;\r\n }\r\n return new ConvexClipPlaneSet();\r\n }\r\n /** negate all planes of the set. */\r\n public negateAllPlanes(): void {\r\n for (const plane of this._planes)\r\n plane.negateInPlace();\r\n }\r\n /** Create a convex clip plane set that clips to `x0 <= x <= x1` and `y0 <= y <= y1`.\r\n * * Note that there is no test for the usual ordering `x0 <= x1` or `y0 <= y1`.\r\n * * if the usual ordering is violated, the convex set is an empty set.\r\n */\r\n public static createXYBox(x0: number, y0: number, x1: number, y1: number, result?: ConvexClipPlaneSet): ConvexClipPlaneSet {\r\n result = result ? result : new ConvexClipPlaneSet();\r\n result._planes.length = 0;\r\n const clip0 = ClipPlane.createNormalAndDistance(Vector3d.create(-1, 0, 0), -x1, false, true);\r\n const clip1 = ClipPlane.createNormalAndDistance(Vector3d.create(1, 0, 0), x0, false, true);\r\n const clip2 = ClipPlane.createNormalAndDistance(Vector3d.create(0, -1, 0), -y1, false, true);\r\n const clip3 = ClipPlane.createNormalAndDistance(Vector3d.create(0, 1, 0), y0, false, true);\r\n if (clip0 && clip1 && clip2 && clip3) {\r\n result._planes.push(clip0, clip1, clip2, clip3);\r\n }\r\n return result;\r\n }\r\n /** Create a convex set containing a half space for each edge between points of a polyline.\r\n * * Caller is responsible for assuring the polyline is convex.\r\n * @param points array of points. Only xy parts are considered.\r\n * @param interior array whose boolean value is used as both the `interior` and `invisible` bits of the plane for the succeeding segment. If this array is not provided, both are false.\r\n * @param leftIsInside if true, the interior is \"to the left\" of the segments. If false, interior is \"to the right\"\r\n */\r\n public static createXYPolyLine(points: Point3d[], interior: boolean[] | undefined, leftIsInside: boolean, result?: ConvexClipPlaneSet): ConvexClipPlaneSet {\r\n result = result ? result : new ConvexClipPlaneSet();\r\n result._planes.length = 0;\r\n for (let i0 = 0; (i0 + 1) < points.length; i0++) {\r\n const edgeVector: Vector3d = Vector3d.createStartEnd(points[i0], points[i0 + 1]);\r\n const perp: Vector3d = edgeVector.unitPerpendicularXY();\r\n perp.z = 0.0;\r\n\r\n if (!leftIsInside)\r\n perp.scaleInPlace(-1.0);\r\n\r\n const perpNormalized = perp.normalize();\r\n if (perpNormalized) {\r\n const flag = interior !== undefined ? interior[i0] : false;\r\n const clip = ClipPlane.createNormalAndPoint(perp, points[i0], flag, flag);\r\n if (clip) {\r\n result._planes.push(clip);\r\n }\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Create a convexClipPlaneSet with planes whose \"inside\" normal is to the left of each segment.\r\n * @param points array of points.\r\n */\r\n public static createXYPolyLineInsideLeft(points: Point3d[], result?: ConvexClipPlaneSet): ConvexClipPlaneSet {\r\n result = result ? result : new ConvexClipPlaneSet();\r\n result._planes.length = 0;\r\n for (let i0 = 0; (i0 + 1) < points.length; i0++) {\r\n const edgeVector: Vector3d = Vector3d.createStartEnd(points[i0], points[i0 + 1]);\r\n const perp: Vector3d = edgeVector.unitPerpendicularXY();\r\n perp.z = 0.0;\r\n\r\n const perpNormalized = perp.normalize();\r\n if (perpNormalized) {\r\n const clip = ClipPlane.createNormalAndPoint(perp, points[i0], false, false);\r\n if (clip) { result._planes.push(clip); }\r\n }\r\n }\r\n return result;\r\n }\r\n /**\r\n * (re)set a plane and ConvexClipPlaneSet for a convex array, such as a convex facet used for xy clip.\r\n * * The planeOfPolygon is (re)initialized with the normal from 3 points, but not otherwise referenced.\r\n * * The ConvexClipPlaneSet is filled with outward normals of the facet edges as viewed to xy plane.\r\n * @param points\r\n * @param result\r\n */\r\n public static setPlaneAndXYLoopCCW(points: GrowableXYZArray, planeOfPolygon: ClipPlane, frustum: ConvexClipPlaneSet) {\r\n const i0 = points.length - 1;\r\n const n = points.length;\r\n let x0 = points.getXAtUncheckedPointIndex(i0);\r\n let y0 = points.getYAtUncheckedPointIndex(i0);\r\n let x1, y1, nx, ny;\r\n frustum._planes.length = 0;\r\n const z0 = points.getZAtUncheckedPointIndex(i0); // z for planes can stay fixed\r\n const planeNormal = points.crossProductIndexIndexIndex(0, 2, 1)!;\r\n ClipPlane.createNormalAndPointXYZXYZ(planeNormal.x, planeNormal.y, planeNormal.z, x0, y0, z0, false, false, planeOfPolygon);\r\n if (planeNormal.normalizeInPlace()) {\r\n for (let i1 = 0; i1 < n; i1++, x0 = x1, y0 = y1) {\r\n x1 = points.getXAtUncheckedPointIndex(i1);\r\n y1 = points.getYAtUncheckedPointIndex(i1);\r\n nx = -(y1 - y0);\r\n ny = x1 - x0;\r\n const clipper = ClipPlane.createNormalAndPointXYZXYZ(nx, ny, 0, x1, y1, z0);\r\n if (clipper)\r\n frustum._planes.push(clipper);\r\n }\r\n }\r\n }\r\n\r\n /** Deep clone of all planes. */\r\n public clone(result?: ConvexClipPlaneSet): ConvexClipPlaneSet {\r\n result = result ? result : new ConvexClipPlaneSet();\r\n result._planes.length = 0;\r\n for (const plane of this._planes)\r\n result._planes.push(plane.clone());\r\n return result;\r\n }\r\n /** Return the (reference to the) array of `ClipPlane` */\r\n public get planes(): ClipPlane[] {\r\n return this._planes;\r\n }\r\n\r\n /** Test if there is any intersection with a ray defined by origin and direction.\r\n * * Optionally record the range (null or otherwise) in caller-allocated result.\r\n * * If the ray is unbounded inside the clip, result can contain positive or negative \"Geometry.hugeCoordinate\" values\r\n * * If no result is provide, there are no object allocations.\r\n * @param result optional Range1d to receive parameters along the ray.\r\n */\r\n public hasIntersectionWithRay(ray: Ray3d, result?: Range1d, tolerance: number = Geometry.smallMetricDistance ): boolean {\r\n // form low and high values in locals that do not require allocation.\r\n // transfer to caller-supplied result at end\r\n let t0 = -Geometry.hugeCoordinate;\r\n let t1 = Geometry.hugeCoordinate;\r\n if (result)\r\n result.setNull();\r\n const velocityTolerance = 1.0e-13;\r\n for (const plane of this._planes) {\r\n const vD = plane.velocity(ray.direction);\r\n const vN = plane.altitude(ray.origin);\r\n\r\n if (Math.abs (vD) <= velocityTolerance) {\r\n // Ray is parallel... No need to continue testing if outside halfspace.\r\n if (vN < -tolerance)\r\n return false; // and result is a null range.\r\n } else {\r\n const rayFraction = - vN / vD;\r\n if (vD < 0.0) {\r\n if (rayFraction < t1)\r\n t1 = rayFraction;\r\n } else {\r\n if (rayFraction > t0)\r\n t0 = rayFraction;\r\n }\r\n }\r\n }\r\n if (t1 < t0)\r\n return false; // and result is a null range.\r\n if (result) {\r\n result.extendX(t0);\r\n result.extendX(t1);\r\n }\r\n return true;\r\n }\r\n /**\r\n * Multiply all the ClipPlanes DPoint4d by matrix.\r\n * @param matrix matrix to apply.\r\n * @param invert if true, use in verse of the matrix.\r\n * @param transpose if true, use the transpose of the matrix (or inverse, per invert parameter)\r\n * * Note that if matrixA is applied to all of space, the matrix to send to this method to get a corresponding effect on the plane is the inverse transpose of matrixA\r\n * * Callers that will apply the same matrix to many planes should pre-invert the matrix for efficiency.\r\n * * Both params default to true to get the full effect of transforming space.\r\n * @param matrix matrix to apply\r\n */\r\n public multiplyPlanesByMatrix4d(matrix: Matrix4d, invert: boolean = true, transpose: boolean = true): boolean {\r\n if (invert) { // form inverse once here, reuse for all planes\r\n const inverse = matrix.createInverse();\r\n if (!inverse)\r\n return false;\r\n return this.multiplyPlanesByMatrix4d(inverse, false, transpose);\r\n }\r\n for (const plane of this._planes) {\r\n plane.multiplyPlaneByMatrix4d(matrix, false, transpose);\r\n }\r\n return true;\r\n }\r\n /** Return true if `point` satisfies `point.isPointInside` for all planes */\r\n public isPointInside(point: Point3d): boolean {\r\n for (const plane of this._planes) {\r\n if (!plane.isPointInside(point)) // Defaults to strict inside check. Other clipping classes may use \"on or inside\" check for the \"on\" case\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /** Return true if `point` satisfies `point.isPointOnOrInside` for all planes */\r\n public isPointOnOrInside(point: Point3d, tolerance: number): boolean {\r\n const interiorTolerance = Math.abs(tolerance); // Interior tolerance should always be positive. (TFS# 246598).\r\n for (const plane of this._planes) {\r\n if (!plane.isPointOnOrInside(point, (plane.interior ? interiorTolerance : tolerance)))\r\n return false;\r\n }\r\n return true;\r\n }\r\n /**\r\n * Test if a sphere is completely inside the convex set.\r\n * @param centerPoint center of sphere\r\n * @param radius radius of sphere.\r\n */\r\n public isSphereInside(centerPoint: Point3d, radius: number): boolean {\r\n const r1 = Math.abs(radius) + Geometry.smallMetricDistance;\r\n for (const plane of this._planes) {\r\n if (!plane.isPointOnOrInside(centerPoint, r1)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /** Find the parts of the line segment (if any) that is within the convex clip volume.\r\n * * The input fractional interval from fraction0 to fraction1 (increasing!!) is the active part to consider.\r\n * * To clip to the usual bounded line segment, starts with fractions (0,1).\r\n * If the clip volume is unbounded, the line interval may also be unbounded.\r\n * * An unbounded line portion will have fraction coordinates positive or negative Number.MAX_VALUE.\r\n * @param fraction0 fraction that is the initial lower fraction of the active interval. (e.g. 0.0 for bounded segment)\r\n * @param fraction1 fraction that is the initial upper fraction of the active interval. (e.g. 1.0 for bounded segment)\r\n * @param pointA segment start (fraction 0)\r\n * @param pointB segment end (fraction 1)\r\n * @param announce function to be called to announce a fraction interval that is within the convex clip volume.\r\n * @returns true if a segment was announced, false if entirely outside.\r\n */\r\n public announceClippedSegmentIntervals(f0: number, f1: number, pointA: Point3d, pointB: Point3d, announce?: AnnounceNumberNumber): boolean {\r\n let fraction: number | undefined;\r\n if (f1 < f0)\r\n return false;\r\n for (const plane of this._planes) {\r\n const hA = - plane.altitude(pointA);\r\n const hB = - plane.altitude(pointB);\r\n fraction = Geometry.conditionalDivideFraction(-hA, (hB - hA));\r\n if (fraction === undefined) {\r\n // LIne parallel to the plane. If positive, it is all OUT\r\n if (hA > 0.0)\r\n return false;\r\n } else if (hB > hA) { // STRICTLY moving outward\r\n if (fraction < f0)\r\n return false;\r\n if (fraction < f1)\r\n f1 = fraction;\r\n } else if (hA > hB) { // STRICTLY moving inward\r\n if (fraction > f1)\r\n return false;\r\n if (fraction > f0)\r\n f0 = fraction;\r\n } else {\r\n // Strictly equal evaluations\r\n if (hA > 0.0)\r\n return false;\r\n }\r\n }\r\n if (f1 >= f0) {\r\n if (announce)\r\n announce(f0, f1);\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n private static _clipArcFractionArray = new GrowableFloat64Array();\r\n /** Find fractional parts of the arc that are within this ClipPlaneSet, and announce each as\r\n * * `announce(fraction, fraction, curve)`\r\n */\r\n public announceClippedArcIntervals(arc: Arc3d, announce?: AnnounceNumberNumberCurvePrimitive): boolean {\r\n const breaks = ConvexClipPlaneSet._clipArcFractionArray;\r\n breaks.clear();\r\n for (const clipPlane of this.planes) {\r\n clipPlane.appendIntersectionRadians(arc, breaks);\r\n }\r\n arc.sweep.radiansArrayToPositivePeriodicFractions(breaks);\r\n return ClipUtilities.selectIntervals01(arc, breaks, this, announce);\r\n }\r\n /** Find the parts of the (unbounded) line segment (if any) that is within the convex clip volume.\r\n * @param pointA segment start (fraction 0)\r\n * @param pointB segment end (fraction 1)\r\n * @param announce function to be called to announce a fraction interval that is within the convex clip volume.\r\n * @returns true if a segment was announced, false if entirely outside.\r\n */\r\n public clipUnboundedSegment(pointA: Point3d, pointB: Point3d, announce?: AnnounceNumberNumber): boolean {\r\n return this.announceClippedSegmentIntervals(-Number.MAX_VALUE, Number.MAX_VALUE, pointA, pointB, announce);\r\n }\r\n /** transform each plane in place. */\r\n public transformInPlace(transform: Transform) {\r\n for (const plane of this._planes) {\r\n plane.transformInPlace(transform);\r\n }\r\n }\r\n\r\n /**\r\n * Clip a polygon to the inside of the convex set.\r\n * * Results with 2 or fewer points are ignored.\r\n * * Other than ensuring capacity in the arrays, there are no object allocations during execution of this function.\r\n * @param xyz input points.\r\n * @param work work buffer\r\n * @param tolerance tolerance for \"on plane\" decision.\r\n */\r\n public clipConvexPolygonInPlace(xyz: GrowableXYZArray, work: GrowableXYZArray, tolerance: number = Geometry.smallMetricDistance) {\r\n for (const plane of this._planes) {\r\n plane.clipConvexPolygonInPlace(xyz, work, true, tolerance);\r\n if (xyz.length < 3)\r\n return;\r\n }\r\n }\r\n /** Clip a convex polygon to (a single) inside part and (possibly many) outside parts.\r\n * @param xyz input polygon.\r\n * @param outsideFragments an array to receive (via push, with no preliminary clear) outside fragments\r\n * @param arrayCache cache for work arrays.\r\n * @return the surviving inside part (if any)\r\n */\r\n public clipInsidePushOutside(xyz: GrowableXYZArray,\r\n outsideFragments: GrowableXYZArray[] | undefined,\r\n arrayCache: GrowableXYZArrayCache): GrowableXYZArray | undefined {\r\n const perpendicularRange = Range1d.createNull();\r\n let newInside = arrayCache.grabFromCache();\r\n let newOutside = arrayCache.grabFromCache();\r\n let insidePart = arrayCache.grabFromCache(); // this is empty ...\r\n insidePart.pushFrom(xyz);\r\n // While looping through planes . .\r\n // the outside part for the current plane is definitely outside and can be stashed to the final outside\r\n // the inside part for the current plane passes forward to be further split by the remaining planes.\r\n for (const plane of this._planes) {\r\n IndexedXYZCollectionPolygonOps.splitConvexPolygonInsideOutsidePlane(plane, insidePart, newInside, newOutside, perpendicularRange);\r\n if (newOutside.length > 0) {\r\n // the newOutside fragment is definitely outside the ConvexClipPlaneSet\r\n if (outsideFragments) // save the definitely outside part as return data.\r\n ClipUtilities.captureOrDrop(newOutside, 3, outsideFragments, arrayCache);\r\n newOutside = arrayCache.grabFromCache();\r\n if (newInside.length === 0) {\r\n insidePart.length = 0;\r\n break;\r\n }\r\n // insideWork is changed ... swap it with insidePart\r\n arrayCache.dropToCache(insidePart);\r\n insidePart = newInside;\r\n newInside = arrayCache.grabFromCache();\r\n }\r\n // outside clip was empty .. insideWork is identical to insidePart .. let insidePart feed through to the next clipper.\r\n }\r\n // at break or fall out ...\r\n // ALWAYS drop `newInside` and `newOutside` to the cache\r\n arrayCache.dropToCache(newInside);\r\n arrayCache.dropToCache(newOutside);\r\n // if `insidePart` is alive, return it to caller. Otherwise drop it to cache and return undefined.\r\n if (insidePart.length > 0)\r\n return insidePart;\r\n arrayCache.dropToCache(insidePart);\r\n return undefined;\r\n }\r\n /** Returns 1, 2, or 3 based on whether point array is strongly inside, ambiguous, or strongly outside respectively.\r\n * * This has a peculiar expected use case as a very fast pre-filter for more precise clipping.\r\n * * The expected point set is for a polygon.\r\n * * Hence any clipping will eventually have to consider the lines between the points.\r\n * * This method looks for the special case of a single clip plane that has all the points outside.\r\n * * In this case the whole polygon must be outside.\r\n * * Note that this does not detect a polygon that is outside but \"crosses a corner\" -- it is mixed with respect to\r\n * multiple planes.\r\n */\r\n public classifyPointContainment(points: Point3d[], onIsOutside: boolean): ClipPlaneContainment {\r\n let allInside = true;\r\n const onTolerance = onIsOutside ? 1.0e-8 : -1.0e-8;\r\n const interiorTolerance = 1.0e-8; // Interior tolerance should always be positive\r\n\r\n for (const plane of this._planes) {\r\n let nOutside = 0;\r\n for (const point of points) {\r\n if (plane.altitude(point) < (plane.interior ? interiorTolerance : onTolerance)) {\r\n nOutside++;\r\n allInside = false;\r\n }\r\n }\r\n\r\n if (nOutside === points.length)\r\n return ClipPlaneContainment.StronglyOutside;\r\n }\r\n\r\n return allInside ? ClipPlaneContainment.StronglyInside : ClipPlaneContainment.Ambiguous;\r\n }\r\n\r\n /**\r\n * * Create a convex clip set for a polygon swept with possible tilt angle.\r\n * * planes are constructed by ClipPlane.createEdgeAndUpVector, using successive points from the array.\r\n * * If the first and last points match, the polygon area is checked. If the area is negative, points are used in reverse order.\r\n * * If first and last points do not match, points are used in order given\r\n * @param points polygon points. (Closure point optional)\r\n * @param upVector primary sweep direction, as applied by ClipPlane.createEdgeAndUpVector\r\n * @param tiltAngle angle to tilt sweep planes away from the sweep direction.\r\n */\r\n public static createSweptPolyline(points: Point3d[], upVector: Vector3d, tiltAngle?: Angle): ConvexClipPlaneSet | undefined {\r\n const result = ConvexClipPlaneSet.createEmpty();\r\n let reverse = false;\r\n if (points.length > 3 && points[0].isAlmostEqual(points[points.length - 1])) {\r\n const polygonNormal: Vector3d = PolygonOps.areaNormal(points);\r\n const normalDot = polygonNormal.dotProduct(upVector);\r\n if (normalDot > 0.0)\r\n reverse = true;\r\n }\r\n for (let i = 0; (i + 1) < points.length; i++) {\r\n if (reverse) {\r\n const toAdd = ClipPlane.createEdgeAndUpVector(points[i + 1], points[i], upVector, tiltAngle);\r\n if (toAdd) { // clipPlane creation could result in undefined\r\n result.addPlaneToConvexSet(toAdd);\r\n } else {\r\n return undefined;\r\n }\r\n } else {\r\n const toAdd = ClipPlane.createEdgeAndUpVector(points[i], points[i + 1], upVector, tiltAngle);\r\n if (toAdd) { // clipPlane creation could result in undefined\r\n result.addPlaneToConvexSet(toAdd);\r\n } else {\r\n return undefined;\r\n }\r\n }\r\n }\r\n return result;\r\n }\r\n /**\r\n * Add a plane to the convex set.\r\n * @param plane plane to add\r\n */\r\n public addPlaneToConvexSet(plane: ClipPlane | Plane3dByOriginAndUnitNormal| undefined) {\r\n if (plane instanceof ClipPlane)\r\n this._planes.push(plane);\r\n else if (plane instanceof Plane3dByOriginAndUnitNormal)\r\n this._planes.push(ClipPlane.createPlane(plane));\r\n }\r\n /**\r\n * test many points. Distribute them to arrays depending on in/out result.\r\n * @param points points to test\r\n * @param inOrOn points that are in or on the set\r\n * @param out points that are out.\r\n */\r\n public clipPointsOnOrInside(points: Point3d[], inOrOn: Point3d[], out: Point3d[]) {\r\n inOrOn.length = 0;\r\n out.length = 0;\r\n for (const xyz of points) {\r\n if (this.isPointOnOrInside(xyz, 0.0)) {\r\n inOrOn.push(xyz);\r\n } else {\r\n out.push(xyz);\r\n }\r\n }\r\n }\r\n /**\r\n * Clip a polygon to the planes of the clip plane set.\r\n * * For a convex input polygon, the output is another convex polygon.\r\n * * For a non-convex input, the output may have double-back edges along plane intersections. This is still a valid clip in a parity sense.\r\n * * The containingPlane parameter allows callers within ConvexClipPlane set to bypass planes known to contain the polygon\r\n * @param input input polygon, usually convex.\r\n * @param output output polygon\r\n * @param work work array.\r\n * @param containingPlane if this plane is found in the convex set, it is NOT applied.\r\n */\r\n public polygonClip(input: GrowableXYZArray | Point3d[], output: GrowableXYZArray, work: GrowableXYZArray, planeToSkip?: ClipPlane) {\r\n if (input instanceof GrowableXYZArray)\r\n input.clone(output);\r\n else\r\n GrowableXYZArray.create(input, output);\r\n\r\n for (const plane of this._planes) {\r\n if (planeToSkip === plane)\r\n continue;\r\n if (output.length === 0)\r\n break;\r\n plane.clipConvexPolygonInPlace(output, work);\r\n }\r\n }\r\n /**\r\n * * Define new planes in this ConvexClipPlaneSet so it clips to the inside of a polygon.\r\n * * always create planes for the swept edges of the polygon\r\n * * optionally (with nonzero sideSelect) create a cap plane using the polygon normal.\r\n * @param points Points of a bounding polygon\r\n * @param sweepDirection direction to sweep.\r\n * @param sideSelect 0 to have no cap polygon, 1 if the sweep vector side is in, -1 if sweep vector side is out.\r\n */\r\n public reloadSweptPolygon(points: Point3d[], sweepDirection: Vector3d, sideSelect: number): number {\r\n this._planes.length = 0;\r\n const n = points.length;\r\n if (n <= 2)\r\n return 0;\r\n\r\n const planeNormal: Vector3d = PolygonOps.areaNormal(points);\r\n const isCCW = sweepDirection.dotProduct(planeNormal) > 0.0;\r\n\r\n const delta = isCCW ? 1 : n - 1;\r\n for (let i = 0; i < n; i++) {\r\n const i1 = (i + delta) % n;\r\n const xyz0: Point3d = points[i];\r\n const xyz1: Point3d = points[i1];\r\n if (xyz0.isAlmostEqual(xyz1))\r\n continue;\r\n const edgeVector: Vector3d = Vector3d.createStartEnd(xyz0, xyz1);\r\n const inwardNormal: Vector3d = Vector3d.createCrossProduct(sweepDirection.x, sweepDirection.y, sweepDirection.z,\r\n edgeVector.x, edgeVector.y, edgeVector.z);\r\n const inwardNormalNormalized = inwardNormal.normalize();\r\n let distance;\r\n if (inwardNormalNormalized) { // Should never fail... simply a check due to the format of the normalize function return\r\n distance = inwardNormalNormalized.dotProduct(xyz0);\r\n const clipToAdd = ClipPlane.createNormalAndDistance(inwardNormalNormalized, distance, false, false);\r\n if (clipToAdd) { this._planes.push(clipToAdd); } // clipPlane creation could result in undefined\r\n }\r\n }\r\n if (sideSelect !== 0.0) {\r\n let planeNormalNormalized = planeNormal.normalize();\r\n if (planeNormalNormalized) { // Again.. should never fail\r\n const a = sweepDirection.dotProduct(planeNormalNormalized) * sideSelect;\r\n if (a < 0.0)\r\n planeNormalNormalized = planeNormalNormalized.negate();\r\n const xyz0: Point3d = points[0];\r\n const distance = planeNormalNormalized.dotProduct(xyz0);\r\n const clipToAdd = ClipPlane.createNormalAndDistance(planeNormalNormalized, distance, false, false);\r\n if (clipToAdd) { this._planes.push(clipToAdd); } // clipPlane creation could result in undefined\r\n }\r\n }\r\n return isCCW ? 1 : -1;\r\n }\r\n\r\n /**\r\n * Compute intersections among all combinations of 3 planes in the convex set.\r\n * * optionally throw out points that are not in the set.\r\n * * optionally push the points in the caller-supplied point array.\r\n * * optionally extend a caller supplied range.\r\n * * In the common case where the convex set is (a) a slab or (b) a view frustum, there will be 8 points and the range is the range of the convex set.\r\n * * If the convex set is unbounded, the range only contains the range of the accepted (corner) points, and the range is not a representative of the \"range of all points in the set\" .\r\n * @param transform (optional) transform to apply to the points.\r\n * @param points (optional) array to which computed points are to be added.\r\n * @param range (optional) range to be extended by the computed points\r\n * @param transform (optional) transform to apply to the accepted points.\r\n * @param testContainment if true, test each point to see if it is within the convex set. (Send false if confident that the convex set is rectilinear set such as a slab. Send true if chiseled corners are possible)\r\n * @returns number of points.\r\n */\r\n public computePlanePlanePlaneIntersections(points: Point3d[] | undefined, rangeToExtend: Range3d | undefined, transform?: Transform, testContainment: boolean = true): number {\r\n\r\n const normalRows = Matrix3d.createIdentity();\r\n const allPlanes = this._planes;\r\n const n = allPlanes.length;\r\n let numPoints = 0; // explicitly count points -- can't wait to end for points.length because it may be an optional output.\r\n for (let i = 0; i < n; i++) {\r\n for (let j = i + 1; j < n; j++)\r\n for (let k = j + 1; k < n; k++) {\r\n Matrix3d.createRowValues(\r\n allPlanes[i].inwardNormalRef.x, allPlanes[i].inwardNormalRef.y, allPlanes[i].inwardNormalRef.z,\r\n allPlanes[j].inwardNormalRef.x, allPlanes[j].inwardNormalRef.y, allPlanes[j].inwardNormalRef.z,\r\n allPlanes[k].inwardNormalRef.x, allPlanes[k].inwardNormalRef.y, allPlanes[k].inwardNormalRef.z,\r\n normalRows);\r\n if (normalRows.computeCachedInverse(false)) {\r\n const xyz = normalRows.multiplyInverseXYZAsPoint3d(allPlanes[i].distance, allPlanes[j].distance, allPlanes[k].distance)!;\r\n if (!testContainment || this.isPointOnOrInside(xyz, Geometry.smallMetricDistance)) {\r\n numPoints++;\r\n if (transform)\r\n transform.multiplyPoint3d(xyz, xyz);\r\n if (points)\r\n points.push(xyz);\r\n if (rangeToExtend)\r\n rangeToExtend.extendPoint(xyz);\r\n }\r\n }\r\n }\r\n }\r\n return numPoints;\r\n }\r\n /**\r\n * Set the `invisible` property on each plane of the convex set.\r\n * @param invisible value to store\r\n */\r\n public setInvisible(invisible: boolean) {\r\n for (const plane of this._planes) {\r\n plane.setInvisible(invisible);\r\n }\r\n }\r\n /**\r\n * Add planes for z-direction clip between low and high z levels.\r\n * @param invisible value to apply to the `invisible` bit for the new planes\r\n * @param zLow low z value. The plane clips out points with z below this.\r\n * @param zHigh high z value. The plane clips out points with z above this.\r\n */\r\n public addZClipPlanes(invisible: boolean, zLow?: number, zHigh?: number) {\r\n if (zLow !== undefined)\r\n this._planes.push(ClipPlane.createNormalAndDistance(Vector3d.create(0, 0, 1), zLow, invisible)!);\r\n if (zHigh !== undefined)\r\n this._planes.push(ClipPlane.createNormalAndDistance(Vector3d.create(0, 0, -1), -zHigh, invisible)!);\r\n }\r\n /** Implement appendPolygonClip, as defined in interface PolygonClipper. /**\r\n *\r\n * @param xyz input polygon. This is not changed.\r\n * @param insideFragments Array to receive \"inside\" fragments. Each fragment is a GrowableXYZArray grabbed from the cache. This is NOT cleared.\r\n * @param outsideFragments Array to receive \"outside\" fragments. Each fragment is a GrowableXYZArray grabbed from the cache. This is NOT cleared.\r\n * @param arrayCache cache for reusable GrowableXYZArray.\r\n */\r\n public appendPolygonClip(\r\n xyz: GrowableXYZArray,\r\n insideFragments: GrowableXYZArray[],\r\n outsideFragments: GrowableXYZArray[],\r\n arrayCache: GrowableXYZArrayCache): void {\r\n const newInside = this.clipInsidePushOutside(xyz, outsideFragments, arrayCache);\r\n if (newInside)\r\n insideFragments.push(newInside);\r\n }\r\n\r\n // FUNCTIONS SKIPPED DUE TO BSPLINES, VU, OR NON-USAGE IN NATIVE CODE----------------------------------------------------------------\r\n\r\n // Uses bsplines... skipping for now:\r\n // public convexAppendIntervalsFromBspline();\r\n\r\n // Uses pushing and clearing from/to a cache and added functionality for arrays. . . skipping for now\r\n // public convexPolygonClipInsideOutside(input: Point3d[], inside: Point3d[], outside: Point3d[], work1: Point3d[], work2: Point3d[],\r\n // clearOutside: boolean, distanceTolerance: number)\r\n}\r\n"]}
@@ -226,7 +226,7 @@ export declare class CurveChainWithDistanceIndex extends CurvePrimitive {
226
226
  * (via a handler) determines a CurveLocation detail among the children.
227
227
  * * The returned detail directly identifies fractional position along the CurveChainWithDistanceIndex, and has pointer to an additional detail for the child curve.
228
228
  * @param spacePoint point in space
229
- * @param extend true to extend the curve (NOT USED)
229
+ * @param extend true to extend the curve
230
230
  * @returns Returns a CurveLocationDetail structure that holds the details of the close point.
231
231
  */
232
232
  closestPoint(spacePoint: Point3d, extend: VariantCurveExtendParameter): CurveLocationDetail | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"CurveChainWithDistanceIndex.d.ts","sourceRoot":"","sources":["../../../src/curve/CurveChainWithDistanceIndex.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAC1F,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAE,OAAO,EAAY,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,K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+B,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAgB5G;;OAEG;IACa,WAAW,IAAI,MAAM;IAGrC;;;OAGG;IACI,WAAW,IAAI,MAAM;IAI5B;;;;OAIG;IACI,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO;IAYnE;;;;;;;OAOG;IACI,4BAA4B,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK;IAU5E;;;;;OAKG;IACa,6BAA6B,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK;IAQtF;;;;;OAKG;IACI,8BAA8B,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,yBAAyB,GAAG,yBAAyB,GAAG,SAAS;IAoBlI;;OAEG;IACI,mBAAmB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO;IAQzD,gGAAgG;IACzF,cAAc,IAAI,IAAI;IAW7B;;;;;OAKG;IACa,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IAQ5D;;;OAGG;IACa,8BAA8B,CAAC,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,mBAAmB,GAAG,mBAAmB;IAWzK;;;;;;;OAOG;IACa,YAAY,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,2BAA2B,GAAG,mBAAmB,GAAG,SAAS;CAgCxH"}
@@ -109,7 +109,7 @@ class DistanceIndexConstructionContext {
109
109
  }
110
110
  else {
111
111
  let f1;
112
- for (let i = 1, f0 = 0.0; i <= numStrokes; i++, f0 = f1) {
112
+ for (let i = 1, f0 = fraction0; i <= numStrokes; i++, f0 = f1) {
113
113
  f1 = Geometry.interpolate(fraction0, i / numStrokes, fraction1);
114
114
  d0 = this._accumulatedDistance;
115
115
  this._accumulatedDistance += (Math.abs(f1 - f0) * point0.distance(point1));
@@ -474,11 +474,10 @@ export class CurveChainWithDistanceIndex extends CurvePrimitive {
474
474
  * (via a handler) determines a CurveLocation detail among the children.
475
475
  * * The returned detail directly identifies fractional position along the CurveChainWithDistanceIndex, and has pointer to an additional detail for the child curve.
476
476
  * @param spacePoint point in space
477
- * @param extend true to extend the curve (NOT USED)
477
+ * @param extend true to extend the curve
478
478
  * @returns Returns a CurveLocationDetail structure that holds the details of the close point.
479
479
  */
480
480
  closestPoint(spacePoint, extend) {
481
- // umm... to "extend", would require selective extension of first, last
482
481
  let childDetail;
483
482
  let aMin = Number.MAX_VALUE;
484
483
  const numChildren = this.path.children.length;
@@ -1 +1 @@
1
- {"version":3,"file":"CurveChainWithDistanceIndex.js","sourceRoot":"","sources":["../../../src/curve/CurveChainWithDistanceIndex.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIvC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAIlE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAA+B,MAAM,mBAAmB,CAAC;AACrG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAK5D;;;;;;GAMG;AACH,MAAM,OAAO,YAAY;IAWvB,yEAAyE;IACzE,YAAmB,cAAsB,EAAE,cAAsB,EAAE,SAAiB,EAAE,SAAiB,EAAE,UAA0B;QACjI,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,cAAc,GAAG,SA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BAAmB,CAAC,wBAAwB,CAAC,IAAI,EAAE,aAAa,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;YACzG,WAAW,CAAC,WAAW,GAAG,WAAW,CAAC;YACtC,OAAO,WAAW,CAAC;SACpB;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { StrokeCountMap } from \"../curve/Query/StrokeCountMap\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GeometryHandler, IStrokeHandler } from \"../geometry3d/GeometryHandler\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport { Plane3dByOriginAndVectors } from \"../geometry3d/Plane3dByOriginAndVectors\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { CurveChain } from \"./CurveCollection\";\r\nimport { CurveExtendMode, CurveExtendOptions, VariantCurveExtendParameter } from \"./CurveExtendMode\";\r\nimport { CurveLocationDetail } from \"./CurveLocationDetail\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\nimport { LineString3d } from \"./LineString3d\";\r\nimport { StrokeOptions } from \"./StrokeOptions\";\r\n\r\n/**\r\n * * Annotation of an interval of a curve.\r\n * * The interval is marked with two pairs of numbers:\r\n * * * fraction0, fraction1 = fraction parameters along the child curve\r\n * * * distance0,distance1 = distances within containing CurveChainWithDistanceIndex\r\n * @public\r\n */\r\nexport class PathFragment {\r\n /** distance along parent to this fragment start */\r\n public chainDistance0: number;\r\n /** distance along parent to this fragment end */\r\n public chainDistance1: number;\r\n /** Fractional position of this fragment start within its curve primitive. */\r\n public childFraction0: number;\r\n /** Fractional position of this fragment end within its curve primitive.. */\r\n public childFraction1: number;\r\n /** Curve primitive of this fragment */\r\n public childCurve: CurvePrimitive;\r\n /** Create a fragment with complete fraction, distance and child data. */\r\n public constructor(childFraction0: number, childFraction1: number, distance0: number, distance1: number, childCurve: CurvePrimitive) {\r\n this.childFraction0 = childFraction0;\r\n this.childFraction1 = childFraction1;\r\n this.chainDistance0 = distance0;\r\n this.chainDistance1 = distance1;\r\n this.childCurve = childCurve;\r\n }\r\n /**\r\n * Return true if the distance is within the distance limits of this fragment.\r\n * @param distance\r\n */\r\n public containsChainDistance(distance: number): boolean {\r\n return distance >= this.chainDistance0 && distance <= this.chainDistance1;\r\n }\r\n\r\n /**\r\n * Return true if this fragment addresses `curve` and brackets `fraction`\r\n * @param distance\r\n */\r\n public containsChildCurveAndChildFraction(curve: CurvePrimitive, fraction: number): boolean {\r\n return this.childCurve === curve && fraction >= this.childFraction0 && fraction <= this.childFraction1;\r\n }\r\n\r\n /** Convert distance to local fraction, and apply that to interpolate between the stored curve fractions.\r\n * Note that proportional calculation does NOT account for nonuniform parameterization in the child curve.\r\n */\r\n public chainDistanceToInterpolatedChildFraction(distance: number): number {\r\n return Geometry.inverseInterpolate(\r\n this.childFraction0, this.chainDistance0,\r\n this.childFraction1, this.chainDistance1,\r\n distance, this.childFraction0)!; // the interval \"must\" have nonzero length, division should be safe . ..\r\n }\r\n /** Convert chainDistance to true chidFraction, using detailed moveSignedDistanceFromFraction\r\n */\r\n public chainDistanceToAccurateChildFraction(chainDistance: number): number {\r\n // The fragments are really expected to do good mappings in their distance range ...\r\n const childDetail = this.childCurve.moveSignedDistanceFromFraction(\r\n this.childFraction0, chainDistance - this.chainDistance0, false);\r\n return childDetail.fraction;\r\n }\r\n /** Return the scale factor to map childCurve fraction derivatives to chain fraction derivatives\r\n * @param globalDistance total length of the global curve.\r\n */\r\n public fractionScaleFactor(globalDistance: number): number {\r\n return globalDistance * (this.childFraction1 - this.childFraction0) / (this.chainDistance1 - this.chainDistance0);\r\n }\r\n /** Reverse the fraction and distance data.\r\n * * each child fraction `f` is replaced by `1-f`\r\n * * each `chainDistance` is replaced by `totalDistance-chainDistance`\r\n */\r\n public reverseFractionsAndDistances(totalDistance: number) {\r\n const f0 = this.childFraction0;\r\n const f1 = this.childFraction1;\r\n const d0 = this.chainDistance0;\r\n const d1 = this.chainDistance1;\r\n this.childFraction0 = 1.0 - f1;\r\n this.childFraction1 = 1.0 - f0;\r\n this.chainDistance0 = totalDistance - d1;\r\n this.chainDistance1 = totalDistance - d0;\r\n }\r\n /**\r\n * convert a fractional position on the childCurve to distance in the chain space.\r\n * * Return value is SIGNED -- will be negative when fraction < this.childFraction0.\r\n * @param fraction fraction along the curve within this fragment\r\n */\r\n public childFractionTChainDistance(fraction: number): number {\r\n let d = this.childCurve.curveLengthBetweenFractions(this.childFraction0, fraction);\r\n if (fraction < this.childFraction0)\r\n d = -d;\r\n return this.chainDistance0 + d;\r\n }\r\n}\r\n/** Non-instantiable class to build a distance index for a path. */\r\nclass DistanceIndexConstructionContext implements IStrokeHandler {\r\n private _fragments: PathFragment[];\r\n private _accumulatedDistance: number;\r\n private constructor() {\r\n this._accumulatedDistance = 0;\r\n this._fragments = [];\r\n }\r\n // ignore curve announcements -- they are repeated in stroke announcements\r\n public startParentCurvePrimitive(_cp: CurvePrimitive) { }\r\n public startCurvePrimitive(_cp: CurvePrimitive) { }\r\n public endParentCurvePrimitive(_cp: CurvePrimitive) { }\r\n public endCurvePrimitive(_cp: CurvePrimitive) { }\r\n // um .. we need to see curves? how to reject?\r\n public announcePointTangent(_xyz: Point3d, _fraction: number, _tangent: Vector3d) { }\r\n /** Announce numPoints interpolated between point0 and point1, with associated fractions */\r\n public announceSegmentInterval(\r\n cp: CurvePrimitive,\r\n point0: Point3d,\r\n point1: Point3d,\r\n numStrokes: number,\r\n fraction0: number,\r\n fraction1: number): void {\r\n let d0 = this._accumulatedDistance;\r\n if (numStrokes <= 1) {\r\n this._accumulatedDistance += point0.distance(point1);\r\n this._fragments.push(new PathFragment(fraction0, fraction1, d0, this._accumulatedDistance, cp));\r\n } else {\r\n let f1;\r\n for (let i = 1, f0 = 0.0; i <= numStrokes; i++, f0 = f1) {\r\n f1 = Geometry.interpolate(fraction0, i / numStrokes, fraction1);\r\n d0 = this._accumulatedDistance;\r\n this._accumulatedDistance += (Math.abs(f1 - f0) * point0.distance(point1));\r\n this._fragments.push(new PathFragment(f0, f1, d0, this._accumulatedDistance, cp));\r\n }\r\n }\r\n }\r\n public announceIntervalForUniformStepStrokes(\r\n cp: CurvePrimitive,\r\n numStrokes: number,\r\n fraction0: number,\r\n fraction1: number): void {\r\n let f1, d, d0;\r\n for (let i = 1, f0 = fraction0; i <= numStrokes; i++, f0 = f1) {\r\n f1 = Geometry.interpolate(fraction0, i / numStrokes, fraction1);\r\n d = cp.curveLengthBetweenFractions(f0, f1);\r\n d0 = this._accumulatedDistance;\r\n this._accumulatedDistance += d;\r\n this._fragments.push(new PathFragment(f0, f1, d0, this._accumulatedDistance, cp));\r\n }\r\n }\r\n public needPrimaryGeometryForStrokes?(): boolean { return true;}\r\n public static createPathFragmentIndex(path: CurveChain, options?: StrokeOptions): PathFragment[] {\r\n const handler = new DistanceIndexConstructionContext();\r\n for (const curve of path.children) {\r\n curve.emitStrokableParts(handler, options);\r\n }\r\n const fragments = handler._fragments;\r\n return fragments;\r\n }\r\n}\r\n/**\r\n * `CurveChainWithDistanceIndex` is a CurvePrimitive whose fractional parameterization is proportional to true\r\n * distance along a CurveChain.\r\n * * The curve chain can be any type derived from CurveChain.\r\n * * * i.e. either a `Path` or a `Loop`\r\n * @public\r\n */\r\nexport class CurveChainWithDistanceIndex extends CurvePrimitive {\r\n /** String name for schema properties */\r\n public readonly curvePrimitiveType = \"curveChainWithDistanceIndex\";\r\n\r\n private _path: CurveChain;\r\n private _fragments: PathFragment[];\r\n private _totalLength: number; // matches final fragment distance1.\r\n /** Test if other is a `CurveChainWithDistanceIndex` */\r\n public isSameGeometryClass(other: GeometryQuery): boolean { return other instanceof CurveChainWithDistanceIndex; }\r\n // final assembly of CurveChainWithDistanceIndex -- caller must create valid fragment index.\r\n private constructor(path: CurveChain, fragments: PathFragment[]) {\r\n super();\r\n this._path = path;\r\n this._fragments = fragments;\r\n this._totalLength = fragments[fragments.length - 1].chainDistance1;\r\n }\r\n /**\r\n * Create a clone, transformed and with its own distance index.\r\n * @param transform transform to apply in the clone.\r\n */\r\n public cloneTransformed(transform: Transform): CurvePrimitive | undefined {\r\n const c = this._path.clone();\r\n if (c !== undefined && c instanceof CurveChain && c.tryTransformInPlace(transform))\r\n return CurveChainWithDistanceIndex.createCapture(c);\r\n return undefined;\r\n }\r\n /** Reference to the contained path.\r\n * * Do not modify the path. The distance index will be wrong.\r\n */\r\n public get path(): CurveChain { return this._path; }\r\n\r\n /** Return a deep clone */\r\n public clone(): CurvePrimitive | undefined {\r\n const c = this._path.clone();\r\n if (c !== undefined && c instanceof CurveChain)\r\n return CurveChainWithDistanceIndex.createCapture(c);\r\n return undefined;\r\n }\r\n /** Ask if the curve is within tolerance of a plane.\r\n * @returns Returns true if the curve is completely within tolerance of the plane.\r\n */\r\n public isInPlane(plane: Plane3dByOriginAndUnitNormal): boolean {\r\n for (const c of this._path.children) {\r\n if (!c.isInPlane(plane))\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /** return the start point of the primitive. The default implementation returns fractionToPoint (0.0) */\r\n public override startPoint(result?: Point3d): Point3d {\r\n const c = this._path.cyclicCurvePrimitive(0);\r\n if (c)\r\n return c.startPoint(result);\r\n return Point3d.createZero(result);\r\n }\r\n /** Return the end point of the primitive. The default implementation returns fractionToPoint(1.0) */\r\n public override endPoint(result?: Point3d): Point3d {\r\n const c = this._path.cyclicCurvePrimitive(-1);\r\n if (c)\r\n return c.endPoint(result);\r\n return Point3d.createZero(result);\r\n }\r\n /** Add strokes to caller-supplied linestring */\r\n public emitStrokes(dest: LineString3d, options?: StrokeOptions): void {\r\n for (const c of this._path.children) {\r\n c.emitStrokes(dest, options);\r\n }\r\n }\r\n /** Ask the curve to announce points and simple subcurve fragments for stroking.\r\n * See IStrokeHandler for description of the sequence of the method calls.\r\n */\r\n public emitStrokableParts(dest: IStrokeHandler, options?: StrokeOptions): void {\r\n for (const c of this._path.children) {\r\n c.emitStrokableParts(dest, options);\r\n }\r\n }\r\n /**\r\n * return the stroke count required for given options.\r\n * @param options StrokeOptions that determine count\r\n */\r\n public computeStrokeCountForOptions(options?: StrokeOptions): number {\r\n let numStroke = 0;\r\n for (const c of this._path.children) {\r\n numStroke += c.computeStrokeCountForOptions(options);\r\n }\r\n return numStroke;\r\n }\r\n /**\r\n * Return an array containing only the curve primitives.\r\n * * This DEFAULT simply pushes `this` to the collectorArray.\r\n * * CurvePrimitiveWithDistanceIndex optionally collects its members.\r\n * @param collectorArray array to receive primitives (pushed -- the array is not cleared)\r\n * @param smallestPossiblePrimitives if false, CurvePrimitiveWithDistanceIndex returns only itself. If true, it recurses to its (otherwise hidden) children.\r\n */\r\n public override collectCurvePrimitivesGo(collectorArray: CurvePrimitive[], smallestPossiblePrimitives: boolean) {\r\n if (smallestPossiblePrimitives) {\r\n for (const c of this._path.children) {\r\n c.collectCurvePrimitivesGo(collectorArray, smallestPossiblePrimitives);\r\n }\r\n } else {\r\n collectorArray.push(this);\r\n }\r\n }\r\n\r\n /**\r\n * construct StrokeCountMap for each child, accumulating data to stroke count map for this primitive.\r\n * @param options StrokeOptions that determine count\r\n * @param parentStrokeMap evolving parent map.\r\n */\r\n public override computeAndAttachRecursiveStrokeCounts(options?: StrokeOptions, parentStrokeMap?: StrokeCountMap) {\r\n const myMap = StrokeCountMap.createWithCurvePrimitiveAndOptionalParent(this, parentStrokeMap);\r\n for (const c of this._path.children) {\r\n c.computeAndAttachRecursiveStrokeCounts(options, myMap);\r\n }\r\n CurvePrimitive.installStrokeCountMap(this, myMap, parentStrokeMap);\r\n }\r\n /** Second step of double dispatch: call `this._path.dispatchToGeometryHandler (handler)`\r\n * * Note that this exposes the children individually to the handler.\r\n */\r\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\r\n return this._path.dispatchToGeometryHandler(handler);\r\n }\r\n /** Extend (increase) `rangeToExtend` as needed to include these curves (optionally transformed)\r\n */\r\n public extendRange(rangeToExtend: Range3d, transform?: Transform): void {\r\n this._path.extendRange(rangeToExtend, transform);\r\n }\r\n /**\r\n *\r\n * * Curve length is always positive.\r\n * @returns Returns a (high accuracy) length of the curve between fractional positions\r\n * @returns Returns the length of the curve.\r\n */\r\n public override curveLengthBetweenFractions(fraction0: number, fraction1: number): number {\r\n return Math.abs(fraction1 - fraction0) * this._totalLength;\r\n }\r\n /**\r\n * Capture (not clone) a path into a new `CurveChainWithDistanceIndex`\r\n * @param primitives primitive array to be CAPTURED (not cloned)\r\n */\r\n public static createCapture(path: CurveChain, options?: StrokeOptions): CurveChainWithDistanceIndex | undefined {\r\n if (path.children.length === 0)\r\n return undefined;\r\n const fragments = DistanceIndexConstructionContext.createPathFragmentIndex(path, options);\r\n const result = new CurveChainWithDistanceIndex(path, fragments);\r\n return result;\r\n }\r\n\r\n /**\r\n * Resolve a fraction of the CurveChain to a PathFragment\r\n * @param distance\r\n * @param allowExtrapolation\r\n */\r\n protected chainDistanceToFragment(distance: number, allowExtrapolation: boolean = false): PathFragment | undefined {\r\n const numFragments = this._fragments.length;\r\n const fragments = this._fragments;\r\n if (numFragments > 0) {\r\n if (distance < 0.0)\r\n return allowExtrapolation ? fragments[0] : undefined;\r\n if (distance >= this._totalLength)\r\n return allowExtrapolation ? fragments[numFragments - 1] : undefined;\r\n // humbug, linear search\r\n for (const fragment of fragments) {\r\n if (fragment.containsChainDistance(distance)) return fragment;\r\n }\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Convert distance along the chain to fraction along the chain.\r\n * @param distance distance along the chain\r\n */\r\n public chainDistanceToChainFraction(distance: number): number { return distance / this._totalLength; }\r\n /**\r\n * Resolve a fraction within a specific curve to a fragment.\r\n * @param curve\r\n * @param fraction\r\n */\r\n protected curveAndChildFractionToFragment(curve: CurvePrimitive, fraction: number): PathFragment | undefined {\r\n const numFragments = this._fragments.length;\r\n const fragments = this._fragments;\r\n if (numFragments > 0) {\r\n // humbug, linear search\r\n for (const fragment of fragments) {\r\n if (fragment.containsChildCurveAndChildFraction(curve, fraction)) return fragment;\r\n }\r\n if (fraction <= 0)\r\n return fragments[0];\r\n if (fraction > 1.0)\r\n return fragments[numFragments - 1];\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Returns the total length of curves.\r\n */\r\n public override curveLength(): number {\r\n return this._totalLength;\r\n }\r\n /**\r\n * Returns the total length of the path.\r\n * * This is exact (and simple property lookup) because the true lengths were summed at construction time.\r\n */\r\n public quickLength(): number {\r\n return this._totalLength;\r\n }\r\n\r\n /**\r\n * Return the point (x,y,z) on the curve at fractional position along the chain.\r\n * @param fraction fractional position along the geometry.\r\n * @returns Returns a point on the curve.\r\n */\r\n public fractionToPoint(fraction: number, result?: Point3d): Point3d {\r\n const chainDistance = fraction * this._totalLength;\r\n const fragment = this.chainDistanceToFragment(chainDistance, true);\r\n if (fragment) {\r\n const childFraction = fragment.chainDistanceToAccurateChildFraction(chainDistance);\r\n return fragment.childCurve.fractionToPoint(childFraction, result);\r\n }\r\n // no fragment found. Use _fragments[0]\r\n // fragment = this.chainDistanceToFragment(chainDistance, true);\r\n return this._fragments[0].childCurve.fractionToPoint(0.0, result);\r\n }\r\n\r\n /** Return the point (x,y,z) and derivative on the curve at fractional position.\r\n *\r\n * * Note that this derivative is \"derivative of xyz with respect to fraction.\"\r\n * * this derivative shows the speed of the \"fractional point\" moving along the curve.\r\n * * this is not generally a unit vector. use fractionToPointAndUnitTangent for a unit vector.\r\n * @param fraction fractional position along the geometry.\r\n * @returns Returns a ray whose origin is the curve point and direction is the derivative with respect to the fraction.\r\n */\r\n public fractionToPointAndDerivative(fraction: number, result?: Ray3d): Ray3d {\r\n const distanceAlongPath = fraction * this._totalLength;\r\n const fragment = this.chainDistanceToFragment(distanceAlongPath, true)!;\r\n const curveFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath);\r\n result = fragment.childCurve.fractionToPointAndDerivative(curveFraction, result);\r\n const a = this._totalLength / result.direction.magnitude();\r\n result.direction.scaleInPlace(a);\r\n return result;\r\n }\r\n\r\n /**\r\n * Returns a ray whose origin is the curve point and direction is the unit tangent.\r\n * @param fraction fractional position on the curve\r\n * @param result optional receiver for the result.\r\n * Returns a ray whose origin is the curve point and direction is the unit tangent.\r\n */\r\n public override fractionToPointAndUnitTangent(fraction: number, result?: Ray3d): Ray3d {\r\n const distanceAlongPath = fraction * this._totalLength;\r\n const fragment = this.chainDistanceToFragment(distanceAlongPath, true)!;\r\n const curveFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath);\r\n result = fragment.childCurve.fractionToPointAndDerivative(curveFraction, result);\r\n result.direction.normalizeInPlace();\r\n return result;\r\n }\r\n /** Return a plane with\r\n *\r\n * * origin at fractional position along the curve\r\n * * vectorU is the first derivative, i.e. tangent vector with length equal to the rate of change with respect to the fraction.\r\n * * vectorV is the second derivative, i.e.derivative of vectorU.\r\n */\r\n public fractionToPointAnd2Derivatives(fraction: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors | undefined {\r\n const totalLength = this._totalLength;\r\n const distanceAlongPath = fraction * totalLength;\r\n const fragment = this.chainDistanceToFragment(distanceAlongPath, true)!;\r\n const curveFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath);\r\n result = fragment.childCurve.fractionToPointAnd2Derivatives(curveFraction, result);\r\n if (!result)\r\n return undefined;\r\n const dotUU = result.vectorU.magnitudeSquared();\r\n const magU = Math.sqrt(dotUU);\r\n const dotUV = result.vectorU.dotProduct(result.vectorV);\r\n const duds = 1.0 / magU;\r\n const a = duds * duds;\r\n Vector3d.createAdd2Scaled(result.vectorV, a, result.vectorU, -a * dotUV / dotUU, result.vectorV); // IN PLACE update to vectorV.\r\n result.vectorU.scale(duds);\r\n // scale for 0..1 parameterization ....\r\n result.vectorU.scaleInPlace(totalLength);\r\n result.vectorV.scaleInPlace(totalLength * totalLength);\r\n return result;\r\n }\r\n /** Attempt to transform in place.\r\n * * Warning: If any child fails, this object becomes invalid. But that should never happen.\r\n */\r\n public tryTransformInPlace(transform: Transform): boolean {\r\n let numFail = 0;\r\n for (const c of this._path.children) {\r\n if (!c.tryTransformInPlace(transform))\r\n numFail++;\r\n }\r\n return numFail === 0;\r\n }\r\n /** Reverse the curve's data so that its fractional stroking moves in the opposite direction. */\r\n public reverseInPlace(): void {\r\n this._path.reverseChildrenInPlace();\r\n const totalLength = this._totalLength;\r\n for (const fragment of this._fragments)\r\n fragment.reverseFractionsAndDistances(totalLength);\r\n for (let i = 0, j = this._fragments.length - 1; i < j; i++, j--) {\r\n const fragment = this._fragments[i];\r\n this._fragments[i] = this._fragments[j];\r\n this._fragments[j] = fragment;\r\n }\r\n }\r\n /**\r\n * Test for equality conditions:\r\n * * Mismatched totalLength is a quick exit condition\r\n * * If totalLength matches, recurse to the path for matching primitives.\r\n * @param other\r\n */\r\n public override isAlmostEqual(other: GeometryQuery): boolean {\r\n if (other instanceof CurveChainWithDistanceIndex) {\r\n return Geometry.isSameCoordinate(this._totalLength, other._totalLength)\r\n && this._path.isAlmostEqual(other._path);\r\n }\r\n return false;\r\n }\r\n\r\n /** Implement moveSignedDistanceFromFraction.\r\n * * See `CurvePrimitive` for parameter details.\r\n * * The returned location directly identifies fractional position along the CurveChainWithDistanceIndex, and has pointer to an additional detail for the child curve.\r\n */\r\n public override moveSignedDistanceFromFraction(startFraction: number, signedDistance: number, allowExtension: boolean, result?: CurveLocationDetail): CurveLocationDetail {\r\n const distanceA = startFraction * this._totalLength;\r\n const distanceB = distanceA + signedDistance;\r\n const fragmentB = this.chainDistanceToFragment(distanceB, true)!;\r\n const childDetail = fragmentB.childCurve.moveSignedDistanceFromFraction(fragmentB.childFraction0, distanceB - fragmentB.chainDistance0, allowExtension, result);\r\n const endFraction = startFraction + (signedDistance / this._totalLength);\r\n const chainDetail = CurveLocationDetail.createConditionalMoveSignedDistance(allowExtension, this, startFraction, endFraction, signedDistance, result);\r\n chainDetail.childDetail = childDetail;\r\n return chainDetail;\r\n }\r\n\r\n /** Search for the curve point that is closest to the spacePoint.\r\n * * The CurveChainWithDistanceIndex invokes the base class CurvePrimitive method, which\r\n * (via a handler) determines a CurveLocation detail among the children.\r\n * * The returned detail directly identifies fractional position along the CurveChainWithDistanceIndex, and has pointer to an additional detail for the child curve.\r\n * @param spacePoint point in space\r\n * @param extend true to extend the curve (NOT USED)\r\n * @returns Returns a CurveLocationDetail structure that holds the details of the close point.\r\n */\r\n public override closestPoint(spacePoint: Point3d, extend: VariantCurveExtendParameter): CurveLocationDetail | undefined {\r\n // umm... to \"extend\", would require selective extension of first, last\r\n let childDetail: CurveLocationDetail | undefined;\r\n let aMin = Number.MAX_VALUE;\r\n const numChildren = this.path.children.length;\r\n if (numChildren === 1) {\r\n childDetail = this.path.children[0].closestPoint(spacePoint, extend);\r\n } else {\r\n const extend0 = [CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 0), CurveExtendMode.None];\r\n const extend1 = [CurveExtendMode.None, CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 1)];\r\n for (let childIndex = 0; childIndex < numChildren; childIndex++) {\r\n const child = this.path.children[childIndex];\r\n const detailA = child.closestPoint(spacePoint, childIndex === 0 ? extend0 : childIndex + 1 === numChildren ? extend1 : false);\r\n if (detailA && detailA.a < aMin) {\r\n aMin = detailA.a;\r\n childDetail = CurveLocationDetail.createCurveFractionPoint(detailA.curve, detailA.fraction, detailA.point, childDetail)!;\r\n childDetail.a = detailA.a;\r\n }\r\n }\r\n\r\n }\r\n if (!childDetail)\r\n return undefined;\r\n const fragment = this.curveAndChildFractionToFragment(childDetail.curve!, childDetail.fraction);\r\n if (fragment) {\r\n const chainDistance = fragment.childFractionTChainDistance(childDetail.fraction);\r\n const chainFraction = this.chainDistanceToChainFraction(chainDistance);\r\n const chainDetail = CurveLocationDetail.createCurveFractionPoint(this, chainFraction, childDetail.point);\r\n chainDetail.childDetail = childDetail;\r\n return chainDetail;\r\n }\r\n return undefined;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"CurveChainWithDistanceIndex.js","sourceRoot":"","sources":["../../../src/curve/CurveChainWithDistanceIndex.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIvC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAIlE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAA+B,MAAM,mBAAmB,CAAC;AACrG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAK5D;;;;;;GAMG;AACH,MAAM,OAAO,YAAY;IAWvB,yEAAyE;IACzE,YAAmB,cAAsB,EAAE,cAAsB,EAAE,SAAiB,EAAE,SAAiB,EAAE,UAA0B;QACjI,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;QAChC,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IACD;;;OAGG;IACI,qBAAqB,CAAC,QAAgB;QAC3C,OAAO,QAAQ,IAAI,IAAI,CAAC,cAAc,IAAI,QAAQ,IAAI,IAAI,CAAC,cAAc,CAAC;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,EAAE,EAAE;gBAC/D,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;gBAC7C,MAAM,OAAO,GAAG,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBAC9H,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,GAAG,IAAI,EAAE;oBAC/B,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;oBACjB,WAAW,GAAG,mBAAmB,CAAC,wBAAwB,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,KAAK,EAAE,WAAW,CAAE,CAAC;oBACzH,WAAW,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;iBAC3B;aACF;SAEF;QACD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QACnB,MAAM,QAAQ,GAAG,IAAI,CAAC,+BAA+B,CAAC,WAAW,CAAC,KAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;QAChG,IAAI,QAAQ,EAAE;YACZ,MAAM,aAAa,GAAG,QAAQ,CAAC,2BAA2B,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YACjF,MAAM,aAAa,GAAG,IAAI,CAAC,4BAA4B,CAAC,aAAa,CAAC,CAAC;YACvE,MAAM,WAAW,GAAG,mBAAmB,CAAC,wBAAwB,CAAC,IAAI,EAAE,aAAa,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;YACzG,WAAW,CAAC,WAAW,GAAG,WAAW,CAAC;YACtC,OAAO,WAAW,CAAC;SACpB;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { StrokeCountMap } from \"../curve/Query/StrokeCountMap\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GeometryHandler, IStrokeHandler } from \"../geometry3d/GeometryHandler\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport { Plane3dByOriginAndVectors } from \"../geometry3d/Plane3dByOriginAndVectors\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { CurveChain } from \"./CurveCollection\";\r\nimport { CurveExtendMode, CurveExtendOptions, VariantCurveExtendParameter } from \"./CurveExtendMode\";\r\nimport { CurveLocationDetail } from \"./CurveLocationDetail\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\nimport { LineString3d } from \"./LineString3d\";\r\nimport { StrokeOptions } from \"./StrokeOptions\";\r\n\r\n/**\r\n * * Annotation of an interval of a curve.\r\n * * The interval is marked with two pairs of numbers:\r\n * * * fraction0, fraction1 = fraction parameters along the child curve\r\n * * * distance0,distance1 = distances within containing CurveChainWithDistanceIndex\r\n * @public\r\n */\r\nexport class PathFragment {\r\n /** distance along parent to this fragment start */\r\n public chainDistance0: number;\r\n /** distance along parent to this fragment end */\r\n public chainDistance1: number;\r\n /** Fractional position of this fragment start within its curve primitive. */\r\n public childFraction0: number;\r\n /** Fractional position of this fragment end within its curve primitive.. */\r\n public childFraction1: number;\r\n /** Curve primitive of this fragment */\r\n public childCurve: CurvePrimitive;\r\n /** Create a fragment with complete fraction, distance and child data. */\r\n public constructor(childFraction0: number, childFraction1: number, distance0: number, distance1: number, childCurve: CurvePrimitive) {\r\n this.childFraction0 = childFraction0;\r\n this.childFraction1 = childFraction1;\r\n this.chainDistance0 = distance0;\r\n this.chainDistance1 = distance1;\r\n this.childCurve = childCurve;\r\n }\r\n /**\r\n * Return true if the distance is within the distance limits of this fragment.\r\n * @param distance\r\n */\r\n public containsChainDistance(distance: number): boolean {\r\n return distance >= this.chainDistance0 && distance <= this.chainDistance1;\r\n }\r\n\r\n /**\r\n * Return true if this fragment addresses `curve` and brackets `fraction`\r\n * @param distance\r\n */\r\n public containsChildCurveAndChildFraction(curve: CurvePrimitive, fraction: number): boolean {\r\n return this.childCurve === curve && fraction >= this.childFraction0 && fraction <= this.childFraction1;\r\n }\r\n\r\n /** Convert distance to local fraction, and apply that to interpolate between the stored curve fractions.\r\n * Note that proportional calculation does NOT account for nonuniform parameterization in the child curve.\r\n */\r\n public chainDistanceToInterpolatedChildFraction(distance: number): number {\r\n return Geometry.inverseInterpolate(\r\n this.childFraction0, this.chainDistance0,\r\n this.childFraction1, this.chainDistance1,\r\n distance, this.childFraction0)!; // the interval \"must\" have nonzero length, division should be safe . ..\r\n }\r\n /** Convert chainDistance to true chidFraction, using detailed moveSignedDistanceFromFraction\r\n */\r\n public chainDistanceToAccurateChildFraction(chainDistance: number): number {\r\n // The fragments are really expected to do good mappings in their distance range ...\r\n const childDetail = this.childCurve.moveSignedDistanceFromFraction(\r\n this.childFraction0, chainDistance - this.chainDistance0, false);\r\n return childDetail.fraction;\r\n }\r\n /** Return the scale factor to map childCurve fraction derivatives to chain fraction derivatives\r\n * @param globalDistance total length of the global curve.\r\n */\r\n public fractionScaleFactor(globalDistance: number): number {\r\n return globalDistance * (this.childFraction1 - this.childFraction0) / (this.chainDistance1 - this.chainDistance0);\r\n }\r\n /** Reverse the fraction and distance data.\r\n * * each child fraction `f` is replaced by `1-f`\r\n * * each `chainDistance` is replaced by `totalDistance-chainDistance`\r\n */\r\n public reverseFractionsAndDistances(totalDistance: number) {\r\n const f0 = this.childFraction0;\r\n const f1 = this.childFraction1;\r\n const d0 = this.chainDistance0;\r\n const d1 = this.chainDistance1;\r\n this.childFraction0 = 1.0 - f1;\r\n this.childFraction1 = 1.0 - f0;\r\n this.chainDistance0 = totalDistance - d1;\r\n this.chainDistance1 = totalDistance - d0;\r\n }\r\n /**\r\n * convert a fractional position on the childCurve to distance in the chain space.\r\n * * Return value is SIGNED -- will be negative when fraction < this.childFraction0.\r\n * @param fraction fraction along the curve within this fragment\r\n */\r\n public childFractionTChainDistance(fraction: number): number {\r\n let d = this.childCurve.curveLengthBetweenFractions(this.childFraction0, fraction);\r\n if (fraction < this.childFraction0)\r\n d = -d;\r\n return this.chainDistance0 + d;\r\n }\r\n}\r\n/** Non-instantiable class to build a distance index for a path. */\r\nclass DistanceIndexConstructionContext implements IStrokeHandler {\r\n private _fragments: PathFragment[];\r\n private _accumulatedDistance: number;\r\n private constructor() {\r\n this._accumulatedDistance = 0;\r\n this._fragments = [];\r\n }\r\n // ignore curve announcements -- they are repeated in stroke announcements\r\n public startParentCurvePrimitive(_cp: CurvePrimitive) { }\r\n public startCurvePrimitive(_cp: CurvePrimitive) { }\r\n public endParentCurvePrimitive(_cp: CurvePrimitive) { }\r\n public endCurvePrimitive(_cp: CurvePrimitive) { }\r\n // um .. we need to see curves? how to reject?\r\n public announcePointTangent(_xyz: Point3d, _fraction: number, _tangent: Vector3d) { }\r\n /** Announce numPoints interpolated between point0 and point1, with associated fractions */\r\n public announceSegmentInterval(\r\n cp: CurvePrimitive,\r\n point0: Point3d,\r\n point1: Point3d,\r\n numStrokes: number,\r\n fraction0: number,\r\n fraction1: number): void {\r\n let d0 = this._accumulatedDistance;\r\n if (numStrokes <= 1) {\r\n this._accumulatedDistance += point0.distance(point1);\r\n this._fragments.push(new PathFragment(fraction0, fraction1, d0, this._accumulatedDistance, cp));\r\n } else {\r\n let f1;\r\n for (let i = 1, f0 = fraction0; i <= numStrokes; i++, f0 = f1) {\r\n f1 = Geometry.interpolate(fraction0, i / numStrokes, fraction1);\r\n d0 = this._accumulatedDistance;\r\n this._accumulatedDistance += (Math.abs(f1 - f0) * point0.distance(point1));\r\n this._fragments.push(new PathFragment(f0, f1, d0, this._accumulatedDistance, cp));\r\n }\r\n }\r\n }\r\n public announceIntervalForUniformStepStrokes(\r\n cp: CurvePrimitive,\r\n numStrokes: number,\r\n fraction0: number,\r\n fraction1: number): void {\r\n let f1, d, d0;\r\n for (let i = 1, f0 = fraction0; i <= numStrokes; i++, f0 = f1) {\r\n f1 = Geometry.interpolate(fraction0, i / numStrokes, fraction1);\r\n d = cp.curveLengthBetweenFractions(f0, f1);\r\n d0 = this._accumulatedDistance;\r\n this._accumulatedDistance += d;\r\n this._fragments.push(new PathFragment(f0, f1, d0, this._accumulatedDistance, cp));\r\n }\r\n }\r\n public needPrimaryGeometryForStrokes?(): boolean { return true;}\r\n public static createPathFragmentIndex(path: CurveChain, options?: StrokeOptions): PathFragment[] {\r\n const handler = new DistanceIndexConstructionContext();\r\n for (const curve of path.children) {\r\n curve.emitStrokableParts(handler, options);\r\n }\r\n const fragments = handler._fragments;\r\n return fragments;\r\n }\r\n}\r\n/**\r\n * `CurveChainWithDistanceIndex` is a CurvePrimitive whose fractional parameterization is proportional to true\r\n * distance along a CurveChain.\r\n * * The curve chain can be any type derived from CurveChain.\r\n * * * i.e. either a `Path` or a `Loop`\r\n * @public\r\n */\r\nexport class CurveChainWithDistanceIndex extends CurvePrimitive {\r\n /** String name for schema properties */\r\n public readonly curvePrimitiveType = \"curveChainWithDistanceIndex\";\r\n\r\n private _path: CurveChain;\r\n private _fragments: PathFragment[];\r\n private _totalLength: number; // matches final fragment distance1.\r\n /** Test if other is a `CurveChainWithDistanceIndex` */\r\n public isSameGeometryClass(other: GeometryQuery): boolean { return other instanceof CurveChainWithDistanceIndex; }\r\n // final assembly of CurveChainWithDistanceIndex -- caller must create valid fragment index.\r\n private constructor(path: CurveChain, fragments: PathFragment[]) {\r\n super();\r\n this._path = path;\r\n this._fragments = fragments;\r\n this._totalLength = fragments[fragments.length - 1].chainDistance1;\r\n }\r\n /**\r\n * Create a clone, transformed and with its own distance index.\r\n * @param transform transform to apply in the clone.\r\n */\r\n public cloneTransformed(transform: Transform): CurvePrimitive | undefined {\r\n const c = this._path.clone();\r\n if (c !== undefined && c instanceof CurveChain && c.tryTransformInPlace(transform))\r\n return CurveChainWithDistanceIndex.createCapture(c);\r\n return undefined;\r\n }\r\n /** Reference to the contained path.\r\n * * Do not modify the path. The distance index will be wrong.\r\n */\r\n public get path(): CurveChain { return this._path; }\r\n\r\n /** Return a deep clone */\r\n public clone(): CurvePrimitive | undefined {\r\n const c = this._path.clone();\r\n if (c !== undefined && c instanceof CurveChain)\r\n return CurveChainWithDistanceIndex.createCapture(c);\r\n return undefined;\r\n }\r\n /** Ask if the curve is within tolerance of a plane.\r\n * @returns Returns true if the curve is completely within tolerance of the plane.\r\n */\r\n public isInPlane(plane: Plane3dByOriginAndUnitNormal): boolean {\r\n for (const c of this._path.children) {\r\n if (!c.isInPlane(plane))\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /** return the start point of the primitive. The default implementation returns fractionToPoint (0.0) */\r\n public override startPoint(result?: Point3d): Point3d {\r\n const c = this._path.cyclicCurvePrimitive(0);\r\n if (c)\r\n return c.startPoint(result);\r\n return Point3d.createZero(result);\r\n }\r\n /** Return the end point of the primitive. The default implementation returns fractionToPoint(1.0) */\r\n public override endPoint(result?: Point3d): Point3d {\r\n const c = this._path.cyclicCurvePrimitive(-1);\r\n if (c)\r\n return c.endPoint(result);\r\n return Point3d.createZero(result);\r\n }\r\n /** Add strokes to caller-supplied linestring */\r\n public emitStrokes(dest: LineString3d, options?: StrokeOptions): void {\r\n for (const c of this._path.children) {\r\n c.emitStrokes(dest, options);\r\n }\r\n }\r\n /** Ask the curve to announce points and simple subcurve fragments for stroking.\r\n * See IStrokeHandler for description of the sequence of the method calls.\r\n */\r\n public emitStrokableParts(dest: IStrokeHandler, options?: StrokeOptions): void {\r\n for (const c of this._path.children) {\r\n c.emitStrokableParts(dest, options);\r\n }\r\n }\r\n /**\r\n * return the stroke count required for given options.\r\n * @param options StrokeOptions that determine count\r\n */\r\n public computeStrokeCountForOptions(options?: StrokeOptions): number {\r\n let numStroke = 0;\r\n for (const c of this._path.children) {\r\n numStroke += c.computeStrokeCountForOptions(options);\r\n }\r\n return numStroke;\r\n }\r\n /**\r\n * Return an array containing only the curve primitives.\r\n * * This DEFAULT simply pushes `this` to the collectorArray.\r\n * * CurvePrimitiveWithDistanceIndex optionally collects its members.\r\n * @param collectorArray array to receive primitives (pushed -- the array is not cleared)\r\n * @param smallestPossiblePrimitives if false, CurvePrimitiveWithDistanceIndex returns only itself. If true, it recurses to its (otherwise hidden) children.\r\n */\r\n public override collectCurvePrimitivesGo(collectorArray: CurvePrimitive[], smallestPossiblePrimitives: boolean) {\r\n if (smallestPossiblePrimitives) {\r\n for (const c of this._path.children) {\r\n c.collectCurvePrimitivesGo(collectorArray, smallestPossiblePrimitives);\r\n }\r\n } else {\r\n collectorArray.push(this);\r\n }\r\n }\r\n\r\n /**\r\n * construct StrokeCountMap for each child, accumulating data to stroke count map for this primitive.\r\n * @param options StrokeOptions that determine count\r\n * @param parentStrokeMap evolving parent map.\r\n */\r\n public override computeAndAttachRecursiveStrokeCounts(options?: StrokeOptions, parentStrokeMap?: StrokeCountMap) {\r\n const myMap = StrokeCountMap.createWithCurvePrimitiveAndOptionalParent(this, parentStrokeMap);\r\n for (const c of this._path.children) {\r\n c.computeAndAttachRecursiveStrokeCounts(options, myMap);\r\n }\r\n CurvePrimitive.installStrokeCountMap(this, myMap, parentStrokeMap);\r\n }\r\n /** Second step of double dispatch: call `this._path.dispatchToGeometryHandler (handler)`\r\n * * Note that this exposes the children individually to the handler.\r\n */\r\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\r\n return this._path.dispatchToGeometryHandler(handler);\r\n }\r\n /** Extend (increase) `rangeToExtend` as needed to include these curves (optionally transformed)\r\n */\r\n public extendRange(rangeToExtend: Range3d, transform?: Transform): void {\r\n this._path.extendRange(rangeToExtend, transform);\r\n }\r\n /**\r\n *\r\n * * Curve length is always positive.\r\n * @returns Returns a (high accuracy) length of the curve between fractional positions\r\n * @returns Returns the length of the curve.\r\n */\r\n public override curveLengthBetweenFractions(fraction0: number, fraction1: number): number {\r\n return Math.abs(fraction1 - fraction0) * this._totalLength;\r\n }\r\n /**\r\n * Capture (not clone) a path into a new `CurveChainWithDistanceIndex`\r\n * @param primitives primitive array to be CAPTURED (not cloned)\r\n */\r\n public static createCapture(path: CurveChain, options?: StrokeOptions): CurveChainWithDistanceIndex | undefined {\r\n if (path.children.length === 0)\r\n return undefined;\r\n const fragments = DistanceIndexConstructionContext.createPathFragmentIndex(path, options);\r\n const result = new CurveChainWithDistanceIndex(path, fragments);\r\n return result;\r\n }\r\n\r\n /**\r\n * Resolve a fraction of the CurveChain to a PathFragment\r\n * @param distance\r\n * @param allowExtrapolation\r\n */\r\n protected chainDistanceToFragment(distance: number, allowExtrapolation: boolean = false): PathFragment | undefined {\r\n const numFragments = this._fragments.length;\r\n const fragments = this._fragments;\r\n if (numFragments > 0) {\r\n if (distance < 0.0)\r\n return allowExtrapolation ? fragments[0] : undefined;\r\n if (distance >= this._totalLength)\r\n return allowExtrapolation ? fragments[numFragments - 1] : undefined;\r\n // humbug, linear search\r\n for (const fragment of fragments) {\r\n if (fragment.containsChainDistance(distance)) return fragment;\r\n }\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Convert distance along the chain to fraction along the chain.\r\n * @param distance distance along the chain\r\n */\r\n public chainDistanceToChainFraction(distance: number): number { return distance / this._totalLength; }\r\n /**\r\n * Resolve a fraction within a specific curve to a fragment.\r\n * @param curve\r\n * @param fraction\r\n */\r\n protected curveAndChildFractionToFragment(curve: CurvePrimitive, fraction: number): PathFragment | undefined {\r\n const numFragments = this._fragments.length;\r\n const fragments = this._fragments;\r\n if (numFragments > 0) {\r\n // humbug, linear search\r\n for (const fragment of fragments) {\r\n if (fragment.containsChildCurveAndChildFraction(curve, fraction)) return fragment;\r\n }\r\n if (fraction <= 0)\r\n return fragments[0];\r\n if (fraction > 1.0)\r\n return fragments[numFragments - 1];\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Returns the total length of curves.\r\n */\r\n public override curveLength(): number {\r\n return this._totalLength;\r\n }\r\n /**\r\n * Returns the total length of the path.\r\n * * This is exact (and simple property lookup) because the true lengths were summed at construction time.\r\n */\r\n public quickLength(): number {\r\n return this._totalLength;\r\n }\r\n\r\n /**\r\n * Return the point (x,y,z) on the curve at fractional position along the chain.\r\n * @param fraction fractional position along the geometry.\r\n * @returns Returns a point on the curve.\r\n */\r\n public fractionToPoint(fraction: number, result?: Point3d): Point3d {\r\n const chainDistance = fraction * this._totalLength;\r\n const fragment = this.chainDistanceToFragment(chainDistance, true);\r\n if (fragment) {\r\n const childFraction = fragment.chainDistanceToAccurateChildFraction(chainDistance);\r\n return fragment.childCurve.fractionToPoint(childFraction, result);\r\n }\r\n // no fragment found. Use _fragments[0]\r\n // fragment = this.chainDistanceToFragment(chainDistance, true);\r\n return this._fragments[0].childCurve.fractionToPoint(0.0, result);\r\n }\r\n\r\n /** Return the point (x,y,z) and derivative on the curve at fractional position.\r\n *\r\n * * Note that this derivative is \"derivative of xyz with respect to fraction.\"\r\n * * this derivative shows the speed of the \"fractional point\" moving along the curve.\r\n * * this is not generally a unit vector. use fractionToPointAndUnitTangent for a unit vector.\r\n * @param fraction fractional position along the geometry.\r\n * @returns Returns a ray whose origin is the curve point and direction is the derivative with respect to the fraction.\r\n */\r\n public fractionToPointAndDerivative(fraction: number, result?: Ray3d): Ray3d {\r\n const distanceAlongPath = fraction * this._totalLength;\r\n const fragment = this.chainDistanceToFragment(distanceAlongPath, true)!;\r\n const curveFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath);\r\n result = fragment.childCurve.fractionToPointAndDerivative(curveFraction, result);\r\n const a = this._totalLength / result.direction.magnitude();\r\n result.direction.scaleInPlace(a);\r\n return result;\r\n }\r\n\r\n /**\r\n * Returns a ray whose origin is the curve point and direction is the unit tangent.\r\n * @param fraction fractional position on the curve\r\n * @param result optional receiver for the result.\r\n * Returns a ray whose origin is the curve point and direction is the unit tangent.\r\n */\r\n public override fractionToPointAndUnitTangent(fraction: number, result?: Ray3d): Ray3d {\r\n const distanceAlongPath = fraction * this._totalLength;\r\n const fragment = this.chainDistanceToFragment(distanceAlongPath, true)!;\r\n const curveFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath);\r\n result = fragment.childCurve.fractionToPointAndDerivative(curveFraction, result);\r\n result.direction.normalizeInPlace();\r\n return result;\r\n }\r\n /** Return a plane with\r\n *\r\n * * origin at fractional position along the curve\r\n * * vectorU is the first derivative, i.e. tangent vector with length equal to the rate of change with respect to the fraction.\r\n * * vectorV is the second derivative, i.e.derivative of vectorU.\r\n */\r\n public fractionToPointAnd2Derivatives(fraction: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors | undefined {\r\n const totalLength = this._totalLength;\r\n const distanceAlongPath = fraction * totalLength;\r\n const fragment = this.chainDistanceToFragment(distanceAlongPath, true)!;\r\n const curveFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath);\r\n result = fragment.childCurve.fractionToPointAnd2Derivatives(curveFraction, result);\r\n if (!result)\r\n return undefined;\r\n const dotUU = result.vectorU.magnitudeSquared();\r\n const magU = Math.sqrt(dotUU);\r\n const dotUV = result.vectorU.dotProduct(result.vectorV);\r\n const duds = 1.0 / magU;\r\n const a = duds * duds;\r\n Vector3d.createAdd2Scaled(result.vectorV, a, result.vectorU, -a * dotUV / dotUU, result.vectorV); // IN PLACE update to vectorV.\r\n result.vectorU.scale(duds);\r\n // scale for 0..1 parameterization ....\r\n result.vectorU.scaleInPlace(totalLength);\r\n result.vectorV.scaleInPlace(totalLength * totalLength);\r\n return result;\r\n }\r\n /** Attempt to transform in place.\r\n * * Warning: If any child fails, this object becomes invalid. But that should never happen.\r\n */\r\n public tryTransformInPlace(transform: Transform): boolean {\r\n let numFail = 0;\r\n for (const c of this._path.children) {\r\n if (!c.tryTransformInPlace(transform))\r\n numFail++;\r\n }\r\n return numFail === 0;\r\n }\r\n /** Reverse the curve's data so that its fractional stroking moves in the opposite direction. */\r\n public reverseInPlace(): void {\r\n this._path.reverseChildrenInPlace();\r\n const totalLength = this._totalLength;\r\n for (const fragment of this._fragments)\r\n fragment.reverseFractionsAndDistances(totalLength);\r\n for (let i = 0, j = this._fragments.length - 1; i < j; i++, j--) {\r\n const fragment = this._fragments[i];\r\n this._fragments[i] = this._fragments[j];\r\n this._fragments[j] = fragment;\r\n }\r\n }\r\n /**\r\n * Test for equality conditions:\r\n * * Mismatched totalLength is a quick exit condition\r\n * * If totalLength matches, recurse to the path for matching primitives.\r\n * @param other\r\n */\r\n public override isAlmostEqual(other: GeometryQuery): boolean {\r\n if (other instanceof CurveChainWithDistanceIndex) {\r\n return Geometry.isSameCoordinate(this._totalLength, other._totalLength)\r\n && this._path.isAlmostEqual(other._path);\r\n }\r\n return false;\r\n }\r\n\r\n /** Implement moveSignedDistanceFromFraction.\r\n * * See `CurvePrimitive` for parameter details.\r\n * * The returned location directly identifies fractional position along the CurveChainWithDistanceIndex, and has pointer to an additional detail for the child curve.\r\n */\r\n public override moveSignedDistanceFromFraction(startFraction: number, signedDistance: number, allowExtension: boolean, result?: CurveLocationDetail): CurveLocationDetail {\r\n const distanceA = startFraction * this._totalLength;\r\n const distanceB = distanceA + signedDistance;\r\n const fragmentB = this.chainDistanceToFragment(distanceB, true)!;\r\n const childDetail = fragmentB.childCurve.moveSignedDistanceFromFraction(fragmentB.childFraction0, distanceB - fragmentB.chainDistance0, allowExtension, result);\r\n const endFraction = startFraction + (signedDistance / this._totalLength);\r\n const chainDetail = CurveLocationDetail.createConditionalMoveSignedDistance(allowExtension, this, startFraction, endFraction, signedDistance, result);\r\n chainDetail.childDetail = childDetail;\r\n return chainDetail;\r\n }\r\n\r\n /** Search for the curve point that is closest to the spacePoint.\r\n * * The CurveChainWithDistanceIndex invokes the base class CurvePrimitive method, which\r\n * (via a handler) determines a CurveLocation detail among the children.\r\n * * The returned detail directly identifies fractional position along the CurveChainWithDistanceIndex, and has pointer to an additional detail for the child curve.\r\n * @param spacePoint point in space\r\n * @param extend true to extend the curve\r\n * @returns Returns a CurveLocationDetail structure that holds the details of the close point.\r\n */\r\n public override closestPoint(spacePoint: Point3d, extend: VariantCurveExtendParameter): CurveLocationDetail | undefined {\r\n let childDetail: CurveLocationDetail | undefined;\r\n let aMin = Number.MAX_VALUE;\r\n const numChildren = this.path.children.length;\r\n if (numChildren === 1) {\r\n childDetail = this.path.children[0].closestPoint(spacePoint, extend);\r\n } else {\r\n const extend0 = [CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 0), CurveExtendMode.None];\r\n const extend1 = [CurveExtendMode.None, CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 1)];\r\n for (let childIndex = 0; childIndex < numChildren; childIndex++) {\r\n const child = this.path.children[childIndex];\r\n const detailA = child.closestPoint(spacePoint, childIndex === 0 ? extend0 : childIndex + 1 === numChildren ? extend1 : false);\r\n if (detailA && detailA.a < aMin) {\r\n aMin = detailA.a;\r\n childDetail = CurveLocationDetail.createCurveFractionPoint(detailA.curve, detailA.fraction, detailA.point, childDetail)!;\r\n childDetail.a = detailA.a;\r\n }\r\n }\r\n\r\n }\r\n if (!childDetail)\r\n return undefined;\r\n const fragment = this.curveAndChildFractionToFragment(childDetail.curve!, childDetail.fraction);\r\n if (fragment) {\r\n const chainDistance = fragment.childFractionTChainDistance(childDetail.fraction);\r\n const chainFraction = this.chainDistanceToChainFraction(chainDistance);\r\n const chainDetail = CurveLocationDetail.createCurveFractionPoint(this, chainFraction, childDetail.point);\r\n chainDetail.childDetail = childDetail;\r\n return chainDetail;\r\n }\r\n return undefined;\r\n }\r\n}\r\n"]}
@@ -1,3 +1,7 @@
1
+ /** @packageDocumentation
2
+ * @module Curve
3
+ */
4
+ import { PlaneAltitudeEvaluator } from "../Geometry";
1
5
  import { AngleSweep } from "../geometry3d/AngleSweep";
2
6
  import { Ellipsoid, GeodesicPathPoint } from "../geometry3d/Ellipsoid";
3
7
  import { IndexedXYZCollection } from "../geometry3d/IndexedXYZCollection";
@@ -11,6 +15,7 @@ import { Loop } from "./Loop";
11
15
  import { Path } from "./Path";
12
16
  import { Angle } from "../geometry3d/Angle";
13
17
  import { IntegratedSpiralTypeName } from "./spiral/TransitionSpiral3d";
18
+ import { Ray3d } from "../geometry3d/Ray3d";
14
19
  /**
15
20
  * The `CurveFactory` class contains methods for specialized curve constructions.
16
21
  * @public
@@ -118,5 +123,12 @@ export declare class CurveFactory {
118
123
  * @return array with the computed spirals, or undefined if failure.
119
124
  */
120
125
  static createLineSpiralArcSpiralLine(spiralType: IntegratedSpiralTypeName, pointA: Point3d, pointB: Point3d, pointC: Point3d, lengthA: number, lengthB: number, arcRadius: number): GeometryQuery[] | undefined;
126
+ /**
127
+ * Return the intersection point of 3 planes.
128
+ * @param planeA
129
+ * @param planeB
130
+ * @param planeC
131
+ */
132
+ static planePlaneIntersectionRay(planeA: PlaneAltitudeEvaluator, planeB: PlaneAltitudeEvaluator): Ray3d | undefined;
121
133
  }
122
134
  //# sourceMappingURL=CurveFactory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CurveFactory.d.ts","sourceRoot":"","sources":["../../../src/curve/CurveFactory.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAG1E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAIlE,OAAO,EAAE,KAAK,EAAgB,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,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