@itwin/core-geometry 4.3.0-dev.0 → 4.3.0-dev.10
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/CHANGELOG.md +21 -1
- package/lib/cjs/Geometry.d.ts.map +1 -1
- package/lib/cjs/Geometry.js +2 -4
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/clipping/AlternatingConvexClipTree.js.map +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +18 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js +47 -0
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/cjs/curve/CurveCollection.d.ts +9 -9
- package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCollection.js +7 -10
- package/lib/cjs/curve/CurveCollection.js.map +1 -1
- package/lib/cjs/curve/CurveCurve.d.ts +2 -2
- package/lib/cjs/curve/CurveCurve.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCurve.js +3 -16
- package/lib/cjs/curve/CurveCurve.js.map +1 -1
- package/lib/cjs/curve/CurveLocationDetail.d.ts +17 -4
- package/lib/cjs/curve/CurveLocationDetail.d.ts.map +1 -1
- package/lib/cjs/curve/CurveLocationDetail.js +32 -10
- package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
- package/lib/cjs/curve/CurveWireMomentsXYZ.d.ts.map +1 -1
- package/lib/cjs/curve/CurveWireMomentsXYZ.js +2 -4
- package/lib/cjs/curve/CurveWireMomentsXYZ.js.map +1 -1
- package/lib/cjs/curve/LineString3d.d.ts +1 -4
- package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineString3d.js +1 -4
- package/lib/cjs/curve/LineString3d.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +2 -1
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +2 -1
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +0 -9
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +16 -35
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts +12 -6
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +80 -18
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts +11 -5
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js +73 -8
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
- package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/MultiChainCollector.js +2 -3
- package/lib/cjs/curve/internalContexts/MultiChainCollector.js.map +1 -1
- package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts +21 -5
- package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/CoincidentGeometryOps.js +71 -45
- package/lib/cjs/geometry3d/CoincidentGeometryOps.js.map +1 -1
- package/lib/cjs/geometry3d/Segment1d.d.ts +5 -1
- package/lib/cjs/geometry3d/Segment1d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Segment1d.js +11 -7
- package/lib/cjs/geometry3d/Segment1d.js.map +1 -1
- package/lib/cjs/geometry4d/Point4d.d.ts +1 -1
- package/lib/cjs/geometry4d/Point4d.js +1 -1
- package/lib/cjs/geometry4d/Point4d.js.map +1 -1
- package/lib/cjs/numerics/BezierPolynomials.d.ts +3 -4
- package/lib/cjs/numerics/BezierPolynomials.d.ts.map +1 -1
- package/lib/cjs/numerics/BezierPolynomials.js +8 -6
- package/lib/cjs/numerics/BezierPolynomials.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceClip.d.ts +1 -1
- package/lib/cjs/polyface/PolyfaceClip.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceClip.js +6 -3
- package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.d.ts +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/cjs/serialization/BGFBWriter.js.map +1 -1
- package/lib/cjs/solid/SweepContour.d.ts +4 -2
- package/lib/cjs/solid/SweepContour.d.ts.map +1 -1
- package/lib/cjs/solid/SweepContour.js +4 -2
- package/lib/cjs/solid/SweepContour.js.map +1 -1
- package/lib/esm/Geometry.d.ts.map +1 -1
- package/lib/esm/Geometry.js +2 -4
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/clipping/AlternatingConvexClipTree.js.map +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +18 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.js +48 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/esm/curve/CurveCollection.d.ts +9 -9
- package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
- package/lib/esm/curve/CurveCollection.js +7 -10
- package/lib/esm/curve/CurveCollection.js.map +1 -1
- package/lib/esm/curve/CurveCurve.d.ts +2 -2
- package/lib/esm/curve/CurveCurve.d.ts.map +1 -1
- package/lib/esm/curve/CurveCurve.js +3 -16
- package/lib/esm/curve/CurveCurve.js.map +1 -1
- package/lib/esm/curve/CurveLocationDetail.d.ts +17 -4
- package/lib/esm/curve/CurveLocationDetail.d.ts.map +1 -1
- package/lib/esm/curve/CurveLocationDetail.js +32 -10
- package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
- package/lib/esm/curve/CurveWireMomentsXYZ.d.ts.map +1 -1
- package/lib/esm/curve/CurveWireMomentsXYZ.js +2 -4
- package/lib/esm/curve/CurveWireMomentsXYZ.js.map +1 -1
- package/lib/esm/curve/LineString3d.d.ts +1 -4
- package/lib/esm/curve/LineString3d.d.ts.map +1 -1
- package/lib/esm/curve/LineString3d.js +1 -4
- package/lib/esm/curve/LineString3d.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +2 -1
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +2 -1
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +0 -9
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +16 -35
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts +12 -6
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +81 -19
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts +11 -5
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js +74 -9
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
- package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/MultiChainCollector.js +2 -3
- package/lib/esm/curve/internalContexts/MultiChainCollector.js.map +1 -1
- package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts +21 -5
- package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/CoincidentGeometryOps.js +71 -45
- package/lib/esm/geometry3d/CoincidentGeometryOps.js.map +1 -1
- package/lib/esm/geometry3d/Segment1d.d.ts +5 -1
- package/lib/esm/geometry3d/Segment1d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Segment1d.js +11 -7
- package/lib/esm/geometry3d/Segment1d.js.map +1 -1
- package/lib/esm/geometry4d/Point4d.d.ts +1 -1
- package/lib/esm/geometry4d/Point4d.js +1 -1
- package/lib/esm/geometry4d/Point4d.js.map +1 -1
- package/lib/esm/numerics/BezierPolynomials.d.ts +3 -4
- package/lib/esm/numerics/BezierPolynomials.d.ts.map +1 -1
- package/lib/esm/numerics/BezierPolynomials.js +8 -6
- package/lib/esm/numerics/BezierPolynomials.js.map +1 -1
- package/lib/esm/polyface/PolyfaceClip.d.ts +1 -1
- package/lib/esm/polyface/PolyfaceClip.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceClip.js +6 -3
- package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.d.ts +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/esm/serialization/BGFBWriter.js.map +1 -1
- package/lib/esm/solid/SweepContour.d.ts +4 -2
- package/lib/esm/solid/SweepContour.d.ts.map +1 -1
- package/lib/esm/solid/SweepContour.js +4 -2
- package/lib/esm/solid/SweepContour.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiChainCollector.js","sourceRoot":"","sources":["../../../../src/curve/internalContexts/MultiChainCollector.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,6CAA0C;AAC1C,gE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CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;SACpB;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IACD,0DAA0D;IACnD,4BAA4B,CAAC,aAAyC,EAAE,OAAuB;QACpG,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACvB,MAAM,EAAE,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YACxD,IAAI,EAAE;gBACJ,aAAa,CAAC,EAAE,CAAC,CAAC;SACrB;aAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YAC5B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;gBAC1B,MAAM,EAAE,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;gBACpD,IAAI,EAAE;oBACJ,aAAa,CAAC,EAAE,CAAC,CAAC;aACrB;SACF;IACH,CAAC;CACF;AApTD,kDAoTC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { Geometry } from \"../../Geometry\";\r\nimport { FrameBuilder } from \"../../geometry3d/FrameBuilder\";\r\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\r\nimport { XYAndZ } from \"../../geometry3d/XYZProps\";\r\nimport { Arc3d } from \"../Arc3d\";\r\nimport { AnyCurve } from \"../CurveTypes\";\r\nimport { BagOfCurves, CurveCollection } from \"../CurveCollection\";\r\nimport { CurveCurve } from \"../CurveCurve\";\r\nimport { CurvePrimitive } from \"../CurvePrimitive\";\r\nimport { LineSegment3d } from \"../LineSegment3d\";\r\nimport { LineString3d } from \"../LineString3d\";\r\nimport { Loop } from \"../Loop\";\r\nimport { Path } from \"../Path\";\r\nimport { ChainTypes, RegionOps } from \"../RegionOps\";\r\nimport { StrokeOptions } from \"../StrokeOptions\";\r\n\r\n/**\r\n * Manage a growing array of arrays of curve primitives that are to be joined \"head to tail\" in paths.\r\n * * The caller makes a sequence of calls to announce individual primitives.\r\n * * This collector (unlike the simpler [[ChainCollectorContext]]) expects to have inputs arriving in random order, leaving multiple open chains in play at any time.\r\n * * When all curves have been announced, the call to `grabResults` restructures the various active chains into Paths (and optionally, Loops).\r\n * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.\r\n * * Usage pattern is\r\n * * initialization: `context = new MultiChainCollector(gapTol, planeTol)`\r\n * * many times:\r\n * * `context.captureCurve(anyCurve)`\r\n * * `context.captureCurvePrimitive(primitive)`\r\n * * end: `result = context.grabResult(makeLoopIfClosed)`\r\n * @internal\r\n */\r\nexport class MultiChainCollector {\r\n /** accumulated chains */\r\n private _chains: CurvePrimitive[][];\r\n /** largest gap distance to close */\r\n private _gapTolerance: number;\r\n /** end point snap tolerance (assumed to be as tight or tighter than gapTolerance) */\r\n private _snapTolerance: number;\r\n /** tolerance for choosing Path or Loop. If undefined, always Path. */\r\n private _planeTolerance: number | undefined;\r\n\r\n private static _staticPointA: Point3d;\r\n private static _staticPointB: Point3d;\r\n private _xyzWork0?: Point3d;\r\n private _xyzWork1?: Point3d;\r\n\r\n /** Initialize with an empty array of chains.\r\n * @param gapTolerance tolerance for calling endpoints identical\r\n * @param planeTolerance tolerance for considering a closed chain to be planar. If undefined, only create Path. If defined, create Loops for closed chains within tolerance of a plane.\r\n */\r\n public constructor(gapTolerance = Geometry.smallMetricDistance, planeTolerance: number | undefined = Geometry.smallMetricDistance) {\r\n this._chains = [];\r\n this._gapTolerance = gapTolerance;\r\n this._snapTolerance = Geometry.smallMetricDistance;\r\n this._planeTolerance = planeTolerance;\r\n }\r\n /**\r\n * Find a chain (with index _other than_ exceptChainIndex) that starts or ends at xyz\r\n * @param xyz endpoint to check\r\n * @param tolerance absolute distance tolerance for equating endpoints\r\n * @param exceptChainIndex index of chain to ignore. Send -1 to consider all chains.\r\n */\r\n private findAnyChainToConnect(xyz: Point3d, tolerance: number, exceptChainIndex: number = -1): { chainIndex: number, atEnd: boolean } | undefined {\r\n for (let chainIndexA = 0; chainIndexA < this._chains.length; chainIndexA++) {\r\n if (exceptChainIndex === chainIndexA)\r\n continue;\r\n const chain = this._chains[chainIndexA];\r\n this._xyzWork1 = chain[chain.length - 1].endPoint(this._xyzWork1);\r\n if (this._xyzWork1.isAlmostEqual(xyz, tolerance))\r\n return { chainIndex: chainIndexA, atEnd: true };\r\n this._xyzWork1 = chain[0].startPoint(this._xyzWork1);\r\n if (this._xyzWork1.isAlmostEqual(xyz, tolerance))\r\n return { chainIndex: chainIndexA, atEnd: false };\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Insert a single curve primitive into the active chains.\r\n * * The primitive is captured (not cloned)\r\n * * The primitive may be reversed in place\r\n * @param candidate curve to add to the context\r\n */\r\n public captureCurvePrimitive(candidate: CurvePrimitive) {\r\n if (this._snapTolerance < this._gapTolerance) {\r\n if (this.attachPrimitiveToAnyChain(candidate, this._snapTolerance))\r\n return;\r\n }\r\n if (this.attachPrimitiveToAnyChain(candidate, this._gapTolerance))\r\n return;\r\n this._chains.push([candidate]);\r\n }\r\n /**\r\n * Insert any curve into the collection.\r\n * * This recurses into Path, Loop, BagOfCurves etc\r\n * * All primitives are captured, and may be reversed in place.\r\n * @param candidate curve to add to the context\r\n */\r\n public captureCurve(candidate: AnyCurve) {\r\n if (candidate instanceof CurvePrimitive)\r\n this.captureCurvePrimitive(candidate);\r\n else if (candidate instanceof CurveCollection && candidate.children !== undefined) {\r\n for (const c of candidate.children) {\r\n this.captureCurve(c as AnyCurve);\r\n }\r\n }\r\n }\r\n /** If allowed by the geometry type, move an endpoint. */\r\n private static simpleEndPointMove(curve: CurvePrimitive, atEnd: boolean, to: XYAndZ): boolean {\r\n if (curve instanceof (LineSegment3d)) {\r\n if (atEnd) {\r\n curve.point1Ref.setFrom(to);\r\n } else {\r\n curve.point0Ref.setFrom(to);\r\n }\r\n return true;\r\n } else if (curve instanceof LineString3d && curve.numPoints() > 0) {\r\n const i = atEnd ? curve.numPoints() - 1 : 0;\r\n curve.packedPoints.setAtCheckedPointIndex(i, to);\r\n return true;\r\n }\r\n return false;\r\n }\r\n /**\r\n * Try to move the end of curve0 and/or the start of curve1 to a common point.\r\n * * All z-coordinates are ignored.\r\n * @param curve0 first curve, assumed to end close to the start of curve1\r\n * @param curve1 second curve, assumed to start close to the end of curve0\r\n * @param gapTolerance max distance to move a curve start/end point\r\n * @returns whether curve start/end point(s) moved\r\n */\r\n private static moveHeadOrTail(curve0: CurvePrimitive, curve1: CurvePrimitive, gapTolerance: number): boolean {\r\n const xyz0 = curve0.endPoint();\r\n const xyz1 = curve1.startPoint();\r\n const minShift = Geometry.smallMetricDistance * 0.001;\r\n const d01 = xyz0.distanceXY(xyz1);\r\n if (d01 < minShift)\r\n return false;\r\n // try lines and linestrings\r\n if (d01 < gapTolerance) {\r\n if (this.simpleEndPointMove(curve1, false, xyz0) || this.simpleEndPointMove(curve0, true, xyz1))\r\n return true;\r\n }\r\n // try other primitive types\r\n const intersections = CurveCurve.intersectionXYPairs(curve0, true, curve1, true);\r\n const shiftFactor = 5.0;\r\n for (const pair of intersections) {\r\n const detail0 = pair.detailA;\r\n const detail1 = pair.detailB;\r\n const distance0 = detail0.point.distanceXY(xyz0);\r\n const distance1 = detail1.point.distanceXY(xyz1);\r\n if (distance0 < shiftFactor * gapTolerance && distance1 < shiftFactor * gapTolerance) {\r\n if (curve0 instanceof Arc3d && curve1 instanceof Arc3d) {\r\n const radians0End = curve0.sweep.fractionToRadians(detail0.fraction);\r\n curve0.sweep.setStartEndRadians(curve0.sweep.startRadians, radians0End);\r\n const radians1Start = curve1.sweep.fractionToRadians(detail1.fraction);\r\n curve1.sweep.setStartEndRadians(radians1Start, curve1.sweep.endRadians);\r\n return true;\r\n }\r\n // TODO: other combinations of types\r\n }\r\n }\r\n return false;\r\n }\r\n /** Announce a curve primitive\r\n * * If a \"nearby\" connection is possible, insert the candidate in the chain and force endpoint match.\r\n * * Otherwise start a new chain.\r\n */\r\n private attachPrimitiveToAnyChain(candidate: CurvePrimitive, tolerance: number): boolean {\r\n if (candidate) {\r\n this._xyzWork0 = candidate.startPoint(this._xyzWork0);\r\n let connect = this.findAnyChainToConnect(this._xyzWork0, tolerance);\r\n if (connect) {\r\n if (connect.atEnd) {\r\n const chain = this._chains[connect.chainIndex];\r\n const index0 = chain.length - 1;\r\n this._chains[connect.chainIndex].push(candidate);\r\n MultiChainCollector.moveHeadOrTail(chain[index0], chain[index0 + 1], this._gapTolerance);\r\n this.searchAndMergeChainIndex(connect.chainIndex, tolerance);\r\n return true;\r\n } else {\r\n candidate.reverseInPlace();\r\n const chain = this._chains[connect.chainIndex];\r\n chain.splice(0, 0, candidate);\r\n MultiChainCollector.moveHeadOrTail(chain[0], chain[1], this._gapTolerance);\r\n this.searchAndMergeChainIndex(connect.chainIndex, tolerance);\r\n return true;\r\n }\r\n } else {\r\n this._xyzWork0 = candidate.endPoint(this._xyzWork0);\r\n connect = this.findAnyChainToConnect(this._xyzWork0, tolerance);\r\n if (connect) {\r\n if (connect.atEnd) {\r\n candidate.reverseInPlace();\r\n const chain = this._chains[connect.chainIndex];\r\n const index0 = chain.length - 1;\r\n this._chains[connect.chainIndex].push(candidate);\r\n MultiChainCollector.moveHeadOrTail(chain[index0], chain[index0 + 1], this._gapTolerance);\r\n this.searchAndMergeChainIndex(connect.chainIndex, tolerance);\r\n return true;\r\n } else {\r\n const chain = this._chains[connect.chainIndex];\r\n chain.splice(0, 0, candidate);\r\n MultiChainCollector.moveHeadOrTail(chain[0], chain[1], this._gapTolerance);\r\n this.searchAndMergeChainIndex(connect.chainIndex, tolerance);\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n /**\r\n * Merge two entries in the chain array.\r\n * * Move each primitive from chainB to the end of chainA.\r\n * * Clear chainB.\r\n * * Move the final chain to chainB index.\r\n * * Decrement the array length.\r\n * @param chainIndexA index of chainA\r\n * @param chainIndexB index of chainB\r\n */\r\n private mergeChainsForwardForward(chainIndexA: number, chainIndexB: number) {\r\n const chainA = this._chains[chainIndexA];\r\n const chainB = this._chains[chainIndexB];\r\n for (const p of chainB) {\r\n chainA.push(p);\r\n }\r\n chainB.length = 0; // chainIndexB is unused\r\n const lastChainIndex = this._chains.length - 1;\r\n if (chainIndexB !== lastChainIndex)\r\n this._chains[chainIndexB] = this._chains[lastChainIndex];\r\n this._chains.pop();\r\n }\r\n /** Reverse the curve chain in place. */\r\n private reverseChain(chainIndex: number) {\r\n const chain = this._chains[chainIndex];\r\n chain.reverse();\r\n for (const p of chain)\r\n p.reverseInPlace();\r\n }\r\n /** See if the head or tail of chainIndex matches any existing chain. If so, merge the two chains. */\r\n private searchAndMergeChainIndex(chainIndex: number, tolerance: number): void {\r\n // ASSUME valid index of non-empty chain\r\n const chain = this._chains[chainIndex];\r\n const lastIndexInChain = chain.length - 1;\r\n this._xyzWork0 = chain[0].startPoint(this._xyzWork0);\r\n // try start with any other chain\r\n let connect = this.findAnyChainToConnect(this._xyzWork0, tolerance, chainIndex);\r\n if (connect) {\r\n if (!connect.atEnd)\r\n this.reverseChain(connect.chainIndex);\r\n this.mergeChainsForwardForward(connect.chainIndex, chainIndex);\r\n return;\r\n }\r\n // try end with any other chain\r\n this._xyzWork0 = chain[lastIndexInChain].endPoint(this._xyzWork0);\r\n connect = this.findAnyChainToConnect(this._xyzWork0, tolerance, chainIndex);\r\n if (connect) {\r\n if (connect.atEnd)\r\n this.reverseChain(connect.chainIndex);\r\n this.mergeChainsForwardForward(chainIndex, connect.chainIndex);\r\n return;\r\n }\r\n }\r\n /**\r\n * Convert an array of curve primitives into the simplest possible strongly typed curve structure.\r\n * @param curves input array, assembled correctly into a single contiguous path, captured by returned object\r\n * @param makeLoopIfClosed whether to return a Loop from physically closed curves array, otherwise Path\r\n * @return Loop or Path if multiple curves; the primitive if only one curve; undefined if no curves\r\n */\r\n private promoteArrayToCurves(curves: CurvePrimitive[], makeLoopIfClosed: boolean): CurvePrimitive | Path | Loop | undefined {\r\n if (curves.length === 0)\r\n return undefined;\r\n if (makeLoopIfClosed) {\r\n const primitive0 = curves[0];\r\n const primitiveN = curves[curves.length - 1];\r\n MultiChainCollector._staticPointA = primitive0.startPoint(MultiChainCollector._staticPointA);\r\n MultiChainCollector._staticPointB = primitiveN.endPoint(MultiChainCollector._staticPointB);\r\n if (MultiChainCollector.moveHeadOrTail(primitiveN, primitive0, this._gapTolerance)) {\r\n // get the corrected coordinates\r\n MultiChainCollector._staticPointA = primitive0.startPoint(MultiChainCollector._staticPointA);\r\n MultiChainCollector._staticPointB = primitiveN.endPoint(MultiChainCollector._staticPointB);\r\n }\r\n if (MultiChainCollector._staticPointA.isAlmostEqual(MultiChainCollector._staticPointB, this._gapTolerance)) {\r\n const localToWorld = FrameBuilder.createRightHandedLocalToWorld(curves);\r\n if (localToWorld) {\r\n const worldToLocal = localToWorld.inverse();\r\n if (worldToLocal) {\r\n const range = RegionOps.curveArrayRange(curves, worldToLocal);\r\n if (this._planeTolerance !== undefined && range.zLength() <= this._planeTolerance) {\r\n return Loop.createArray(curves);\r\n }\r\n }\r\n }\r\n return Path.createArray(curves);\r\n }\r\n }\r\n if (curves.length === 1)\r\n return curves[0];\r\n return Path.createArray(curves);\r\n }\r\n /** Stroke the curve chain to a line string, de-duplicate the points. */\r\n private chainToLineString3d(chain: CurvePrimitive[], options?: StrokeOptions): LineString3d | undefined {\r\n if (chain.length === 0)\r\n return undefined;\r\n const linestring = LineString3d.create();\r\n for (const curve of chain)\r\n curve.emitStrokes(linestring, options);\r\n linestring.removeDuplicatePoints(this._gapTolerance);\r\n return linestring;\r\n }\r\n /** Return the collected results, structured as the simplest possible type. */\r\n public grabResult(makeLoopIfClosed: boolean = false): ChainTypes {\r\n const chains = this._chains;\r\n if (chains.length === 0)\r\n return undefined;\r\n if (chains.length === 1)\r\n return this.promoteArrayToCurves(chains[0], makeLoopIfClosed);\r\n const bag = BagOfCurves.create();\r\n for (const chain of chains) {\r\n const q = this.promoteArrayToCurves(chain, makeLoopIfClosed);\r\n bag.tryAddChild(q);\r\n }\r\n return bag;\r\n }\r\n /** Return chains as individual calls to announceChain. */\r\n public announceChainsAsLineString3d(announceChain: (ls: LineString3d) => void, options?: StrokeOptions): void {\r\n const chains = this._chains;\r\n if (chains.length === 1) {\r\n const ls = this.chainToLineString3d(chains[0], options);\r\n if (ls)\r\n announceChain(ls);\r\n } else if (chains.length > 1) {\r\n for (const chain of chains) {\r\n const ls = this.chainToLineString3d(chain, options);\r\n if (ls)\r\n announceChain(ls);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"MultiChainCollector.js","sourceRoot":"","sources":["../../../../src/curve/internalContexts/MultiChainCollector.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,6CAA0C;AAC1C,gEAA6D;AAG7D,oCAAiC;AAEjC,wDAAkE;AAClE,8CAA2C;AAC3C,sDAAmD;AACnD,oDAAiD;AACjD,kDAA+C;AAC/C,kCAA+B;AAC/B,kCAA+B;AAC/B,4CAAqD;AAGrD;;;;;;;;;;;;;GAaG;AACH,MAAa,mBAAmB;IAe9B;;;OAGG;IACH,YAAmB,YAAY,GAAG,mBAAQ,CAAC,mBAAmB,EAAE,iBAAqC,mBAAQ,CAAC,mBAAmB;QAC/H,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,cAAc,GAAG,mBAAQ,CAAC,mBAAmB,CAAC;QACnD,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IACxC,CAAC;IACD;;;;;OAKG;IACK,qBAAqB,CAAC,GAAY,EAAE,SAAiB,EAAE,mBAA2B,CAAC,CAAC;QAC1F,KAAK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;IACH,CAAC;CACF;AAnTD,kDAmTC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { Geometry } from \"../../Geometry\";\r\nimport { FrameBuilder } from \"../../geometry3d/FrameBuilder\";\r\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\r\nimport { XYAndZ } from \"../../geometry3d/XYZProps\";\r\nimport { Arc3d } from \"../Arc3d\";\r\nimport { AnyCurve } from \"../CurveTypes\";\r\nimport { BagOfCurves, CurveCollection } from \"../CurveCollection\";\r\nimport { CurveCurve } from \"../CurveCurve\";\r\nimport { CurvePrimitive } from \"../CurvePrimitive\";\r\nimport { LineSegment3d } from \"../LineSegment3d\";\r\nimport { LineString3d } from \"../LineString3d\";\r\nimport { Loop } from \"../Loop\";\r\nimport { Path } from \"../Path\";\r\nimport { ChainTypes, RegionOps } from \"../RegionOps\";\r\nimport { StrokeOptions } from \"../StrokeOptions\";\r\n\r\n/**\r\n * Manage a growing array of arrays of curve primitives that are to be joined \"head to tail\" in paths.\r\n * * The caller makes a sequence of calls to announce individual primitives.\r\n * * This collector (unlike the simpler [[ChainCollectorContext]]) expects to have inputs arriving in random order, leaving multiple open chains in play at any time.\r\n * * When all curves have been announced, the call to `grabResults` restructures the various active chains into Paths (and optionally, Loops).\r\n * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.\r\n * * Usage pattern is\r\n * * initialization: `context = new MultiChainCollector(gapTol, planeTol)`\r\n * * many times:\r\n * * `context.captureCurve(anyCurve)`\r\n * * `context.captureCurvePrimitive(primitive)`\r\n * * end: `result = context.grabResult(makeLoopIfClosed)`\r\n * @internal\r\n */\r\nexport class MultiChainCollector {\r\n /** accumulated chains */\r\n private _chains: CurvePrimitive[][];\r\n /** largest gap distance to close */\r\n private _gapTolerance: number;\r\n /** end point snap tolerance (assumed to be as tight or tighter than gapTolerance) */\r\n private _snapTolerance: number;\r\n /** tolerance for choosing Path or Loop. If undefined, always Path. */\r\n private _planeTolerance: number | undefined;\r\n\r\n private static _staticPointA: Point3d;\r\n private static _staticPointB: Point3d;\r\n private _xyzWork0?: Point3d;\r\n private _xyzWork1?: Point3d;\r\n\r\n /** Initialize with an empty array of chains.\r\n * @param gapTolerance tolerance for calling endpoints identical\r\n * @param planeTolerance tolerance for considering a closed chain to be planar. If undefined, only create Path. If defined, create Loops for closed chains within tolerance of a plane.\r\n */\r\n public constructor(gapTolerance = Geometry.smallMetricDistance, planeTolerance: number | undefined = Geometry.smallMetricDistance) {\r\n this._chains = [];\r\n this._gapTolerance = gapTolerance;\r\n this._snapTolerance = Geometry.smallMetricDistance;\r\n this._planeTolerance = planeTolerance;\r\n }\r\n /**\r\n * Find a chain (with index _other than_ exceptChainIndex) that starts or ends at xyz\r\n * @param xyz endpoint to check\r\n * @param tolerance absolute distance tolerance for equating endpoints\r\n * @param exceptChainIndex index of chain to ignore. Send -1 to consider all chains.\r\n */\r\n private findAnyChainToConnect(xyz: Point3d, tolerance: number, exceptChainIndex: number = -1): { chainIndex: number, atEnd: boolean } | undefined {\r\n for (let chainIndexA = 0; chainIndexA < this._chains.length; chainIndexA++) {\r\n if (exceptChainIndex === chainIndexA)\r\n continue;\r\n const chain = this._chains[chainIndexA];\r\n this._xyzWork1 = chain[chain.length - 1].endPoint(this._xyzWork1);\r\n if (this._xyzWork1.isAlmostEqual(xyz, tolerance))\r\n return { chainIndex: chainIndexA, atEnd: true };\r\n this._xyzWork1 = chain[0].startPoint(this._xyzWork1);\r\n if (this._xyzWork1.isAlmostEqual(xyz, tolerance))\r\n return { chainIndex: chainIndexA, atEnd: false };\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Insert a single curve primitive into the active chains.\r\n * * The primitive is captured (not cloned)\r\n * * The primitive may be reversed in place\r\n * @param candidate curve to add to the context\r\n */\r\n public captureCurvePrimitive(candidate: CurvePrimitive) {\r\n if (this._snapTolerance < this._gapTolerance) {\r\n if (this.attachPrimitiveToAnyChain(candidate, this._snapTolerance))\r\n return;\r\n }\r\n if (this.attachPrimitiveToAnyChain(candidate, this._gapTolerance))\r\n return;\r\n this._chains.push([candidate]);\r\n }\r\n /**\r\n * Insert any curve into the collection.\r\n * * This recurses into Path, Loop, BagOfCurves etc\r\n * * All primitives are captured, and may be reversed in place.\r\n * @param candidate curve to add to the context\r\n */\r\n public captureCurve(candidate: AnyCurve) {\r\n if (candidate instanceof CurvePrimitive)\r\n this.captureCurvePrimitive(candidate);\r\n else if (candidate instanceof CurveCollection) {\r\n for (const c of candidate.children)\r\n this.captureCurve(c);\r\n }\r\n }\r\n /** If allowed by the geometry type, move an endpoint. */\r\n private static simpleEndPointMove(curve: CurvePrimitive, atEnd: boolean, to: XYAndZ): boolean {\r\n if (curve instanceof (LineSegment3d)) {\r\n if (atEnd) {\r\n curve.point1Ref.setFrom(to);\r\n } else {\r\n curve.point0Ref.setFrom(to);\r\n }\r\n return true;\r\n } else if (curve instanceof LineString3d && curve.numPoints() > 0) {\r\n const i = atEnd ? curve.numPoints() - 1 : 0;\r\n curve.packedPoints.setAtCheckedPointIndex(i, to);\r\n return true;\r\n }\r\n return false;\r\n }\r\n /**\r\n * Try to move the end of curve0 and/or the start of curve1 to a common point.\r\n * * All z-coordinates are ignored.\r\n * @param curve0 first curve, assumed to end close to the start of curve1\r\n * @param curve1 second curve, assumed to start close to the end of curve0\r\n * @param gapTolerance max distance to move a curve start/end point\r\n * @returns whether curve start/end point(s) moved\r\n */\r\n private static moveHeadOrTail(curve0: CurvePrimitive, curve1: CurvePrimitive, gapTolerance: number): boolean {\r\n const xyz0 = curve0.endPoint();\r\n const xyz1 = curve1.startPoint();\r\n const minShift = Geometry.smallMetricDistance * 0.001;\r\n const d01 = xyz0.distanceXY(xyz1);\r\n if (d01 < minShift)\r\n return false;\r\n // try lines and linestrings\r\n if (d01 < gapTolerance) {\r\n if (this.simpleEndPointMove(curve1, false, xyz0) || this.simpleEndPointMove(curve0, true, xyz1))\r\n return true;\r\n }\r\n // try other primitive types\r\n const intersections = CurveCurve.intersectionXYPairs(curve0, true, curve1, true);\r\n const shiftFactor = 5.0;\r\n for (const pair of intersections) {\r\n const detail0 = pair.detailA;\r\n const detail1 = pair.detailB;\r\n const distance0 = detail0.point.distanceXY(xyz0);\r\n const distance1 = detail1.point.distanceXY(xyz1);\r\n if (distance0 < shiftFactor * gapTolerance && distance1 < shiftFactor * gapTolerance) {\r\n if (curve0 instanceof Arc3d && curve1 instanceof Arc3d) {\r\n const radians0End = curve0.sweep.fractionToRadians(detail0.fraction);\r\n curve0.sweep.setStartEndRadians(curve0.sweep.startRadians, radians0End);\r\n const radians1Start = curve1.sweep.fractionToRadians(detail1.fraction);\r\n curve1.sweep.setStartEndRadians(radians1Start, curve1.sweep.endRadians);\r\n return true;\r\n }\r\n // TODO: other combinations of types\r\n }\r\n }\r\n return false;\r\n }\r\n /** Announce a curve primitive\r\n * * If a \"nearby\" connection is possible, insert the candidate in the chain and force endpoint match.\r\n * * Otherwise start a new chain.\r\n */\r\n private attachPrimitiveToAnyChain(candidate: CurvePrimitive, tolerance: number): boolean {\r\n if (candidate) {\r\n this._xyzWork0 = candidate.startPoint(this._xyzWork0);\r\n let connect = this.findAnyChainToConnect(this._xyzWork0, tolerance);\r\n if (connect) {\r\n if (connect.atEnd) {\r\n const chain = this._chains[connect.chainIndex];\r\n const index0 = chain.length - 1;\r\n this._chains[connect.chainIndex].push(candidate);\r\n MultiChainCollector.moveHeadOrTail(chain[index0], chain[index0 + 1], this._gapTolerance);\r\n this.searchAndMergeChainIndex(connect.chainIndex, tolerance);\r\n return true;\r\n } else {\r\n candidate.reverseInPlace();\r\n const chain = this._chains[connect.chainIndex];\r\n chain.splice(0, 0, candidate);\r\n MultiChainCollector.moveHeadOrTail(chain[0], chain[1], this._gapTolerance);\r\n this.searchAndMergeChainIndex(connect.chainIndex, tolerance);\r\n return true;\r\n }\r\n } else {\r\n this._xyzWork0 = candidate.endPoint(this._xyzWork0);\r\n connect = this.findAnyChainToConnect(this._xyzWork0, tolerance);\r\n if (connect) {\r\n if (connect.atEnd) {\r\n candidate.reverseInPlace();\r\n const chain = this._chains[connect.chainIndex];\r\n const index0 = chain.length - 1;\r\n this._chains[connect.chainIndex].push(candidate);\r\n MultiChainCollector.moveHeadOrTail(chain[index0], chain[index0 + 1], this._gapTolerance);\r\n this.searchAndMergeChainIndex(connect.chainIndex, tolerance);\r\n return true;\r\n } else {\r\n const chain = this._chains[connect.chainIndex];\r\n chain.splice(0, 0, candidate);\r\n MultiChainCollector.moveHeadOrTail(chain[0], chain[1], this._gapTolerance);\r\n this.searchAndMergeChainIndex(connect.chainIndex, tolerance);\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n /**\r\n * Merge two entries in the chain array.\r\n * * Move each primitive from chainB to the end of chainA.\r\n * * Clear chainB.\r\n * * Move the final chain to chainB index.\r\n * * Decrement the array length.\r\n * @param chainIndexA index of chainA\r\n * @param chainIndexB index of chainB\r\n */\r\n private mergeChainsForwardForward(chainIndexA: number, chainIndexB: number) {\r\n const chainA = this._chains[chainIndexA];\r\n const chainB = this._chains[chainIndexB];\r\n for (const p of chainB) {\r\n chainA.push(p);\r\n }\r\n chainB.length = 0; // chainIndexB is unused\r\n const lastChainIndex = this._chains.length - 1;\r\n if (chainIndexB !== lastChainIndex)\r\n this._chains[chainIndexB] = this._chains[lastChainIndex];\r\n this._chains.pop();\r\n }\r\n /** Reverse the curve chain in place. */\r\n private reverseChain(chainIndex: number) {\r\n const chain = this._chains[chainIndex];\r\n chain.reverse();\r\n for (const p of chain)\r\n p.reverseInPlace();\r\n }\r\n /** See if the head or tail of chainIndex matches any existing chain. If so, merge the two chains. */\r\n private searchAndMergeChainIndex(chainIndex: number, tolerance: number): void {\r\n // ASSUME valid index of non-empty chain\r\n const chain = this._chains[chainIndex];\r\n const lastIndexInChain = chain.length - 1;\r\n this._xyzWork0 = chain[0].startPoint(this._xyzWork0);\r\n // try start with any other chain\r\n let connect = this.findAnyChainToConnect(this._xyzWork0, tolerance, chainIndex);\r\n if (connect) {\r\n if (!connect.atEnd)\r\n this.reverseChain(connect.chainIndex);\r\n this.mergeChainsForwardForward(connect.chainIndex, chainIndex);\r\n return;\r\n }\r\n // try end with any other chain\r\n this._xyzWork0 = chain[lastIndexInChain].endPoint(this._xyzWork0);\r\n connect = this.findAnyChainToConnect(this._xyzWork0, tolerance, chainIndex);\r\n if (connect) {\r\n if (connect.atEnd)\r\n this.reverseChain(connect.chainIndex);\r\n this.mergeChainsForwardForward(chainIndex, connect.chainIndex);\r\n return;\r\n }\r\n }\r\n /**\r\n * Convert an array of curve primitives into the simplest possible strongly typed curve structure.\r\n * @param curves input array, assembled correctly into a single contiguous path, captured by returned object\r\n * @param makeLoopIfClosed whether to return a Loop from physically closed curves array, otherwise Path\r\n * @return Loop or Path if multiple curves; the primitive if only one curve; undefined if no curves\r\n */\r\n private promoteArrayToCurves(curves: CurvePrimitive[], makeLoopIfClosed: boolean): CurvePrimitive | Path | Loop | undefined {\r\n if (curves.length === 0)\r\n return undefined;\r\n if (makeLoopIfClosed) {\r\n const primitive0 = curves[0];\r\n const primitiveN = curves[curves.length - 1];\r\n MultiChainCollector._staticPointA = primitive0.startPoint(MultiChainCollector._staticPointA);\r\n MultiChainCollector._staticPointB = primitiveN.endPoint(MultiChainCollector._staticPointB);\r\n if (MultiChainCollector.moveHeadOrTail(primitiveN, primitive0, this._gapTolerance)) {\r\n // get the corrected coordinates\r\n MultiChainCollector._staticPointA = primitive0.startPoint(MultiChainCollector._staticPointA);\r\n MultiChainCollector._staticPointB = primitiveN.endPoint(MultiChainCollector._staticPointB);\r\n }\r\n if (MultiChainCollector._staticPointA.isAlmostEqual(MultiChainCollector._staticPointB, this._gapTolerance)) {\r\n const localToWorld = FrameBuilder.createRightHandedLocalToWorld(curves);\r\n if (localToWorld) {\r\n const worldToLocal = localToWorld.inverse();\r\n if (worldToLocal) {\r\n const range = RegionOps.curveArrayRange(curves, worldToLocal);\r\n if (this._planeTolerance !== undefined && range.zLength() <= this._planeTolerance) {\r\n return Loop.createArray(curves);\r\n }\r\n }\r\n }\r\n return Path.createArray(curves);\r\n }\r\n }\r\n if (curves.length === 1)\r\n return curves[0];\r\n return Path.createArray(curves);\r\n }\r\n /** Stroke the curve chain to a line string, de-duplicate the points. */\r\n private chainToLineString3d(chain: CurvePrimitive[], options?: StrokeOptions): LineString3d | undefined {\r\n if (chain.length === 0)\r\n return undefined;\r\n const linestring = LineString3d.create();\r\n for (const curve of chain)\r\n curve.emitStrokes(linestring, options);\r\n linestring.removeDuplicatePoints(this._gapTolerance);\r\n return linestring;\r\n }\r\n /** Return the collected results, structured as the simplest possible type. */\r\n public grabResult(makeLoopIfClosed: boolean = false): ChainTypes {\r\n const chains = this._chains;\r\n if (chains.length === 0)\r\n return undefined;\r\n if (chains.length === 1)\r\n return this.promoteArrayToCurves(chains[0], makeLoopIfClosed);\r\n const bag = BagOfCurves.create();\r\n for (const chain of chains) {\r\n const q = this.promoteArrayToCurves(chain, makeLoopIfClosed);\r\n bag.tryAddChild(q);\r\n }\r\n return bag;\r\n }\r\n /** Return chains as individual calls to announceChain. */\r\n public announceChainsAsLineString3d(announceChain: (ls: LineString3d) => void, options?: StrokeOptions): void {\r\n const chains = this._chains;\r\n if (chains.length === 1) {\r\n const ls = this.chainToLineString3d(chains[0], options);\r\n if (ls)\r\n announceChain(ls);\r\n } else if (chains.length > 1) {\r\n for (const chain of chains) {\r\n const ls = this.chainToLineString3d(chain, options);\r\n if (ls)\r\n announceChain(ls);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -21,17 +21,33 @@ export declare class CoincidentGeometryQuery {
|
|
|
21
21
|
* * reevaluate the points as simple interpolation between given points.
|
|
22
22
|
*/
|
|
23
23
|
static assignDetailInterpolatedFractionsAndPoints(detail: CurveLocationDetail, f0: number, f1: number, pointA: Point3d, pointB: Point3d, swap?: boolean): void;
|
|
24
|
-
/** Return a curve location detail with projection of a `spacePoint` to the line segment with `pointA` and `pointB`
|
|
25
|
-
*
|
|
26
|
-
*/
|
|
24
|
+
/** Return a curve location detail with projection of a `spacePoint` to the line segment with `pointA` and `pointB` */
|
|
27
25
|
projectPointToSegmentXY(spacePoint: Point3d, pointA: Point3d, pointB: Point3d): CurveLocationDetail;
|
|
28
26
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
27
|
+
* Given a detail pair representing the projection of each of two colinear line segments onto the other,
|
|
28
|
+
* clamp the details (in place) to the line segments' endpoints according to the given flags.
|
|
29
|
+
* @param overlap segment overlap as returned by [[coincidentSegmentRangeXY]], modified on return
|
|
30
|
+
* @param pointA0 start point of segment A
|
|
31
|
+
* @param pointA1 end point of segment A
|
|
32
|
+
* @param pointB0 start point of segment B
|
|
33
|
+
* @param pointB1 end point of segment B
|
|
34
|
+
* @param extendA0 whether to extend segment A beyond its start
|
|
35
|
+
* @param extendA1 whether to extend segment A beyond its end
|
|
36
|
+
* @param extendB0 whether to extend segment B beyond its start
|
|
37
|
+
* @param extendB1 whether to extend segment B beyond its end
|
|
38
|
+
* @return reference to the input clamped in place, or undefined (leaving interval untouched) if clamping would result in empty interval.
|
|
39
|
+
*/
|
|
40
|
+
clampCoincidentOverlapToSegmentBounds(overlap: CurveLocationDetailPair, pointA0: Point3d, pointA1: Point3d, pointB0: Point3d, pointB1: Point3d, extendA0?: boolean, extendA1?: boolean, extendB0?: boolean, extendB1?: boolean): CurveLocationDetailPair | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Compute whether two line segments have a coincident overlap in xy.
|
|
43
|
+
* * Project `pointA0` and `pointA1` onto the line formed by `pointB0` and `pointB1` and vice versa
|
|
44
|
+
* * If all projection distances are sufficiently small, return a detail pair recording the coincident interval, optionally clipped to segment bounds.
|
|
31
45
|
* @param pointA0 start point of segment A
|
|
32
46
|
* @param pointA1 end point of segment A
|
|
33
47
|
* @param pointB0 start point of segment B
|
|
34
48
|
* @param pointB1 end point of segment B
|
|
49
|
+
* @param restrictToBounds whether to clip the coincident segment details to the segment bounds
|
|
50
|
+
* @return detail pair for the coincident interval (`detailA` has fractions along segment A, and `detailB` has fractions along segment B), or undefined if no coincidence
|
|
35
51
|
*/
|
|
36
52
|
coincidentSegmentRangeXY(pointA0: Point3d, pointA1: Point3d, pointB0: Point3d, pointB1: Point3d, restrictToBounds?: boolean): CurveLocationDetailPair | undefined;
|
|
37
53
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoincidentGeometryOps.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/CoincidentGeometryOps.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAI5F,OAAO,EAAE,OAAO,EAAY,MAAM,mBAAmB,CAAC;AAGtD;;;;;GAKG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,QAAQ,CAAC,CAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,CAAW;IAC5B,OAAO,CAAC,OAAO,CAAC,CAAU;IAC1B,OAAO,CAAC,OAAO,CAAC,CAAU;IAC1B,OAAO,CAAC,UAAU,CAAS;IAC3B,IAAW,SAAS,IAAI,MAAM,CAE7B;IACD,OAAO;WAGO,MAAM,CAAC,SAAS,GAAE,MAAqC,GAAG,uBAAuB;IAG/F;;;OAGG;WACW,0CAA0C,CAAC,MAAM,EAAE,mBAAmB,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAC1G,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,GAAE,OAAe;IAazD
|
|
1
|
+
{"version":3,"file":"CoincidentGeometryOps.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/CoincidentGeometryOps.ts"],"names":[],"mappings":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OAAc,GAAG,uBAAuB,GAAG,SAAS;IAuB9K;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,gBAAgB;IAQxB;;;;;;OAMG;IACI,2BAA2B,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,iBAAiB,GAAE,OAAc,GAAG,uBAAuB,EAAE,GAAG,SAAS;CAgEvI"}
|
|
@@ -46,9 +46,7 @@ class CoincidentGeometryQuery {
|
|
|
46
46
|
detail.point = pointA.interpolate(detail.fraction, pointB, detail.point);
|
|
47
47
|
detail.point1 = pointA.interpolate(detail.fraction1, pointB, detail.point1);
|
|
48
48
|
}
|
|
49
|
-
/** Return a curve location detail with projection of a `spacePoint` to the line segment with `pointA` and `pointB`
|
|
50
|
-
*
|
|
51
|
-
*/
|
|
49
|
+
/** Return a curve location detail with projection of a `spacePoint` to the line segment with `pointA` and `pointB` */
|
|
52
50
|
projectPointToSegmentXY(spacePoint, pointA, pointB) {
|
|
53
51
|
this._vectorU = Point3dVector3d_1.Vector3d.createStartEnd(pointA, pointB, this._vectorU);
|
|
54
52
|
this._vectorV = Point3dVector3d_1.Vector3d.createStartEnd(pointA, spacePoint, this._vectorV);
|
|
@@ -58,12 +56,78 @@ class CoincidentGeometryQuery {
|
|
|
58
56
|
return CurveLocationDetail_1.CurveLocationDetail.createCurveFractionPoint(undefined, fraction, pointA.interpolate(fraction, pointB));
|
|
59
57
|
}
|
|
60
58
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
59
|
+
* Given a detail pair representing the projection of each of two colinear line segments onto the other,
|
|
60
|
+
* clamp the details (in place) to the line segments' endpoints according to the given flags.
|
|
61
|
+
* @param overlap segment overlap as returned by [[coincidentSegmentRangeXY]], modified on return
|
|
62
|
+
* @param pointA0 start point of segment A
|
|
63
|
+
* @param pointA1 end point of segment A
|
|
64
|
+
* @param pointB0 start point of segment B
|
|
65
|
+
* @param pointB1 end point of segment B
|
|
66
|
+
* @param extendA0 whether to extend segment A beyond its start
|
|
67
|
+
* @param extendA1 whether to extend segment A beyond its end
|
|
68
|
+
* @param extendB0 whether to extend segment B beyond its start
|
|
69
|
+
* @param extendB1 whether to extend segment B beyond its end
|
|
70
|
+
* @return reference to the input clamped in place, or undefined (leaving interval untouched) if clamping would result in empty interval.
|
|
71
|
+
*/
|
|
72
|
+
clampCoincidentOverlapToSegmentBounds(overlap, pointA0, pointA1, pointB0, pointB1, extendA0 = false, extendA1 = false, extendB0 = false, extendB1 = false) {
|
|
73
|
+
const rangeA = Segment1d_1.Segment1d.create(overlap.detailA.fraction, overlap.detailA.hasFraction1 ? overlap.detailA.fraction1 : overlap.detailA.fraction);
|
|
74
|
+
const rangeB = Segment1d_1.Segment1d.create(overlap.detailB.fraction, overlap.detailB.hasFraction1 ? overlap.detailB.fraction1 : overlap.detailB.fraction);
|
|
75
|
+
const reversed = rangeA.signedDelta() < 0.0;
|
|
76
|
+
const updateIntervalFromRangesAndInterpolatedPoints = () => {
|
|
77
|
+
const a0 = rangeA.x0;
|
|
78
|
+
const a1 = rangeA.x1;
|
|
79
|
+
const b0 = rangeB.x0;
|
|
80
|
+
const b1 = rangeB.x1;
|
|
81
|
+
CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(overlap.detailA, a0, a1, pointA0, pointA1, a0 > a1);
|
|
82
|
+
CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(overlap.detailB, b0, b1, pointB0, pointB1, b0 > b1);
|
|
83
|
+
return overlap;
|
|
84
|
+
};
|
|
85
|
+
const haveIntervalA = rangeA.clampDirectedTo01(!extendA0, !extendA1, false);
|
|
86
|
+
const haveIntervalB = rangeB.clampDirectedTo01(!extendB0, !extendB1, false);
|
|
87
|
+
if (haveIntervalA && haveIntervalB) {
|
|
88
|
+
if (Geometry_1.Geometry.isAlmostEqualNumber(rangeA.absoluteDelta(), rangeB.absoluteDelta(), Geometry_1.Geometry.smallFraction))
|
|
89
|
+
return updateIntervalFromRangesAndInterpolatedPoints(); // intersection of partially clamped ranges
|
|
90
|
+
else if (rangeA.clampDirectedTo01(true, true, false) && rangeB.clampDirectedTo01(true, true, false))
|
|
91
|
+
return updateIntervalFromRangesAndInterpolatedPoints(); // intersection of fully clamped ranges
|
|
92
|
+
}
|
|
93
|
+
const collapseToSingleton = (pointA, pointB, atStartA, atStartB) => {
|
|
94
|
+
pointA.clone(overlap.detailA.point);
|
|
95
|
+
pointB.clone(overlap.detailB.point);
|
|
96
|
+
overlap.detailA.fraction = atStartA ? 0.0 : 1.0;
|
|
97
|
+
overlap.detailB.fraction = atStartB ? 0.0 : 1.0;
|
|
98
|
+
overlap.detailA.collapseToStart();
|
|
99
|
+
overlap.detailB.collapseToStart();
|
|
100
|
+
return overlap;
|
|
101
|
+
};
|
|
102
|
+
const haveSingletonA = rangeA.clampDirectedTo01(true, true, true);
|
|
103
|
+
const haveSingletonB = rangeB.clampDirectedTo01(true, true, true);
|
|
104
|
+
if (haveSingletonA && haveSingletonB) { // intersection is a single point
|
|
105
|
+
const point1 = overlap.detailA.point1 ?? overlap.detailA.point;
|
|
106
|
+
if (reversed) {
|
|
107
|
+
if (overlap.detailA.point.isAlmostEqual(pointA0, this.tolerance))
|
|
108
|
+
return collapseToSingleton(pointA0, pointB0, true, true);
|
|
109
|
+
else if (point1.isAlmostEqual(pointA1, this.tolerance))
|
|
110
|
+
return collapseToSingleton(pointA1, pointB1, false, false);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
if (point1.isAlmostEqual(pointA0, this.tolerance))
|
|
114
|
+
return collapseToSingleton(pointA0, pointB1, true, false);
|
|
115
|
+
else if (overlap.detailA.point.isAlmostEqual(pointA1, this.tolerance))
|
|
116
|
+
return collapseToSingleton(pointA1, pointB0, false, true);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return undefined; // no intersection
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Compute whether two line segments have a coincident overlap in xy.
|
|
123
|
+
* * Project `pointA0` and `pointA1` onto the line formed by `pointB0` and `pointB1` and vice versa
|
|
124
|
+
* * If all projection distances are sufficiently small, return a detail pair recording the coincident interval, optionally clipped to segment bounds.
|
|
63
125
|
* @param pointA0 start point of segment A
|
|
64
126
|
* @param pointA1 end point of segment A
|
|
65
127
|
* @param pointB0 start point of segment B
|
|
66
128
|
* @param pointB1 end point of segment B
|
|
129
|
+
* @param restrictToBounds whether to clip the coincident segment details to the segment bounds
|
|
130
|
+
* @return detail pair for the coincident interval (`detailA` has fractions along segment A, and `detailB` has fractions along segment B), or undefined if no coincidence
|
|
67
131
|
*/
|
|
68
132
|
coincidentSegmentRangeXY(pointA0, pointA1, pointB0, pointB1, restrictToBounds = true) {
|
|
69
133
|
const detailA0OnB = this.projectPointToSegmentXY(pointA0, pointB0, pointB1);
|
|
@@ -82,46 +146,8 @@ class CoincidentGeometryQuery {
|
|
|
82
146
|
detailA0OnB.point1 = detailA1OnB.point; // capture -- detailA1OnB is not reused.
|
|
83
147
|
detailB0OnA.fraction1 = detailB1OnA.fraction;
|
|
84
148
|
detailB0OnA.point1 = detailB1OnA.point;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const segment = Segment1d_1.Segment1d.create(detailB0OnA.fraction, detailB0OnA.fraction1);
|
|
88
|
-
if (segment.clampDirectedTo01()) {
|
|
89
|
-
const f0 = segment.x0;
|
|
90
|
-
const f1 = segment.x1;
|
|
91
|
-
const h0 = detailB0OnA.inverseInterpolateFraction(f0);
|
|
92
|
-
const h1 = detailB0OnA.inverseInterpolateFraction(f1);
|
|
93
|
-
// recompute fractions and points..
|
|
94
|
-
CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(detailB0OnA, f0, f1, pointA0, pointA1, f0 > f1);
|
|
95
|
-
CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(detailA0OnB, h0, h1, pointB0, pointB1, h0 > h1);
|
|
96
|
-
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
if (segment.signedDelta() < 0.0) {
|
|
100
|
-
if (detailB0OnA.point.isAlmostEqual(pointA0, this.tolerance)) {
|
|
101
|
-
detailB0OnA.collapseToStart();
|
|
102
|
-
detailA0OnB.collapseToStart();
|
|
103
|
-
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
104
|
-
}
|
|
105
|
-
if (detailB0OnA.point1.isAlmostEqual(pointA1, this.tolerance)) {
|
|
106
|
-
detailB0OnA.collapseToEnd();
|
|
107
|
-
detailA0OnB.collapseToEnd();
|
|
108
|
-
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
if (detailB0OnA.point.isAlmostEqual(pointA1, this.tolerance)) {
|
|
113
|
-
detailB0OnA.collapseToStart();
|
|
114
|
-
detailA0OnB.collapseToEnd();
|
|
115
|
-
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
116
|
-
}
|
|
117
|
-
if (detailB0OnA.point1.isAlmostEqual(pointA0, this.tolerance)) {
|
|
118
|
-
detailB0OnA.collapseToEnd();
|
|
119
|
-
detailA0OnB.collapseToStart();
|
|
120
|
-
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return undefined;
|
|
149
|
+
const interval = CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
150
|
+
return restrictToBounds ? this.clampCoincidentOverlapToSegmentBounds(interval, pointA0, pointA1, pointB0, pointB1) : interval;
|
|
125
151
|
}
|
|
126
152
|
/**
|
|
127
153
|
* Create a CurveLocationDetailPair for a coincident interval of two overlapping curves
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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AAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;6BACjG;yBACF;wBACD,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC;oBACtD,CAAC,CAAC;oBAEF,4BAA4B,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,CAAE,wDAAwD;oBAE9G,yEAAyE;oBACzE,IAAI,UAAU,IAAI,eAAe;wBAC/B,4BAA4B,CAAC,qBAAS,CAAC,MAAM,CAAC,UAAU,GAAG,eAAe,EAAE,UAAU,GAAG,eAAe,CAAC,EAAE,IAAI,CAAC,CAAC;yBAC9G,IAAI,UAAU,KAAK,GAAG;wBACzB,4BAA4B,CAAC,qBAAS,CAAC,MAAM,CAAC,UAAU,GAAG,eAAe,EAAE,UAAU,GAAG,eAAe,CAAC,EAAE,IAAI,CAAC,CAAC;iBACpH;aACF;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AArND,0DAqNC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Arc3d } from \"../curve/Arc3d\";\r\nimport { CurveLocationDetail, CurveLocationDetailPair } from \"../curve/CurveLocationDetail\";\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { AngleSweep } from \"./AngleSweep\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { Segment1d } from \"./Segment1d\";\r\n\r\n/**\r\n * `CoincidentGeometryQuery` has methods useful in testing for overlapping geometry.\r\n * * Each instance carries tolerance information that can be reused over extended call sequences.\r\n * * These methods are expected to be called internally by CurveCurve intersection methods.\r\n * @internal\r\n */\r\nexport class CoincidentGeometryQuery {\r\n private _vectorU?: Vector3d;\r\n private _vectorV?: Vector3d;\r\n private _point0?: Point3d;\r\n private _point1?: Point3d;\r\n private _tolerance: number;\r\n public get tolerance(): number {\r\n return this._tolerance;\r\n }\r\n private constructor(tolerance: number = Geometry.smallMetricDistance) {\r\n this._tolerance = tolerance;\r\n }\r\n public static create(tolerance: number = Geometry.smallMetricDistance): CoincidentGeometryQuery {\r\n return new CoincidentGeometryQuery(tolerance);\r\n }\r\n /**\r\n * * Assign both the fraction and fraction1 values in the detail, possibly swapped.\r\n * * reevaluate the points as simple interpolation between given points.\r\n */\r\n public static assignDetailInterpolatedFractionsAndPoints(detail: CurveLocationDetail, f0: number, f1: number,\r\n pointA: Point3d, pointB: Point3d, swap: boolean = false) {\r\n if (swap) {\r\n detail.fraction = f1;\r\n detail.fraction1 = f0;\r\n } else {\r\n detail.fraction = f0;\r\n detail.fraction1 = f1;\r\n }\r\n detail.point = pointA.interpolate(detail.fraction, pointB, detail.point);\r\n detail.point1 = pointA.interpolate(detail.fraction1, pointB, detail.point1);\r\n\r\n }\r\n\r\n /** Return a curve location detail with projection of a `spacePoint` to the line segment with `pointA` and `pointB`\r\n *\r\n */\r\n public projectPointToSegmentXY(spacePoint: Point3d, pointA: Point3d, pointB: Point3d): CurveLocationDetail {\r\n this._vectorU = Vector3d.createStartEnd(pointA, pointB, this._vectorU);\r\n this._vectorV = Vector3d.createStartEnd(pointA, spacePoint, this._vectorV);\r\n const uDotU = this._vectorU.dotProductXY(this._vectorU);\r\n const uDotV = this._vectorU.dotProductXY(this._vectorV);\r\n const fraction = Geometry.safeDivideFraction(uDotV, uDotU, 0.0);\r\n return CurveLocationDetail.createCurveFractionPoint(undefined, fraction,\r\n pointA.interpolate(fraction, pointB));\r\n }\r\n /**\r\n * * project `pointA0` and `pointA1` onto the segment with `pointB0` and `pointB1`\r\n * * In the returned detail pair, the `detailA` has fractions along segmentA, and `detailB` has fractions along segment B\r\n * @param pointA0 start point of segment A\r\n * @param pointA1 end point of segment A\r\n * @param pointB0 start point of segment B\r\n * @param pointB1 end point of segment B\r\n */\r\n public coincidentSegmentRangeXY(pointA0: Point3d, pointA1: Point3d, pointB0: Point3d, pointB1: Point3d, restrictToBounds: boolean = true): CurveLocationDetailPair | undefined {\r\n const detailA0OnB = this.projectPointToSegmentXY(pointA0, pointB0, pointB1);\r\n if (pointA0.distanceXY(detailA0OnB.point) > this._tolerance)\r\n return undefined;\r\n const detailA1OnB = this.projectPointToSegmentXY(pointA1, pointB0, pointB1);\r\n if (pointA1.distanceXY(detailA1OnB.point) > this._tolerance)\r\n return undefined;\r\n\r\n const detailB0OnA = this.projectPointToSegmentXY(pointB0, pointA0, pointA1);\r\n if (pointB0.distanceXY(detailB0OnA.point) > this._tolerance)\r\n return undefined;\r\n const detailB1OnA = this.projectPointToSegmentXY(pointB1, pointA0, pointA1);\r\n if (pointB1.distanceXY(detailB1OnA.point) > this._tolerance)\r\n return undefined;\r\n\r\n detailA0OnB.fraction1 = detailA1OnB.fraction;\r\n detailA0OnB.point1 = detailA1OnB.point; // capture -- detailA1OnB is not reused.\r\n detailB0OnA.fraction1 = detailB1OnA.fraction;\r\n detailB0OnA.point1 = detailB1OnA.point;\r\n if (!restrictToBounds)\r\n return CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);\r\n\r\n const segment = Segment1d.create(detailB0OnA.fraction, detailB0OnA.fraction1);\r\n if (segment.clampDirectedTo01()) {\r\n const f0 = segment.x0;\r\n const f1 = segment.x1;\r\n const h0 = detailB0OnA.inverseInterpolateFraction(f0);\r\n const h1 = detailB0OnA.inverseInterpolateFraction(f1);\r\n // recompute fractions and points..\r\n CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(detailB0OnA, f0, f1, pointA0, pointA1, f0 > f1);\r\n CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(detailA0OnB, h0, h1, pointB0, pointB1, h0 > h1);\r\n return CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);\r\n } else {\r\n if (segment.signedDelta() < 0.0) {\r\n if (detailB0OnA.point.isAlmostEqual(pointA0, this.tolerance)) {\r\n detailB0OnA.collapseToStart();\r\n detailA0OnB.collapseToStart();\r\n return CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);\r\n }\r\n if (detailB0OnA.point1.isAlmostEqual(pointA1, this.tolerance)) {\r\n detailB0OnA.collapseToEnd();\r\n detailA0OnB.collapseToEnd();\r\n return CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);\r\n }\r\n } else {\r\n if (detailB0OnA.point.isAlmostEqual(pointA1, this.tolerance)) {\r\n detailB0OnA.collapseToStart();\r\n detailA0OnB.collapseToEnd();\r\n return CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);\r\n }\r\n if (detailB0OnA.point1.isAlmostEqual(pointA0, this.tolerance)) {\r\n detailB0OnA.collapseToEnd();\r\n detailA0OnB.collapseToStart();\r\n return CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);\r\n }\r\n }\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Create a CurveLocationDetailPair for a coincident interval of two overlapping curves\r\n * @param cpA curveA\r\n * @param cpB curveB\r\n * @param fractionsOnA coincident interval of curveB in fraction space of curveA\r\n * @param fractionB0 curveB start in fraction space of curveA\r\n * @param fractionB1 curveB end in fraction space of curveA\r\n * @param reverse whether curveB and curveA have opposite direction\r\n */\r\n private createDetailPair(cpA: CurvePrimitive, cpB: CurvePrimitive, fractionsOnA: Segment1d, fractionB0: number, fractionB1: number, reverse: boolean): CurveLocationDetailPair | undefined {\r\n const deltaB = fractionB1 - fractionB0;\r\n const g0 = Geometry.conditionalDivideFraction(fractionsOnA.x0 - fractionB0, deltaB);\r\n const g1 = Geometry.conditionalDivideFraction(fractionsOnA.x1 - fractionB0, deltaB);\r\n if (g0 !== undefined && g1 !== undefined) {\r\n const detailA = CurveLocationDetail.createCurveEvaluatedFractionFraction(cpA, fractionsOnA.x0, fractionsOnA.x1);\r\n const detailB = CurveLocationDetail.createCurveEvaluatedFractionFraction(cpB, g0, g1);\r\n if (reverse)\r\n detailA.swapFractionsAndPoints();\r\n return CurveLocationDetailPair.createCapture(detailA, detailB);\r\n }\r\n return undefined;\r\n }\r\n private appendDetailPair(result: CurveLocationDetailPair[] | undefined, pair: CurveLocationDetailPair | undefined): CurveLocationDetailPair[] | undefined {\r\n if (pair === undefined)\r\n return result;\r\n if (result === undefined)\r\n return [pair];\r\n result.push(pair);\r\n return result;\r\n }\r\n /**\r\n * Test if 2 arcs have coinciding portions.\r\n * @param arcA\r\n * @param arcB\r\n * @param _restrictToBounds\r\n * @return 0, 1, or 2 overlap points/intervals\r\n */\r\n public coincidentArcIntersectionXY(arcA: Arc3d, arcB: Arc3d, _restrictToBounds: boolean = true): CurveLocationDetailPair[] | undefined {\r\n let result: CurveLocationDetailPair[] | undefined;\r\n if (arcA.center.isAlmostEqual(arcB.center, this.tolerance)) {\r\n const matrixBToA = arcA.matrixRef.multiplyMatrixInverseMatrix(arcB.matrixRef);\r\n if (matrixBToA) {\r\n const ux = matrixBToA.at(0, 0); const uy = matrixBToA.at(1, 0);\r\n const vx = matrixBToA.at(0, 1); const vy = matrixBToA.at(1, 1);\r\n const ru = Geometry.hypotenuseXY(ux, uy);\r\n const rv = Geometry.hypotenuseXY(vx, vy);\r\n const dot = Geometry.dotProductXYXY(ux, uy, vx, vy);\r\n const cross = Geometry.crossProductXYXY(ux, uy, vx, vy);\r\n if (Geometry.isAlmostEqualNumber(ru, 1.0)\r\n && Geometry.isAlmostEqualNumber(rv, 1.0)\r\n && Geometry.isAlmostEqualNumber(0, dot)) {\r\n const alphaB0Radians = Math.atan2(uy, ux); // angular position of arcB 0 point in arcA sweep\r\n const sweepDirection = cross > 0 ? 1.0 : -1.0; // 1 if arcB parameter space sweeps in same direction as arcA, -1 if opposite\r\n const betaStartRadians = alphaB0Radians + sweepDirection * arcB.sweep.startRadians; // arcB start in arcA parameter space\r\n const betaEndRadians = alphaB0Radians + sweepDirection * arcB.sweep.endRadians; // arcB end in arcA parameter space\r\n const fractionSpacesReversed = (sweepDirection * arcA.sweep.sweepRadians * arcB.sweep.sweepRadians) < 0;\r\n const sweepB = AngleSweep.createStartEndRadians(betaStartRadians, betaEndRadians);\r\n const sweepA = arcA.sweep;\r\n const fractionPeriodA = sweepA.fractionPeriod();\r\n const fractionB0 = sweepA.radiansToPositivePeriodicFraction(sweepB.startRadians); // arcB start in arcA fraction space\r\n assert(fractionB0 >= 0.0);\r\n const fractionSweep = sweepB.sweepRadians / sweepA.sweepRadians; // arcB sweep in arcA fraction space\r\n const fractionB1 = fractionB0 + fractionSweep; // arcB end in arcA fraction space\r\n const fractionSweepB = Segment1d.create(fractionB0, fractionB1);\r\n\r\n /** lambda to add a coincident interval or isolated intersection, given inputs in arcA fraction space\r\n * @param arcBInArcAFractionSpace span of arcB in arcA fraction space. On return, clamped to [0,1] if nontrivial.\r\n * @param testStartOfArcA if no nontrivial coincident interval was found, look for an isolated intersection at the start (true) or end (false) of arcA\r\n * @returns whether a detail pair was appended to result\r\n */\r\n const appendCoincidentIntersection = (arcBInArcAFractionSpace: Segment1d, testStartOfArcA: boolean): boolean => {\r\n const size = result ? result.length : 0;\r\n const arcBStart = arcBInArcAFractionSpace.x0;\r\n const arcBEnd = arcBInArcAFractionSpace.x1;\r\n if (arcBInArcAFractionSpace.clampDirectedTo01() && !Geometry.isSmallRelative(arcBInArcAFractionSpace.absoluteDelta())) {\r\n result = this.appendDetailPair(result, this.createDetailPair(arcA, arcB, arcBInArcAFractionSpace, arcBStart, arcBEnd, fractionSpacesReversed));\r\n } else { // test isolated intersection\r\n const testStartOfArcB = fractionSpacesReversed ? testStartOfArcA : !testStartOfArcA;\r\n const arcAPt = this._point0 = testStartOfArcA ? arcA.startPoint(this._point0): arcA.endPoint(this._point0);\r\n const arcBPt = this._point1 = testStartOfArcB ? arcB.startPoint(this._point1): arcB.endPoint(this._point1);\r\n if (arcAPt.isAlmostEqual(arcBPt, this.tolerance)) {\r\n const detailA = CurveLocationDetail.createCurveFractionPoint(arcA, testStartOfArcA ? 0 : 1, arcAPt);\r\n const detailB = CurveLocationDetail.createCurveFractionPoint(arcB, testStartOfArcB ? 0 : 1, arcBPt);\r\n result = this.appendDetailPair(result, CurveLocationDetailPair.createCapture(detailA, detailB));\r\n }\r\n }\r\n return result !== undefined && result.length > size;\r\n };\r\n\r\n appendCoincidentIntersection(fractionSweepB, false); // compute overlap in strict interior, or at end of arcA\r\n\r\n // check overlap at start of arcA with a periodic shift of fractionSweepB\r\n if (fractionB1 >= fractionPeriodA)\r\n appendCoincidentIntersection(Segment1d.create(fractionB0 - fractionPeriodA, fractionB1 - fractionPeriodA), true);\r\n else if (fractionB0 === 0.0)\r\n appendCoincidentIntersection(Segment1d.create(fractionB0 + fractionPeriodA, fractionB1 + fractionPeriodA), true);\r\n }\r\n }\r\n }\r\n return result;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"CoincidentGeometryOps.js","sourceRoot":"","sources":["../../../src/geometry3d/CoincidentGeometryOps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,sDAA6C;AAE7C,sEAA4F;AAE5F,0CAAuC;AACvC,6CAA0C;AAC1C,uDAAsD;AACtD,2CAAwC;AAExC;;;;;GAKG;AACH,MAAa,uBAAuB;IAMlC,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IACD,YAAoB,YAAoB,mBAAQ,CAAC,mBAAmB;QAClE,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IACM,MAAM,CAAC,MAAM,CAAC,YAAoB,mBAAQ,CAAC,mBAAmB;QACnE,OAAO,IAAI,uBAAuB,CAAC,SAAS,CAAC,CAAC;IAChD,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,0CAA0C,CAAC,MAA2B,EAAE,EAAU,EAAE,EAAU,EAC1G,MAAe,EAAE,MAAe,EAAE,OAAgB,KAAK;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6CAAuB,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;6BACjG;yBACF;wBACD,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC;oBACtD,CAAC,CAAC;oBAEF,4BAA4B,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,CAAE,wDAAwD;oBAE9G,yEAAyE;oBACzE,IAAI,UAAU,IAAI,eAAe;wBAC/B,4BAA4B,CAAC,qBAAS,CAAC,MAAM,CAAC,UAAU,GAAG,eAAe,EAAE,UAAU,GAAG,eAAe,CAAC,EAAE,IAAI,CAAC,CAAC;yBAC9G,IAAI,UAAU,KAAK,GAAG;wBACzB,4BAA4B,CAAC,qBAAS,CAAC,MAAM,CAAC,UAAU,GAAG,eAAe,EAAE,UAAU,GAAG,eAAe,CAAC,EAAE,IAAI,CAAC,CAAC;iBACpH;aACF;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAvPD,0DAuPC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Arc3d } from \"../curve/Arc3d\";\r\nimport { CurveLocationDetail, CurveLocationDetailPair } from \"../curve/CurveLocationDetail\";\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { AngleSweep } from \"./AngleSweep\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { Segment1d } from \"./Segment1d\";\r\n\r\n/**\r\n * `CoincidentGeometryQuery` has methods useful in testing for overlapping geometry.\r\n * * Each instance carries tolerance information that can be reused over extended call sequences.\r\n * * These methods are expected to be called internally by CurveCurve intersection methods.\r\n * @internal\r\n */\r\nexport class CoincidentGeometryQuery {\r\n private _vectorU?: Vector3d;\r\n private _vectorV?: Vector3d;\r\n private _point0?: Point3d;\r\n private _point1?: Point3d;\r\n private _tolerance: number;\r\n public get tolerance(): number {\r\n return this._tolerance;\r\n }\r\n private constructor(tolerance: number = Geometry.smallMetricDistance) {\r\n this._tolerance = tolerance;\r\n }\r\n public static create(tolerance: number = Geometry.smallMetricDistance): CoincidentGeometryQuery {\r\n return new CoincidentGeometryQuery(tolerance);\r\n }\r\n /**\r\n * * Assign both the fraction and fraction1 values in the detail, possibly swapped.\r\n * * reevaluate the points as simple interpolation between given points.\r\n */\r\n public static assignDetailInterpolatedFractionsAndPoints(detail: CurveLocationDetail, f0: number, f1: number,\r\n pointA: Point3d, pointB: Point3d, swap: boolean = false) {\r\n if (swap) {\r\n detail.fraction = f1;\r\n detail.fraction1 = f0;\r\n } else {\r\n detail.fraction = f0;\r\n detail.fraction1 = f1;\r\n }\r\n detail.point = pointA.interpolate(detail.fraction, pointB, detail.point);\r\n detail.point1 = pointA.interpolate(detail.fraction1, pointB, detail.point1);\r\n\r\n }\r\n\r\n /** Return a curve location detail with projection of a `spacePoint` to the line segment with `pointA` and `pointB` */\r\n public projectPointToSegmentXY(spacePoint: Point3d, pointA: Point3d, pointB: Point3d): CurveLocationDetail {\r\n this._vectorU = Vector3d.createStartEnd(pointA, pointB, this._vectorU);\r\n this._vectorV = Vector3d.createStartEnd(pointA, spacePoint, this._vectorV);\r\n const uDotU = this._vectorU.dotProductXY(this._vectorU);\r\n const uDotV = this._vectorU.dotProductXY(this._vectorV);\r\n const fraction = Geometry.safeDivideFraction(uDotV, uDotU, 0.0);\r\n return CurveLocationDetail.createCurveFractionPoint(undefined, fraction,\r\n pointA.interpolate(fraction, pointB));\r\n }\r\n /**\r\n * Given a detail pair representing the projection of each of two colinear line segments onto the other,\r\n * clamp the details (in place) to the line segments' endpoints according to the given flags.\r\n * @param overlap segment overlap as returned by [[coincidentSegmentRangeXY]], modified on return\r\n * @param pointA0 start point of segment A\r\n * @param pointA1 end point of segment A\r\n * @param pointB0 start point of segment B\r\n * @param pointB1 end point of segment B\r\n * @param extendA0 whether to extend segment A beyond its start\r\n * @param extendA1 whether to extend segment A beyond its end\r\n * @param extendB0 whether to extend segment B beyond its start\r\n * @param extendB1 whether to extend segment B beyond its end\r\n * @return reference to the input clamped in place, or undefined (leaving interval untouched) if clamping would result in empty interval.\r\n */\r\n public clampCoincidentOverlapToSegmentBounds(overlap: CurveLocationDetailPair,\r\n pointA0: Point3d, pointA1: Point3d, pointB0: Point3d, pointB1: Point3d,\r\n extendA0: boolean = false, extendA1: boolean = false, extendB0: boolean = false, extendB1: boolean = false,\r\n ): CurveLocationDetailPair | undefined {\r\n const rangeA = Segment1d.create(overlap.detailA.fraction, overlap.detailA.hasFraction1 ? overlap.detailA.fraction1 : overlap.detailA.fraction);\r\n const rangeB = Segment1d.create(overlap.detailB.fraction, overlap.detailB.hasFraction1 ? overlap.detailB.fraction1 : overlap.detailB.fraction);\r\n const reversed = rangeA.signedDelta() < 0.0;\r\n\r\n const updateIntervalFromRangesAndInterpolatedPoints = (): CurveLocationDetailPair => {\r\n const a0 = rangeA.x0;\r\n const a1 = rangeA.x1;\r\n const b0 = rangeB.x0;\r\n const b1 = rangeB.x1;\r\n CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(overlap.detailA, a0, a1, pointA0, pointA1, a0 > a1);\r\n CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(overlap.detailB, b0, b1, pointB0, pointB1, b0 > b1);\r\n return overlap;\r\n };\r\n\r\n const haveIntervalA = rangeA.clampDirectedTo01(!extendA0, !extendA1, false);\r\n const haveIntervalB = rangeB.clampDirectedTo01(!extendB0, !extendB1, false);\r\n if (haveIntervalA && haveIntervalB) {\r\n if (Geometry.isAlmostEqualNumber(rangeA.absoluteDelta(), rangeB.absoluteDelta(), Geometry.smallFraction))\r\n return updateIntervalFromRangesAndInterpolatedPoints(); // intersection of partially clamped ranges\r\n else if (rangeA.clampDirectedTo01(true, true, false) && rangeB.clampDirectedTo01(true, true, false))\r\n return updateIntervalFromRangesAndInterpolatedPoints(); // intersection of fully clamped ranges\r\n }\r\n\r\n const collapseToSingleton = (pointA: Point3d, pointB: Point3d, atStartA: boolean, atStartB: boolean): CurveLocationDetailPair => {\r\n pointA.clone(overlap.detailA.point);\r\n pointB.clone(overlap.detailB.point);\r\n overlap.detailA.fraction = atStartA ? 0.0 : 1.0;\r\n overlap.detailB.fraction = atStartB ? 0.0 : 1.0;\r\n overlap.detailA.collapseToStart();\r\n overlap.detailB.collapseToStart();\r\n return overlap;\r\n };\r\n\r\n const haveSingletonA = rangeA.clampDirectedTo01(true, true, true);\r\n const haveSingletonB = rangeB.clampDirectedTo01(true, true, true);\r\n if (haveSingletonA && haveSingletonB) { // intersection is a single point\r\n const point1 = overlap.detailA.point1 ?? overlap.detailA.point;\r\n if (reversed) {\r\n if (overlap.detailA.point.isAlmostEqual(pointA0, this.tolerance))\r\n return collapseToSingleton(pointA0, pointB0, true, true);\r\n else if (point1.isAlmostEqual(pointA1, this.tolerance))\r\n return collapseToSingleton(pointA1, pointB1, false, false);\r\n } else {\r\n if (point1.isAlmostEqual(pointA0, this.tolerance))\r\n return collapseToSingleton(pointA0, pointB1, true, false);\r\n else if (overlap.detailA.point.isAlmostEqual(pointA1, this.tolerance))\r\n return collapseToSingleton(pointA1, pointB0, false, true);\r\n }\r\n }\r\n return undefined; // no intersection\r\n }\r\n /**\r\n * Compute whether two line segments have a coincident overlap in xy.\r\n * * Project `pointA0` and `pointA1` onto the line formed by `pointB0` and `pointB1` and vice versa\r\n * * If all projection distances are sufficiently small, return a detail pair recording the coincident interval, optionally clipped to segment bounds.\r\n * @param pointA0 start point of segment A\r\n * @param pointA1 end point of segment A\r\n * @param pointB0 start point of segment B\r\n * @param pointB1 end point of segment B\r\n * @param restrictToBounds whether to clip the coincident segment details to the segment bounds\r\n * @return detail pair for the coincident interval (`detailA` has fractions along segment A, and `detailB` has fractions along segment B), or undefined if no coincidence\r\n */\r\n public coincidentSegmentRangeXY(pointA0: Point3d, pointA1: Point3d, pointB0: Point3d, pointB1: Point3d, restrictToBounds: boolean = true): CurveLocationDetailPair | undefined {\r\n const detailA0OnB = this.projectPointToSegmentXY(pointA0, pointB0, pointB1);\r\n if (pointA0.distanceXY(detailA0OnB.point) > this._tolerance)\r\n return undefined;\r\n const detailA1OnB = this.projectPointToSegmentXY(pointA1, pointB0, pointB1);\r\n if (pointA1.distanceXY(detailA1OnB.point) > this._tolerance)\r\n return undefined;\r\n\r\n const detailB0OnA = this.projectPointToSegmentXY(pointB0, pointA0, pointA1);\r\n if (pointB0.distanceXY(detailB0OnA.point) > this._tolerance)\r\n return undefined;\r\n const detailB1OnA = this.projectPointToSegmentXY(pointB1, pointA0, pointA1);\r\n if (pointB1.distanceXY(detailB1OnA.point) > this._tolerance)\r\n return undefined;\r\n\r\n detailA0OnB.fraction1 = detailA1OnB.fraction;\r\n detailA0OnB.point1 = detailA1OnB.point; // capture -- detailA1OnB is not reused.\r\n detailB0OnA.fraction1 = detailB1OnA.fraction;\r\n detailB0OnA.point1 = detailB1OnA.point;\r\n const interval = CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);\r\n\r\n return restrictToBounds ? this.clampCoincidentOverlapToSegmentBounds(interval, pointA0, pointA1, pointB0, pointB1) : interval;\r\n }\r\n /**\r\n * Create a CurveLocationDetailPair for a coincident interval of two overlapping curves\r\n * @param cpA curveA\r\n * @param cpB curveB\r\n * @param fractionsOnA coincident interval of curveB in fraction space of curveA\r\n * @param fractionB0 curveB start in fraction space of curveA\r\n * @param fractionB1 curveB end in fraction space of curveA\r\n * @param reverse whether curveB and curveA have opposite direction\r\n */\r\n private createDetailPair(cpA: CurvePrimitive, cpB: CurvePrimitive, fractionsOnA: Segment1d, fractionB0: number, fractionB1: number, reverse: boolean): CurveLocationDetailPair | undefined {\r\n const deltaB = fractionB1 - fractionB0;\r\n const g0 = Geometry.conditionalDivideFraction(fractionsOnA.x0 - fractionB0, deltaB);\r\n const g1 = Geometry.conditionalDivideFraction(fractionsOnA.x1 - fractionB0, deltaB);\r\n if (g0 !== undefined && g1 !== undefined) {\r\n const detailA = CurveLocationDetail.createCurveEvaluatedFractionFraction(cpA, fractionsOnA.x0, fractionsOnA.x1);\r\n const detailB = CurveLocationDetail.createCurveEvaluatedFractionFraction(cpB, g0, g1);\r\n if (reverse)\r\n detailA.swapFractionsAndPoints();\r\n return CurveLocationDetailPair.createCapture(detailA, detailB);\r\n }\r\n return undefined;\r\n }\r\n private appendDetailPair(result: CurveLocationDetailPair[] | undefined, pair: CurveLocationDetailPair | undefined): CurveLocationDetailPair[] | undefined {\r\n if (pair === undefined)\r\n return result;\r\n if (result === undefined)\r\n return [pair];\r\n result.push(pair);\r\n return result;\r\n }\r\n /**\r\n * Test if 2 arcs have coinciding portions.\r\n * @param arcA\r\n * @param arcB\r\n * @param _restrictToBounds\r\n * @return 0, 1, or 2 overlap points/intervals\r\n */\r\n public coincidentArcIntersectionXY(arcA: Arc3d, arcB: Arc3d, _restrictToBounds: boolean = true): CurveLocationDetailPair[] | undefined {\r\n let result: CurveLocationDetailPair[] | undefined;\r\n if (arcA.center.isAlmostEqual(arcB.center, this.tolerance)) {\r\n const matrixBToA = arcA.matrixRef.multiplyMatrixInverseMatrix(arcB.matrixRef);\r\n if (matrixBToA) {\r\n const ux = matrixBToA.at(0, 0); const uy = matrixBToA.at(1, 0);\r\n const vx = matrixBToA.at(0, 1); const vy = matrixBToA.at(1, 1);\r\n const ru = Geometry.hypotenuseXY(ux, uy);\r\n const rv = Geometry.hypotenuseXY(vx, vy);\r\n const dot = Geometry.dotProductXYXY(ux, uy, vx, vy);\r\n const cross = Geometry.crossProductXYXY(ux, uy, vx, vy);\r\n if (Geometry.isAlmostEqualNumber(ru, 1.0)\r\n && Geometry.isAlmostEqualNumber(rv, 1.0)\r\n && Geometry.isAlmostEqualNumber(0, dot)) {\r\n const alphaB0Radians = Math.atan2(uy, ux); // angular position of arcB 0 point in arcA sweep\r\n const sweepDirection = cross > 0 ? 1.0 : -1.0; // 1 if arcB parameter space sweeps in same direction as arcA, -1 if opposite\r\n const betaStartRadians = alphaB0Radians + sweepDirection * arcB.sweep.startRadians; // arcB start in arcA parameter space\r\n const betaEndRadians = alphaB0Radians + sweepDirection * arcB.sweep.endRadians; // arcB end in arcA parameter space\r\n const fractionSpacesReversed = (sweepDirection * arcA.sweep.sweepRadians * arcB.sweep.sweepRadians) < 0;\r\n const sweepB = AngleSweep.createStartEndRadians(betaStartRadians, betaEndRadians);\r\n const sweepA = arcA.sweep;\r\n const fractionPeriodA = sweepA.fractionPeriod();\r\n const fractionB0 = sweepA.radiansToPositivePeriodicFraction(sweepB.startRadians); // arcB start in arcA fraction space\r\n assert(fractionB0 >= 0.0);\r\n const fractionSweep = sweepB.sweepRadians / sweepA.sweepRadians; // arcB sweep in arcA fraction space\r\n const fractionB1 = fractionB0 + fractionSweep; // arcB end in arcA fraction space\r\n const fractionSweepB = Segment1d.create(fractionB0, fractionB1);\r\n\r\n /** lambda to add a coincident interval or isolated intersection, given inputs in arcA fraction space\r\n * @param arcBInArcAFractionSpace span of arcB in arcA fraction space. On return, clamped to [0,1] if nontrivial.\r\n * @param testStartOfArcA if no nontrivial coincident interval was found, look for an isolated intersection at the start (true) or end (false) of arcA\r\n * @returns whether a detail pair was appended to result\r\n */\r\n const appendCoincidentIntersection = (arcBInArcAFractionSpace: Segment1d, testStartOfArcA: boolean): boolean => {\r\n const size = result ? result.length : 0;\r\n const arcBStart = arcBInArcAFractionSpace.x0;\r\n const arcBEnd = arcBInArcAFractionSpace.x1;\r\n if (arcBInArcAFractionSpace.clampDirectedTo01() && !Geometry.isSmallRelative(arcBInArcAFractionSpace.absoluteDelta())) {\r\n result = this.appendDetailPair(result, this.createDetailPair(arcA, arcB, arcBInArcAFractionSpace, arcBStart, arcBEnd, fractionSpacesReversed));\r\n } else { // test isolated intersection\r\n const testStartOfArcB = fractionSpacesReversed ? testStartOfArcA : !testStartOfArcA;\r\n const arcAPt = this._point0 = testStartOfArcA ? arcA.startPoint(this._point0) : arcA.endPoint(this._point0);\r\n const arcBPt = this._point1 = testStartOfArcB ? arcB.startPoint(this._point1) : arcB.endPoint(this._point1);\r\n if (arcAPt.isAlmostEqual(arcBPt, this.tolerance)) {\r\n const detailA = CurveLocationDetail.createCurveFractionPoint(arcA, testStartOfArcA ? 0 : 1, arcAPt);\r\n const detailB = CurveLocationDetail.createCurveFractionPoint(arcB, testStartOfArcB ? 0 : 1, arcBPt);\r\n result = this.appendDetailPair(result, CurveLocationDetailPair.createCapture(detailA, detailB));\r\n }\r\n }\r\n return result !== undefined && result.length > size;\r\n };\r\n\r\n appendCoincidentIntersection(fractionSweepB, false); // compute overlap in strict interior, or at end of arcA\r\n\r\n // check overlap at start of arcA with a periodic shift of fractionSweepB\r\n if (fractionB1 >= fractionPeriodA)\r\n appendCoincidentIntersection(Segment1d.create(fractionB0 - fractionPeriodA, fractionB1 - fractionPeriodA), true);\r\n else if (fractionB0 === 0.0)\r\n appendCoincidentIntersection(Segment1d.create(fractionB0 + fractionPeriodA, fractionB1 + fractionPeriodA), true);\r\n }\r\n }\r\n }\r\n return result;\r\n }\r\n}\r\n"]}
|
|
@@ -100,7 +100,11 @@ export declare class Segment1d {
|
|
|
100
100
|
* * On output, it is restricted to (0,1) while maintaining direction
|
|
101
101
|
* * If the clip leaves nothing, leave this segment alone and return false.
|
|
102
102
|
* * If the clip leaves something, update this segment and return true.
|
|
103
|
+
* @param clamp0 whether to clamp the smaller number to 0. Default value is true.
|
|
104
|
+
* @param clamp1 whether to clamp the larger number to 1. Default value is true.
|
|
105
|
+
* @param allowSingleton whether to return true for an interval clipped to a single number (x0 === x1). Default value is false.
|
|
106
|
+
* @return whether this interval was clipped
|
|
103
107
|
*/
|
|
104
|
-
clampDirectedTo01(): boolean;
|
|
108
|
+
clampDirectedTo01(clamp0?: boolean, clamp1?: boolean, allowSingleton?: boolean): boolean;
|
|
105
109
|
}
|
|
106
110
|
//# sourceMappingURL=Segment1d.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Segment1d.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/Segment1d.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;GAcG;AACH,qBAAa,SAAS;IACpB,uBAAuB;IAChB,EAAE,EAAE,MAAM,CAAC;IAClB,qBAAqB;IACd,EAAE,EAAE,MAAM,CAAC;IAClB,OAAO;IAIP;;;;OAIG;IACI,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IACjC;;;OAGG;IACI,KAAK,CAAC,EAAE,EAAE,MAAM;IACvB;;;;;OAKG;WACW,MAAM,CAAC,EAAE,GAAE,MAAU,EAAE,EAAE,GAAE,MAAU,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS;IAMnF;;;OAGG;IACI,OAAO,CAAC,KAAK,EAAE,SAAS;IAC/B;;OAEG;IACI,KAAK,IAAI,SAAS;IACzB;;OAEG;IACH,IAAW,MAAM,YAGhB;IACD;;;;OAIG;IACI,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAChD;;OAEG;IACI,WAAW,IAAI,MAAM;IAC5B;;OAEG;IACI,aAAa,IAAI,MAAM;IAC9B;;;OAGG;IACI,cAAc,IAAI,IAAI;IAC7B;;;OAGG;IACI,2BAA2B,CAAC,IAAI,GAAE,MAAU,GAAG,IAAI;IAI1D;;OAEG;IACI,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO;IAG/C;;OAEG;IACH,IAAW,SAAS,IAAI,OAAO,CAA+C;IAC9E;;OAEG;IACH,IAAW,iBAAiB,IAAI,OAAO,CAA+C;IAEtF;;;;;;;OAOG;IACI,8BAA8B,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO;IAqBtE
|
|
1
|
+
{"version":3,"file":"Segment1d.d.ts","sourceRoot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145
|
* * On output, it is restricted to (0,1) while maintaining direction
|
|
146
146
|
* * If the clip leaves nothing, leave this segment alone and return false.
|
|
147
147
|
* * If the clip leaves something, update this segment and return true.
|
|
148
|
+
* @param clamp0 whether to clamp the smaller number to 0. Default value is true.
|
|
149
|
+
* @param clamp1 whether to clamp the larger number to 1. Default value is true.
|
|
150
|
+
* @param allowSingleton whether to return true for an interval clipped to a single number (x0 === x1). Default value is false.
|
|
151
|
+
* @return whether this interval was clipped
|
|
148
152
|
*/
|
|
149
|
-
clampDirectedTo01() {
|
|
153
|
+
clampDirectedTo01(clamp0 = true, clamp1 = true, allowSingleton = false) {
|
|
150
154
|
let x0 = this.x0;
|
|
151
155
|
let x1 = this.x1;
|
|
152
156
|
if (x1 > x0) {
|
|
153
|
-
if (x0 < 0)
|
|
157
|
+
if (x0 < 0 && clamp0)
|
|
154
158
|
x0 = 0;
|
|
155
|
-
if (x1 > 1)
|
|
159
|
+
if (x1 > 1 && clamp1)
|
|
156
160
|
x1 = 1;
|
|
157
|
-
if (x0
|
|
161
|
+
if (x0 > x1 || (x0 === x1 && !allowSingleton))
|
|
158
162
|
return false;
|
|
159
163
|
}
|
|
160
164
|
else {
|
|
161
|
-
if (x0 > 1)
|
|
165
|
+
if (x0 > 1 && clamp1)
|
|
162
166
|
x0 = 1;
|
|
163
|
-
if (x1 < 0)
|
|
167
|
+
if (x1 < 0 && clamp0)
|
|
164
168
|
x1 = 0;
|
|
165
|
-
if (x0
|
|
169
|
+
if (x0 < x1 || (x0 === x1 && !allowSingleton))
|
|
166
170
|
return false;
|
|
167
171
|
}
|
|
168
172
|
this.set(x0, x1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Segment1d.js","sourceRoot":"","sources":["../../../src/geometry3d/Segment1d.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AAEvC;;;;;;;;;;;;;;GAcG;AACH,MAAa,SAAS;IAKpB,YAAoB,EAAU,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YACL,IAAI,EAAE,GAAG,CAAC;gBAAE,EAAE,GAAG,CAAC,CAAC;YACnB,IAAI,EAAE,GAAG,CAAC;gBAAE,EAAE,GAAG,CAAC,CAAC;YACnB,IAAI,EAAE,IAAI,EAAE;gBACV,OAAO,KAAK,CAAC;SAChB;QACD,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;CAEF;AA/ID,8BA+IC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\n\r\n/**\r\n * * A Segment1d is an interval of an axis named x.\r\n * * The interval is defined by two values x0 and x1.\r\n * * The x0 and x1 values can be in either order.\r\n * * if `x0 < x1` fractional coordinates within the segment move from left to right.\r\n * * if `x0 > x1` fractional coordinates within the segment move from right to left.\r\n * * This differs from a Range1d in that:\r\n * * For a Range1d the reversed ordering of its limit values means \"empty interval\".\r\n * * For a Segment1d the reversed ordering is a real interval but fractional positions move backwards.\r\n * * The segment is parameterized with a fraction\r\n * * * Fraction 0 is the start (`x0`)\r\n * * * Fraction 1 is the end (`x1`)\r\n * * * The fraction equation is `x = x0 + fraction * (x1-x0)` or (equivalently) `x = (1-fraction) * x0 + fraction * x1`\r\n * @public\r\n */\r\nexport class Segment1d {\r\n /** start coordinate */\r\n public x0: number;\r\n /** end coordinate */\r\n public x1: number;\r\n private constructor(x0: number, x1: number) {\r\n this.x0 = x0;\r\n this.x1 = x1;\r\n }\r\n /**\r\n * replace both end values.\r\n * @param x0 new x0 value\r\n * @param x1 new y0 value\r\n */\r\n public set(x0: number, x1: number) { this.x0 = x0, this.x1 = x1; }\r\n /**\r\n * shift (translate) the segment along its axis by adding `dx` to both `x0` and `x1`.\r\n * @param dx value to add to both x0 and x1\r\n */\r\n public shift(dx: number) { this.x0 += dx, this.x1 += dx; }\r\n /**\r\n * create segment1d with given end values\r\n * @param x0 start value\r\n * @param x1 end value\r\n * @param result optional pre-existing result to be reinitialized.\r\n */\r\n public static create(x0: number = 0, x1: number = 1, result?: Segment1d): Segment1d {\r\n if (!result)\r\n return new Segment1d(x0, x1);\r\n result.set(x0, x1);\r\n return result;\r\n }\r\n /**\r\n * Copy both end values from other Segment1d\r\n * @param other source Segment1d\r\n */\r\n public setFrom(other: Segment1d) { this.x0 = other.x0; this.x1 = other.x1; }\r\n /**\r\n * clone this Segment1d, return as a separate object.\r\n */\r\n public clone(): Segment1d { return new Segment1d(this.x0, this.x1); }\r\n /**\r\n * Returns true if both coordinates (`x0` and `x1`) are in the 0..1 range.\r\n */\r\n public get isIn01() {\r\n return Geometry.isIn01(this.x0) && Geometry.isIn01(this.x1);\r\n\r\n }\r\n /**\r\n * Evaluate the segment at fractional position\r\n * @returns position within the segment\r\n * @param fraction fractional position within this segment\r\n */\r\n public fractionToPoint(fraction: number): number { return Geometry.interpolate(this.x0, fraction, this.x1); }\r\n /**\r\n * Return the signed start-to-end shift (aka signed distance)\r\n */\r\n public signedDelta(): number { return this.x1 - this.x0; }\r\n /**\r\n * Return the absolute start-to-end shift (aka distance)\r\n */\r\n public absoluteDelta(): number { return Math.abs(this.x1 - this.x0); }\r\n /**\r\n * * swap the x0 and x1 member values.\r\n * * This makes the fractionToPoint evaluates reverse direction.\r\n */\r\n public reverseInPlace(): void { const x = this.x0; this.x0 = this.x1; this.x1 = x; }\r\n /**\r\n * * if `x1-x0` multiplied by the scale factor is (strictly) negative, swap the x0 and x1 member values.\r\n * * This makes the fractionToPoint evaluates reverse direction.\r\n */\r\n public reverseIfNeededForDeltaSign(sign: number = 1): void {\r\n if (sign * (this.x1 - this.x0) < 0)\r\n this.reverseInPlace();\r\n }\r\n /**\r\n * Near equality test, using Geometry.isSameCoordinate for tolerances.\r\n */\r\n public isAlmostEqual(other: Segment1d): boolean {\r\n return Geometry.isSameCoordinate(this.x0, other.x0) && Geometry.isSameCoordinate(this.x1, other.x1);\r\n }\r\n /**\r\n * Return true if the segment limits are (exactly) 0 and 1\r\n */\r\n public get isExact01(): boolean { return this.x0 === 0.0 && this.x1 === 1.0; }\r\n /**\r\n * Return true if the segment limits are (exactly) 1 and 0\r\n */\r\n public get isExact01Reversed(): boolean { return this.x0 === 1.0 && this.x1 === 0.0; }\r\n\r\n /** On input, `this` is an interval of a line. On output, the interval has been clipped to positive parts of a linear function\r\n * * f0 and f1 are values at parameter values 0 and 1 (which are in general NOT x0 and x1)\r\n * * From that determine where the segment crosses function value 0.\r\n * * The segment contains some interval in the same parameter space.\r\n * * Clip the segment to the positive part of the space.\r\n * * Return true (and modify the segment) if any of the segment remains.\r\n * * Return false (but without modifying the segment) if the active part is entirely out.\r\n */\r\n public clipBy01FunctionValuesPositive(f0: number, f1: number): boolean {\r\n const df01 = f1 - f0;\r\n const fA = f0 + this.x0 * df01;\r\n const fB = f0 + this.x1 * df01;\r\n const dfAB = fB - fA;\r\n if (fA > 0) {\r\n if (fB >= 0) return true; // inside at both ends\r\n /** There is an inside to outside crossing. The division is safe ... (and value between 0 and 1) */\r\n const u = -fA / dfAB;\r\n this.x1 = this.x0 + u * (this.x1 - this.x0);\r\n return true;\r\n } else if (fA < 0) {\r\n if (fB < 0) return false; // outside at both ends.\r\n /** There is an outside to inside crossing crossing. The division is safe ... (and value between 0 and 1) */\r\n const u = -fA / dfAB;\r\n this.x0 = this.x0 + u * (this.x1 - this.x0);\r\n return true;\r\n }\r\n /** fA is on the cut. fB determines the entire segment. */\r\n return fB > 0;\r\n }\r\n /**\r\n * * On input, (f0,f1) is a (directed) segment.\r\n * * On output, it is restricted to (0,1) while maintaining direction\r\n * * If the clip leaves nothing, leave this segment alone and return false.\r\n * * If the clip leaves something, update this segment and return true.\r\n */\r\n public clampDirectedTo01(): boolean {\r\n let x0 = this.x0;\r\n let x1 = this.x1;\r\n if (x1 > x0) {\r\n if (x0 < 0) x0 = 0;\r\n if (x1 > 1) x1 = 1;\r\n if (x0 >= x1)\r\n return false;\r\n } else {\r\n if (x0 > 1) x0 = 1;\r\n if (x1 < 0) x1 = 0;\r\n if (x0 <= x1)\r\n return false;\r\n }\r\n this.set(x0, x1);\r\n return true;\r\n }\r\n\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Segment1d.js","sourceRoot":"","sources":["../../../src/geometry3d/Segment1d.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AAEvC;;;;;;;;;;;;;;GAcG;AACH,MAAa,SAAS;IAKpB,YAAoB,EAAU,EAAE,EAAU;QACxC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IACD;;;;OAIG;IACI,GAAG,CAAC,EAAU,EAAE,EAAU,IAAI,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IAClE;;;OAGG;IACI,KAAK,CAAC,EAAU,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1D;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,KAAa,CAAC,EAAE,KAAa,CAAC,EAAE,MAAkB;QACrE,IAAI,CAAC,MAAM;YACT,OAAO,IAAI,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC/B,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACnB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD;;;OAGG;IACI,OAAO,CAAC,KAAgB,IAAI,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC,CA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AC5C,OAAO,IAAI,CAAC;SACb;QACD,4DAA4D;QAC5D,OAAO,EAAE,GAAG,CAAC,CAAC;IAChB,CAAC;IACD;;;;;;;;;OASG;IACI,iBAAiB,CAAC,SAAkB,IAAI,EAAE,SAAkB,IAAI,EAAE,iBAA0B,KAAK;QACtG,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QACjB,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QACjB,IAAI,EAAE,GAAG,EAAE,EAAE;YACX,IAAI,EAAE,GAAG,CAAC,IAAI,MAAM;gBAClB,EAAE,GAAG,CAAC,CAAC;YACT,IAAI,EAAE,GAAG,CAAC,IAAI,MAAM;gBAClB,EAAE,GAAG,CAAC,CAAC;YACT,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC;gBAC3C,OAAO,KAAK,CAAC;SAChB;aAAM;YACL,IAAI,EAAE,GAAG,CAAC,IAAI,MAAM;gBAClB,EAAE,GAAG,CAAC,CAAC;YACT,IAAI,EAAE,GAAG,CAAC,IAAI,MAAM;gBAClB,EAAE,GAAG,CAAC,CAAC;YACT,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC;gBAC3C,OAAO,KAAK,CAAC;SAChB;QACD,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAtJD,8BAsJC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\n\r\n/**\r\n * * A Segment1d is an interval of an axis named x.\r\n * * The interval is defined by two values x0 and x1.\r\n * * The x0 and x1 values can be in either order.\r\n * * if `x0 < x1` fractional coordinates within the segment move from left to right.\r\n * * if `x0 > x1` fractional coordinates within the segment move from right to left.\r\n * * This differs from a Range1d in that:\r\n * * For a Range1d the reversed ordering of its limit values means \"empty interval\".\r\n * * For a Segment1d the reversed ordering is a real interval but fractional positions move backwards.\r\n * * The segment is parameterized with a fraction\r\n * * * Fraction 0 is the start (`x0`)\r\n * * * Fraction 1 is the end (`x1`)\r\n * * * The fraction equation is `x = x0 + fraction * (x1-x0)` or (equivalently) `x = (1-fraction) * x0 + fraction * x1`\r\n * @public\r\n */\r\nexport class Segment1d {\r\n /** start coordinate */\r\n public x0: number;\r\n /** end coordinate */\r\n public x1: number;\r\n private constructor(x0: number, x1: number) {\r\n this.x0 = x0;\r\n this.x1 = x1;\r\n }\r\n /**\r\n * replace both end values.\r\n * @param x0 new x0 value\r\n * @param x1 new y0 value\r\n */\r\n public set(x0: number, x1: number) { this.x0 = x0, this.x1 = x1; }\r\n /**\r\n * shift (translate) the segment along its axis by adding `dx` to both `x0` and `x1`.\r\n * @param dx value to add to both x0 and x1\r\n */\r\n public shift(dx: number) { this.x0 += dx, this.x1 += dx; }\r\n /**\r\n * create segment1d with given end values\r\n * @param x0 start value\r\n * @param x1 end value\r\n * @param result optional pre-existing result to be reinitialized.\r\n */\r\n public static create(x0: number = 0, x1: number = 1, result?: Segment1d): Segment1d {\r\n if (!result)\r\n return new Segment1d(x0, x1);\r\n result.set(x0, x1);\r\n return result;\r\n }\r\n /**\r\n * Copy both end values from other Segment1d\r\n * @param other source Segment1d\r\n */\r\n public setFrom(other: Segment1d) { this.x0 = other.x0; this.x1 = other.x1; }\r\n /**\r\n * clone this Segment1d, return as a separate object.\r\n */\r\n public clone(): Segment1d { return new Segment1d(this.x0, this.x1); }\r\n /**\r\n * Returns true if both coordinates (`x0` and `x1`) are in the 0..1 range.\r\n */\r\n public get isIn01() {\r\n return Geometry.isIn01(this.x0) && Geometry.isIn01(this.x1);\r\n\r\n }\r\n /**\r\n * Evaluate the segment at fractional position\r\n * @returns position within the segment\r\n * @param fraction fractional position within this segment\r\n */\r\n public fractionToPoint(fraction: number): number { return Geometry.interpolate(this.x0, fraction, this.x1); }\r\n /**\r\n * Return the signed start-to-end shift (aka signed distance)\r\n */\r\n public signedDelta(): number { return this.x1 - this.x0; }\r\n /**\r\n * Return the absolute start-to-end shift (aka distance)\r\n */\r\n public absoluteDelta(): number { return Math.abs(this.x1 - this.x0); }\r\n /**\r\n * * swap the x0 and x1 member values.\r\n * * This makes the fractionToPoint evaluates reverse direction.\r\n */\r\n public reverseInPlace(): void { const x = this.x0; this.x0 = this.x1; this.x1 = x; }\r\n /**\r\n * * if `x1-x0` multiplied by the scale factor is (strictly) negative, swap the x0 and x1 member values.\r\n * * This makes the fractionToPoint evaluates reverse direction.\r\n */\r\n public reverseIfNeededForDeltaSign(sign: number = 1): void {\r\n if (sign * (this.x1 - this.x0) < 0)\r\n this.reverseInPlace();\r\n }\r\n /**\r\n * Near equality test, using Geometry.isSameCoordinate for tolerances.\r\n */\r\n public isAlmostEqual(other: Segment1d): boolean {\r\n return Geometry.isSameCoordinate(this.x0, other.x0) && Geometry.isSameCoordinate(this.x1, other.x1);\r\n }\r\n /**\r\n * Return true if the segment limits are (exactly) 0 and 1\r\n */\r\n public get isExact01(): boolean { return this.x0 === 0.0 && this.x1 === 1.0; }\r\n /**\r\n * Return true if the segment limits are (exactly) 1 and 0\r\n */\r\n public get isExact01Reversed(): boolean { return this.x0 === 1.0 && this.x1 === 0.0; }\r\n\r\n /** On input, `this` is an interval of a line. On output, the interval has been clipped to positive parts of a linear function\r\n * * f0 and f1 are values at parameter values 0 and 1 (which are in general NOT x0 and x1)\r\n * * From that determine where the segment crosses function value 0.\r\n * * The segment contains some interval in the same parameter space.\r\n * * Clip the segment to the positive part of the space.\r\n * * Return true (and modify the segment) if any of the segment remains.\r\n * * Return false (but without modifying the segment) if the active part is entirely out.\r\n */\r\n public clipBy01FunctionValuesPositive(f0: number, f1: number): boolean {\r\n const df01 = f1 - f0;\r\n const fA = f0 + this.x0 * df01;\r\n const fB = f0 + this.x1 * df01;\r\n const dfAB = fB - fA;\r\n if (fA > 0) {\r\n if (fB >= 0) return true; // inside at both ends\r\n /** There is an inside to outside crossing. The division is safe ... (and value between 0 and 1) */\r\n const u = -fA / dfAB;\r\n this.x1 = this.x0 + u * (this.x1 - this.x0);\r\n return true;\r\n } else if (fA < 0) {\r\n if (fB < 0) return false; // outside at both ends.\r\n /** There is an outside to inside crossing crossing. The division is safe ... (and value between 0 and 1) */\r\n const u = -fA / dfAB;\r\n this.x0 = this.x0 + u * (this.x1 - this.x0);\r\n return true;\r\n }\r\n /** fA is on the cut. fB determines the entire segment. */\r\n return fB > 0;\r\n }\r\n /**\r\n * * On input, (f0,f1) is a (directed) segment.\r\n * * On output, it is restricted to (0,1) while maintaining direction\r\n * * If the clip leaves nothing, leave this segment alone and return false.\r\n * * If the clip leaves something, update this segment and return true.\r\n * @param clamp0 whether to clamp the smaller number to 0. Default value is true.\r\n * @param clamp1 whether to clamp the larger number to 1. Default value is true.\r\n * @param allowSingleton whether to return true for an interval clipped to a single number (x0 === x1). Default value is false.\r\n * @return whether this interval was clipped\r\n */\r\n public clampDirectedTo01(clamp0: boolean = true, clamp1: boolean = true, allowSingleton: boolean = false): boolean {\r\n let x0 = this.x0;\r\n let x1 = this.x1;\r\n if (x1 > x0) {\r\n if (x0 < 0 && clamp0)\r\n x0 = 0;\r\n if (x1 > 1 && clamp1)\r\n x1 = 1;\r\n if (x0 > x1 || (x0 === x1 && !allowSingleton))\r\n return false;\r\n } else {\r\n if (x0 > 1 && clamp1)\r\n x0 = 1;\r\n if (x1 < 0 && clamp0)\r\n x1 = 0;\r\n if (x0 < x1 || (x0 === x1 && !allowSingleton))\r\n return false;\r\n }\r\n this.set(x0, x1);\r\n return true;\r\n }\r\n}\r\n"]}
|
|
@@ -182,7 +182,7 @@ export declare class Point4d extends Plane3d implements BeJSONFunctions {
|
|
|
182
182
|
/** Divide by denominator, but return undefined if denominator is zero. */
|
|
183
183
|
safeDivideOrNull(denominator: number, result?: Point4d): Point4d | undefined;
|
|
184
184
|
/**
|
|
185
|
-
* * Return xyz projection of spacePoint to the plane
|
|
185
|
+
* * Return xyz projection of spacePoint to the plane (this Point4d is understood as plane coefficients, not point coordinates)
|
|
186
186
|
* * If the xyz part of `this` are all zero, (a clone of) `spacePoint` is returned.
|
|
187
187
|
*/
|
|
188
188
|
projectPointToPlane(spacePoint: Point3d, result?: Point3d): Point3d;
|
|
@@ -339,7 +339,7 @@ class Point4d extends Plane3d_1.Plane3d {
|
|
|
339
339
|
return undefined;
|
|
340
340
|
}
|
|
341
341
|
/**
|
|
342
|
-
* * Return xyz projection of spacePoint to the plane
|
|
342
|
+
* * Return xyz projection of spacePoint to the plane (this Point4d is understood as plane coefficients, not point coordinates)
|
|
343
343
|
* * If the xyz part of `this` are all zero, (a clone of) `spacePoint` is returned.
|
|
344
344
|
*/
|
|
345
345
|
projectPointToPlane(spacePoint, result) {
|