@itwin/core-geometry 5.4.0-dev.7 → 5.5.0-dev.2

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 (94) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/lib/cjs/bspline/SurfaceLocationDetail.d.ts +1 -1
  3. package/lib/cjs/bspline/SurfaceLocationDetail.js +1 -1
  4. package/lib/cjs/bspline/SurfaceLocationDetail.js.map +1 -1
  5. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  6. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  7. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts +13 -0
  8. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  9. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +78 -3
  10. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  11. package/lib/cjs/curve/spiral/AustralianRailCorpXYEvaluator.d.ts +1 -1
  12. package/lib/cjs/curve/spiral/AustralianRailCorpXYEvaluator.js +1 -1
  13. package/lib/cjs/curve/spiral/AustralianRailCorpXYEvaluator.js.map +1 -1
  14. package/lib/cjs/curve/spiral/ClothoidSeries.d.ts +3 -3
  15. package/lib/cjs/curve/spiral/ClothoidSeries.d.ts.map +1 -1
  16. package/lib/cjs/curve/spiral/ClothoidSeries.js +15 -11
  17. package/lib/cjs/curve/spiral/ClothoidSeries.js.map +1 -1
  18. package/lib/cjs/curve/spiral/CzechSpiralEvaluator.d.ts +2 -5
  19. package/lib/cjs/curve/spiral/CzechSpiralEvaluator.d.ts.map +1 -1
  20. package/lib/cjs/curve/spiral/CzechSpiralEvaluator.js +4 -12
  21. package/lib/cjs/curve/spiral/CzechSpiralEvaluator.js.map +1 -1
  22. package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts +7 -6
  23. package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
  24. package/lib/cjs/curve/spiral/DirectSpiral3d.js +8 -6
  25. package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
  26. package/lib/cjs/curve/spiral/IntegratedSpiral3d.d.ts +2 -2
  27. package/lib/cjs/curve/spiral/IntegratedSpiral3d.d.ts.map +1 -1
  28. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js +9 -5
  29. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  30. package/lib/cjs/curve/spiral/NormalizedTransition.d.ts +8 -7
  31. package/lib/cjs/curve/spiral/NormalizedTransition.d.ts.map +1 -1
  32. package/lib/cjs/curve/spiral/NormalizedTransition.js +32 -16
  33. package/lib/cjs/curve/spiral/NormalizedTransition.js.map +1 -1
  34. package/lib/cjs/curve/spiral/TransitionConditionalProperties.d.ts.map +1 -1
  35. package/lib/cjs/curve/spiral/TransitionConditionalProperties.js +1 -0
  36. package/lib/cjs/curve/spiral/TransitionConditionalProperties.js.map +1 -1
  37. package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts +1 -1
  38. package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
  39. package/lib/cjs/curve/spiral/TransitionSpiral3d.js +1 -0
  40. package/lib/cjs/curve/spiral/TransitionSpiral3d.js.map +1 -1
  41. package/lib/cjs/geometry3d/Ray3d.d.ts +1 -2
  42. package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
  43. package/lib/cjs/geometry3d/Ray3d.js +1 -2
  44. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  45. package/lib/cjs/numerics/Newton.d.ts +1 -1
  46. package/lib/cjs/numerics/Newton.js +1 -1
  47. package/lib/cjs/numerics/Newton.js.map +1 -1
  48. package/lib/esm/bspline/SurfaceLocationDetail.d.ts +1 -1
  49. package/lib/esm/bspline/SurfaceLocationDetail.js +1 -1
  50. package/lib/esm/bspline/SurfaceLocationDetail.js.map +1 -1
  51. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  52. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  53. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts +13 -0
  54. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  55. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +78 -3
  56. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  57. package/lib/esm/curve/spiral/AustralianRailCorpXYEvaluator.d.ts +1 -1
  58. package/lib/esm/curve/spiral/AustralianRailCorpXYEvaluator.js +1 -1
  59. package/lib/esm/curve/spiral/AustralianRailCorpXYEvaluator.js.map +1 -1
  60. package/lib/esm/curve/spiral/ClothoidSeries.d.ts +3 -3
  61. package/lib/esm/curve/spiral/ClothoidSeries.d.ts.map +1 -1
  62. package/lib/esm/curve/spiral/ClothoidSeries.js +15 -11
  63. package/lib/esm/curve/spiral/ClothoidSeries.js.map +1 -1
  64. package/lib/esm/curve/spiral/CzechSpiralEvaluator.d.ts +2 -5
  65. package/lib/esm/curve/spiral/CzechSpiralEvaluator.d.ts.map +1 -1
  66. package/lib/esm/curve/spiral/CzechSpiralEvaluator.js +4 -12
  67. package/lib/esm/curve/spiral/CzechSpiralEvaluator.js.map +1 -1
  68. package/lib/esm/curve/spiral/DirectSpiral3d.d.ts +7 -6
  69. package/lib/esm/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
  70. package/lib/esm/curve/spiral/DirectSpiral3d.js +8 -6
  71. package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
  72. package/lib/esm/curve/spiral/IntegratedSpiral3d.d.ts +2 -2
  73. package/lib/esm/curve/spiral/IntegratedSpiral3d.d.ts.map +1 -1
  74. package/lib/esm/curve/spiral/IntegratedSpiral3d.js +9 -5
  75. package/lib/esm/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  76. package/lib/esm/curve/spiral/NormalizedTransition.d.ts +8 -7
  77. package/lib/esm/curve/spiral/NormalizedTransition.d.ts.map +1 -1
  78. package/lib/esm/curve/spiral/NormalizedTransition.js +32 -16
  79. package/lib/esm/curve/spiral/NormalizedTransition.js.map +1 -1
  80. package/lib/esm/curve/spiral/TransitionConditionalProperties.d.ts.map +1 -1
  81. package/lib/esm/curve/spiral/TransitionConditionalProperties.js +1 -0
  82. package/lib/esm/curve/spiral/TransitionConditionalProperties.js.map +1 -1
  83. package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts +1 -1
  84. package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
  85. package/lib/esm/curve/spiral/TransitionSpiral3d.js +1 -0
  86. package/lib/esm/curve/spiral/TransitionSpiral3d.js.map +1 -1
  87. package/lib/esm/geometry3d/Ray3d.d.ts +1 -2
  88. package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
  89. package/lib/esm/geometry3d/Ray3d.js +1 -2
  90. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  91. package/lib/esm/numerics/Newton.d.ts +1 -1
  92. package/lib/esm/numerics/Newton.js +1 -1
  93. package/lib/esm/numerics/Newton.js.map +1 -1
  94. package/package.json +3 -3
