@itwin/core-geometry 4.2.0-dev.9 → 4.3.0-dev.1

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 (478) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/lib/cjs/Geometry.d.ts +4 -4
  3. package/lib/cjs/Geometry.d.ts.map +1 -1
  4. package/lib/cjs/Geometry.js +2 -2
  5. package/lib/cjs/Geometry.js.map +1 -1
  6. package/lib/cjs/clipping/AlternatingConvexClipTree.d.ts +4 -3
  7. package/lib/cjs/clipping/AlternatingConvexClipTree.d.ts.map +1 -1
  8. package/lib/cjs/clipping/AlternatingConvexClipTree.js +1 -1
  9. package/lib/cjs/clipping/AlternatingConvexClipTree.js.map +1 -1
  10. package/lib/cjs/clipping/BooleanClipNode.d.ts +4 -3
  11. package/lib/cjs/clipping/BooleanClipNode.d.ts.map +1 -1
  12. package/lib/cjs/clipping/BooleanClipNode.js.map +1 -1
  13. package/lib/cjs/clipping/ClipPlane.d.ts +2 -1
  14. package/lib/cjs/clipping/ClipPlane.d.ts.map +1 -1
  15. package/lib/cjs/clipping/ClipPlane.js.map +1 -1
  16. package/lib/cjs/clipping/ClipUtils.d.ts +17 -11
  17. package/lib/cjs/clipping/ClipUtils.d.ts.map +1 -1
  18. package/lib/cjs/clipping/ClipUtils.js +14 -8
  19. package/lib/cjs/clipping/ClipUtils.js.map +1 -1
  20. package/lib/cjs/clipping/ClipVector.d.ts +6 -5
  21. package/lib/cjs/clipping/ClipVector.d.ts.map +1 -1
  22. package/lib/cjs/clipping/ClipVector.js +1 -1
  23. package/lib/cjs/clipping/ClipVector.js.map +1 -1
  24. package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts +3 -2
  25. package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
  26. package/lib/cjs/clipping/ConvexClipPlaneSet.js.map +1 -1
  27. package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.d.ts +2 -1
  28. package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.d.ts.map +1 -1
  29. package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
  30. package/lib/cjs/core-geometry.d.ts +1 -3
  31. package/lib/cjs/core-geometry.d.ts.map +1 -1
  32. package/lib/cjs/core-geometry.js +1 -3
  33. package/lib/cjs/core-geometry.js.map +1 -1
  34. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  35. package/lib/cjs/curve/Arc3d.js +4 -4
  36. package/lib/cjs/curve/Arc3d.js.map +1 -1
  37. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +93 -91
  38. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  39. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +171 -152
  40. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  41. package/lib/cjs/curve/CurveCollection.d.ts +19 -19
  42. package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
  43. package/lib/cjs/curve/CurveCollection.js +20 -22
  44. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  45. package/lib/cjs/curve/CurveCurve.d.ts +47 -30
  46. package/lib/cjs/curve/CurveCurve.d.ts.map +1 -1
  47. package/lib/cjs/curve/CurveCurve.js +81 -46
  48. package/lib/cjs/curve/CurveCurve.js.map +1 -1
  49. package/lib/cjs/curve/CurveFactory.d.ts +1 -1
  50. package/lib/cjs/curve/CurveFactory.js.map +1 -1
  51. package/lib/cjs/curve/CurveLocationDetail.d.ts +17 -5
  52. package/lib/cjs/curve/CurveLocationDetail.d.ts.map +1 -1
  53. package/lib/cjs/curve/CurveLocationDetail.js +14 -2
  54. package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
  55. package/lib/cjs/curve/CurveOps.d.ts +1 -1
  56. package/lib/cjs/curve/CurveOps.js.map +1 -1
  57. package/lib/cjs/curve/CurvePrimitive.d.ts +1 -2
  58. package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
  59. package/lib/cjs/curve/CurvePrimitive.js +2 -2
  60. package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
  61. package/lib/cjs/curve/CurveProcessor.d.ts +1 -1
  62. package/lib/cjs/curve/CurveProcessor.js.map +1 -1
  63. package/lib/cjs/curve/{CurveChain.d.ts → CurveTypes.d.ts} +6 -6
  64. package/lib/cjs/curve/CurveTypes.d.ts.map +1 -0
  65. package/lib/cjs/curve/{CurveChain.js → CurveTypes.js} +1 -1
  66. package/lib/cjs/curve/CurveTypes.js.map +1 -0
  67. package/lib/cjs/curve/CurveWireMomentsXYZ.d.ts +1 -1
  68. package/lib/cjs/curve/CurveWireMomentsXYZ.js.map +1 -1
  69. package/lib/cjs/curve/ParityRegion.d.ts +3 -3
  70. package/lib/cjs/curve/ParityRegion.d.ts.map +1 -1
  71. package/lib/cjs/curve/ParityRegion.js +2 -2
  72. package/lib/cjs/curve/ParityRegion.js.map +1 -1
  73. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts +3 -2
  74. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
  75. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js +2 -2
  76. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
  77. package/lib/cjs/curve/Query/CurveSplitContext.d.ts +1 -1
  78. package/lib/cjs/curve/Query/CurveSplitContext.js.map +1 -1
  79. package/lib/cjs/curve/Query/CylindricalRange.d.ts +1 -1
  80. package/lib/cjs/curve/Query/CylindricalRange.js.map +1 -1
  81. package/lib/cjs/curve/Query/InOutTests.d.ts +1 -1
  82. package/lib/cjs/curve/Query/InOutTests.js.map +1 -1
  83. package/lib/cjs/curve/Query/StrokeCountChain.d.ts +1 -1
  84. package/lib/cjs/curve/Query/StrokeCountChain.js.map +1 -1
  85. package/lib/cjs/curve/RegionOps.d.ts +54 -5
  86. package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
  87. package/lib/cjs/curve/RegionOps.js +154 -3
  88. package/lib/cjs/curve/RegionOps.js.map +1 -1
  89. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +1 -1
  90. package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
  91. package/lib/cjs/curve/StrokeOptions.d.ts +20 -11
  92. package/lib/cjs/curve/StrokeOptions.d.ts.map +1 -1
  93. package/lib/cjs/curve/StrokeOptions.js +22 -11
  94. package/lib/cjs/curve/StrokeOptions.js.map +1 -1
  95. package/lib/cjs/curve/UnionRegion.d.ts +3 -3
  96. package/lib/cjs/curve/UnionRegion.d.ts.map +1 -1
  97. package/lib/cjs/curve/UnionRegion.js +2 -2
  98. package/lib/cjs/curve/UnionRegion.js.map +1 -1
  99. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts +1 -1
  100. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -1
  101. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js +2 -2
  102. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
  103. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +233 -0
  104. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -0
  105. package/lib/cjs/curve/{CurveCurveCloseApproachXY.js → internalContexts/CurveCurveCloseApproachXY.js} +299 -202
  106. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -0
  107. package/lib/{esm/curve → cjs/curve/internalContexts}/CurveCurveIntersectXY.d.ts +45 -51
  108. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -0
  109. package/lib/cjs/curve/{CurveCurveIntersectXY.js → internalContexts/CurveCurveIntersectXY.js} +104 -115
  110. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -0
  111. package/lib/cjs/curve/{CurveCurveIntersectXYZ.d.ts → internalContexts/CurveCurveIntersectXYZ.d.ts} +18 -18
  112. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -0
  113. package/lib/cjs/curve/{CurveCurveIntersectXYZ.js → internalContexts/CurveCurveIntersectXYZ.js} +134 -108
  114. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -0
  115. package/lib/cjs/curve/internalContexts/CurveOffsetXYHandler.d.ts +2 -2
  116. package/lib/cjs/curve/internalContexts/CurveOffsetXYHandler.d.ts.map +1 -1
  117. package/lib/cjs/curve/internalContexts/CurveOffsetXYHandler.js +9 -5
  118. package/lib/cjs/curve/internalContexts/CurveOffsetXYHandler.js.map +1 -1
  119. package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts +1 -1
  120. package/lib/cjs/curve/internalContexts/MultiChainCollector.js.map +1 -1
  121. package/lib/cjs/geometry3d/BarycentricTriangle.d.ts +1 -0
  122. package/lib/cjs/geometry3d/BarycentricTriangle.d.ts.map +1 -1
  123. package/lib/cjs/geometry3d/BarycentricTriangle.js +1 -0
  124. package/lib/cjs/geometry3d/BarycentricTriangle.js.map +1 -1
  125. package/lib/cjs/geometry3d/FrameBuilder.d.ts +28 -11
  126. package/lib/cjs/geometry3d/FrameBuilder.d.ts.map +1 -1
  127. package/lib/cjs/geometry3d/FrameBuilder.js +57 -45
  128. package/lib/cjs/geometry3d/FrameBuilder.js.map +1 -1
  129. package/lib/cjs/geometry3d/GeometryHandler.d.ts +15 -26
  130. package/lib/cjs/geometry3d/GeometryHandler.d.ts.map +1 -1
  131. package/lib/cjs/geometry3d/GeometryHandler.js +23 -32
  132. package/lib/cjs/geometry3d/GeometryHandler.js.map +1 -1
  133. package/lib/cjs/geometry3d/GrowableXYZArray.d.ts +0 -8
  134. package/lib/cjs/geometry3d/GrowableXYZArray.d.ts.map +1 -1
  135. package/lib/cjs/geometry3d/GrowableXYZArray.js +0 -16
  136. package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
  137. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +4 -4
  138. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  139. package/lib/cjs/geometry3d/IndexedXYZCollection.js +12 -0
  140. package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
  141. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  142. package/lib/cjs/geometry3d/Matrix3d.js +3 -6
  143. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  144. package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  145. package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
  146. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +1 -2
  147. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  148. package/lib/cjs/geometry3d/Point3dVector3d.js +0 -1
  149. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  150. package/lib/cjs/geometry3d/PolygonOps.d.ts +2 -2
  151. package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
  152. package/lib/cjs/geometry3d/PolygonOps.js +2 -3
  153. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  154. package/lib/cjs/geometry3d/Range.d.ts +1 -1
  155. package/lib/cjs/geometry3d/Range.d.ts.map +1 -1
  156. package/lib/cjs/geometry3d/Range.js +1 -1
  157. package/lib/cjs/geometry3d/Range.js.map +1 -1
  158. package/lib/cjs/geometry3d/Ray3d.d.ts +3 -1
  159. package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
  160. package/lib/cjs/geometry3d/Ray3d.js +4 -3
  161. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  162. package/lib/cjs/geometry3d/ReusableObjectCache.d.ts +2 -1
  163. package/lib/cjs/geometry3d/ReusableObjectCache.d.ts.map +1 -1
  164. package/lib/cjs/geometry3d/ReusableObjectCache.js +1 -1
  165. package/lib/cjs/geometry3d/ReusableObjectCache.js.map +1 -1
  166. package/lib/cjs/geometry3d/SortablePolygon.d.ts +1 -1
  167. package/lib/cjs/geometry3d/SortablePolygon.js.map +1 -1
  168. package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
  169. package/lib/cjs/geometry3d/Transform.js +4 -6
  170. package/lib/cjs/geometry3d/Transform.js.map +1 -1
  171. package/lib/cjs/geometry3d/YawPitchRollAngles.js +1 -1
  172. package/lib/cjs/geometry3d/YawPitchRollAngles.js.map +1 -1
  173. package/lib/cjs/geometry4d/Map4d.d.ts +14 -8
  174. package/lib/cjs/geometry4d/Map4d.d.ts.map +1 -1
  175. package/lib/cjs/geometry4d/Map4d.js +38 -16
  176. package/lib/cjs/geometry4d/Map4d.js.map +1 -1
  177. package/lib/cjs/geometry4d/Matrix4d.d.ts.map +1 -1
  178. package/lib/cjs/geometry4d/Matrix4d.js +4 -2
  179. package/lib/cjs/geometry4d/Matrix4d.js.map +1 -1
  180. package/lib/cjs/geometry4d/Point4d.js.map +1 -1
  181. package/lib/cjs/numerics/Polynomials.d.ts +2 -2
  182. package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
  183. package/lib/cjs/numerics/Polynomials.js +2 -2
  184. package/lib/cjs/numerics/Polynomials.js.map +1 -1
  185. package/lib/cjs/polyface/PolyfaceBuilder.d.ts +18 -6
  186. package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
  187. package/lib/cjs/polyface/PolyfaceBuilder.js +55 -25
  188. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  189. package/lib/cjs/polyface/PolyfaceClip.d.ts +16 -7
  190. package/lib/cjs/polyface/PolyfaceClip.d.ts.map +1 -1
  191. package/lib/cjs/polyface/PolyfaceClip.js +38 -7
  192. package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
  193. package/lib/cjs/polyface/PolyfaceData.d.ts +5 -39
  194. package/lib/cjs/polyface/PolyfaceData.d.ts.map +1 -1
  195. package/lib/cjs/polyface/PolyfaceData.js +7 -41
  196. package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
  197. package/lib/cjs/polyface/PolyfaceQuery.d.ts +10 -8
  198. package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
  199. package/lib/cjs/polyface/PolyfaceQuery.js +64 -18
  200. package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
  201. package/lib/cjs/serialization/GeometrySamples.d.ts +6 -0
  202. package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
  203. package/lib/cjs/serialization/GeometrySamples.js +68 -2
  204. package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
  205. package/lib/cjs/solid/LinearSweep.d.ts +1 -1
  206. package/lib/cjs/solid/LinearSweep.js.map +1 -1
  207. package/lib/cjs/solid/RotationalSweep.d.ts +1 -1
  208. package/lib/cjs/solid/RotationalSweep.js.map +1 -1
  209. package/lib/cjs/solid/RuledSweep.d.ts +1 -1
  210. package/lib/cjs/solid/RuledSweep.js.map +1 -1
  211. package/lib/cjs/solid/SweepContour.d.ts +35 -26
  212. package/lib/cjs/solid/SweepContour.d.ts.map +1 -1
  213. package/lib/cjs/solid/SweepContour.js +84 -100
  214. package/lib/cjs/solid/SweepContour.js.map +1 -1
  215. package/lib/cjs/topology/Graph.d.ts +29 -11
  216. package/lib/cjs/topology/Graph.d.ts.map +1 -1
  217. package/lib/cjs/topology/Graph.js +45 -26
  218. package/lib/cjs/topology/Graph.js.map +1 -1
  219. package/lib/cjs/topology/HalfEdgeMarkSet.d.ts +2 -2
  220. package/lib/cjs/topology/HalfEdgeMarkSet.d.ts.map +1 -1
  221. package/lib/cjs/topology/HalfEdgeMarkSet.js +4 -4
  222. package/lib/cjs/topology/HalfEdgeMarkSet.js.map +1 -1
  223. package/lib/cjs/topology/Merging.d.ts +3 -0
  224. package/lib/cjs/topology/Merging.d.ts.map +1 -1
  225. package/lib/cjs/topology/Merging.js +19 -5
  226. package/lib/cjs/topology/Merging.js.map +1 -1
  227. package/lib/cjs/topology/Triangulation.d.ts +15 -7
  228. package/lib/cjs/topology/Triangulation.d.ts.map +1 -1
  229. package/lib/cjs/topology/Triangulation.js +89 -47
  230. package/lib/cjs/topology/Triangulation.js.map +1 -1
  231. package/lib/esm/Geometry.d.ts +4 -4
  232. package/lib/esm/Geometry.d.ts.map +1 -1
  233. package/lib/esm/Geometry.js +2 -2
  234. package/lib/esm/Geometry.js.map +1 -1
  235. package/lib/esm/clipping/AlternatingConvexClipTree.d.ts +4 -3
  236. package/lib/esm/clipping/AlternatingConvexClipTree.d.ts.map +1 -1
  237. package/lib/esm/clipping/AlternatingConvexClipTree.js +1 -1
  238. package/lib/esm/clipping/AlternatingConvexClipTree.js.map +1 -1
  239. package/lib/esm/clipping/BooleanClipNode.d.ts +4 -3
  240. package/lib/esm/clipping/BooleanClipNode.d.ts.map +1 -1
  241. package/lib/esm/clipping/BooleanClipNode.js.map +1 -1
  242. package/lib/esm/clipping/ClipPlane.d.ts +2 -1
  243. package/lib/esm/clipping/ClipPlane.d.ts.map +1 -1
  244. package/lib/esm/clipping/ClipPlane.js.map +1 -1
  245. package/lib/esm/clipping/ClipUtils.d.ts +17 -11
  246. package/lib/esm/clipping/ClipUtils.d.ts.map +1 -1
  247. package/lib/esm/clipping/ClipUtils.js +14 -8
  248. package/lib/esm/clipping/ClipUtils.js.map +1 -1
  249. package/lib/esm/clipping/ClipVector.d.ts +6 -5
  250. package/lib/esm/clipping/ClipVector.d.ts.map +1 -1
  251. package/lib/esm/clipping/ClipVector.js +1 -1
  252. package/lib/esm/clipping/ClipVector.js.map +1 -1
  253. package/lib/esm/clipping/ConvexClipPlaneSet.d.ts +3 -2
  254. package/lib/esm/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
  255. package/lib/esm/clipping/ConvexClipPlaneSet.js.map +1 -1
  256. package/lib/esm/clipping/UnionOfConvexClipPlaneSets.d.ts +2 -1
  257. package/lib/esm/clipping/UnionOfConvexClipPlaneSets.d.ts.map +1 -1
  258. package/lib/esm/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
  259. package/lib/esm/core-geometry.d.ts +1 -3
  260. package/lib/esm/core-geometry.d.ts.map +1 -1
  261. package/lib/esm/core-geometry.js +1 -3
  262. package/lib/esm/core-geometry.js.map +1 -1
  263. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  264. package/lib/esm/curve/Arc3d.js +4 -4
  265. package/lib/esm/curve/Arc3d.js.map +1 -1
  266. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +93 -91
  267. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  268. package/lib/esm/curve/CurveChainWithDistanceIndex.js +171 -152
  269. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  270. package/lib/esm/curve/CurveCollection.d.ts +19 -19
  271. package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
  272. package/lib/esm/curve/CurveCollection.js +19 -20
  273. package/lib/esm/curve/CurveCollection.js.map +1 -1
  274. package/lib/esm/curve/CurveCurve.d.ts +47 -30
  275. package/lib/esm/curve/CurveCurve.d.ts.map +1 -1
  276. package/lib/esm/curve/CurveCurve.js +81 -46
  277. package/lib/esm/curve/CurveCurve.js.map +1 -1
  278. package/lib/esm/curve/CurveFactory.d.ts +1 -1
  279. package/lib/esm/curve/CurveFactory.js.map +1 -1
  280. package/lib/esm/curve/CurveLocationDetail.d.ts +17 -5
  281. package/lib/esm/curve/CurveLocationDetail.d.ts.map +1 -1
  282. package/lib/esm/curve/CurveLocationDetail.js +12 -1
  283. package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
  284. package/lib/esm/curve/CurveOps.d.ts +1 -1
  285. package/lib/esm/curve/CurveOps.js.map +1 -1
  286. package/lib/esm/curve/CurvePrimitive.d.ts +1 -2
  287. package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
  288. package/lib/esm/curve/CurvePrimitive.js +2 -2
  289. package/lib/esm/curve/CurvePrimitive.js.map +1 -1
  290. package/lib/esm/curve/CurveProcessor.d.ts +1 -1
  291. package/lib/esm/curve/CurveProcessor.js.map +1 -1
  292. package/lib/esm/curve/{CurveChain.d.ts → CurveTypes.d.ts} +6 -6
  293. package/lib/esm/curve/CurveTypes.d.ts.map +1 -0
  294. package/lib/esm/curve/{CurveChain.js → CurveTypes.js} +1 -1
  295. package/lib/esm/curve/CurveTypes.js.map +1 -0
  296. package/lib/esm/curve/CurveWireMomentsXYZ.d.ts +1 -1
  297. package/lib/esm/curve/CurveWireMomentsXYZ.js.map +1 -1
  298. package/lib/esm/curve/ParityRegion.d.ts +3 -3
  299. package/lib/esm/curve/ParityRegion.d.ts.map +1 -1
  300. package/lib/esm/curve/ParityRegion.js +2 -2
  301. package/lib/esm/curve/ParityRegion.js.map +1 -1
  302. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts +3 -2
  303. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
  304. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js +1 -1
  305. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
  306. package/lib/esm/curve/Query/CurveSplitContext.d.ts +1 -1
  307. package/lib/esm/curve/Query/CurveSplitContext.js.map +1 -1
  308. package/lib/esm/curve/Query/CylindricalRange.d.ts +1 -1
  309. package/lib/esm/curve/Query/CylindricalRange.js.map +1 -1
  310. package/lib/esm/curve/Query/InOutTests.d.ts +1 -1
  311. package/lib/esm/curve/Query/InOutTests.js.map +1 -1
  312. package/lib/esm/curve/Query/StrokeCountChain.d.ts +1 -1
  313. package/lib/esm/curve/Query/StrokeCountChain.js.map +1 -1
  314. package/lib/esm/curve/RegionOps.d.ts +54 -5
  315. package/lib/esm/curve/RegionOps.d.ts.map +1 -1
  316. package/lib/esm/curve/RegionOps.js +153 -3
  317. package/lib/esm/curve/RegionOps.js.map +1 -1
  318. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +1 -1
  319. package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
  320. package/lib/esm/curve/StrokeOptions.d.ts +20 -11
  321. package/lib/esm/curve/StrokeOptions.d.ts.map +1 -1
  322. package/lib/esm/curve/StrokeOptions.js +22 -11
  323. package/lib/esm/curve/StrokeOptions.js.map +1 -1
  324. package/lib/esm/curve/UnionRegion.d.ts +3 -3
  325. package/lib/esm/curve/UnionRegion.d.ts.map +1 -1
  326. package/lib/esm/curve/UnionRegion.js +2 -2
  327. package/lib/esm/curve/UnionRegion.js.map +1 -1
  328. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts +1 -1
  329. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -1
  330. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js +2 -2
  331. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
  332. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +233 -0
  333. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -0
  334. package/lib/esm/curve/{CurveCurveCloseApproachXY.js → internalContexts/CurveCurveCloseApproachXY.js} +299 -202
  335. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -0
  336. package/lib/{cjs/curve → esm/curve/internalContexts}/CurveCurveIntersectXY.d.ts +45 -51
  337. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -0
  338. package/lib/esm/curve/{CurveCurveIntersectXY.js → internalContexts/CurveCurveIntersectXY.js} +103 -113
  339. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -0
  340. package/lib/esm/curve/{CurveCurveIntersectXYZ.d.ts → internalContexts/CurveCurveIntersectXYZ.d.ts} +18 -18
  341. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -0
  342. package/lib/esm/curve/{CurveCurveIntersectXYZ.js → internalContexts/CurveCurveIntersectXYZ.js} +134 -108
  343. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -0
  344. package/lib/esm/curve/internalContexts/CurveOffsetXYHandler.d.ts +2 -2
  345. package/lib/esm/curve/internalContexts/CurveOffsetXYHandler.d.ts.map +1 -1
  346. package/lib/esm/curve/internalContexts/CurveOffsetXYHandler.js +9 -5
  347. package/lib/esm/curve/internalContexts/CurveOffsetXYHandler.js.map +1 -1
  348. package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts +1 -1
  349. package/lib/esm/curve/internalContexts/MultiChainCollector.js.map +1 -1
  350. package/lib/esm/geometry3d/BarycentricTriangle.d.ts +1 -0
  351. package/lib/esm/geometry3d/BarycentricTriangle.d.ts.map +1 -1
  352. package/lib/esm/geometry3d/BarycentricTriangle.js +1 -0
  353. package/lib/esm/geometry3d/BarycentricTriangle.js.map +1 -1
  354. package/lib/esm/geometry3d/FrameBuilder.d.ts +28 -11
  355. package/lib/esm/geometry3d/FrameBuilder.d.ts.map +1 -1
  356. package/lib/esm/geometry3d/FrameBuilder.js +57 -45
  357. package/lib/esm/geometry3d/FrameBuilder.js.map +1 -1
  358. package/lib/esm/geometry3d/GeometryHandler.d.ts +15 -26
  359. package/lib/esm/geometry3d/GeometryHandler.d.ts.map +1 -1
  360. package/lib/esm/geometry3d/GeometryHandler.js +23 -32
  361. package/lib/esm/geometry3d/GeometryHandler.js.map +1 -1
  362. package/lib/esm/geometry3d/GrowableXYZArray.d.ts +0 -8
  363. package/lib/esm/geometry3d/GrowableXYZArray.d.ts.map +1 -1
  364. package/lib/esm/geometry3d/GrowableXYZArray.js +0 -16
  365. package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
  366. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +4 -4
  367. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  368. package/lib/esm/geometry3d/IndexedXYZCollection.js +12 -0
  369. package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
  370. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  371. package/lib/esm/geometry3d/Matrix3d.js +3 -6
  372. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  373. package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  374. package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
  375. package/lib/esm/geometry3d/Point3dVector3d.d.ts +1 -2
  376. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  377. package/lib/esm/geometry3d/Point3dVector3d.js +0 -1
  378. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  379. package/lib/esm/geometry3d/PolygonOps.d.ts +2 -2
  380. package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
  381. package/lib/esm/geometry3d/PolygonOps.js +2 -3
  382. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  383. package/lib/esm/geometry3d/Range.d.ts +1 -1
  384. package/lib/esm/geometry3d/Range.d.ts.map +1 -1
  385. package/lib/esm/geometry3d/Range.js +1 -1
  386. package/lib/esm/geometry3d/Range.js.map +1 -1
  387. package/lib/esm/geometry3d/Ray3d.d.ts +3 -1
  388. package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
  389. package/lib/esm/geometry3d/Ray3d.js +4 -3
  390. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  391. package/lib/esm/geometry3d/ReusableObjectCache.d.ts +2 -1
  392. package/lib/esm/geometry3d/ReusableObjectCache.d.ts.map +1 -1
  393. package/lib/esm/geometry3d/ReusableObjectCache.js +1 -1
  394. package/lib/esm/geometry3d/ReusableObjectCache.js.map +1 -1
  395. package/lib/esm/geometry3d/SortablePolygon.d.ts +1 -1
  396. package/lib/esm/geometry3d/SortablePolygon.js.map +1 -1
  397. package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
  398. package/lib/esm/geometry3d/Transform.js +4 -6
  399. package/lib/esm/geometry3d/Transform.js.map +1 -1
  400. package/lib/esm/geometry3d/YawPitchRollAngles.js +1 -1
  401. package/lib/esm/geometry3d/YawPitchRollAngles.js.map +1 -1
  402. package/lib/esm/geometry4d/Map4d.d.ts +14 -8
  403. package/lib/esm/geometry4d/Map4d.d.ts.map +1 -1
  404. package/lib/esm/geometry4d/Map4d.js +38 -16
  405. package/lib/esm/geometry4d/Map4d.js.map +1 -1
  406. package/lib/esm/geometry4d/Matrix4d.d.ts.map +1 -1
  407. package/lib/esm/geometry4d/Matrix4d.js +4 -2
  408. package/lib/esm/geometry4d/Matrix4d.js.map +1 -1
  409. package/lib/esm/geometry4d/Point4d.js.map +1 -1
  410. package/lib/esm/numerics/Polynomials.d.ts +2 -2
  411. package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
  412. package/lib/esm/numerics/Polynomials.js +2 -2
  413. package/lib/esm/numerics/Polynomials.js.map +1 -1
  414. package/lib/esm/polyface/PolyfaceBuilder.d.ts +18 -6
  415. package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
  416. package/lib/esm/polyface/PolyfaceBuilder.js +55 -25
  417. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  418. package/lib/esm/polyface/PolyfaceClip.d.ts +16 -7
  419. package/lib/esm/polyface/PolyfaceClip.d.ts.map +1 -1
  420. package/lib/esm/polyface/PolyfaceClip.js +38 -7
  421. package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
  422. package/lib/esm/polyface/PolyfaceData.d.ts +5 -39
  423. package/lib/esm/polyface/PolyfaceData.d.ts.map +1 -1
  424. package/lib/esm/polyface/PolyfaceData.js +7 -41
  425. package/lib/esm/polyface/PolyfaceData.js.map +1 -1
  426. package/lib/esm/polyface/PolyfaceQuery.d.ts +10 -8
  427. package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
  428. package/lib/esm/polyface/PolyfaceQuery.js +64 -18
  429. package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
  430. package/lib/esm/serialization/GeometrySamples.d.ts +6 -0
  431. package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
  432. package/lib/esm/serialization/GeometrySamples.js +68 -2
  433. package/lib/esm/serialization/GeometrySamples.js.map +1 -1
  434. package/lib/esm/solid/LinearSweep.d.ts +1 -1
  435. package/lib/esm/solid/LinearSweep.js.map +1 -1
  436. package/lib/esm/solid/RotationalSweep.d.ts +1 -1
  437. package/lib/esm/solid/RotationalSweep.js.map +1 -1
  438. package/lib/esm/solid/RuledSweep.d.ts +1 -1
  439. package/lib/esm/solid/RuledSweep.js.map +1 -1
  440. package/lib/esm/solid/SweepContour.d.ts +35 -26
  441. package/lib/esm/solid/SweepContour.d.ts.map +1 -1
  442. package/lib/esm/solid/SweepContour.js +84 -100
  443. package/lib/esm/solid/SweepContour.js.map +1 -1
  444. package/lib/esm/topology/Graph.d.ts +29 -11
  445. package/lib/esm/topology/Graph.d.ts.map +1 -1
  446. package/lib/esm/topology/Graph.js +45 -26
  447. package/lib/esm/topology/Graph.js.map +1 -1
  448. package/lib/esm/topology/HalfEdgeMarkSet.d.ts +2 -2
  449. package/lib/esm/topology/HalfEdgeMarkSet.d.ts.map +1 -1
  450. package/lib/esm/topology/HalfEdgeMarkSet.js +2 -2
  451. package/lib/esm/topology/HalfEdgeMarkSet.js.map +1 -1
  452. package/lib/esm/topology/Merging.d.ts +3 -0
  453. package/lib/esm/topology/Merging.d.ts.map +1 -1
  454. package/lib/esm/topology/Merging.js +19 -5
  455. package/lib/esm/topology/Merging.js.map +1 -1
  456. package/lib/esm/topology/Triangulation.d.ts +15 -7
  457. package/lib/esm/topology/Triangulation.d.ts.map +1 -1
  458. package/lib/esm/topology/Triangulation.js +89 -47
  459. package/lib/esm/topology/Triangulation.js.map +1 -1
  460. package/package.json +4 -4
  461. package/lib/cjs/curve/CurveChain.d.ts.map +0 -1
  462. package/lib/cjs/curve/CurveChain.js.map +0 -1
  463. package/lib/cjs/curve/CurveCurveCloseApproachXY.d.ts +0 -175
  464. package/lib/cjs/curve/CurveCurveCloseApproachXY.d.ts.map +0 -1
  465. package/lib/cjs/curve/CurveCurveCloseApproachXY.js.map +0 -1
  466. package/lib/cjs/curve/CurveCurveIntersectXY.d.ts.map +0 -1
  467. package/lib/cjs/curve/CurveCurveIntersectXY.js.map +0 -1
  468. package/lib/cjs/curve/CurveCurveIntersectXYZ.d.ts.map +0 -1
  469. package/lib/cjs/curve/CurveCurveIntersectXYZ.js.map +0 -1
  470. package/lib/esm/curve/CurveChain.d.ts.map +0 -1
  471. package/lib/esm/curve/CurveChain.js.map +0 -1
  472. package/lib/esm/curve/CurveCurveCloseApproachXY.d.ts +0 -175
  473. package/lib/esm/curve/CurveCurveCloseApproachXY.d.ts.map +0 -1
  474. package/lib/esm/curve/CurveCurveCloseApproachXY.js.map +0 -1
  475. package/lib/esm/curve/CurveCurveIntersectXY.d.ts.map +0 -1
  476. package/lib/esm/curve/CurveCurveIntersectXY.js.map +0 -1
  477. package/lib/esm/curve/CurveCurveIntersectXYZ.d.ts.map +0 -1
  478. package/lib/esm/curve/CurveCurveIntersectXYZ.js.map +0 -1
