@itwin/core-geometry 4.0.0-dev.23 → 4.0.0-dev.28

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 (204) hide show
  1. package/CHANGELOG.md +7 -2
  2. package/lib/cjs/Geometry.d.ts +23 -0
  3. package/lib/cjs/Geometry.d.ts.map +1 -1
  4. package/lib/cjs/Geometry.js +25 -1
  5. package/lib/cjs/Geometry.js.map +1 -1
  6. package/lib/cjs/bspline/BSplineCurveOps.js +4 -5
  7. package/lib/cjs/bspline/BSplineCurveOps.js.map +1 -1
  8. package/lib/cjs/bspline/InterpolationCurve3d.js +7 -10
  9. package/lib/cjs/bspline/InterpolationCurve3d.js.map +1 -1
  10. package/lib/cjs/clipping/ClipPrimitive.js +2 -2
  11. package/lib/cjs/clipping/ClipPrimitive.js.map +1 -1
  12. package/lib/cjs/clipping/ClipUtils.js +4 -4
  13. package/lib/cjs/clipping/ClipUtils.js.map +1 -1
  14. package/lib/cjs/clipping/internalContexts/LineStringOffsetClipperContext.js +2 -2
  15. package/lib/cjs/clipping/internalContexts/LineStringOffsetClipperContext.js.map +1 -1
  16. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +1 -1
  17. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  18. package/lib/cjs/curve/CurveCollection.js +1 -1
  19. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  20. package/lib/cjs/curve/StrokeOptions.js +1 -2
  21. package/lib/cjs/curve/StrokeOptions.js.map +1 -1
  22. package/lib/cjs/curve/spiral/DirectSpiral3d.js +1 -2
  23. package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
  24. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js +1 -2
  25. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  26. package/lib/cjs/geometry3d/BarycentricTriangle.d.ts +195 -8
  27. package/lib/cjs/geometry3d/BarycentricTriangle.d.ts.map +1 -1
  28. package/lib/cjs/geometry3d/BarycentricTriangle.js +459 -11
  29. package/lib/cjs/geometry3d/BarycentricTriangle.js.map +1 -1
  30. package/lib/cjs/geometry3d/GrowableFloat64Array.js +2 -2
  31. package/lib/cjs/geometry3d/GrowableFloat64Array.js.map +1 -1
  32. package/lib/cjs/geometry3d/GrowableXYArray.d.ts +1 -1
  33. package/lib/cjs/geometry3d/GrowableXYArray.d.ts.map +1 -1
  34. package/lib/cjs/geometry3d/GrowableXYArray.js +2 -2
  35. package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
  36. package/lib/cjs/geometry3d/GrowableXYZArray.js +1 -1
  37. package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
  38. package/lib/cjs/geometry3d/IndexedXYCollection.d.ts +22 -7
  39. package/lib/cjs/geometry3d/IndexedXYCollection.d.ts.map +1 -1
  40. package/lib/cjs/geometry3d/IndexedXYCollection.js +41 -5
  41. package/lib/cjs/geometry3d/IndexedXYCollection.js.map +1 -1
  42. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +58 -4
  43. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  44. package/lib/cjs/geometry3d/IndexedXYZCollection.js +102 -4
  45. package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
  46. package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts +10 -0
  47. package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
  48. package/lib/cjs/geometry3d/Point2dArrayCarrier.js +14 -0
  49. package/lib/cjs/geometry3d/Point2dArrayCarrier.js.map +1 -1
  50. package/lib/cjs/geometry3d/Point2dVector2d.js +4 -6
  51. package/lib/cjs/geometry3d/Point2dVector2d.js.map +1 -1
  52. package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts +0 -6
  53. package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  54. package/lib/cjs/geometry3d/Point3dArrayCarrier.js +0 -6
  55. package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
  56. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +1 -1
  57. package/lib/cjs/geometry3d/Point3dVector3d.js +6 -8
  58. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  59. package/lib/cjs/geometry3d/PointHelpers.d.ts +14 -1
  60. package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
  61. package/lib/cjs/geometry3d/PointHelpers.js +33 -1
  62. package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
  63. package/lib/cjs/geometry3d/PolygonOps.d.ts +120 -10
  64. package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
  65. package/lib/cjs/geometry3d/PolygonOps.js +413 -13
  66. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  67. package/lib/cjs/geometry3d/Ray3d.js +1 -1
  68. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  69. package/lib/cjs/polyface/AuxData.js +1 -1
  70. package/lib/cjs/polyface/AuxData.js.map +1 -1
  71. package/lib/cjs/polyface/FacetLocationDetail.d.ts +264 -0
  72. package/lib/cjs/polyface/FacetLocationDetail.d.ts.map +1 -0
  73. package/lib/cjs/polyface/FacetLocationDetail.js +376 -0
  74. package/lib/cjs/polyface/FacetLocationDetail.js.map +1 -0
  75. package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts +2 -5
  76. package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
  77. package/lib/cjs/polyface/IndexedPolyfaceVisitor.js +5 -2
  78. package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
  79. package/lib/cjs/polyface/PolyfaceBuilder.d.ts +20 -14
  80. package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
  81. package/lib/cjs/polyface/PolyfaceBuilder.js +21 -17
  82. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  83. package/lib/cjs/polyface/PolyfaceClip.js +6 -7
  84. package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
  85. package/lib/cjs/polyface/PolyfaceData.d.ts +1 -1
  86. package/lib/cjs/polyface/PolyfaceData.d.ts.map +1 -1
  87. package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
  88. package/lib/cjs/polyface/PolyfaceQuery.d.ts +22 -1
  89. package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
  90. package/lib/cjs/polyface/PolyfaceQuery.js +52 -2
  91. package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
  92. package/lib/cjs/serialization/BGFBReader.js +4 -4
  93. package/lib/cjs/serialization/BGFBReader.js.map +1 -1
  94. package/lib/cjs/serialization/IModelJsonSchema.js +1 -2
  95. package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
  96. package/lib/cjs/solid/Sphere.d.ts +5 -5
  97. package/lib/cjs/solid/Sphere.js +5 -5
  98. package/lib/cjs/solid/Sphere.js.map +1 -1
  99. package/lib/cjs/solid/SweepContour.js +1 -1
  100. package/lib/cjs/solid/SweepContour.js.map +1 -1
  101. package/lib/cjs/topology/Triangulation.js +1 -1
  102. package/lib/cjs/topology/Triangulation.js.map +1 -1
  103. package/lib/esm/Geometry.d.ts +23 -0
  104. package/lib/esm/Geometry.d.ts.map +1 -1
  105. package/lib/esm/Geometry.js +24 -0
  106. package/lib/esm/Geometry.js.map +1 -1
  107. package/lib/esm/bspline/BSplineCurveOps.js +4 -5
  108. package/lib/esm/bspline/BSplineCurveOps.js.map +1 -1
  109. package/lib/esm/bspline/InterpolationCurve3d.js +7 -10
  110. package/lib/esm/bspline/InterpolationCurve3d.js.map +1 -1
  111. package/lib/esm/clipping/ClipPrimitive.js +2 -2
  112. package/lib/esm/clipping/ClipPrimitive.js.map +1 -1
  113. package/lib/esm/clipping/ClipUtils.js +4 -4
  114. package/lib/esm/clipping/ClipUtils.js.map +1 -1
  115. package/lib/esm/clipping/internalContexts/LineStringOffsetClipperContext.js +2 -2
  116. package/lib/esm/clipping/internalContexts/LineStringOffsetClipperContext.js.map +1 -1
  117. package/lib/esm/curve/CurveChainWithDistanceIndex.js +1 -1
  118. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  119. package/lib/esm/curve/CurveCollection.js +1 -1
  120. package/lib/esm/curve/CurveCollection.js.map +1 -1
  121. package/lib/esm/curve/StrokeOptions.js +1 -2
  122. package/lib/esm/curve/StrokeOptions.js.map +1 -1
  123. package/lib/esm/curve/spiral/DirectSpiral3d.js +1 -2
  124. package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
  125. package/lib/esm/curve/spiral/IntegratedSpiral3d.js +1 -2
  126. package/lib/esm/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  127. package/lib/esm/geometry3d/BarycentricTriangle.d.ts +195 -8
  128. package/lib/esm/geometry3d/BarycentricTriangle.d.ts.map +1 -1
  129. package/lib/esm/geometry3d/BarycentricTriangle.js +459 -12
  130. package/lib/esm/geometry3d/BarycentricTriangle.js.map +1 -1
  131. package/lib/esm/geometry3d/GrowableFloat64Array.js +2 -2
  132. package/lib/esm/geometry3d/GrowableFloat64Array.js.map +1 -1
  133. package/lib/esm/geometry3d/GrowableXYArray.d.ts +1 -1
  134. package/lib/esm/geometry3d/GrowableXYArray.d.ts.map +1 -1
  135. package/lib/esm/geometry3d/GrowableXYArray.js +2 -2
  136. package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
  137. package/lib/esm/geometry3d/GrowableXYZArray.js +1 -1
  138. package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
  139. package/lib/esm/geometry3d/IndexedXYCollection.d.ts +22 -7
  140. package/lib/esm/geometry3d/IndexedXYCollection.d.ts.map +1 -1
  141. package/lib/esm/geometry3d/IndexedXYCollection.js +41 -5
  142. package/lib/esm/geometry3d/IndexedXYCollection.js.map +1 -1
  143. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +58 -4
  144. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  145. package/lib/esm/geometry3d/IndexedXYZCollection.js +103 -5
  146. package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
  147. package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts +10 -0
  148. package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
  149. package/lib/esm/geometry3d/Point2dArrayCarrier.js +14 -0
  150. package/lib/esm/geometry3d/Point2dArrayCarrier.js.map +1 -1
  151. package/lib/esm/geometry3d/Point2dVector2d.js +4 -6
  152. package/lib/esm/geometry3d/Point2dVector2d.js.map +1 -1
  153. package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts +0 -6
  154. package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  155. package/lib/esm/geometry3d/Point3dArrayCarrier.js +0 -6
  156. package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
  157. package/lib/esm/geometry3d/Point3dVector3d.d.ts +1 -1
  158. package/lib/esm/geometry3d/Point3dVector3d.js +6 -8
  159. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  160. package/lib/esm/geometry3d/PointHelpers.d.ts +14 -1
  161. package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
  162. package/lib/esm/geometry3d/PointHelpers.js +33 -1
  163. package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
  164. package/lib/esm/geometry3d/PolygonOps.d.ts +120 -10
  165. package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
  166. package/lib/esm/geometry3d/PolygonOps.js +412 -13
  167. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  168. package/lib/esm/geometry3d/Ray3d.js +1 -1
  169. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  170. package/lib/esm/polyface/AuxData.js +1 -1
  171. package/lib/esm/polyface/AuxData.js.map +1 -1
  172. package/lib/esm/polyface/FacetLocationDetail.d.ts +264 -0
  173. package/lib/esm/polyface/FacetLocationDetail.d.ts.map +1 -0
  174. package/lib/esm/polyface/FacetLocationDetail.js +369 -0
  175. package/lib/esm/polyface/FacetLocationDetail.js.map +1 -0
  176. package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts +2 -5
  177. package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
  178. package/lib/esm/polyface/IndexedPolyfaceVisitor.js +5 -2
  179. package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
  180. package/lib/esm/polyface/PolyfaceBuilder.d.ts +20 -14
  181. package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
  182. package/lib/esm/polyface/PolyfaceBuilder.js +21 -17
  183. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  184. package/lib/esm/polyface/PolyfaceClip.js +6 -7
  185. package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
  186. package/lib/esm/polyface/PolyfaceData.d.ts +1 -1
  187. package/lib/esm/polyface/PolyfaceData.d.ts.map +1 -1
  188. package/lib/esm/polyface/PolyfaceData.js.map +1 -1
  189. package/lib/esm/polyface/PolyfaceQuery.d.ts +22 -1
  190. package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
  191. package/lib/esm/polyface/PolyfaceQuery.js +52 -2
  192. package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
  193. package/lib/esm/serialization/BGFBReader.js +4 -4
  194. package/lib/esm/serialization/BGFBReader.js.map +1 -1
  195. package/lib/esm/serialization/IModelJsonSchema.js +1 -2
  196. package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
  197. package/lib/esm/solid/Sphere.d.ts +5 -5
  198. package/lib/esm/solid/Sphere.js +5 -5
  199. package/lib/esm/solid/Sphere.js.map +1 -1
  200. package/lib/esm/solid/SweepContour.js +1 -1
  201. package/lib/esm/solid/SweepContour.js.map +1 -1
  202. package/lib/esm/topology/Triangulation.js +1 -1
  203. package/lib/esm/topology/Triangulation.js.map +1 -1
  204. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"CurveChainWithDistanceIndex.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I,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAC/C,IAAI,MAAM,KAAK,SAAS,EAAE;gBACxB,IAAI,MAAM,YAAY,+BAAc;oBAClC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;qBAClB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;oBAC5B,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;aAC5C;SACF;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACa,uBAAuB,CAAC,GAAqB,EAAE,OAAiB;QAC9E,OAAO,qDAAyB,CAAC,kCAAkC,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1F,CAAC;;AAjhBH,kEAkhBC;AApFgB,qCAAS,GAAG,CAAC,CAAC;AACd,sCAAU,GAAG,CAAC,CAAC;AACf,wCAAY,GAAG,CAAC,CAAC;AACjB,yCAAa,GAAG,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Curve\n */\n\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\nimport { StrokeCountMap } from \"../curve/Query/StrokeCountMap\";\nimport { Geometry } from \"../Geometry\";\nimport { GeometryHandler, IStrokeHandler } from \"../geometry3d/GeometryHandler\";\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\nimport { Plane3dByOriginAndVectors } from \"../geometry3d/Plane3dByOriginAndVectors\";\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\nimport { Range1d, Range3d } from \"../geometry3d/Range\";\nimport { Ray3d } from \"../geometry3d/Ray3d\";\nimport { Transform } from \"../geometry3d/Transform\";\nimport { CurveChain } from \"./CurveCollection\";\nimport { CurveExtendMode, CurveExtendOptions, VariantCurveExtendParameter } from \"./CurveExtendMode\";\nimport { CurveLocationDetail } from \"./CurveLocationDetail\";\nimport { GeometryQuery } from \"./GeometryQuery\";\nimport { PlaneAltitudeRangeContext } from \"./internalContexts/PlaneAltitudeRangeContext\";\nimport { OffsetOptions } from \"./internalContexts/PolygonOffsetContext\";\nimport { LineString3d } from \"./LineString3d\";\nimport { Path } from \"./Path\";\nimport { StrokeOptions } from \"./StrokeOptions\";\n\n/**\n * * Annotation of an interval of a curve.\n * * The interval is marked with two pairs of numbers:\n * * * fraction0, fraction1 = fraction parameters along the child curve\n * * * distance0,distance1 = distances within containing CurveChainWithDistanceIndex\n * @public\n */\nexport class PathFragment {\n /** distance along parent to this fragment start */\n public chainDistance0: number;\n /** distance along parent to this fragment end */\n public chainDistance1: number;\n /** Fractional position of this fragment start within its curve primitive. */\n public childFraction0: number;\n /** Fractional position of this fragment end within its curve primitive.. */\n public childFraction1: number;\n /** Curve primitive of this fragment, as presented in stroker. Note that this might have become a proxy. */\n public childCurve: CurvePrimitive;\n /** optional range */\n public range?: Range3d;\n /** working var for use in searches. */\n public a: number;\n /** Create a fragment with complete fraction, distance and child data. */\n public constructor(childFraction0: number, childFraction1: number, distance0: number, distance1: number, childCurve: CurvePrimitive,\n range?: Range3d) {\n this.childFraction0 = childFraction0;\n this.childFraction1 = childFraction1;\n this.chainDistance0 = distance0;\n this.chainDistance1 = distance1;\n this.childCurve = childCurve;\n this.range = range;\n this.a = 0;\n }\n /**\n * Return true if the distance is within the distance limits of this fragment.\n * @param distance\n */\n public containsChainDistance(distance: number): boolean {\n return distance >= this.chainDistance0 && distance <= this.chainDistance1;\n }\n // Return a quick distance to the curve. This may be SMALLER than true distance but may\n // not be larger.\n public quickMinDistanceToChildCurve(spacePoint: Point3d): number {\n if (this.range) {\n return this.range.distanceToPoint(spacePoint);\n }\n // ugh. have to do real computation ..\n const detail = this.childCurve.closestPoint(spacePoint, false);\n if (detail)\n return detail.a;\n return 0;\n }\n // Return an array with (references to) all the path fragments, sorted smallest to largest on\n // the \"a\" value equal to the quick min distance to the fragment\n public static collectSortedQuickMinDistances(fragments: PathFragment[], spacePoint: Point3d): PathFragment[] {\n const sortedFragments: PathFragment[] = [];\n for (const f of fragments) {\n f.a = f.quickMinDistanceToChildCurve(spacePoint);\n sortedFragments.push(f);\n }\n sortedFragments.sort((a: PathFragment, b: PathFragment) => a.a - b.a);\n return sortedFragments;\n }\n /**\n * Return true if this fragment addresses `curve` and brackets `fraction`\n * @param distance\n */\n public containsChildCurveAndChildFraction(curve: CurvePrimitive, fraction: number): boolean {\n return this.childCurve === curve && fraction >= this.childFraction0 && fraction <= this.childFraction1;\n }\n\n /** Convert distance to local fraction, and apply that to interpolate between the stored curve fractions.\n * Note that proportional calculation does NOT account for nonuniform parameterization in the child curve.\n */\n public chainDistanceToInterpolatedChildFraction(distance: number): number {\n return Geometry.inverseInterpolate(\n this.childFraction0, this.chainDistance0,\n this.childFraction1, this.chainDistance1,\n distance, this.childFraction0)!; // the interval \"must\" have nonzero length, division should be safe . ..\n }\n /** Convert chainDistance to true chidFraction, using detailed moveSignedDistanceFromFraction\n */\n public chainDistanceToAccurateChildFraction(chainDistance: number, allowExtrapolation?: boolean): number {\n // The fragments are really expected to do good mappings in their distance range ...\n const childDetail = this.childCurve.moveSignedDistanceFromFraction(\n this.childFraction0, chainDistance - this.chainDistance0, allowExtrapolation ?? false);\n return childDetail.fraction;\n }\n /** Return the scale factor to map childCurve fraction derivatives to chain fraction derivatives\n * @param globalDistance total length of the global curve.\n */\n public fractionScaleFactor(globalDistance: number): number {\n return globalDistance * (this.childFraction1 - this.childFraction0) / (this.chainDistance1 - this.chainDistance0);\n }\n /** Reverse the fraction and distance data.\n * * each child fraction `f` is replaced by `1-f`\n * * each `chainDistance` is replaced by `totalDistance-chainDistance`\n */\n public reverseFractionsAndDistances(totalDistance: number) {\n const f0 = this.childFraction0;\n const f1 = this.childFraction1;\n const d0 = this.chainDistance0;\n const d1 = this.chainDistance1;\n this.childFraction0 = 1.0 - f1;\n this.childFraction1 = 1.0 - f0;\n this.chainDistance0 = totalDistance - d1;\n this.chainDistance1 = totalDistance - d0;\n }\n /** @deprecated in 3.x. Use childFractionToChainDistance */\n public childFractionTChainDistance(fraction: number): number {\n return this.childFractionToChainDistance(fraction);\n }\n /**\n * convert a fractional position on the childCurve to distance in the chain space.\n * * Return value is SIGNED -- will be negative when fraction < this.childFraction0.\n * @param fraction fraction along the curve within this fragment\n */\n public childFractionToChainDistance(fraction: number): number {\n let d = this.childCurve.curveLengthBetweenFractions(this.childFraction0, fraction);\n if (fraction < this.childFraction0)\n d = -d;\n return this.chainDistance0 + d;\n }\n}\n/** Non-instantiable class to build a distance index for a path. */\nclass DistanceIndexConstructionContext implements IStrokeHandler {\n private _fragments: PathFragment[];\n private _accumulatedDistance: number;\n private constructor() {\n this._accumulatedDistance = 0;\n this._fragments = [];\n }\n // ignore curve announcements -- they are repeated in stroke announcements\n public startParentCurvePrimitive(_cp: CurvePrimitive) { }\n public startCurvePrimitive(_cp: CurvePrimitive) { }\n public endParentCurvePrimitive(_cp: CurvePrimitive) { }\n public endCurvePrimitive(_cp: CurvePrimitive) { }\n // um .. we need to see curves? how to reject?\n public announcePointTangent(_xyz: Point3d, _fraction: number, _tangent: Vector3d) { }\n /** Announce numPoints interpolated between point0 and point1, with associated fractions */\n public announceSegmentInterval(\n cp: CurvePrimitive,\n point0: Point3d,\n point1: Point3d,\n numStrokes: number,\n fraction0: number,\n fraction1: number): void {\n const fragmentPoint0 = point0.clone();\n const fragmentPoint1 = point1.clone();\n let d0 = this._accumulatedDistance;\n if (numStrokes <= 1) {\n this._accumulatedDistance += point0.distance(point1);\n this._fragments.push(new PathFragment(fraction0, fraction1, d0, this._accumulatedDistance, cp,\n Range3d.create(fragmentPoint0, fragmentPoint1)));\n } else {\n let f1;\n for (let i = 1, f0 = fraction0; i <= numStrokes; i++, f0 = f1) {\n f1 = Geometry.interpolate(fraction0, i / numStrokes, fraction1);\n point0.interpolate(f1, point1, fragmentPoint1);\n d0 = this._accumulatedDistance;\n this._accumulatedDistance += (Math.abs(f1 - f0) * point0.distance(point1));\n this._fragments.push(new PathFragment(f0, f1, d0, this._accumulatedDistance, cp,\n Range3d.create(fragmentPoint0, fragmentPoint1)));\n fragmentPoint0.setFrom(fragmentPoint1);\n }\n }\n }\n public announceIntervalForUniformStepStrokes(\n cp: CurvePrimitive,\n numStrokes: number,\n fraction0: number,\n fraction1: number): void {\n let f1, d, d0;\n for (let i = 1, f0 = fraction0; i <= numStrokes; i++, f0 = f1) {\n f1 = Geometry.interpolate(fraction0, i / numStrokes, fraction1);\n d = cp.curveLengthBetweenFractions(f0, f1);\n d0 = this._accumulatedDistance;\n this._accumulatedDistance += d;\n const range = cp.rangeBetweenFractions(f0, f1);\n this._fragments.push(new PathFragment(f0, f1, d0, this._accumulatedDistance, cp, range));\n }\n }\n public needPrimaryGeometryForStrokes?(): boolean { return true; }\n public static createPathFragmentIndex(path: CurveChain, options?: StrokeOptions): PathFragment[] {\n const handler = new DistanceIndexConstructionContext();\n for (const curve of path.children) {\n curve.emitStrokableParts(handler, options);\n }\n const fragments = handler._fragments;\n return fragments;\n }\n}\n/**\n * `CurveChainWithDistanceIndex` is a CurvePrimitive whose fractional parameterization is proportional to true\n * distance along a CurveChain.\n * * The curve chain can be any type derived from CurveChain.\n * * * i.e. either a `Path` or a `Loop`\n * @public\n */\nexport class CurveChainWithDistanceIndex extends CurvePrimitive {\n /** String name for schema properties */\n public readonly curvePrimitiveType = \"curveChainWithDistanceIndex\";\n\n private readonly _path: CurveChain;\n private readonly _fragments: PathFragment[];\n private readonly _totalLength: number; // matches final fragment distance1.\n /** Test if other is a `CurveChainWithDistanceIndex` */\n public isSameGeometryClass(other: GeometryQuery): boolean { return other instanceof CurveChainWithDistanceIndex; }\n // final assembly of CurveChainWithDistanceIndex -- caller must create valid fragment index.\n private constructor(path: CurveChain, fragments: PathFragment[]) {\n super();\n this._path = path;\n this._fragments = fragments;\n this._totalLength = fragments.length > 0 ? fragments[fragments.length - 1].chainDistance1 : 0;\n }\n /**\n * Create a clone, transformed and with its own distance index.\n * @param transform transform to apply in the clone.\n */\n public cloneTransformed(transform: Transform): CurveChainWithDistanceIndex | undefined {\n const c = this._path.clone();\n if (c instanceof CurveChain && c.tryTransformInPlace(transform))\n return CurveChainWithDistanceIndex.createCapture(c);\n return undefined;\n }\n /** Reference to the contained path.\n * * Do not modify the path. The distance index will be wrong.\n */\n public get path(): CurveChain { return this._path; }\n\n /** Reference to the fragments array.\n * * Do not modify.\n */\n public get fragments(): PathFragment[] { return this._fragments; }\n\n /** Return a deep clone */\n public clone(): CurveChainWithDistanceIndex {\n const c = this._path.clone() as CurveChain;\n return CurveChainWithDistanceIndex.createCapture(c);\n }\n\n /** Return a deep clone */\n public override clonePartialCurve(fractionA: number, fractionB: number): CurveChainWithDistanceIndex | undefined {\n if (fractionA === fractionB)\n return undefined;\n let fracA = fractionA;\n let fracB = fractionB;\n const reversed = fractionA > fractionB;\n if (reversed) {\n fracA = fractionB;\n fracB = fractionA;\n }\n const chainDistanceA = fracA * this._totalLength;\n const chainDistanceB = fracB * this._totalLength;\n const fragmentA = this.chainDistanceToFragment(chainDistanceA, true);\n if (undefined === fragmentA)\n return undefined;\n const fragmentB = this.chainDistanceToFragment(chainDistanceB, true);\n if (undefined === fragmentB)\n return undefined;\n const childCurveIndexA = this._path.childIndex(fragmentA.childCurve, true);\n if (undefined === childCurveIndexA)\n return undefined;\n const childCurveIndexB = this._path.childIndex(fragmentB.childCurve, true);\n if (undefined === childCurveIndexB)\n return undefined;\n const childFractionA = fragmentA.chainDistanceToAccurateChildFraction(chainDistanceA, true);\n const childFractionB = fragmentB.chainDistanceToAccurateChildFraction(chainDistanceB, true);\n\n // add a (possibly reversed) partial clone to newPath\n const newPath = Path.create();\n const addPartialChild = (childCurve: CurvePrimitive, childFraction0: number, childFraction1: number, reversedClone: boolean): boolean => {\n if (childFraction0 === childFraction1)\n return false;\n let newCurve;\n if (childFraction0 === 0.0 && childFraction1 === 1.0) {\n newCurve = childCurve.clone();\n if (reversedClone)\n newCurve.reverseInPlace();\n } else {\n newCurve = reversedClone ?\n childCurve.clonePartialCurve(childFraction1, childFraction0)\n : childCurve.clonePartialCurve(childFraction0, childFraction1);\n }\n if (newCurve) {\n newPath.children.push(newCurve);\n return true;\n }\n return false;\n };\n\n if (fragmentA.childCurve === fragmentB.childCurve) {\n // the two distances are within the same curve.\n if (addPartialChild(fragmentA.childCurve, childFractionA, childFractionB, reversed))\n return CurveChainWithDistanceIndex.createCapture(newPath); // singleton -- children[] does not need to be reversed.\n return undefined;\n }\n addPartialChild(this._path.children[childCurveIndexA], childFractionA, 1.0, reversed);\n // at least two distinct children are impacted ....\n for (let childIndex = childCurveIndexA + 1; childIndex < childCurveIndexB; childIndex++) {\n addPartialChild(this._path.children[childIndex], 0.0, 1.0, reversed);\n }\n addPartialChild(this._path.children[childCurveIndexB], 0.0, childFractionB, reversed);\n // This reverses array entries but not orientation within each curve ...\n if (reversed)\n newPath.children.reverse();\n return CurveChainWithDistanceIndex.createCapture(newPath);\n }\n\n /** Ask if the curve is within tolerance of a plane.\n * @returns Returns true if the curve is completely within tolerance of the plane.\n */\n public isInPlane(plane: Plane3dByOriginAndUnitNormal): boolean {\n for (const c of this._path.children) {\n if (!c.isInPlane(plane))\n return false;\n }\n return true;\n }\n\n /** return the start point of the primitive. The default implementation returns fractionToPoint (0.0) */\n public override startPoint(result?: Point3d): Point3d {\n const c = this._path.cyclicCurvePrimitive(0);\n if (c)\n return c.startPoint(result);\n return Point3d.createZero(result);\n }\n /** Return the end point of the primitive. The default implementation returns fractionToPoint(1.0) */\n public override endPoint(result?: Point3d): Point3d {\n const c = this._path.cyclicCurvePrimitive(-1);\n if (c)\n return c.endPoint(result);\n return Point3d.createZero(result);\n }\n /** Add strokes to caller-supplied linestring */\n public emitStrokes(dest: LineString3d, options?: StrokeOptions): void {\n for (const c of this._path.children) {\n c.emitStrokes(dest, options);\n }\n }\n /** Ask the curve to announce points and simple subcurve fragments for stroking.\n * See IStrokeHandler for description of the sequence of the method calls.\n */\n public emitStrokableParts(dest: IStrokeHandler, options?: StrokeOptions): void {\n for (const c of this._path.children) {\n c.emitStrokableParts(dest, options);\n }\n }\n /**\n * return the stroke count required for given options.\n * @param options StrokeOptions that determine count\n */\n public computeStrokeCountForOptions(options?: StrokeOptions): number {\n let numStroke = 0;\n for (const c of this._path.children) {\n numStroke += c.computeStrokeCountForOptions(options);\n }\n return numStroke;\n }\n /**\n * Return an array containing only the curve primitives.\n * * This DEFAULT simply pushes `this` to the collectorArray.\n * * CurvePrimitiveWithDistanceIndex optionally collects its members.\n * @param collectorArray array to receive primitives (pushed -- the array is not cleared)\n * @param smallestPossiblePrimitives if false, CurvePrimitiveWithDistanceIndex returns only itself. If true, it recurses to its (otherwise hidden) children.\n */\n public override collectCurvePrimitivesGo(collectorArray: CurvePrimitive[], smallestPossiblePrimitives: boolean = false, explodeLineStrings: boolean = false) {\n if (smallestPossiblePrimitives) {\n for (const c of this._path.children) {\n c.collectCurvePrimitivesGo(collectorArray, smallestPossiblePrimitives, explodeLineStrings);\n }\n } else {\n collectorArray.push(this);\n }\n }\n\n /**\n * construct StrokeCountMap for each child, accumulating data to stroke count map for this primitive.\n * @param options StrokeOptions that determine count\n * @param parentStrokeMap evolving parent map.\n */\n public override computeAndAttachRecursiveStrokeCounts(options?: StrokeOptions, parentStrokeMap?: StrokeCountMap) {\n const myMap = StrokeCountMap.createWithCurvePrimitiveAndOptionalParent(this, parentStrokeMap);\n for (const c of this._path.children) {\n c.computeAndAttachRecursiveStrokeCounts(options, myMap);\n }\n CurvePrimitive.installStrokeCountMap(this, myMap, parentStrokeMap);\n }\n /** Second step of double dispatch: call `this._path.dispatchToGeometryHandler (handler)`\n * * Note that this exposes the children individually to the handler.\n */\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\n return this._path.dispatchToGeometryHandler(handler);\n }\n /** Extend (increase) `rangeToExtend` as needed to include these curves (optionally transformed)\n */\n public extendRange(rangeToExtend: Range3d, transform?: Transform): void {\n this._path.extendRange(rangeToExtend, transform);\n }\n /**\n *\n * * Curve length is always positive.\n * @returns Returns a (high accuracy) length of the curve between fractional positions\n * @returns Returns the length of the curve.\n */\n public override curveLengthBetweenFractions(fraction0: number, fraction1: number): number {\n return Math.abs(fraction1 - fraction0) * this._totalLength;\n }\n /**\n * Capture (not clone) a path into a new `CurveChainWithDistanceIndex`\n * @param path primitive array to be CAPTURED (not cloned)\n */\n public static createCapture(path: CurveChain, options?: StrokeOptions): CurveChainWithDistanceIndex {\n const fragments = DistanceIndexConstructionContext.createPathFragmentIndex(path, options);\n const result = new CurveChainWithDistanceIndex(path, fragments);\n return result;\n }\n\n /**\n * Resolve a fraction of the CurveChain to a PathFragment\n * @param distance\n * @param allowExtrapolation\n */\n public chainDistanceToFragment(distance: number, allowExtrapolation: boolean = false): PathFragment | undefined {\n const i = this.chainDistanceToFragmentIndex(distance, allowExtrapolation);\n if (undefined !== i)\n return this._fragments[i];\n return undefined;\n }\n /**\n * Resolve a fraction of the CurveChain to a PathFragment index\n * @param distance\n * @param allowExtrapolation\n */\n protected chainDistanceToFragmentIndex(distance: number, allowExtrapolation: boolean = false): number | undefined {\n const numFragments = this._fragments.length;\n const fragments = this._fragments;\n if (numFragments > 0) {\n if (distance < 0.0)\n return allowExtrapolation ? 0 : undefined;\n if (distance > this._totalLength)\n return allowExtrapolation ? (numFragments - 1) : undefined;\n // humbug, linear search\n for (let i = 0; i < numFragments; i++) {\n if (fragments[i].containsChainDistance(distance)) return i;\n }\n }\n return undefined;\n }\n\n /**\n * Convert distance along the chain to fraction along the chain.\n * @param distance distance along the chain\n */\n public chainDistanceToChainFraction(distance: number): number { return distance / this._totalLength; }\n /**\n * Resolve a fraction within a specific curve to a fragment.\n * @param curve\n * @param fraction\n */\n public curveAndChildFractionToFragment(curve: CurvePrimitive, fraction: number): PathFragment | undefined {\n const numFragments = this._fragments.length;\n const fragments = this._fragments;\n if (numFragments > 0) {\n // humbug, linear search\n for (const fragment of fragments) {\n if (fragment.containsChildCurveAndChildFraction(curve, fraction))\n return fragment;\n }\n if (fraction <= 0)\n return fragments[0];\n if (fraction > 1.0)\n return fragments[numFragments - 1];\n }\n return undefined;\n }\n\n /**\n * Returns the total length of curves.\n */\n public override curveLength(): number {\n return this._totalLength;\n }\n /**\n * Returns the total length of the path.\n * * This is exact (and simple property lookup) because the true lengths were summed at construction time.\n */\n public quickLength(): number {\n return this._totalLength;\n }\n\n /**\n * Return the point (x,y,z) on the curve at fractional position along the chain.\n * @param fraction fractional position along the geometry.\n * @returns Returns a point on the curve.\n */\n public fractionToPoint(fraction: number, result?: Point3d): Point3d {\n const chainDistance = fraction * this._totalLength;\n const fragment = this.chainDistanceToFragment(chainDistance, true);\n if (fragment) {\n const childFraction = fragment.chainDistanceToAccurateChildFraction(chainDistance, true);\n return fragment.childCurve.fractionToPoint(childFraction, result);\n }\n // no fragment found. Use _fragments[0]\n // fragment = this.chainDistanceToFragment(chainDistance, true);\n return this._fragments[0].childCurve.fractionToPoint(0.0, result);\n }\n\n /** Return the point (x,y,z) and derivative on the curve at fractional position.\n *\n * * Note that this derivative is \"derivative of xyz with respect to fraction.\"\n * * this derivative shows the speed of the \"fractional point\" moving along the curve.\n * * this is not generally a unit vector. use fractionToPointAndUnitTangent for a unit vector.\n * @param fraction fractional position along the geometry.\n * @returns Returns a ray whose origin is the curve point and direction is the derivative with respect to the fraction.\n */\n public fractionToPointAndDerivative(fraction: number, result?: Ray3d): Ray3d {\n const distanceAlongPath = fraction * this._totalLength;\n const fragment = this.chainDistanceToFragment(distanceAlongPath, true)!;\n const curveFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath, true);\n result = fragment.childCurve.fractionToPointAndDerivative(curveFraction, result);\n // Fractional arc length parameterization for the curve C is f=f(t)=s(t)/L, where\n // L is total length of C, f'=||C'||/L, and inverse t=t(f), t'=1/f'=L/||C'||.\n // Then d/df(C(t(f)))=C't'=C'L/||C'||. The fragment gave us C', so the\n // derivative we seek is just a scale away.\n const a = this._totalLength / result.direction.magnitude();\n result.direction.scaleInPlace(a);\n return result;\n }\n\n /**\n * Returns a ray whose origin is the curve point and direction is the unit tangent.\n * @param fraction fractional position on the curve\n * @param result optional receiver for the result.\n * Returns a ray whose origin is the curve point and direction is the unit tangent.\n */\n public override fractionToPointAndUnitTangent(fraction: number, result?: Ray3d): Ray3d {\n const distanceAlongPath = fraction * this._totalLength;\n const fragment = this.chainDistanceToFragment(distanceAlongPath, true)!;\n const curveFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath, true);\n result = fragment.childCurve.fractionToPointAndDerivative(curveFraction, result);\n result.direction.normalizeInPlace();\n return result;\n }\n /** Return a plane with\n *\n * * origin at fractional position along the curve\n * * vectorU is the first derivative, i.e. tangent vector with length equal to the rate of change with respect to the fraction.\n * * vectorV is the second derivative, i.e.derivative of vectorU.\n */\n public fractionToPointAnd2Derivatives(fraction: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors | undefined {\n const distanceAlongPath = fraction * this._totalLength;\n const fragment = this.chainDistanceToFragment(distanceAlongPath, true)!;\n const curveFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath, true);\n result = fragment.childCurve.fractionToPointAnd2Derivatives(curveFraction, result);\n if (!result)\n return undefined;\n // See fractionToPointAndDerivative for derivation of d/df(C(t(f)))=L C'/||C'||.\n // For the 2nd deriv, use quotient rule, d/dt||x(t)||=x.x'/||x|| and ||x||^2=x.x :\n // d/df(C'(t(f))) = L d/df(C'/||C'||)\n // = L (||C'|| d/df(C') - C' d/df||C'||) / ||C'||^2\n // = L (||C'|| C\" L/||C'|| - C' C'.C\"/||C'|| L/||C'||) / ||C'||^2\n // = (L/||C'||)^2 (C\" - C' C'.C\"/C'.C' )\n // We have C' and C\" from the fragment.\n const magU = result.vectorU.magnitude();\n const dotUU = magU * magU;\n const dotUV = result.vectorU.dotProduct(result.vectorV);\n result.vectorV.addScaledInPlace(result.vectorU, -dotUV / dotUU);\n const scale = this._totalLength / magU;\n result.vectorU.scaleInPlace(scale);\n result.vectorV.scaleInPlace(scale * scale);\n return result;\n }\n /** Attempt to transform in place.\n * * Warning: If any child fails, this object becomes invalid. But that should never happen.\n */\n public tryTransformInPlace(transform: Transform): boolean {\n let numFail = 0;\n for (const c of this._path.children) {\n if (!c.tryTransformInPlace(transform))\n numFail++;\n }\n return numFail === 0;\n }\n /** Reverse the curve's data so that its fractional stroking moves in the opposite direction. */\n public reverseInPlace(): void {\n this._path.reverseChildrenInPlace();\n const totalLength = this._totalLength;\n for (const fragment of this._fragments) {\n fragment.reverseFractionsAndDistances(totalLength);\n }\n this._fragments.reverse();\n }\n /**\n * Test for equality conditions:\n * * Mismatched totalLength is a quick exit condition\n * * If totalLength matches, recurse to the path for matching primitives.\n * @param other\n */\n public override isAlmostEqual(other: GeometryQuery): boolean {\n if (other instanceof CurveChainWithDistanceIndex) {\n return Geometry.isSameCoordinate(this._totalLength, other._totalLength)\n && this._path.isAlmostEqual(other._path);\n }\n return false;\n }\n\n /** Implement moveSignedDistanceFromFraction.\n * * See `CurvePrimitive` for parameter details.\n * * The returned location directly identifies fractional position along the CurveChainWithDistanceIndex, and has pointer to an additional detail for the child curve.\n */\n public override moveSignedDistanceFromFraction(startFraction: number, signedDistance: number, allowExtension: boolean, result?: CurveLocationDetail): CurveLocationDetail {\n const distanceA = startFraction * this._totalLength;\n const distanceB = distanceA + signedDistance;\n const fragmentB = this.chainDistanceToFragment(distanceB, true)!;\n const childDetail = fragmentB.childCurve.moveSignedDistanceFromFraction(fragmentB.childFraction0, distanceB - fragmentB.chainDistance0, allowExtension, result);\n const endFraction = startFraction + (signedDistance / this._totalLength);\n const chainDetail = CurveLocationDetail.createConditionalMoveSignedDistance(allowExtension, this, startFraction, endFraction, signedDistance, result);\n chainDetail.childDetail = childDetail;\n return chainDetail;\n }\n\n /**\n *\n * The returned object has\n * * numCalls = number of times closestPoint was called.\n * * numCurvesTested = number of curves tested with full closestPoint\n * * numAssigned = number of times a new minimum value was recorded\n * * numCandidate = number of curves that would be tested in worst case.\n * return an object summarizing closest point test counts\n * @param clear if true, counts are cleared after the return object is formed.\n */\n public static getClosestPointTestCounts(clear: boolean = true): { numCalls: number, numTested: number, numAssigned: number, numCandidate: number } {\n const a = {\n numCalls: this._numCalls,\n numTested: this._numTested,\n numAssigned: this._numAssigned,\n numCandidate: this._numCandidate,\n };\n\n if (clear) {\n this._numTested = this._numAssigned = this._numCandidate = 0;\n }\n return a;\n }\n private static _numCalls = 0;\n private static _numTested = 0;\n private static _numAssigned = 0;\n private static _numCandidate = 0;\n /** Search for the curve point that is closest to the spacePoint.\n * * The CurveChainWithDistanceIndex invokes the base class CurvePrimitive method, which\n * (via a handler) determines a CurveLocation detail among the children.\n * * The returned detail directly identifies fractional position along the CurveChainWithDistanceIndex, and has pointer to an additional detail for the child curve.\n * @param spacePoint point in space\n * @param extend true to extend the curve\n * @returns Returns a CurveLocationDetail structure that holds the details of the close point.\n */\n public override closestPoint(spacePoint: Point3d, extend: VariantCurveExtendParameter): CurveLocationDetail | undefined {\n let childDetail: CurveLocationDetail | undefined;\n let aMin = Number.MAX_VALUE;\n const numChildren = this.path.children.length;\n if (numChildren === 1) {\n childDetail = this.path.children[0].closestPoint(spacePoint, extend);\n } else {\n const sortedFragments = PathFragment.collectSortedQuickMinDistances(this._fragments, spacePoint);\n const extend0 = [CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 0), CurveExtendMode.None];\n const extend1 = [CurveExtendMode.None, CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 1)];\n const fragment0 = this._fragments[0];\n const fragment1 = this._fragments[this._fragments.length - 1];\n CurveChainWithDistanceIndex._numCalls++;\n CurveChainWithDistanceIndex._numCandidate += sortedFragments.length;\n for (const f of sortedFragments) {\n if (f.a > aMin)\n break;\n CurveChainWithDistanceIndex._numTested++;\n const child = f.childCurve;\n const detailA = child.closestPoint(spacePoint,\n f === fragment0 ? extend0 : f === fragment1 ? extend1 : false);\n if (detailA && detailA.a < aMin) {\n aMin = detailA.a;\n childDetail = CurveLocationDetail.createCurveFractionPoint(detailA.curve, detailA.fraction, detailA.point, childDetail)!;\n childDetail.a = detailA.a;\n CurveChainWithDistanceIndex._numAssigned++;\n }\n }\n\n }\n if (!childDetail)\n return undefined;\n const fragment = this.curveAndChildFractionToFragment(childDetail.curve!, childDetail.fraction);\n if (fragment) {\n const chainDistance = fragment.childFractionToChainDistance(childDetail.fraction);\n const chainFraction = this.chainDistanceToChainFraction(chainDistance);\n const chainDetail = CurveLocationDetail.createCurveFractionPoint(this, chainFraction, childDetail.point);\n chainDetail.childDetail = childDetail;\n chainDetail.a = childDetail.a;\n return chainDetail;\n }\n return undefined;\n }\n\n /**\n * Construct an offset of each child as viewed in the xy-plane (ignoring z).\n * * No attempt is made to join the offset children. Use RegionOps.constructCurveXYOffset() to return a fully joined offset.\n * @param offsetDistanceOrOptions offset distance (positive to left of the instance curve), or options object\n */\n public override constructOffsetXY(offsetDistanceOrOptions: number | OffsetOptions): CurvePrimitive | CurvePrimitive[] | undefined {\n const options = OffsetOptions.create(offsetDistanceOrOptions);\n const offsets: CurvePrimitive[] = [];\n for (const prim of this.collectCurvePrimitives(undefined, true, true)) {\n const offset = prim.constructOffsetXY(options);\n if (offset !== undefined) {\n if (offset instanceof CurvePrimitive)\n offsets.push(offset);\n else if (Array.isArray(offset))\n offset.forEach((cp) => offsets.push(cp));\n }\n }\n return offsets;\n }\n\n /** Project instance geometry (via dispatch) onto the given ray, and return the extreme fractional parameters of projection.\n * @param ray ray onto which the instance is projected. A `Vector3d` is treated as a `Ray3d` with zero origin.\n * @param lowHigh optional receiver for output\n * @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the end of the ray.\n */\n public override projectedParameterRange(ray: Vector3d | Ray3d, lowHigh?: Range1d): Range1d | undefined {\n return PlaneAltitudeRangeContext.findExtremeFractionsAlongDirection(this, ray, lowHigh);\n }\n}\n"]}
