@itwin/core-geometry 4.2.0-dev.16 → 4.2.0-dev.18

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 (166) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/lib/cjs/clipping/ClipUtils.d.ts +1 -1
  3. package/lib/cjs/clipping/ClipUtils.js.map +1 -1
  4. package/lib/cjs/core-geometry.d.ts +1 -1
  5. package/lib/cjs/core-geometry.js +1 -1
  6. package/lib/cjs/core-geometry.js.map +1 -1
  7. package/lib/cjs/curve/Arc3d.js +4 -4
  8. package/lib/cjs/curve/Arc3d.js.map +1 -1
  9. package/lib/cjs/curve/CurveCollection.d.ts +2 -15
  10. package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
  11. package/lib/cjs/curve/CurveCollection.js +1 -18
  12. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  13. package/lib/cjs/curve/CurveCurve.d.ts +4 -1
  14. package/lib/cjs/curve/CurveCurve.d.ts.map +1 -1
  15. package/lib/cjs/curve/CurveCurve.js +3 -0
  16. package/lib/cjs/curve/CurveCurve.js.map +1 -1
  17. package/lib/cjs/curve/CurveFactory.d.ts +1 -1
  18. package/lib/cjs/curve/CurveFactory.js.map +1 -1
  19. package/lib/cjs/curve/CurveOps.d.ts +1 -1
  20. package/lib/cjs/curve/CurveOps.js.map +1 -1
  21. package/lib/cjs/curve/CurveProcessor.d.ts +1 -1
  22. package/lib/cjs/curve/CurveProcessor.js.map +1 -1
  23. package/lib/cjs/curve/{CurveChain.d.ts → CurveTypes.d.ts} +6 -6
  24. package/lib/cjs/curve/CurveTypes.d.ts.map +1 -0
  25. package/lib/cjs/curve/{CurveChain.js → CurveTypes.js} +1 -1
  26. package/lib/cjs/curve/CurveTypes.js.map +1 -0
  27. package/lib/cjs/curve/CurveWireMomentsXYZ.d.ts +1 -1
  28. package/lib/cjs/curve/CurveWireMomentsXYZ.js.map +1 -1
  29. package/lib/cjs/curve/ParityRegion.d.ts +1 -1
  30. package/lib/cjs/curve/ParityRegion.js.map +1 -1
  31. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts +3 -2
  32. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
  33. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js +2 -2
  34. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
  35. package/lib/cjs/curve/Query/CurveSplitContext.d.ts +1 -1
  36. package/lib/cjs/curve/Query/CurveSplitContext.js.map +1 -1
  37. package/lib/cjs/curve/Query/CylindricalRange.d.ts +1 -1
  38. package/lib/cjs/curve/Query/CylindricalRange.js.map +1 -1
  39. package/lib/cjs/curve/Query/InOutTests.d.ts +1 -1
  40. package/lib/cjs/curve/Query/InOutTests.js.map +1 -1
  41. package/lib/cjs/curve/Query/StrokeCountChain.d.ts +1 -1
  42. package/lib/cjs/curve/Query/StrokeCountChain.js.map +1 -1
  43. package/lib/cjs/curve/RegionOps.d.ts +16 -2
  44. package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
  45. package/lib/cjs/curve/RegionOps.js +18 -1
  46. package/lib/cjs/curve/RegionOps.js.map +1 -1
  47. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +1 -1
  48. package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
  49. package/lib/cjs/curve/UnionRegion.d.ts +1 -1
  50. package/lib/cjs/curve/UnionRegion.js.map +1 -1
  51. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +19 -10
  52. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
  53. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +69 -62
  54. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  55. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -1
  56. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  57. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts +1 -1
  58. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
  59. package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts +1 -1
  60. package/lib/cjs/curve/internalContexts/MultiChainCollector.js.map +1 -1
  61. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  62. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  63. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +0 -1
  64. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  65. package/lib/cjs/geometry3d/Point3dVector3d.js +0 -1
  66. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  67. package/lib/cjs/geometry3d/SortablePolygon.d.ts +1 -1
  68. package/lib/cjs/geometry3d/SortablePolygon.js.map +1 -1
  69. package/lib/cjs/geometry3d/YawPitchRollAngles.js +1 -1
  70. package/lib/cjs/geometry3d/YawPitchRollAngles.js.map +1 -1
  71. package/lib/cjs/polyface/PolyfaceBuilder.d.ts +1 -1
  72. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  73. package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
  74. package/lib/cjs/solid/LinearSweep.d.ts +1 -1
  75. package/lib/cjs/solid/LinearSweep.js.map +1 -1
  76. package/lib/cjs/solid/RotationalSweep.d.ts +1 -1
  77. package/lib/cjs/solid/RotationalSweep.js.map +1 -1
  78. package/lib/cjs/solid/RuledSweep.d.ts +1 -1
  79. package/lib/cjs/solid/RuledSweep.js.map +1 -1
  80. package/lib/cjs/solid/SweepContour.d.ts +1 -1
  81. package/lib/cjs/solid/SweepContour.js.map +1 -1
  82. package/lib/esm/clipping/ClipUtils.d.ts +1 -1
  83. package/lib/esm/clipping/ClipUtils.js.map +1 -1
  84. package/lib/esm/core-geometry.d.ts +1 -1
  85. package/lib/esm/core-geometry.js +1 -1
  86. package/lib/esm/core-geometry.js.map +1 -1
  87. package/lib/esm/curve/Arc3d.js +4 -4
  88. package/lib/esm/curve/Arc3d.js.map +1 -1
  89. package/lib/esm/curve/CurveCollection.d.ts +2 -15
  90. package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
  91. package/lib/esm/curve/CurveCollection.js +0 -16
  92. package/lib/esm/curve/CurveCollection.js.map +1 -1
  93. package/lib/esm/curve/CurveCurve.d.ts +4 -1
  94. package/lib/esm/curve/CurveCurve.d.ts.map +1 -1
  95. package/lib/esm/curve/CurveCurve.js +3 -0
  96. package/lib/esm/curve/CurveCurve.js.map +1 -1
  97. package/lib/esm/curve/CurveFactory.d.ts +1 -1
  98. package/lib/esm/curve/CurveFactory.js.map +1 -1
  99. package/lib/esm/curve/CurveOps.d.ts +1 -1
  100. package/lib/esm/curve/CurveOps.js.map +1 -1
  101. package/lib/esm/curve/CurveProcessor.d.ts +1 -1
  102. package/lib/esm/curve/CurveProcessor.js.map +1 -1
  103. package/lib/esm/curve/{CurveChain.d.ts → CurveTypes.d.ts} +6 -6
  104. package/lib/esm/curve/CurveTypes.d.ts.map +1 -0
  105. package/lib/esm/curve/{CurveChain.js → CurveTypes.js} +1 -1
  106. package/lib/esm/curve/CurveTypes.js.map +1 -0
  107. package/lib/esm/curve/CurveWireMomentsXYZ.d.ts +1 -1
  108. package/lib/esm/curve/CurveWireMomentsXYZ.js.map +1 -1
  109. package/lib/esm/curve/ParityRegion.d.ts +1 -1
  110. package/lib/esm/curve/ParityRegion.js.map +1 -1
  111. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts +3 -2
  112. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
  113. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js +1 -1
  114. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
  115. package/lib/esm/curve/Query/CurveSplitContext.d.ts +1 -1
  116. package/lib/esm/curve/Query/CurveSplitContext.js.map +1 -1
  117. package/lib/esm/curve/Query/CylindricalRange.d.ts +1 -1
  118. package/lib/esm/curve/Query/CylindricalRange.js.map +1 -1
  119. package/lib/esm/curve/Query/InOutTests.d.ts +1 -1
  120. package/lib/esm/curve/Query/InOutTests.js.map +1 -1
  121. package/lib/esm/curve/Query/StrokeCountChain.d.ts +1 -1
  122. package/lib/esm/curve/Query/StrokeCountChain.js.map +1 -1
  123. package/lib/esm/curve/RegionOps.d.ts +16 -2
  124. package/lib/esm/curve/RegionOps.d.ts.map +1 -1
  125. package/lib/esm/curve/RegionOps.js +16 -0
  126. package/lib/esm/curve/RegionOps.js.map +1 -1
  127. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +1 -1
  128. package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
  129. package/lib/esm/curve/UnionRegion.d.ts +1 -1
  130. package/lib/esm/curve/UnionRegion.js.map +1 -1
  131. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +19 -10
  132. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
  133. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +70 -63
  134. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  135. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -1
  136. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  137. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts +1 -1
  138. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
  139. package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts +1 -1
  140. package/lib/esm/curve/internalContexts/MultiChainCollector.js.map +1 -1
  141. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  142. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  143. package/lib/esm/geometry3d/Point3dVector3d.d.ts +0 -1
  144. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  145. package/lib/esm/geometry3d/Point3dVector3d.js +0 -1
  146. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  147. package/lib/esm/geometry3d/SortablePolygon.d.ts +1 -1
  148. package/lib/esm/geometry3d/SortablePolygon.js.map +1 -1
  149. package/lib/esm/geometry3d/YawPitchRollAngles.js +1 -1
  150. package/lib/esm/geometry3d/YawPitchRollAngles.js.map +1 -1
  151. package/lib/esm/polyface/PolyfaceBuilder.d.ts +1 -1
  152. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  153. package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
  154. package/lib/esm/solid/LinearSweep.d.ts +1 -1
  155. package/lib/esm/solid/LinearSweep.js.map +1 -1
  156. package/lib/esm/solid/RotationalSweep.d.ts +1 -1
  157. package/lib/esm/solid/RotationalSweep.js.map +1 -1
  158. package/lib/esm/solid/RuledSweep.d.ts +1 -1
  159. package/lib/esm/solid/RuledSweep.js.map +1 -1
  160. package/lib/esm/solid/SweepContour.d.ts +1 -1
  161. package/lib/esm/solid/SweepContour.js.map +1 -1
  162. package/package.json +3 -3
  163. package/lib/cjs/curve/CurveChain.d.ts.map +0 -1
  164. package/lib/cjs/curve/CurveChain.js.map +0 -1
  165. package/lib/esm/curve/CurveChain.d.ts.map +0 -1
  166. package/lib/esm/curve/CurveChain.js.map +0 -1