@@ -8,6 +8,7 @@ exports.CurveChainWithDistanceIndex = exports.PathFragment = void 0;
8
8
  /** @packageDocumentation
9
9
  * @module Curve
10
10
  */
11
+ const core_bentley_1 = require("@itwin/core-bentley");
11
12
  const CurvePrimitive_1 = require("../curve/CurvePrimitive");
12
13
  const StrokeCountMap_1 = require("../curve/Query/StrokeCountMap");
13
14
  const Geometry_1 = require("../Geometry");
@@ -20,14 +21,14 @@ const PlaneAltitudeRangeContext_1 = require("./internalContexts/PlaneAltitudeRan
20
21
  const OffsetOptions_1 = require("./OffsetOptions");
21
22
  const Path_1 = require("./Path");
22
23
  /**
23
- * Annotation of an interval of a curve.
24
+ * Annotation of a fragment, i.e. an interval of a curve.
24
25
  * * The interval is marked with two pairs of numbers:
25
- * * * fraction0, fraction1 = fraction parameters along the child curve
26
- * * * distance0,distance1 = distances within containing CurveChainWithDistanceIndex
26
+ * * * fraction0, fraction1 = fraction parameters along the child curve.
27
+ * * * distance0, distance1 = distances within containing CurveChainWithDistanceIndex.
27
28
  * @public
28
29
  */
29
30
  class PathFragment {
30
- /** Create a fragment with complete fraction, distance and child data. */
31
+ /** Create a fragment with complete fraction, distance, and child data. */
31
32
  constructor(childFraction0, childFraction1, distance0, distance1, childCurve, range) {
32
33
  this.childFraction0 = childFraction0;
33
34
  this.childFraction1 = childFraction1;
@@ -37,68 +38,64 @@ class PathFragment {
37
38
  this.range = range;
38
39
  this.a = 0;
39
40
  }
40
- /**
41
- * Return true if the distance is within the distance limits of this fragment.
42
- * @param distance
43
- */
41
+ /** Return true if the distance is within the distance limits of this fragment. */
44
42
  containsChainDistance(distance) {
45
43
  return distance >= this.chainDistance0 && distance <= this.chainDistance1;
46
44
  }
47
- /** Return a quick distance to the curve. This may be SMALLER than true distance but may not be larger */
45
+ /**
46
+ * Return a quick minimum distance from spacePoint to the curve.
47
+ * * The returned distance is to the curve's range box if defined; otherwise, the true distance is computed.
48
+ * * Thus the returned distance may be SMALLER than the true distance to the curve, but not larger.
49
+ */
48
50
  quickMinDistanceToChildCurve(spacePoint) {
49
- if (this.range) {
51
+ if (this.range)
50
52
  return this.range.distanceToPoint(spacePoint);
51
- }
52
- // ugh. have to do real computation ..
53
53
  const detail = this.childCurve.closestPoint(spacePoint, false);
54
54
  if (detail)
55
55
  return detail.a;
56
56
  return 0;
57
57
  }
58
58
  /**
59
- * Return an array with (references to) all the path fragments, sorted smallest to largest on the "a" value
60
- * equal to the quick min distance to the fragment
59
+ * Return an array with (references to) all the input path fragments, sorted smallest to largest on the "a" value,
60
+ * initialized with `quickMinDistanceToChildCurve`
61
61
  */
62
62
  static collectSortedQuickMinDistances(fragments, spacePoint) {
63
63
  const sortedFragments = [];
64
- for (const f of fragments) {
65
- f.a = f.quickMinDistanceToChildCurve(spacePoint);
66
- sortedFragments.push(f);
64
+ for (const frag of fragments) {
65
+ frag.a = frag.quickMinDistanceToChildCurve(spacePoint);
66
+ sortedFragments.push(frag);
67
67
  }
68
- sortedFragments.sort((a, b) => a.a - b.a);
68
+ sortedFragments.sort((frag1, frag2) => frag1.a - frag2.a);
69
69
  return sortedFragments;
70
70
  }
71
- /**
72
- * Return true if this fragment addresses `curve` and brackets `fraction`
73
- * @param distance
74
- */
71
+ /** Return true if `this` fragment addresses `curve` and brackets `fraction`. */
75
72
  containsChildCurveAndChildFraction(curve, fraction) {
76
73
  return this.childCurve === curve && fraction >= this.childFraction0 && fraction <= this.childFraction1;
77
74
  }
78
75
  /**
79
- * Convert distance to local fraction, and apply that to interpolate between the stored curve fractions.
80
- * Note that proportional calculation does NOT account for nonuniform parameterization in the child curve.
76
+ * Convert distance to local fraction and apply that to interpolate between the stored curve fractions.
77
+ * Note that proportional calculation does NOT account for non-uniform parameterization in the child curve.
81
78
  */
82
79
  chainDistanceToInterpolatedChildFraction(distance) {
83
- return Geometry_1.Geometry.inverseInterpolate(this.childFraction0, this.chainDistance0, this.childFraction1, this.chainDistance1, distance, this.childFraction0); // the interval "must" have nonzero length, division should be safe . ..
80
+ return Geometry_1.Geometry.inverseInterpolate(this.childFraction0, this.chainDistance0, this.childFraction1, this.chainDistance1, distance, this.childFraction0); // the interval must have nonzero length so division should be safe
84
81
  }
85
- /** Convert chainDistance to true chidFraction, using detailed moveSignedDistanceFromFraction */
82
+ /** Convert the given chainDistance to a fraction along this childCurve using `moveSignedDistanceFromFraction`. */
86
83
  chainDistanceToAccurateChildFraction(chainDistance, allowExtrapolation) {
87
- // The fragments are really expected to do good mappings in their distance range ...
88
84
  const childDetail = this.childCurve.moveSignedDistanceFromFraction(this.childFraction0, chainDistance - this.chainDistance0, allowExtrapolation ?? false);
89
85
  return childDetail.fraction;
90
86
  }
91
87
  /**
92
- * Return the scale factor to map childCurve fraction derivatives to chain fraction derivatives
93
- * @param globalDistance total length of the global curve.
88
+ * Return the scale factor to map childCurve fraction derivatives to chain fraction derivatives.
89
+ * @param globalDistance total length of the global curve
94
90
  */
95
91
  fractionScaleFactor(globalDistance) {
96
92
  return globalDistance * (this.childFraction1 - this.childFraction0) / (this.chainDistance1 - this.chainDistance0);
97
93
  }
98
94
  /**
99
95
  * Reverse the fraction and distance data.
100
- * * each child fraction `f` is replaced by `1-f`
101
- * * each `chainDistance` is replaced by `totalDistance-chainDistance`
96
+ * * Each child fraction `f` is replaced by `1-f`
97
+ * * Each `chainDistance` is replaced by `totalDistance - chainDistance`
98
+ * @param totalDistance the total distance
102
99
  */
103
100
  reverseFractionsAndDistances(totalDistance) {
104
101
  const f0 = this.childFraction0;
@@ -110,14 +107,14 @@ class PathFragment {
110
107
  this.chainDistance0 = totalDistance - d1;
111
108
  this.chainDistance1 = totalDistance - d0;
112
109
  }
113
- /** @deprecated in 3.x. Use childFractionToChainDistance */
110
+ /** @deprecated in 3.x. Use `PathFragment.childFractionToChainDistance`. */
114
111
  childFractionTChainDistance(fraction) {
115
112
  return this.childFractionToChainDistance(fraction);
116
113
  }
117
114
  /**
118
- * Convert a fractional position on the childCurve to distance in the chain space.
119
- * * Return value is SIGNED -- will be negative when fraction < this.childFraction0.
120
- * @param fraction fraction along the curve within this fragment
115
+ * Convert a fractional position on the childCurve of this fragment to distance on the curve chain.
116
+ * * Return value is SIGNED and will be negative when `fraction < this.childFraction0`.
117
+ * @param fraction the fractional position on the childCurve of this fragment
121
118
  */
122
119
  childFractionToChainDistance(fraction) {
123
120
  let d = this.childCurve.curveLengthBetweenFractions(this.childFraction0, fraction);
@@ -127,7 +124,7 @@ class PathFragment {
127
124
  }
128
125
  }
129
126
  exports.PathFragment = PathFragment;
130
- /** Non-instantiable class to build a distance index for a path. */
127
+ /** Non-instantiable class to build a distance index for a curve chain. */
131
128
  class DistanceIndexConstructionContext {
132
129
  constructor() {
133
130
  this._accumulatedDistance = 0;
@@ -139,7 +136,6 @@ class DistanceIndexConstructionContext {
139
136
  endParentCurvePrimitive(_cp) { }
140
137
  endCurvePrimitive(_cp) { }
141
138
  announcePointTangent(_xyz, _fraction, _tangent) { }
142
- /** Announce numPoints interpolated between point0 and point1, with associated fractions */
143
139
  announceSegmentInterval(cp, point0, point1, numStrokes, fraction0, fraction1) {
144
140
  const fragmentPoint0 = point0.clone();
145
141
  const fragmentPoint1 = point1.clone();
@@ -171,7 +167,10 @@ class DistanceIndexConstructionContext {
171
167
  this._fragments.push(new PathFragment(f0, f1, d0, this._accumulatedDistance, cp, range));
172
168
  }
173
169
  }
174
- needPrimaryGeometryForStrokes() { return true; }
170
+ needPrimaryGeometryForStrokes() {
171
+ return true;
172
+ }
173
+ /** Create an array of PathFragment from input curve chain. */
175
174
  static createPathFragmentIndex(path, options) {
176
175
  const handler = new DistanceIndexConstructionContext();
177
176
  for (const curve of path.children) {
@@ -186,12 +185,11 @@ class DistanceIndexConstructionContext {
186
185
  * distance along a CurveChain.
187
186
  * * For example if the total length of the chain is `L`, then the distance along the chain from parameters `t0`
188
187
  * to `t1` is easily computed as `L*(t1-t0)`.
189
- * * The curve chain can be any type derived from CurveChain.
190
- * * * i.e. either a `Path` or a `Loop`
188
+ * * The curve chain can be any type derived from `CurveChain`, i.e., either a `Path` or a `Loop`.
191
189
  * @public
192
190
  */
193
191
  class CurveChainWithDistanceIndex extends CurvePrimitive_1.CurvePrimitive {
194
- /** Test if other is a `CurveChainWithDistanceIndex` */
192
+ /** Test if `other` is a `CurveChainWithDistanceIndex` */
195
193
  isSameGeometryClass(other) {
196
194
  return other instanceof CurveChainWithDistanceIndex;
197
195
  }
@@ -216,7 +214,7 @@ class CurveChainWithDistanceIndex extends CurvePrimitive_1.CurvePrimitive {
216
214
  }
217
215
  /**
218
216
  * Reference to the contained path.
219
- * * Do not modify the path. The distance index will be wrong.
217
+ * * Do not modify the path. The distance index will be wrong.
220
218
  */
221
219
  get path() {
222
220
  return this._path;
@@ -310,14 +308,14 @@ class CurveChainWithDistanceIndex extends CurvePrimitive_1.CurvePrimitive {
310
308
  }
311
309
  return true;
312
310
  }
313
- /** Return the start point of the primitive. The default implementation returns fractionToPoint (0.0) */
311
+ /** Return the start point of `this` curve. */
314
312
  startPoint(result) {
315
313
  const c = this._path.cyclicCurvePrimitive(0);
316
314
  if (c)
317
315
  return c.startPoint(result);
318
316
  return Point3dVector3d_1.Point3d.createZero(result);
319
317
  }
320
- /** Return the end point of the primitive. The default implementation returns fractionToPoint(1.0) */
318
+ /** Return the end point of of `this` curve. */
321
319
  endPoint(result) {
322
320
  const c = this._path.cyclicCurvePrimitive(-1);
323
321
  if (c)
@@ -353,7 +351,7 @@ class CurveChainWithDistanceIndex extends CurvePrimitive_1.CurvePrimitive {
353
351
  /**
354
352
  * Return an array containing only the curve primitives.
355
353
  * @param collectorArray array to receive primitives (pushed -- the array is not cleared)
356
- * @param smallestPossiblePrimitives if true, recurse on the (otherwise hidden) children. If false, only push `this`.
354
+ * @param smallestPossiblePrimitives if true, recurse on the children. If false, only push `this`.
357
355
  * @param explodeLinestrings (if smallestPossiblePrimitives is true) whether to push a [[LineSegment3d]] for each
358
356
  * segment of a [[LineString3d]] child. If false, push only the [[LineString3d]].
359
357
  */
@@ -380,21 +378,17 @@ class CurveChainWithDistanceIndex extends CurvePrimitive_1.CurvePrimitive {
380
378
  CurvePrimitive_1.CurvePrimitive.installStrokeCountMap(this, myMap, parentStrokeMap);
381
379
  }
382
380
  /**
383
- * Second step of double dispatch: call `this._path.dispatchToGeometryHandler (handler)`
381
+ * Second step of double dispatch: call `this._path.dispatchToGeometryHandler (handler)`
384
382
  * * Note that this exposes the children individually to the handler.
385
383
  */
386
384
  dispatchToGeometryHandler(handler) {
387
- return this._path.dispatchToGeometryHandler(handler);
385
+ return handler.handleCurveChainWithDistanceIndex(this);
388
386
  }
389
- /** Extend (increase) `rangeToExtend` as needed to include these curves (optionally transformed) */
387
+ /** Extend `rangeToExtend` as needed to include these curves (optionally transformed) */
390
388
  extendRange(rangeToExtend, transform) {
391
389
  this._path.extendRange(rangeToExtend, transform);
392
390
  }
393
- /**
394
- * Curve length is always positive.
395
- * @returns Returns a (high accuracy) length of the curve between fractional positions
396
- * @returns Returns the length of the curve.
397
- */
391
+ /** Return a (high accuracy and positive) length of the curve between fractional positions */
398
392
  curveLengthBetweenFractions(fraction0, fraction1) {
399
393
  return Math.abs(fraction1 - fraction0) * this._totalLength;
400
394
  }
@@ -408,9 +402,10 @@ class CurveChainWithDistanceIndex extends CurvePrimitive_1.CurvePrimitive {
408
402
  return result;
409
403
  }
410
404
  /**
411
- * Resolve a fraction of the CurveChain to a PathFragment
412
- * @param distance
413
- * @param allowExtrapolation
405
+ * Return the PathFragment object at the given `distance` along the chain.
406
+ * @param distance distance along the chain.
407
+ * @param allowExtrapolation if `true`, returns first fragment for negative distances and returns last fragment
408
+ * for distances larger than curve length. If `false` returns `undefined` for those out of bound distances.
414
409
  */
415
410
  chainDistanceToFragment(distance, allowExtrapolation = false) {
416
411
  const i = this.chainDistanceToFragmentIndex(distance, allowExtrapolation);
@@ -419,9 +414,10 @@ class CurveChainWithDistanceIndex extends CurvePrimitive_1.CurvePrimitive {
419
414
  return undefined;
420
415
  }
421
416
  /**
422
- * Resolve a fraction of the CurveChain to a PathFragment index
423
- * @param distance
424
- * @param allowExtrapolation
417
+ * Return the index of the PathFragment at the given `distance` along the chain.
418
+ * @param distance distance along the chain.
419
+ * @param allowExtrapolation if `true`, returns 0 for negative distances and returns last fragment index for
420
+ * distances larger than curve length. If `false` returns `undefined` for those out of bound distances.
425
421
  */
426
422
  chainDistanceToFragmentIndex(distance, allowExtrapolation = false) {
427
423
  const numFragments = this._fragments.length;
@@ -431,7 +427,7 @@ class CurveChainWithDistanceIndex extends CurvePrimitive_1.CurvePrimitive {
431
427
  return allowExtrapolation ? 0 : undefined;
432
428
  if (distance > this._totalLength)
433
429
  return allowExtrapolation ? (numFragments - 1) : undefined;
434
- // humbug, linear search
430
+ // linear search (opportunity for improvement)
435
431
  for (let i = 0; i < numFragments; i++) {
436
432
  if (fragments[i].containsChainDistance(distance))
437
433
  return i;
@@ -441,33 +437,29 @@ class CurveChainWithDistanceIndex extends CurvePrimitive_1.CurvePrimitive {
441
437
  }
442
438
  /**
443
439
  * Convert distance along the chain to fraction along the chain.
444
- * @param distance distance along the chain
440
+ * @param distance distance along the chain.
445
441
  */
446
442
  chainDistanceToChainFraction(distance) {
447
443
  return distance / this._totalLength;
448
444
  }
449
- /**
450
- * Resolve a fraction within a specific curve to a fragment.
451
- * @param curve
452
- * @param fraction
453
- */
445
+ /** Return the PathFragment object containing the point at the given `fraction` of the given child curve. */
454
446
  curveAndChildFractionToFragment(curve, fraction) {
455
447
  const numFragments = this._fragments.length;
456
448
  const fragments = this._fragments;
457
449
  if (numFragments > 0) {
458
- // humbug, linear search
450
+ if (fraction < 0)
451
+ return fragments[0];
452
+ if (fraction > 1.0)
453
+ return fragments[numFragments - 1];
454
+ // linear search (opportunity for improvement)
459
455
  for (const fragment of fragments) {
460
456
  if (fragment.containsChildCurveAndChildFraction(curve, fraction))
461
457
  return fragment;
462
458
  }
463
- if (fraction <= 0)
464
- return fragments[0];
465
- if (fraction > 1.0)
466
- return fragments[numFragments - 1];
467
459
  }
468
460
  return undefined;
469
461
  }
470
- /** Returns the total length of curves. */
462
+ /** Returns the total length of `this` curve. */
471
463
  curveLength() {
472
464
  return this._totalLength;
473
465
  }
@@ -480,52 +472,59 @@ class CurveChainWithDistanceIndex extends CurvePrimitive_1.CurvePrimitive {
480
472
  }
481
473
  /**
482
474
  * Return the point (x,y,z) on the curve at fractional position along the chain.
483
- * @param fraction fractional position along the geometry.
484
- * @returns Returns a point on the curve.
475
+ * @param fraction fractional position along the curve.
476
+ * @returns a point on the curve.
485
477
  */
486
478
  fractionToPoint(fraction, result) {
487
- const chainDistance = fraction * this._totalLength;
488
- const fragment = this.chainDistanceToFragment(chainDistance, true);
479
+ const distanceAlongPath = fraction * this._totalLength;
480
+ const fragment = this.chainDistanceToFragment(distanceAlongPath, true);
489
481
  if (fragment) {
490
- const childFraction = fragment.chainDistanceToAccurateChildFraction(chainDistance, true);
482
+ const childFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath, true);
491
483
  return fragment.childCurve.fractionToPoint(childFraction, result);
492
484
  }
493
- // no fragment found. Use _fragments[0]
494
- // fragment = this.chainDistanceToFragment(chainDistance, true);
485
+ (0, core_bentley_1.assert)(false); // we never expect to get here
486
+ // no fragment found. just return the first point on the curve.
495
487
  return this._fragments[0].childCurve.fractionToPoint(0.0, result);
496
488
  }
497
489
  /**
498
490
  * Return the point (x,y,z) and derivative on the curve at fractional position.
499
- * * Note that this derivative is "derivative of xyz with respect to fraction."
500
- * * this derivative shows the speed of the "fractional point" moving along the curve.
501
- * * this is not generally a unit vector. use fractionToPointAndUnitTangent for a unit vector.
491
+ * * Note that the derivative is "derivative of xyz with respect to fraction".
492
+ * * The derivative shows the speed of the "fractional point" moving along the curve.
493
+ * * The derivative is not generally a unit vector. Use `fractionToPointAndUnitTangent` for a unit vector.
502
494
  * @param fraction fractional position along the geometry.
503
- * @returns Returns a ray whose origin is the curve point and direction is the derivative with respect to the fraction.
495
+ * @param result optional receiver for the result.
496
+ * @returns a ray whose origin is the curve point and direction is the derivative with respect to the fraction.
504
497
  */
505
498
  fractionToPointAndDerivative(fraction, result) {
506
499
  const distanceAlongPath = fraction * this._totalLength;
507
500
  const fragment = this.chainDistanceToFragment(distanceAlongPath, true);
508
- const curveFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath, true);
509
- result = fragment.childCurve.fractionToPointAndDerivative(curveFraction, result);
510
- // Fractional arc length parameterization for the curve C is f=f(t)=s(t)/L, where
511
- // L is total length of C, f'=||C'||/L, and inverse t=t(f), t'=1/f'=L/||C'||.
512
- // Then d/df(C(t(f)))=C't'=C'L/||C'||. The fragment gave us C', so the
513
- // derivative we seek is just a scale away.
514
- const a = this._totalLength / result.direction.magnitude();
501
+ const childFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath, true);
502
+ result = fragment.childCurve.fractionToPointAndDerivative(childFraction, result);
503
+ // Recall the standard arclength formula s(t) for the curve C = C(t), with derivative s'(t) = ||C'||.
504
+ // Define fractional arclength for C by f = f(t) = s(t)/L, where L is the total length of C. Then f' = ||C'||/L.
505
+ // Denote the inverse of f by t = t(f). Then C = C(t(f)) is a parameterization of C by its fractional arclength f.
506
+ // Since the derivative of t is t'=1/f'=L/||C'||, the derivative we seek is d/df(C(t(f))) = C' t' = C' L/||C'||.
507
+ // The fragment gives us C', so we're just a scale away.
508
+ // Math details can be found at core/geometry/internaldocs/Curve.md
509
+ const a = this._totalLength / result.direction.magnitude(); // L/||C'||
515
510
  result.direction.scaleInPlace(a);
516
511
  return result;
517
512
  }
518
513
  /**
519
- * Returns a ray whose origin is the curve point and direction is the unit tangent.
514
+ * Return the point (x,y,z) and normalized derivative on the curve at fractional position.
515
+ * * Note that the derivative is "derivative of xyz with respect to fraction".
516
+ * * The un-normalized derivative shows the speed of the "fractional point" moving along the curve.
517
+ * * To find the un-normalized derivative, use `fractionToPointAndDerivative`.
520
518
  * @param fraction fractional position on the curve
521
519
  * @param result optional receiver for the result.
522
- * Returns a ray whose origin is the curve point and direction is the unit tangent.
520
+ * @returns a ray whose origin is the curve point and direction is the normalized derivative with respect to
521
+ * the fraction.
523
522
  */
524
523
  fractionToPointAndUnitTangent(fraction, result) {
525
524
  const distanceAlongPath = fraction * this._totalLength;
526
525
  const fragment = this.chainDistanceToFragment(distanceAlongPath, true);
527
- const curveFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath, true);
528
- result = fragment.childCurve.fractionToPointAndDerivative(curveFraction, result);
526
+ const childFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath, true);
527
+ result = fragment.childCurve.fractionToPointAndDerivative(childFraction, result);
529
528
  result.direction.normalizeInPlace();
530
529
  return result;
531
530
  }
@@ -534,34 +533,39 @@ class CurveChainWithDistanceIndex extends CurvePrimitive_1.CurvePrimitive {
534
533
  * * origin at fractional position along the curve
535
534
  * * vectorU is the first derivative, i.e. tangent vector with length equal to the rate of change with respect to
536
535
  * the fraction.
537
- * * vectorV is the second derivative, i.e.derivative of vectorU.
536
+ * * vectorV is the second derivative, i.e. derivative of vectorU which points in the direction of the curve's
537
+ * derivative's change.
538
538
  */
539
539
  fractionToPointAnd2Derivatives(fraction, result) {
540
540
  const distanceAlongPath = fraction * this._totalLength;
541
541
  const fragment = this.chainDistanceToFragment(distanceAlongPath, true);
542
- const curveFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath, true);
543
- result = fragment.childCurve.fractionToPointAnd2Derivatives(curveFraction, result);
542
+ const childFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath, true);
543
+ result = fragment.childCurve.fractionToPointAnd2Derivatives(childFraction, result);
544
544
  if (!result)
545
545
  return undefined;
546
- // See fractionToPointAndDerivative for derivation of d/df(C(t(f)))=L C'/||C'||.
547
- // For the 2nd deriv, use quotient rule, d/dt||x(t)||=x.x'/||x|| and ||x||^2=x.x :
548
- // d/df(C'(t(f))) = L d/df(C'/||C'||)
549
- // = L (||C'|| d/df(C') - C' d/df||C'||) / ||C'||^2
546
+ // See fractionToPointAndDerivative, where we show d/df(C(t(f))) = L C'/||C'||.
547
+ // Here we seek the 2nd derivative. We'll use the quotient rule, and the identities
548
+ // d/dt||x(t)|| = x.x'/||x|| and ||x||^2 = x.x, where "." is the dot product.
549
+ // d2/df2(C(t(f))) = L d/df(C'/||C'||) = L (||C'|| d/df(C') - C' d/df||C'||) / ||C'||^2
550
550
  // = L (||C'|| C" L/||C'|| - C' C'.C"/||C'|| L/||C'||) / ||C'||^2
551
- // = (L/||C'||)^2 (C" - C' C'.C"/C'.C' )
552
- // We have C' and C" from the fragment.
553
- const magU = result.vectorU.magnitude();
554
- const dotUU = magU * magU;
555
- const dotUV = result.vectorU.dotProduct(result.vectorV);
556
- result.vectorV.addScaledInPlace(result.vectorU, -dotUV / dotUU);
557
- const scale = this._totalLength / magU;
558
- result.vectorU.scaleInPlace(scale);
559
- result.vectorV.scaleInPlace(scale * scale);
551
+ // = (L/||C'||)^2 (C" - C' C'.C"/C'.C' ), where C' and C" are given by the fragment.
552
+ // The second derivative that fractionToPointAnd2Derivatives returns is C", so the second
553
+ // derivative we seek is just few scales away.
554
+ // Math details can be found at core/geometry/internaldocs/Curve.md
555
+ const magU = result.vectorU.magnitude(); // ||C'||
556
+ const dotUU = magU * magU; // ||C'||^2
557
+ const dotUV = result.vectorU.dotProduct(result.vectorV); // C'.C"
558
+ result.vectorV.addScaledInPlace(result.vectorU, -dotUV / dotUU); // add -(C'*C'.C")/(||C'||^2) to vectorV
559
+ const scale = this._totalLength / magU; // L/||C'||
560
+ result.vectorU.scaleInPlace(scale); // scale vectorU by L/||C'||
561
+ result.vectorV.scaleInPlace(scale * scale); // scale vectorV by (L/||C'(t)||)^2
560
562
  return result;
561
563
  }
562
564
  /**
563
565
  * Attempt to transform in place.
564
- * * Warning: If any child fails, this object becomes invalid. But that should never happen.
566
+ * * Warning: If any child transform fails, `this` object becomes invalid but that should never happen.
567
+ * @param transform the transform to be applied.
568
+ * @returns true if all of child transforms succeed and false otherwise.
565
569
  */
566
570
  tryTransformInPlace(transform) {
567
571
  let numFail = 0;
@@ -574,48 +578,45 @@ class CurveChainWithDistanceIndex extends CurvePrimitive_1.CurvePrimitive {
574
578
  /** Reverse the curve's data so that its fractional stroking moves in the opposite direction. */
575
579
  reverseInPlace() {
576
580
  this._path.reverseChildrenInPlace();
577
- const totalLength = this._totalLength;
578
581
  for (const fragment of this._fragments) {
579
- fragment.reverseFractionsAndDistances(totalLength);
582
+ fragment.reverseFractionsAndDistances(this._totalLength);
580
583
  }
581
584
  this._fragments.reverse();
582
585
  }
583
586
  /**
584
- * Test for equality conditions:
585
- * * Mismatched totalLength is a quick exit condition
586
- * * If totalLength matches, recurse to the path for matching primitives.
587
- * @param other
587
+ * Test for equality conditions.
588
+ * * Mismatched total length is a quick exit condition.
589
+ * * If total length matches, recurse to the path for matching primitives.
588
590
  */
589
591
  isAlmostEqual(other) {
590
592
  if (other instanceof CurveChainWithDistanceIndex) {
591
- return Geometry_1.Geometry.isSameCoordinate(this._totalLength, other._totalLength)
592
- && this._path.isAlmostEqual(other._path);
593
+ return Geometry_1.Geometry.isSameCoordinate(this._totalLength, other._totalLength) && this._path.isAlmostEqual(other._path);
593
594
  }
594
595
  return false;
595
596
  }
596
597
  /**
597
- * Implement moveSignedDistanceFromFraction.
598
- * * See `CurvePrimitive` for parameter details.
599
- * * The returned location directly identifies fractional position along the CurveChainWithDistanceIndex, and
598
+ * (Attempt to) find a position on the curve at a signed distance from start fraction.
599
+ * * See `CurvePrimitive.moveSignedDistanceFromFraction` for parameter details.
600
+ * * The returned location directly identifies fractional position along the CurveChainWithDistanceIndex and
600
601
  * has pointer to an additional detail for the child curve.
601
602
  */
602
603
  moveSignedDistanceFromFraction(startFraction, signedDistance, allowExtension, result) {
603
604
  const distanceA = startFraction * this._totalLength;
604
605
  const distanceB = distanceA + signedDistance;
605
606
  const fragmentB = this.chainDistanceToFragment(distanceB, true);
606
- const childDetail = fragmentB.childCurve.moveSignedDistanceFromFraction(fragmentB.childFraction0, distanceB - fragmentB.chainDistance0, allowExtension, result);
607
+ const childDetail = fragmentB.childCurve.moveSignedDistanceFromFraction(fragmentB.childFraction0, distanceB - fragmentB.chainDistance0, allowExtension, result); // local detail related to the child curve
607
608
  const endFraction = startFraction + (signedDistance / this._totalLength);
608
- const chainDetail = CurveLocationDetail_1.CurveLocationDetail.createConditionalMoveSignedDistance(allowExtension, this, startFraction, endFraction, signedDistance, result);
609
+ const chainDetail = CurveLocationDetail_1.CurveLocationDetail.createConditionalMoveSignedDistance(allowExtension, this, startFraction, endFraction, signedDistance, result); // global detail related to the curve chain
609
610
  chainDetail.childDetail = childDetail;
610
611
  return chainDetail;
611
612
  }
612
613
  /**
614
+ * Return an object summarizing closest point test counts.
613
615
  * The returned object has
614
616
  * * numCalls = number of times closestPoint was called.
615
- * * numCurvesTested = number of curves tested with full closestPoint
616
- * * numAssigned = number of times a new minimum value was recorded
617
+ * * numCurvesTested = number of curves tested with full closestPoint.
618
+ * * numAssigned = number of times a new minimum value was recorded.
617
619
  * * numCandidate = number of curves that would be tested in worst case.
618
- * return an object summarizing closest point test counts
619
620
  * @param clear if true, counts are cleared after the return object is formed.
620
621
  */
621
622
  static getClosestPointTestCounts(clear = true) {
@@ -632,13 +633,13 @@ class CurveChainWithDistanceIndex extends CurvePrimitive_1.CurvePrimitive {
632
633
  }
633
634
  /**
634
635
  * Search for the curve point that is closest to the spacePoint.
635
- * * The CurveChainWithDistanceIndex invokes the base class CurvePrimitive method, which
636
- * (via a handler) determines a CurveLocation detail among the children.
637
- * * The returned detail directly identifies fractional position along the CurveChainWithDistanceIndex, and
636
+ * * The CurveChainWithDistanceIndex invokes the base class CurvePrimitive method, which (via a handler)
637
+ * determines a CurveLocation detail among the children.
638
+ * * The returned detail directly identifies fractional position along the CurveChainWithDistanceIndex and
638
639
  * has pointer to an additional detail for the child curve.
639
640
  * @param spacePoint point in space
640
641
  * @param extend true to extend the curve
641
- * @returns Returns a CurveLocationDetail structure that holds the details of the close point.
642
+ * @returns a CurveLocationDetail structure that holds the details of the close point.
642
643
  */
643
644
  closestPoint(spacePoint, extend) {
644
645
  let childDetail;
@@ -649,44 +650,43 @@ class CurveChainWithDistanceIndex extends CurvePrimitive_1.CurvePrimitive {
649
650
  }
650
651
  else {
651
652
  const sortedFragments = PathFragment.collectSortedQuickMinDistances(this._fragments, spacePoint);
652
- const extend0 = [CurveExtendMode_1.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 0), CurveExtendMode_1.CurveExtendMode.None];
653
- const extend1 = [CurveExtendMode_1.CurveExtendMode.None, CurveExtendMode_1.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 1)];
653
+ const extend0 = [
654
+ CurveExtendMode_1.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 0),
655
+ CurveExtendMode_1.CurveExtendMode.None,
656
+ ];
657
+ const extend1 = [
658
+ CurveExtendMode_1.CurveExtendMode.None,
659
+ CurveExtendMode_1.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 1),
660
+ ];
654
661
  const fragment0 = this._fragments[0];
655
662
  const fragment1 = this._fragments[this._fragments.length - 1];
656
663
  CurveChainWithDistanceIndex._numCalls++;
657
664
  CurveChainWithDistanceIndex._numCandidate += sortedFragments.length;
658
- for (const f of sortedFragments) {
659
- if (f.a > aMin)
665
+ let detailA;
666
+ for (const sortedFragment of sortedFragments) {
667
+ if (sortedFragment.a > aMin)
668
+ // sortedFragments help early exit because it is likely that one of the first few fragments
669
+ // in sortedFragments is the fragment with minimum distance from space point to the curve.
660
670
  break;
661
671
  CurveChainWithDistanceIndex._numTested++;
662
- const child = f.childCurve;
663
- const detailA = child.closestPoint(spacePoint, f === fragment0 ? extend0 : f === fragment1 ? extend1 : false);
672
+ const child = sortedFragment.childCurve;
673
+ detailA = child.closestPoint(spacePoint, sortedFragment === fragment0 ? extend0 : sortedFragment === fragment1 ? extend1 : false, detailA);
664
674
  if (detailA && detailA.a < aMin) {
665
675
  aMin = detailA.a;
666
- childDetail = CurveLocationDetail_1.CurveLocationDetail.createCurveFractionPoint(detailA.curve, detailA.fraction, detailA.point, childDetail);
667
- childDetail.a = detailA.a;
676
+ childDetail = detailA.clone(childDetail);
668
677
  CurveChainWithDistanceIndex._numAssigned++;
669
678
  }
670
679
  }
671
680
  }
672
681
  if (!childDetail)
673
682
  return undefined;
674
- const fragment = this.curveAndChildFractionToFragment(childDetail.curve, childDetail.fraction);
675
- if (fragment) {
676
- const chainDistance = fragment.childFractionToChainDistance(childDetail.fraction);
677
- const chainFraction = this.chainDistanceToChainFraction(chainDistance);
678
- const chainDetail = CurveLocationDetail_1.CurveLocationDetail.createCurveFractionPoint(this, chainFraction, childDetail.point);
679
- chainDetail.childDetail = childDetail;
680
- chainDetail.a = childDetail.a;
681
- return chainDetail;
682
- }
683
- return undefined;
683
+ return this.computeChainDetail(childDetail);
684
684
  }
685
685
  /**
686
686
  * Construct an offset of each child as viewed in the xy-plane (ignoring z).
687
- * * No attempt is made to join the offset children. Use RegionOps.constructCurveXYOffset() to return a fully
687
+ * * No attempt is made to join the offset children. Use RegionOps.constructCurveXYOffset to return a fully
688
688
  * joined offset.
689
- * @param offsetDistanceOrOptions offset distance (positive to left of the instance curve), or options object
689
+ * @param offsetDistanceOrOptions offset distance (positive to left of the instance curve) or offset options object.
690
690
  */
691
691
  constructOffsetXY(offsetDistanceOrOptions) {
692
692
  const options = OffsetOptions_1.OffsetOptions.create(offsetDistanceOrOptions);
@@ -706,13 +706,32 @@ class CurveChainWithDistanceIndex extends CurvePrimitive_1.CurvePrimitive {
706
706
  * Project instance geometry (via dispatch) onto the given ray, and return the extreme fractional parameters of
707
707
  * projection.
708
708
  * @param ray ray onto which the instance is projected. A `Vector3d` is treated as a `Ray3d` with zero origin.
709
- * @param lowHigh optional receiver for output
709
+ * @param lowHigh optional receiver for output.
710
710
  * @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the
711
711
  * end of the ray.
712
712
  */
713
713
  projectedParameterRange(ray, lowHigh) {
714
714
  return PlaneAltitudeRangeContext_1.PlaneAltitudeRangeContext.findExtremeFractionsAlongDirection(this, ray, lowHigh);
715
715
  }
716
+ /**
717
+ * Compute the global chain detail corresponding to a local child detail.
718
+ * @param childDetail the local detail, with respect to a child of this chain.
719
+ * @returns the global detail, with respect to this chain.
720
+ */
721
+ computeChainDetail(childDetail) {
722
+ if (!childDetail.curve)
723
+ return undefined;
724
+ const fragment = this.curveAndChildFractionToFragment(childDetail.curve, childDetail.fraction);
725
+ if (fragment) {
726
+ const chainDistance = fragment.childFractionToChainDistance(childDetail.fraction);
727
+ const chainFraction = this.chainDistanceToChainFraction(chainDistance);
728
+ const chainDetail = CurveLocationDetail_1.CurveLocationDetail.createCurveFractionPoint(this, chainFraction, childDetail.point);
729
+ chainDetail.childDetail = childDetail;
730
+ chainDetail.a = childDetail.a;
731
+ return chainDetail;
732
+ }
733
+ return undefined;
734
+ }
716
735
  }
717
736
  CurveChainWithDistanceIndex._numCalls = 0;
718
737
  CurveChainWithDistanceIndex._numTested = 0;