@itwin/core-geometry 5.9.0-dev.15 → 5.9.0-dev.16
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/curve/Loop.d.ts.map +1 -1
- package/lib/cjs/curve/Loop.js +3 -1
- package/lib/cjs/curve/Loop.js.map +1 -1
- package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +21 -27
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +97 -152
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts +15 -14
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +144 -163
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.js +6 -7
- package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
- package/lib/cjs/numerics/Newton.d.ts +10 -2
- package/lib/cjs/numerics/Newton.d.ts.map +1 -1
- package/lib/cjs/numerics/Newton.js.map +1 -1
- package/lib/esm/curve/Loop.d.ts.map +1 -1
- package/lib/esm/curve/Loop.js +3 -1
- package/lib/esm/curve/Loop.js.map +1 -1
- package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +21 -27
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +98 -153
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts +15 -14
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +144 -163
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.js +6 -7
- package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
- package/lib/esm/numerics/Newton.d.ts +10 -2
- package/lib/esm/numerics/Newton.d.ts.map +1 -1
- package/lib/esm/numerics/Newton.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Loop.d.ts","sourceRoot":"","sources":["../../../src/curve/Loop.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;GAIG;AACH,qBAAa,IAAK,SAAQ,UAAU;IAClC,wCAAwC;IACxC,SAAgB,mBAAmB,UAAU;IAC7C,qFAAqF;IACrE,OAAO,EAAE,OAAO,CAAS;IACzC,kCAAkC;IAC3B,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;;IAMzD;;;;;OAKG;WACW,MAAM,CAAC,GAAG,MAAM,EAAE,cAAc,EAAE,GA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kB,EAAE,CAAC;CAC9B"}
|
package/lib/cjs/curve/Loop.js
CHANGED
|
@@ -87,7 +87,9 @@ class Loop extends CurveCollection_1.CurveChain {
|
|
|
87
87
|
}
|
|
88
88
|
/** Create a new `Loop` with no children */
|
|
89
89
|
cloneEmptyPeer() {
|
|
90
|
-
|
|
90
|
+
const emptyClone = new Loop();
|
|
91
|
+
emptyClone.isInner = this.isInner;
|
|
92
|
+
return emptyClone;
|
|
91
93
|
}
|
|
92
94
|
/** Second step of double dispatch: call `handler.handleLoop(this)` */
|
|
93
95
|
dispatchToGeometryHandler(handler) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Loop.js","sourceRoot":"","sources":["../../../src/curve/Loop.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAQ/F,+EAA4E;AAC5E,uDAA+C;AAI/C,iDAA8C;AAG9C;;;;GAIG;AACH,MAAa,IAAK,SAAQ,4BAAU;IAClC,wCAAwC;IACxB,mBAAmB,GAAG,MAAM,CAAC;IAC7C,qFAAqF;IACrE,OAAO,GAAY,KAAK,CAAC;IACzC,kCAAkC;IAC3B,mBAAmB,CAAC,KAAoB;QAC7C,OAAO,KAAK,YAAY,IAAI,CAAC;IAC/B,CAAC;IACD;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IACD;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,GAAG,MAAwB;QAC9C,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QAC1B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,KAAK,YAAY,yDAA2B;gBAC9C,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;;gBAE7C,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD;;;;;OAKG;IACI,MAAM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AAM,GAAG,KAAK,CAAC;IACtB,CAAC;IACD,uCAAuC;IAChC,IAAI,CAAC,IAAU,EAAE,KAAqB;QAC3C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;CACF;AA5BD,gDA4BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Curve\n */\nimport { GeometryHandler } from \"../geometry3d/GeometryHandler\";\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\nimport { CurveChainWithDistanceIndex } from \"./CurveChainWithDistanceIndex\";\nimport { CurveChain } from \"./CurveCollection\";\nimport { CurvePrimitive } from \"./CurvePrimitive\";\nimport { RecursiveCurveProcessor } from \"./CurveProcessor\";\nimport { GeometryQuery } from \"./GeometryQuery\";\nimport { LineString3d } from \"./LineString3d\";\nimport { StrokeOptions } from \"./StrokeOptions\";\n\n/**\n * A `Loop` is a curve chain that is the boundary of a closed (planar) loop.\n * @see [Curve Collections]($docs/learning/geometry/CurveCollection.md) learning article.\n * @public\n */\nexport class Loop extends CurveChain {\n /** String name for schema properties */\n public readonly curveCollectionType = \"loop\";\n /** Tag value that can be set to true for user code to mark inner and outer loops. */\n public override isInner: boolean = false;\n /** Test if `other` is a `Loop` */\n public isSameGeometryClass(other: GeometryQuery): boolean {\n return other instanceof Loop;\n }\n public constructor() {\n super();\n }\n /**\n * Create a loop from a variable length list of [[CurvePrimitive]]s.\n * * A significant gap between the end of one curve and the start of the next, or between chain start and end,\n * is not bridged and may cause unexpected behavior.\n * @param curves array of individual curve primitives, assumed to form a closed planar loop.\n */\n public static create(...curves: CurvePrimitive[]): Loop {\n const result = new Loop();\n for (const curve of curves) {\n if (curve instanceof CurveChainWithDistanceIndex)\n result.children.push(...curve.path.children);\n else\n result.children.push(curve);\n }\n return result;\n }\n /**\n * Create a loop from an array of [[CurvePrimitive]]s.\n * * A significant gap between the end of one curve and the start of the next, or between chain start and end,\n * is not bridged and may cause unexpected behavior.\n * @param curves array of individual curve primitives, assumed to form a closed planar loop.\n */\n public static createArray(curves: CurvePrimitive[]): Loop {\n return this.create(...curves);\n }\n /**\n * Create a loop from an array of coplanar points.\n * @param points vertices of polygon, closure point optional.\n */\n public static createPolygon(points: IndexedXYZCollection | Point3d[]): Loop {\n const linestring = LineString3d.create(points);\n linestring.addClosurePoint();\n return Loop.create(linestring);\n }\n /** Create a loop with the stroked form of this loop. */\n public cloneStroked(options?: StrokeOptions): Loop {\n const strokes = LineString3d.create();\n for (const curve of this.children)\n curve.emitStrokes(strokes, options);\n // eliminate near-duplicate points between children\n strokes.removeDuplicatePoints();\n if (strokes.isPhysicallyClosed) {\n strokes.popPoint();\n strokes.addClosurePoint();\n }\n return Loop.create(strokes);\n }\n /** Return the boundary type (2) of a corresponding MicroStation CurveVector */\n public dgnBoundaryType(): number {\n /**\n * All \"Loop\" become \"outer\". TypeScript Loop object is equivalent to a native CurveVector with\n * boundaryType = BOUNDARY_TYPE_Outer. In other words, TypeScript has no flavor of Loop that\n * carries \"hole\" semantics.\n */\n return 2;\n }\n /** Invoke `processor.announceLoop(this, indexInParent)` */\n public announceToCurveProcessor(processor: RecursiveCurveProcessor, indexInParent: number = -1): void {\n return processor.announceLoop(this, indexInParent);\n }\n /** Create a new `Loop` with no children */\n public cloneEmptyPeer(): Loop {\n const emptyClone = new Loop();\n emptyClone.isInner = this.isInner;\n return emptyClone;\n }\n /** Second step of double dispatch: call `handler.handleLoop(this)` */\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\n return handler.handleLoop(this);\n }\n}\n\n/**\n * Structure carrying a pair of loops with curve geometry.\n * @public\n */\nexport class LoopCurveLoopCurve {\n /** First loop */\n public loopA?: Loop;\n /** A curve (typically an edge of loopA) */\n public curveA?: CurvePrimitive;\n /** second loop */\n public loopB?: Loop;\n /** A curve (typically an edge of loopB) */\n public curveB?: CurvePrimitive;\n /** Constructor */\n public constructor(\n loopA: Loop | undefined, curveA: CurvePrimitive | undefined, loopB: Loop | undefined, curveB: CurvePrimitive | undefined,\n ) {\n this.loopA = loopA;\n this.curveA = curveA;\n this.loopB = loopB;\n this.curveB = curveB;\n }\n /** Set the loopA and curveA members */\n public setA(loop: Loop, curve: CurvePrimitive) {\n this.loopA = loop;\n this.curveA = curve;\n }\n /** Set the loopB and curveB members */\n public setB(loop: Loop, curve: CurvePrimitive) {\n this.loopB = loop;\n this.curveB = curve;\n }\n}\n\n/**\n * Carrier object for loops characterized by area sign\n * @public\n */\nexport interface SignedLoops {\n /** Array of loops that have positive area sign (i.e. counterclockwise loops). */\n positiveAreaLoops: Loop[];\n /** Array of loops that have negative area sign (i.e. clockwise loops). */\n negativeAreaLoops: Loop[];\n /** Slivers where there are coincident sections of input curves. */\n slivers: Loop[];\n /** Array indicating edges between loops */\n edges?: LoopCurveLoopCurve[];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClosestPointStrokeHandler.js","sourceRoot":"","sources":["../../../../src/curve/internalContexts/ClosestPointStrokeHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,6CAA0C;AAE1C,sEAAqE;AACrE,kDAA+C;AAC/C,kDAAwG;AACxG,4DAAyD;AACzD,wDAAsG;AACtG,gEAA6D;AAG7D;;;GAGG;AACH,MAAa,yBAA0B,SAAQ,gCAAuB;IAC5D,MAAM,CAA6B;IACnC,aAAa,CAAkC;IAC/C,WAAW,CAAU;IACrB,OAAO,CAA8B;IACrC,OAAO,CAAU;IACzB,iFAAiF;IACzE,UAAU,GAAW,CAAC,CAAC;IACvB,UAAU,GAAW,CAAC,CAAC;IAC/B,uFAAuF;IAC/E,UAAU,GAAW,CAAC,CAAC;IAC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,CAAC;QAC1C,IAAA,qBAAM,EAAC,KAAK,KAAK,SAAS,EAAE,iFAAiF,CAAC,CAAC;QAC/G,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC;QAC3B,IAAI,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,EAAE,oFAAoF;YAChH,IAAI,CAAC,cAAc,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACpC,CAAC;IACM,oBAAoB,CAAC,KAAc,EAAE,QAAgB,EAAE,OAAiB;QAC7E,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAClC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;CACF;AAvKD,8DAuKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Curve\n */\n\nimport { assert } from \"@itwin/core-bentley\";\nimport { Geometry } from \"../../Geometry\";\nimport { IStrokeHandler } from \"../../geometry3d/GeometryHandler\";\nimport { Point3d, Vector3d } from \"../../geometry3d/Point3dVector3d\";\nimport { Ray3d } from \"../../geometry3d/Ray3d\";\nimport { Newton1dUnboundedApproximateDerivative, NewtonRtoRStrokeHandler } from \"../../numerics/Newton\";\nimport { SmallSystem } from \"../../numerics/SmallSystem\";\nimport { CurveExtendMode, CurveExtendOptions, VariantCurveExtendParameter } from \"../CurveExtendMode\";\nimport { CurveLocationDetail } from \"../CurveLocationDetail\";\nimport { CurvePrimitive } from \"../CurvePrimitive\";\n\n/**\n * Context for searching for the closest point to a CurvePrimitive.\n * @internal\n */\nexport class ClosestPointStrokeHandler extends NewtonRtoRStrokeHandler implements IStrokeHandler {\n private _curve: CurvePrimitive | undefined;\n private _closestPoint: CurveLocationDetail | undefined;\n private _spacePoint: Point3d;\n private _extend: VariantCurveExtendParameter;\n private _xyOnly: boolean;\n // fraction and function value on one side of an interval that may bracket a root\n private _fractionA: number = 0;\n private _functionA: number = 0;\n // fraction and function value on the other side of an interval that may bracket a root\n private _fractionB: number = 0;\n private _functionB: number = 0;\n private _numThisCurve: number = 0;\n // scratch vars to use within methods\n private _workPoint: Point3d;\n private _workRay: Ray3d;\n private _newtonSolver: Newton1dUnboundedApproximateDerivative;\n /** Constructor */\n public constructor(spacePoint: Point3d, extend?: VariantCurveExtendParameter, result?: CurveLocationDetail, xyOnly?: boolean) {\n super();\n this._spacePoint = spacePoint;\n this._workPoint = Point3d.create();\n this._workRay = Ray3d.createZero();\n this._closestPoint = result;\n if (this._closestPoint)\n this._closestPoint.a = Geometry.largeCoordinateResult\n this._extend = extend ?? false;\n this._xyOnly = xyOnly ?? false;\n this.startCurvePrimitive(undefined);\n this._newtonSolver = new Newton1dUnboundedApproximateDerivative(this);\n }\n public claimResult(): CurveLocationDetail | undefined {\n if (this._closestPoint) {\n this._newtonSolver.setX(this._closestPoint.fraction);\n this._curve = this._closestPoint.curve;\n if (this._newtonSolver.runIterations()) {\n let fraction = this._newtonSolver.getX();\n fraction = CurveExtendOptions.correctFraction(this._extend, fraction);\n this.announceSolutionFraction(fraction);\n }\n }\n return this._closestPoint;\n }\n public needPrimaryGeometryForStrokes() {\n return true;\n }\n public startCurvePrimitive(curve: CurvePrimitive | undefined) {\n this._curve = curve;\n this._fractionA = 0.0;\n this._numThisCurve = 0;\n this._functionA = 0.0;\n }\n public endCurvePrimitive() {\n }\n public announceIntervalForUniformStepStrokes(\n cp: CurvePrimitive, numStrokes: number, fraction0: number, fraction1: number,\n ): void {\n this.startCurvePrimitive(cp);\n this.announceSolutionFraction(0.0); // test start point as closest\n this.announceSolutionFraction(1.0); // test end point as closest\n if (numStrokes < 1)\n numStrokes = 1;\n const df = 1.0 / numStrokes;\n for (let i = 0; i <= numStrokes; i++) {\n const fraction = Geometry.interpolate(fraction0, i * df, fraction1);\n cp.fractionToPointAndDerivative(fraction, this._workRay);\n this.announceRay(fraction, this._workRay);\n }\n }\n private announceCandidate(cp: CurvePrimitive, fraction: number, point: Point3d) {\n const distance = this._xyOnly ? this._spacePoint.distanceXY(point) : this._spacePoint.distance(point);\n if (this._closestPoint && distance > this._closestPoint.a)\n return;\n this._closestPoint = CurveLocationDetail.createCurveFractionPoint(cp, fraction, point, this._closestPoint);\n this._closestPoint.a = distance;\n if (this._parentCurvePrimitive !== undefined)\n this._closestPoint.curve = this._parentCurvePrimitive;\n }\n public announceSegmentInterval(\n cp: CurvePrimitive, point0: Point3d, point1: Point3d, _numStrokes: number, fraction0: number, fraction1: number,\n ): void {\n let localFraction = 0;\n if (this._xyOnly)\n localFraction = SmallSystem.lineSegment3dXYClosestPointUnbounded(point0, point1, this._spacePoint) ?? 0;\n else\n localFraction = this._spacePoint.fractionOfProjectionToLine(point0, point1, 0.0);\n // only consider segment extension at a parent curve endpoint, i.e. when fraction0 is 0 or fraction1 is 1\n const extend0 = (fraction0 === 0) ? CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(this._extend, 0) : CurveExtendMode.None;\n const extend1 = (fraction1 === 1) ? CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(this._extend, 1) : CurveExtendMode.None;\n localFraction = CurveExtendOptions.correctFraction([extend0, extend1], localFraction);\n this._workPoint = point0.interpolate(localFraction, point1);\n const globalFraction = Geometry.interpolate(fraction0, localFraction, fraction1);\n this.announceCandidate(cp, globalFraction, this._workPoint);\n }\n /**\n * Given a function `f` and (unordered) fractions `a` and `b`, search for and announce a root of `f` in this\n * fractional interval.\n * * This method searches for a root of `f` if and only if the stroke segment defined by `(a, f(a))` and\n * `(b, f(b))` has a root. This is a HEURISTIC: given continuous `f` between `a` and `b`, a root of the stroke\n * segment implies a root of `f`, but not vice-versa. Therefore, if the strokes are not sufficiently dense,\n * this method can miss a root of `f`.\n */\n private searchInterval() {\n if (this._functionA * this._functionB > 0)\n return; // stroke segment has no root; ASSUME the function has no root either\n if (this._functionA === 0)\n this.announceSolutionFraction(this._fractionA);\n if (this._functionB === 0)\n this.announceSolutionFraction(this._fractionB);\n // by the Intermediate Value Theorem, a root lies between fractionA and fractionB; use Newton to find it.\n if (this._functionA * this._functionB < 0) {\n const fraction = Geometry.inverseInterpolate(this._fractionA, this._functionA, this._fractionB, this._functionB);\n if (fraction) {\n this._newtonSolver.setX(fraction);\n if (this._newtonSolver.runIterations())\n this.announceSolutionFraction(this._newtonSolver.getX());\n }\n }\n }\n private announceSolutionFraction(fraction: number) {\n if (this._curve)\n this.announceCandidate(this._curve, fraction, this._curve.fractionToPoint(fraction));\n }\n /**\n * Evaluate the univariate real-valued function for which we are finding roots.\n * * For finding the closest point to curve X from point Q, this function is `f(t) := Q-X(t) dot X'(t)`.\n * * Either `pointAndDerivative` must be defined, or both `fraction` and `curve`.\n * @param pointAndDerivative pre-evaluated curve\n * @param fraction fraction at which to evaluate `curve`\n * @param curve curve to evaluate at `fraction`\n */\n private evaluateFunction(pointAndDerivative?: Ray3d, fraction?: number, curve?: CurvePrimitive): number | undefined {\n if (pointAndDerivative)\n this._workRay.setFrom(pointAndDerivative);\n else if (fraction !== undefined && curve)\n this._workRay = curve.fractionToPointAndDerivative(fraction, this._workRay);\n else\n return undefined;\n if (this._xyOnly)\n return this._workRay.dotProductToPointXY(this._spacePoint);\n else\n return this._workRay.dotProductToPoint(this._spacePoint);\n }\n public evaluate(fraction: number): boolean {\n let curve = this._curve;\n if (this._parentCurvePrimitive)\n curve = this._parentCurvePrimitive;\n const value = this.evaluateFunction(undefined, fraction, curve);\n if (value === undefined)\n return false;\n this.currentF = value;\n return true;\n }\n private announceRay(fraction: number, data: Ray3d): void {\n const value = this.evaluateFunction(data);\n assert(value !== undefined, \"expect defined because evaluateFunction never returns undefined for input Ray3d\");\n this._functionB = value;\n this._fractionB = fraction;\n if (this._numThisCurve++ > 0) // after the first stroke point, a stroke segment is defined, so we have an interval\n this.searchInterval();\n this._functionA = this._functionB;\n this._fractionA = this._fractionB;\n }\n public announcePointTangent(point: Point3d, fraction: number, tangent: Vector3d) {\n this._workRay.set(point, tangent);\n this.announceRay(fraction, this._workRay);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ClosestPointStrokeHandler.js","sourceRoot":"","sources":["../../../../src/curve/internalContexts/ClosestPointStrokeHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,6CAA0C;AAE1C,sEAAqE;AACrE,kDAA+C;AAC/C,kDAAwG;AACxG,4DAAyD;AACzD,wDAAsG;AACtG,gEAA6D;AAG7D;;;GAGG;AACH,MAAa,yBAA0B,SAAQ,gCAAuB;IAC5D,MAAM,CAA6B;IACnC,aAAa,CAAkC;IAC/C,WAAW,CAAU;IACrB,OAAO,CAA8B;IACrC,OAAO,CAAU;IACzB,iFAAiF;IACzE,UAAU,GAAW,CAAC,CAAC;IACvB,UAAU,GAAW,CAAC,CAAC;IAC/B,uFAAuF;IAC/E,UAAU,GAAW,CAAC,CAAC;IACvB,UAAU,GAAW,CAAC,CAAC;IACvB,aAAa,GAAW,CAAC,CAAC;IAClC,qCAAqC;IAC7B,UAAU,CAAU;IACpB,QAAQ,CAAQ;IAChB,aAAa,CAAyC;IAC9D,kBAAkB;IAClB,YAAmB,UAAmB,EAAE,MAAoC,EAAE,MAA4B,EAAE,MAAgB;QAC1H,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,aAAK,CAAC,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;QAC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,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAClC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;CACF;AAvKD,8DAuKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Curve\n */\n\nimport { assert } from \"@itwin/core-bentley\";\nimport { Geometry } from \"../../Geometry\";\nimport { IStrokeHandler } from \"../../geometry3d/GeometryHandler\";\nimport { Point3d, Vector3d } from \"../../geometry3d/Point3dVector3d\";\nimport { Ray3d } from \"../../geometry3d/Ray3d\";\nimport { Newton1dUnboundedApproximateDerivative, NewtonRtoRStrokeHandler } from \"../../numerics/Newton\";\nimport { SmallSystem } from \"../../numerics/SmallSystem\";\nimport { CurveExtendMode, CurveExtendOptions, VariantCurveExtendParameter } from \"../CurveExtendMode\";\nimport { CurveLocationDetail } from \"../CurveLocationDetail\";\nimport { CurvePrimitive } from \"../CurvePrimitive\";\n\n/**\n * Context for searching for the closest point to a CurvePrimitive.\n * @internal\n */\nexport class ClosestPointStrokeHandler extends NewtonRtoRStrokeHandler implements IStrokeHandler {\n private _curve: CurvePrimitive | undefined;\n private _closestPoint: CurveLocationDetail | undefined;\n private _spacePoint: Point3d;\n private _extend: VariantCurveExtendParameter;\n private _xyOnly: boolean;\n // fraction and function value on one side of an interval that may bracket a root\n private _fractionA: number = 0;\n private _functionA: number = 0;\n // fraction and function value on the other side of an interval that may bracket a root\n private _fractionB: number = 0;\n private _functionB: number = 0;\n private _numThisCurve: number = 0;\n // scratch vars to use within methods\n private _workPoint: Point3d;\n private _workRay: Ray3d;\n private _newtonSolver: Newton1dUnboundedApproximateDerivative;\n /** Constructor */\n public constructor(spacePoint: Point3d, extend?: VariantCurveExtendParameter, result?: CurveLocationDetail, xyOnly?: boolean) {\n super();\n this._spacePoint = spacePoint;\n this._workPoint = Point3d.create();\n this._workRay = Ray3d.createZero();\n this._closestPoint = result;\n if (this._closestPoint)\n this._closestPoint.a = Geometry.largeCoordinateResult;\n this._extend = extend ?? false;\n this._xyOnly = xyOnly ?? false;\n this.startCurvePrimitive(undefined);\n this._newtonSolver = new Newton1dUnboundedApproximateDerivative(this);\n }\n public claimResult(): CurveLocationDetail | undefined {\n if (this._closestPoint) {\n this._newtonSolver.setX(this._closestPoint.fraction);\n this._curve = this._closestPoint.curve;\n if (this._newtonSolver.runIterations()) {\n let fraction = this._newtonSolver.getX();\n fraction = CurveExtendOptions.correctFraction(this._extend, fraction);\n this.announceSolutionFraction(fraction);\n }\n }\n return this._closestPoint;\n }\n public needPrimaryGeometryForStrokes() {\n return true;\n }\n public startCurvePrimitive(curve: CurvePrimitive | undefined) {\n this._curve = curve;\n this._fractionA = 0.0;\n this._numThisCurve = 0;\n this._functionA = 0.0;\n }\n public endCurvePrimitive() {\n }\n public announceIntervalForUniformStepStrokes(\n cp: CurvePrimitive, numStrokes: number, fraction0: number, fraction1: number,\n ): void {\n this.startCurvePrimitive(cp);\n this.announceSolutionFraction(0.0); // test start point as closest\n this.announceSolutionFraction(1.0); // test end point as closest\n if (numStrokes < 1)\n numStrokes = 1;\n const df = 1.0 / numStrokes;\n for (let i = 0; i <= numStrokes; i++) {\n const fraction = Geometry.interpolate(fraction0, i * df, fraction1);\n cp.fractionToPointAndDerivative(fraction, this._workRay);\n this.announceRay(fraction, this._workRay);\n }\n }\n private announceCandidate(cp: CurvePrimitive, fraction: number, point: Point3d) {\n const distance = this._xyOnly ? this._spacePoint.distanceXY(point) : this._spacePoint.distance(point);\n if (this._closestPoint && distance > this._closestPoint.a)\n return;\n this._closestPoint = CurveLocationDetail.createCurveFractionPoint(cp, fraction, point, this._closestPoint);\n this._closestPoint.a = distance;\n if (this._parentCurvePrimitive !== undefined)\n this._closestPoint.curve = this._parentCurvePrimitive;\n }\n public announceSegmentInterval(\n cp: CurvePrimitive, point0: Point3d, point1: Point3d, _numStrokes: number, fraction0: number, fraction1: number,\n ): void {\n let localFraction = 0;\n if (this._xyOnly)\n localFraction = SmallSystem.lineSegment3dXYClosestPointUnbounded(point0, point1, this._spacePoint) ?? 0;\n else\n localFraction = this._spacePoint.fractionOfProjectionToLine(point0, point1, 0.0);\n // only consider segment extension at a parent curve endpoint, i.e. when fraction0 is 0 or fraction1 is 1\n const extend0 = (fraction0 === 0) ? CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(this._extend, 0) : CurveExtendMode.None;\n const extend1 = (fraction1 === 1) ? CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(this._extend, 1) : CurveExtendMode.None;\n localFraction = CurveExtendOptions.correctFraction([extend0, extend1], localFraction);\n this._workPoint = point0.interpolate(localFraction, point1);\n const globalFraction = Geometry.interpolate(fraction0, localFraction, fraction1);\n this.announceCandidate(cp, globalFraction, this._workPoint);\n }\n /**\n * Given a function `f` and (unordered) fractions `a` and `b`, search for and announce a root of `f` in this\n * fractional interval.\n * * This method searches for a root of `f` if and only if the stroke segment defined by `(a, f(a))` and\n * `(b, f(b))` has a root. This is a HEURISTIC: given continuous `f` between `a` and `b`, a root of the stroke\n * segment implies a root of `f`, but not vice-versa. Therefore, if the strokes are not sufficiently dense,\n * this method can miss a root of `f`.\n */\n private searchInterval() {\n if (this._functionA * this._functionB > 0)\n return; // stroke segment has no root; ASSUME the function has no root either\n if (this._functionA === 0)\n this.announceSolutionFraction(this._fractionA);\n if (this._functionB === 0)\n this.announceSolutionFraction(this._fractionB);\n // by the Intermediate Value Theorem, a root lies between fractionA and fractionB; use Newton to find it.\n if (this._functionA * this._functionB < 0) {\n const fraction = Geometry.inverseInterpolate(this._fractionA, this._functionA, this._fractionB, this._functionB);\n if (fraction) {\n this._newtonSolver.setX(fraction);\n if (this._newtonSolver.runIterations())\n this.announceSolutionFraction(this._newtonSolver.getX());\n }\n }\n }\n private announceSolutionFraction(fraction: number) {\n if (this._curve)\n this.announceCandidate(this._curve, fraction, this._curve.fractionToPoint(fraction));\n }\n /**\n * Evaluate the univariate real-valued function for which we are finding roots.\n * * For finding the closest point to curve X from point Q, this function is `f(t) := Q-X(t) dot X'(t)`.\n * * Either `pointAndDerivative` must be defined, or both `fraction` and `curve`.\n * @param pointAndDerivative pre-evaluated curve\n * @param fraction fraction at which to evaluate `curve`\n * @param curve curve to evaluate at `fraction`\n */\n private evaluateFunction(pointAndDerivative?: Ray3d, fraction?: number, curve?: CurvePrimitive): number | undefined {\n if (pointAndDerivative)\n this._workRay.setFrom(pointAndDerivative);\n else if (fraction !== undefined && curve)\n this._workRay = curve.fractionToPointAndDerivative(fraction, this._workRay);\n else\n return undefined;\n if (this._xyOnly)\n return this._workRay.dotProductToPointXY(this._spacePoint);\n else\n return this._workRay.dotProductToPoint(this._spacePoint);\n }\n public evaluate(fraction: number): boolean {\n let curve = this._curve;\n if (this._parentCurvePrimitive)\n curve = this._parentCurvePrimitive;\n const value = this.evaluateFunction(undefined, fraction, curve);\n if (value === undefined)\n return false;\n this.currentF = value;\n return true;\n }\n private announceRay(fraction: number, data: Ray3d): void {\n const value = this.evaluateFunction(data);\n assert(value !== undefined, \"expect defined because evaluateFunction never returns undefined for input Ray3d\");\n this._functionB = value;\n this._fractionB = fraction;\n if (this._numThisCurve++ > 0) // after the first stroke point, a stroke segment is defined, so we have an interval\n this.searchInterval();\n this._functionA = this._functionB;\n this._fractionA = this._fractionB;\n }\n public announcePointTangent(point: Point3d, fraction: number, tangent: Vector3d) {\n this._workRay.set(point, tangent);\n this.announceRay(fraction, this._workRay);\n }\n}\n"]}
|
|
@@ -167,14 +167,6 @@ export declare class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHa
|
|
|
167
167
|
allPerpendicularsArcArcBounded(arcA: Arc3d, arcB: Arc3d, reversed?: boolean): void;
|
|
168
168
|
/** Low level dispatch of arc with Arc3d. */
|
|
169
169
|
private dispatchArcArc;
|
|
170
|
-
/** Low level dispatch of arc with (beziers of) a bspline curve */
|
|
171
|
-
private dispatchArcBsplineCurve3d;
|
|
172
|
-
/** Low level dispatch of (beziers of) a bspline curve with (beziers of) a bspline curve */
|
|
173
|
-
private dispatchBSplineCurve3dBSplineCurve3d;
|
|
174
|
-
/** Low level dispatch of linestring with (beziers of) a bspline curve */
|
|
175
|
-
private dispatchLineStringBSplineCurve;
|
|
176
|
-
/** Low level dispatch of segment with (beziers of) a bspline curve */
|
|
177
|
-
private dispatchSegmentBsplineCurve;
|
|
178
170
|
/** Detail computation for segment approaching linestring. */
|
|
179
171
|
private computeSegmentLineString;
|
|
180
172
|
/** Detail computation for arc approaching linestring. */
|
|
@@ -202,23 +194,17 @@ export declare class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHa
|
|
|
202
194
|
private dispatchCurveCollection;
|
|
203
195
|
/** Low level dispatch to geomA given a CurveChainWithDistanceIndex in geometryB. */
|
|
204
196
|
private dispatchCurveChainWithDistanceIndex;
|
|
205
|
-
/**
|
|
206
|
-
|
|
207
|
-
/** Double dispatch handler for strongly typed linestring. */
|
|
208
|
-
handleLineString3d(lsA: LineString3d): any;
|
|
209
|
-
/** Double dispatch handler for strongly typed arc. */
|
|
210
|
-
handleArc3d(arcA: Arc3d): any;
|
|
211
|
-
/** Double dispatch handler for strongly typed bspline curve. */
|
|
212
|
-
handleBSplineCurve3d(curveA: BSplineCurve3d): any;
|
|
197
|
+
/** Specifies whether the curve needs to be stroked for close approach computation. */
|
|
198
|
+
private needsStroking;
|
|
213
199
|
/**
|
|
214
|
-
* Process seeds for xy close approach between
|
|
200
|
+
* Process seeds for xy close approach between one curve and another curve to be stroked.
|
|
215
201
|
* * Refine each result via Newton iteration. If it doesn't converge, remove it.
|
|
216
|
-
* @param seeds
|
|
217
|
-
* @param curveA
|
|
218
|
-
* @param
|
|
219
|
-
* @param reversed whether `
|
|
202
|
+
* @param seeds the initial seed results to refine.
|
|
203
|
+
* @param curveA curve to find its XY close approach with curveB.
|
|
204
|
+
* @param curveB the other curve to be stroked.
|
|
205
|
+
* @param reversed whether `curveB` data is in `detailA` of each recorded pair, and `curveA` data in `detailB`.
|
|
220
206
|
*/
|
|
221
|
-
private
|
|
207
|
+
private refineStrokedResultsByNewton;
|
|
222
208
|
/**
|
|
223
209
|
* Append stroke points and return the line string.
|
|
224
210
|
* * This is a convenient wrapper for [[CurvePrimitive.emitStrokes]] but the analogous instance method cannot be added
|
|
@@ -230,12 +216,20 @@ export declare class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHa
|
|
|
230
216
|
/** Find and return the close approaches between curveA and the discretization of curveB. */
|
|
231
217
|
private computeDiscreteCloseApproachResults;
|
|
232
218
|
/**
|
|
233
|
-
* Compute the XY close approach of a curve and
|
|
234
|
-
* @param curveA curve to find its close approach with
|
|
235
|
-
* @param
|
|
236
|
-
* @param reversed whether `
|
|
219
|
+
* Compute the XY close approach of a curve and another curve to be stroked.
|
|
220
|
+
* @param curveA curve to find its XY close approach with curveB.
|
|
221
|
+
* @param curveB the other curve to be stroked.
|
|
222
|
+
* @param reversed whether `curveB` data will be recorded in `detailA` of each result, and `curveA` data in `detailB`.
|
|
237
223
|
*/
|
|
238
|
-
private
|
|
224
|
+
private dispatchCurveStrokedCurve;
|
|
225
|
+
/** Double dispatch handler for strongly typed segment. */
|
|
226
|
+
handleLineSegment3d(segmentA: LineSegment3d): any;
|
|
227
|
+
/** Double dispatch handler for strongly typed linestring. */
|
|
228
|
+
handleLineString3d(lsA: LineString3d): any;
|
|
229
|
+
/** Double dispatch handler for strongly typed arc. */
|
|
230
|
+
handleArc3d(arcA: Arc3d): any;
|
|
231
|
+
/** Double dispatch handler for strongly typed bspline curve. */
|
|
232
|
+
handleBSplineCurve3d(curveA: BSplineCurve3d): any;
|
|
239
233
|
/** Double dispatch handler for strongly typed spiral curve. */
|
|
240
234
|
handleTransitionSpiral(spiral: TransitionSpiral3d): any;
|
|
241
235
|
/** Double dispatch handler for strongly typed CurveChainWithDistanceIndex. */
|
|
@@ -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;;;;;;;;;;;;;GAaG;AACH,qBAAa,yBAA0B,SAAQ,8BAA8B;IAC3E,OAAO,CAAC,UAAU,CAAuB;IACzC;;;OAGG;IACH,OAAO,CAAC,oBAAoB,CAAqB;IACjD,gFAAgF;IAChF,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,gBAAgB,CAAS;IACjC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAuC;IAEvD,OAAO,CAAC,MAAM,CAAC,aAAa,CAAoB;IAChD,OAAO,CAAC,MAAM,CAAC,aAAa,CAAoB;IAChD,OAAO,CAAC,MAAM,CAAC,aAAa,CAAoB;IAChD,OAAO,CAAC,MAAM,CAAC,aAAa,CAAoB;IAChD,OAAO,CAAC,MAAM,CAAC,WAAW,CAAoB;IAE9C;;;;;OAKG;gBACgB,SAAS,CAAC,EAAE,QAAQ,EAAE,WAAW,GAAE,MAAqC,EAAE,eAAe,GAAE,MAAiC;IAS/I,6EAA6E;IAC7E,IAAW,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAQvD;IACD,gFAAgF;IAChF,IAAW,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAEnD;IACD,mEAAmE;IACnE,IAAW,gBAAgB,IAAI,OAAO,CAErC;IACD;;;;OAIG;IACI,aAAa,CAAC,SAAS,CAAC,EAAE,QAAQ;IAIzC,8DAA8D;IAC9D,OAAO,CAAC,cAAc;IAOtB,0FAA0F;IACnF,iBAAiB,IAAI,uBAAuB,EAAE;IAGrD;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,sBAAsB;IAsB9B;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IAYzB;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,sBAAsB;IAsB9B,oEAAoE;IACpE,OAAO,CAAC,MAAM,CAAC,4BAA4B;IAoB3C;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,MAAM,CAAC,6BAA6B;IA2D5C;;;;;;OAMG;IACH,OAAO,CAAC,+BAA+B;IAavC,+DAA+D;IAC/D,OAAO,CAAC,uBAAuB;IAK/B;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAgB7B;;;;;;;;OAQG;IACH,OAAO,CAAC,0CAA0C;IAiBlD;;;;;;;;;OASG;IACH,OAAO,CAAC,iBAAiB;IA0CzB;;;;;;;OAOG;IACI,8BAA8B,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,GAAE,OAAe,GAAG,IAAI;IAmBhG,4CAA4C;IAC5C,OAAO,CAAC,cAAc;IAYtB,
|
|
1
|
+
{"version":3,"file":"CurveCurveCloseApproachXY.d.ts","sourceRoot":"","sources":["../../../../src/curve/internalContexts/CurveCurveCloseApproachXY.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAA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BAA4B;IAkBpC;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAKnB,4FAA4F;IAC5F,OAAO,CAAC,mCAAmC;IAkB3C;;;;;OAKG;IACH,OAAO,CAAC,yBAAyB;IAoBjC,0DAA0D;IAC1C,mBAAmB,CAAC,QAAQ,EAAE,aAAa,GAAG,GAAG;IAqBjE,6DAA6D;IAC7C,kBAAkB,CAAC,GAAG,EAAE,YAAY,GAAG,GAAG;IAgB1D,sDAAsD;IACtC,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,GAAG;IAgB7C,gEAAgE;IAChD,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,GAAG;IAUjE,+DAA+D;IAC/C,sBAAsB,CAAC,MAAM,EAAE,kBAAkB,GAAG,GAAG;IAUvE,8EAA8E;IAC9D,iCAAiC,CAAC,KAAK,EAAE,2BAA2B,GAAG,GAAG;IAS1F,8EAA8E;IAC9D,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,GAAG;CAIpE"}
|
|
@@ -434,32 +434,6 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
434
434
|
// 2) perpendicular line between 2 arcs (includes intersections)
|
|
435
435
|
this.allPerpendicularsArcArcBounded(cpA, cpB, reversed);
|
|
436
436
|
}
|
|
437
|
-
/** Low level dispatch of arc with (beziers of) a bspline curve */
|
|
438
|
-
dispatchArcBsplineCurve3d(cpA, cpB, reversed) {
|
|
439
|
-
const ls = LineString3d_1.LineString3d.create();
|
|
440
|
-
cpB.emitStrokes(ls);
|
|
441
|
-
this.computeArcLineString(cpA, ls, reversed);
|
|
442
|
-
}
|
|
443
|
-
/** Low level dispatch of (beziers of) a bspline curve with (beziers of) a bspline curve */
|
|
444
|
-
dispatchBSplineCurve3dBSplineCurve3d(bcurveA, bcurveB, reversed) {
|
|
445
|
-
const lsA = LineString3d_1.LineString3d.create();
|
|
446
|
-
bcurveA.emitStrokes(lsA);
|
|
447
|
-
const lsB = LineString3d_1.LineString3d.create();
|
|
448
|
-
bcurveB.emitStrokes(lsB);
|
|
449
|
-
this.computeLineStringLineString(lsA, lsB, reversed);
|
|
450
|
-
}
|
|
451
|
-
/** Low level dispatch of linestring with (beziers of) a bspline curve */
|
|
452
|
-
dispatchLineStringBSplineCurve(lsA, curveB, reversed) {
|
|
453
|
-
const lsB = LineString3d_1.LineString3d.create();
|
|
454
|
-
curveB.emitStrokes(lsB);
|
|
455
|
-
this.computeLineStringLineString(lsA, lsB, reversed);
|
|
456
|
-
}
|
|
457
|
-
/** Low level dispatch of segment with (beziers of) a bspline curve */
|
|
458
|
-
dispatchSegmentBsplineCurve(segA, curveB, reversed) {
|
|
459
|
-
const lsB = LineString3d_1.LineString3d.create();
|
|
460
|
-
curveB.emitStrokes(lsB);
|
|
461
|
-
this.computeSegmentLineString(segA, lsB, reversed);
|
|
462
|
-
}
|
|
463
437
|
/** Detail computation for segment approaching linestring. */
|
|
464
438
|
computeSegmentLineString(segA, lsB, reversed) {
|
|
465
439
|
const numB = lsB.numPoints();
|
|
@@ -615,6 +589,91 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
615
589
|
});
|
|
616
590
|
saveResults.forEach((pair) => this._results.insert(pair));
|
|
617
591
|
}
|
|
592
|
+
/** Specifies whether the curve needs to be stroked for close approach computation. */
|
|
593
|
+
needsStroking(curve) {
|
|
594
|
+
return curve instanceof BSplineCurve_1.BSplineCurve3dBase || curve instanceof TransitionSpiral3d_1.TransitionSpiral3d;
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Process seeds for xy close approach between one curve and another curve to be stroked.
|
|
598
|
+
* * Refine each result via Newton iteration. If it doesn't converge, remove it.
|
|
599
|
+
* @param seeds the initial seed results to refine.
|
|
600
|
+
* @param curveA curve to find its XY close approach with curveB.
|
|
601
|
+
* @param curveB the other curve to be stroked.
|
|
602
|
+
* @param reversed whether `curveB` data is in `detailA` of each recorded pair, and `curveA` data in `detailB`.
|
|
603
|
+
*/
|
|
604
|
+
refineStrokedResultsByNewton(seeds, curveA, curveB, reversed = false) {
|
|
605
|
+
const xyMatchingFunction = new Newton_1.CurveCurveCloseApproachXYRRtoRRD(curveA, curveB);
|
|
606
|
+
const newtonSearcher = new Newton_1.Newton2dUnboundedWithDerivative(xyMatchingFunction, 50, this._newtonTolerance); // seen: 47
|
|
607
|
+
for (const seed of seeds) {
|
|
608
|
+
const detailA = reversed ? seed.detailB : seed.detailA;
|
|
609
|
+
const detailB = reversed ? seed.detailA : seed.detailB;
|
|
610
|
+
(0, core_bentley_1.assert)(detailB.curve instanceof LineString3d_1.LineString3d, "Caller has discretized the curve");
|
|
611
|
+
newtonSearcher.setUV(detailA.fraction, detailB.fraction); // use the linestring fraction as initial curveB fraction (ASSUME it's close enough)
|
|
612
|
+
if (newtonSearcher.runIterations()) {
|
|
613
|
+
const fractionA = newtonSearcher.getU();
|
|
614
|
+
const fractionB = newtonSearcher.getV();
|
|
615
|
+
if (this.acceptFraction(fractionA) && this.acceptFraction(fractionB))
|
|
616
|
+
this.testAndRecordPointPair(curveA, fractionA, undefined, curveB, fractionB, undefined, reversed);
|
|
617
|
+
} // ignore failure to converge
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Append stroke points and return the line string.
|
|
622
|
+
* * This is a convenient wrapper for [[CurvePrimitive.emitStrokes]] but the analogous instance method cannot be added
|
|
623
|
+
* to that class due to the ensuing recursion with subclass [[LineString3d]].
|
|
624
|
+
* @param options options for stroking the instance curve.
|
|
625
|
+
* @param result object to receive appended stroke points; if omitted, a new object is created, populated, and returned.
|
|
626
|
+
*/
|
|
627
|
+
strokeCurve(curve, options, result) {
|
|
628
|
+
const ls = result ? result : LineString3d_1.LineString3d.create();
|
|
629
|
+
curve.emitStrokes(ls, options);
|
|
630
|
+
return ls;
|
|
631
|
+
}
|
|
632
|
+
/** Find and return the close approaches between curveA and the discretization of curveB. */
|
|
633
|
+
computeDiscreteCloseApproachResults(curveA, lsB, reversed) {
|
|
634
|
+
const maxDist = this.maxDistanceToAccept;
|
|
635
|
+
const saveResults = this.grabPairedResults(); // save current results
|
|
636
|
+
const geomB = this._geometryB;
|
|
637
|
+
this.maxDistanceToAccept = maxDist ? maxDist * 1.2 : undefined; // HEURISTIC: allow slack for Newton seeds
|
|
638
|
+
this.resetGeometry(curveA);
|
|
639
|
+
this.handleLineString3d(lsB); // populate empty results with discrete solutions
|
|
640
|
+
if (!reversed) {
|
|
641
|
+
// handleLineString3d put lsB data into detailA, so if we aren't reversing, we need to swap
|
|
642
|
+
for (const result of this._results)
|
|
643
|
+
result.swapDetails();
|
|
644
|
+
}
|
|
645
|
+
this.resetGeometry(geomB);
|
|
646
|
+
this.maxDistanceToAccept = maxDist;
|
|
647
|
+
const discreteResults = this._results.extractArray();
|
|
648
|
+
saveResults.forEach((pair) => this._results.insert(pair)); // restore current results
|
|
649
|
+
return discreteResults;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Compute the XY close approach of a curve and another curve to be stroked.
|
|
653
|
+
* @param curveA curve to find its XY close approach with curveB.
|
|
654
|
+
* @param curveB the other curve to be stroked.
|
|
655
|
+
* @param reversed whether `curveB` data will be recorded in `detailA` of each result, and `curveA` data in `detailB`.
|
|
656
|
+
*/
|
|
657
|
+
dispatchCurveStrokedCurve(curveA, curveB, reversed) {
|
|
658
|
+
// explicit search for intersections (Newton converges too slowly on DirectSpiral3d tangent intersections)
|
|
659
|
+
const intersections = CurveCurve_1.CurveCurve.intersectionXYPairs(curveA, false, curveB, false, this._xyTolerance);
|
|
660
|
+
for (const intersection of intersections)
|
|
661
|
+
this.testAndRecordPair(intersection, reversed);
|
|
662
|
+
// append seeds computed by solving the discretized spiral close approach problem, then refine the seeds via Newton
|
|
663
|
+
let cpA = curveA;
|
|
664
|
+
if (this.needsStroking(curveA))
|
|
665
|
+
cpA = this.strokeCurve(curveA);
|
|
666
|
+
const cpB = this.strokeCurve(curveB);
|
|
667
|
+
const seeds = this.computeDiscreteCloseApproachResults(cpA, cpB, reversed);
|
|
668
|
+
this.refineStrokedResultsByNewton(seeds, curveA, curveB, reversed);
|
|
669
|
+
if (curveA instanceof LineString3d_1.LineString3d) { // explicitly test corners (where Newton converges too slowly)
|
|
670
|
+
const fStep = Geometry_1.Geometry.safeDivideFraction(1.0, curveA.numEdges(), 0);
|
|
671
|
+
const v0 = CurveCurveCloseApproachXY._workPointBB0;
|
|
672
|
+
for (let i = 1; i < curveA.numEdges(); ++i)
|
|
673
|
+
this.testAndRecordProjection(curveA, i * fStep, curveA.pointAtUnchecked(i, v0), curveB, reversed);
|
|
674
|
+
}
|
|
675
|
+
this.testAndRecordEndPointApproaches(curveA, curveB, reversed);
|
|
676
|
+
}
|
|
618
677
|
/** Double dispatch handler for strongly typed segment. */
|
|
619
678
|
handleLineSegment3d(segmentA) {
|
|
620
679
|
if (this._geometryB instanceof LineSegment3d_1.LineSegment3d) {
|
|
@@ -627,11 +686,8 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
627
686
|
else if (this._geometryB instanceof Arc3d_1.Arc3d) {
|
|
628
687
|
this.computeSegmentArc(segmentA, this._geometryB, false);
|
|
629
688
|
}
|
|
630
|
-
else if (this._geometryB
|
|
631
|
-
this.
|
|
632
|
-
}
|
|
633
|
-
else if (this._geometryB instanceof TransitionSpiral3d_1.TransitionSpiral3d) {
|
|
634
|
-
this.dispatchCurveSpiral(segmentA, this._geometryB, false);
|
|
689
|
+
else if (this.needsStroking(this._geometryB)) {
|
|
690
|
+
this.dispatchCurveStrokedCurve(segmentA, this._geometryB, false);
|
|
635
691
|
}
|
|
636
692
|
else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
|
|
637
693
|
this.dispatchCurveCollection(segmentA, this.handleLineSegment3d.bind(this));
|
|
@@ -652,11 +708,8 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
652
708
|
else if (this._geometryB instanceof Arc3d_1.Arc3d) {
|
|
653
709
|
this.computeArcLineString(this._geometryB, lsA, true);
|
|
654
710
|
}
|
|
655
|
-
else if (this._geometryB
|
|
656
|
-
this.
|
|
657
|
-
}
|
|
658
|
-
else if (this._geometryB instanceof TransitionSpiral3d_1.TransitionSpiral3d) {
|
|
659
|
-
this.dispatchCurveSpiral(lsA, this._geometryB, false);
|
|
711
|
+
else if (this.needsStroking(this._geometryB)) {
|
|
712
|
+
this.dispatchCurveStrokedCurve(lsA, this._geometryB, false);
|
|
660
713
|
}
|
|
661
714
|
else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
|
|
662
715
|
this.dispatchCurveCollection(lsA, this.handleLineString3d.bind(this));
|
|
@@ -677,11 +730,8 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
677
730
|
else if (this._geometryB instanceof Arc3d_1.Arc3d) {
|
|
678
731
|
this.dispatchArcArc(arcA, this._geometryB, false);
|
|
679
732
|
}
|
|
680
|
-
else if (this._geometryB
|
|
681
|
-
this.
|
|
682
|
-
}
|
|
683
|
-
else if (this._geometryB instanceof TransitionSpiral3d_1.TransitionSpiral3d) {
|
|
684
|
-
this.dispatchCurveSpiral(arcA, this._geometryB, false);
|
|
733
|
+
else if (this.needsStroking(this._geometryB)) {
|
|
734
|
+
this.dispatchCurveStrokedCurve(arcA, this._geometryB, false);
|
|
685
735
|
}
|
|
686
736
|
else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
|
|
687
737
|
this.dispatchCurveCollection(arcA, this.handleArc3d.bind(this));
|
|
@@ -693,117 +743,24 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
693
743
|
}
|
|
694
744
|
/** Double dispatch handler for strongly typed bspline curve. */
|
|
695
745
|
handleBSplineCurve3d(curveA) {
|
|
696
|
-
if (this._geometryB instanceof
|
|
697
|
-
this.
|
|
698
|
-
}
|
|
699
|
-
else if (this._geometryB instanceof LineString3d_1.LineString3d) {
|
|
700
|
-
this.dispatchLineStringBSplineCurve(this._geometryB, curveA, true);
|
|
701
|
-
}
|
|
702
|
-
else if (this._geometryB instanceof Arc3d_1.Arc3d) {
|
|
703
|
-
this.dispatchArcBsplineCurve3d(this._geometryB, curveA, true);
|
|
704
|
-
}
|
|
705
|
-
else if (this._geometryB instanceof BSplineCurve_1.BSplineCurve3dBase) {
|
|
706
|
-
this.dispatchBSplineCurve3dBSplineCurve3d(curveA, this._geometryB, false);
|
|
746
|
+
if (this._geometryB instanceof CurveChainWithDistanceIndex_1.CurveChainWithDistanceIndex) {
|
|
747
|
+
this.dispatchCurveChainWithDistanceIndex(curveA, this.handleBSplineCurve3d.bind(this));
|
|
707
748
|
}
|
|
708
|
-
else if (this._geometryB instanceof
|
|
709
|
-
this.
|
|
749
|
+
else if (this._geometryB instanceof CurvePrimitive_1.CurvePrimitive) {
|
|
750
|
+
this.dispatchCurveStrokedCurve(this._geometryB, curveA, true);
|
|
710
751
|
}
|
|
711
752
|
else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
|
|
712
753
|
this.dispatchCurveCollection(curveA, this.handleBSplineCurve3d.bind(this));
|
|
713
754
|
}
|
|
714
|
-
else if (this._geometryB instanceof CurveChainWithDistanceIndex_1.CurveChainWithDistanceIndex) {
|
|
715
|
-
this.dispatchCurveChainWithDistanceIndex(curveA, this.handleBSplineCurve3d.bind(this));
|
|
716
|
-
}
|
|
717
755
|
return undefined;
|
|
718
756
|
}
|
|
719
|
-
/**
|
|
720
|
-
* Process seeds for xy close approach between the curve and spiral.
|
|
721
|
-
* * Refine each result via Newton iteration. If it doesn't converge, remove it.
|
|
722
|
-
* @param seeds The initial seed results to refine.
|
|
723
|
-
* @param curveA The other curve primitive. May also be a transition spiral.
|
|
724
|
-
* @param spiralB The transition spiral.
|
|
725
|
-
* @param reversed whether `spiralB` data is in `detailA` of each recorded pair, and `curveA` data in `detailB`.
|
|
726
|
-
*/
|
|
727
|
-
refineSpiralResultsByNewton(seeds, curveA, spiralB, reversed = false) {
|
|
728
|
-
const xyMatchingFunction = new Newton_1.CurveCurveCloseApproachXYRRtoRRD(curveA, spiralB);
|
|
729
|
-
const newtonSearcher = new Newton_1.Newton2dUnboundedWithDerivative(xyMatchingFunction, 50, this._newtonTolerance); // seen: 47
|
|
730
|
-
for (const seed of seeds) {
|
|
731
|
-
const detailA = reversed ? seed.detailB : seed.detailA;
|
|
732
|
-
const detailB = reversed ? seed.detailA : seed.detailB;
|
|
733
|
-
(0, core_bentley_1.assert)(detailB.curve instanceof LineString3d_1.LineString3d, "Caller has discretized the spiral");
|
|
734
|
-
newtonSearcher.setUV(detailA.fraction, detailB.fraction); // use linestring fraction as spiral param; it generally yields a closer point than fractional length!
|
|
735
|
-
if (newtonSearcher.runIterations()) {
|
|
736
|
-
const fractionA = newtonSearcher.getU();
|
|
737
|
-
const fractionB = newtonSearcher.getV();
|
|
738
|
-
if (this.acceptFraction(fractionA) && this.acceptFraction(fractionB))
|
|
739
|
-
this.testAndRecordPointPair(curveA, fractionA, undefined, spiralB, fractionB, undefined, reversed);
|
|
740
|
-
} // ignore failure to converge
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
/**
|
|
744
|
-
* Append stroke points and return the line string.
|
|
745
|
-
* * This is a convenient wrapper for [[CurvePrimitive.emitStrokes]] but the analogous instance method cannot be added
|
|
746
|
-
* to that class due to the ensuing recursion with subclass [[LineString3d]].
|
|
747
|
-
* @param options options for stroking the instance curve.
|
|
748
|
-
* @param result object to receive appended stroke points; if omitted, a new object is created, populated, and returned.
|
|
749
|
-
*/
|
|
750
|
-
strokeCurve(curve, options, result) {
|
|
751
|
-
const ls = result ? result : LineString3d_1.LineString3d.create();
|
|
752
|
-
curve.emitStrokes(ls, options);
|
|
753
|
-
return ls;
|
|
754
|
-
}
|
|
755
|
-
/** Find and return the close approaches between curveA and the discretization of curveB. */
|
|
756
|
-
computeDiscreteCloseApproachResults(curveA, lsB, reversed) {
|
|
757
|
-
const maxDist = this.maxDistanceToAccept;
|
|
758
|
-
const saveResults = this.grabPairedResults(); // save current results
|
|
759
|
-
const geomB = this._geometryB;
|
|
760
|
-
this.maxDistanceToAccept = maxDist ? maxDist * 1.2 : undefined; // HEURISTIC: allow slack for Newton seeds
|
|
761
|
-
this.resetGeometry(curveA);
|
|
762
|
-
this.handleLineString3d(lsB); // populate empty results with discrete solutions
|
|
763
|
-
if (!reversed) {
|
|
764
|
-
// handleLineString3d put lsB data into detailA, so if we aren't reversing, we need to swap
|
|
765
|
-
for (const result of this._results)
|
|
766
|
-
result.swapDetails();
|
|
767
|
-
}
|
|
768
|
-
this.resetGeometry(geomB);
|
|
769
|
-
this.maxDistanceToAccept = maxDist;
|
|
770
|
-
const discreteResults = this._results.extractArray();
|
|
771
|
-
saveResults.forEach((pair) => this._results.insert(pair)); // restore current results
|
|
772
|
-
return discreteResults;
|
|
773
|
-
}
|
|
774
|
-
/**
|
|
775
|
-
* Compute the XY close approach of a curve and a spiral.
|
|
776
|
-
* @param curveA curve to find its close approach with spiralB. May also be a transition spiral.
|
|
777
|
-
* @param spiralB transition spiral to find its close approach with curveA.
|
|
778
|
-
* @param reversed whether `spiralB` data will be recorded in `detailA` of each result, and `curveA` data in `detailB`.
|
|
779
|
-
*/
|
|
780
|
-
dispatchCurveSpiral(curveA, spiralB, reversed) {
|
|
781
|
-
// explicit search for intersections (Newton converges too slowly on DirectSpiral3d tangent intersections)
|
|
782
|
-
const intersections = CurveCurve_1.CurveCurve.intersectionXYPairs(curveA, false, spiralB, false, this._xyTolerance);
|
|
783
|
-
for (const intersection of intersections)
|
|
784
|
-
this.testAndRecordPair(intersection, reversed);
|
|
785
|
-
// append seeds computed by solving the discretized spiral close approach problem, then refine the seeds via Newton
|
|
786
|
-
let cpA = curveA;
|
|
787
|
-
if (curveA instanceof TransitionSpiral3d_1.TransitionSpiral3d)
|
|
788
|
-
cpA = this.strokeCurve(curveA);
|
|
789
|
-
const cpB = this.strokeCurve(spiralB);
|
|
790
|
-
const seeds = this.computeDiscreteCloseApproachResults(cpA, cpB, reversed);
|
|
791
|
-
this.refineSpiralResultsByNewton(seeds, curveA, spiralB, reversed);
|
|
792
|
-
if (curveA instanceof LineString3d_1.LineString3d) { // explicitly test corners (where Newton converges too slowly)
|
|
793
|
-
const fStep = Geometry_1.Geometry.safeDivideFraction(1.0, curveA.numEdges(), 0);
|
|
794
|
-
const v0 = CurveCurveCloseApproachXY._workPointBB0;
|
|
795
|
-
for (let i = 1; i < curveA.numEdges(); ++i)
|
|
796
|
-
this.testAndRecordProjection(curveA, i * fStep, curveA.pointAtUnchecked(i, v0), spiralB, reversed);
|
|
797
|
-
}
|
|
798
|
-
this.testAndRecordEndPointApproaches(curveA, spiralB, reversed);
|
|
799
|
-
}
|
|
800
757
|
/** Double dispatch handler for strongly typed spiral curve. */
|
|
801
758
|
handleTransitionSpiral(spiral) {
|
|
802
759
|
if (this._geometryB instanceof CurveChainWithDistanceIndex_1.CurveChainWithDistanceIndex) {
|
|
803
760
|
this.dispatchCurveChainWithDistanceIndex(spiral, this.handleTransitionSpiral.bind(this));
|
|
804
761
|
}
|
|
805
762
|
else if (this._geometryB instanceof CurvePrimitive_1.CurvePrimitive) {
|
|
806
|
-
this.
|
|
763
|
+
this.dispatchCurveStrokedCurve(this._geometryB, spiral, true);
|
|
807
764
|
}
|
|
808
765
|
else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
|
|
809
766
|
this.dispatchCurveCollection(spiral, this.handleTransitionSpiral.bind(this));
|
|
@@ -822,19 +779,7 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
822
779
|
}
|
|
823
780
|
/** Double dispatch handler for strongly typed homogeneous bspline curve .. */
|
|
824
781
|
handleBSplineCurve3dH(_curve) {
|
|
825
|
-
|
|
826
|
-
//NEEDS WORK -- make "dispatch" methods tolerant of both 3d and 3dH.
|
|
827
|
-
// "easy" if both present BezierCurve3dH span loaders
|
|
828
|
-
if (this._geometryB instanceof LineSegment3d) {
|
|
829
|
-
this.dispatchSegmentBsplineCurve(
|
|
830
|
-
this._geometryB, this._extendB, this._geometryB.point0Ref, 0.0, this._geometryB.point1Ref, 1.0, this._extendB,
|
|
831
|
-
curve, this._extendA, true);
|
|
832
|
-
} else if (this._geometryB instanceof LineString3d) {
|
|
833
|
-
this.dispatchLineStringBSplineCurve(this._geometryB, this._extendB, curve, this._extendA, true);
|
|
834
|
-
} else if (this._geometryB instanceof Arc3d) {
|
|
835
|
-
this.dispatchArcBsplineCurve3d(this._geometryB, this._extendB, curve, this._extendA, true);
|
|
836
|
-
}
|
|
837
|
-
*/
|
|
782
|
+
// NEEDS WORK -- make "dispatch" methods tolerant of both 3d and 3dH
|
|
838
783
|
return undefined;
|
|
839
784
|
}
|
|
840
785
|
}
|