@@ -25,11 +25,13 @@ const Arc3d_1 = require("../Arc3d");
25
25
  const CurveChainWithDistanceIndex_1 = require("../CurveChainWithDistanceIndex");
26
26
  const CurveCollection_1 = require("../CurveCollection");
27
27
  const CurveLocationDetail_1 = require("../CurveLocationDetail");
28
+ const CurvePrimitive_1 = require("../CurvePrimitive");
28
29
  const LineSegment3d_1 = require("../LineSegment3d");
29
30
  const LineString3d_1 = require("../LineString3d");
30
31
  const Loop_1 = require("../Loop");
31
32
  const Path_1 = require("../Path");
32
33
  const ProxyCurve_1 = require("../ProxyCurve");
34
+ const TransitionSpiral3d_1 = require("../spiral/TransitionSpiral3d");
33
35
  // cspell:word XYRR
34
36
  /**
35
37
  * Handler class for XY intersections between _geometryB and another geometry.
@@ -739,7 +741,7 @@ class CurveCurveIntersectXY extends GeometryHandler_1.RecurseToCurvesGeometryHan
739
741
  return undefined;
740
742
  }
741
743
  /** Detail computation for linestring intersecting linestring. */
742
- computeLineStringLineString(lsA, lsB, reversed) {
744
+ computeLineStringLineString(lsA, extendA0, extendA1, lsB, extendB0, extendB1, reversed) {
743
745
  const pointA0 = CurveCurveIntersectXY._workPointAA0;
744
746
  const pointA1 = CurveCurveIntersectXY._workPointAA1;
745
747
  const pointB0 = CurveCurveIntersectXY._workPointBB0;
@@ -763,7 +765,7 @@ class CurveCurveIntersectXY extends GeometryHandler_1.RecurseToCurvesGeometryHan
763
765
  for (let ib = 1; ib < numB; ib++, pointB0.setFrom(pointB1), fB0 = fB1) {
764
766
  lsB.pointAt(ib, pointB1);
765
767
  fB1 = ib * dfB;
766
- this.dispatchSegmentSegment(lsA, ia === 1 && this._extendA0, pointA0, fA0, pointA1, fA1, (ia + 1) === numA && this._extendA1, lsB, ib === 1 && this._extendB0, pointB0, fB0, pointB1, fB1, (ib + 1) === numB && this._extendB1, reversed);
768
+ this.dispatchSegmentSegment(lsA, ia === 1 && extendA0, pointA0, fA0, pointA1, fA1, (ia + 1) === numA && extendA1, lsB, ib === 1 && extendB0, pointB0, fB0, pointB1, fB1, (ib + 1) === numB && extendB1, reversed);
767
769
  }
768
770
  }
769
771
  }