1
+ {"version":3,"file":"CurveChainWithDistanceIndex.js","sourceRoot":"","sources":["../../../src/curve/CurveChainWithDistanceIndex.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,4DAAyD;AACzD,kEAA+D;AAC/D,0CAAuC;AAIvC,mEAAkE;AAClE,+CAAuD;AAGvD,uDAA+C;AAC/C,uDAAqG;AACrG,+DAA4D;AAE5D,4FAAyF;AACzF,kFAAwE;AAExE,iCAA8B;AAG9B;;;;;;GAMG;AACH,MAAa,YAAY;IAevB,yEAAyE;IACzE,YAAmB,cAAsB,EAAE,cAAsB,EAAE,SAAiB,EAAE,SAAiB,EAAE,UAA0B,EACjI,KAAe;QACf,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;QAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACb,CAAC;IACD;;;OAGG;IACI,qBAAqB,CAAC,QAAgB;QAC3C,OAAO,QAAQ,IAAI,IAAI,CAAC,cAAc,IAAI,QAAQ,IAAI,IAAI,CAAC,cAAc,CAAC;IAC5E,CAAC;IACD,yFAAyF;IACzF,iBAAiB;IACV,4BAA4B,CAAC,UAAmB;QACrD,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;SAC/C;QACD,uCAAuC;QACvC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC/D,IAAI,MAAM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C,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE;YACrE,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAC/C,IAAI,MAAM,KAAK,SAAS,EAAE;gBACxB,IAAI,MAAM,YAAY,+BAAc;oBAClC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;qBAClB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;oBAC5B,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;aAC5C;SACF;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACa,uBAAuB,CAAC,GAAqB,EAAE,OAAiB;QAC9E,OAAO,qDAAyB,CAAC,kCAAkC,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1F,CAAC;;AAjhBH,kEAkhBC;AApFgB,qCAAS,GAAG,CAAC,CAAC;AACd,sCAAU,GAAG,CAAC,CAAC;AACf,wCAAY,GAAG,CAAC,CAAC;AACjB,yCAAa,GAAG,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Curve\n */\n\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\nimport { StrokeCountMap } from \"../curve/Query/StrokeCountMap\";\nimport { Geometry } from \"../Geometry\";\nimport { GeometryHandler, IStrokeHandler } from \"../geometry3d/GeometryHandler\";\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\nimport { Plane3dByOriginAndVectors } from \"../geometry3d/Plane3dByOriginAndVectors\";\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\nimport { Range1d, Range3d } from \"../geometry3d/Range\";\nimport { Ray3d } from \"../geometry3d/Ray3d\";\nimport { Transform } from \"../geometry3d/Transform\";\nimport { CurveChain } from \"./CurveCollection\";\nimport { CurveExtendMode, CurveExtendOptions, VariantCurveExtendParameter } from \"./CurveExtendMode\";\nimport { CurveLocationDetail } from \"./CurveLocationDetail\";\nimport { GeometryQuery } from \"./GeometryQuery\";\nimport { PlaneAltitudeRangeContext } from \"./internalContexts/PlaneAltitudeRangeContext\";\nimport { OffsetOptions } from \"./internalContexts/PolygonOffsetContext\";\nimport { LineString3d } from \"./LineString3d\";\nimport { Path } from \"./Path\";\nimport { StrokeOptions } from \"./StrokeOptions\";\n\n/**\n * * Annotation of an interval of a curve.\n * * The interval is marked with two pairs of numbers:\n * * * fraction0, fraction1 = fraction parameters along the child curve\n * * * distance0,distance1 = distances within containing CurveChainWithDistanceIndex\n * @public\n */\nexport class PathFragment {\n /** distance along parent to this fragment start */\n public chainDistance0: number;\n /** distance along parent to this fragment end */\n public chainDistance1: number;\n /** Fractional position of this fragment start within its curve primitive. */\n public childFraction0: number;\n /** Fractional position of this fragment end within its curve primitive.. */\n public childFraction1: number;\n /** Curve primitive of this fragment, as presented in stroker. Note that this might have become a proxy. */\n public childCurve: CurvePrimitive;\n /** optional range */\n public range?: Range3d;\n /** working var for use in searches. */\n public a: number;\n /** Create a fragment with complete fraction, distance and child data. */\n public constructor(childFraction0: number, childFraction1: number, distance0: number, distance1: number, childCurve: CurvePrimitive,\n range?: Range3d) {\n this.childFraction0 = childFraction0;\n this.childFraction1 = childFraction1;\n this.chainDistance0 = distance0;\n this.chainDistance1 = distance1;\n this.childCurve = childCurve;\n this.range = range;\n this.a = 0;\n }\n /**\n * Return true if the distance is within the distance limits of this fragment.\n * @param distance\n */\n public containsChainDistance(distance: number): boolean {\n return distance >= this.chainDistance0 && distance <= this.chainDistance1;\n }\n // Return a quick distance to the curve. This may be SMALLER than true distance but may\n // not be larger.\n public quickMinDistanceToChildCurve(spacePoint: Point3d): number {\n if (this.range) {\n return this.range.distanceToPoint(spacePoint);\n }\n // ugh. have to do real computation ..\n const detail = this.childCurve.closestPoint(spacePoint, false);\n if (detail)\n return detail.a;\n return 0;\n }\n // Return an array with (references to) all the path fragments, sorted smallest to largest on\n // the \"a\" value equal to the quick min distance to the fragment\n public static collectSortedQuickMinDistances(fragments: PathFragment[], spacePoint: Point3d): PathFragment[] {\n const sortedFragments: PathFragment[] = [];\n for (const f of fragments) {\n f.a = f.quickMinDistanceToChildCurve(spacePoint);\n sortedFragments.push(f);\n }\n sortedFragments.sort((a: PathFragment, b: PathFragment) => a.a - b.a);\n return sortedFragments;\n }\n /**\n * Return true if this fragment addresses `curve` and brackets `fraction`\n * @param distance\n */\n public containsChildCurveAndChildFraction(curve: CurvePrimitive, fraction: number): boolean {\n return this.childCurve === curve && fraction >= this.childFraction0 && fraction <= this.childFraction1;\n }\n\n /** Convert distance to local fraction, and apply that to interpolate between the stored curve fractions.\n * Note that proportional calculation does NOT account for nonuniform parameterization in the child curve.\n */\n public chainDistanceToInterpolatedChildFraction(distance: number): number {\n return Geometry.inverseInterpolate(\n this.childFraction0, this.chainDistance0,\n this.childFraction1, this.chainDistance1,\n distance, this.childFraction0)!; // the interval \"must\" have nonzero length, division should be safe . ..\n }\n /** Convert chainDistance to true chidFraction, using detailed moveSignedDistanceFromFraction\n */\n public chainDistanceToAccurateChildFraction(chainDistance: number, allowExtrapolation?: boolean): number {\n // The fragments are really expected to do good mappings in their distance range ...\n const childDetail = this.childCurve.moveSignedDistanceFromFraction(\n this.childFraction0, chainDistance - this.chainDistance0, allowExtrapolation ?? false);\n return childDetail.fraction;\n }\n /** Return the scale factor to map childCurve fraction derivatives to chain fraction derivatives\n * @param globalDistance total length of the global curve.\n */\n public fractionScaleFactor(globalDistance: number): number {\n return globalDistance * (this.childFraction1 - this.childFraction0) / (this.chainDistance1 - this.chainDistance0);\n }\n /** Reverse the fraction and distance data.\n * * each child fraction `f` is replaced by `1-f`\n * * each `chainDistance` is replaced by `totalDistance-chainDistance`\n */\n public reverseFractionsAndDistances(totalDistance: number) {\n const f0 = this.childFraction0;\n const f1 = this.childFraction1;\n const d0 = this.chainDistance0;\n const d1 = this.chainDistance1;\n this.childFraction0 = 1.0 - f1;\n this.childFraction1 = 1.0 - f0;\n this.chainDistance0 = totalDistance - d1;\n this.chainDistance1 = totalDistance - d0;\n }\n /** @deprecated in 3.x. Use childFractionToChainDistance */\n public childFractionTChainDistance(fraction: number): number {\n return this.childFractionToChainDistance(fraction);\n }\n /**\n * convert a fractional position on the childCurve to distance in the chain space.\n * * Return value is SIGNED -- will be negative when fraction < this.childFraction0.\n * @param fraction fraction along the curve within this fragment\n */\n public childFractionToChainDistance(fraction: number): number {\n let d = this.childCurve.curveLengthBetweenFractions(this.childFraction0, fraction);\n if (fraction < this.childFraction0)\n d = -d;\n return this.chainDistance0 + d;\n }\n}\n/** Non-instantiable class to build a distance index for a path. */\nclass DistanceIndexConstructionContext implements IStrokeHandler {\n private _fragments: PathFragment[];\n private _accumulatedDistance: number;\n private constructor() {\n this._accumulatedDistance = 0;\n this._fragments = [];\n }\n // ignore curve announcements -- they are repeated in stroke announcements\n public startParentCurvePrimitive(_cp: CurvePrimitive) { }\n public startCurvePrimitive(_cp: CurvePrimitive) { }\n public endParentCurvePrimitive(_cp: CurvePrimitive) { }\n public endCurvePrimitive(_cp: CurvePrimitive) { }\n // um .. we need to see curves? how to reject?\n public announcePointTangent(_xyz: Point3d, _fraction: number, _tangent: Vector3d) { }\n /** Announce numPoints interpolated between point0 and point1, with associated fractions */\n public announceSegmentInterval(\n cp: CurvePrimitive,\n point0: Point3d,\n point1: Point3d,\n numStrokes: number,\n fraction0: number,\n fraction1: number): void {\n const fragmentPoint0 = point0.clone();\n const fragmentPoint1 = point1.clone();\n let d0 = this._accumulatedDistance;\n if (numStrokes <= 1) {\n this._accumulatedDistance += point0.distance(point1);\n this._fragments.push(new PathFragment(fraction0, fraction1, d0, this._accumulatedDistance, cp,\n Range3d.create(fragmentPoint0, fragmentPoint1)));\n } else {\n let f1;\n for (let i = 1, f0 = fraction0; i <= numStrokes; i++, f0 = f1) {\n f1 = Geometry.interpolate(fraction0, i / numStrokes, fraction1);\n point0.interpolate(f1, point1, fragmentPoint1);\n d0 = this._accumulatedDistance;\n this._accumulatedDistance += (Math.abs(f1 - f0) * point0.distance(point1));\n this._fragments.push(new PathFragment(f0, f1, d0, this._accumulatedDistance, cp,\n Range3d.create(fragmentPoint0, fragmentPoint1)));\n fragmentPoint0.setFrom(fragmentPoint1);\n }\n }\n }\n public announceIntervalForUniformStepStrokes(\n cp: CurvePrimitive,\n numStrokes: number,\n fraction0: number,\n fraction1: number): void {\n let f1, d, d0;\n for (let i = 1, f0 = fraction0; i <= numStrokes; i++, f0 = f1) {\n f1 = Geometry.interpolate(fraction0, i / numStrokes, fraction1);\n d = cp.curveLengthBetweenFractions(f0, f1);\n d0 = this._accumulatedDistance;\n this._accumulatedDistance += d;\n const range = cp.rangeBetweenFractions(f0, f1);\n this._fragments.push(new PathFragment(f0, f1, d0, this._accumulatedDistance, cp, range));\n }\n }\n public needPrimaryGeometryForStrokes?(): boolean { return true; }\n public static createPathFragmentIndex(path: CurveChain, options?: StrokeOptions): PathFragment[] {\n const handler = new DistanceIndexConstructionContext();\n for (const curve of path.children) {\n curve.emitStrokableParts(handler, options);\n }\n const fragments = handler._fragments;\n return fragments;\n }\n}\n/**\n * `CurveChainWithDistanceIndex` is a CurvePrimitive whose fractional parameterization is proportional to true\n * distance along a CurveChain.\n * * The curve chain can be any type derived from CurveChain.\n * * * i.e. either a `Path` or a `Loop`\n * @public\n */\nexport class CurveChainWithDistanceIndex extends CurvePrimitive {\n /** String name for schema properties */\n public readonly curvePrimitiveType = \"curveChainWithDistanceIndex\";\n\n private readonly _path: CurveChain;\n private readonly _fragments: PathFragment[];\n private readonly _totalLength: number; // matches final fragment distance1.\n /** Test if other is a `CurveChainWithDistanceIndex` */\n public isSameGeometryClass(other: GeometryQuery): boolean { return other instanceof CurveChainWithDistanceIndex; }\n // final assembly of CurveChainWithDistanceIndex -- caller must create valid fragment index.\n private constructor(path: CurveChain, fragments: PathFragment[]) {\n super();\n this._path = path;\n this._fragments = fragments;\n this._totalLength = fragments.length > 0 ? fragments[fragments.length - 1].chainDistance1 : 0;\n }\n /**\n * Create a clone, transformed and with its own distance index.\n * @param transform transform to apply in the clone.\n */\n public cloneTransformed(transform: Transform): CurveChainWithDistanceIndex | undefined {\n const c = this._path.clone();\n if (c instanceof CurveChain && c.tryTransformInPlace(transform))\n return CurveChainWithDistanceIndex.createCapture(c);\n return undefined;\n }\n /** Reference to the contained path.\n * * Do not modify the path. The distance index will be wrong.\n */\n public get path(): CurveChain { return this._path; }\n\n /** Reference to the fragments array.\n * * Do not modify.\n */\n public get fragments(): PathFragment[] { return this._fragments; }\n\n /** Return a deep clone */\n public clone(): CurveChainWithDistanceIndex {\n const c = this._path.clone() as CurveChain;\n return CurveChainWithDistanceIndex.createCapture(c);\n }\n\n /** Return a deep clone */\n public override clonePartialCurve(fractionA: number, fractionB: number): CurveChainWithDistanceIndex | undefined {\n if (fractionA === fractionB)\n return undefined;\n let fracA = fractionA;\n let fracB = fractionB;\n const reversed = fractionA > fractionB;\n if (reversed) {\n fracA = fractionB;\n fracB = fractionA;\n }\n const chainDistanceA = fracA * this._totalLength;\n const chainDistanceB = fracB * this._totalLength;\n const fragmentA = this.chainDistanceToFragment(chainDistanceA, true);\n if (undefined === fragmentA)\n return undefined;\n const fragmentB = this.chainDistanceToFragment(chainDistanceB, true);\n if (undefined === fragmentB)\n return undefined;\n const childCurveIndexA = this._path.childIndex(fragmentA.childCurve, true);\n if (undefined === childCurveIndexA)\n return undefined;\n const childCurveIndexB = this._path.childIndex(fragmentB.childCurve, true);\n if (undefined === childCurveIndexB)\n return undefined;\n const childFractionA = fragmentA.chainDistanceToAccurateChildFraction(chainDistanceA, true);\n const childFractionB = fragmentB.chainDistanceToAccurateChildFraction(chainDistanceB, true);\n\n // add a (possibly reversed) partial clone to newPath\n const newPath = Path.create();\n const addPartialChild = (childCurve: CurvePrimitive, childFraction0: number, childFraction1: number, reversedClone: boolean): boolean => {\n if (childFraction0 === childFraction1)\n return false;\n let newCurve;\n if (childFraction0 === 0.0 && childFraction1 === 1.0) {\n newCurve = childCurve.clone();\n if (reversedClone)\n newCurve.reverseInPlace();\n } else {\n newCurve = reversedClone ?\n childCurve.clonePartialCurve(childFraction1, childFraction0)\n : childCurve.clonePartialCurve(childFraction0, childFraction1);\n }\n if (newCurve) {\n newPath.children.push(newCurve);\n return true;\n }\n return false;\n };\n\n if (fragmentA.childCurve === fragmentB.childCurve) {\n // the two distances are within the same curve.\n if (addPartialChild(fragmentA.childCurve, childFractionA, childFractionB, reversed))\n return CurveChainWithDistanceIndex.createCapture(newPath); // singleton -- children[] does not need to be reversed.\n return undefined;\n }\n addPartialChild(this._path.children[childCurveIndexA], childFractionA, 1.0, reversed);\n // at least two distinct children are impacted ....\n for (let childIndex = childCurveIndexA + 1; childIndex < childCurveIndexB; childIndex++) {\n addPartialChild(this._path.children[childIndex], 0.0, 1.0, reversed);\n }\n addPartialChild(this._path.children[childCurveIndexB], 0.0, childFractionB, reversed);\n // This reverses array entries but not orientation within each curve ...\n if (reversed)\n newPath.children.reverse();\n return CurveChainWithDistanceIndex.createCapture(newPath);\n }\n\n /** Ask if the curve is within tolerance of a plane.\n * @returns Returns true if the curve is completely within tolerance of the plane.\n */\n public isInPlane(plane: Plane3dByOriginAndUnitNormal): boolean {\n for (const c of this._path.children) {\n if (!c.isInPlane(plane))\n return false;\n }\n return true;\n }\n\n /** return the start point of the primitive. The default implementation returns fractionToPoint (0.0) */\n public override startPoint(result?: Point3d): Point3d {\n const c = this._path.cyclicCurvePrimitive(0);\n if (c)\n return c.startPoint(result);\n return Point3d.createZero(result);\n }\n /** Return the end point of the primitive. The default implementation returns fractionToPoint(1.0) */\n public override endPoint(result?: Point3d): Point3d {\n const c = this._path.cyclicCurvePrimitive(-1);\n if (c)\n return c.endPoint(result);\n return Point3d.createZero(result);\n }\n /** Add strokes to caller-supplied linestring */\n public emitStrokes(dest: LineString3d, options?: StrokeOptions): void {\n for (const c of this._path.children) {\n c.emitStrokes(dest, options);\n }\n }\n /** Ask the curve to announce points and simple subcurve fragments for stroking.\n * See IStrokeHandler for description of the sequence of the method calls.\n */\n public emitStrokableParts(dest: IStrokeHandler, options?: StrokeOptions): void {\n for (const c of this._path.children) {\n c.emitStrokableParts(dest, options);\n }\n }\n /**\n * return the stroke count required for given options.\n * @param options StrokeOptions that determine count\n */\n public computeStrokeCountForOptions(options?: StrokeOptions): number {\n let numStroke = 0;\n for (const c of this._path.children) {\n numStroke += c.computeStrokeCountForOptions(options);\n }\n return numStroke;\n }\n /**\n * Return an array containing only the curve primitives.\n * * This DEFAULT simply pushes `this` to the collectorArray.\n * * CurvePrimitiveWithDistanceIndex optionally collects its members.\n * @param collectorArray array to receive primitives (pushed -- the array is not cleared)\n * @param smallestPossiblePrimitives if false, CurvePrimitiveWithDistanceIndex returns only itself. If true, it recurses to its (otherwise hidden) children.\n */\n public override collectCurvePrimitivesGo(collectorArray: CurvePrimitive[], smallestPossiblePrimitives: boolean = false, explodeLineStrings: boolean = false) {\n if (smallestPossiblePrimitives) {\n for (const c of this._path.children) {\n c.collectCurvePrimitivesGo(collectorArray, smallestPossiblePrimitives, explodeLineStrings);\n }\n } else {\n collectorArray.push(this);\n }\n }\n\n /**\n * construct StrokeCountMap for each child, accumulating data to stroke count map for this primitive.\n * @param options StrokeOptions that determine count\n * @param parentStrokeMap evolving parent map.\n */\n public override computeAndAttachRecursiveStrokeCounts(options?: StrokeOptions, parentStrokeMap?: StrokeCountMap) {\n const myMap = StrokeCountMap.createWithCurvePrimitiveAndOptionalParent(this, parentStrokeMap);\n for (const c of this._path.children) {\n c.computeAndAttachRecursiveStrokeCounts(options, myMap);\n }\n CurvePrimitive.installStrokeCountMap(this, myMap, parentStrokeMap);\n }\n /** Second step of double dispatch: call `this._path.dispatchToGeometryHandler (handler)`\n * * Note that this exposes the children individually to the handler.\n */\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\n return this._path.dispatchToGeometryHandler(handler);\n }\n /** Extend (increase) `rangeToExtend` as needed to include these curves (optionally transformed)\n */\n public extendRange(rangeToExtend: Range3d, transform?: Transform): void {\n this._path.extendRange(rangeToExtend, transform);\n }\n /**\n *\n * * Curve length is always positive.\n * @returns Returns a (high accuracy) length of the curve between fractional positions\n * @returns Returns the length of the curve.\n */\n public override curveLengthBetweenFractions(fraction0: number, fraction1: number): number {\n return Math.abs(fraction1 - fraction0) * this._totalLength;\n }\n /**\n * Capture (not clone) a path into a new `CurveChainWithDistanceIndex`\n * @param path primitive array to be CAPTURED (not cloned)\n */\n public static createCapture(path: CurveChain, options?: StrokeOptions): CurveChainWithDistanceIndex {\n const fragments = DistanceIndexConstructionContext.createPathFragmentIndex(path, options);\n const result = new CurveChainWithDistanceIndex(path, fragments);\n return result;\n }\n\n /**\n * Resolve a fraction of the CurveChain to a PathFragment\n * @param distance\n * @param allowExtrapolation\n */\n public chainDistanceToFragment(distance: number, allowExtrapolation: boolean = false): PathFragment | undefined {\n const i = this.chainDistanceToFragmentIndex(distance, allowExtrapolation);\n if (undefined !== i)\n return this._fragments[i];\n return undefined;\n }\n /**\n * Resolve a fraction of the CurveChain to a PathFragment index\n * @param distance\n * @param allowExtrapolation\n */\n protected chainDistanceToFragmentIndex(distance: number, allowExtrapolation: boolean = false): number | undefined {\n const numFragments = this._fragments.length;\n const fragments = this._fragments;\n if (numFragments > 0) {\n if (distance < 0.0)\n return allowExtrapolation ? 0 : undefined;\n if (distance > this._totalLength)\n return allowExtrapolation ? (numFragments - 1) : undefined;\n // humbug, linear search\n for (let i = 0; i < numFragments; i++) {\n if (fragments[i].containsChainDistance(distance)) return i;\n }\n }\n return undefined;\n }\n\n /**\n * Convert distance along the chain to fraction along the chain.\n * @param distance distance along the chain\n */\n public chainDistanceToChainFraction(distance: number): number { return distance / this._totalLength; }\n /**\n * Resolve a fraction within a specific curve to a fragment.\n * @param curve\n * @param fraction\n */\n public curveAndChildFractionToFragment(curve: CurvePrimitive, fraction: number): PathFragment | undefined {\n const numFragments = this._fragments.length;\n const fragments = this._fragments;\n if (numFragments > 0) {\n // humbug, linear search\n for (const fragment of fragments) {\n if (fragment.containsChildCurveAndChildFraction(curve, fraction))\n return fragment;\n }\n if (fraction <= 0)\n return fragments[0];\n if (fraction > 1.0)\n return fragments[numFragments - 1];\n }\n return undefined;\n }\n\n /**\n * Returns the total length of curves.\n */\n public override curveLength(): number {\n return this._totalLength;\n }\n /**\n * Returns the total length of the path.\n * * This is exact (and simple property lookup) because the true lengths were summed at construction time.\n */\n public quickLength(): number {\n return this._totalLength;\n }\n\n /**\n * Return the point (x,y,z) on the curve at fractional position along the chain.\n * @param fraction fractional position along the geometry.\n * @returns Returns a point on the curve.\n */\n public fractionToPoint(fraction: number, result?: Point3d): Point3d {\n const chainDistance = fraction * this._totalLength;\n const fragment = this.chainDistanceToFragment(chainDistance, true);\n if (fragment) {\n const childFraction = fragment.chainDistanceToAccurateChildFraction(chainDistance, true);\n return fragment.childCurve.fractionToPoint(childFraction, result);\n }\n // no fragment found. Use _fragments[0]\n // fragment = this.chainDistanceToFragment(chainDistance, true);\n return this._fragments[0].childCurve.fractionToPoint(0.0, result);\n }\n\n /** Return the point (x,y,z) and derivative on the curve at fractional position.\n *\n * * Note that this derivative is \"derivative of xyz with respect to fraction.\"\n * * this derivative shows the speed of the \"fractional point\" moving along the curve.\n * * this is not generally a unit vector. use fractionToPointAndUnitTangent for a unit vector.\n * @param fraction fractional position along the geometry.\n * @returns Returns a ray whose origin is the curve point and direction is the derivative with respect to the fraction.\n */\n public fractionToPointAndDerivative(fraction: number, result?: Ray3d): Ray3d {\n const distanceAlongPath = fraction * this._totalLength;\n const fragment = this.chainDistanceToFragment(distanceAlongPath, true)!;\n const curveFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath, true);\n result = fragment.childCurve.fractionToPointAndDerivative(curveFraction, result);\n // Fractional arc length parameterization for the curve C is f=f(t)=s(t)/L, where\n // L is total length of C, f'=||C'||/L, and inverse t=t(f), t'=1/f'=L/||C'||.\n // Then d/df(C(t(f)))=C't'=C'L/||C'||. The fragment gave us C', so the\n // derivative we seek is just a scale away.\n const a = this._totalLength / result.direction.magnitude();\n result.direction.scaleInPlace(a);\n return result;\n }\n\n /**\n * Returns a ray whose origin is the curve point and direction is the unit tangent.\n * @param fraction fractional position on the curve\n * @param result optional receiver for the result.\n * Returns a ray whose origin is the curve point and direction is the unit tangent.\n */\n public override fractionToPointAndUnitTangent(fraction: number, result?: Ray3d): Ray3d {\n const distanceAlongPath = fraction * this._totalLength;\n const fragment = this.chainDistanceToFragment(distanceAlongPath, true)!;\n const curveFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath, true);\n result = fragment.childCurve.fractionToPointAndDerivative(curveFraction, result);\n result.direction.normalizeInPlace();\n return result;\n }\n /** Return a plane with\n *\n * * origin at fractional position along the curve\n * * vectorU is the first derivative, i.e. tangent vector with length equal to the rate of change with respect to the fraction.\n * * vectorV is the second derivative, i.e.derivative of vectorU.\n */\n public fractionToPointAnd2Derivatives(fraction: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors | undefined {\n const distanceAlongPath = fraction * this._totalLength;\n const fragment = this.chainDistanceToFragment(distanceAlongPath, true)!;\n const curveFraction = fragment.chainDistanceToAccurateChildFraction(distanceAlongPath, true);\n result = fragment.childCurve.fractionToPointAnd2Derivatives(curveFraction, result);\n if (!result)\n return undefined;\n // See fractionToPointAndDerivative for derivation of d/df(C(t(f)))=L C'/||C'||.\n // For the 2nd deriv, use quotient rule, d/dt||x(t)||=x.x'/||x|| and ||x||^2=x.x :\n // d/df(C'(t(f))) = L d/df(C'/||C'||)\n // = L (||C'|| d/df(C') - C' d/df||C'||) / ||C'||^2\n // = L (||C'|| C\" L/||C'|| - C' C'.C\"/||C'|| L/||C'||) / ||C'||^2\n // = (L/||C'||)^2 (C\" - C' C'.C\"/C'.C' )\n // We have C' and C\" from the fragment.\n const magU = result.vectorU.magnitude();\n const dotUU = magU * magU;\n const dotUV = result.vectorU.dotProduct(result.vectorV);\n result.vectorV.addScaledInPlace(result.vectorU, -dotUV / dotUU);\n const scale = this._totalLength / magU;\n result.vectorU.scaleInPlace(scale);\n result.vectorV.scaleInPlace(scale * scale);\n return result;\n }\n /** Attempt to transform in place.\n * * Warning: If any child fails, this object becomes invalid. But that should never happen.\n */\n public tryTransformInPlace(transform: Transform): boolean {\n let numFail = 0;\n for (const c of this._path.children) {\n if (!c.tryTransformInPlace(transform))\n numFail++;\n }\n return numFail === 0;\n }\n /** Reverse the curve's data so that its fractional stroking moves in the opposite direction. */\n public reverseInPlace(): void {\n this._path.reverseChildrenInPlace();\n const totalLength = this._totalLength;\n for (const fragment of this._fragments) {\n fragment.reverseFractionsAndDistances(totalLength);\n }\n this._fragments.reverse();\n }\n /**\n * Test for equality conditions:\n * * Mismatched totalLength is a quick exit condition\n * * If totalLength matches, recurse to the path for matching primitives.\n * @param other\n */\n public override isAlmostEqual(other: GeometryQuery): boolean {\n if (other instanceof CurveChainWithDistanceIndex) {\n return Geometry.isSameCoordinate(this._totalLength, other._totalLength)\n && this._path.isAlmostEqual(other._path);\n }\n return false;\n }\n\n /** Implement moveSignedDistanceFromFraction.\n * * See `CurvePrimitive` for parameter details.\n * * The returned location directly identifies fractional position along the CurveChainWithDistanceIndex, and has pointer to an additional detail for the child curve.\n */\n public override moveSignedDistanceFromFraction(startFraction: number, signedDistance: number, allowExtension: boolean, result?: CurveLocationDetail): CurveLocationDetail {\n const distanceA = startFraction * this._totalLength;\n const distanceB = distanceA + signedDistance;\n const fragmentB = this.chainDistanceToFragment(distanceB, true)!;\n const childDetail = fragmentB.childCurve.moveSignedDistanceFromFraction(fragmentB.childFraction0, distanceB - fragmentB.chainDistance0, allowExtension, result);\n const endFraction = startFraction + (signedDistance / this._totalLength);\n const chainDetail = CurveLocationDetail.createConditionalMoveSignedDistance(allowExtension, this, startFraction, endFraction, signedDistance, result);\n chainDetail.childDetail = childDetail;\n return chainDetail;\n }\n\n /**\n *\n * The returned object has\n * * numCalls = number of times closestPoint was called.\n * * numCurvesTested = number of curves tested with full closestPoint\n * * numAssigned = number of times a new minimum value was recorded\n * * numCandidate = number of curves that would be tested in worst case.\n * return an object summarizing closest point test counts\n * @param clear if true, counts are cleared after the return object is formed.\n */\n public static getClosestPointTestCounts(clear: boolean = true): { numCalls: number, numTested: number, numAssigned: number, numCandidate: number } {\n const a = {\n numCalls: this._numCalls,\n numTested: this._numTested,\n numAssigned: this._numAssigned,\n numCandidate: this._numCandidate,\n };\n\n if (clear) {\n this._numTested = this._numAssigned = this._numCandidate = 0;\n }\n return a;\n }\n private static _numCalls = 0;\n private static _numTested = 0;\n private static _numAssigned = 0;\n private static _numCandidate = 0;\n /** Search for the curve point that is closest to the spacePoint.\n * * The CurveChainWithDistanceIndex invokes the base class CurvePrimitive method, which\n * (via a handler) determines a CurveLocation detail among the children.\n * * The returned detail directly identifies fractional position along the CurveChainWithDistanceIndex, and has pointer to an additional detail for the child curve.\n * @param spacePoint point in space\n * @param extend true to extend the curve\n * @returns Returns a CurveLocationDetail structure that holds the details of the close point.\n */\n public override closestPoint(spacePoint: Point3d, extend: VariantCurveExtendParameter): CurveLocationDetail | undefined {\n let childDetail: CurveLocationDetail | undefined;\n let aMin = Number.MAX_VALUE;\n const numChildren = this.path.children.length;\n if (numChildren === 1) {\n childDetail = this.path.children[0].closestPoint(spacePoint, extend);\n } else {\n const sortedFragments = PathFragment.collectSortedQuickMinDistances(this._fragments, spacePoint);\n const extend0 = [CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 0), CurveExtendMode.None];\n const extend1 = [CurveExtendMode.None, CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 1)];\n const fragment0 = this._fragments[0];\n const fragment1 = this._fragments[this._fragments.length - 1];\n CurveChainWithDistanceIndex._numCalls++;\n CurveChainWithDistanceIndex._numCandidate += sortedFragments.length;\n for (const f of sortedFragments) {\n if (f.a > aMin)\n break;\n CurveChainWithDistanceIndex._numTested++;\n const child = f.childCurve;\n const detailA = child.closestPoint(spacePoint,\n f === fragment0 ? extend0 : f === fragment1 ? extend1 : false);\n if (detailA && detailA.a < aMin) {\n aMin = detailA.a;\n childDetail = CurveLocationDetail.createCurveFractionPoint(detailA.curve, detailA.fraction, detailA.point, childDetail)!;\n childDetail.a = detailA.a;\n CurveChainWithDistanceIndex._numAssigned++;\n }\n }\n\n }\n if (!childDetail)\n return undefined;\n const fragment = this.curveAndChildFractionToFragment(childDetail.curve!, childDetail.fraction);\n if (fragment) {\n const chainDistance = fragment.childFractionToChainDistance(childDetail.fraction);\n const chainFraction = this.chainDistanceToChainFraction(chainDistance);\n const chainDetail = CurveLocationDetail.createCurveFractionPoint(this, chainFraction, childDetail.point);\n chainDetail.childDetail = childDetail;\n chainDetail.a = childDetail.a;\n return chainDetail;\n }\n return undefined;\n }\n\n /**\n * Construct an offset of each child as viewed in the xy-plane (ignoring z).\n * * No attempt is made to join the offset children. Use RegionOps.constructCurveXYOffset() to return a fully joined offset.\n * @param offsetDistanceOrOptions offset distance (positive to left of the instance curve), or options object\n */\n public override constructOffsetXY(offsetDistanceOrOptions: number | OffsetOptions): CurvePrimitive | CurvePrimitive[] | undefined {\n const options = OffsetOptions.create(offsetDistanceOrOptions);\n const offsets: CurvePrimitive[] = [];\n for (const prim of this.collectCurvePrimitives(undefined, true, true)) {\n const offset = prim.constructOffsetXY(options);\n if (offset !== undefined) {\n if (offset instanceof CurvePrimitive)\n offsets.push(offset);\n else if (Array.isArray(offset))\n offset.forEach((cp) => offsets.push(cp));\n }\n }\n return offsets;\n }\n\n /** Project instance geometry (via dispatch) onto the given ray, and return the extreme fractional parameters of projection.\n * @param ray ray onto which the instance is projected. A `Vector3d` is treated as a `Ray3d` with zero origin.\n * @param lowHigh optional receiver for output\n * @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the end of the ray.\n */\n public override projectedParameterRange(ray: Vector3d | Ray3d, lowHigh?: Range1d): Range1d | undefined {\n return PlaneAltitudeRangeContext.findExtremeFractionsAlongDirection(this, ray, lowHigh);\n }\n}\n"]}
@@ -262,7 +262,7 @@ class CurveChain extends CurveCollection {
262
262
  if (this._curves[i] === target)
263
263
  return i;
264
264
  }
