@itwin/core-geometry 4.9.0-dev.19 → 4.9.0-dev.20

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 (79) hide show
  1. package/lib/cjs/curve/CurveOps.d.ts +4 -4
  2. package/lib/cjs/curve/CurveOps.d.ts.map +1 -1
  3. package/lib/cjs/curve/CurveOps.js +6 -6
  4. package/lib/cjs/curve/CurveOps.js.map +1 -1
  5. package/lib/cjs/curve/CurvePrimitive.d.ts +1 -1
  6. package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
  7. package/lib/cjs/curve/Query/CylindricalRange.js.map +1 -1
  8. package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts +11 -8
  9. package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts.map +1 -1
  10. package/lib/cjs/curve/internalContexts/MultiChainCollector.js +7 -4
  11. package/lib/cjs/curve/internalContexts/MultiChainCollector.js.map +1 -1
  12. package/lib/cjs/geometry3d/FrameBuilder.d.ts +2 -1
  13. package/lib/cjs/geometry3d/FrameBuilder.d.ts.map +1 -1
  14. package/lib/cjs/geometry3d/FrameBuilder.js +12 -10
  15. package/lib/cjs/geometry3d/FrameBuilder.js.map +1 -1
  16. package/lib/cjs/geometry3d/PolygonOps.d.ts +4 -4
  17. package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
  18. package/lib/cjs/geometry3d/PolygonOps.js +7 -11
  19. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  20. package/lib/cjs/geometry3d/Ray3d.d.ts +1 -1
  21. package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
  22. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  23. package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
  24. package/lib/cjs/polyface/PolyfaceBuilder.js +3 -2
  25. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  26. package/lib/cjs/polyface/PolyfaceClip.d.ts +13 -10
  27. package/lib/cjs/polyface/PolyfaceClip.d.ts.map +1 -1
  28. package/lib/cjs/polyface/PolyfaceClip.js +17 -14
  29. package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
  30. package/lib/cjs/polyface/PolyfaceQuery.d.ts +8 -11
  31. package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
  32. package/lib/cjs/polyface/PolyfaceQuery.js +56 -49
  33. package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
  34. package/lib/cjs/solid/SweepContour.d.ts.map +1 -1
  35. package/lib/cjs/solid/SweepContour.js +0 -4
  36. package/lib/cjs/solid/SweepContour.js.map +1 -1
  37. package/lib/cjs/topology/Merging.d.ts +2 -2
  38. package/lib/cjs/topology/Merging.js +2 -2
  39. package/lib/cjs/topology/Merging.js.map +1 -1
  40. package/lib/esm/curve/CurveOps.d.ts +4 -4
  41. package/lib/esm/curve/CurveOps.d.ts.map +1 -1
  42. package/lib/esm/curve/CurveOps.js +6 -6
  43. package/lib/esm/curve/CurveOps.js.map +1 -1
  44. package/lib/esm/curve/CurvePrimitive.d.ts +1 -1
  45. package/lib/esm/curve/CurvePrimitive.js.map +1 -1
  46. package/lib/esm/curve/Query/CylindricalRange.js.map +1 -1
  47. package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts +11 -8
  48. package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts.map +1 -1
  49. package/lib/esm/curve/internalContexts/MultiChainCollector.js +7 -4
  50. package/lib/esm/curve/internalContexts/MultiChainCollector.js.map +1 -1
  51. package/lib/esm/geometry3d/FrameBuilder.d.ts +2 -1
  52. package/lib/esm/geometry3d/FrameBuilder.d.ts.map +1 -1
  53. package/lib/esm/geometry3d/FrameBuilder.js +12 -10
  54. package/lib/esm/geometry3d/FrameBuilder.js.map +1 -1
  55. package/lib/esm/geometry3d/PolygonOps.d.ts +4 -4
  56. package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
  57. package/lib/esm/geometry3d/PolygonOps.js +7 -11
  58. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  59. package/lib/esm/geometry3d/Ray3d.d.ts +1 -1
  60. package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
  61. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  62. package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
  63. package/lib/esm/polyface/PolyfaceBuilder.js +3 -2
  64. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  65. package/lib/esm/polyface/PolyfaceClip.d.ts +13 -10
  66. package/lib/esm/polyface/PolyfaceClip.d.ts.map +1 -1
  67. package/lib/esm/polyface/PolyfaceClip.js +17 -14
  68. package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
  69. package/lib/esm/polyface/PolyfaceQuery.d.ts +8 -11
  70. package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
  71. package/lib/esm/polyface/PolyfaceQuery.js +56 -49
  72. package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
  73. package/lib/esm/solid/SweepContour.d.ts.map +1 -1
  74. package/lib/esm/solid/SweepContour.js +0 -4
  75. package/lib/esm/solid/SweepContour.js.map +1 -1
  76. package/lib/esm/topology/Merging.d.ts +2 -2
  77. package/lib/esm/topology/Merging.js +2 -2
  78. package/lib/esm/topology/Merging.js.map +1 -1
  79. package/package.json +3 -3
@@ -61,16 +61,16 @@ export declare class CurveOps {
61
61
  * @param planeTolerance tolerance for considering a closed chain to be planar. If undefined, only create Path. If defined, create Loops for closed chains within tolerance of a plane.
62
62
  * @returns chains, possibly wrapped in a [[BagOfCurves]].
63
63
  */
64
- static collectChains(fragments: AnyCurve[], gapTolerance?: number, planeTolerance?: number | undefined): AnyChain | undefined;
64
+ static collectChains(fragments: AnyCurve[], gapTolerance?: number, planeTolerance?: number): AnyChain | undefined;
65
65
  /**
66
- * Restructure curve fragments as Paths and Loops, to be stroked and passed into the callback.
66
+ * Restructure curve fragments, to be stroked and passed into the callback.
67
67
  * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.
68
68
  * @param fragments fragments to be chained and stroked
69
69
  * @param announceChain callback to process each stroked Path and Loop
70
70
  * @param strokeOptions options for stroking the chains
71
71
  * @param gapTolerance distance to be treated as "effectively zero" when assembling fragments head-to-tail. Also used for removing duplicate points in the stroked chains.
72
- * @param planeTolerance tolerance for considering a closed chain to be planar. If undefined, only create Path. If defined, create Loops for closed chains within tolerance of a plane.
72
+ * @param _planeTolerance unused, pass undefined
73
73
  */
74
- static collectChainsAsLineString3d(fragments: AnyCurve[], announceChain: (chainPoints: LineString3d) => void, strokeOptions?: StrokeOptions, gapTolerance?: number, planeTolerance?: number | undefined): void;
74
+ static collectChainsAsLineString3d(fragments: AnyCurve[], announceChain: (chainPoints: LineString3d) => void, strokeOptions?: StrokeOptions, gapTolerance?: number, _planeTolerance?: number): void;
75
75
  }
76
76
  //# sourceMappingURL=CurveOps.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CurveOps.d.ts","sourceRoot":"","sources":["../../../src/curve/CurveOps.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAe,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;GAGG;AACH,qBAAa,QAAQ;IACnB,8GAA8G;WAChG,UAAU,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ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IAGvI;;;;OAIG;WACW,6BAA6B,CAAC,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,GAAG,aAAa,GAAG,cAAc,GAAG,cAAc,EAAE,GAAG,SAAS;IAGlK;;;;;;;OAOG;WACW,aAAa,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,YAAY,GAAE,MAAqC,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAOtJ;;;;;;;;OAQG;WACW,2BAA2B,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,aAAa,EAAE,CAAC,WAAW,EAAE,YAAY,KAAK,IAAI,EAAE,aAAa,CAAC,EAAE,aAAa,EAAE,YAAY,GAAE,MAAqC,EAAE,eAAe,CAAC,EAAE,MAAM;CAOlO"}