@@ -862,6 +864,14 @@ class CurveCurveIntersectXY extends GeometryHandler_1.RecurseToCurvesGeometryHan
862
864
  else if (this._geometryB instanceof BSplineCurve_1.BSplineCurve3d) {
863
865
  this.dispatchSegmentBsplineCurve(segmentA, this._extendA0, segmentA.point0Ref, 0.0, segmentA.point1Ref, 1.0, this._extendA1, this._geometryB, this._extendB0, this._extendB1, false);
864
866
  }
867
+ else if (this._geometryB instanceof TransitionSpiral3d_1.TransitionSpiral3d) {
868
+ const spiralApproximation = LineString3d_1.LineString3d.create();
869
+ this._geometryB.emitStrokes(spiralApproximation);
870
+ const numPreviousResults = this._results.length;
871
+ this.computeSegmentLineString(segmentA, this._extendA0, this._extendA1, spiralApproximation, false, false, false);
872
+ const numberOfNewResults = this._results.length - numPreviousResults;
873
+ this.refineSpiralResultsByNewton(segmentA, this._geometryB, numberOfNewResults);
874
+ }
865
875
  else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
866
876
  this.dispatchCurveCollection(segmentA, this.handleLineSegment3d.bind(this));
867
877
  }
@@ -874,7 +884,7 @@ class CurveCurveIntersectXY extends GeometryHandler_1.RecurseToCurvesGeometryHan
874
884
  handleLineString3d(lsA) {
875
885
  if (this._geometryB instanceof LineString3d_1.LineString3d) {
876
886
  const lsB = this._geometryB;
877
- this.computeLineStringLineString(lsA, lsB, false);
887
+ this.computeLineStringLineString(lsA, this._extendA0, this._extendA1, lsB, this._extendB0, this._extendB1, false);
878
888
  }
879
889
  else if (this._geometryB instanceof LineSegment3d_1.LineSegment3d) {
880
890
  this.computeSegmentLineString(this._geometryB, this._extendB0, this._extendB1, lsA, this._extendA0, this._extendA1, true);
@@ -885,6 +895,14 @@ class CurveCurveIntersectXY extends GeometryHandler_1.RecurseToCurvesGeometryHan
885
895
  else if (this._geometryB instanceof BSplineCurve_1.BSplineCurve3d) {
886
896
  this.dispatchLineStringBSplineCurve(lsA, this._extendA0, this._extendA1, this._geometryB, this._extendB0, this._extendB1, false);
887
897
  }
898
+ else if (this._geometryB instanceof TransitionSpiral3d_1.TransitionSpiral3d) {
899
+ const spiralApproximation = LineString3d_1.LineString3d.create();
900
+ this._geometryB.emitStrokes(spiralApproximation);
901
+ const numPreviousResults = this._results.length;
902
+ this.computeLineStringLineString(lsA, this._extendA0, this._extendA1, spiralApproximation, false, false, false);
903
+ const numberOfNewResults = this._results.length - numPreviousResults;
904
+ this.refineSpiralResultsByNewton(lsA, this._geometryB, numberOfNewResults);
905
+ }
888
906
  else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
889
907
  this.dispatchCurveCollection(lsA, this.handleLineString3d.bind(this));
890
908
  }
@@ -907,6 +925,14 @@ class CurveCurveIntersectXY extends GeometryHandler_1.RecurseToCurvesGeometryHan
907
925
  else if (this._geometryB instanceof BSplineCurve_1.BSplineCurve3d) {
908
926
  this.dispatchArcBsplineCurve3d(arc0, this._extendA0, this._extendA1, this._geometryB, this._extendB0, this._extendB1, false);
909
927
  }
928
+ else if (this._geometryB instanceof TransitionSpiral3d_1.TransitionSpiral3d) {
929
+ const spiralApproximation = LineString3d_1.LineString3d.create();
930
+ this._geometryB.emitStrokes(spiralApproximation);
931
+ const numPreviousResults = this._results.length;
932
+ this.computeArcLineString(arc0, this._extendA0, this._extendA1, spiralApproximation, false, false, false);
933
+ const numberOfNewResults = this._results.length - numPreviousResults;
934
+ this.refineSpiralResultsByNewton(arc0, this._geometryB, numberOfNewResults);
935
+ }
910
936
  else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
911
937
  this.dispatchCurveCollection(arc0, this.handleArc3d.bind(this));
912
938
  }
