@itwin/core-geometry 5.10.0-dev.16 → 5.10.0-dev.19
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.
- package/lib/cjs/Geometry.d.ts +5 -0
- package/lib/cjs/Geometry.d.ts.map +1 -1
- package/lib/cjs/Geometry.js +7 -0
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/curve/CurveCurve.d.ts +34 -4
- package/lib/cjs/curve/CurveCurve.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCurve.js +19 -12
- package/lib/cjs/curve/CurveCurve.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +9 -4
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +20 -11
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/cjs/numerics/BezierPolynomials.d.ts.map +1 -1
- package/lib/cjs/numerics/BezierPolynomials.js +2 -1
- package/lib/cjs/numerics/BezierPolynomials.js.map +1 -1
- package/lib/esm/Geometry.d.ts +5 -0
- package/lib/esm/Geometry.d.ts.map +1 -1
- package/lib/esm/Geometry.js +7 -0
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/curve/CurveCurve.d.ts +34 -4
- package/lib/esm/curve/CurveCurve.d.ts.map +1 -1
- package/lib/esm/curve/CurveCurve.js +19 -12
- package/lib/esm/curve/CurveCurve.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +9 -4
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +20 -11
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/esm/numerics/BezierPolynomials.d.ts.map +1 -1
- package/lib/esm/numerics/BezierPolynomials.js +2 -1
- package/lib/esm/numerics/BezierPolynomials.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurveCurve.d.ts","sourceRoot":"","sources":["../../../src/curve/CurveCurve.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAKxC;;;GAGG;AACH,qBAAa,UAAU;IACrB;;;;;;;;OAQG;WACW,mBAAmB,CAC/B,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,OAAO,EAChB,SAAS,GAAE,MAAqC,GAC/C,uBAAuB,EAAE;IAG5B;;;;;;;;;OASG;WACW,4BAA4B,CACxC,YAAY,EAAE,QAAQ,GAAG,SAAS,EAClC,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,OAAO,EAChB,SAAS,GAAE,MAAqC,GAC/C,uBAAuB,EAAE;IAK5B;;;;;;;;;OASG;WACW,oBAAoB,CAChC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,GACrE,uBAAuB,EAAE;IAK5B;;;;OAIG;WACW,iCAAiC,CAC7C,UAAU,EAAE,cAAc,EAAE,EAAE,SAAS,GAAE,MAAqC,GAC7E,uBAAuB,EAAE;IAW5B
|
|
1
|
+
{"version":3,"file":"CurveCurve.d.ts","sourceRoot":"","sources":["../../../src/curve/CurveCurve.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,w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kD,GACpH,uBAAuB,EAAE;IAW5B;;;;;;;;;;;;OAYG;WACW,8BAA8B,CAC1C,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAC9D,uBAAuB,GAAG,SAAS;CAiBvC"}
|
|
@@ -85,11 +85,18 @@ class CurveCurve {
|
|
|
85
85
|
* an `AnyRegion`, then close approaches are computed only to the defining curves, not to the area they enclose.
|
|
86
86
|
* @param curveA first curve
|
|
87
87
|
* @param curveB second curve
|
|
88
|
-
* @param
|
|
88
|
+
* @param maxDistanceOrOptions maximum xy-distance to consider between the curves, or a list of extended options.
|
|
89
89
|
* Close approaches further than this xy-distance are not returned.
|
|
90
|
+
* @return array of detail pairs of close xy-approaches. XY-length of the returned close approach is set in `detailA.a`
|
|
91
|
+
* and `detailB.a`.
|
|
90
92
|
*/
|
|
91
|
-
static closeApproachProjectedXYPairs(curveA, curveB,
|
|
92
|
-
const
|
|
93
|
+
static closeApproachProjectedXYPairs(curveA, curveB, maxDistanceOrOptions = Geometry_1.Geometry.largeCoordinateResult) {
|
|
94
|
+
const optionIsNumber = Geometry_1.Geometry.isNumber(maxDistanceOrOptions);
|
|
95
|
+
const maxDistance = optionIsNumber ? maxDistanceOrOptions : maxDistanceOrOptions.maxDistance ?? Geometry_1.Geometry.largeCoordinateResult;
|
|
96
|
+
const xyTolerance = optionIsNumber ? undefined : maxDistanceOrOptions.xyTolerance;
|
|
97
|
+
const newtonTolerance = optionIsNumber ? undefined : maxDistanceOrOptions.newtonTolerance;
|
|
98
|
+
const maxIterations = optionIsNumber ? undefined : maxDistanceOrOptions.maxIterations;
|
|
99
|
+
const handler = new CurveCurveCloseApproachXY_1.CurveCurveCloseApproachXY(curveB, xyTolerance, newtonTolerance, maxIterations);
|
|
93
100
|
handler.maxDistanceToAccept = maxDistance;
|
|
94
101
|
curveA.dispatchToGeometryHandler(handler);
|
|
95
102
|
return handler.grabPairedResults();
|
|
@@ -103,20 +110,20 @@ class CurveCurve {
|
|
|
103
110
|
* found among the pairs.
|
|
104
111
|
* @param curveA first curve
|
|
105
112
|
* @param curveB second curve
|
|
106
|
-
* @
|
|
113
|
+
* @param options optional parameters for close approach calculation
|
|
114
|
+
* @return detail pair of closest xy-approach, undefined if not found. XY-length of the returned close approach is
|
|
115
|
+
* set in `detailA.a` and `detailB.a`.
|
|
107
116
|
*/
|
|
108
|
-
static closestApproachProjectedXYPair(curveA, curveB) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
const closeApproaches = this.closeApproachProjectedXYPairs(curveA, curveB, maxDistance);
|
|
117
|
+
static closestApproachProjectedXYPair(curveA, curveB, options) {
|
|
118
|
+
if (options === undefined)
|
|
119
|
+
options = { maxDistance: Geometry_1.Geometry.largeCoordinateResult };
|
|
120
|
+
const closeApproaches = this.closeApproachProjectedXYPairs(curveA, curveB, options);
|
|
113
121
|
if (!closeApproaches.length)
|
|
114
122
|
return undefined;
|
|
115
123
|
let iMin = 0;
|
|
116
|
-
let minDistXY =
|
|
124
|
+
let minDistXY = Geometry_1.Geometry.largeCoordinateResult;
|
|
117
125
|
for (let i = 0; i < closeApproaches.length; ++i) {
|
|
118
|
-
|
|
119
|
-
const distXY = closeApproaches[i].detailA.point.distanceXY(closeApproaches[i].detailB.point);
|
|
126
|
+
const distXY = closeApproaches[i].detailA.a;
|
|
120
127
|
if (distXY < minDistXY) {
|
|
121
128
|
iMin = i;
|
|
122
129
|
minDistXY = distXY;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurveCurve.js","sourceRoot":"","sources":["../../../src/curve/CurveCurve.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,0CAAuC;AAKvC,4FAAyF;AACzF,oFAAiF;AACjF,sFAAmF;AAEnF;;;GAGG;AACH,MAAa,UAAU;IACrB;;;;;;;;OAQG;IACI,MAAM,CAAC,mBAAmB,CAC/B,MAAgB,EAChB,OAAg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AChD,iHAAiH;YACjH,MAAM,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC7F,IAAI,MAAM,GAAG,SAAS,EAAE,CAAC;gBACvB,IAAI,GAAG,CAAC,CAAC;gBACT,SAAS,GAAG,MAAM,CAAC;YACrB,CAAC;QACH,CAAC;QACD,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF;AA/HD,gCA+HC","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\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Matrix4d } from \"../geometry4d/Matrix4d\";\r\nimport { CurveLocationDetailPair } from \"./CurveLocationDetail\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { AnyCurve } from \"./CurveTypes\";\r\nimport { CurveCurveCloseApproachXY } from \"./internalContexts/CurveCurveCloseApproachXY\";\r\nimport { CurveCurveIntersectXY } from \"./internalContexts/CurveCurveIntersectXY\";\r\nimport { CurveCurveIntersectXYZ } from \"./internalContexts/CurveCurveIntersectXYZ\";\r\n\r\n/**\r\n * `CurveCurve` has static method for various computations that work on a pair of curves or curve collections.\r\n * @public\r\n */\r\nexport class CurveCurve {\r\n /**\r\n * Return xy intersections of 2 curves.\r\n * * Curves can be extended if extend flags are set. B-splines are not extended even if the flag is set.\r\n * @param curveA first curve\r\n * @param extendA true to allow curveA to extend\r\n * @param curveB second curve\r\n * @param extendB true to allow curveB to extend\r\n * @param tolerance optional distance tolerance for coincidence\r\n */\r\n public static intersectionXYPairs(\r\n curveA: AnyCurve,\r\n extendA: boolean,\r\n curveB: AnyCurve,\r\n extendB: boolean,\r\n tolerance: number = Geometry.smallMetricDistance,\r\n ): CurveLocationDetailPair[] {\r\n return CurveCurve.intersectionProjectedXYPairs(undefined, curveA, extendA, curveB, extendB, tolerance);\r\n }\r\n /**\r\n * Return xy intersections of 2 projected curves.\r\n * * Curves can be extended if extend flags are set. B-splines are not extended even if the flag is set.\r\n * @param worldToLocal transform (possibly perspective) defining the local coordinates in which to compute xy intersections\r\n * @param curveA first curve\r\n * @param extendA true to allow curveA to extend\r\n * @param curveB second curve\r\n * @param extendB true to allow curveB to extend\r\n * @param tolerance optional distance tolerance for coincidence\r\n */\r\n public static intersectionProjectedXYPairs(\r\n worldToLocal: Matrix4d | undefined,\r\n curveA: AnyCurve,\r\n extendA: boolean,\r\n curveB: AnyCurve,\r\n extendB: boolean,\r\n tolerance: number = Geometry.smallMetricDistance,\r\n ): CurveLocationDetailPair[] {\r\n const handler = new CurveCurveIntersectXY(worldToLocal, extendA, curveB, extendB, tolerance);\r\n curveA.dispatchToGeometryHandler(handler);\r\n return handler.grabPairedResults();\r\n }\r\n /**\r\n * Return full 3d xyz intersections of 2 curves.\r\n * * Implemented for combinations of LineSegment3d, LineString3d, Arc3d.\r\n * * Not Implemented for bspline and bezier curves.\r\n * @param curveA first curve\r\n * @param extendA true to allow curveA to extend\r\n * @param curveB second curve\r\n * @param extendB true to allow curveB to extend\r\n * @returns array of intersections structured as CurveLocationDetailPair[]\r\n */\r\n public static intersectionXYZPairs(\r\n curveA: AnyCurve, extendA: boolean, curveB: AnyCurve, extendB: boolean,\r\n ): CurveLocationDetailPair[] {\r\n const handler = new CurveCurveIntersectXYZ(extendA, curveB, extendB);\r\n curveA.dispatchToGeometryHandler(handler);\r\n return handler.grabPairedResults();\r\n }\r\n /**\r\n * Return xy intersections of input curves.\r\n * @param primitives input curves to intersect\r\n * @param tolerance optional distance tolerance for coincidence\r\n */\r\n public static allIntersectionsAmongPrimitivesXY(\r\n primitives: CurvePrimitive[], tolerance: number = Geometry.smallMetricDistance,\r\n ): CurveLocationDetailPair[] {\r\n const handler = new CurveCurveIntersectXY(undefined, false, undefined, false, tolerance);\r\n for (let i = 0; i < primitives.length; i++) {\r\n const curveA = primitives[i];\r\n for (let j = i + 1; j < primitives.length; j++) {\r\n handler.resetGeometryB(primitives[j]);\r\n curveA.dispatchToGeometryHandler(handler);\r\n }\r\n }\r\n return handler.grabPairedResults();\r\n }\r\n /**\r\n * Return at least one XY close approach between 2 curves.\r\n * * Close approach xy-distances are measured without regard to z. This is equivalent to their separation distance\r\n * as seen in the top view, or as measured between their projections onto the xy-plane.\r\n * * If more than one approach is returned, one of them is the closest approach.\r\n * * If an input curve is a `CurveCollection`, then close approaches are computed to each `CurvePrimitive` child.\r\n * This can lead to many returned pairs, especially when both inputs are `CurveCollection`s. If an input curve is\r\n * an `AnyRegion`, then close approaches are computed only to the defining curves, not to the area they enclose.\r\n * @param curveA first curve\r\n * @param curveB second curve\r\n * @param maxDistance maximum xy-distance to consider between the curves.\r\n * Close approaches further than this xy-distance are not returned.\r\n */\r\n public static closeApproachProjectedXYPairs(\r\n curveA: AnyCurve, curveB: AnyCurve, maxDistance: number,\r\n ): CurveLocationDetailPair[] {\r\n const handler = new CurveCurveCloseApproachXY(curveB);\r\n handler.maxDistanceToAccept = maxDistance;\r\n curveA.dispatchToGeometryHandler(handler);\r\n return handler.grabPairedResults();\r\n }\r\n /**\r\n * Convenience method that calls [[closeApproachProjectedXYPairs]] with a large `maxDistance`\r\n * and returns a detail pair representing the closest xy-approach between the curves.\r\n * * There may be many detail pairs that represent \"closest\" xy-approach, including coincident interval pairs,\r\n * isolated intersections, or close approaches within tolerance of each other. This method makes no attempt to\r\n * distinguish among them, and returns a pair whose `detail.point` values are separated by the smallest xy distance\r\n * found among the pairs.\r\n * @param curveA first curve\r\n * @param curveB second curve\r\n * @return detail pair of closest xy-approach, undefined if not found\r\n */\r\n public static closestApproachProjectedXYPair(curveA: AnyCurve, curveB: AnyCurve): CurveLocationDetailPair | undefined {\r\n const range = curveA.range();\r\n range.extendRange(curveB.range());\r\n const maxDistance = range.low.distanceXY(range.high);\r\n const closeApproaches = this.closeApproachProjectedXYPairs(curveA, curveB, maxDistance);\r\n if (!closeApproaches.length)\r\n return undefined;\r\n let iMin = 0;\r\n let minDistXY = 2 * maxDistance;\r\n for (let i = 0; i < closeApproaches.length; ++i) {\r\n // TODO: this distance should already be in detail.a. Verify this, then just use it instead of recomputing below.\r\n const distXY = closeApproaches[i].detailA.point.distanceXY(closeApproaches[i].detailB.point);\r\n if (distXY < minDistXY) {\r\n iMin = i;\r\n minDistXY = distXY;\r\n }\r\n }\r\n return closeApproaches[iMin];\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"CurveCurve.js","sourceRoot":"","sources":["../../../src/curve/CurveCurve.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,0CAAuC;AAKvC,4FAAyF;AACzF,oFAAiF;AACjF,sFAAmF;AA6BnF;;;GAGG;AACH,MAAa,UAAU;IACrB;;;;;;;;OAQG;IACI,MAAM,CAAC,mBAAmB,CAC/B,MAAgB,EAChB,OAAgB,EAChB,MAAgB,EAChB,OAAgB,EAChB,YAAoB,mBAAQ,CAAC,mBAAmB;QAEhD,OAAO,UAAU,CAAC,4BAA4B,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IACzG,CAAC;IACD;;;;;;;;;OASG;IACI,MAAM,CAAC,4BAA4B,CACxC,YAAkC,EAClC,MAAgB,EAChB,OAAgB,EAChB,MAAgB,EAChB,OAAgB,EAChB,YAAoB,mBAAQ,CAAC,mBAAmB;QAEhD,MAAM,OAAO,GAAG,IAAI,6CAAqB,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAC7F,MAAM,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;QAC1C,OAAO,OAAO,CAAC,iBAAiB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AC,CAAC,CAAC;YAC5C,IAAI,MAAM,GAAG,SAAS,EAAE,CAAC;gBACvB,IAAI,GAAG,CAAC,CAAC;gBACT,SAAS,GAAG,MAAM,CAAC;YACrB,CAAC;QACH,CAAC;QACD,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF;AAxID,gCAwIC","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\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Matrix4d } from \"../geometry4d/Matrix4d\";\r\nimport { CurveLocationDetailPair } from \"./CurveLocationDetail\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { AnyCurve } from \"./CurveTypes\";\r\nimport { CurveCurveCloseApproachXY } from \"./internalContexts/CurveCurveCloseApproachXY\";\r\nimport { CurveCurveIntersectXY } from \"./internalContexts/CurveCurveIntersectXY\";\r\nimport { CurveCurveIntersectXYZ } from \"./internalContexts/CurveCurveIntersectXYZ\";\r\n\r\n/**\r\n * Options used for method [[CurveCurve.closeApproachProjectedXYPairs]] and [[CurveCurve.closestApproachProjectedXYPair]].\r\n * @public\r\n */\r\nexport interface CurveCurveOptions {\r\n /**\r\n * Maximum xy approach distance to be returned.\r\n * Default: {@link Geometry.largeCoordinateResult}.\r\n */\r\n maxDistance?: number;\r\n /**\r\n * Tolerance for comparing xy points.\r\n * Default: {@link Geometry.smallMetricDistance}.\r\n */\r\n xyTolerance?: number;\r\n /**\r\n * Newton convergence tolerance, in parametric space.\r\n * Default: {@link Geometry.smallNewtonStep}.\r\n */\r\n newtonTolerance?: number;\r\n /**\r\n * Maximum number of iterations for the Newton method.\r\n * Default: 50.\r\n */\r\n maxIterations?: number;\r\n}\r\n\r\n/**\r\n * `CurveCurve` has static method for various computations that work on a pair of curves or curve collections.\r\n * @public\r\n */\r\nexport class CurveCurve {\r\n /**\r\n * Return xy intersections of 2 curves.\r\n * * Curves can be extended if extend flags are set. B-splines are not extended even if the flag is set.\r\n * @param curveA first curve\r\n * @param extendA true to allow curveA to extend\r\n * @param curveB second curve\r\n * @param extendB true to allow curveB to extend\r\n * @param tolerance optional distance tolerance for coincidence\r\n */\r\n public static intersectionXYPairs(\r\n curveA: AnyCurve,\r\n extendA: boolean,\r\n curveB: AnyCurve,\r\n extendB: boolean,\r\n tolerance: number = Geometry.smallMetricDistance,\r\n ): CurveLocationDetailPair[] {\r\n return CurveCurve.intersectionProjectedXYPairs(undefined, curveA, extendA, curveB, extendB, tolerance);\r\n }\r\n /**\r\n * Return xy intersections of 2 projected curves.\r\n * * Curves can be extended if extend flags are set. B-splines are not extended even if the flag is set.\r\n * @param worldToLocal transform (possibly perspective) defining the local coordinates in which to compute xy intersections\r\n * @param curveA first curve\r\n * @param extendA true to allow curveA to extend\r\n * @param curveB second curve\r\n * @param extendB true to allow curveB to extend\r\n * @param tolerance optional distance tolerance for coincidence\r\n */\r\n public static intersectionProjectedXYPairs(\r\n worldToLocal: Matrix4d | undefined,\r\n curveA: AnyCurve,\r\n extendA: boolean,\r\n curveB: AnyCurve,\r\n extendB: boolean,\r\n tolerance: number = Geometry.smallMetricDistance,\r\n ): CurveLocationDetailPair[] {\r\n const handler = new CurveCurveIntersectXY(worldToLocal, extendA, curveB, extendB, tolerance);\r\n curveA.dispatchToGeometryHandler(handler);\r\n return handler.grabPairedResults();\r\n }\r\n /**\r\n * Return full 3d xyz intersections of 2 curves.\r\n * * Implemented for combinations of LineSegment3d, LineString3d, Arc3d.\r\n * * Not Implemented for bspline and bezier curves.\r\n * @param curveA first curve\r\n * @param extendA true to allow curveA to extend\r\n * @param curveB second curve\r\n * @param extendB true to allow curveB to extend\r\n * @returns array of intersections structured as CurveLocationDetailPair[]\r\n */\r\n public static intersectionXYZPairs(\r\n curveA: AnyCurve, extendA: boolean, curveB: AnyCurve, extendB: boolean,\r\n ): CurveLocationDetailPair[] {\r\n const handler = new CurveCurveIntersectXYZ(extendA, curveB, extendB);\r\n curveA.dispatchToGeometryHandler(handler);\r\n return handler.grabPairedResults();\r\n }\r\n /**\r\n * Return xy intersections of input curves.\r\n * @param primitives input curves to intersect\r\n * @param tolerance optional distance tolerance for coincidence\r\n */\r\n public static allIntersectionsAmongPrimitivesXY(\r\n primitives: CurvePrimitive[], tolerance: number = Geometry.smallMetricDistance,\r\n ): CurveLocationDetailPair[] {\r\n const handler = new CurveCurveIntersectXY(undefined, false, undefined, false, tolerance);\r\n for (let i = 0; i < primitives.length; i++) {\r\n const curveA = primitives[i];\r\n for (let j = i + 1; j < primitives.length; j++) {\r\n handler.resetGeometryB(primitives[j]);\r\n curveA.dispatchToGeometryHandler(handler);\r\n }\r\n }\r\n return handler.grabPairedResults();\r\n }\r\n /**\r\n * Return at least one XY close approach between 2 curves.\r\n * * Close approach xy-distances are measured without regard to z. This is equivalent to their separation distance\r\n * as seen in the top view, or as measured between their projections onto the xy-plane.\r\n * * If more than one approach is returned, one of them is the closest approach.\r\n * * If an input curve is a `CurveCollection`, then close approaches are computed to each `CurvePrimitive` child.\r\n * This can lead to many returned pairs, especially when both inputs are `CurveCollection`s. If an input curve is\r\n * an `AnyRegion`, then close approaches are computed only to the defining curves, not to the area they enclose.\r\n * @param curveA first curve\r\n * @param curveB second curve\r\n * @param maxDistanceOrOptions maximum xy-distance to consider between the curves, or a list of extended options.\r\n * Close approaches further than this xy-distance are not returned.\r\n * @return array of detail pairs of close xy-approaches. XY-length of the returned close approach is set in `detailA.a`\r\n * and `detailB.a`.\r\n */\r\n public static closeApproachProjectedXYPairs(\r\n curveA: AnyCurve, curveB: AnyCurve, maxDistanceOrOptions: number | CurveCurveOptions = Geometry.largeCoordinateResult,\r\n ): CurveLocationDetailPair[] {\r\n const optionIsNumber = Geometry.isNumber(maxDistanceOrOptions);\r\n const maxDistance = optionIsNumber ? maxDistanceOrOptions : maxDistanceOrOptions.maxDistance ?? Geometry.largeCoordinateResult;\r\n const xyTolerance = optionIsNumber ? undefined : maxDistanceOrOptions.xyTolerance;\r\n const newtonTolerance = optionIsNumber ? undefined : maxDistanceOrOptions.newtonTolerance;\r\n const maxIterations = optionIsNumber ? undefined : maxDistanceOrOptions.maxIterations;\r\n const handler = new CurveCurveCloseApproachXY(curveB, xyTolerance, newtonTolerance, maxIterations);\r\n handler.maxDistanceToAccept = maxDistance;\r\n curveA.dispatchToGeometryHandler(handler);\r\n return handler.grabPairedResults();\r\n }\r\n /**\r\n * Convenience method that calls [[closeApproachProjectedXYPairs]] with a large `maxDistance`\r\n * and returns a detail pair representing the closest xy-approach between the curves.\r\n * * There may be many detail pairs that represent \"closest\" xy-approach, including coincident interval pairs,\r\n * isolated intersections, or close approaches within tolerance of each other. This method makes no attempt to\r\n * distinguish among them, and returns a pair whose `detail.point` values are separated by the smallest xy distance\r\n * found among the pairs.\r\n * @param curveA first curve\r\n * @param curveB second curve\r\n * @param options optional parameters for close approach calculation\r\n * @return detail pair of closest xy-approach, undefined if not found. XY-length of the returned close approach is\r\n * set in `detailA.a` and `detailB.a`.\r\n */\r\n public static closestApproachProjectedXYPair(\r\n curveA: AnyCurve, curveB: AnyCurve, options?: CurveCurveOptions\r\n ): CurveLocationDetailPair | undefined {\r\n if (options === undefined)\r\n options = { maxDistance: Geometry.largeCoordinateResult };\r\n const closeApproaches = this.closeApproachProjectedXYPairs(curveA, curveB, options);\r\n if (!closeApproaches.length)\r\n return undefined;\r\n let iMin = 0;\r\n let minDistXY = Geometry.largeCoordinateResult;\r\n for (let i = 0; i < closeApproaches.length; ++i) {\r\n const distXY = closeApproaches[i].detailA.a;\r\n if (distXY < minDistXY) {\r\n iMin = i;\r\n minDistXY = distXY;\r\n }\r\n }\r\n return closeApproaches[iMin];\r\n }\r\n}\r\n"]}
|
|
@@ -33,6 +33,7 @@ export declare class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHa
|
|
|
33
33
|
private _maxDistanceSquared;
|
|
34
34
|
private _xyTolerance;
|
|
35
35
|
private _newtonTolerance;
|
|
36
|
+
private _maxIterations;
|
|
36
37
|
/**
|
|
37
38
|
* Start and end points of line segments that meet closest approach criteria, i.e., they are perpendicular to
|
|
38
39
|
* both curves and their length is smaller than _maxDistanceToAccept.
|
|
@@ -48,8 +49,9 @@ export declare class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHa
|
|
|
48
49
|
* @param geometryB second curve for intersection. Saved for reference by specific handler methods.
|
|
49
50
|
* @param xyTolerance optional tolerance for comparing xy points (default [[Geometry.smallMetricDistance]]).
|
|
50
51
|
* @param newtonTolerance optional relative fraction tolerance for Newton iteration (default [[Geometry.smallNewtonStep]]).
|
|
52
|
+
* @param maxIterations optional max iterations for Newton iteration (default 50).
|
|
51
53
|
*/
|
|
52
|
-
constructor(geometryB?: AnyCurve, xyTolerance?: number, newtonTolerance?: number);
|
|
54
|
+
constructor(geometryB?: AnyCurve, xyTolerance?: number, newtonTolerance?: number, maxIterations?: number);
|
|
53
55
|
/** Set the (possibly undefined) max XY distance (z is ignored) to accept. */
|
|
54
56
|
set maxDistanceToAccept(value: number | undefined);
|
|
55
57
|
/** Access the (possibly undefined) max XY distance (z is ignored) to accept. */
|
|
@@ -197,11 +199,14 @@ export declare class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHa
|
|
|
197
199
|
/** Specifies whether the curve needs to be stroked for close approach computation. */
|
|
198
200
|
private needsStroking;
|
|
199
201
|
/**
|
|
200
|
-
* Process seeds for xy close approach between one curve and another curve
|
|
202
|
+
* Process seeds for xy close approach between one curve and another curve.
|
|
203
|
+
* * Seeds typically result from solving a discrete close approach problem, where one or both curves have been stroked.
|
|
201
204
|
* * Refine each result via Newton iteration. If it doesn't converge, remove it.
|
|
202
205
|
* @param seeds the initial seed results to refine.
|
|
203
206
|
* @param curveA curve to find its XY close approach with curveB.
|
|
204
|
-
* @param
|
|
207
|
+
* @param curveAIsStroked whether `seeds` contains results from a linestring approximation to `curveA`
|
|
208
|
+
* @param curveB the other curve.
|
|
209
|
+
* @param curveBIsStroked whether `seeds` contains results from a linestring approximation to `curveB`
|
|
205
210
|
* @param reversed whether `curveB` data is in `detailA` of each recorded pair, and `curveA` data in `detailB`.
|
|
206
211
|
*/
|
|
207
212
|
private refineStrokedResultsByNewton;
|
|
@@ -218,7 +223,7 @@ export declare class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHa
|
|
|
218
223
|
/**
|
|
219
224
|
* Compute the XY close approach of a curve and another curve to be stroked.
|
|
220
225
|
* @param curveA curve to find its XY close approach with curveB.
|
|
221
|
-
* @param curveB the other curve to be stroked.
|
|
226
|
+
* @param curveB the other curve, to be stroked.
|
|
222
227
|
* @param reversed whether `curveB` data will be recorded in `detailA` of each result, and `curveA` data in `detailB`.
|
|
223
228
|
*/
|
|
224
229
|
private dispatchCurveStrokedCurve;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurveCurveCloseApproachXY.d.ts","sourceRoot":"","sources":["../../../../src/curve/internalContexts/CurveCurveCloseApproachXY.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAsB,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAOlF,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAG7E,OAAO,EAA0C,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEzG,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAKlE;;;;;;;;;;;;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AAE,2BAA2B,GAAG,GAAG;IAS1F,8EAA8E;IAC9D,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,GAAG;CAIpE"}
|
|
@@ -54,6 +54,7 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
54
54
|
_maxDistanceSquared;
|
|
55
55
|
_xyTolerance;
|
|
56
56
|
_newtonTolerance;
|
|
57
|
+
_maxIterations;
|
|
57
58
|
/**
|
|
58
59
|
* Start and end points of line segments that meet closest approach criteria, i.e., they are perpendicular to
|
|
59
60
|
* both curves and their length is smaller than _maxDistanceToAccept.
|
|
@@ -69,13 +70,16 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
69
70
|
* @param geometryB second curve for intersection. Saved for reference by specific handler methods.
|
|
70
71
|
* @param xyTolerance optional tolerance for comparing xy points (default [[Geometry.smallMetricDistance]]).
|
|
71
72
|
* @param newtonTolerance optional relative fraction tolerance for Newton iteration (default [[Geometry.smallNewtonStep]]).
|
|
73
|
+
* @param maxIterations optional max iterations for Newton iteration (default 50).
|
|
72
74
|
*/
|
|
73
|
-
constructor(geometryB, xyTolerance = Geometry_1.Geometry.smallMetricDistance, newtonTolerance = Geometry_1.Geometry.smallNewtonStep
|
|
75
|
+
constructor(geometryB, xyTolerance = Geometry_1.Geometry.smallMetricDistance, newtonTolerance = Geometry_1.Geometry.smallNewtonStep, maxIterations = 50 // seen: 47
|
|
76
|
+
) {
|
|
74
77
|
super();
|
|
75
78
|
this._geometryB = geometryB instanceof ProxyCurve_1.ProxyCurve ? geometryB.proxyCurve : geometryB;
|
|
76
79
|
this._maxDistanceSquared = Geometry_1.Geometry.smallMetricDistanceSquared;
|
|
77
80
|
this._xyTolerance = xyTolerance;
|
|
78
81
|
this._newtonTolerance = newtonTolerance;
|
|
82
|
+
this._maxIterations = maxIterations;
|
|
79
83
|
const compare = CurveLocationDetail_1.CurveLocationDetailPair.comparePairsByPoints(xyTolerance, true);
|
|
80
84
|
this._results = new core_bentley_1.SortedArray(compare, core_bentley_1.DuplicatePolicy.Retain);
|
|
81
85
|
}
|
|
@@ -594,21 +598,27 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
594
598
|
return curve instanceof BSplineCurve_1.BSplineCurve3dBase || curve instanceof TransitionSpiral3d_1.TransitionSpiral3d;
|
|
595
599
|
}
|
|
596
600
|
/**
|
|
597
|
-
* Process seeds for xy close approach between one curve and another curve
|
|
601
|
+
* Process seeds for xy close approach between one curve and another curve.
|
|
602
|
+
* * Seeds typically result from solving a discrete close approach problem, where one or both curves have been stroked.
|
|
598
603
|
* * Refine each result via Newton iteration. If it doesn't converge, remove it.
|
|
599
604
|
* @param seeds the initial seed results to refine.
|
|
600
605
|
* @param curveA curve to find its XY close approach with curveB.
|
|
601
|
-
* @param
|
|
606
|
+
* @param curveAIsStroked whether `seeds` contains results from a linestring approximation to `curveA`
|
|
607
|
+
* @param curveB the other curve.
|
|
608
|
+
* @param curveBIsStroked whether `seeds` contains results from a linestring approximation to `curveB`
|
|
602
609
|
* @param reversed whether `curveB` data is in `detailA` of each recorded pair, and `curveA` data in `detailB`.
|
|
603
610
|
*/
|
|
604
|
-
refineStrokedResultsByNewton(seeds, curveA, curveB, reversed = false) {
|
|
611
|
+
refineStrokedResultsByNewton(seeds, curveA, curveAIsStroked, curveB, curveBIsStroked, reversed = false) {
|
|
605
612
|
const xyMatchingFunction = new Newton_1.CurveCurveCloseApproachXYRRtoRRD(curveA, curveB);
|
|
606
|
-
const newtonSearcher = new Newton_1.Newton2dUnboundedWithDerivative(xyMatchingFunction,
|
|
613
|
+
const newtonSearcher = new Newton_1.Newton2dUnboundedWithDerivative(xyMatchingFunction, this._maxIterations, this._newtonTolerance);
|
|
607
614
|
for (const seed of seeds) {
|
|
608
615
|
const detailA = reversed ? seed.detailB : seed.detailA;
|
|
609
616
|
const detailB = reversed ? seed.detailA : seed.detailB;
|
|
610
617
|
(0, core_bentley_1.assert)(detailB.curve instanceof LineString3d_1.LineString3d, "Caller has discretized the curve");
|
|
611
|
-
|
|
618
|
+
// when the curve is stroked, project the discrete seed to compute a fraction in the original curve's parameter space
|
|
619
|
+
const u = curveAIsStroked ? curveA.closestPointXY(detailA.point)?.fraction ?? detailA.fraction : detailA.fraction;
|
|
620
|
+
const v = curveBIsStroked ? curveB.closestPointXY(detailB.point)?.fraction ?? detailB.fraction : detailB.fraction;
|
|
621
|
+
newtonSearcher.setUV(u, v);
|
|
612
622
|
if (newtonSearcher.runIterations()) {
|
|
613
623
|
const fractionA = newtonSearcher.getU();
|
|
614
624
|
const fractionB = newtonSearcher.getV();
|
|
@@ -651,7 +661,7 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
651
661
|
/**
|
|
652
662
|
* Compute the XY close approach of a curve and another curve to be stroked.
|
|
653
663
|
* @param curveA curve to find its XY close approach with curveB.
|
|
654
|
-
* @param curveB the other curve to be stroked.
|
|
664
|
+
* @param curveB the other curve, to be stroked.
|
|
655
665
|
* @param reversed whether `curveB` data will be recorded in `detailA` of each result, and `curveA` data in `detailB`.
|
|
656
666
|
*/
|
|
657
667
|
dispatchCurveStrokedCurve(curveA, curveB, reversed) {
|
|
@@ -660,12 +670,11 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
660
670
|
for (const intersection of intersections)
|
|
661
671
|
this.testAndRecordPair(intersection, reversed);
|
|
662
672
|
// append seeds computed by solving the discretized spiral close approach problem, then refine the seeds via Newton
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
cpA = this.strokeCurve(curveA);
|
|
673
|
+
const curveAIsStroked = this.needsStroking(curveA);
|
|
674
|
+
const cpA = curveAIsStroked ? this.strokeCurve(curveA) : curveA;
|
|
666
675
|
const cpB = this.strokeCurve(curveB);
|
|
667
676
|
const seeds = this.computeDiscreteCloseApproachResults(cpA, cpB, reversed);
|
|
668
|
-
this.refineStrokedResultsByNewton(seeds, curveA, curveB, reversed);
|
|
677
|
+
this.refineStrokedResultsByNewton(seeds, curveA, curveAIsStroked, curveB, true, reversed);
|
|
669
678
|
if (curveA instanceof LineString3d_1.LineString3d) { // explicitly test corners (where Newton converges too slowly)
|
|
670
679
|
const fStep = Geometry_1.Geometry.safeDivideFraction(1.0, curveA.numEdges(), 0);
|
|
671
680
|
const v0 = CurveCurveCloseApproachXY._workPointBB0;
|