@@ -260,7 +260,7 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
260
260
  fractionB = 1;
261
261
  this._workPointB = pointB0.interpolate(fractionB, pointB1, this._workPointB);
262
262
  const distanceSquared = this._workPointB.distanceSquaredXY(pointA);
263
- if (distanceSquared < Math.min(maxDistanceSquared, closestApproach.detailA.a)) {
263
+ if (distanceSquared <= Math.min(maxDistanceSquared, closestApproach.detailA.a)) {
264
264
  closestApproach.detailA.setFP(fractionA, pointA, undefined, distanceSquared);
265
265
  closestApproach.detailB.setFP(fractionB, this._workPointB, undefined, distanceSquared);
266
266
  updated = true;
@@ -303,23 +303,23 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
303
303
  closestApproach.detailA.a = 2 * maxDistanceSquared; // init to an approach that's too far away
304
304
  let reversed = false;
305
305
  const uu = Geometry_1.Geometry.hypotenuseSquaredXY(ux, uy);
306
- if (hab0 * hab0 < maxDistanceSquared * uu) { // test distance of b0 to u
306
+ if (hab0 * hab0 <= maxDistanceSquared * uu) { // test distance of b0 to u
307
307
  const fractionA = Geometry_1.Geometry.dotProductXYXY(ux, uy, e00x, e00y) / uu;
308
308
  if (this.updatePointToSegmentDistance(0, b0, a0, a1, fractionA, maxDistanceSquared, closestApproach))
309
309
  reversed = true;
310
310
  }
311
- if (hab1 * hab1 < maxDistanceSquared * uu) { // test distance of b1 to u
311
+ if (hab1 * hab1 <= maxDistanceSquared * uu) { // test distance of b1 to u
312
312
  const fractionA = Geometry_1.Geometry.dotProductXYXY(ux, uy, e01x, e01y) / uu;
313
313
  if (this.updatePointToSegmentDistance(1, b1, a0, a1, fractionA, maxDistanceSquared, closestApproach))
314
314
  reversed = true;
315
315
  }
316
316
  const vv = Geometry_1.Geometry.hypotenuseSquaredXY(vx, vy);
317
- if (hba0 * hba0 < maxDistanceSquared * vv) { // test distance of a0 to v
317
+ if (hba0 * hba0 <= maxDistanceSquared * vv) { // test distance of a0 to v
318
318
  const fractionB = -Geometry_1.Geometry.dotProductXYXY(vx, vy, e00x, e00y) / vv;
319
319
  if (this.updatePointToSegmentDistance(0, a0, b0, b1, fractionB, maxDistanceSquared, closestApproach))
320
320
  reversed = false;
321
321
  }
322
- if (hba1 * hba1 < maxDistanceSquared * vv) { // test distance of a1 to v
322
+ if (hba1 * hba1 <= maxDistanceSquared * vv) { // test distance of a1 to v
323
323
  const fractionB = -Geometry_1.Geometry.dotProductXYXY(vx, vy, e10x, e10y) / vv;
324
324
  if (this.updatePointToSegmentDistance(1, a1, b0, b1, fractionB, maxDistanceSquared, closestApproach))
325
325
  reversed = false;
@@ -397,10 +397,10 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
397
397
  * Low level dispatch of segment with arc.
398
398
  * Find close approaches within maxDistance between a line segments (pointA0, pointA1) and an arc.
399
399
  * To consider:
400
- * 1) arc endpoints to segment endpoints or arc endpoints projection to the segment.
401
- * 2) intersection between arc and segment.
400
+ * 1) intersection between arc and segment.
401
+ * 2) arc endpoints to segment endpoints or arc endpoints projection to the segment.
402
402
  * 3) line parallel to arc tangent.
403
- * @param cpA the segment
403
+ * @param cpA curve A (line segment or line string)
404
404
  * @param pointA0 start point of the segment
405
405
  * @param fractionA0 fraction of the start of the segment
406
406
  * @param pointA1 end point of the segment
@@ -409,9 +409,7 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
409
409
  * @param reversed true to have order reversed in final structures
410
410
  */
411
411
  dispatchSegmentArc(cpA, pointA0, fractionA0, pointA1, fractionA1, arc, reversed) {
412
- // 1) arc endpoints to segment endpoints or arc endpoints projection to the segment
413
- this.testAndRecordFractionalPairApproach(cpA, 0, 1, true, arc, 0, 1, false, reversed);
414
- // 2) intersection between arc and segment
412
+ // 1) intersection between arc and segment
415
413
  // Suppose:
416
414
  // Arc: X = C + cU + sV where c = cos(theta) and s = sin(theta)
417
415
  // Line: contains points A0 and A1
@@ -420,6 +418,7 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
420
418
  // solve for theta.
421
419
  // evaluate points.
422
420
  // project back to line.
421
+ let intersectionFound = false;
423
422
  const data = arc.toTransformedVectors();
424
423
  const pointA0Local = pointA0;
425
424
  const pointA1Local = pointA1;
@@ -438,8 +437,13 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
438
437
  // only add if the point is within the start and end fractions of both line segment and arc
439
438
  if (lineFraction !== undefined && this.acceptFraction(lineFraction) && this.acceptFraction(arcFraction)) {
440
439
  this.recordPointWithLocalFractions(lineFraction, cpA, fractionA0, fractionA1, arcFraction, arc, 0, 1, reversed);
440
+ intersectionFound = true;
441
441
  }
442
442
  }
443
+ if (intersectionFound)
444
+ return;
445
+ // 2) endpoints to endpoints or endpoints projection to the other curve
446
+ this.testAndRecordFractionalPairApproach(cpA, fractionA0, fractionA1, true, arc, 0, 1, false, reversed);
443
447
  // 3) line parallel to arc tangent.
444
448
  // If line does not intersect the arc, then the closest (and/or the furthest) point on arc to the line is a
445
449
  // point where the tangent line on arc at that point is parallel to the line.
@@ -456,48 +460,37 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
456
460
  }
457
461
  }