265
- if (alsoSearchProxies !== null && alsoSearchProxies !== void 0 ? alsoSearchProxies : false) {
265
+ if (alsoSearchProxies ?? false) {
266
266
  for (let i = 0; i < this._curves.length; i++) {
267
267
  const childCurve = this._curves[i];
268
268
  if (childCurve instanceof ProxyCurve_1.ProxyCurve) {
@@ -1 +1 @@
1
- {"version":3,"file":"CurveCollection.js","sourceRoot":"","sources":["../../../src/curve/CurveCollection.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,0CAAuC;AAQvC,+DAA4D;AAC5D,qDAAkD;AAElD,mDAAgD;AAChD,8EAA2E;AAC3E,kGAA+F;AAC/F,oGAAiG;AACjG,0EAAuE;AACvE,4FAAyF;AACzF,4EAAyE;AACzE,wFAAqF;AACrF,iDAA8C;AAC9C,6CAA0C;AAa1C;;;;;;;;;;;GAWG;AACH,MAAsB,eAAgB,SAAQ,6BAAa;IAA3D;;QACE,wCAAwC;QACxB,qBAAgB,GAAG,iBAAiB,CAAC;QAIrD,mEAAmE;QACnE,wDAAwD;QACjD,YAAO,GAAY,KAAK,CAAC;IA4IlC,CAAC;IA3IC,6DAA6D;IACtD,UAAU,KAAa,OAAO,qCAAiB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC1E,uDAAuD;IAChD,YAAY,CAAC,UAAmB;QACrC,IAAI,OAAwC,CAAC;QAC7C,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC/B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACjC,IAAI,KAAK,YAAY,+BAAc,EAAE;oBACnC,MAAM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YAAY;oBACd,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;aACrC;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,oCAAoC;IAC7B,cAAc,KAAkB,OAAO,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC;IAClE,mBAAmB;IACZ,WAAW,CAAC,KAA2B;QAC5C,IAAI,KAAK;YACP,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,2BAA2B;IACpB,QAAQ,CAAC,CAAS;QACvB,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM;YAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC3B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,8EAA8E;IACvE,yBAAyB,CAAC,OAAwB;QACvD,OAAO,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;CACF;AAhED,kCAgEC;AACD;;;GAGG;AACH,MAAa,yCAAyC;IAAtD;QACE,8GAA8G;QACvG,8BAAyB,GAAY,IAAI,CAAC;QACjD,0CAA0C;QACnC,8BAAyB,GAAY,IAAI,CAAC;QACjD,gDAAgD;QACzC,4BAAuB,GAAG,mBAAQ,CAAC,mBAAmB,CAAC;QAC9D,uDAAuD;QAChD,2BAAsB,GAAG,mBAAQ,CAAC,mBAAmB,CAAC;IAC/D,CAAC;CAAA;AATD,8FASC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Curve\n */\nimport { Geometry } from \"../Geometry\";\nimport { GeometryHandler } from \"../geometry3d/GeometryHandler\";\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\nimport { Range1d, Range3d } from \"../geometry3d/Range\";\nimport { Ray3d } from \"../geometry3d/Ray3d\";\nimport { Transform } from \"../geometry3d/Transform\";\nimport { AnyCurve } from \"./CurveChain\";\nimport { CurveLocationDetail } from \"./CurveLocationDetail\";\nimport { CurvePrimitive } from \"./CurvePrimitive\";\nimport { RecursiveCurveProcessor } from \"./CurveProcessor\";\nimport { GeometryQuery } from \"./GeometryQuery\";\nimport { CloneCurvesContext } from \"./internalContexts/CloneCurvesContext\";\nimport { CloneWithExpandedLineStrings } from \"./internalContexts/CloneWithExpandedLineStrings\";\nimport { CountLinearPartsSearchContext } from \"./internalContexts/CountLinearPartsSearchContext\";\nimport { GapSearchContext } from \"./internalContexts/GapSearchContext\";\nimport { PlaneAltitudeRangeContext } from \"./internalContexts/PlaneAltitudeRangeContext\";\nimport { SumLengthsContext } from \"./internalContexts/SumLengthsContext\";\nimport { TransformInPlaceContext } from \"./internalContexts/TransformInPlaceContext\";\nimport { LineString3d } from \"./LineString3d\";\nimport { ProxyCurve } from \"./ProxyCurve\";\nimport { StrokeOptions } from \"./StrokeOptions\";\n\n/** Describes the concrete type of a [[CurveCollection]]. Each type name maps to a specific subclass and can be used in conditional statements for type-switching.\n * - \"loop\" => [[Loop]]\n * - \"path\" => [[Path]]\n * - \"unionRegion\" => [[UnionRegion]]\n * - \"parityRegion\" => [[ParityRegion]]\n * - \"bagOfCurves\" => [[BagOfCurves]]\n * @public\n */\nexport type CurveCollectionType = \"loop\" | \"path\" | \"unionRegion\" | \"parityRegion\" | \"bagOfCurves\";\n\n/**\n * A `CurveCollection` is an abstract (non-instantiable) class for various sets of curves with particular structures:\n * - `CurveChain` is a (non-instantiable) intermediate class for a sequence of `CurvePrimitive ` joining head-to-tail. The two instantiable forms of `CurveChain` are\n * - `Path` - A chain not required to close, and not enclosing a planar area\n * - `Loop` - A chain required to close from last to first so that a planar area is enclosed.\n * - `ParityRegion` -- a collection of coplanar `Loop`s, with \"in/out\" classification by parity rules\n * - `UnionRegion` -- a collection of coplanar `Loop`s, with \"in/out\" classification by union rules\n * - `BagOfCurves` -- a collection of `AnyCurve` with no implied structure.\n *\n * @see [Curve Collections]($docs/learning/geometry/CurveCollection.md) learning article.\n * @public\n */\nexport abstract class CurveCollection extends GeometryQuery {\n /** String name for schema properties */\n public readonly geometryCategory = \"curveCollection\";\n /** Type discriminator. */\n public abstract readonly curveCollectionType: CurveCollectionType;\n\n /* eslint-disable @typescript-eslint/naming-convention, no-empty */\n /** Flag for inner loop status. Only used by `Loop`. */\n public isInner: boolean = false;\n /** Return the sum of the lengths of all contained curves. */\n public sumLengths(): number { return SumLengthsContext.sumLengths(this); }\n /** Return the closest point on the contained curves */\n public closestPoint(spacePoint: Point3d): CurveLocationDetail | undefined {\n let detailA: CurveLocationDetail | undefined;\n if (this.children !== undefined) {\n for (const child of this.children) {\n if (child instanceof CurvePrimitive) {\n const detailB = child.closestPoint(spacePoint, false);\n detailA = CurveLocationDetail.chooseSmallerA(detailA, detailB);\n } else if (child instanceof CurveCollection) {\n const detailB = child.closestPoint(spacePoint);\n detailA = CurveLocationDetail.chooseSmallerA(detailA, detailB);\n }\n }\n }\n return detailA;\n }\n\n /** return the max gap between adjacent primitives in Path and Loop collections.\n *\n * * In a Path, gaps are computed between consecutive primitives.\n * * In a Loop, gaps are computed between consecutive primitives and between last and first.\n * * gaps are NOT computed between consecutive CurvePrimitives in \"unstructured\" collections. The type is \"unstructured\" so gaps should not be semantically meaningful.\n */\n public maxGap(): number { return GapSearchContext.maxGap(this); }\n /** return true if the curve collection has any primitives other than LineSegment3d and LineString3d */\n public checkForNonLinearPrimitives(): boolean { return CountLinearPartsSearchContext.hasNonLinearPrimitives(this); }\n /** Apply transform recursively to children */\n public tryTransformInPlace(transform: Transform): boolean { return TransformInPlaceContext.tryTransformInPlace(this, transform); }\n /** Return a deep copy. */\n public override clone(): CurveCollection {\n return CloneCurvesContext.clone(this) as CurveCollection;\n }\n /** Create a deep copy of transformed curves. */\n public override cloneTransformed(transform: Transform): CurveCollection | undefined {\n return CloneCurvesContext.clone(this, transform);\n }\n /** Create a deep copy with all linestrings expanded to multiple LineSegment3d. */\n public cloneWithExpandedLineStrings(): CurveCollection {\n return CloneWithExpandedLineStrings.clone(this);\n }\n /** Recurse through children to collect CurvePrimitive's in flat array. */\n private collectCurvePrimitivesGo(results: CurvePrimitive[], smallestPossiblePrimitives: boolean, explodeLinestrings: boolean = false) {\n if (this.children) {\n for (const child of this.children) {\n if (child instanceof CurvePrimitive)\n child.collectCurvePrimitivesGo(results, smallestPossiblePrimitives, explodeLinestrings);\n else if (child instanceof CurveCollection)\n child.collectCurvePrimitivesGo(results, smallestPossiblePrimitives, explodeLinestrings);\n }\n }\n }\n\n /**\n * Return an array containing only the curve primitives.\n * @param collectorArray optional array to receive primitives. If present, new primitives are ADDED (without clearing the array.)\n * @param smallestPossiblePrimitives if false, CurvePrimitiveWithDistanceIndex returns only itself. If true, it recurses to its (otherwise hidden) children.\n */\n public collectCurvePrimitives(collectorArray?: CurvePrimitive[], smallestPossiblePrimitives: boolean = false, explodeLineStrings: boolean = false): CurvePrimitive[] {\n const results: CurvePrimitive[] = collectorArray === undefined ? [] : collectorArray;\n this.collectCurvePrimitivesGo(results, smallestPossiblePrimitives, explodeLineStrings);\n return results;\n }\n\n /** Return true for planar region types:\n * * `Loop`\n * * `ParityRegion`\n * * `UnionRegion`\n */\n public get isAnyRegionType(): boolean {\n return this.dgnBoundaryType() === 2 || this.dgnBoundaryType() === 5 || this.dgnBoundaryType() === 4;\n }\n /** Return true for a `Path`, i.e. a chain of curves joined head-to-tail\n */\n public get isOpenPath(): boolean {\n return this.dgnBoundaryType() === 1;\n }\n /** Return true for a single-loop planar region type, i.e. `Loop`.\n * * This is _not- a test for physical closure of a `Path`\n */\n public get isClosedPath(): boolean {\n return this.dgnBoundaryType() === 2;\n }\n /** Return a CurveCollection with the same structure but all curves replaced by strokes. */\n public abstract cloneStroked(options?: StrokeOptions): AnyCurve;\n\n /** Support method for ICurvePrimitive ... one line call to specific announce method . . */\n public abstract announceToCurveProcessor(processor: RecursiveCurveProcessor): void;\n /** clone an empty collection. */\n public abstract cloneEmptyPeer(): CurveCollection;\n /** Return the boundary type of a corresponding MicroStation CurveVector.\n * * Derived class must implement.\n */\n public abstract dgnBoundaryType(): number;\n /**\n * Try to add a child.\n * @param child child to add.\n * @return true if child is an acceptable type for this collection.\n */\n public abstract tryAddChild(child: AnyCurve | undefined): boolean;\n /** Return a child identified by by index */\n public abstract getChild(i: number): AnyCurve | undefined;\n /** Extend (increase) `rangeToExtend` as needed to include these curves (optionally transformed) */\n public extendRange(rangeToExtend: Range3d, transform?: Transform): void {\n const children = this.children;\n if (children) {\n for (const c of children) {\n c.extendRange(rangeToExtend, transform);\n }\n }\n }\n /**\n * * Find any curve primitive in the source.\n * * Evaluate it at a fraction (which by default is an interior fraction)\n * @param source containing `CurvePrimitive` or `CurveCollection`\n * @param fraction fraction to use in `curve.fractionToPoint(fraction)`\n */\n public static createCurveLocationDetailOnAnyCurvePrimitive(source: GeometryQuery | undefined, fraction: number = 0.5): CurveLocationDetail | undefined {\n if (!source)\n return undefined;\n if (source instanceof CurvePrimitive) {\n return CurveLocationDetail.createCurveEvaluatedFraction(source, fraction);\n } else if (source instanceof CurveCollection && source.children !== undefined)\n for (const child of source.children) {\n const detail = this.createCurveLocationDetailOnAnyCurvePrimitive(child, fraction);\n if (detail)\n return detail;\n }\n return undefined;\n }\n /** Project instance geometry (via dispatch) onto the given ray, and return the extreme fractional parameters of projection.\n * @param ray ray onto which the instance is projected. A `Vector3d` is treated as a `Ray3d` with zero origin.\n * @param lowHigh optional receiver for output\n * @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the end of the ray.\n */\n public projectedParameterRange(ray: Vector3d | Ray3d, lowHigh?: Range1d): Range1d | undefined {\n return PlaneAltitudeRangeContext.findExtremeFractionsAlongDirection(this, ray, lowHigh);\n }\n}\n\n/** Shared base class for use by both open and closed paths.\n * - A `CurveChain` contains only curvePrimitives. No other paths, loops, or regions allowed.\n * - A single entry in the chain can in fact contain multiple curve primitives if the entry itself is (for instance) `CurveChainWithDistanceIndex`\n * which presents itself (through method interface) as a CurvePrimitive with well defined mappings from fraction to xyz, but in fact does all the\n * calculations over multiple primitives.\n * - The specific derived classes are `Path` and `Loop`\n * - `CurveChain` is an intermediate class. It is not instantiable on its own.\n * @see [Curve Collections]($docs/learning/geometry/CurveCollection.md) learning article.\n * @public\n */\nexport abstract class CurveChain extends CurveCollection {\n /** The curve primitives in the chain. */\n protected _curves: CurvePrimitive[];\n protected constructor() { super(); this._curves = []; }\n /** Return the array of `CurvePrimitive` */\n public override get children(): CurvePrimitive[] {\n if (this._curves === undefined)\n this._curves = [];\n return this._curves;\n }\n /**\n * Return the `[index]` curve primitive, optionally using `modulo` to map`index` to the cyclic indexing.\n * * In particular, `-1` is the final curve.\n * @param index cyclic index\n */\n public cyclicCurvePrimitive(index: number, cyclic: boolean = true): CurvePrimitive | undefined {\n const n = this.children.length;\n if (n === 0)\n return undefined;\n /** Try simplest non-cyclic access first . . */\n if (index >= 0 && index < n)\n return this.children[index];\n if (cyclic) {\n const index2 = Geometry.modulo(index, n);\n return this.children[index2];\n }\n return undefined;\n }\n /** Stroke the chain into a simple xyz array.\n * @param options tolerance parameters controlling the stroking.\n */\n public getPackedStrokes(options?: StrokeOptions): GrowableXYZArray | undefined {\n const tree = this.cloneStroked(options);\n if (tree instanceof CurveChain) {\n const children = tree.children;\n if (children.length === 1) {\n const ls = children[0];\n if (ls instanceof LineString3d)\n return ls.packedPoints;\n }\n }\n return undefined;\n }\n /** Return a structural clone, with CurvePrimitive objects stroked. */\n public abstract override cloneStroked(options?: StrokeOptions): AnyCurve;\n /* EDL 01/20 Path, Loop, CurveChainWithDistanceIndex all implement this.\n Reducing it to abstract.\n Hypothetically, a derived class in the wild might be depending on this.\n {\n const strokes = LineString3d.create();\n for (const curve of this.children)\n curve.emitStrokes(strokes, options);\n return strokes;\n }\n */\n /** add a child curve.\n * * Returns false if the given child is not a CurvePrimitive.\n */\n public tryAddChild(child: AnyCurve | undefined): boolean {\n if (child && child instanceof CurvePrimitive) {\n this._curves.push(child);\n return true;\n }\n return false;\n }\n /** Return a child by index */\n public getChild(i: number): CurvePrimitive | undefined {\n if (i < this._curves.length) return this._curves[i];\n return undefined;\n }\n /** invoke `curve.extendRange(range, transform)` for each child */\n public override extendRange(range: Range3d, transform?: Transform): void {\n for (const curve of this._curves)\n curve.extendRange(range, transform);\n }\n /**\n * Reverse each child curve (in place)\n * Reverse the order of the children in the CurveChain array.\n */\n public reverseChildrenInPlace() {\n for (const curve of this._curves)\n curve.reverseInPlace();\n this._curves.reverse();\n }\n /** Return the index where target is found in the array of children\n * @param alsoSearchProxies whether to also check proxy curves of the children\n */\n public childIndex(target: CurvePrimitive | undefined, alsoSearchProxies?: boolean): number | undefined {\n for (let i = 0; i < this._curves.length; i++){\n if (this._curves[i] === target)\n return i;\n }\n if (alsoSearchProxies ?? false) {\n for (let i = 0; i < this._curves.length; i++) {\n const childCurve = this._curves[i];\n if (childCurve instanceof ProxyCurve) {\n if (childCurve.proxyCurve === target)\n return i;\n }\n }\n }\n return undefined;\n }\n /** Evaluate an indexed curve at a fraction. Return as a CurveLocationDetail that indicates the primitive.\n */\n public primitiveIndexAndFractionToCurveLocationDetailPointAndDerivative(index: number, fraction: number, cyclic: boolean = false, result?: CurveLocationDetail): CurveLocationDetail | undefined {\n const primitive = this.cyclicCurvePrimitive(index, cyclic);\n if (primitive) {\n return CurveLocationDetail.createCurveEvaluatedFractionPointAndDerivative(primitive, fraction, result);\n }\n return undefined;\n }\n}\n\n/**\n * * A `BagOfCurves` object is a collection of `AnyCurve` objects.\n * * A `BagOfCurves` has no implied properties such as being planar.\n * @public\n */\nexport class BagOfCurves extends CurveCollection {\n /** String name for schema properties */\n public readonly curveCollectionType = \"bagOfCurves\";\n\n /** test if `other` is an instance of `BagOfCurves` */\n public isSameGeometryClass(other: GeometryQuery): boolean { return other instanceof BagOfCurves; }\n /** Array of children.\n * * No restrictions on type.\n */\n protected _children: AnyCurve[];\n /** Construct an empty `BagOfCurves` */\n public constructor() { super(); this._children = []; }\n /** Return the (reference to) array of children */\n public override get children(): AnyCurve[] { return this._children; }\n /** create with given curves. */\n public static create(...data: AnyCurve[]): BagOfCurves {\n const result = new BagOfCurves();\n for (const child of data) {\n result.tryAddChild(child);\n }\n return result;\n }\n /** Return the boundary type (0) of a corresponding MicroStation CurveVector */\n public dgnBoundaryType(): number { return 0; }\n /** invoke `processor.announceBagOfCurves(this, indexInParent);` */\n public announceToCurveProcessor(processor: RecursiveCurveProcessor, indexInParent: number = -1): void {\n return processor.announceBagOfCurves(this, indexInParent);\n }\n /** Clone all children in stroked form. */\n public cloneStroked(options?: StrokeOptions): BagOfCurves {\n const clone = new BagOfCurves();\n let child;\n for (child of this.children) {\n if (child instanceof CurvePrimitive) {\n const ls = LineString3d.create();\n child.emitStrokes(ls, options);\n if (ls)\n clone.children.push(ls);\n } else if (child instanceof CurveCollection) {\n const childStrokes = child.cloneStroked(options);\n if (childStrokes)\n clone.children.push(childStrokes);\n }\n }\n return clone;\n }\n /** Return an empty `BagOfCurves` */\n public cloneEmptyPeer(): BagOfCurves { return new BagOfCurves(); }\n /** Add a child */\n public tryAddChild(child: AnyCurve | undefined): boolean {\n if (child)\n this._children.push(child);\n return true;\n }\n /** Get a child by index */\n public getChild(i: number): AnyCurve | undefined {\n if (i < this._children.length)\n return this._children[i];\n return undefined;\n }\n /** Second step of double dispatch: call `handler.handleBagOfCurves(this)` */\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\n return handler.handleBagOfCurves(this);\n }\n}\n/**\n * * Options to control method `RegionOps.consolidateAdjacentPrimitives`\n * @public\n */\nexport class ConsolidateAdjacentCurvePrimitivesOptions {\n /** True to consolidated linear geometry (e.g. separate LineSegment3d and LineString3d) into LineString3d */\n public consolidateLinearGeometry: boolean = true;\n /** True to consolidate contiguous arcs */\n public consolidateCompatibleArcs: boolean = true;\n /** Tolerance for collapsing identical points */\n public duplicatePointTolerance = Geometry.smallMetricDistance;\n /** Tolerance for removing interior colinear points. */\n public colinearPointTolerance = Geometry.smallMetricDistance;\n}\n"]}
1
+ {"version":3,"file":"CurveCollection.js","sourceRoot":"","sources":["../../../src/curve/CurveCollection.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,0CAAuC;AAQvC,+DAA4D;AAC5D,qDAAkD;AAElD,mDAAgD;AAChD,8EAA2E;AAC3E,kGAA+F;AAC/F,oGAAiG;AACjG,0EAAuE;AACvE,4FAAyF;AACzF,4EAAyE;AACzE,wFAAqF;AACrF,iDAA8C;AAC9C,6CAA0C;AAa1C;;;;;;;;;;;GAWG;AACH,MAAsB,eAAgB,SAAQ,6BAAa;IAA3D;;QACE,wCAAwC;QACxB,qBAAgB,GAAG,iBAAiB,CAAC;QAIrD,mEAAmE;QACnE,wDAAwD;QACjD,YAAO,GAAY,KAAK,CAAC;IA4IlC,CAAC;IA3IC,6DAA6D;IACtD,UAAU,KAAa,OAAO,qCAAiB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC1E,uDAAuD;IAChD,YAAY,CAAC,UAAmB;QACrC,IAAI,OAAwC,CAAC;QAC7C,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC/B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACjC,IAAI,KAAK,YAAY,+BAAc,EAAE;oBACnC,MAAM,OAAO,GAAG,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;oBACtD,OAAO,GAAG,yCAAmB,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;iBAChE;qBAAM,IAAI,KAAK,YAAY,eAAe,EAAE;oBAC3C,MAAM,OAAO,GAAG,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;oBAC/C,OAAO,G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C;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,2BAA2B;IACpB,QAAQ,CAAC,CAAS;QACvB,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM;YAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC3B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,8EAA8E;IACvE,yBAAyB,CAAC,OAAwB;QACvD,OAAO,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;CACF;AAhED,kCAgEC;AACD;;;GAGG;AACH,MAAa,yCAAyC;IAAtD;QACE,8GAA8G;QACvG,8BAAyB,GAAY,IAAI,CAAC;QACjD,0CAA0C;QACnC,8BAAyB,GAAY,IAAI,CAAC;QACjD,gDAAgD;QACzC,4BAAuB,GAAG,mBAAQ,CAAC,mBAAmB,CAAC;QAC9D,uDAAuD;QAChD,2BAAsB,GAAG,mBAAQ,CAAC,mBAAmB,CAAC;IAC/D,CAAC;CAAA;AATD,8FASC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Curve\n */\nimport { Geometry } from \"../Geometry\";\nimport { GeometryHandler } from \"../geometry3d/GeometryHandler\";\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\nimport { Range1d, Range3d } from \"../geometry3d/Range\";\nimport { Ray3d } from \"../geometry3d/Ray3d\";\nimport { Transform } from \"../geometry3d/Transform\";\nimport { AnyCurve } from \"./CurveChain\";\nimport { CurveLocationDetail } from \"./CurveLocationDetail\";\nimport { CurvePrimitive } from \"./CurvePrimitive\";\nimport { RecursiveCurveProcessor } from \"./CurveProcessor\";\nimport { GeometryQuery } from \"./GeometryQuery\";\nimport { CloneCurvesContext } from \"./internalContexts/CloneCurvesContext\";\nimport { CloneWithExpandedLineStrings } from \"./internalContexts/CloneWithExpandedLineStrings\";\nimport { CountLinearPartsSearchContext } from \"./internalContexts/CountLinearPartsSearchContext\";\nimport { GapSearchContext } from \"./internalContexts/GapSearchContext\";\nimport { PlaneAltitudeRangeContext } from \"./internalContexts/PlaneAltitudeRangeContext\";\nimport { SumLengthsContext } from \"./internalContexts/SumLengthsContext\";\nimport { TransformInPlaceContext } from \"./internalContexts/TransformInPlaceContext\";\nimport { LineString3d } from \"./LineString3d\";\nimport { ProxyCurve } from \"./ProxyCurve\";\nimport { StrokeOptions } from \"./StrokeOptions\";\n\n/** Describes the concrete type of a [[CurveCollection]]. Each type name maps to a specific subclass and can be used in conditional statements for type-switching.\n * - \"loop\" => [[Loop]]\n * - \"path\" => [[Path]]\n * - \"unionRegion\" => [[UnionRegion]]\n * - \"parityRegion\" => [[ParityRegion]]\n * - \"bagOfCurves\" => [[BagOfCurves]]\n * @public\n */\nexport type CurveCollectionType = \"loop\" | \"path\" | \"unionRegion\" | \"parityRegion\" | \"bagOfCurves\";\n\n/**\n * A `CurveCollection` is an abstract (non-instantiable) class for various sets of curves with particular structures:\n * - `CurveChain` is a (non-instantiable) intermediate class for a sequence of `CurvePrimitive ` joining head-to-tail. The two instantiable forms of `CurveChain` are\n * - `Path` - A chain not required to close, and not enclosing a planar area\n * - `Loop` - A chain required to close from last to first so that a planar area is enclosed.\n * - `ParityRegion` -- a collection of coplanar `Loop`s, with \"in/out\" classification by parity rules\n * - `UnionRegion` -- a collection of coplanar `Loop`s, with \"in/out\" classification by union rules\n * - `BagOfCurves` -- a collection of `AnyCurve` with no implied structure.\n *\n * @see [Curve Collections]($docs/learning/geometry/CurveCollection.md) learning article.\n * @public\n */\nexport abstract class CurveCollection extends GeometryQuery {\n /** String name for schema properties */\n public readonly geometryCategory = \"curveCollection\";\n /** Type discriminator. */\n public abstract readonly curveCollectionType: CurveCollectionType;\n\n /* eslint-disable @typescript-eslint/naming-convention, no-empty */\n /** Flag for inner loop status. Only used by `Loop`. */\n public isInner: boolean = false;\n /** Return the sum of the lengths of all contained curves. */\n public sumLengths(): number { return SumLengthsContext.sumLengths(this); }\n /** Return the closest point on the contained curves */\n public closestPoint(spacePoint: Point3d): CurveLocationDetail | undefined {\n let detailA: CurveLocationDetail | undefined;\n if (this.children !== undefined) {\n for (const child of this.children) {\n if (child instanceof CurvePrimitive) {\n const detailB = child.closestPoint(spacePoint, false);\n detailA = CurveLocationDetail.chooseSmallerA(detailA, detailB);\n } else if (child instanceof CurveCollection) {\n const detailB = child.closestPoint(spacePoint);\n detailA = CurveLocationDetail.chooseSmallerA(detailA, detailB);\n }\n }\n }\n return detailA;\n }\n\n /** return the max gap between adjacent primitives in Path and Loop collections.\n *\n * * In a Path, gaps are computed between consecutive primitives.\n * * In a Loop, gaps are computed between consecutive primitives and between last and first.\n * * gaps are NOT computed between consecutive CurvePrimitives in \"unstructured\" collections. The type is \"unstructured\" so gaps should not be semantically meaningful.\n */\n public maxGap(): number { return GapSearchContext.maxGap(this); }\n /** return true if the curve collection has any primitives other than LineSegment3d and LineString3d */\n public checkForNonLinearPrimitives(): boolean { return CountLinearPartsSearchContext.hasNonLinearPrimitives(this); }\n /** Apply transform recursively to children */\n public tryTransformInPlace(transform: Transform): boolean { return TransformInPlaceContext.tryTransformInPlace(this, transform); }\n /** Return a deep copy. */\n public override clone(): CurveCollection {\n return CloneCurvesContext.clone(this) as CurveCollection;\n }\n /** Create a deep copy of transformed curves. */\n public override cloneTransformed(transform: Transform): CurveCollection | undefined {\n return CloneCurvesContext.clone(this, transform);\n }\n /** Create a deep copy with all linestrings expanded to multiple LineSegment3d. */\n public cloneWithExpandedLineStrings(): CurveCollection {\n return CloneWithExpandedLineStrings.clone(this);\n }\n /** Recurse through children to collect CurvePrimitive's in flat array. */\n private collectCurvePrimitivesGo(results: CurvePrimitive[], smallestPossiblePrimitives: boolean, explodeLinestrings: boolean = false) {\n if (this.children) {\n for (const child of this.children) {\n if (child instanceof CurvePrimitive)\n child.collectCurvePrimitivesGo(results, smallestPossiblePrimitives, explodeLinestrings);\n else if (child instanceof CurveCollection)\n child.collectCurvePrimitivesGo(results, smallestPossiblePrimitives, explodeLinestrings);\n }\n }\n }\n\n /**\n * Return an array containing only the curve primitives.\n * @param collectorArray optional array to receive primitives. If present, new primitives are ADDED (without clearing the array.)\n * @param smallestPossiblePrimitives if false, CurvePrimitiveWithDistanceIndex returns only itself. If true, it recurses to its (otherwise hidden) children.\n */\n public collectCurvePrimitives(collectorArray?: CurvePrimitive[], smallestPossiblePrimitives: boolean = false, explodeLineStrings: boolean = false): CurvePrimitive[] {\n const results: CurvePrimitive[] = collectorArray === undefined ? [] : collectorArray;\n this.collectCurvePrimitivesGo(results, smallestPossiblePrimitives, explodeLineStrings);\n return results;\n }\n\n /** Return true for planar region types:\n * * `Loop`\n * * `ParityRegion`\n * * `UnionRegion`\n */\n public get isAnyRegionType(): boolean {\n return this.dgnBoundaryType() === 2 || this.dgnBoundaryType() === 5 || this.dgnBoundaryType() === 4;\n }\n /** Return true for a `Path`, i.e. a chain of curves joined head-to-tail\n */\n public get isOpenPath(): boolean {\n return this.dgnBoundaryType() === 1;\n }\n /** Return true for a single-loop planar region type, i.e. `Loop`.\n * * This is _not- a test for physical closure of a `Path`\n */\n public get isClosedPath(): boolean {\n return this.dgnBoundaryType() === 2;\n }\n /** Return a CurveCollection with the same structure but all curves replaced by strokes. */\n public abstract cloneStroked(options?: StrokeOptions): AnyCurve;\n\n /** Support method for ICurvePrimitive ... one line call to specific announce method . . */\n public abstract announceToCurveProcessor(processor: RecursiveCurveProcessor): void;\n /** clone an empty collection. */\n public abstract cloneEmptyPeer(): CurveCollection;\n /** Return the boundary type of a corresponding MicroStation CurveVector.\n * * Derived class must implement.\n */\n public abstract dgnBoundaryType(): number;\n /**\n * Try to add a child.\n * @param child child to add.\n * @return true if child is an acceptable type for this collection.\n */\n public abstract tryAddChild(child: AnyCurve | undefined): boolean;\n /** Return a child identified by by index */\n public abstract getChild(i: number): AnyCurve | undefined;\n /** Extend (increase) `rangeToExtend` as needed to include these curves (optionally transformed) */\n public extendRange(rangeToExtend: Range3d, transform?: Transform): void {\n const children = this.children;\n if (children) {\n for (const c of children) {\n c.extendRange(rangeToExtend, transform);\n }\n }\n }\n /**\n * * Find any curve primitive in the source.\n * * Evaluate it at a fraction (which by default is an interior fraction)\n * @param source containing `CurvePrimitive` or `CurveCollection`\n * @param fraction fraction to use in `curve.fractionToPoint(fraction)`\n */\n public static createCurveLocationDetailOnAnyCurvePrimitive(source: GeometryQuery | undefined, fraction: number = 0.5): CurveLocationDetail | undefined {\n if (!source)\n return undefined;\n if (source instanceof CurvePrimitive) {\n return CurveLocationDetail.createCurveEvaluatedFraction(source, fraction);\n } else if (source instanceof CurveCollection && source.children !== undefined)\n for (const child of source.children) {\n const detail = this.createCurveLocationDetailOnAnyCurvePrimitive(child, fraction);\n if (detail)\n return detail;\n }\n return undefined;\n }\n /** Project instance geometry (via dispatch) onto the given ray, and return the extreme fractional parameters of projection.\n * @param ray ray onto which the instance is projected. A `Vector3d` is treated as a `Ray3d` with zero origin.\n * @param lowHigh optional receiver for output\n * @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the end of the ray.\n */\n public projectedParameterRange(ray: Vector3d | Ray3d, lowHigh?: Range1d): Range1d | undefined {\n return PlaneAltitudeRangeContext.findExtremeFractionsAlongDirection(this, ray, lowHigh);\n }\n}\n\n/** Shared base class for use by both open and closed paths.\n * - A `CurveChain` contains only curvePrimitives. No other paths, loops, or regions allowed.\n * - A single entry in the chain can in fact contain multiple curve primitives if the entry itself is (for instance) `CurveChainWithDistanceIndex`\n * which presents itself (through method interface) as a CurvePrimitive with well defined mappings from fraction to xyz, but in fact does all the\n * calculations over multiple primitives.\n * - The specific derived classes are `Path` and `Loop`\n * - `CurveChain` is an intermediate class. It is not instantiable on its own.\n * @see [Curve Collections]($docs/learning/geometry/CurveCollection.md) learning article.\n * @public\n */\nexport abstract class CurveChain extends CurveCollection {\n /** The curve primitives in the chain. */\n protected _curves: CurvePrimitive[];\n protected constructor() { super(); this._curves = []; }\n /** Return the array of `CurvePrimitive` */\n public override get children(): CurvePrimitive[] {\n if (this._curves === undefined)\n this._curves = [];\n return this._curves;\n }\n /**\n * Return the `[index]` curve primitive, optionally using `modulo` to map`index` to the cyclic indexing.\n * * In particular, `-1` is the final curve.\n * @param index cyclic index\n */\n public cyclicCurvePrimitive(index: number, cyclic: boolean = true): CurvePrimitive | undefined {\n const n = this.children.length;\n if (n === 0)\n return undefined;\n /** Try simplest non-cyclic access first . . */\n if (index >= 0 && index < n)\n return this.children[index];\n if (cyclic) {\n const index2 = Geometry.modulo(index, n);\n return this.children[index2];\n }\n return undefined;\n }\n /** Stroke the chain into a simple xyz array.\n * @param options tolerance parameters controlling the stroking.\n */\n public getPackedStrokes(options?: StrokeOptions): GrowableXYZArray | undefined {\n const tree = this.cloneStroked(options);\n if (tree instanceof CurveChain) {\n const children = tree.children;\n if (children.length === 1) {\n const ls = children[0];\n if (ls instanceof LineString3d)\n return ls.packedPoints;\n }\n }\n return undefined;\n }\n /** Return a structural clone, with CurvePrimitive objects stroked. */\n public abstract override cloneStroked(options?: StrokeOptions): AnyCurve;\n /* EDL 01/20 Path, Loop, CurveChainWithDistanceIndex all implement this.\n Reducing it to abstract.\n Hypothetically, a derived class in the wild might be depending on this.\n {\n const strokes = LineString3d.create();\n for (const curve of this.children)\n curve.emitStrokes(strokes, options);\n return strokes;\n }\n */\n /** add a child curve.\n * * Returns false if the given child is not a CurvePrimitive.\n */\n public tryAddChild(child: AnyCurve | undefined): boolean {\n if (child && child instanceof CurvePrimitive) {\n this._curves.push(child);\n return true;\n }\n return false;\n }\n /** Return a child by index */\n public getChild(i: number): CurvePrimitive | undefined {\n if (i < this._curves.length) return this._curves[i];\n return undefined;\n }\n /** invoke `curve.extendRange(range, transform)` for each child */\n public override extendRange(range: Range3d, transform?: Transform): void {\n for (const curve of this._curves)\n curve.extendRange(range, transform);\n }\n /**\n * Reverse each child curve (in place)\n * Reverse the order of the children in the CurveChain array.\n */\n public reverseChildrenInPlace() {\n for (const curve of this._curves)\n curve.reverseInPlace();\n this._curves.reverse();\n }\n /** Return the index where target is found in the array of children\n * @param alsoSearchProxies whether to also check proxy curves of the children\n */\n public childIndex(target: CurvePrimitive | undefined, alsoSearchProxies?: boolean): number | undefined {\n for (let i = 0; i < this._curves.length; i++){\n if (this._curves[i] === target)\n return i;\n }\n if (alsoSearchProxies ?? false) {\n for (let i = 0; i < this._curves.length; i++) {\n const childCurve = this._curves[i];\n if (childCurve instanceof ProxyCurve) {\n if (childCurve.proxyCurve === target)\n return i;\n }\n }\n }\n return undefined;\n }\n /** Evaluate an indexed curve at a fraction. Return as a CurveLocationDetail that indicates the primitive.\n */\n public primitiveIndexAndFractionToCurveLocationDetailPointAndDerivative(index: number, fraction: number, cyclic: boolean = false, result?: CurveLocationDetail): CurveLocationDetail | undefined {\n const primitive = this.cyclicCurvePrimitive(index, cyclic);\n if (primitive) {\n return CurveLocationDetail.createCurveEvaluatedFractionPointAndDerivative(primitive, fraction, result);\n }\n return undefined;\n }\n}\n\n/**\n * * A `BagOfCurves` object is a collection of `AnyCurve` objects.\n * * A `BagOfCurves` has no implied properties such as being planar.\n * @public\n */\nexport class BagOfCurves extends CurveCollection {\n /** String name for schema properties */\n public readonly curveCollectionType = \"bagOfCurves\";\n\n /** test if `other` is an instance of `BagOfCurves` */\n public isSameGeometryClass(other: GeometryQuery): boolean { return other instanceof BagOfCurves; }\n /** Array of children.\n * * No restrictions on type.\n */\n protected _children: AnyCurve[];\n /** Construct an empty `BagOfCurves` */\n public constructor() { super(); this._children = []; }\n /** Return the (reference to) array of children */\n public override get children(): AnyCurve[] { return this._children; }\n /** create with given curves. */\n public static create(...data: AnyCurve[]): BagOfCurves {\n const result = new BagOfCurves();\n for (const child of data) {\n result.tryAddChild(child);\n }\n return result;\n }\n /** Return the boundary type (0) of a corresponding MicroStation CurveVector */\n public dgnBoundaryType(): number { return 0; }\n /** invoke `processor.announceBagOfCurves(this, indexInParent);` */\n public announceToCurveProcessor(processor: RecursiveCurveProcessor, indexInParent: number = -1): void {\n return processor.announceBagOfCurves(this, indexInParent);\n }\n /** Clone all children in stroked form. */\n public cloneStroked(options?: StrokeOptions): BagOfCurves {\n const clone = new BagOfCurves();\n let child;\n for (child of this.children) {\n if (child instanceof CurvePrimitive) {\n const ls = LineString3d.create();\n child.emitStrokes(ls, options);\n if (ls)\n clone.children.push(ls);\n } else if (child instanceof CurveCollection) {\n const childStrokes = child.cloneStroked(options);\n if (childStrokes)\n clone.children.push(childStrokes);\n }\n }\n return clone;\n }\n /** Return an empty `BagOfCurves` */\n public cloneEmptyPeer(): BagOfCurves { return new BagOfCurves(); }\n /** Add a child */\n public tryAddChild(child: AnyCurve | undefined): boolean {\n if (child)\n this._children.push(child);\n return true;\n }\n /** Get a child by index */\n public getChild(i: number): AnyCurve | undefined {\n if (i < this._children.length)\n return this._children[i];\n return undefined;\n }\n /** Second step of double dispatch: call `handler.handleBagOfCurves(this)` */\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\n return handler.handleBagOfCurves(this);\n }\n}\n/**\n * * Options to control method `RegionOps.consolidateAdjacentPrimitives`\n * @public\n */\nexport class ConsolidateAdjacentCurvePrimitivesOptions {\n /** True to consolidated linear geometry (e.g. separate LineSegment3d and LineString3d) into LineString3d */\n public consolidateLinearGeometry: boolean = true;\n /** True to consolidate contiguous arcs */\n public consolidateCompatibleArcs: boolean = true;\n /** Tolerance for collapsing identical points */\n public duplicatePointTolerance = Geometry.smallMetricDistance;\n /** Tolerance for removing interior colinear points. */\n public colinearPointTolerance = Geometry.smallMetricDistance;\n}\n"]}
@@ -56,10 +56,9 @@ class StrokeOptions {
56
56
  get hasMaxEdgeLength() { return this.maxEdgeLength !== undefined && this.maxEdgeLength > 0.0; }
57
57
  /** Return a deep clone */
58
58
  clone() {
59
- var _a;
60
59
  const options = new StrokeOptions();
61
60
  options.chordTol = this.chordTol;
62
- options.angleTol = (_a = this.angleTol) === null || _a === void 0 ? void 0 : _a.clone();
61
+ options.angleTol = this.angleTol?.clone();
63
62
  options.maxEdgeLength = this.maxEdgeLength;
64
63
  options.needConvexFacets = this.needConvexFacets;
65
64
  options.minStrokesPerPrimitive = this.minStrokesPerPrimitive;
@@ -1 +1 @@
1
- {"version":3,"file":"StrokeOptions.js","sourceRoot":"","sources":["../../../src/curve/StrokeOptions.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AACvC,+CAA4C;AAE5C,mEAAmE;AAEnE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,aAAa;IAA1B;QAYE,qDAAqD;QAC9C,sBAAiB,GAAY,KAAK,CAAC;QAe1C,8CAA8C;QACvC,yBAAoB,GAAG,EAAE,CAAC;IA+HnC,CAAC;IA3IC,oCAAoC;IACpC,IAAW,UAAU,KAAc,OAAO,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACtG,IAAW,UAAU,CAAC,KAAc,IAAI,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC;IACnE,oCAAoC;IACpC,IAAW,WAAW,KAAc,OAAO,IAAI,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACzG,IAAW,WAAW,CAAC,KAAc,IAAI,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC;IACrE,qCAAqC;IACrC,IAAW,YAAY,KAAc,OAAO,IAAI,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5G,IAAW,YAAY,CAAC,KAAc,IAAI,IAAI,C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AAS,CAAC,WAAW,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;SACpE;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD;OACG;IACI,+BAA+B,CAAC,QAAgB,EAAE,MAAc,EAAE,YAAoB;QAC3F,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,GAAG,GAAG,EAAE;YACxC,MAAM,MAAM,GAAG,mBAAQ,CAAC,yBAAyB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YACxE,IAAI,MAAM,KAAK,SAAS;gBACtB,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;SAC7D;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,iGAAiG;IAC1F,2BAA2B,CAAC,QAAgB;QACjD,IAAI,IAAI,CAAC,sBAAsB,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,sBAAsB,CAAC;eACxF,IAAI,CAAC,sBAAsB,GAAG,QAAQ;YACzC,QAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC;QACzC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,eAAe;QAC3B,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,OAAO,CAAC,QAAQ,GAAG,aAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,eAAe;QAC3B,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,OAAO,CAAC,QAAQ,GAAG,aAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA5JD,sCA4JC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Curve\n */\n\nimport { Geometry } from \"../Geometry\";\nimport { Angle } from \"../geometry3d/Angle\";\n\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\n\n/** tolerance blob for various stroking methods.\n *\n * * Across many applications, the critical concepts are: chordTol, angleTol, maxEdgeLength\n * * Chord error is an distance measured from a curve or facet to its approximating stroke or facet.\n * * angle is the angle between two contiguous strokes or across a facet edge.\n * * maxEdgeLength is the length of a stroke or a edge of a facet.\n *\n * It is rare for all three to be active at once:\n * * Nearly all stroke and facet use cases will apply an angle tolerance.\n * * * For curves, 15 degrees is typical\n * * * For facets, 22.5 degrees is typical.\n * * * Halving the angle tolerance will (roughly) make curves get twice as many strokes, and surfaces get 4 times as many facets.\n * * * The angle tolerance has the useful property that its effect is independent of scale of that data. If data is suddenly scaled into millimeters rather than meters, the facet counts remain the same.\n * * When creating output for devices such as 3D printing will want a chord tolerance.\n * * For graphics display, use an angle tolerance of around 15 degrees and an chord tolerance which is the size of several pixels.\n * * Analysis meshes (e.g. Finite Elements) commonly need to apply maxEdgeLength.\n * * * Using maxEdgeLength for graphics probably produces too many facets. For example, it causes long cylinders to get many nearly-square facets instead of the small number of long quads usually used for graphics.\n * * Facet tolerances are, as the Pirates' Code, guidelines, not absolute rules. Facet and stroke code may ignore tolerances in awkward situations.\n * * If multiple tolerances are in effect, the actual count will usually be based on the one that demands the most strokes or facets, unless it is so high that it violates some upper limit on the number of facets on an arc or a section of a curve.\n * @public\n */\nexport class StrokeOptions {\n\n /** distance from stroke to actual geometry */\n public chordTol?: number;\n /** turning angle between strokes. */\n public angleTol?: Angle;\n /** maximum length of a single stroke. */\n public maxEdgeLength?: number;\n /** caller expects convex facets. */\n public needConvexFacets?: boolean;\n /** minimum strokes on a primitive */\n public minStrokesPerPrimitive?: number;\n /** whether or not to triangulate each added facet */\n public shouldTriangulate: boolean = false;\n private _needNormals?: boolean;\n private _needTwoSided?: boolean;\n private _needParams?: boolean;\n /** Whether params are requested. */\n public get needParams(): boolean { return this._needParams !== undefined ? this._needParams : false; }\n public set needParams(value: boolean) { this._needParams = value; }\n /** Whether normals are requested */\n public get needNormals(): boolean { return this._needNormals !== undefined ? this._needNormals : false; }\n public set needNormals(value: boolean) { this._needNormals = value; }\n /** Whether twoSided is requested. */\n public get needTwoSided(): boolean { return this._needTwoSided !== undefined ? this._needTwoSided : false; }\n public set needTwoSided(value: boolean) { this._needTwoSided = value; }\n /** optional color request flag */\n public needColors?: boolean;\n /** default number of strokes for a circle. */\n public defaultCircleStrokes = 16;\n /** ask if angleTol is specified */\n public get hasAngleTol(): boolean { return this.angleTol !== undefined && Math.abs(this.angleTol.radians) > 0.0; }\n /** ask if chordTol is specified */\n public get hasChordTol(): boolean { return this.chordTol !== undefined && this.chordTol > 0.0; }\n /** ask if maxEdgeLength is specified */\n public get hasMaxEdgeLength(): boolean { return this.maxEdgeLength !== undefined && this.maxEdgeLength > 0.0; }\n\n /** Return a deep clone */\n public clone(): StrokeOptions {\n const options = new StrokeOptions();\n options.chordTol = this.chordTol;\n options.angleTol = this.angleTol?.clone();\n options.maxEdgeLength = this.maxEdgeLength;\n options.needConvexFacets = this.needConvexFacets;\n options.minStrokesPerPrimitive = this.minStrokesPerPrimitive;\n options.shouldTriangulate = this.shouldTriangulate;\n options._needNormals = this._needNormals;\n options._needTwoSided = this._needTwoSided;\n options._needParams = this._needParams;\n options.needColors = this.needColors;\n options.defaultCircleStrokes = this.defaultCircleStrokes;\n return options;\n }\n\n /** return stroke count which is the larger of the minCount or count needed for edge length condition. */\n public applyMaxEdgeLength(minCount: number, totalLength: number): number {\n totalLength = Math.abs(totalLength);\n if (this.maxEdgeLength && this.maxEdgeLength > 0.0 && minCount * this.maxEdgeLength < totalLength) {\n minCount = Geometry.stepCount(this.maxEdgeLength, totalLength, minCount);\n }\n return minCount;\n }\n\n /**\n * return stroke count which is the larger of the existing count or count needed for angle condition for given sweepRadians\n * * defaultStepRadians is assumed to be larger than zero.\n */\n public applyAngleTol(minCount: number, sweepRadians: number, defaultStepRadians: number): number {\n return StrokeOptions.applyAngleTol(this, minCount, sweepRadians, defaultStepRadians);\n }\n /**\n * return stroke count which is the larger of minCount and the count required to turn sweepRadians, using tolerance from the options.\n */\n public static applyAngleTol(options: StrokeOptions | undefined, minCount: number, sweepRadians: number, defaultStepRadians?: number): number {\n sweepRadians = Math.abs(sweepRadians);\n let stepRadians = defaultStepRadians ? defaultStepRadians : Math.PI / 8.0;\n if (options && options.angleTol && options.angleTol.radians > 0.0)\n stepRadians = options.angleTol.radians;\n if (minCount * stepRadians < sweepRadians)\n minCount = Geometry.stepCount(stepRadians, sweepRadians, minCount);\n return minCount;\n }\n /**\n * Return the number of strokes needed for given edgeLength curve.\n * @param options\n * @param minCount smallest allowed count\n * @param edgeLength\n */\n public static applyMaxEdgeLength(options: StrokeOptions | undefined, minCount: number, edgeLength: number): number {\n if (edgeLength < 0)\n edgeLength = - edgeLength;\n if (minCount < 1)\n minCount = 1;\n if (options && options.maxEdgeLength && options.maxEdgeLength * minCount < edgeLength) {\n minCount = Geometry.stepCount(options.maxEdgeLength, edgeLength, minCount);\n }\n return minCount;\n }\n /**\n * Determine a stroke count for a (partial) circular arc of given radius. This considers angle, maxEdgeLength, chord, and minimum stroke.\n */\n public applyTolerancesToArc(radius: number, sweepRadians: number = Math.PI * 2): number {\n let numStrokes = 1;\n numStrokes = this.applyAngleTol(numStrokes, sweepRadians, Math.PI * 0.25);\n numStrokes = this.applyMaxEdgeLength(numStrokes, sweepRadians * radius);\n numStrokes = this.applyChordTol(numStrokes, radius, sweepRadians);\n numStrokes = this.applyMinStrokesPerPrimitive(numStrokes);\n return numStrokes;\n }\n\n /** return stroke count which is the larger of existing count or count needed for circular arc chord tolerance condition. */\n public applyChordTol(minCount: number, radius: number, sweepRadians: number): number {\n if (this.chordTol && this.chordTol > 0.0 && this.chordTol < radius) {\n const a = this.chordTol;\n const stepRadians = 2.0 * Math.acos((1.0 - a / radius));\n minCount = Geometry.stepCount(stepRadians, sweepRadians, minCount);\n }\n return minCount;\n }\n /** return stroke count which is the larger of existing count or count needed for circular arc chord tol with given arc length and radians\n */\n public applyChordTolToLengthAndRadians(minCount: number, length: number, sweepRadians: number): number {\n if (this.chordTol && this.chordTol > 0.0) {\n const radius = Geometry.conditionalDivideFraction(length, sweepRadians);\n if (radius !== undefined)\n return this.applyChordTol(minCount, radius, sweepRadians);\n }\n return minCount;\n }\n\n /** return stroke count which is the larger of existing count or `this.minStrokesPerPrimitive` */\n public applyMinStrokesPerPrimitive(minCount: number): number {\n if (this.minStrokesPerPrimitive !== undefined && Number.isFinite(this.minStrokesPerPrimitive)\n && this.minStrokesPerPrimitive > minCount)\n minCount = this.minStrokesPerPrimitive;\n return minCount;\n }\n\n /** create `StrokeOptions` with defaults appropriate for curves.\n * * angle tolerance of 15 degrees.\n * * all others inactive.\n */\n public static createForCurves(): StrokeOptions {\n const options = new StrokeOptions();\n options.angleTol = Angle.createDegrees(15.0);\n return options;\n }\n /** create `StrokeOptions` with defaults appropriate for surfaces facets\n * * angle tolerance of 22.5 degrees.\n * * all others inactive.\n */\n public static createForFacets(): StrokeOptions {\n const options = new StrokeOptions();\n options.angleTol = Angle.createDegrees(22.5);\n return options;\n }\n}\n"]}
1
+ {"version":3,"file":"StrokeOptions.js","sourceRoot":"","sources":["../../../src/curve/StrokeOptions.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AACvC,+CAA4C;AAE5C,mEAAmE;AAEnE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,aAAa;IAA1B;QAYE,qDAAqD;QAC9C,sBAAiB,GAAY,KAAK,CAAC;QAe1C,8CAA8C;QACvC,yBAAoB,GAAG,EAAE,CAAC;IA+HnC,CAAC;IA3IC,oCAAoC;IACpC,IAAW,UAAU,KAAc,OAAO,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,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ACzC,QAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC;QACzC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,eAAe;QAC3B,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,OAAO,CAAC,QAAQ,GAAG,aAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,eAAe;QAC3B,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,OAAO,CAAC,QAAQ,GAAG,aAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA5JD,sCA4JC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Curve\n */\n\nimport { Geometry } from \"../Geometry\";\nimport { Angle } from \"../geometry3d/Angle\";\n\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\n\n/** tolerance blob for various stroking methods.\n *\n * * Across many applications, the critical concepts are: chordTol, angleTol, maxEdgeLength\n * * Chord error is an distance measured from a curve or facet to its approximating stroke or facet.\n * * angle is the angle between two contiguous strokes or across a facet edge.\n * * maxEdgeLength is the length of a stroke or a edge of a facet.\n *\n * It is rare for all three to be active at once:\n * * Nearly all stroke and facet use cases will apply an angle tolerance.\n * * * For curves, 15 degrees is typical\n * * * For facets, 22.5 degrees is typical.\n * * * Halving the angle tolerance will (roughly) make curves get twice as many strokes, and surfaces get 4 times as many facets.\n * * * The angle tolerance has the useful property that its effect is independent of scale of that data. If data is suddenly scaled into millimeters rather than meters, the facet counts remain the same.\n * * When creating output for devices such as 3D printing will want a chord tolerance.\n * * For graphics display, use an angle tolerance of around 15 degrees and an chord tolerance which is the size of several pixels.\n * * Analysis meshes (e.g. Finite Elements) commonly need to apply maxEdgeLength.\n * * * Using maxEdgeLength for graphics probably produces too many facets. For example, it causes long cylinders to get many nearly-square facets instead of the small number of long quads usually used for graphics.\n * * Facet tolerances are, as the Pirates' Code, guidelines, not absolute rules. Facet and stroke code may ignore tolerances in awkward situations.\n * * If multiple tolerances are in effect, the actual count will usually be based on the one that demands the most strokes or facets, unless it is so high that it violates some upper limit on the number of facets on an arc or a section of a curve.\n * @public\n */\nexport class StrokeOptions {\n\n /** distance from stroke to actual geometry */\n public chordTol?: number;\n /** turning angle between strokes. */\n public angleTol?: Angle;\n /** maximum length of a single stroke. */\n public maxEdgeLength?: number;\n /** caller expects convex facets. */\n public needConvexFacets?: boolean;\n /** minimum strokes on a primitive */\n public minStrokesPerPrimitive?: number;\n /** whether or not to triangulate each added facet */\n public shouldTriangulate: boolean = false;\n private _needNormals?: boolean;\n private _needTwoSided?: boolean;\n private _needParams?: boolean;\n /** Whether params are requested. */\n public get needParams(): boolean { return this._needParams !== undefined ? this._needParams : false; }\n public set needParams(value: boolean) { this._needParams = value; }\n /** Whether normals are requested */\n public get needNormals(): boolean { return this._needNormals !== undefined ? this._needNormals : false; }\n public set needNormals(value: boolean) { this._needNormals = value; }\n /** Whether twoSided is requested. */\n public get needTwoSided(): boolean { return this._needTwoSided !== undefined ? this._needTwoSided : false; }\n public set needTwoSided(value: boolean) { this._needTwoSided = value; }\n /** optional color request flag */\n public needColors?: boolean;\n /** default number of strokes for a circle. */\n public defaultCircleStrokes = 16;\n /** ask if angleTol is specified */\n public get hasAngleTol(): boolean { return this.angleTol !== undefined && Math.abs(this.angleTol.radians) > 0.0; }\n /** ask if chordTol is specified */\n public get hasChordTol(): boolean { return this.chordTol !== undefined && this.chordTol > 0.0; }\n /** ask if maxEdgeLength is specified */\n public get hasMaxEdgeLength(): boolean { return this.maxEdgeLength !== undefined && this.maxEdgeLength > 0.0; }\n\n /** Return a deep clone */\n public clone(): StrokeOptions {\n const options = new StrokeOptions();\n options.chordTol = this.chordTol;\n options.angleTol = this.angleTol?.clone();\n options.maxEdgeLength = this.maxEdgeLength;\n options.needConvexFacets = this.needConvexFacets;\n options.minStrokesPerPrimitive = this.minStrokesPerPrimitive;\n options.shouldTriangulate = this.shouldTriangulate;\n options._needNormals = this._needNormals;\n options._needTwoSided = this._needTwoSided;\n options._needParams = this._needParams;\n options.needColors = this.needColors;\n options.defaultCircleStrokes = this.defaultCircleStrokes;\n return options;\n }\n\n /** return stroke count which is the larger of the minCount or count needed for edge length condition. */\n public applyMaxEdgeLength(minCount: number, totalLength: number): number {\n totalLength = Math.abs(totalLength);\n if (this.maxEdgeLength && this.maxEdgeLength > 0.0 && minCount * this.maxEdgeLength < totalLength) {\n minCount = Geometry.stepCount(this.maxEdgeLength, totalLength, minCount);\n }\n return minCount;\n }\n\n /**\n * return stroke count which is the larger of the existing count or count needed for angle condition for given sweepRadians\n * * defaultStepRadians is assumed to be larger than zero.\n */\n public applyAngleTol(minCount: number, sweepRadians: number, defaultStepRadians: number): number {\n return StrokeOptions.applyAngleTol(this, minCount, sweepRadians, defaultStepRadians);\n }\n /**\n * return stroke count which is the larger of minCount and the count required to turn sweepRadians, using tolerance from the options.\n */\n public static applyAngleTol(options: StrokeOptions | undefined, minCount: number, sweepRadians: number, defaultStepRadians?: number): number {\n sweepRadians = Math.abs(sweepRadians);\n let stepRadians = defaultStepRadians ? defaultStepRadians : Math.PI / 8.0;\n if (options && options.angleTol && options.angleTol.radians > 0.0)\n stepRadians = options.angleTol.radians;\n if (minCount * stepRadians < sweepRadians)\n minCount = Geometry.stepCount(stepRadians, sweepRadians, minCount);\n return minCount;\n }\n /**\n * Return the number of strokes needed for given edgeLength curve.\n * @param options\n * @param minCount smallest allowed count\n * @param edgeLength\n */\n public static applyMaxEdgeLength(options: StrokeOptions | undefined, minCount: number, edgeLength: number): number {\n if (edgeLength < 0)\n edgeLength = - edgeLength;\n if (minCount < 1)\n minCount = 1;\n if (options && options.maxEdgeLength && options.maxEdgeLength * minCount < edgeLength) {\n minCount = Geometry.stepCount(options.maxEdgeLength, edgeLength, minCount);\n }\n return minCount;\n }\n /**\n * Determine a stroke count for a (partial) circular arc of given radius. This considers angle, maxEdgeLength, chord, and minimum stroke.\n */\n public applyTolerancesToArc(radius: number, sweepRadians: number = Math.PI * 2): number {\n let numStrokes = 1;\n numStrokes = this.applyAngleTol(numStrokes, sweepRadians, Math.PI * 0.25);\n numStrokes = this.applyMaxEdgeLength(numStrokes, sweepRadians * radius);\n numStrokes = this.applyChordTol(numStrokes, radius, sweepRadians);\n numStrokes = this.applyMinStrokesPerPrimitive(numStrokes);\n return numStrokes;\n }\n\n /** return stroke count which is the larger of existing count or count needed for circular arc chord tolerance condition. */\n public applyChordTol(minCount: number, radius: number, sweepRadians: number): number {\n if (this.chordTol && this.chordTol > 0.0 && this.chordTol < radius) {\n const a = this.chordTol;\n const stepRadians = 2.0 * Math.acos((1.0 - a / radius));\n minCount = Geometry.stepCount(stepRadians, sweepRadians, minCount);\n }\n return minCount;\n }\n /** return stroke count which is the larger of existing count or count needed for circular arc chord tol with given arc length and radians\n */\n public applyChordTolToLengthAndRadians(minCount: number, length: number, sweepRadians: number): number {\n if (this.chordTol && this.chordTol > 0.0) {\n const radius = Geometry.conditionalDivideFraction(length, sweepRadians);\n if (radius !== undefined)\n return this.applyChordTol(minCount, radius, sweepRadians);\n }\n return minCount;\n }\n\n /** return stroke count which is the larger of existing count or `this.minStrokesPerPrimitive` */\n public applyMinStrokesPerPrimitive(minCount: number): number {\n if (this.minStrokesPerPrimitive !== undefined && Number.isFinite(this.minStrokesPerPrimitive)\n && this.minStrokesPerPrimitive > minCount)\n minCount = this.minStrokesPerPrimitive;\n return minCount;\n }\n\n /** create `StrokeOptions` with defaults appropriate for curves.\n * * angle tolerance of 15 degrees.\n * * all others inactive.\n */\n public static createForCurves(): StrokeOptions {\n const options = new StrokeOptions();\n options.angleTol = Angle.createDegrees(15.0);\n return options;\n }\n /** create `StrokeOptions` with defaults appropriate for surfaces facets\n * * angle tolerance of 22.5 degrees.\n * * all others inactive.\n */\n public static createForFacets(): StrokeOptions {\n const options = new StrokeOptions();\n options.angleTol = Angle.createDegrees(22.5);\n return options;\n }\n}\n"]}
@@ -322,8 +322,7 @@ class DirectSpiral3d extends TransitionSpiral3d_1.TransitionSpiral3d {
322
322
  }
323
323
  /** Deep clone of this spiral */
324
324
  clone() {
325
- var _a, _b;
326
- return new DirectSpiral3d(this.localToWorld.clone(), this._spiralType, (_a = this.designProperties) === null || _a === void 0 ? void 0 : _a.clone(), this._nominalL1, this._nominalR1, (_b = this._activeFractionInterval) === null || _b === void 0 ? void 0 : _b.clone(), this._evaluator.clone());
325
+ return new DirectSpiral3d(this.localToWorld.clone(), this._spiralType, this.designProperties?.clone(), this._nominalL1, this._nominalR1, this._activeFractionInterval?.clone(), this._evaluator.clone());
327
326
  }
328
327
  /** apply `transform` to this spiral's local to world transform. */
329
328
  tryTransformInPlace(transformA) {