@@ -91,7 +91,7 @@ class CurveOps {
91
91
  * @returns object with named chains, insideOffsets, outsideOffsets
92
92
  */
93
93
  static collectInsideAndOutsideXYOffsets(fragments, offsetDistance, gapTolerance) {
94
- const collector = new MultiChainCollector_1.MultiChainCollector(gapTolerance);
94
+ const collector = new MultiChainCollector_1.MultiChainCollector(gapTolerance, gapTolerance);
95
95
  for (const s of fragments) {
96
96
  collector.captureCurve(s);
97
97
  }
@@ -132,7 +132,7 @@ class CurveOps {
132
132
  * @param planeTolerance tolerance for considering a closed chain to be planar. If undefined, only create Path. If defined, create Loops for closed chains within tolerance of a plane.
133
133
  * @returns chains, possibly wrapped in a [[BagOfCurves]].
134
134
  */
135
- static collectChains(fragments, gapTolerance = Geometry_1.Geometry.smallMetricDistance, planeTolerance = Geometry_1.Geometry.smallMetricDistance) {
135
+ static collectChains(fragments, gapTolerance = Geometry_1.Geometry.smallMetricDistance, planeTolerance) {
136
136
  const collector = new MultiChainCollector_1.MultiChainCollector(gapTolerance, planeTolerance);
137
137
  for (const s of fragments) {
138
138
  collector.captureCurve(s);
@@ -140,16 +140,16 @@ class CurveOps {
140
140
  return collector.grabResult(true);
141
141
  }
142
142
  /**
143
- * Restructure curve fragments as Paths and Loops, to be stroked and passed into the callback.
143
+ * Restructure curve fragments, to be stroked and passed into the callback.
144
144
  * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.
145
145
  * @param fragments fragments to be chained and stroked
146
146
  * @param announceChain callback to process each stroked Path and Loop
147
147
  * @param strokeOptions options for stroking the chains
148
148
  * @param gapTolerance distance to be treated as "effectively zero" when assembling fragments head-to-tail. Also used for removing duplicate points in the stroked chains.
149
- * @param planeTolerance tolerance for considering a closed chain to be planar. If undefined, only create Path. If defined, create Loops for closed chains within tolerance of a plane.
149
+ * @param _planeTolerance unused, pass undefined
150
150
  */
151
- static collectChainsAsLineString3d(fragments, announceChain, strokeOptions, gapTolerance = Geometry_1.Geometry.smallMetricDistance, planeTolerance = Geometry_1.Geometry.smallMetricDistance) {
152
- const collector = new MultiChainCollector_1.MultiChainCollector(gapTolerance, planeTolerance);
151
+ static collectChainsAsLineString3d(fragments, announceChain, strokeOptions, gapTolerance = Geometry_1.Geometry.smallMetricDistance, _planeTolerance) {
152
+ const collector = new MultiChainCollector_1.MultiChainCollector(gapTolerance); // no planarity tolerance needed
153
153
  for (const s of fragments) {
154
154
  collector.captureCurve(s);
155
155
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CurveOps.js","sourceRoot":"","sources":["../../../src/curve/CurveOps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AAEvC,uDAAiE;AACjE,qDAAkD;AAElD,gFAA6E;AAC7E,kFAAsF;AAEtF,iCAA8B;AAE9B,iCAA8B;AAG9B;;;GAGG;AACH,MAAa,QAAQ;IACnB,8GAA8G;IACvG,MAAM,CAAC,UAAU,CAAC,MAA6B;QACpD,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,MAAM,YAAY,+BAAc,EAAE,CAAC;YACrC,KAAK,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QAChC,CAAC;aAAM,IAAI,MAAM,YAAY,iCAAe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C,aAAa,EAAE,aAAa,CAAC,CAAC;IACvE,CAAC;CACF;AAjID,4BAiIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { BagOfCurves, CurveCollection } from \"./CurveCollection\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { AnyChain, AnyCurve } from \"./CurveTypes\";\r\nimport { MultiChainCollector } from \"./internalContexts/MultiChainCollector\";\r\nimport { CurveChainWireOffsetContext } from \"./internalContexts/PolygonOffsetContext\";\r\nimport { LineString3d } from \"./LineString3d\";\r\nimport { Loop } from \"./Loop\";\r\nimport { OffsetOptions } from \"./OffsetOptions\";\r\nimport { Path } from \"./Path\";\r\nimport { StrokeOptions } from \"./StrokeOptions\";\r\n\r\n/**\r\n * Static methods for miscellaneous curve operations.\r\n * @public\r\n */\r\nexport class CurveOps {\r\n /** Recursively sum curve lengths, allowing CurvePrimitive, CurveCollection, or array of such at any level. */\r\n public static sumLengths(curves: AnyCurve | AnyCurve[]): number {\r\n let mySum = 0;\r\n if (curves instanceof CurvePrimitive) {\r\n mySum += curves.curveLength();\r\n } else if (curves instanceof CurveCollection) {\r\n mySum += curves.sumLengths();\r\n } else if (Array.isArray(curves)) {\r\n for (const data1 of curves)\r\n mySum += this.sumLengths(data1);\r\n }\r\n return mySum;\r\n }\r\n /** Recursively extend the range by each curve's range, allowing CurvePrimitive, CurveCollection, or array of such at any level. */\r\n public static extendRange(range: Range3d, curves: AnyCurve | AnyCurve[]): Range3d {\r\n if (Array.isArray(curves)) {\r\n for (const data1 of curves)\r\n this.extendRange(range, data1);\r\n } else {\r\n curves.extendRange(range);\r\n }\r\n return range;\r\n }\r\n /**\r\n * Construct a separate xy-offset for each input curve.\r\n * * For best offset results, the inputs should be parallel to the xy-plane.\r\n * @param curves input curve(s), z-coordinates ignored. Only curves of type [[AnyChain]] are handled.\r\n * @param offset offset distance (positive to left of curve, negative to right)\r\n * @param result array to collect offset curves\r\n * @returns summed length of offset curves\r\n */\r\n public static appendXYOffsets(curves: AnyCurve | AnyCurve[] | undefined, offset: number, result: AnyCurve[]): number {\r\n let summedLengths = 0;\r\n if (curves instanceof CurvePrimitive) {\r\n const resultA = CurveChainWireOffsetContext.constructCurveXYOffset(Path.create(curves), offset);\r\n if (resultA) {\r\n summedLengths += this.sumLengths(resultA);\r\n result.push(resultA);\r\n }\r\n } else if (curves instanceof Loop || curves instanceof Path) {\r\n const resultA = CurveChainWireOffsetContext.constructCurveXYOffset(curves, offset);\r\n if (resultA) {\r\n summedLengths += this.sumLengths(resultA);\r\n result.push(resultA);\r\n }\r\n } else if (curves instanceof BagOfCurves) {\r\n for (const q of curves.children)\r\n summedLengths += this.appendXYOffsets(q, offset, result);\r\n } else if (Array.isArray(curves)) {\r\n for (const q of curves)\r\n summedLengths += this.appendXYOffsets(q, offset, result);\r\n }\r\n return summedLengths;\r\n }\r\n /**\r\n * Restructure curve fragments as Paths and Loops, and construct xy-offsets of the chains.\r\n * * If the inputs do not form Loop(s), the classification of offsets is suspect.\r\n * * For best offset results, the inputs should be parallel to the xy-plane.\r\n * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.\r\n * @param fragments fragments to be chained and offset\r\n * @param offsetDistance offset distance, applied to both sides of each fragment to produce inside and outside xy-offset curves.\r\n * @param gapTolerance distance to be treated as \"effectively zero\" when joining head-to-tail\r\n * @returns object with named chains, insideOffsets, outsideOffsets\r\n */\r\n public static collectInsideAndOutsideXYOffsets(fragments: AnyCurve[], offsetDistance: number, gapTolerance: number): { insideOffsets: AnyCurve[], outsideOffsets: AnyCurve[], chains?: AnyChain } {\r\n const collector = new MultiChainCollector(gapTolerance);\r\n for (const s of fragments) {\r\n collector.captureCurve(s);\r\n }\r\n const chains = collector.grabResult(true);\r\n const myOffsetA: CurveCollection[] = [];\r\n const myOffsetB: CurveCollection[] = [];\r\n const offsetLengthA = CurveOps.appendXYOffsets(chains, offsetDistance, myOffsetA);\r\n const offsetLengthB = CurveOps.appendXYOffsets(chains, -offsetDistance, myOffsetB);\r\n if (offsetLengthA > offsetLengthB) {\r\n return { outsideOffsets: myOffsetA, insideOffsets: myOffsetB, chains };\r\n } else {\r\n return { insideOffsets: myOffsetA, outsideOffsets: myOffsetB, chains };\r\n }\r\n }\r\n /**\r\n * Construct curves that are offset from a Path or Loop as viewed in xy-plane (ignoring z).\r\n * * The construction will remove \"some\" local effects of features smaller than the offset distance, but will not detect self intersection among widely separated edges.\r\n * @param curves base curves.\r\n * @param offsetDistanceOrOptions offset distance (positive to left of curve, negative to right) or options object.\r\n */\r\n public static constructCurveXYOffset(curves: Path | Loop, offsetDistanceOrOptions: number | OffsetOptions): CurveCollection | undefined {\r\n return CurveChainWireOffsetContext.constructCurveXYOffset(curves, offsetDistanceOrOptions);\r\n }\r\n /**\r\n * Create the offset of a single curve primitive as viewed in the xy-plane (ignoring z).\r\n * @param curve primitive to offset\r\n * @param offsetDistanceOrOptions offset distance (positive to left of curve, negative to right) or options object\r\n */\r\n public static createSingleOffsetPrimitiveXY(curve: CurvePrimitive, offsetDistanceOrOptions: number | OffsetOptions): CurvePrimitive | CurvePrimitive[] | undefined {\r\n return CurveChainWireOffsetContext.createSingleOffsetPrimitiveXY(curve, offsetDistanceOrOptions);\r\n }\r\n /**\r\n * Restructure curve fragments as Paths and Loops.\r\n * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.\r\n * @param fragments fragments to be chained\r\n * @param gapTolerance distance to be treated as \"effectively zero\" when assembling fragments head-to-tail\r\n * @param planeTolerance tolerance for considering a closed chain to be planar. If undefined, only create Path. If defined, create Loops for closed chains within tolerance of a plane.\r\n * @returns chains, possibly wrapped in a [[BagOfCurves]].\r\n */\r\n public static collectChains(fragments: AnyCurve[], gapTolerance: number = Geometry.smallMetricDistance, planeTolerance: number | undefined = Geometry.smallMetricDistance): AnyChain | undefined {\r\n const collector = new MultiChainCollector(gapTolerance, planeTolerance);\r\n for (const s of fragments) {\r\n collector.captureCurve(s);\r\n }\r\n return collector.grabResult(true);\r\n }\r\n /**\r\n * Restructure curve fragments as Paths and Loops, to be stroked and passed into the callback.\r\n * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.\r\n * @param fragments fragments to be chained and stroked\r\n * @param announceChain callback to process each stroked Path and Loop\r\n * @param strokeOptions options for stroking the chains\r\n * @param gapTolerance distance to be treated as \"effectively zero\" when assembling fragments head-to-tail. Also used for removing duplicate points in the stroked chains.\r\n * @param planeTolerance tolerance for considering a closed chain to be planar. If undefined, only create Path. If defined, create Loops for closed chains within tolerance of a plane.\r\n */\r\n public static collectChainsAsLineString3d(fragments: AnyCurve[], announceChain: (chainPoints: LineString3d) => void, strokeOptions?: StrokeOptions, gapTolerance: number = Geometry.smallMetricDistance, planeTolerance: number | undefined = Geometry.smallMetricDistance) {\r\n const collector = new MultiChainCollector(gapTolerance, planeTolerance);\r\n for (const s of fragments) {\r\n collector.captureCurve(s);\r\n }\r\n collector.announceChainsAsLineString3d(announceChain, strokeOptions);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"CurveOps.js","sourceRoot":"","sources":["../../../src/curve/CurveOps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AAEvC,uDAAiE;AACjE,qDAAkD;AAElD,gFAA6E;AAC7E,kFAAsF;AAEtF,iCAA8B;AAE9B,iCAA8B;AAG9B;;;GAGG;AACH,MAAa,QAAQ;IACnB,8GAA8G;IACvG,MAAM,CAAC,UAAU,CAAC,MAA6B;QACpD,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,MAAM,YAAY,+BAAc,EAAE,CAAC;YACrC,KAAK,IAAI,MAAM,CAAC,WAAW,EAAE,CAA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4BAA4B,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IACvE,CAAC;CACF;AAjID,4BAiIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { BagOfCurves, CurveCollection } from \"./CurveCollection\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { AnyChain, AnyCurve } from \"./CurveTypes\";\r\nimport { MultiChainCollector } from \"./internalContexts/MultiChainCollector\";\r\nimport { CurveChainWireOffsetContext } from \"./internalContexts/PolygonOffsetContext\";\r\nimport { LineString3d } from \"./LineString3d\";\r\nimport { Loop } from \"./Loop\";\r\nimport { OffsetOptions } from \"./OffsetOptions\";\r\nimport { Path } from \"./Path\";\r\nimport { StrokeOptions } from \"./StrokeOptions\";\r\n\r\n/**\r\n * Static methods for miscellaneous curve operations.\r\n * @public\r\n */\r\nexport class CurveOps {\r\n /** Recursively sum curve lengths, allowing CurvePrimitive, CurveCollection, or array of such at any level. */\r\n public static sumLengths(curves: AnyCurve | AnyCurve[]): number {\r\n let mySum = 0;\r\n if (curves instanceof CurvePrimitive) {\r\n mySum += curves.curveLength();\r\n } else if (curves instanceof CurveCollection) {\r\n mySum += curves.sumLengths();\r\n } else if (Array.isArray(curves)) {\r\n for (const data1 of curves)\r\n mySum += this.sumLengths(data1);\r\n }\r\n return mySum;\r\n }\r\n /** Recursively extend the range by each curve's range, allowing CurvePrimitive, CurveCollection, or array of such at any level. */\r\n public static extendRange(range: Range3d, curves: AnyCurve | AnyCurve[]): Range3d {\r\n if (Array.isArray(curves)) {\r\n for (const data1 of curves)\r\n this.extendRange(range, data1);\r\n } else {\r\n curves.extendRange(range);\r\n }\r\n return range;\r\n }\r\n /**\r\n * Construct a separate xy-offset for each input curve.\r\n * * For best offset results, the inputs should be parallel to the xy-plane.\r\n * @param curves input curve(s), z-coordinates ignored. Only curves of type [[AnyChain]] are handled.\r\n * @param offset offset distance (positive to left of curve, negative to right)\r\n * @param result array to collect offset curves\r\n * @returns summed length of offset curves\r\n */\r\n public static appendXYOffsets(curves: AnyCurve | AnyCurve[] | undefined, offset: number, result: AnyCurve[]): number {\r\n let summedLengths = 0;\r\n if (curves instanceof CurvePrimitive) {\r\n const resultA = CurveChainWireOffsetContext.constructCurveXYOffset(Path.create(curves), offset);\r\n if (resultA) {\r\n summedLengths += this.sumLengths(resultA);\r\n result.push(resultA);\r\n }\r\n } else if (curves instanceof Loop || curves instanceof Path) {\r\n const resultA = CurveChainWireOffsetContext.constructCurveXYOffset(curves, offset);\r\n if (resultA) {\r\n summedLengths += this.sumLengths(resultA);\r\n result.push(resultA);\r\n }\r\n } else if (curves instanceof BagOfCurves) {\r\n for (const q of curves.children)\r\n summedLengths += this.appendXYOffsets(q, offset, result);\r\n } else if (Array.isArray(curves)) {\r\n for (const q of curves)\r\n summedLengths += this.appendXYOffsets(q, offset, result);\r\n }\r\n return summedLengths;\r\n }\r\n /**\r\n * Restructure curve fragments as Paths and Loops, and construct xy-offsets of the chains.\r\n * * If the inputs do not form Loop(s), the classification of offsets is suspect.\r\n * * For best offset results, the inputs should be parallel to the xy-plane.\r\n * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.\r\n * @param fragments fragments to be chained and offset\r\n * @param offsetDistance offset distance, applied to both sides of each fragment to produce inside and outside xy-offset curves.\r\n * @param gapTolerance distance to be treated as \"effectively zero\" when joining head-to-tail\r\n * @returns object with named chains, insideOffsets, outsideOffsets\r\n */\r\n public static collectInsideAndOutsideXYOffsets(fragments: AnyCurve[], offsetDistance: number, gapTolerance: number): { insideOffsets: AnyCurve[], outsideOffsets: AnyCurve[], chains?: AnyChain } {\r\n const collector = new MultiChainCollector(gapTolerance, gapTolerance);\r\n for (const s of fragments) {\r\n collector.captureCurve(s);\r\n }\r\n const chains = collector.grabResult(true);\r\n const myOffsetA: CurveCollection[] = [];\r\n const myOffsetB: CurveCollection[] = [];\r\n const offsetLengthA = CurveOps.appendXYOffsets(chains, offsetDistance, myOffsetA);\r\n const offsetLengthB = CurveOps.appendXYOffsets(chains, -offsetDistance, myOffsetB);\r\n if (offsetLengthA > offsetLengthB) {\r\n return { outsideOffsets: myOffsetA, insideOffsets: myOffsetB, chains };\r\n } else {\r\n return { insideOffsets: myOffsetA, outsideOffsets: myOffsetB, chains };\r\n }\r\n }\r\n /**\r\n * Construct curves that are offset from a Path or Loop as viewed in xy-plane (ignoring z).\r\n * * The construction will remove \"some\" local effects of features smaller than the offset distance, but will not detect self intersection among widely separated edges.\r\n * @param curves base curves.\r\n * @param offsetDistanceOrOptions offset distance (positive to left of curve, negative to right) or options object.\r\n */\r\n public static constructCurveXYOffset(curves: Path | Loop, offsetDistanceOrOptions: number | OffsetOptions): CurveCollection | undefined {\r\n return CurveChainWireOffsetContext.constructCurveXYOffset(curves, offsetDistanceOrOptions);\r\n }\r\n /**\r\n * Create the offset of a single curve primitive as viewed in the xy-plane (ignoring z).\r\n * @param curve primitive to offset\r\n * @param offsetDistanceOrOptions offset distance (positive to left of curve, negative to right) or options object\r\n */\r\n public static createSingleOffsetPrimitiveXY(curve: CurvePrimitive, offsetDistanceOrOptions: number | OffsetOptions): CurvePrimitive | CurvePrimitive[] | undefined {\r\n return CurveChainWireOffsetContext.createSingleOffsetPrimitiveXY(curve, offsetDistanceOrOptions);\r\n }\r\n /**\r\n * Restructure curve fragments as Paths and Loops.\r\n * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.\r\n * @param fragments fragments to be chained\r\n * @param gapTolerance distance to be treated as \"effectively zero\" when assembling fragments head-to-tail\r\n * @param planeTolerance tolerance for considering a closed chain to be planar. If undefined, only create Path. If defined, create Loops for closed chains within tolerance of a plane.\r\n * @returns chains, possibly wrapped in a [[BagOfCurves]].\r\n */\r\n public static collectChains(fragments: AnyCurve[], gapTolerance: number = Geometry.smallMetricDistance, planeTolerance?: number): AnyChain | undefined {\r\n const collector = new MultiChainCollector(gapTolerance, planeTolerance);\r\n for (const s of fragments) {\r\n collector.captureCurve(s);\r\n }\r\n return collector.grabResult(true);\r\n }\r\n /**\r\n * Restructure curve fragments, to be stroked and passed into the callback.\r\n * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.\r\n * @param fragments fragments to be chained and stroked\r\n * @param announceChain callback to process each stroked Path and Loop\r\n * @param strokeOptions options for stroking the chains\r\n * @param gapTolerance distance to be treated as \"effectively zero\" when assembling fragments head-to-tail. Also used for removing duplicate points in the stroked chains.\r\n * @param _planeTolerance unused, pass undefined\r\n */\r\n public static collectChainsAsLineString3d(fragments: AnyCurve[], announceChain: (chainPoints: LineString3d) => void, strokeOptions?: StrokeOptions, gapTolerance: number = Geometry.smallMetricDistance, _planeTolerance?: number) {\r\n const collector = new MultiChainCollector(gapTolerance); // no planarity tolerance needed\r\n for (const s of fragments) {\r\n collector.captureCurve(s);\r\n }\r\n collector.announceChainsAsLineString3d(announceChain, strokeOptions);\r\n }\r\n}\r\n"]}
@@ -440,7 +440,7 @@ export declare abstract class CurvePrimitive extends GeometryQuery {
440
440
  /**
441
441
  * Construct an offset of the instance curve as viewed in the xy-plane (ignoring z).
442
442
  * * No attempt is made to join the offsets of smaller constituent primitives. To construct a fully joined offset
443
- * for an aggregate instance (e.g., LineString3d, CurveChainWithDistanceIndex), use RegionOps.constructCurveXYOffset()
443
+ * for an aggregate instance (e.g., LineString3d, CurveChainWithDistanceIndex), use [[CurveOps.constructCurveXYOffset]]
444
444
  * instead.
445
445
  * @param offsetDistanceOrOptions offset distance (positive to left of the instance curve), or options object
446
446
  */
@@ -1 +1 @@
1
- {"version":3,"file":"CurvePrimitive.js","sourceRoot":"","sources":["../../../src/curve/CurvePrimitive.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH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;gBACxC,MAAM,QAAQ,GAAG,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC;gBACnC,UAAU,CAAC,qBAAqB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QACD,OAAO,UAAU,CAAC,SAAS,EAAE,GAAG,SAAS,CAAC;IAC5C,CAAC;IACD;;;;;OAKG;IACI,MAAM,CAAC,qBAAqB,CAAC,KAAqB,EAAE,QAAwB,EAAE,SAA0B;QAC7G,IAAI,SAAS;YACX,SAAS,CAAC,mBAAmB,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC1E,KAAK,CAAC,UAAU,GAAG,QAAQ,CAAC;IAC9B,CAAC;IACD;;;;;;;;OAQG;IACI,wBAAwB,CAC7B,cAAgC,EAAE,2BAAoC,EAAE,sBAA+B,KAAK;QAE5G,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IACD;;;;;;;OAOG;IACI,sBAAsB,CAC3B,cAAiC,EAAE,6BAAsC,KAAK,EAAE,qBAA8B,KAAK;QAEnH,MAAM,OAAO,GAAqB,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC;QACrF,IAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,CAAC,CAAC;QACvF,OAAO,OAAO,CAAC;IACjB,CAAC;IAYD;;;;;;;OAOG;IACI,uBAAuB,CAAC,IAAsB,EAAE,QAAkB;QACvE,OAAO,SAAS,CAAC,CAAC,6EAA6E;IACjG,CAAC;CACF;AAtsBD,wCAssBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { StrokeCountMap } from \"../curve/Query/StrokeCountMap\";\r\nimport { AxisOrder, Geometry, type PlaneAltitudeEvaluator } from \"../Geometry\";\r\nimport { Matrix3d } from \"../geometry3d/Matrix3d\";\r\nimport { Point3d, type Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { type Range1d, Range3d } from \"../geometry3d/Range\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { CurveIntervalRole, CurveLocationDetail, CurveSearchStatus } from \"./CurveLocationDetail\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\nimport { AppendPlaneIntersectionStrokeHandler } from \"./internalContexts/AppendPlaneIntersectionStrokeHandler\";\r\nimport { ClosestPointStrokeHandler } from \"./internalContexts/ClosestPointStrokeHandler\";\r\nimport { CurveLengthContext } from \"./internalContexts/CurveLengthContext\";\r\nimport { LineString3d } from \"./LineString3d\";\r\n\r\nimport type { AkimaCurve3d } from \"../bspline/AkimaCurve3d\";\r\nimport type { Arc3d } from \"./Arc3d\";\r\nimport type { BezierCurve3d } from \"../bspline/BezierCurve3d\";\r\nimport type { BSplineCurve3d } from \"../bspline/BSplineCurve\";\r\nimport type { Clipper } from \"../clipping/ClipUtils\";\r\nimport type { CurveChainWithDistanceIndex } from \"./CurveChainWithDistanceIndex\";\r\nimport type { DirectSpiral3d } from \"./spiral/DirectSpiral3d\";\r\nimport type { IntegratedSpiral3d } from \"./spiral/IntegratedSpiral3d\";\r\nimport type { InterpolationCurve3d } from \"../bspline/InterpolationCurve3d\";\r\nimport type { IStrokeHandler } from \"../geometry3d/GeometryHandler\";\r\nimport type { LineSegment3d } from \"./LineSegment3d\";\r\nimport type { OffsetOptions } from \"./OffsetOptions\";\r\nimport type { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport type { Plane3dByOriginAndVectors } from \"../geometry3d/Plane3dByOriginAndVectors\";\r\nimport type { StrokeOptions } from \"./StrokeOptions\";\r\nimport type { VariantCurveExtendParameter } from \"./CurveExtendMode\";\r\n\r\n/**\r\n * Describes the concrete type of a [[CurvePrimitive]]. Each type name maps to a specific subclass and can be used\r\n * for type-switching in conditional statements.\r\n * - \"arc\" => [[Arc3d]]\r\n * - \"lineSegment\" => [[LineSegment3d]]\r\n * - \"lineString\" => [[LineString3d]]\r\n * - \"bsplineCurve\" => [[BSplineCurve3dBase]] which is an intermediate class implemented by [[BSplineCurve3d]] and\r\n * [[BSplineCurve3dH]]\r\n * - \"bezierCurve\" => [[BezierCurveBase]] which is an intermediate class implemented by [[BezierCurve3d]] and\r\n * [[BezierCurve3dH]]\r\n * - \"transitionSpiral\" => [[TransitionSpiral3d]]\r\n * - \"curveChainWithDistanceIndex\" => [[CurveChainWithDistanceIndex]]\r\n * @see [Curve Collections]($docs/learning/geometry/CurvePrimitive.md) learning article.\r\n * @see [[AnyCurvePrimitive]] for a union type that supports compile-time type narrowing.\r\n * @public\r\n */\r\nexport type CurvePrimitiveType = \"arc\" | \"lineSegment\" | \"lineString\" | \"bsplineCurve\" | \"bezierCurve\" | \"transitionSpiral\" | \"curveChainWithDistanceIndex\" | \"interpolationCurve\" | \"akimaCurve\";\r\n/**\r\n * Union type for subclasses of [[CurvePrimitive]]. Specific subclasses can be discriminated at compile- or run-time\r\n * using [[CurvePrimitive.curvePrimitiveType]].\r\n * @public\r\n */\r\nexport type AnyCurvePrimitive = Arc3d | LineSegment3d | LineString3d | BSplineCurve3d | BezierCurve3d | DirectSpiral3d | IntegratedSpiral3d | CurveChainWithDistanceIndex | InterpolationCurve3d | AkimaCurve3d;\r\n/**\r\n * Union type for a linear [[CurvePrimitive]].\r\n * @public\r\n */\r\nexport type LinearCurvePrimitive = LineSegment3d | LineString3d;\r\n/**\r\n * Function signature for callback which announces a pair of numbers, such as a fractional interval, along with a\r\n * containing CurvePrimitive.\r\n * @public\r\n */\r\nexport type AnnounceNumberNumberCurvePrimitive = (a0: number, a1: number, cp: CurvePrimitive) => void;\r\n/**\r\n * Function signature for a callback which announces a pair of numbers\r\n * @public\r\n */\r\nexport type AnnounceNumberNumber = (a0: number, a1: number) => void;\r\n/** Function signature for a callback which announces a curve primitive\r\n * @public\r\n */\r\nexport type AnnounceCurvePrimitive = (cp: CurvePrimitive) => void;\r\n\r\n/**\r\n * A curve primitive is bounded.\r\n * A curve primitive maps fractions in 0..1 to points in space.\r\n * As the fraction proceeds from 0 towards 1, the point moves \"forward\" along the curve.\r\n * True distance along the curve is not always strictly proportional to fraction.\r\n * * A LineSegment3d always has proportional fraction and distance.\r\n * * An Arc3d which is true circular has proportional fraction and distance.\r\n * * A LineString3d is not proportional (except for special case of all segments of equal length).\r\n * * A Spiral3d is proportional.\r\n * * A BsplineCurve3d is only proportional for special cases.\r\n * For fractions outside 0..1, the curve primitive class may either (a) return the near endpoint or (b) evaluate\r\n * an extended curve.\r\n * @public\r\n */\r\nexport abstract class CurvePrimitive extends GeometryQuery {\r\n /** String name for schema properties */\r\n public readonly geometryCategory = \"curvePrimitive\";\r\n /** String name for schema properties */\r\n public abstract readonly curvePrimitiveType: CurvePrimitiveType;\r\n /** Constructor */\r\n protected constructor() {\r\n super();\r\n }\r\n /**\r\n * Data attached during stroking for facets.\r\n */\r\n public strokeData?: StrokeCountMap;\r\n /**\r\n * Data attached in curve cutting.\r\n * @internal\r\n */\r\n public startCut?: CurveLocationDetail;\r\n /**\r\n * Data attached in curve cutting.\r\n * @internal\r\n */\r\n public endCut?: CurveLocationDetail;\r\n /**\r\n * Data attached by various algorithms (e.g. Region booleans)\r\n */\r\n public parent?: any;\r\n /**\r\n * Return the point (x,y,z) on the curve at fractional position.\r\n * @param fraction fractional position along the geometry.\r\n * @returns Returns a point on the curve.\r\n */\r\n public abstract fractionToPoint(fraction: number, result?: Point3d): Point3d;\r\n /**\r\n * Return the point (x,y,z) and derivative on the curve at fractional position.\r\n * * Note that this derivative is \"derivative of xyz with respect to fraction\".\r\n * * This derivative shows the speed of the \"fractional point\" moving along the curve.\r\n * * This is not generally a unit vector. Use fractionToPointAndUnitTangent for a unit vector.\r\n * @param fraction fractional position along the geometry.\r\n * @returns Returns a ray whose origin is the curve point and direction is the derivative with respect to the fraction.\r\n */\r\n public abstract fractionToPointAndDerivative(fraction: number, result?: Ray3d): Ray3d;\r\n /**\r\n * Returns a ray whose origin is the curve point and direction is the unit tangent.\r\n * @param fraction fractional position on the curve\r\n * @param result optional preallocated ray.\r\n */\r\n public fractionToPointAndUnitTangent(fraction: number, result?: Ray3d): Ray3d {\r\n const ray = this.fractionToPointAndDerivative(fraction, result);\r\n ray.trySetDirectionMagnitudeInPlace(1.0);\r\n return ray;\r\n }\r\n /**\r\n * Returns the (absolute) curvature magnitude.\r\n * * Base implementation in CurvePrimitive computes curvature from the first and second derivative vectors.\r\n * @param fraction fractional position on the curve\r\n */\r\n public fractionToCurvature(fraction: number): number | undefined {\r\n const data = this.fractionToPointAnd2Derivatives(fraction)!;\r\n const cross = data.vectorU.crossProduct(data.vectorV);\r\n const a = cross.magnitude();\r\n const b = data.vectorU.magnitude();\r\n return Geometry.conditionalDivideFraction(a, b * b * b);\r\n }\r\n /**\r\n * Return a plane with\r\n * * origin at fractional position along the curve\r\n * * vectorU is the first derivative, i.e. tangent vector with length equal to the rate of change with respect to\r\n * the fraction.\r\n * * vectorV is the second derivative, i.e. derivative of vectorU which points in the direction of the curve's\r\n * derivative's change.\r\n * * **Note:** We are dealing with a parametric equation of the curve (a function f : R -> R^3) so first and\r\n * second derivatives are in fact derivatives of the parametric equation.\r\n */\r\n public abstract fractionToPointAnd2Derivatives(\r\n fraction: number, result?: Plane3dByOriginAndVectors\r\n ): Plane3dByOriginAndVectors | undefined;\r\n /**\r\n * Construct a frenet frame:\r\n * * origin at the point on the curve\r\n * * x axis is unit vector along the curve (tangent)\r\n * * y axis is perpendicular and in the plane of the osculating circle. y axis is called \"main normal\"\r\n * * z axis perpendicular to those. z axis is called \"bi-normal\"\r\n */\r\n public fractionToFrenetFrame(fraction: number, result?: Transform): Transform | undefined {\r\n const plane = this.fractionToPointAnd2Derivatives(fraction);\r\n if (!plane)\r\n return undefined;\r\n // first derivative (plane.vectorU) and second derivative (plane.vectorV) are not essentially\r\n // perpendicular so we use createRigidFromColumns to make 3 perpendicular vectors.\r\n let axes = Matrix3d.createRigidFromColumns(plane.vectorU, plane.vectorV, AxisOrder.XYZ);\r\n if (axes)\r\n return Transform.createRefs(plane.origin, axes, result);\r\n // 2nd derivative not distinct. for example if curve is linear at fraction so second derivative is 0.\r\n // in this case we find perpendicular vector to plane.vectorU and pass it to createRigidFromColumns.\r\n const perpVector = Matrix3d.createPerpendicularVectorFavorXYPlane(plane.vectorU, plane.vectorV);\r\n axes = Matrix3d.createRigidFromColumns(plane.vectorU, perpVector, AxisOrder.XYZ);\r\n if (axes)\r\n return Transform.createRefs(plane.origin, axes, result);\r\n return undefined;\r\n }\r\n /**\r\n * Construct signed distance from a point on the planar curve to its center of curvature (in xy only).\r\n * * Positive distance means the center is to the left of the curve at fraction.\r\n * * Negative distance means the center is to the right of the curve at fraction.\r\n * * Zero distance means curve is linear at fraction.\r\n */\r\n public fractionToSignedXYRadiusOfCurvature(fraction: number): number {\r\n const plane = this.fractionToPointAnd2Derivatives(fraction);\r\n if (!plane)\r\n return 0.0;\r\n const cross = plane.vectorU.crossProductXY(plane.vectorV);\r\n const b = plane.vectorU.magnitude();\r\n if (b === 0.0)\r\n return 0.0;\r\n const r = Geometry.conditionalDivideCoordinate(b * b * b, cross);\r\n if (r !== undefined)\r\n return r;\r\n return 0.0;\r\n }\r\n /**\r\n * Construct a point extrapolated along tangent at fraction.\r\n * @param fraction fractional position on the primitive\r\n * @param distance (signed) distance to move on the tangent.\r\n */\r\n public fractionAndDistanceToPointOnTangent(fraction: number, distance: number): Point3d {\r\n const ray = this.fractionToPointAndUnitTangent(fraction);\r\n return ray.fractionToPoint(distance);\r\n }\r\n /**\r\n * Return the length of the curve.\r\n * * Curve length is always positive.\r\n */\r\n public curveLength(): number {\r\n const context = new CurveLengthContext();\r\n this.emitStrokableParts(context);\r\n return context.getSum();\r\n }\r\n /**\r\n * Returns a (high accuracy) length of the curve between fractional positions.\r\n * * Curve length is always positive.\r\n * * Default implementation applies a generic Gaussian integration.\r\n * * Most curve classes (certainly LineSegment, LineString, Arc) are expected to provide efficient implementations.\r\n */\r\n public curveLengthBetweenFractions(fraction0: number, fraction1: number): number {\r\n if (fraction0 === fraction1)\r\n return 0.0;\r\n const scale = this.getFractionToDistanceScale();\r\n if (scale !== undefined) {\r\n // We are in luck! simple proportions determine it all !!!\r\n // (for example, a LineSegment3d or a circular arc)\r\n const totalLength = this.curveLength();\r\n return Math.abs((fraction1 - fraction0) * totalLength);\r\n }\r\n const context = new CurveLengthContext(fraction0, fraction1);\r\n this.emitStrokableParts(context);\r\n return Math.abs(context.getSum());\r\n }\r\n /**\r\n * Returns a (high accuracy) range of the curve between fractional positions\r\n * * Default implementation returns the range of the curve from clonePartialCurve.\r\n */\r\n public rangeBetweenFractions(fraction0: number, fraction1: number, transform?: Transform): Range3d {\r\n return this.rangeBetweenFractionsByClone(fraction0, fraction1, transform);\r\n }\r\n /**\r\n * Returns a (high accuracy) range of the curve between fractional positions\r\n * * Default implementation returns the range of the curve from clonePartialCurve\r\n */\r\n public rangeBetweenFractionsByClone(fraction0: number, fraction1: number, transform?: Transform): Range3d {\r\n if (fraction0 === fraction1)\r\n return Range3d.create(this.fractionToPoint(fraction0));\r\n const fragment = this.clonePartialCurve(fraction0, fraction1);\r\n if (fragment)\r\n return fragment.range(transform);\r\n return Range3d.createNull();\r\n }\r\n /**\r\n * Returns an approximate range based on a fixed number of evaluations\r\n * * Default implementation returns a range determined by evaluating a specified number of points on the curve.\r\n * * Optional evaluate again at interval midpoints and extrapolate any increase\r\n * * For a smooth curve, Richardson extrapolation suggests each subdivision moves 3/4 of the way to final. So\r\n * extrapolationFactor of 1/3 gets speculatively moves closer to the tight range, and larger multipliers increase\r\n * confidence in being safely larger.\r\n * * This function is faster version to compute the range of a portion of a curve (because some curves can be\r\n * expensive to compute the partial curve and/or to compute the partial curve's range.\r\n * @param fraction0 start fraction for evaluation\r\n * @param fraction1 end fraction for evaluation\r\n * @param count number of points to evaluate\r\n * @param transform optional transform to be applied to the curve\r\n * @param extrapolationFactor if positive, evaluate again at interval midpoints and apply this fraction multiplier\r\n * to any increase in size.\r\n */\r\n public rangeBetweenFractionsByCount(\r\n fraction0: number, fraction1: number, count: number, transform?: Transform, extrapolationFactor: number = 0.0,\r\n ): Range3d {\r\n const range = Range3d.createNull();\r\n const workPoint = Point3d.create();\r\n range.extendPoint(this.startPoint(workPoint));\r\n range.extendPoint(this.endPoint(workPoint));\r\n // Evaluate at count fractions (fraction0 + i * fractionStep)\r\n const evaluateSteps = (fractionA: number, fractionStep: number, countA: number) => {\r\n let f = fractionA;\r\n for (let i = 0; i < countA; i++, f += fractionStep) {\r\n this.fractionToPoint(f, workPoint);\r\n if (transform)\r\n range.extendTransformedPoint(transform, workPoint);\r\n else\r\n range.extendPoint(workPoint);\r\n }\r\n };\r\n const interiorCount = count - 2;\r\n if (interiorCount > 0) {\r\n const localFraction0 = 1.0 / (interiorCount + 1);\r\n const globalFractionStep = localFraction0 * (fraction1 - fraction0);\r\n evaluateSteps(fraction0 + globalFractionStep, globalFractionStep, interiorCount);\r\n }\r\n if (extrapolationFactor > 0.0) {\r\n // Evaluate at midpoints. Where this makes the range larger, apply extrapolationFactor to move it to safer\r\n // excess value. same interior step, but shift to interval midpoints.\r\n const baseRange = range.clone();\r\n const interiorCount1 = interiorCount + 1;\r\n const localFraction0 = 0.5 / interiorCount1; // we only evaluate at new midpoints.\r\n const globalFractionStep = 2 * localFraction0 * (fraction1 - fraction0); // same as above, but avoids special logic for interiorCount = 0\r\n evaluateSteps(fraction0 + globalFractionStep * 0.5, globalFractionStep, interiorCount1);\r\n range.extendWhenLarger(baseRange, extrapolationFactor);\r\n }\r\n return range;\r\n }\r\n /**\r\n * Run an integration (with a default Gaussian quadrature) with a fixed fractional step\r\n * * This is typically called by specific curve type implementations of curveLengthBetweenFractions.\r\n * * For example, in Arc3d implementation of curveLengthBetweenFractions:\r\n * * If the Arc3d is true circular, it the arc is true circular, use the direct `arcLength = radius * sweepRadians`\r\n * * If the Arc3d is not true circular, call this method with an interval count appropriate to eccentricity and\r\n * sweepRadians.\r\n * @returns Returns the curve length via an integral estimated by numerical quadrature between the fractional positions.\r\n * @param fraction0 start fraction for integration\r\n * @param fraction1 end fraction for integration\r\n * @param numInterval number of quadrature intervals\r\n */\r\n public curveLengthWithFixedIntervalCountQuadrature(\r\n fraction0: number, fraction1: number, numInterval: number, numGauss: number = 5,\r\n ): number {\r\n if (fraction0 > fraction1) {\r\n const fSave = fraction0;\r\n fraction0 = fraction1;\r\n fraction1 = fSave;\r\n }\r\n const context = new CurveLengthContext(fraction0, fraction1, numGauss);\r\n context.announceIntervalForUniformStepStrokes(this, numInterval, fraction0, fraction1);\r\n return Math.abs(context.getSum());\r\n }\r\n /**\r\n * (Attempt to) find a position on the curve at a signed distance from start fraction.\r\n * * Return the position as a CurveLocationDetail.\r\n * * In the `CurveLocationDetail`, record:\r\n * * `fraction` = fractional position\r\n * * `point` = coordinates of the point\r\n * * `a` = (signed!) distance moved. If `allowExtension` is false and the move reached the start or end of the\r\n * curve, this distance is smaller than the requested signedDistance.\r\n * * `curveSearchStatus` indicates one of:\r\n * * `error` (unusual) computation failed not supported for this curve.\r\n * * `success` full movement completed\r\n * * `stoppedAtBoundary` partial movement completed. This can be due to either\r\n * * `allowExtension` parameter sent as `false`\r\n * * the curve type (e.g. bspline) does not support extended range.\r\n * * if `allowExtension` is true, movement may still end at the startPoint or end point for curves that do not support\r\n * extended geometry (specifically bsplines)\r\n * * if the curve returns a value (i.e. not `undefined`) for `curve.getFractionToDistanceScale()`, the base class\r\n * carries out the computation\r\n * and returns a final location.\r\n * * LineSegment3d relies on this.\r\n * * If the curve does not implement the computation or the curve has zero length, the returned `CurveLocationDetail`\r\n * has\r\n * * `fraction` = the value of `startFraction`\r\n * * `point` = result of `curve.fractionToPoint(startFraction)`\r\n * * `a` = 0\r\n * * `curveStartState` = `CurveSearchStatus.error`\r\n * @param startFraction fractional position where the move starts\r\n * @param signedDistance distance to move. Negative distance is backwards in the fraction space\r\n * @param allowExtension if true, allow the move to go beyond the startPoint or endpoint of the curve. If false,\r\n * do not allow movement beyond the startPoint or endpoint\r\n * @param result optional result.\r\n * @returns A CurveLocationDetail annotated as above. Note that if the curve does not support the calculation, there is\r\n * still a result which contains the point at the input startFraction, with failure indicated in the `curveStartState`\r\n * member\r\n */\r\n public moveSignedDistanceFromFraction(\r\n startFraction: number, signedDistance: number, allowExtension: boolean, result?: CurveLocationDetail,\r\n ): CurveLocationDetail {\r\n const scale = this.getFractionToDistanceScale();\r\n if (scale !== undefined) {\r\n // We are in luck! simple proportions determine it all !!!\r\n // (for example, a LineSegment3d or a circular arc)\r\n const totalLength = this.curveLength();\r\n const signedFractionMove = Geometry.conditionalDivideFraction(signedDistance, totalLength);\r\n if (signedFractionMove === undefined) {\r\n return CurveLocationDetail.createCurveFractionPointDistanceCurveSearchStatus(\r\n this, startFraction, this.fractionToPoint(startFraction), 0.0, CurveSearchStatus.error);\r\n }\r\n return CurveLocationDetail.createConditionalMoveSignedDistance(\r\n allowExtension,\r\n this,\r\n startFraction,\r\n startFraction + signedFractionMove,\r\n signedDistance,\r\n result,\r\n );\r\n }\r\n return this.moveSignedDistanceFromFractionGeneric(startFraction, signedDistance, allowExtension, result);\r\n }\r\n /**\r\n * Generic algorithm to search for point at signed distance from a fractional startPoint.\r\n * * This will work for well for smooth curves.\r\n * * Curves with tangent or other low-order-derivative discontinuities may need to implement specialized algorithms.\r\n * * We need to find an endFraction which is the end-of-interval (usually upper) limit of integration of the tangent\r\n * magnitude from startFraction to endFraction\r\n * * That integral is a function of endFraction.\r\n * * The derivative of that integral with respect to end fraction is the tangent magnitude at end fraction.\r\n * * Use that function and (easily evaluated!) derivative for a Newton iteration\r\n * * TO ALL WHO HAVE FUZZY MEMORIES OF CALCULUS CLASS: \"The derivative of the integral wrt upper limit is the value\r\n * of the integrand there\" is the fundamental theorem of integral calculus !!! The fundamental theorem is not just\r\n * an abstraction !!! It is being used here in its barest possible form !!!\r\n * * See https://en.wikipedia.org/wiki/Fundamental_theorem_of_calculus\r\n * @param startFraction\r\n * @param signedDistance\r\n * @param _allowExtension\r\n * @param result\r\n */\r\n protected moveSignedDistanceFromFractionGeneric(\r\n startFraction: number, signedDistance: number, allowExtension: boolean, result?: CurveLocationDetail,\r\n ): CurveLocationDetail {\r\n let limitFraction: number;\r\n const slackFraction = 0.1; // slack to use when integration would otherwise have no room to work\r\n if (signedDistance === 0.0)\r\n return CurveLocationDetail.createCurveEvaluatedFraction(this, startFraction, result); // no movement, just evaluate at startFraction\r\n if (signedDistance > 0.0) {\r\n limitFraction = 1.0;\r\n if (startFraction >= 1.0) {\r\n const newStartFraction = 1.0 - slackFraction;\r\n signedDistance += this.curveLengthBetweenFractions(newStartFraction, startFraction);\r\n startFraction = newStartFraction;\r\n }\r\n } else { // signedDistance < 0.0\r\n limitFraction = 0.0;\r\n if (startFraction <= 0.0) {\r\n const newStartFraction = 0.0 + slackFraction;\r\n signedDistance -= this.curveLengthBetweenFractions(startFraction, newStartFraction);\r\n startFraction = newStartFraction;\r\n }\r\n }\r\n const availableLength = this.curveLengthBetweenFractions(startFraction, limitFraction);\r\n assert(availableLength > 0.0);\r\n const absDistance = Math.abs(signedDistance);\r\n if (availableLength < absDistance && !allowExtension)\r\n return CurveLocationDetail.createConditionalMoveSignedDistance(allowExtension, this, startFraction, limitFraction, signedDistance, result);\r\n\r\n const fractionStep = Geometry.conditionalDivideCoordinate(absDistance, availableLength);\r\n if (undefined === fractionStep) {\r\n // no available length!\r\n result = CurveLocationDetail.createCurveEvaluatedFraction(this, startFraction, result);\r\n result.curveSearchStatus = CurveSearchStatus.error;\r\n return result;\r\n }\r\n const directionFactor = signedDistance < 0.0 ? -1.0 : 1.0;\r\n let fractionB = Geometry.interpolate(startFraction, fractionStep, limitFraction);\r\n let fractionA = startFraction;\r\n let distanceA = 0.0;\r\n const tol = 1.0e-12 * availableLength;\r\n let numConverged = 0;\r\n const tangent = Ray3d.createXAxis();\r\n // on each loop entry:\r\n // fractionA is the most recent endOfInterval. (It may have been reached by a mixture of forward and backward step.)\r\n // distanceA is the distance to (the point at) fractionA\r\n // fractionB is the next end fraction\r\n for (let iterations = 0; iterations < 10; iterations++) {\r\n const distanceAB = this.curveLengthBetweenFractions(fractionA, fractionB);\r\n const directionAB = fractionB > fractionA ? directionFactor : -directionFactor;\r\n const distance0B = distanceA + directionAB * distanceAB;\r\n const distanceError = absDistance - distance0B;\r\n if (Math.abs(distanceError) < tol) {\r\n numConverged++;\r\n if (numConverged > 1)\r\n break;\r\n } else {\r\n numConverged = 0;\r\n }\r\n this.fractionToPointAndDerivative(fractionB, tangent);\r\n const tangentMagnitude = tangent.direction.magnitude();\r\n fractionA = fractionB;\r\n fractionB = fractionA + directionFactor * distanceError / tangentMagnitude;\r\n if (fractionA === fractionB) { // YES -- that is an exact equality test. When it happens, there's no need for confirming with another iteration.\r\n numConverged = 100;\r\n break;\r\n }\r\n distanceA = distance0B;\r\n }\r\n if (numConverged > 1)\r\n return CurveLocationDetail.createConditionalMoveSignedDistance(\r\n allowExtension, this, startFraction, fractionB, signedDistance, result,\r\n );\r\n result = CurveLocationDetail.createCurveEvaluatedFraction(this, startFraction, result);\r\n result.curveSearchStatus = CurveSearchStatus.error;\r\n return result;\r\n }\r\n /**\r\n * * Returns true if the curve can be easily extended past its start/end point (i.e., beyond the usual\r\n * fraction space [0,1]). Otherwise, returns false.\r\n * * Base class default implementation returns false.\r\n * * These classes (and perhaps others in the future) will return true:\r\n * * LineSegment3d\r\n * * LineString3d\r\n * * Arc3d\r\n */\r\n public get isExtensibleFractionSpace(): boolean {\r\n return false;\r\n }\r\n /**\r\n * Compute a length for curve which may be a fast approximation to the true length.\r\n * This is expected to be either (a) exact or (b) larger than the actual length, but by no more than\r\n * a small multiple, perhaps up to PI/2, but commonly much closer to 1.\r\n *\r\n * * An example use of this is for setting a tolerance which is a small multiple of the curve length.\r\n * * Simple line, circular arc, and transition spiral may return exact length\r\n * * Ellipse may return circumference of some circle or polygon that encloses the ellipse.\r\n * * bspline curve may return control polygon length\r\n * *\r\n */\r\n public abstract quickLength(): number;\r\n /**\r\n * Search for a point on the curve that is closest to the spacePoint.\r\n * * If the space point is exactly on the curve, this is the reverse of fractionToPoint.\r\n * * Since CurvePrimitive should always have start and end available as candidate points, this method should always\r\n * succeed\r\n * @param spacePoint point in space\r\n * @param extend true to extend the curve (if possible), false for no extend, single CurveExtendOptions (for both\r\n * directions), or array of distinct CurveExtendOptions for start and end.\r\n * @returns Returns a CurveLocationDetail structure that holds the details of the close point.\r\n */\r\n public closestPoint(\r\n spacePoint: Point3d, extend: VariantCurveExtendParameter, result?: CurveLocationDetail,\r\n ): CurveLocationDetail | undefined {\r\n const strokeHandler = new ClosestPointStrokeHandler(spacePoint, extend, result);\r\n this.emitStrokableParts(strokeHandler);\r\n return strokeHandler.claimResult();\r\n }\r\n /**\r\n * Find intervals of this curvePrimitive that are interior to a clipper\r\n * @param clipper clip structure (e.g. clip planes)\r\n * @param announce (optional) function to be called announcing fractional intervals\r\n * `announce(fraction0, fraction1, curvePrimitive)`\r\n * @returns true if any \"in\" segments are announced.\r\n */\r\n public announceClipIntervals(_clipper: Clipper, _announce?: AnnounceNumberNumberCurvePrimitive): boolean {\r\n // DEFAULT IMPLEMENTATION -- no interior parts\r\n return false;\r\n }\r\n /** Return a deep clone. */\r\n public abstract override clone(): CurvePrimitive;\r\n /** Return a transformed deep clone. */\r\n public abstract override cloneTransformed(transform: Transform): CurvePrimitive | undefined;\r\n /**\r\n * Return (if possible) a curve primitive which is a portion of this curve.\r\n * @param _fractionA [in] start fraction\r\n * @param _fractionB [in] end fraction\r\n */\r\n public clonePartialCurve(_fractionA: number, _fractionB: number): CurvePrimitive | undefined {\r\n return undefined;\r\n }\r\n /**\r\n * If the curve primitive has distance-along-curve strictly proportional to curve fraction, return the scale factor.\r\n * If distance-along-the-curve is not proportional, return undefined.\r\n * * When defined, the scale factor is always the length of the curve.\r\n * * This scale factor is typically available for these curve types:\r\n * * * All `LineSegment3d`\r\n * * * Arc3d which is a true circular arc (axes perpendicular and of equal length).\r\n * * * CurveChainWithDistanceIndex\r\n * * This scale factor is undefined for these curve types:\r\n * * * Arc3d which is a true ellipse, i.e. unequal lengths of defining vectors or non-perpendicular defining vectors.\r\n * * * bspline and bezier curves\r\n * @returns scale factor or undefined\r\n */\r\n public getFractionToDistanceScale(): number | undefined {\r\n return undefined;\r\n }\r\n /** Reverse the curve's data so that its fractional stroking moves in the opposite direction. */\r\n public abstract reverseInPlace(): void;\r\n /**\r\n * Compute intersections of the curve with a plane.\r\n * * The intersections are appended to the result array.\r\n * * The base class implementation emits strokes to an AppendPlaneIntersectionStrokeHandler object, which uses a\r\n * Newton iteration to get high-accuracy intersection points within strokes.\r\n * * Derived classes should override this default implementation if there are easy analytic solutions.\r\n * * Derived classes are free to implement extended intersections (e.g. arc!!!)\r\n * @param plane The plane to be intersected.\r\n * @param result Array to receive intersections\r\n * @returns Return the number of CurveLocationDetail's added to the result array.\r\n */\r\n public appendPlaneIntersectionPoints(plane: PlaneAltitudeEvaluator, result: CurveLocationDetail[]): number {\r\n const strokeHandler = new AppendPlaneIntersectionStrokeHandler(plane, result);\r\n const n0 = result.length;\r\n this.emitStrokableParts(strokeHandler);\r\n return result.length - n0;\r\n }\r\n /**\r\n * Examine contents of an array of CurveLocationDetail.\r\n * Filter the intersections according to the parameters.\r\n * @param allowExtend if false, remove points on the extension.\r\n * @param applySnappedCoordinates if true, change the stored fractions and coordinates to exact end values.\r\n * Otherwise use the exact values only for purpose of updating the curveIntervalRole.\r\n * @param startEndFractionTolerance if nonzero, adjust fraction to 0 or 1 with this tolerance.\r\n * @param startEndXYZTolerance if nonzero, adjust to endpoint with this tolerance.\r\n * @internal\r\n */\r\n public static snapAndRestrictDetails(\r\n details: CurveLocationDetail[],\r\n allowExtend: boolean = true,\r\n applySnappedCoordinates: boolean = false,\r\n startEndFractionTolerance = Geometry.smallAngleRadians,\r\n startEndXYZTolerance = Geometry.smallMetricDistance,\r\n ): void {\r\n const n0 = details.length;\r\n let acceptIndex = 0;\r\n const point0 = Point3d.create();\r\n const point1 = Point3d.create();\r\n let snappedCoordinates: Point3d | undefined;\r\n for (let candidateIndex = 0; candidateIndex < n0; candidateIndex++) {\r\n snappedCoordinates = undefined;\r\n const detail = details[candidateIndex];\r\n let fraction = detail.fraction;\r\n let accept = allowExtend || Geometry.isIn01(fraction);\r\n if (detail.curve) {\r\n detail.curve.startPoint(point0);\r\n detail.curve.endPoint(point1);\r\n }\r\n if (startEndFractionTolerance > 0) {\r\n if (Math.abs(fraction) < startEndFractionTolerance) {\r\n fraction = 0.0;\r\n accept = true;\r\n detail.intervalRole = CurveIntervalRole.isolatedAtVertex;\r\n snappedCoordinates = point0;\r\n }\r\n if (Math.abs(fraction - 1.0) < startEndFractionTolerance) {\r\n fraction = 1.0;\r\n accept = true;\r\n detail.intervalRole = CurveIntervalRole.isolatedAtVertex;\r\n snappedCoordinates = point1;\r\n if (detail.curve)\r\n snappedCoordinates = detail.curve.startPoint(point1);\r\n }\r\n }\r\n if (startEndXYZTolerance > 0 && detail.curve !== undefined) {\r\n // REMARK: always test both endpoints. If there is a cyclic fraction space, an intersection marked as \"after\" the end might have wrapped all the way to the beginning.\r\n if (detail.point.distance(point0) <= startEndXYZTolerance) {\r\n fraction = 0.0;\r\n detail.intervalRole = CurveIntervalRole.isolatedAtVertex;\r\n snappedCoordinates = point0;\r\n } else if (detail.point.distance(point1) <= startEndXYZTolerance) {\r\n fraction = 1.0;\r\n detail.intervalRole = CurveIntervalRole.isolatedAtVertex;\r\n snappedCoordinates = point1;\r\n }\r\n }\r\n if (accept) {\r\n if (applySnappedCoordinates) {\r\n detail.fraction = fraction;\r\n if (snappedCoordinates !== undefined)\r\n detail.point.setFrom(snappedCoordinates);\r\n }\r\n if (acceptIndex < candidateIndex)\r\n details[acceptIndex] = detail;\r\n acceptIndex++;\r\n }\r\n }\r\n if (acceptIndex < n0)\r\n details.length = acceptIndex;\r\n }\r\n /**\r\n * Ask if the curve is within tolerance of a plane.\r\n * @returns Returns true if the curve is completely within tolerance of the plane.\r\n */\r\n public abstract isInPlane(plane: Plane3dByOriginAndUnitNormal): boolean;\r\n /** Return the startPoint of the primitive. The default implementation returns fractionToPoint(0.0) */\r\n public startPoint(result?: Point3d): Point3d {\r\n return this.fractionToPoint(0.0, result);\r\n }\r\n /** Return the end point of the primitive. The default implementation returns fractionToPoint(1.0) */\r\n public endPoint(result?: Point3d): Point3d {\r\n return this.fractionToPoint(1.0, result);\r\n }\r\n /** Add strokes to caller-supplied linestring (function updates `dest`) */\r\n public abstract emitStrokes(dest: LineString3d, options?: StrokeOptions): void;\r\n /**\r\n * Ask the curve to announce points and simple subcurve fragments for stroking.\r\n * See IStrokeHandler for description of the sequence of the method calls.\r\n */\r\n public abstract emitStrokableParts(dest: IStrokeHandler, options?: StrokeOptions): void;\r\n /**\r\n * Return the stroke count required for given options.\r\n * * This returns a single number\r\n * * See computeComponentStrokeCountForOptions to get structured per-component counts and fraction mappings.\r\n * @param options StrokeOptions that determine count\r\n */\r\n public abstract computeStrokeCountForOptions(options?: StrokeOptions): number;\r\n /**\r\n * Attach StrokeCountMap structure to this primitive (and recursively to any children)\r\n * * Base class implementation (here) gets the simple count from computeStrokeCountForOptions and attaches it.\r\n * * LineString3d, arc3d, BezierCurve3d, BezierCurve3dH accept that default.\r\n * * Subdivided primitives (linestring, bspline curve) implement themselves and attach a StrokeCountMap containing the\r\n * total count, and also containing an array of StrokeCountMap per component.\r\n * * For CurvePrimitiveWithDistanceIndex, the top level gets (only) a total count, and each child gets\r\n * its own StrokeCountMap with appropriate structure.\r\n * @param options StrokeOptions that determine count\r\n * @param parentStrokeMap optional map from parent. Its count, curveLength, and a1 values are increased with count\r\n * and distance from this primitive.\r\n * @return sum of `a0+this.curveLength()`, for use as `a0` of successor in chain.\r\n */\r\n public computeAndAttachRecursiveStrokeCounts(options?: StrokeOptions, parentMap?: StrokeCountMap) {\r\n const n = this.computeStrokeCountForOptions(options);\r\n const a = this.curveLength();\r\n CurvePrimitive.installStrokeCountMap(\r\n this,\r\n StrokeCountMap.createWithCurvePrimitive(this, n, a, 0, a),\r\n parentMap);\r\n }\r\n /**\r\n * Evaluate strokes at fractions indicated in a StrokeCountMap.\r\n * * Base class implementation (here) gets the simple count from computeStrokeCountForOptions and strokes at\r\n * uniform fractions.\r\n * * LineString3d, arc3d, BezierCurve3d, BezierCurve3dH accept that default.\r\n * * Subdivided primitives (linestring, bspline curve) implement themselves and evaluate within components.\r\n * * CurvePrimitiveWithDistanceIndex recurses to its children.\r\n * * if packedFraction and packedDerivative arrays are present in the LineString3d, fill them.\r\n * @param map = stroke count data.\r\n * @param linestring = receiver linestring.\r\n * @return number of strokes added. 0 if any errors matching the map to the curve primitive.\r\n */\r\n public addMappedStrokesToLineString3D(map: StrokeCountMap, linestring: LineString3d): number {\r\n const numPoint0 = linestring.numPoints();\r\n if (map.primitive && map.primitive === this && map.numStroke > 0) {\r\n for (let i = 0; i <= map.numStroke; i++) {\r\n const fraction = i / map.numStroke;\r\n linestring.appendFractionToPoint(this, fraction);\r\n }\r\n }\r\n return linestring.numPoints() - numPoint0;\r\n }\r\n /**\r\n * Final install step to save curveMap in curve. If parentMap is given, update its length, count, and a1 fields\r\n * @param curve curve to receive the annotation\r\n * @param map\r\n * @param parentMap\r\n */\r\n public static installStrokeCountMap(curve: CurvePrimitive, curveMap: StrokeCountMap, parentMap?: StrokeCountMap) {\r\n if (parentMap)\r\n parentMap.addToCountAndLength(curveMap.numStroke, curveMap.curveLength);\r\n curve.strokeData = curveMap;\r\n }\r\n /**\r\n * Return an array containing only the curve primitives.\r\n * * This DEFAULT implementation simply pushes `this` to the collectorArray.\r\n * @param collectorArray array to receive primitives (pushed -- the array is not cleared)\r\n * @param smallestPossiblePrimitives if true, a [[CurvePrimitiveWithDistanceIndex]] recurses on its (otherwise hidden)\r\n * children. If false, it returns only itself.\r\n * @param explodeLinestrings if true, push a [[LineSegment3d]] for each segment of a [[LineString3d]]. If false,\r\n * push only the [[LineString3d]].\r\n */\r\n public collectCurvePrimitivesGo(\r\n collectorArray: CurvePrimitive[], _smallestPossiblePrimitives: boolean, _explodeLinestrings: boolean = false,\r\n ): void {\r\n collectorArray.push(this);\r\n }\r\n /**\r\n * Return an array containing only the curve primitives.\r\n * * This DEFAULT implementation captures the optional collector and calls [[collectCurvePrimitivesGo]].\r\n * @param collectorArray optional array to receive primitives. If present, new primitives are ADDED (without\r\n * clearing the array.)\r\n * @param smallestPossiblePrimitives if false, CurvePrimitiveWithDistanceIndex returns only itself. If true,\r\n * it recurses to its (otherwise hidden) children.\r\n */\r\n public collectCurvePrimitives(\r\n collectorArray?: CurvePrimitive[], smallestPossiblePrimitives: boolean = false, explodeLinestrings: boolean = false,\r\n ): CurvePrimitive[] {\r\n const results: CurvePrimitive[] = collectorArray === undefined ? [] : collectorArray;\r\n this.collectCurvePrimitivesGo(results, smallestPossiblePrimitives, explodeLinestrings);\r\n return results;\r\n }\r\n /**\r\n * Construct an offset of the instance curve as viewed in the xy-plane (ignoring z).\r\n * * No attempt is made to join the offsets of smaller constituent primitives. To construct a fully joined offset\r\n * for an aggregate instance (e.g., LineString3d, CurveChainWithDistanceIndex), use RegionOps.constructCurveXYOffset()\r\n * instead.\r\n * @param offsetDistanceOrOptions offset distance (positive to left of the instance curve), or options object\r\n */\r\n public abstract constructOffsetXY(\r\n offsetDistanceOrOptions: number | OffsetOptions\r\n ): CurvePrimitive | CurvePrimitive[] | undefined;\r\n\r\n /**\r\n * Project instance geometry (via dispatch) onto the line of the given ray, and return the extreme fractional\r\n * parameters of projection.\r\n * @param ray ray onto which the instance is projected. A `Vector3d` is treated as a `Ray3d` with zero origin.\r\n * @param lowHigh optional receiver for output\r\n * @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the\r\n * end of the ray.\r\n */\r\n public projectedParameterRange(_ray: Vector3d | Ray3d, _lowHigh?: Range1d): Range1d | undefined {\r\n return undefined; // common implementation delegated to subclasses to avoid circular dependency\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"CurvePrimitive.js","sourceRoot":"","sources":["../../../src/curve/CurvePrimitive.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAA6C;AAC7C,kEAA+D;AAC/D,0CAA+E;AAC/E,qDAAkD;AAClD,mEAAuE;AACvE,+CAA4D;AAC5D,+CAA4C;AAC5C,uDAAoD;AACpD,+DAAkG;AAClG,mDAAgD;AAChD,kHAA+G;AAC/G,4FAAyF;AACzF,8EAA2E;AAgE3E;;;;;;;;;;;;;GAaG;AACH,MAAsB,cAAe,SAAQ,6BAAa;IAKxD,kBAAkB;IAClB;QACE,KAAK,EAAE,CAAC;QANV,wCAAwC;QACxB,qBAAgB,GAAG,gBAAgB,CAAC;IAMpD,CAAC;IAkCD;;;;OAIG;IACI,6BAA6B,CAAC,QAAgB,EAAE,MAAc;QACnE,MAAM,GAAG,GAAG,IAAI,CAAC,4BAA4B,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAChE,GAAG,CAAC,+BAA+B,CAAC,GAAG,CAAC,CAAC;QACzC,OAAO,GAAG,CAAC;IACb,CAAC;IACD;;;;OAIG;IACI,mBAAmB,CAAC,QAAgB;QACzC,MAAM,IAAI,GAAG,IAAI,CAAC,8BAA8B,CAAC,QAAQ,CAAE,CAAC;QAC5D,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtD,MAAM,CAAC,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAC5B,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QACnC,OAAO,mBAAQ,CAAC,yBAAy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AuB,CAAC,IAAsB,EAAE,QAAkB;QACvE,OAAO,SAAS,CAAC,CAAC,6EAA6E;IACjG,CAAC;CACF;AAtsBD,wCAssBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { StrokeCountMap } from \"../curve/Query/StrokeCountMap\";\r\nimport { AxisOrder, Geometry, type PlaneAltitudeEvaluator } from \"../Geometry\";\r\nimport { Matrix3d } from \"../geometry3d/Matrix3d\";\r\nimport { Point3d, type Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { type Range1d, Range3d } from \"../geometry3d/Range\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { CurveIntervalRole, CurveLocationDetail, CurveSearchStatus } from \"./CurveLocationDetail\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\nimport { AppendPlaneIntersectionStrokeHandler } from \"./internalContexts/AppendPlaneIntersectionStrokeHandler\";\r\nimport { ClosestPointStrokeHandler } from \"./internalContexts/ClosestPointStrokeHandler\";\r\nimport { CurveLengthContext } from \"./internalContexts/CurveLengthContext\";\r\nimport { LineString3d } from \"./LineString3d\";\r\n\r\nimport type { AkimaCurve3d } from \"../bspline/AkimaCurve3d\";\r\nimport type { Arc3d } from \"./Arc3d\";\r\nimport type { BezierCurve3d } from \"../bspline/BezierCurve3d\";\r\nimport type { BSplineCurve3d } from \"../bspline/BSplineCurve\";\r\nimport type { Clipper } from \"../clipping/ClipUtils\";\r\nimport type { CurveChainWithDistanceIndex } from \"./CurveChainWithDistanceIndex\";\r\nimport type { DirectSpiral3d } from \"./spiral/DirectSpiral3d\";\r\nimport type { IntegratedSpiral3d } from \"./spiral/IntegratedSpiral3d\";\r\nimport type { InterpolationCurve3d } from \"../bspline/InterpolationCurve3d\";\r\nimport type { IStrokeHandler } from \"../geometry3d/GeometryHandler\";\r\nimport type { LineSegment3d } from \"./LineSegment3d\";\r\nimport type { OffsetOptions } from \"./OffsetOptions\";\r\nimport type { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport type { Plane3dByOriginAndVectors } from \"../geometry3d/Plane3dByOriginAndVectors\";\r\nimport type { StrokeOptions } from \"./StrokeOptions\";\r\nimport type { VariantCurveExtendParameter } from \"./CurveExtendMode\";\r\n\r\n/**\r\n * Describes the concrete type of a [[CurvePrimitive]]. Each type name maps to a specific subclass and can be used\r\n * for type-switching in conditional statements.\r\n * - \"arc\" => [[Arc3d]]\r\n * - \"lineSegment\" => [[LineSegment3d]]\r\n * - \"lineString\" => [[LineString3d]]\r\n * - \"bsplineCurve\" => [[BSplineCurve3dBase]] which is an intermediate class implemented by [[BSplineCurve3d]] and\r\n * [[BSplineCurve3dH]]\r\n * - \"bezierCurve\" => [[BezierCurveBase]] which is an intermediate class implemented by [[BezierCurve3d]] and\r\n * [[BezierCurve3dH]]\r\n * - \"transitionSpiral\" => [[TransitionSpiral3d]]\r\n * - \"curveChainWithDistanceIndex\" => [[CurveChainWithDistanceIndex]]\r\n * @see [Curve Collections]($docs/learning/geometry/CurvePrimitive.md) learning article.\r\n * @see [[AnyCurvePrimitive]] for a union type that supports compile-time type narrowing.\r\n * @public\r\n */\r\nexport type CurvePrimitiveType = \"arc\" | \"lineSegment\" | \"lineString\" | \"bsplineCurve\" | \"bezierCurve\" | \"transitionSpiral\" | \"curveChainWithDistanceIndex\" | \"interpolationCurve\" | \"akimaCurve\";\r\n/**\r\n * Union type for subclasses of [[CurvePrimitive]]. Specific subclasses can be discriminated at compile- or run-time\r\n * using [[CurvePrimitive.curvePrimitiveType]].\r\n * @public\r\n */\r\nexport type AnyCurvePrimitive = Arc3d | LineSegment3d | LineString3d | BSplineCurve3d | BezierCurve3d | DirectSpiral3d | IntegratedSpiral3d | CurveChainWithDistanceIndex | InterpolationCurve3d | AkimaCurve3d;\r\n/**\r\n * Union type for a linear [[CurvePrimitive]].\r\n * @public\r\n */\r\nexport type LinearCurvePrimitive = LineSegment3d | LineString3d;\r\n/**\r\n * Function signature for callback which announces a pair of numbers, such as a fractional interval, along with a\r\n * containing CurvePrimitive.\r\n * @public\r\n */\r\nexport type AnnounceNumberNumberCurvePrimitive = (a0: number, a1: number, cp: CurvePrimitive) => void;\r\n/**\r\n * Function signature for a callback which announces a pair of numbers\r\n * @public\r\n */\r\nexport type AnnounceNumberNumber = (a0: number, a1: number) => void;\r\n/** Function signature for a callback which announces a curve primitive\r\n * @public\r\n */\r\nexport type AnnounceCurvePrimitive = (cp: CurvePrimitive) => void;\r\n\r\n/**\r\n * A curve primitive is bounded.\r\n * A curve primitive maps fractions in 0..1 to points in space.\r\n * As the fraction proceeds from 0 towards 1, the point moves \"forward\" along the curve.\r\n * True distance along the curve is not always strictly proportional to fraction.\r\n * * A LineSegment3d always has proportional fraction and distance.\r\n * * An Arc3d which is true circular has proportional fraction and distance.\r\n * * A LineString3d is not proportional (except for special case of all segments of equal length).\r\n * * A Spiral3d is proportional.\r\n * * A BsplineCurve3d is only proportional for special cases.\r\n * For fractions outside 0..1, the curve primitive class may either (a) return the near endpoint or (b) evaluate\r\n * an extended curve.\r\n * @public\r\n */\r\nexport abstract class CurvePrimitive extends GeometryQuery {\r\n /** String name for schema properties */\r\n public readonly geometryCategory = \"curvePrimitive\";\r\n /** String name for schema properties */\r\n public abstract readonly curvePrimitiveType: CurvePrimitiveType;\r\n /** Constructor */\r\n protected constructor() {\r\n super();\r\n }\r\n /**\r\n * Data attached during stroking for facets.\r\n */\r\n public strokeData?: StrokeCountMap;\r\n /**\r\n * Data attached in curve cutting.\r\n * @internal\r\n */\r\n public startCut?: CurveLocationDetail;\r\n /**\r\n * Data attached in curve cutting.\r\n * @internal\r\n */\r\n public endCut?: CurveLocationDetail;\r\n /**\r\n * Data attached by various algorithms (e.g. Region booleans)\r\n */\r\n public parent?: any;\r\n /**\r\n * Return the point (x,y,z) on the curve at fractional position.\r\n * @param fraction fractional position along the geometry.\r\n * @returns Returns a point on the curve.\r\n */\r\n public abstract fractionToPoint(fraction: number, result?: Point3d): Point3d;\r\n /**\r\n * Return the point (x,y,z) and derivative on the curve at fractional position.\r\n * * Note that this derivative is \"derivative of xyz with respect to fraction\".\r\n * * This derivative shows the speed of the \"fractional point\" moving along the curve.\r\n * * This is not generally a unit vector. Use fractionToPointAndUnitTangent for a unit vector.\r\n * @param fraction fractional position along the geometry.\r\n * @returns Returns a ray whose origin is the curve point and direction is the derivative with respect to the fraction.\r\n */\r\n public abstract fractionToPointAndDerivative(fraction: number, result?: Ray3d): Ray3d;\r\n /**\r\n * Returns a ray whose origin is the curve point and direction is the unit tangent.\r\n * @param fraction fractional position on the curve\r\n * @param result optional preallocated ray.\r\n */\r\n public fractionToPointAndUnitTangent(fraction: number, result?: Ray3d): Ray3d {\r\n const ray = this.fractionToPointAndDerivative(fraction, result);\r\n ray.trySetDirectionMagnitudeInPlace(1.0);\r\n return ray;\r\n }\r\n /**\r\n * Returns the (absolute) curvature magnitude.\r\n * * Base implementation in CurvePrimitive computes curvature from the first and second derivative vectors.\r\n * @param fraction fractional position on the curve\r\n */\r\n public fractionToCurvature(fraction: number): number | undefined {\r\n const data = this.fractionToPointAnd2Derivatives(fraction)!;\r\n const cross = data.vectorU.crossProduct(data.vectorV);\r\n const a = cross.magnitude();\r\n const b = data.vectorU.magnitude();\r\n return Geometry.conditionalDivideFraction(a, b * b * b);\r\n }\r\n /**\r\n * Return a plane with\r\n * * origin at fractional position along the curve\r\n * * vectorU is the first derivative, i.e. tangent vector with length equal to the rate of change with respect to\r\n * the fraction.\r\n * * vectorV is the second derivative, i.e. derivative of vectorU which points in the direction of the curve's\r\n * derivative's change.\r\n * * **Note:** We are dealing with a parametric equation of the curve (a function f : R -> R^3) so first and\r\n * second derivatives are in fact derivatives of the parametric equation.\r\n */\r\n public abstract fractionToPointAnd2Derivatives(\r\n fraction: number, result?: Plane3dByOriginAndVectors\r\n ): Plane3dByOriginAndVectors | undefined;\r\n /**\r\n * Construct a frenet frame:\r\n * * origin at the point on the curve\r\n * * x axis is unit vector along the curve (tangent)\r\n * * y axis is perpendicular and in the plane of the osculating circle. y axis is called \"main normal\"\r\n * * z axis perpendicular to those. z axis is called \"bi-normal\"\r\n */\r\n public fractionToFrenetFrame(fraction: number, result?: Transform): Transform | undefined {\r\n const plane = this.fractionToPointAnd2Derivatives(fraction);\r\n if (!plane)\r\n return undefined;\r\n // first derivative (plane.vectorU) and second derivative (plane.vectorV) are not essentially\r\n // perpendicular so we use createRigidFromColumns to make 3 perpendicular vectors.\r\n let axes = Matrix3d.createRigidFromColumns(plane.vectorU, plane.vectorV, AxisOrder.XYZ);\r\n if (axes)\r\n return Transform.createRefs(plane.origin, axes, result);\r\n // 2nd derivative not distinct. for example if curve is linear at fraction so second derivative is 0.\r\n // in this case we find perpendicular vector to plane.vectorU and pass it to createRigidFromColumns.\r\n const perpVector = Matrix3d.createPerpendicularVectorFavorXYPlane(plane.vectorU, plane.vectorV);\r\n axes = Matrix3d.createRigidFromColumns(plane.vectorU, perpVector, AxisOrder.XYZ);\r\n if (axes)\r\n return Transform.createRefs(plane.origin, axes, result);\r\n return undefined;\r\n }\r\n /**\r\n * Construct signed distance from a point on the planar curve to its center of curvature (in xy only).\r\n * * Positive distance means the center is to the left of the curve at fraction.\r\n * * Negative distance means the center is to the right of the curve at fraction.\r\n * * Zero distance means curve is linear at fraction.\r\n */\r\n public fractionToSignedXYRadiusOfCurvature(fraction: number): number {\r\n const plane = this.fractionToPointAnd2Derivatives(fraction);\r\n if (!plane)\r\n return 0.0;\r\n const cross = plane.vectorU.crossProductXY(plane.vectorV);\r\n const b = plane.vectorU.magnitude();\r\n if (b === 0.0)\r\n return 0.0;\r\n const r = Geometry.conditionalDivideCoordinate(b * b * b, cross);\r\n if (r !== undefined)\r\n return r;\r\n return 0.0;\r\n }\r\n /**\r\n * Construct a point extrapolated along tangent at fraction.\r\n * @param fraction fractional position on the primitive\r\n * @param distance (signed) distance to move on the tangent.\r\n */\r\n public fractionAndDistanceToPointOnTangent(fraction: number, distance: number): Point3d {\r\n const ray = this.fractionToPointAndUnitTangent(fraction);\r\n return ray.fractionToPoint(distance);\r\n }\r\n /**\r\n * Return the length of the curve.\r\n * * Curve length is always positive.\r\n */\r\n public curveLength(): number {\r\n const context = new CurveLengthContext();\r\n this.emitStrokableParts(context);\r\n return context.getSum();\r\n }\r\n /**\r\n * Returns a (high accuracy) length of the curve between fractional positions.\r\n * * Curve length is always positive.\r\n * * Default implementation applies a generic Gaussian integration.\r\n * * Most curve classes (certainly LineSegment, LineString, Arc) are expected to provide efficient implementations.\r\n */\r\n public curveLengthBetweenFractions(fraction0: number, fraction1: number): number {\r\n if (fraction0 === fraction1)\r\n return 0.0;\r\n const scale = this.getFractionToDistanceScale();\r\n if (scale !== undefined) {\r\n // We are in luck! simple proportions determine it all !!!\r\n // (for example, a LineSegment3d or a circular arc)\r\n const totalLength = this.curveLength();\r\n return Math.abs((fraction1 - fraction0) * totalLength);\r\n }\r\n const context = new CurveLengthContext(fraction0, fraction1);\r\n this.emitStrokableParts(context);\r\n return Math.abs(context.getSum());\r\n }\r\n /**\r\n * Returns a (high accuracy) range of the curve between fractional positions\r\n * * Default implementation returns the range of the curve from clonePartialCurve.\r\n */\r\n public rangeBetweenFractions(fraction0: number, fraction1: number, transform?: Transform): Range3d {\r\n return this.rangeBetweenFractionsByClone(fraction0, fraction1, transform);\r\n }\r\n /**\r\n * Returns a (high accuracy) range of the curve between fractional positions\r\n * * Default implementation returns the range of the curve from clonePartialCurve\r\n */\r\n public rangeBetweenFractionsByClone(fraction0: number, fraction1: number, transform?: Transform): Range3d {\r\n if (fraction0 === fraction1)\r\n return Range3d.create(this.fractionToPoint(fraction0));\r\n const fragment = this.clonePartialCurve(fraction0, fraction1);\r\n if (fragment)\r\n return fragment.range(transform);\r\n return Range3d.createNull();\r\n }\r\n /**\r\n * Returns an approximate range based on a fixed number of evaluations\r\n * * Default implementation returns a range determined by evaluating a specified number of points on the curve.\r\n * * Optional evaluate again at interval midpoints and extrapolate any increase\r\n * * For a smooth curve, Richardson extrapolation suggests each subdivision moves 3/4 of the way to final. So\r\n * extrapolationFactor of 1/3 gets speculatively moves closer to the tight range, and larger multipliers increase\r\n * confidence in being safely larger.\r\n * * This function is faster version to compute the range of a portion of a curve (because some curves can be\r\n * expensive to compute the partial curve and/or to compute the partial curve's range.\r\n * @param fraction0 start fraction for evaluation\r\n * @param fraction1 end fraction for evaluation\r\n * @param count number of points to evaluate\r\n * @param transform optional transform to be applied to the curve\r\n * @param extrapolationFactor if positive, evaluate again at interval midpoints and apply this fraction multiplier\r\n * to any increase in size.\r\n */\r\n public rangeBetweenFractionsByCount(\r\n fraction0: number, fraction1: number, count: number, transform?: Transform, extrapolationFactor: number = 0.0,\r\n ): Range3d {\r\n const range = Range3d.createNull();\r\n const workPoint = Point3d.create();\r\n range.extendPoint(this.startPoint(workPoint));\r\n range.extendPoint(this.endPoint(workPoint));\r\n // Evaluate at count fractions (fraction0 + i * fractionStep)\r\n const evaluateSteps = (fractionA: number, fractionStep: number, countA: number) => {\r\n let f = fractionA;\r\n for (let i = 0; i < countA; i++, f += fractionStep) {\r\n this.fractionToPoint(f, workPoint);\r\n if (transform)\r\n range.extendTransformedPoint(transform, workPoint);\r\n else\r\n range.extendPoint(workPoint);\r\n }\r\n };\r\n const interiorCount = count - 2;\r\n if (interiorCount > 0) {\r\n const localFraction0 = 1.0 / (interiorCount + 1);\r\n const globalFractionStep = localFraction0 * (fraction1 - fraction0);\r\n evaluateSteps(fraction0 + globalFractionStep, globalFractionStep, interiorCount);\r\n }\r\n if (extrapolationFactor > 0.0) {\r\n // Evaluate at midpoints. Where this makes the range larger, apply extrapolationFactor to move it to safer\r\n // excess value. same interior step, but shift to interval midpoints.\r\n const baseRange = range.clone();\r\n const interiorCount1 = interiorCount + 1;\r\n const localFraction0 = 0.5 / interiorCount1; // we only evaluate at new midpoints.\r\n const globalFractionStep = 2 * localFraction0 * (fraction1 - fraction0); // same as above, but avoids special logic for interiorCount = 0\r\n evaluateSteps(fraction0 + globalFractionStep * 0.5, globalFractionStep, interiorCount1);\r\n range.extendWhenLarger(baseRange, extrapolationFactor);\r\n }\r\n return range;\r\n }\r\n /**\r\n * Run an integration (with a default Gaussian quadrature) with a fixed fractional step\r\n * * This is typically called by specific curve type implementations of curveLengthBetweenFractions.\r\n * * For example, in Arc3d implementation of curveLengthBetweenFractions:\r\n * * If the Arc3d is true circular, it the arc is true circular, use the direct `arcLength = radius * sweepRadians`\r\n * * If the Arc3d is not true circular, call this method with an interval count appropriate to eccentricity and\r\n * sweepRadians.\r\n * @returns Returns the curve length via an integral estimated by numerical quadrature between the fractional positions.\r\n * @param fraction0 start fraction for integration\r\n * @param fraction1 end fraction for integration\r\n * @param numInterval number of quadrature intervals\r\n */\r\n public curveLengthWithFixedIntervalCountQuadrature(\r\n fraction0: number, fraction1: number, numInterval: number, numGauss: number = 5,\r\n ): number {\r\n if (fraction0 > fraction1) {\r\n const fSave = fraction0;\r\n fraction0 = fraction1;\r\n fraction1 = fSave;\r\n }\r\n const context = new CurveLengthContext(fraction0, fraction1, numGauss);\r\n context.announceIntervalForUniformStepStrokes(this, numInterval, fraction0, fraction1);\r\n return Math.abs(context.getSum());\r\n }\r\n /**\r\n * (Attempt to) find a position on the curve at a signed distance from start fraction.\r\n * * Return the position as a CurveLocationDetail.\r\n * * In the `CurveLocationDetail`, record:\r\n * * `fraction` = fractional position\r\n * * `point` = coordinates of the point\r\n * * `a` = (signed!) distance moved. If `allowExtension` is false and the move reached the start or end of the\r\n * curve, this distance is smaller than the requested signedDistance.\r\n * * `curveSearchStatus` indicates one of:\r\n * * `error` (unusual) computation failed not supported for this curve.\r\n * * `success` full movement completed\r\n * * `stoppedAtBoundary` partial movement completed. This can be due to either\r\n * * `allowExtension` parameter sent as `false`\r\n * * the curve type (e.g. bspline) does not support extended range.\r\n * * if `allowExtension` is true, movement may still end at the startPoint or end point for curves that do not support\r\n * extended geometry (specifically bsplines)\r\n * * if the curve returns a value (i.e. not `undefined`) for `curve.getFractionToDistanceScale()`, the base class\r\n * carries out the computation\r\n * and returns a final location.\r\n * * LineSegment3d relies on this.\r\n * * If the curve does not implement the computation or the curve has zero length, the returned `CurveLocationDetail`\r\n * has\r\n * * `fraction` = the value of `startFraction`\r\n * * `point` = result of `curve.fractionToPoint(startFraction)`\r\n * * `a` = 0\r\n * * `curveStartState` = `CurveSearchStatus.error`\r\n * @param startFraction fractional position where the move starts\r\n * @param signedDistance distance to move. Negative distance is backwards in the fraction space\r\n * @param allowExtension if true, allow the move to go beyond the startPoint or endpoint of the curve. If false,\r\n * do not allow movement beyond the startPoint or endpoint\r\n * @param result optional result.\r\n * @returns A CurveLocationDetail annotated as above. Note that if the curve does not support the calculation, there is\r\n * still a result which contains the point at the input startFraction, with failure indicated in the `curveStartState`\r\n * member\r\n */\r\n public moveSignedDistanceFromFraction(\r\n startFraction: number, signedDistance: number, allowExtension: boolean, result?: CurveLocationDetail,\r\n ): CurveLocationDetail {\r\n const scale = this.getFractionToDistanceScale();\r\n if (scale !== undefined) {\r\n // We are in luck! simple proportions determine it all !!!\r\n // (for example, a LineSegment3d or a circular arc)\r\n const totalLength = this.curveLength();\r\n const signedFractionMove = Geometry.conditionalDivideFraction(signedDistance, totalLength);\r\n if (signedFractionMove === undefined) {\r\n return CurveLocationDetail.createCurveFractionPointDistanceCurveSearchStatus(\r\n this, startFraction, this.fractionToPoint(startFraction), 0.0, CurveSearchStatus.error);\r\n }\r\n return CurveLocationDetail.createConditionalMoveSignedDistance(\r\n allowExtension,\r\n this,\r\n startFraction,\r\n startFraction + signedFractionMove,\r\n signedDistance,\r\n result,\r\n );\r\n }\r\n return this.moveSignedDistanceFromFractionGeneric(startFraction, signedDistance, allowExtension, result);\r\n }\r\n /**\r\n * Generic algorithm to search for point at signed distance from a fractional startPoint.\r\n * * This will work for well for smooth curves.\r\n * * Curves with tangent or other low-order-derivative discontinuities may need to implement specialized algorithms.\r\n * * We need to find an endFraction which is the end-of-interval (usually upper) limit of integration of the tangent\r\n * magnitude from startFraction to endFraction\r\n * * That integral is a function of endFraction.\r\n * * The derivative of that integral with respect to end fraction is the tangent magnitude at end fraction.\r\n * * Use that function and (easily evaluated!) derivative for a Newton iteration\r\n * * TO ALL WHO HAVE FUZZY MEMORIES OF CALCULUS CLASS: \"The derivative of the integral wrt upper limit is the value\r\n * of the integrand there\" is the fundamental theorem of integral calculus !!! The fundamental theorem is not just\r\n * an abstraction !!! It is being used here in its barest possible form !!!\r\n * * See https://en.wikipedia.org/wiki/Fundamental_theorem_of_calculus\r\n * @param startFraction\r\n * @param signedDistance\r\n * @param _allowExtension\r\n * @param result\r\n */\r\n protected moveSignedDistanceFromFractionGeneric(\r\n startFraction: number, signedDistance: number, allowExtension: boolean, result?: CurveLocationDetail,\r\n ): CurveLocationDetail {\r\n let limitFraction: number;\r\n const slackFraction = 0.1; // slack to use when integration would otherwise have no room to work\r\n if (signedDistance === 0.0)\r\n return CurveLocationDetail.createCurveEvaluatedFraction(this, startFraction, result); // no movement, just evaluate at startFraction\r\n if (signedDistance > 0.0) {\r\n limitFraction = 1.0;\r\n if (startFraction >= 1.0) {\r\n const newStartFraction = 1.0 - slackFraction;\r\n signedDistance += this.curveLengthBetweenFractions(newStartFraction, startFraction);\r\n startFraction = newStartFraction;\r\n }\r\n } else { // signedDistance < 0.0\r\n limitFraction = 0.0;\r\n if (startFraction <= 0.0) {\r\n const newStartFraction = 0.0 + slackFraction;\r\n signedDistance -= this.curveLengthBetweenFractions(startFraction, newStartFraction);\r\n startFraction = newStartFraction;\r\n }\r\n }\r\n const availableLength = this.curveLengthBetweenFractions(startFraction, limitFraction);\r\n assert(availableLength > 0.0);\r\n const absDistance = Math.abs(signedDistance);\r\n if (availableLength < absDistance && !allowExtension)\r\n return CurveLocationDetail.createConditionalMoveSignedDistance(allowExtension, this, startFraction, limitFraction, signedDistance, result);\r\n\r\n const fractionStep = Geometry.conditionalDivideCoordinate(absDistance, availableLength);\r\n if (undefined === fractionStep) {\r\n // no available length!\r\n result = CurveLocationDetail.createCurveEvaluatedFraction(this, startFraction, result);\r\n result.curveSearchStatus = CurveSearchStatus.error;\r\n return result;\r\n }\r\n const directionFactor = signedDistance < 0.0 ? -1.0 : 1.0;\r\n let fractionB = Geometry.interpolate(startFraction, fractionStep, limitFraction);\r\n let fractionA = startFraction;\r\n let distanceA = 0.0;\r\n const tol = 1.0e-12 * availableLength;\r\n let numConverged = 0;\r\n const tangent = Ray3d.createXAxis();\r\n // on each loop entry:\r\n // fractionA is the most recent endOfInterval. (It may have been reached by a mixture of forward and backward step.)\r\n // distanceA is the distance to (the point at) fractionA\r\n // fractionB is the next end fraction\r\n for (let iterations = 0; iterations < 10; iterations++) {\r\n const distanceAB = this.curveLengthBetweenFractions(fractionA, fractionB);\r\n const directionAB = fractionB > fractionA ? directionFactor : -directionFactor;\r\n const distance0B = distanceA + directionAB * distanceAB;\r\n const distanceError = absDistance - distance0B;\r\n if (Math.abs(distanceError) < tol) {\r\n numConverged++;\r\n if (numConverged > 1)\r\n break;\r\n } else {\r\n numConverged = 0;\r\n }\r\n this.fractionToPointAndDerivative(fractionB, tangent);\r\n const tangentMagnitude = tangent.direction.magnitude();\r\n fractionA = fractionB;\r\n fractionB = fractionA + directionFactor * distanceError / tangentMagnitude;\r\n if (fractionA === fractionB) { // YES -- that is an exact equality test. When it happens, there's no need for confirming with another iteration.\r\n numConverged = 100;\r\n break;\r\n }\r\n distanceA = distance0B;\r\n }\r\n if (numConverged > 1)\r\n return CurveLocationDetail.createConditionalMoveSignedDistance(\r\n allowExtension, this, startFraction, fractionB, signedDistance, result,\r\n );\r\n result = CurveLocationDetail.createCurveEvaluatedFraction(this, startFraction, result);\r\n result.curveSearchStatus = CurveSearchStatus.error;\r\n return result;\r\n }\r\n /**\r\n * * Returns true if the curve can be easily extended past its start/end point (i.e., beyond the usual\r\n * fraction space [0,1]). Otherwise, returns false.\r\n * * Base class default implementation returns false.\r\n * * These classes (and perhaps others in the future) will return true:\r\n * * LineSegment3d\r\n * * LineString3d\r\n * * Arc3d\r\n */\r\n public get isExtensibleFractionSpace(): boolean {\r\n return false;\r\n }\r\n /**\r\n * Compute a length for curve which may be a fast approximation to the true length.\r\n * This is expected to be either (a) exact or (b) larger than the actual length, but by no more than\r\n * a small multiple, perhaps up to PI/2, but commonly much closer to 1.\r\n *\r\n * * An example use of this is for setting a tolerance which is a small multiple of the curve length.\r\n * * Simple line, circular arc, and transition spiral may return exact length\r\n * * Ellipse may return circumference of some circle or polygon that encloses the ellipse.\r\n * * bspline curve may return control polygon length\r\n * *\r\n */\r\n public abstract quickLength(): number;\r\n /**\r\n * Search for a point on the curve that is closest to the spacePoint.\r\n * * If the space point is exactly on the curve, this is the reverse of fractionToPoint.\r\n * * Since CurvePrimitive should always have start and end available as candidate points, this method should always\r\n * succeed\r\n * @param spacePoint point in space\r\n * @param extend true to extend the curve (if possible), false for no extend, single CurveExtendOptions (for both\r\n * directions), or array of distinct CurveExtendOptions for start and end.\r\n * @returns Returns a CurveLocationDetail structure that holds the details of the close point.\r\n */\r\n public closestPoint(\r\n spacePoint: Point3d, extend: VariantCurveExtendParameter, result?: CurveLocationDetail,\r\n ): CurveLocationDetail | undefined {\r\n const strokeHandler = new ClosestPointStrokeHandler(spacePoint, extend, result);\r\n this.emitStrokableParts(strokeHandler);\r\n return strokeHandler.claimResult();\r\n }\r\n /**\r\n * Find intervals of this curvePrimitive that are interior to a clipper\r\n * @param clipper clip structure (e.g. clip planes)\r\n * @param announce (optional) function to be called announcing fractional intervals\r\n * `announce(fraction0, fraction1, curvePrimitive)`\r\n * @returns true if any \"in\" segments are announced.\r\n */\r\n public announceClipIntervals(_clipper: Clipper, _announce?: AnnounceNumberNumberCurvePrimitive): boolean {\r\n // DEFAULT IMPLEMENTATION -- no interior parts\r\n return false;\r\n }\r\n /** Return a deep clone. */\r\n public abstract override clone(): CurvePrimitive;\r\n /** Return a transformed deep clone. */\r\n public abstract override cloneTransformed(transform: Transform): CurvePrimitive | undefined;\r\n /**\r\n * Return (if possible) a curve primitive which is a portion of this curve.\r\n * @param _fractionA [in] start fraction\r\n * @param _fractionB [in] end fraction\r\n */\r\n public clonePartialCurve(_fractionA: number, _fractionB: number): CurvePrimitive | undefined {\r\n return undefined;\r\n }\r\n /**\r\n * If the curve primitive has distance-along-curve strictly proportional to curve fraction, return the scale factor.\r\n * If distance-along-the-curve is not proportional, return undefined.\r\n * * When defined, the scale factor is always the length of the curve.\r\n * * This scale factor is typically available for these curve types:\r\n * * * All `LineSegment3d`\r\n * * * Arc3d which is a true circular arc (axes perpendicular and of equal length).\r\n * * * CurveChainWithDistanceIndex\r\n * * This scale factor is undefined for these curve types:\r\n * * * Arc3d which is a true ellipse, i.e. unequal lengths of defining vectors or non-perpendicular defining vectors.\r\n * * * bspline and bezier curves\r\n * @returns scale factor or undefined\r\n */\r\n public getFractionToDistanceScale(): number | undefined {\r\n return undefined;\r\n }\r\n /** Reverse the curve's data so that its fractional stroking moves in the opposite direction. */\r\n public abstract reverseInPlace(): void;\r\n /**\r\n * Compute intersections of the curve with a plane.\r\n * * The intersections are appended to the result array.\r\n * * The base class implementation emits strokes to an AppendPlaneIntersectionStrokeHandler object, which uses a\r\n * Newton iteration to get high-accuracy intersection points within strokes.\r\n * * Derived classes should override this default implementation if there are easy analytic solutions.\r\n * * Derived classes are free to implement extended intersections (e.g. arc!!!)\r\n * @param plane The plane to be intersected.\r\n * @param result Array to receive intersections\r\n * @returns Return the number of CurveLocationDetail's added to the result array.\r\n */\r\n public appendPlaneIntersectionPoints(plane: PlaneAltitudeEvaluator, result: CurveLocationDetail[]): number {\r\n const strokeHandler = new AppendPlaneIntersectionStrokeHandler(plane, result);\r\n const n0 = result.length;\r\n this.emitStrokableParts(strokeHandler);\r\n return result.length - n0;\r\n }\r\n /**\r\n * Examine contents of an array of CurveLocationDetail.\r\n * Filter the intersections according to the parameters.\r\n * @param allowExtend if false, remove points on the extension.\r\n * @param applySnappedCoordinates if true, change the stored fractions and coordinates to exact end values.\r\n * Otherwise use the exact values only for purpose of updating the curveIntervalRole.\r\n * @param startEndFractionTolerance if nonzero, adjust fraction to 0 or 1 with this tolerance.\r\n * @param startEndXYZTolerance if nonzero, adjust to endpoint with this tolerance.\r\n * @internal\r\n */\r\n public static snapAndRestrictDetails(\r\n details: CurveLocationDetail[],\r\n allowExtend: boolean = true,\r\n applySnappedCoordinates: boolean = false,\r\n startEndFractionTolerance = Geometry.smallAngleRadians,\r\n startEndXYZTolerance = Geometry.smallMetricDistance,\r\n ): void {\r\n const n0 = details.length;\r\n let acceptIndex = 0;\r\n const point0 = Point3d.create();\r\n const point1 = Point3d.create();\r\n let snappedCoordinates: Point3d | undefined;\r\n for (let candidateIndex = 0; candidateIndex < n0; candidateIndex++) {\r\n snappedCoordinates = undefined;\r\n const detail = details[candidateIndex];\r\n let fraction = detail.fraction;\r\n let accept = allowExtend || Geometry.isIn01(fraction);\r\n if (detail.curve) {\r\n detail.curve.startPoint(point0);\r\n detail.curve.endPoint(point1);\r\n }\r\n if (startEndFractionTolerance > 0) {\r\n if (Math.abs(fraction) < startEndFractionTolerance) {\r\n fraction = 0.0;\r\n accept = true;\r\n detail.intervalRole = CurveIntervalRole.isolatedAtVertex;\r\n snappedCoordinates = point0;\r\n }\r\n if (Math.abs(fraction - 1.0) < startEndFractionTolerance) {\r\n fraction = 1.0;\r\n accept = true;\r\n detail.intervalRole = CurveIntervalRole.isolatedAtVertex;\r\n snappedCoordinates = point1;\r\n if (detail.curve)\r\n snappedCoordinates = detail.curve.startPoint(point1);\r\n }\r\n }\r\n if (startEndXYZTolerance > 0 && detail.curve !== undefined) {\r\n // REMARK: always test both endpoints. If there is a cyclic fraction space, an intersection marked as \"after\" the end might have wrapped all the way to the beginning.\r\n if (detail.point.distance(point0) <= startEndXYZTolerance) {\r\n fraction = 0.0;\r\n detail.intervalRole = CurveIntervalRole.isolatedAtVertex;\r\n snappedCoordinates = point0;\r\n } else if (detail.point.distance(point1) <= startEndXYZTolerance) {\r\n fraction = 1.0;\r\n detail.intervalRole = CurveIntervalRole.isolatedAtVertex;\r\n snappedCoordinates = point1;\r\n }\r\n }\r\n if (accept) {\r\n if (applySnappedCoordinates) {\r\n detail.fraction = fraction;\r\n if (snappedCoordinates !== undefined)\r\n detail.point.setFrom(snappedCoordinates);\r\n }\r\n if (acceptIndex < candidateIndex)\r\n details[acceptIndex] = detail;\r\n acceptIndex++;\r\n }\r\n }\r\n if (acceptIndex < n0)\r\n details.length = acceptIndex;\r\n }\r\n /**\r\n * Ask if the curve is within tolerance of a plane.\r\n * @returns Returns true if the curve is completely within tolerance of the plane.\r\n */\r\n public abstract isInPlane(plane: Plane3dByOriginAndUnitNormal): boolean;\r\n /** Return the startPoint of the primitive. The default implementation returns fractionToPoint(0.0) */\r\n public startPoint(result?: Point3d): Point3d {\r\n return this.fractionToPoint(0.0, result);\r\n }\r\n /** Return the end point of the primitive. The default implementation returns fractionToPoint(1.0) */\r\n public endPoint(result?: Point3d): Point3d {\r\n return this.fractionToPoint(1.0, result);\r\n }\r\n /** Add strokes to caller-supplied linestring (function updates `dest`) */\r\n public abstract emitStrokes(dest: LineString3d, options?: StrokeOptions): void;\r\n /**\r\n * Ask the curve to announce points and simple subcurve fragments for stroking.\r\n * See IStrokeHandler for description of the sequence of the method calls.\r\n */\r\n public abstract emitStrokableParts(dest: IStrokeHandler, options?: StrokeOptions): void;\r\n /**\r\n * Return the stroke count required for given options.\r\n * * This returns a single number\r\n * * See computeComponentStrokeCountForOptions to get structured per-component counts and fraction mappings.\r\n * @param options StrokeOptions that determine count\r\n */\r\n public abstract computeStrokeCountForOptions(options?: StrokeOptions): number;\r\n /**\r\n * Attach StrokeCountMap structure to this primitive (and recursively to any children)\r\n * * Base class implementation (here) gets the simple count from computeStrokeCountForOptions and attaches it.\r\n * * LineString3d, arc3d, BezierCurve3d, BezierCurve3dH accept that default.\r\n * * Subdivided primitives (linestring, bspline curve) implement themselves and attach a StrokeCountMap containing the\r\n * total count, and also containing an array of StrokeCountMap per component.\r\n * * For CurvePrimitiveWithDistanceIndex, the top level gets (only) a total count, and each child gets\r\n * its own StrokeCountMap with appropriate structure.\r\n * @param options StrokeOptions that determine count\r\n * @param parentStrokeMap optional map from parent. Its count, curveLength, and a1 values are increased with count\r\n * and distance from this primitive.\r\n * @return sum of `a0+this.curveLength()`, for use as `a0` of successor in chain.\r\n */\r\n public computeAndAttachRecursiveStrokeCounts(options?: StrokeOptions, parentMap?: StrokeCountMap) {\r\n const n = this.computeStrokeCountForOptions(options);\r\n const a = this.curveLength();\r\n CurvePrimitive.installStrokeCountMap(\r\n this,\r\n StrokeCountMap.createWithCurvePrimitive(this, n, a, 0, a),\r\n parentMap);\r\n }\r\n /**\r\n * Evaluate strokes at fractions indicated in a StrokeCountMap.\r\n * * Base class implementation (here) gets the simple count from computeStrokeCountForOptions and strokes at\r\n * uniform fractions.\r\n * * LineString3d, arc3d, BezierCurve3d, BezierCurve3dH accept that default.\r\n * * Subdivided primitives (linestring, bspline curve) implement themselves and evaluate within components.\r\n * * CurvePrimitiveWithDistanceIndex recurses to its children.\r\n * * if packedFraction and packedDerivative arrays are present in the LineString3d, fill them.\r\n * @param map = stroke count data.\r\n * @param linestring = receiver linestring.\r\n * @return number of strokes added. 0 if any errors matching the map to the curve primitive.\r\n */\r\n public addMappedStrokesToLineString3D(map: StrokeCountMap, linestring: LineString3d): number {\r\n const numPoint0 = linestring.numPoints();\r\n if (map.primitive && map.primitive === this && map.numStroke > 0) {\r\n for (let i = 0; i <= map.numStroke; i++) {\r\n const fraction = i / map.numStroke;\r\n linestring.appendFractionToPoint(this, fraction);\r\n }\r\n }\r\n return linestring.numPoints() - numPoint0;\r\n }\r\n /**\r\n * Final install step to save curveMap in curve. If parentMap is given, update its length, count, and a1 fields\r\n * @param curve curve to receive the annotation\r\n * @param map\r\n * @param parentMap\r\n */\r\n public static installStrokeCountMap(curve: CurvePrimitive, curveMap: StrokeCountMap, parentMap?: StrokeCountMap) {\r\n if (parentMap)\r\n parentMap.addToCountAndLength(curveMap.numStroke, curveMap.curveLength);\r\n curve.strokeData = curveMap;\r\n }\r\n /**\r\n * Return an array containing only the curve primitives.\r\n * * This DEFAULT implementation simply pushes `this` to the collectorArray.\r\n * @param collectorArray array to receive primitives (pushed -- the array is not cleared)\r\n * @param smallestPossiblePrimitives if true, a [[CurvePrimitiveWithDistanceIndex]] recurses on its (otherwise hidden)\r\n * children. If false, it returns only itself.\r\n * @param explodeLinestrings if true, push a [[LineSegment3d]] for each segment of a [[LineString3d]]. If false,\r\n * push only the [[LineString3d]].\r\n */\r\n public collectCurvePrimitivesGo(\r\n collectorArray: CurvePrimitive[], _smallestPossiblePrimitives: boolean, _explodeLinestrings: boolean = false,\r\n ): void {\r\n collectorArray.push(this);\r\n }\r\n /**\r\n * Return an array containing only the curve primitives.\r\n * * This DEFAULT implementation captures the optional collector and calls [[collectCurvePrimitivesGo]].\r\n * @param collectorArray optional array to receive primitives. If present, new primitives are ADDED (without\r\n * clearing the array.)\r\n * @param smallestPossiblePrimitives if false, CurvePrimitiveWithDistanceIndex returns only itself. If true,\r\n * it recurses to its (otherwise hidden) children.\r\n */\r\n public collectCurvePrimitives(\r\n collectorArray?: CurvePrimitive[], smallestPossiblePrimitives: boolean = false, explodeLinestrings: boolean = false,\r\n ): CurvePrimitive[] {\r\n const results: CurvePrimitive[] = collectorArray === undefined ? [] : collectorArray;\r\n this.collectCurvePrimitivesGo(results, smallestPossiblePrimitives, explodeLinestrings);\r\n return results;\r\n }\r\n /**\r\n * Construct an offset of the instance curve as viewed in the xy-plane (ignoring z).\r\n * * No attempt is made to join the offsets of smaller constituent primitives. To construct a fully joined offset\r\n * for an aggregate instance (e.g., LineString3d, CurveChainWithDistanceIndex), use [[CurveOps.constructCurveXYOffset]]\r\n * instead.\r\n * @param offsetDistanceOrOptions offset distance (positive to left of the instance curve), or options object\r\n */\r\n public abstract constructOffsetXY(\r\n offsetDistanceOrOptions: number | OffsetOptions\r\n ): CurvePrimitive | CurvePrimitive[] | undefined;\r\n\r\n /**\r\n * Project instance geometry (via dispatch) onto the line of the given ray, and return the extreme fractional\r\n * parameters of projection.\r\n * @param ray ray onto which the instance is projected. A `Vector3d` is treated as a `Ray3d` with zero origin.\r\n * @param lowHigh optional receiver for output\r\n * @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the\r\n * end of the ray.\r\n */\r\n public projectedParameterRange(_ray: Vector3d | Ray3d, _lowHigh?: Range1d): Range1d | undefined {\r\n return undefined; // common implementation delegated to subclasses to avoid circular dependency\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CylindricalRange.js","sourceRoot":"","sources":["../../../../src/curve/Query/CylindricalRange.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,sEAAkF;AAClF,sEAAqE;AAOrE,kDAA+C;AAC/C,oDAAiD;AAEjD;;;GAGG;AACH,MAAa,qBAAsB,SAAQ,gDAA8B;IAKvE,kDAAkD;IAClD,YAAoB,GAAU;QAC5B,KAAK,EAAE,CAAC;QAKF,gBAAW,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;QAC/B,gBAAW,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;QALrC,IAAI,CAAC,WAAW,GAAG,0BAAQ,CAAC,UAAU,EAAE,CAAC;QACzC,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC;QACxB,IAAI,CAAC,aAAa,GAAG,GAAG,CAAC,aAAa,EAAG,CAAC;IAC5C,CAAC;IAGO,aAAa,CAAC,GAAY;QAChC,IAAI,CAAC,aAAa,CAAC,sBAAsB,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACjE,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,C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CAAiC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;oBACrD,IAAI,OAAO,CAAC,YAAY;wBACtB,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;;wBAE5D,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;oBAChD,QAAQ,CAAC,iBAAiB,CAAC,+BAA+B,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,qCAAqC;oBAC7G,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAE,4BAA4B;oBACrE,OAAO,CAAC,gBAAgB,EAAE,CAAC;oBAC3B,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;aAAM,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAC7B,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;YACnC,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;gBAC7B,IAAI,CAAC,mCAAmC,CAAC,KAAiB,EAAE,IAAI,EAAE,qBAAqB,CAAC,CAAC;YAC3F,CAAC;QACH,CAAC;IACH,CAAC;CACF;AArGD,sDAqGC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { RecurseToCurvesGeometryHandler } from \"../../geometry3d/GeometryHandler\";\r\nimport { Point3d, Vector3d } from \"../../geometry3d/Point3dVector3d\";\r\nimport { Ray3d } from \"../../geometry3d/Ray3d\";\r\nimport { Transform } from \"../../geometry3d/Transform\";\r\nimport { Arc3d } from \"../Arc3d\";\r\nimport { AnyCurve } from \"../CurveTypes\";\r\nimport { GeometryQuery } from \"../GeometryQuery\";\r\nimport { LineSegment3d } from \"../LineSegment3d\";\r\nimport { LineString3d } from \"../LineString3d\";\r\nimport { StrokeOptions } from \"../StrokeOptions\";\r\n\r\n/**\r\n * Context for computing geometry range around an axis.\r\n * * The publicly called method is `computeZRRange (ray, geometry)\r\n */\r\nexport class CylindricalRangeQuery extends RecurseToCurvesGeometryHandler {\r\n // private geometry0: GeometryQuery; <-- Never used\r\n private _perpVector: Vector3d;\r\n private _maxDistance: number;\r\n private _localToWorld: Transform;\r\n /** capture ray and initialize evolving ranges. */\r\n private constructor(ray: Ray3d) {\r\n super();\r\n this._perpVector = Vector3d.createZero();\r\n this._maxDistance = 0.0;\r\n this._localToWorld = ray.toRigidZFrame()!;\r\n }\r\n private _localPoint = Point3d.create();\r\n private _worldPoint = Point3d.create();\r\n private announcePoint(xyz: Point3d) {\r\n this._localToWorld.multiplyInversePoint3d(xyz, this._localPoint);\r\n const distance = this._localPoint.magnitudeXY();\r\n if (distance >= this._maxDistance) {\r\n this._maxDistance = distance;\r\n this._perpVector.setFromPoint3d(this._localPoint);\r\n this._perpVector.z = 0.0;\r\n this._localToWorld.matrix.multiplyXY(this._localPoint.x, this._localPoint.y, this._perpVector);\r\n }\r\n }\r\n\r\n public override handleLineSegment3d(segment0: LineSegment3d) {\r\n this.announcePoint(segment0.startPoint(this._worldPoint));\r\n this.announcePoint(segment0.endPoint(this._worldPoint));\r\n }\r\n public override handleLineString3d(ls0: LineString3d) {\r\n for (let i = 0; i < ls0.numPoints(); i++) {\r\n ls0.pointAt(i, this._worldPoint);\r\n this.announcePoint(this._worldPoint);\r\n }\r\n }\r\n\r\n public override handleArc3d(arc0: Arc3d): any {\r\n // humbug .. just stroke it ..\r\n // exact solution is:\r\n // project the arc to the z=0 plane of the local system.\r\n // find max distance to origin.\r\n const numStroke = StrokeOptions.applyAngleTol(undefined, 3, arc0.sweep.sweepRadians, 0.1);\r\n const df = 1.0 / numStroke;\r\n for (let i = 0; i <= numStroke; i++) {\r\n arc0.fractionToPoint(i * df, this._worldPoint);\r\n this.announcePoint(this._worldPoint);\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Compute the largest vector perpendicular to a ray and ending on the geometry.\r\n * @param geometry0 geometry to search\r\n * @returns vector from ray to geometry.\r\n */\r\n public static computeMaxVectorFromRay(ray: Ray3d, geometry: GeometryQuery): Vector3d {\r\n const accumulator = new CylindricalRangeQuery(ray);\r\n geometry.dispatchToGeometryHandler(accumulator);\r\n return accumulator._perpVector.clone();\r\n }\r\n\r\n /**\r\n * Recurse through geometry.children to find linestrings.\r\n * In each linestring, compute the surface normal annotation from\r\n * * the curve tangent stored in the linestring\r\n * * the axis of rotation\r\n * * a default V vector to be used when the linestring point is close to the axis.\r\n * @param geometry\r\n * @param axis\r\n * @param defaultVectorV\r\n */\r\n public static buildRotationalNormalsInLineStrings(geometry: AnyCurve, axis: Ray3d, defaultVectorFromAxis: Vector3d) {\r\n if (geometry instanceof LineString3d) {\r\n const points = geometry.packedPoints;\r\n const derivatives = geometry.packedDerivatives;\r\n const normals = geometry.ensureEmptySurfaceNormals();\r\n if (derivatives && normals) {\r\n const vectorU = Vector3d.create();\r\n const vectorV = Vector3d.create(); // v direction (forwward along sweep) for surface of rotation.\r\n const xyz = Point3d.create();\r\n const n = points.length;\r\n for (let i = 0; i < n; i++) {\r\n points.getPoint3dAtUncheckedPointIndex(i, xyz);\r\n axis.perpendicularPartOfVectorToTarget(xyz, vectorU);\r\n if (vectorU.isAlmostZero)\r\n axis.direction.crossProduct(defaultVectorFromAxis, vectorV);\r\n else\r\n axis.direction.crossProduct(vectorU, vectorV);\r\n geometry.packedDerivatives.getVector3dAtCheckedVectorIndex(i, vectorU); // reuse vector U as curve derivative\r\n vectorU.crossProduct(vectorV, vectorV); // reuse vector V as normal!\r\n vectorV.normalizeInPlace();\r\n normals.push(vectorV);\r\n }\r\n }\r\n } else if (geometry.children) {\r\n const children = geometry.children;\r\n for (const child of children) {\r\n this.buildRotationalNormalsInLineStrings(child as AnyCurve, axis, defaultVectorFromAxis);\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"CylindricalRange.js","sourceRoot":"","sources":["../../../../src/curve/Query/CylindricalRange.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,sEAAkF;AAClF,sEAAqE;AAOrE,kDAA+C;AAC/C,oDAAiD;AAEjD;;;GAGG;AACH,MAAa,qBAAsB,SAAQ,gDAA8B;IAKvE,kDAAkD;IAClD,YAAoB,GAAU;QAC5B,KAAK,EAAE,CAAC;QAKF,gBAAW,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;QAC/B,gBAAW,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;QALrC,IAAI,CAAC,WAAW,GAAG,0BAAQ,CAAC,UAAU,EAAE,CAAC;QACzC,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC;QACxB,IAAI,CAAC,aAAa,GAAG,GAAG,CAAC,aAAa,EAAE,CAAC;IAC3C,CAAC;IAGO,aAAa,CAAC,GAAY;QAChC,IAAI,CAAC,aAAa,CAAC,sBAAsB,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACjE,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;QAChD,IAAI,QAAQ,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAClC,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC;YAC7B,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAClD,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,GAAG,CAAC;YACzB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACjG,CAAC;IACH,CAAC;IAEe,mBAAm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B,EAAE,CAAC;oBAC3B,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;aAAM,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAC7B,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;YACnC,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;gBAC7B,IAAI,CAAC,mCAAmC,CAAC,KAAiB,EAAE,IAAI,EAAE,qBAAqB,CAAC,CAAC;YAC3F,CAAC;QACH,CAAC;IACH,CAAC;CACF;AArGD,sDAqGC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { RecurseToCurvesGeometryHandler } from \"../../geometry3d/GeometryHandler\";\r\nimport { Point3d, Vector3d } from \"../../geometry3d/Point3dVector3d\";\r\nimport { Ray3d } from \"../../geometry3d/Ray3d\";\r\nimport { Transform } from \"../../geometry3d/Transform\";\r\nimport { Arc3d } from \"../Arc3d\";\r\nimport { AnyCurve } from \"../CurveTypes\";\r\nimport { GeometryQuery } from \"../GeometryQuery\";\r\nimport { LineSegment3d } from \"../LineSegment3d\";\r\nimport { LineString3d } from \"../LineString3d\";\r\nimport { StrokeOptions } from \"../StrokeOptions\";\r\n\r\n/**\r\n * Context for computing geometry range around an axis.\r\n * * The publicly called method is `computeZRRange (ray, geometry)\r\n */\r\nexport class CylindricalRangeQuery extends RecurseToCurvesGeometryHandler {\r\n // private geometry0: GeometryQuery; <-- Never used\r\n private _perpVector: Vector3d;\r\n private _maxDistance: number;\r\n private _localToWorld: Transform;\r\n /** capture ray and initialize evolving ranges. */\r\n private constructor(ray: Ray3d) {\r\n super();\r\n this._perpVector = Vector3d.createZero();\r\n this._maxDistance = 0.0;\r\n this._localToWorld = ray.toRigidZFrame();\r\n }\r\n private _localPoint = Point3d.create();\r\n private _worldPoint = Point3d.create();\r\n private announcePoint(xyz: Point3d) {\r\n this._localToWorld.multiplyInversePoint3d(xyz, this._localPoint);\r\n const distance = this._localPoint.magnitudeXY();\r\n if (distance >= this._maxDistance) {\r\n this._maxDistance = distance;\r\n this._perpVector.setFromPoint3d(this._localPoint);\r\n this._perpVector.z = 0.0;\r\n this._localToWorld.matrix.multiplyXY(this._localPoint.x, this._localPoint.y, this._perpVector);\r\n }\r\n }\r\n\r\n public override handleLineSegment3d(segment0: LineSegment3d) {\r\n this.announcePoint(segment0.startPoint(this._worldPoint));\r\n this.announcePoint(segment0.endPoint(this._worldPoint));\r\n }\r\n public override handleLineString3d(ls0: LineString3d) {\r\n for (let i = 0; i < ls0.numPoints(); i++) {\r\n ls0.pointAt(i, this._worldPoint);\r\n this.announcePoint(this._worldPoint);\r\n }\r\n }\r\n\r\n public override handleArc3d(arc0: Arc3d): any {\r\n // humbug .. just stroke it ..\r\n // exact solution is:\r\n // project the arc to the z=0 plane of the local system.\r\n // find max distance to origin.\r\n const numStroke = StrokeOptions.applyAngleTol(undefined, 3, arc0.sweep.sweepRadians, 0.1);\r\n const df = 1.0 / numStroke;\r\n for (let i = 0; i <= numStroke; i++) {\r\n arc0.fractionToPoint(i * df, this._worldPoint);\r\n this.announcePoint(this._worldPoint);\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Compute the largest vector perpendicular to a ray and ending on the geometry.\r\n * @param geometry0 geometry to search\r\n * @returns vector from ray to geometry.\r\n */\r\n public static computeMaxVectorFromRay(ray: Ray3d, geometry: GeometryQuery): Vector3d {\r\n const accumulator = new CylindricalRangeQuery(ray);\r\n geometry.dispatchToGeometryHandler(accumulator);\r\n return accumulator._perpVector.clone();\r\n }\r\n\r\n /**\r\n * Recurse through geometry.children to find linestrings.\r\n * In each linestring, compute the surface normal annotation from\r\n * * the curve tangent stored in the linestring\r\n * * the axis of rotation\r\n * * a default V vector to be used when the linestring point is close to the axis.\r\n * @param geometry\r\n * @param axis\r\n * @param defaultVectorV\r\n */\r\n public static buildRotationalNormalsInLineStrings(geometry: AnyCurve, axis: Ray3d, defaultVectorFromAxis: Vector3d) {\r\n if (geometry instanceof LineString3d) {\r\n const points = geometry.packedPoints;\r\n const derivatives = geometry.packedDerivatives;\r\n const normals = geometry.ensureEmptySurfaceNormals();\r\n if (derivatives && normals) {\r\n const vectorU = Vector3d.create();\r\n const vectorV = Vector3d.create(); // v direction (forwward along sweep) for surface of rotation.\r\n const xyz = Point3d.create();\r\n const n = points.length;\r\n for (let i = 0; i < n; i++) {\r\n points.getPoint3dAtUncheckedPointIndex(i, xyz);\r\n axis.perpendicularPartOfVectorToTarget(xyz, vectorU);\r\n if (vectorU.isAlmostZero)\r\n axis.direction.crossProduct(defaultVectorFromAxis, vectorV);\r\n else\r\n axis.direction.crossProduct(vectorU, vectorV);\r\n geometry.packedDerivatives.getVector3dAtCheckedVectorIndex(i, vectorU); // reuse vector U as curve derivative\r\n vectorU.crossProduct(vectorV, vectorV); // reuse vector V as normal!\r\n vectorV.normalizeInPlace();\r\n normals.push(vectorV);\r\n }\r\n }\r\n } else if (geometry.children) {\r\n const children = geometry.children;\r\n for (const child of children) {\r\n this.buildRotationalNormalsInLineStrings(child as AnyCurve, axis, defaultVectorFromAxis);\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -6,7 +6,7 @@ import { StrokeOptions } from "../StrokeOptions";
6
6
  * Manage a growing array of arrays of curve primitives that are to be joined "head to tail" in paths.
7
7
  * * The caller makes a sequence of calls to announce individual primitives.
8
8
  * * This collector (unlike the simpler [[ChainCollectorContext]]) expects to have inputs arriving in random order, leaving multiple open chains in play at any time.
9
- * * When all curves have been announced, the call to `grabResults` restructures the various active chains into Paths (and optionally, Loops).
9
+ * * When all curves have been announced, the call to `grabResult` restructures the various active chains into Paths (and optionally, Loops).
10
10
  * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.
11
11
  * * Usage pattern is
12
12
  * * initialization: `context = new MultiChainCollector(gapTol, planeTol)`
@@ -17,13 +17,13 @@ import { StrokeOptions } from "../StrokeOptions";
17
17
  * @internal
18
18
  */
19
19
  export declare class MultiChainCollector {
20
- /** accumulated chains */
20
+ /** Accumulated chains. */
21
21
  private _chains;
22
- /** largest gap distance to close */
22
+ /** Largest gap distance to close. */
23
23
  private _gapTolerance;
24
- /** end point snap tolerance (assumed to be as tight or tighter than gapTolerance) */
24
+ /** End point snap tolerance (assumed to be as tight or tighter than gapTolerance). */
25
25
  private _snapTolerance;
26
- /** tolerance for choosing Path or Loop. If undefined, always Path. */
26
+ /** Planarity tolerance, used to determine whether to return a Path or Loop in `grabResult(true)`. If undefined, always Path. */
27
27
  private _planeTolerance;
28
28
  private static _staticPointA;
29
29
  private static _staticPointB;
@@ -33,7 +33,7 @@ export declare class MultiChainCollector {
33
33
  * @param gapTolerance tolerance for calling endpoints identical
34
34
  * @param planeTolerance tolerance for considering a closed chain to be planar. If undefined, only create Path. If defined, create Loops for closed chains within tolerance of a plane.
35
35
  */
36
- constructor(gapTolerance?: number, planeTolerance?: number | undefined);
36
+ constructor(gapTolerance?: number, planeTolerance?: number);
37
37
  /**
38
38
  * Find a chain (with index _other than_ exceptChainIndex) that starts or ends at xyz
39
39
  * @param xyz endpoint to check
@@ -88,7 +88,7 @@ export declare class MultiChainCollector {
88
88
  /**
89
89
  * Convert an array of curve primitives into the simplest possible strongly typed curve structure.
90
90
  * @param curves input array, assembled correctly into a single contiguous path, captured by returned object
91
- * @param makeLoopIfClosed whether to return a Loop from physically closed curves array, otherwise Path
91
+ * @param makeLoopIfClosed whether to return a Loop from physically closed coplanar curves, otherwise Path
92
92
  * @return Loop or Path if multiple curves; the primitive if only one curve; undefined if no curves
93
93
  */
94
94
  private promoteArrayToCurves;
@@ -96,7 +96,10 @@ export declare class MultiChainCollector {
96
96
  private chainToLineString3d;
97
97
  /** Return the collected results, structured as the simplest possible type. */
98
98
  grabResult(makeLoopIfClosed?: boolean): AnyChain | undefined;
99
- /** Return chains as individual calls to announceChain. */
99
+ /**
100
+ * Return chains as individual calls to announceChain.
101
+ * * Does not use planeTolerance.
102
+ */
100
103
  announceChainsAsLineString3d(announceChain: (ls: LineString3d) => void, options?: StrokeOptions): void;
101
104
  }
102
105
  //# sourceMappingURL=MultiChainCollector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MultiChainCollector.d.ts","sourceRoot":"","sources":["../../../../src/curve/internalContexts/MultiChainCollector.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;;;;;;;;;;;;GAaG;AACH,qBAAa,mBAAmB;IAC9B,yBAAyB;IACzB,OAAO,CAAC,OAAO,CAAqB;IACpC,oCAAoC;IACpC,OAAO,CAAC,aAAa,CAAS;IAC9B,qFAAqF;IACrF,OAAO,CAAC,cAAc,CAAS;IAC/B,sEAAsE;IACtE,OAAO,CAAC,eAAe,CAAqB;IAE5C,OAAO,CAAC,MAAM,CAAC,aAAa,CAAU;IACtC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAU;IACtC,OAAO,CAAC,SAAS,CAAC,CAAU;IAC5B,OAAO,CAAC,SAAS,CAAC,CAAU;IAE5B;;;OAGG;gBACgB,YAAY,SAA+B,EAAE,cAAc,GAAE,MAAM,GAAG,SAAwC;IAMjI;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAc7B;;;;;OAKG;IACI,qBAAqB,CAAC,SAAS,EAAE,cAAc;IAStD;;;;;OAKG;IACI,YAAY,CAAC,SAAS,EAAE,QAAQ;IAQvC,yDAAyD;IACzD,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAejC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AE5B;;;OAGG;gBACgB,YAAY,SAA+B,EAAE,cAAc,CAAC,EAAE,MAAM;IAMvF;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAc7B;;;;;OAKG;IACI,qBAAqB,CAAC,SAAS,EAAE,cAAc;IAStD;;;;;OAKG;IACI,YAAY,CAAC,SAAS,EAAE,QAAQ;IAQvC,yDAAyD;IACzD,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAejC;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAiC7B;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IA4CjC;;;;;;;;OAQG;IACH,OAAO,CAAC,yBAAyB;IAYjC,wCAAwC;IACxC,OAAO,CAAC,YAAY;IAMpB,qGAAqG;IACrG,OAAO,CAAC,wBAAwB;IAuBhC;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IA+B5B,wEAAwE;IACxE,OAAO,CAAC,mBAAmB;IAS3B,8EAA8E;IACvE,UAAU,CAAC,gBAAgB,GAAE,OAAe,GAAG,QAAQ,GAAG,SAAS;IAa1E;;;MAGE;IACK,4BAA4B,CAAC,aAAa,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI;CAc9G"}
@@ -23,7 +23,7 @@ const RegionOps_1 = require("../RegionOps");
23
23
  * Manage a growing array of arrays of curve primitives that are to be joined "head to tail" in paths.
24
24
  * * The caller makes a sequence of calls to announce individual primitives.
25
25
  * * This collector (unlike the simpler [[ChainCollectorContext]]) expects to have inputs arriving in random order, leaving multiple open chains in play at any time.
26
- * * When all curves have been announced, the call to `grabResults` restructures the various active chains into Paths (and optionally, Loops).
26
+ * * When all curves have been announced, the call to `grabResult` restructures the various active chains into Paths (and optionally, Loops).
27
27
  * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.
28
28
  * * Usage pattern is
29
29
  * * initialization: `context = new MultiChainCollector(gapTol, planeTol)`
@@ -38,7 +38,7 @@ class MultiChainCollector {
38
38
  * @param gapTolerance tolerance for calling endpoints identical
39
39
  * @param planeTolerance tolerance for considering a closed chain to be planar. If undefined, only create Path. If defined, create Loops for closed chains within tolerance of a plane.
40
40
  */
41
- constructor(gapTolerance = Geometry_1.Geometry.smallMetricDistance, planeTolerance = Geometry_1.Geometry.smallMetricDistance) {
41
+ constructor(gapTolerance = Geometry_1.Geometry.smallMetricDistance, planeTolerance) {
42
42
  this._chains = [];
43
43
  this._gapTolerance = gapTolerance;
44
44
  this._snapTolerance = Geometry_1.Geometry.smallMetricDistance;
@@ -258,7 +258,7 @@ class MultiChainCollector {
258
258
  /**
259
259
  * Convert an array of curve primitives into the simplest possible strongly typed curve structure.
260
260
  * @param curves input array, assembled correctly into a single contiguous path, captured by returned object
261
- * @param makeLoopIfClosed whether to return a Loop from physically closed curves array, otherwise Path
261
+ * @param makeLoopIfClosed whether to return a Loop from physically closed coplanar curves, otherwise Path
262
262
  * @return Loop or Path if multiple curves; the primitive if only one curve; undefined if no curves
263
263
  */
264
264
  promoteArrayToCurves(curves, makeLoopIfClosed) {
@@ -316,7 +316,10 @@ class MultiChainCollector {
316
316
  }
317
317
  return bag;
318
318
  }
319
- /** Return chains as individual calls to announceChain. */
319
+ /**
320
+ * Return chains as individual calls to announceChain.
321
+ * * Does not use planeTolerance.
322
+ */
320
323
  announceChainsAsLineString3d(announceChain, options) {
321
324
  const chains = this._chains;
322
325
  if (chains.length === 1) {