458
462
  }
459
- // Caller accesses data from two arcs, ensures circular, and orders with radiusA >= radiusB
463
+ /** Low level dispatch of circular arc with circular arc. radiusA must be larger than or equal to radiusB. */
460
464
  dispatchCircularCircularOrdered(cpA, radiusA, cpB, radiusB, reversed) {
461
465
  const c = cpA.center.distance(cpB.center);
462
466
  const e = this._maxDistanceToAccept !== undefined ? this._maxDistanceToAccept : Geometry_1.Geometry.smallMetricDistance;
463
- if (c > radiusA + radiusB + e) // widely separated
467
+ if (c > radiusA + radiusB + e) // distance between circles is more than max distance
464
468
  return;
465
- // To consider:
466
- // 1) endpoint to endpoint or projection
467
- // 2) true intersection
468
- // 3) line parallel to arc tangent.
469
+ // TODO: 1) intersection between arcs
470
+ // 2) endpoints to endpoints
469
471
  this.testAndRecordFractionalPairApproach(cpA, 0, 1, false, cpB, 0, 1, false, reversed);
472
+ // 3) line from one arc to another (perpendicular to arc tangents along center-center line)
470
473
  if (!Geometry_1.Geometry.isSmallMetricDistance(c)) {
471
- // ?? endpoint hits are recorded. Maybe also need overlap?
472
474
  const vectorAB = Point3dVector3d_1.Vector3d.createStartEnd(cpA.center, cpB.center);
473
475
  vectorAB.scaleInPlace(1.0 / c);
474
- if (c - radiusA - radiusB > e) {
475
- // no approaches possible
476
- }
477
- else {
478
- for (const rA of [-radiusA, radiusA]) {
479
- for (const rB of [-radiusB, radiusB]) {
480
- const tangentDistance = c - rA + rB;
481
- if (tangentDistance < e) {
482
- const detailA = this.resolveDirectionToArcXYFraction(cpA, vectorAB, rA);
483
- if (detailA) {
484
- const detailB = this.resolveDirectionToArcXYFraction(cpB, vectorAB, rB);
485
- if (detailB) {
486
- this.captureDetailPair(detailA, detailB, reversed);
487
- }
488
- }
476
+ for (const rA of [-radiusA, radiusA]) {
477
+ for (const rB of [-radiusB, radiusB]) {
478
+ const tangentDistance = c - rA + rB;
479
+ if (tangentDistance < e) {
480
+ const detailA = this.resolveDirectionToArcXYFraction(cpA, vectorAB, rA);
481
+ if (detailA) {
482
+ const detailB = this.resolveDirectionToArcXYFraction(cpB, vectorAB, rB);
483
+ if (detailB)
484
+ this.captureDetailPair(detailA, detailB, reversed);
489
485
  }
490
486
  }
491
487
  }
492
488
  }
493
489
  }
494
490
  }
495
- /**
496
- * Find the fractional point (if any) on an arc, known to be circular and displayed from the center in the
497
- * direction of a scaled vector.
498
- */
491
+ /** Find the fractional point (if any) on the circular `arc` in the direction of `radialVector`. */
499
492
  resolveDirectionToArcXYFraction(arc, radialVector, scale) {
500
- // The scale ultimately only affects the direction --- easiest way to use it is two multiplies
493
+ // The scale ultimately only affects the direction --- easiest way to use it is two multiplies.
501
494
  const c = scale * arc.matrixRef.columnDotXYZ(0, radialVector.x, radialVector.y, 0);
502
495
  const s = scale * arc.matrixRef.columnDotXYZ(1, radialVector.x, radialVector.y, 0);
503
496
  const radians = Math.atan2(s, c);
@@ -506,10 +499,13 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
506
499
  return CurveLocationDetail_1.CurveLocationDetail.createCurveEvaluatedFraction(arc, fraction);
507
500
  return undefined;
508
501
  }
509
- // Caller accesses data from two arcs.
510
- // Selects the best conditioned arc (in xy parts) as "circle after inversion"
511
- // Solves the arc-arc equations
502
+ /** Low level dispatch of arc with arc. Only circular arcs are supported. */
512
503
  dispatchArcArc(cpA, cpB, reversed) {
504
+ const rangeA = cpA.range();
505
+ const rangeB = cpB.range();
506
+ rangeA.expandInPlace(this._maxDistanceToAccept);
507
+ if (!rangeB.intersectsRangeXY(rangeA))
508
+ return;
513
509
  if (this._circularArcB) {
514
510
  const radiusB = this._circularRadiusB;
515
511
  const radiusA = cpA.circularRadiusXY();
@@ -522,17 +518,13 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
522
518
  }
523
519
  }
524
520
  }
525
- // Caller accesses data from two arcs.
526
- // Selects the best conditioned arc (in xy parts) as "circle after inversion"
527
- // Solves the arc-arc equations
521
+ /** Low level dispatch of arc with (beziers of) a bspline curve */
528
522
  dispatchArcBsplineCurve3d(cpA, cpB, reversed) {
529
523
  const ls = LineString3d_1.LineString3d.create();
530
524
  cpB.emitStrokes(ls);
531
525
  this.computeArcLineString(cpA, ls, reversed);
532
526
  }
533
- // Caller accesses data from two arcs.
534
- // Selects the best conditioned arc (in xy parts) as "circle after inversion"
535
- // Solves the arc-arc equations
527
+ /** Low level dispatch of (beziers of) a bspline curve with (beziers of) a bspline curve */
536
528
  dispatchBSplineCurve3dBSplineCurve3d(bcurveA, bcurveB, reversed) {
537
529
  const lsA = LineString3d_1.LineString3d.create();
538
530
  bcurveA.emitStrokes(lsA);
@@ -570,6 +562,11 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
570
562
  }
571
563
  /** Detail computation for arc approaching linestring. */
572
564
  computeArcLineString(arcA, lsB, reversed) {
565
+ const rangeA = arcA.range();
566
+ const rangeB = lsB.range();
567
+ rangeA.expandInPlace(this._maxDistanceToAccept);
568
+ if (!rangeB.intersectsRangeXY(rangeA))
569
+ return;
573
570
  const pointB0 = CurveCurveCloseApproachXY._workPointBB0;
574
571
  const pointB1 = CurveCurveCloseApproachXY._workPointBB1;
575
572
  const numB = lsB.numPoints();
@@ -587,10 +584,10 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
587
584
  }
588
585
  return undefined;
589
586
  }
590
- /** Low level dispatch of curve chain. */
591
- dispatchCurveChain(geomA, geomAHandler) {
587
+ /** Low level dispatch of curve collection. */
588
+ dispatchCurveCollection(geomA, geomAHandler) {
592
589
  const geomB = this._geometryB; // save
593
- if (!geomB || !(geomB instanceof CurveCollection_1.CurveChain))
590
+ if (!geomB || !geomB.children || !(geomB instanceof CurveCollection_1.CurveCollection))
594
591
  return;
595
592
  for (const child of geomB.children) {
596
593
  this.resetGeometry(child);
@@ -613,9 +610,10 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
613
610
  else if (this._geometryB instanceof BSplineCurve_1.BSplineCurve3d) {
614
611
  this.dispatchSegmentBsplineCurve(segmentA, this._geometryB, false);
615
612
  }
616
- else if (this._geometryB instanceof CurveCollection_1.CurveChain) {
617
- this.dispatchCurveChain(segmentA, this.handleLineSegment3d.bind(this));
613
+ else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
614
+ this.dispatchCurveCollection(segmentA, this.handleLineSegment3d.bind(this));
618
615
  }
616
+ return undefined;
619
617
  }
620
618
  /**
621
619
  * Set bits for comparison to range xy
@@ -623,6 +621,13 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
623
621
  * * bit 0x02 => x larger than range.high.x
624
622
  * * bit 0x04 => y smaller than range.low.y
625
623
  * * bit 0x08 => y larger than range.high.y
624
+ * * If we divide XY plane into 9 areas using the range, the function returns 0 for points
625
+ * inside the range. Below is other binary numbers returned by the function for all 9 areas:
626
+ * 1001 | 1000 | 1010
627
+ * ------------------
628
+ * 1 | 0 | 10
629
+ * ------------------
630
+ * 101 | 100 | 110
626
631
  * @param xy point to test
627
632
  * @param range range for comparison
628
633
  */
@@ -632,12 +637,14 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
632
637
  result = 0x01;
633
638
  else if (x > range.high.x)
634
639
  result = 0x02;
640
+ // note the OR operation
635
641
  if (y < range.low.y)
636
642
  result |= 0x04;
637
643
  else if (y > range.high.y)
638
644
  result |= 0x08;
639
645
  return result;
640
646
  }
647
+ /** Low level dispatch of line string with line string. */
641
648
  computeLineStringLineString(lsA, lsB, reversed) {
642
649
  const rangeA = lsA.range();
643
650
  const rangeB = lsB.range();
@@ -654,7 +661,6 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
654
661
  const numA = lsA.numPoints();
655
662
  const numB = lsB.numPoints();
656
663
  if (numA > 1 && numB > 1) {
657
- lsA.pointAt(0, pointA0);
658
664
  const dfA = 1.0 / (numA - 1);
659
665
  const dfB = 1.0 / (numB - 1);
660
666
  let fA0 = 0.0;
@@ -664,6 +670,7 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
664
670
  fA1 = ia * dfA;
665
671
  fB0 = 0.0;
666
672
  lsA.pointAt(ia, pointA1);
673
+ // rangeA1 is around line segment [A0,A1] expanded by max distance
667
674
  rangeA1.setNull();
668
675
  rangeA1.extendPoint(pointA0);
669
676
  rangeA1.extendPoint(pointA1);
@@ -675,10 +682,10 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
675
682
  lsB.pointAt(ib, pointB1);
676
683
  bitB1 = this.classifyBitsPointRangeXY(pointB1.x, pointB1.y, rangeA1);
677
684
  fB1 = ib * dfB;
678
- // Do NOT study the segment in detail if both bitB bits are on for any of the 4 planes . ..
679
- if ((bitB0 & bitB1) === 0) {
685
+ // DO NOT study the segment in detail if both bitB bits are on for any of the 4 planes
686
+ // (i.e., no intersection between rangeA1 and the range around line segment [B0,B1])
687
+ if ((bitB0 & bitB1) === 0)
680
688
  this.dispatchSegmentSegment(lsA, pointA0, fA0, pointA1, fA1, lsB, pointB0, fB0, pointB1, fB1, reversed);
681
- }
682
689
  }
683
690
  }
684
691
  }
@@ -699,8 +706,8 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
699
706
  else if (this._geometryB instanceof BSplineCurve_1.BSplineCurve3d) {
700
707
  this.dispatchLineStringBSplineCurve(lsA, this._geometryB, false);
701
708
  }
702
- else if (this._geometryB instanceof CurveCollection_1.CurveChain) {
703
- this.dispatchCurveChain(lsA, this.handleLineString3d.bind(this));
709
+ else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
710
+ this.dispatchCurveCollection(lsA, this.handleLineString3d.bind(this));
704
711
  }
705
712
  return undefined;
706
713
  }
@@ -718,8 +725,8 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
718
725
  else if (this._geometryB instanceof BSplineCurve_1.BSplineCurve3d) {
719
726
  this.dispatchArcBsplineCurve3d(arc0, this._geometryB, false);
720
727
  }
721
- else if (this._geometryB instanceof CurveCollection_1.CurveChain) {
722
- this.dispatchCurveChain(arc0, this.handleArc3d.bind(this));
728
+ else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
729
+ this.dispatchCurveCollection(arc0, this.handleArc3d.bind(this));
723
730
  }
724
731
  return undefined;
725
732
  }
@@ -737,8 +744,8 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
737
744
  else if (this._geometryB instanceof BSplineCurve_1.BSplineCurve3dBase) {
738
745
  this.dispatchBSplineCurve3dBSplineCurve3d(curve, this._geometryB, false);
739
746
  }
740
- else if (this._geometryB instanceof CurveCollection_1.CurveChain) {
741
- this.dispatchCurveChain(curve, this.handleBSplineCurve3d.bind(this));
747
+ else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
748
+ this.dispatchCurveCollection(curve, this.handleBSplineCurve3d.bind(this));
742
749
  }
743
750
  return undefined;
744
751
  }