@@ -929,6 +955,14 @@ class CurveCurveIntersectXY extends GeometryHandler_1.RecurseToCurvesGeometryHan
929
955
  else if (this._geometryB instanceof BSplineCurve_1.BSplineCurve3dBase) {
930
956
  this.dispatchBSplineCurve3dBSplineCurve3d(curve, this._geometryB, false);
931
957
  }
958
+ else if (this._geometryB instanceof TransitionSpiral3d_1.TransitionSpiral3d) {
959
+ const spiralApproximation = LineString3d_1.LineString3d.create();
960
+ this._geometryB.emitStrokes(spiralApproximation);
961
+ const numPreviousResults = this._results.length;
962
+ this.dispatchLineStringBSplineCurve(spiralApproximation, false, false, curve, this._extendA0, this._extendA1, true);
963
+ const numberOfNewResults = this._results.length - numPreviousResults;
964
+ this.refineSpiralResultsByNewton(curve, this._geometryB, numberOfNewResults);
965
+ }
932
966
  else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
933
967
  this.dispatchCurveCollection(curve, this.handleBSplineCurve3d.bind(this));
934
968
  }
@@ -937,6 +971,47 @@ class CurveCurveIntersectXY extends GeometryHandler_1.RecurseToCurvesGeometryHan
937
971
  }
938
972
  return undefined;
939
973
  }
974
+ /**
975
+ * Assuming the tail of `this._results` holds the given number of approximate solutions to the curve-spiral
976
+ * xy-intersection problem, replace each with its Newton refinement, unless it doesn't converge, in which case
977
+ * it is removed.
978
+ * @param spiral The transition spiral.
979
+ * @param otherCurve The other curve primitive.
980
+ * @param numberOfNewResults The number of results in the tail of `this._results` to be refined.
981
+ * @param reversed Whether the spiral is geometryA (true) or geometryB (false).
982
+ */
983
+ refineSpiralResultsByNewton(otherCurve, spiral, numberOfNewResults, reversed = false) {
984
+ const resultsToBeRefined = this._results.slice(this._results.length - numberOfNewResults);
985
+ this._results.length -= numberOfNewResults; // keep already refined results
986
+ for (const detail of resultsToBeRefined) {
987
+ let spiralFraction = reversed ? detail.detailA.fraction : detail.detailB.fraction;
988
+ let otherFraction = reversed ? detail.detailB.fraction : detail.detailA.fraction;
989
+ const xyMatchingFunction = new Newton_1.CurveCurveIntersectionXYRRToRRD(spiral, otherCurve);
990
+ const newtonSearcher = new Newton_1.Newton2dUnboundedWithDerivative(xyMatchingFunction);
991
+ newtonSearcher.setUV(spiralFraction, otherFraction);
992
+ if (newtonSearcher.runIterations()) {
993
+ spiralFraction = newtonSearcher.getU();
994
+ otherFraction = newtonSearcher.getV();
995
+ if (this.acceptFraction(false, spiralFraction, false) && this.acceptFraction(false, otherFraction, false))
996
+ this.recordPointWithLocalFractions(otherFraction, otherCurve, 0, 1, spiralFraction, spiral, 0, 1, reversed);
997
+ }
998
+ }
999
+ }
1000
+ /** Double dispatch handler for strongly typed spiral curve. */
1001
+ handleTransitionSpiral(spiral) {
1002
+ if (this._geometryB instanceof CurvePrimitive_1.CurvePrimitive) { // this also handles CurveChainWithDistanceIndex
1003
+ const spiralApproximation = LineString3d_1.LineString3d.create();
1004
+ spiral.emitStrokes(spiralApproximation);
1005
+ const numPreviousResults = this._results.length;
1006
+ this.handleLineString3d(spiralApproximation);
1007
+ const numberOfNewResults = this._results.length - numPreviousResults;
1008
+ this.refineSpiralResultsByNewton(this._geometryB, spiral, numberOfNewResults, true);
1009
+ }
1010
+ else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
1011
+ this.dispatchCurveCollection(spiral, this.handleTransitionSpiral.bind(this));
1012
+ }
1013
+ return undefined;
1014
+ }
940
1015
  /** Double dispatch handler for strongly typed CurveChainWithDistanceIndex. */
941
1016
  handleCurveChainWithDistanceIndex(chain) {
942
1017
  super.handleCurveChainWithDistanceIndex(chain);