@itwin/core-geometry 5.2.0 → 5.2.1
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 +6 -1
- package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
- package/lib/cjs/curve/Arc3d.js +5 -7
- package/lib/cjs/curve/Arc3d.js.map +1 -1
- package/lib/cjs/curve/CurveOps.d.ts +2 -5
- package/lib/cjs/curve/CurveOps.d.ts.map +1 -1
- package/lib/cjs/curve/CurveOps.js +2 -5
- package/lib/cjs/curve/CurveOps.js.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.d.ts +50 -15
- package/lib/cjs/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.js +102 -84
- package/lib/cjs/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +44 -25
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +74 -39
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js +8 -8
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -0
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +102 -92
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.d.ts +2 -1
- package/lib/cjs/geometry3d/GrowableXYArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.js +2 -1
- package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts +2 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.js +2 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +9 -16
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.js +3 -3
- package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/cjs/geometry3d/PolylineOps.d.ts +2 -2
- package/lib/cjs/geometry3d/PolylineOps.js +2 -2
- package/lib/cjs/geometry3d/PolylineOps.js.map +1 -1
- package/lib/cjs/numerics/ClusterableArray.d.ts.map +1 -1
- package/lib/cjs/numerics/ClusterableArray.js +2 -2
- package/lib/cjs/numerics/ClusterableArray.js.map +1 -1
- package/lib/cjs/topology/Merging.d.ts +15 -7
- package/lib/cjs/topology/Merging.d.ts.map +1 -1
- package/lib/cjs/topology/Merging.js +15 -10
- package/lib/cjs/topology/Merging.js.map +1 -1
- package/lib/esm/curve/Arc3d.d.ts.map +1 -1
- package/lib/esm/curve/Arc3d.js +5 -7
- package/lib/esm/curve/Arc3d.js.map +1 -1
- package/lib/esm/curve/CurveOps.d.ts +2 -5
- package/lib/esm/curve/CurveOps.d.ts.map +1 -1
- package/lib/esm/curve/CurveOps.js +2 -5
- package/lib/esm/curve/CurveOps.js.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.d.ts +50 -15
- package/lib/esm/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.js +102 -84
- package/lib/esm/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +44 -25
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +72 -37
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.js +8 -8
- package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -0
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +102 -92
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.d.ts +2 -1
- package/lib/esm/geometry3d/GrowableXYArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.js +2 -1
- package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts +2 -1
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.js +2 -1
- package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +9 -16
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.js +3 -3
- package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/esm/geometry3d/PolylineOps.d.ts +2 -2
- package/lib/esm/geometry3d/PolylineOps.js +2 -2
- package/lib/esm/geometry3d/PolylineOps.js.map +1 -1
- package/lib/esm/numerics/ClusterableArray.d.ts.map +1 -1
- package/lib/esm/numerics/ClusterableArray.js +2 -2
- package/lib/esm/numerics/ClusterableArray.js.map +1 -1
- package/lib/esm/topology/Merging.d.ts +15 -7
- package/lib/esm/topology/Merging.d.ts.map +1 -1
- package/lib/esm/topology/Merging.js +15 -10
- package/lib/esm/topology/Merging.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurveOps.d.ts","sourceRoot":"","sources":["../../../src/curve/CurveOps.ts"],"names":[],"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CAAC,MAAM,EAAE,QAAQ,GAAG,0BAA0B,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,KAAK,GAAG,SAAS;CAyC5H"}
|
|
@@ -186,8 +186,7 @@ class CurveOps {
|
|
|
186
186
|
/**
|
|
187
187
|
* Check whether or not the curves are planar, and if so, return a localToWorld frame.
|
|
188
188
|
* @param curves input geometry: curves or points.
|
|
189
|
-
* @param
|
|
190
|
-
* @param result optional pre-allocated object to populate and return.
|
|
189
|
+
* @param options bundle of options.
|
|
191
190
|
* @returns localToWorld frame `T` for coplanar curves, or undefined if they are not coplanar.
|
|
192
191
|
* `T` satisfies:
|
|
193
192
|
* * `T.origin` is in the plane.
|
|
@@ -207,9 +206,7 @@ class CurveOps {
|
|
|
207
206
|
* Check whether or not the curves lie in a straight line, and if so, return a colinear ray.
|
|
208
207
|
* * This test does not take curve traversal or point order into account.
|
|
209
208
|
* @param curves input geometry: curves or points.
|
|
210
|
-
* @param
|
|
211
|
-
* @param tolerance optional maximum allowable linear deviation, default [[Geometry.smallMetricDistance]].
|
|
212
|
-
* @param result optional pre-allocated object to populate and return.
|
|
209
|
+
* @param options bundle of options.
|
|
213
210
|
* @returns ray colinear with input, or undefined if input is not colinear.
|
|
214
211
|
*/
|
|
215
212
|
static isColinear(curves, options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurveOps.js","sourceRoot":"","sources":["../../../src/curve/CurveOps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAkD;AAClD,6DAA0D;AAE1D,mEAAyD;AACzD,+CAA8C;AAC9C,+CAA4C;AAC5C,uDAAoD;AACpD,uDAAiE;AACjE,qDAAkD;AAElD,mDAAgD;AAChD,gFAA6E;AAC7E,kFAAsF;AAEtF,iCAA8B;AAE9B,iCAA8B;AAoB9B;;;GAGG;AACH,MAAa,QAAQ;IACnB,8GAA8G;IACvG,MAAM,CAAC,UAAU,CAAC,MAA6B;QACpD,IAAI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OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC3C,OAAO,GAAG,CAAC,CAAC,oCAAoC;QAClD,CAAC;QACD,IAAI,OAAO,IAAI,WAAW,EAAE,CAAC;YAC3B,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC3C,OAAO,GAAG,CAAC,CAAC,oCAAoC;QAClD,CAAC;QACD,IAAI,CAAC,OAAO,EAAE,UAAU;YACtB,OAAO,SAAS,CAAC,CAAC,eAAe;QAEnC,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,eAAe,IAAI,mBAAQ,CAAC,iBAAiB,CAAC,CAAC;QACxF,MAAM,sBAAsB,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC,oBAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAChG,IAAI,sBAAsB,GAAG,cAAc,EAAE,2CAA2C;YACtF,OAAO,SAAS,CAAC,CAAC,kBAAkB;QAEtC,IAAI,OAAO,GAAG,OAAO;YACnB,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;;YAE3C,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC7C,GAAG,CAAC,SAAS,CAAC,CAAC,GAAG,GAAG,CAAC;QACtB,OAAO,GAAG,CAAC,CAAC,kCAAkC;IAChD,CAAC;CACF;AA7ND,4BA6NC","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 { AxisIndex, Geometry } from \"../Geometry\";\r\nimport { FrameBuilder } from \"../geometry3d/FrameBuilder\";\r\nimport { MultiLineStringDataVariant } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { BagOfCurves, CurveCollection } from \"./CurveCollection\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { AnyChain, AnyCurve } from \"./CurveTypes\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\nimport { MultiChainCollector } from \"./internalContexts/MultiChainCollector\";\r\nimport { CurveChainWireOffsetContext } from \"./internalContexts/PolygonOffsetContext\";\r\nimport { LineString3d } from \"./LineString3d\";\r\nimport { Loop } from \"./Loop\";\r\nimport { OffsetOptions } from \"./OffsetOptions\";\r\nimport { Path } from \"./Path\";\r\nimport { StrokeOptions } from \"./StrokeOptions\";\r\n\r\n /**\r\n * Options bundle for use in [[CurveOps.isPlanar]] and [[CurveOps.isColinear]].\r\n * @public\r\n */\r\n export interface PlanarColinearOptions {\r\n /** Maximum allowable distance that geometry can deviate from planarity/colinearity. Default is [[Geometry.smallMetricDistance]]. */\r\n maxDeviation?: number;\r\n /** Whether colinearity test ignores z-coordinates. Default is `false`. */\r\n xyColinear?: boolean;\r\n /** Radian tolerance for xy-colinearity, measuring maximum angular deviation from a vertical plane. Default is [[Geometry.smallAngleRadians]]. */\r\n radianTolerance?: number;\r\n /** Pre-allocated object to populate with the computed plane-to-world transformation and return when planarity test succeeds. */\r\n localToWorld?: Transform;\r\n /** Pre-allocated object to populate with the computed line and return when colinear test succeeds. */\r\n colinearRay?: Ray3d;\r\n }\r\n\r\n/**\r\n * Static methods for miscellaneous curve operations.\r\n * @public\r\n */\r\nexport class CurveOps {\r\n /** Recursively sum curve lengths, allowing CurvePrimitive, CurveCollection, or array of such at any level. */\r\n public static sumLengths(curves: AnyCurve | AnyCurve[]): number {\r\n let mySum = 0;\r\n if (curves instanceof CurvePrimitive) {\r\n mySum += curves.curveLength();\r\n } else if (curves instanceof CurveCollection) {\r\n mySum += curves.sumLengths();\r\n } else if (Array.isArray(curves)) {\r\n for (const data1 of curves)\r\n mySum += this.sumLengths(data1);\r\n }\r\n return mySum;\r\n }\r\n /** Recursively extend the range by each curve's range, allowing CurvePrimitive, CurveCollection, or array of such at any level. */\r\n public static extendRange(range: Range3d, curves: AnyCurve | AnyCurve[], transform?: Transform): Range3d {\r\n if (Array.isArray(curves)) {\r\n for (const data1 of curves)\r\n this.extendRange(range, data1, transform);\r\n } else {\r\n curves.extendRange(range, transform);\r\n }\r\n return range;\r\n }\r\n /**\r\n * Construct a separate xy-offset for each input curve.\r\n * * For best offset results, the inputs should be parallel to the xy-plane.\r\n * @param curves input curve(s), z-coordinates ignored. Only curves of type [[AnyChain]] are handled.\r\n * @param offset offset distance (positive to left of curve, negative to right)\r\n * @param result array to collect offset curves\r\n * @returns summed length of offset curves\r\n */\r\n public static appendXYOffsets(curves: AnyCurve | AnyCurve[] | undefined, offset: number, result: AnyCurve[]): number {\r\n let summedLengths = 0;\r\n if (curves instanceof CurvePrimitive) {\r\n const resultA = CurveChainWireOffsetContext.constructCurveXYOffset(Path.create(curves), offset);\r\n if (resultA) {\r\n summedLengths += this.sumLengths(resultA);\r\n result.push(resultA);\r\n }\r\n } else if (curves instanceof Loop || curves instanceof Path) {\r\n const resultA = CurveChainWireOffsetContext.constructCurveXYOffset(curves, offset);\r\n if (resultA) {\r\n summedLengths += this.sumLengths(resultA);\r\n result.push(resultA);\r\n }\r\n } else if (curves instanceof BagOfCurves) {\r\n for (const q of curves.children)\r\n summedLengths += this.appendXYOffsets(q, offset, result);\r\n } else if (Array.isArray(curves)) {\r\n for (const q of curves)\r\n summedLengths += this.appendXYOffsets(q, offset, result);\r\n }\r\n return summedLengths;\r\n }\r\n /**\r\n * Restructure curve fragments as Paths and Loops, and construct xy-offsets of the chains.\r\n * * If the inputs do not form Loop(s), the classification of offsets is suspect.\r\n * * For best offset results, the inputs should be parallel to the xy-plane.\r\n * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.\r\n * @param fragments fragments to be chained and offset\r\n * @param offsetDistance offset distance, applied to both sides of each fragment to produce inside and outside xy-offset curves.\r\n * @param gapTolerance distance to be treated as \"effectively zero\" when joining head-to-tail\r\n * @returns object with named chains, insideOffsets, outsideOffsets\r\n */\r\n public static collectInsideAndOutsideXYOffsets(fragments: AnyCurve[], offsetDistance: number, gapTolerance: number): { insideOffsets: AnyCurve[], outsideOffsets: AnyCurve[], chains?: AnyChain } {\r\n const collector = new MultiChainCollector(gapTolerance, gapTolerance);\r\n for (const s of fragments) {\r\n collector.captureCurve(s);\r\n }\r\n const chains = collector.grabResult(true);\r\n const myOffsetA: CurveCollection[] = [];\r\n const myOffsetB: CurveCollection[] = [];\r\n const offsetLengthA = CurveOps.appendXYOffsets(chains, offsetDistance, myOffsetA);\r\n const offsetLengthB = CurveOps.appendXYOffsets(chains, -offsetDistance, myOffsetB);\r\n if (offsetLengthA > offsetLengthB) {\r\n return { outsideOffsets: myOffsetA, insideOffsets: myOffsetB, chains };\r\n } else {\r\n return { insideOffsets: myOffsetA, outsideOffsets: myOffsetB, chains };\r\n }\r\n }\r\n /**\r\n * Construct curves that are offset from a Path or Loop as viewed in xy-plane (ignoring z).\r\n * * The construction will remove \"some\" local effects of features smaller than the offset distance, but will not detect self intersection among widely separated edges.\r\n * @param curves base curves.\r\n * @param offsetDistanceOrOptions offset distance (positive to left of curve, negative to right) or options object.\r\n */\r\n public static constructCurveXYOffset(curves: Path | Loop, offsetDistanceOrOptions: number | OffsetOptions): CurveCollection | undefined {\r\n return CurveChainWireOffsetContext.constructCurveXYOffset(curves, offsetDistanceOrOptions);\r\n }\r\n /**\r\n * Create the offset of a single curve primitive as viewed in the xy-plane (ignoring z).\r\n * @param curve primitive to offset\r\n * @param offsetDistanceOrOptions offset distance (positive to left of curve, negative to right) or options object\r\n */\r\n public static createSingleOffsetPrimitiveXY(curve: CurvePrimitive, offsetDistanceOrOptions: number | OffsetOptions): CurvePrimitive | CurvePrimitive[] | undefined {\r\n return CurveChainWireOffsetContext.createSingleOffsetPrimitiveXY(curve, offsetDistanceOrOptions);\r\n }\r\n /**\r\n * Restructure curve fragments as Paths and Loops.\r\n * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.\r\n * @param fragments fragments to be chained\r\n * @param gapTolerance distance to be treated as \"effectively zero\" when assembling fragments head-to-tail\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 * @returns chains, possibly wrapped in a [[BagOfCurves]].\r\n */\r\n public static collectChains(fragments: AnyCurve[], gapTolerance: number = Geometry.smallMetricDistance, planeTolerance?: number): AnyChain | undefined {\r\n const collector = new MultiChainCollector(gapTolerance, planeTolerance);\r\n for (const s of fragments) {\r\n collector.captureCurve(s);\r\n }\r\n return collector.grabResult(true);\r\n }\r\n /**\r\n * Restructure curve fragments, to be stroked and passed into the callback.\r\n * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.\r\n * @param fragments fragments to be chained and stroked\r\n * @param announceChain callback to process each stroked Path and Loop\r\n * @param strokeOptions options for stroking the chains\r\n * @param gapTolerance distance to be treated as \"effectively zero\" when assembling fragments head-to-tail. Also used for removing duplicate points in the stroked chains.\r\n * @param _planeTolerance unused, pass undefined\r\n */\r\n public static collectChainsAsLineString3d(fragments: AnyCurve[], announceChain: (chainPoints: LineString3d) => void, strokeOptions?: StrokeOptions, gapTolerance: number = Geometry.smallMetricDistance, _planeTolerance?: number) {\r\n const collector = new MultiChainCollector(gapTolerance); // no planarity tolerance needed\r\n for (const s of fragments) {\r\n collector.captureCurve(s);\r\n }\r\n collector.announceChainsAsLineString3d(announceChain, strokeOptions);\r\n }\r\n /**\r\n * Compute the range of the curves in the local coordinates of a constructed localToWorld frame.\r\n * @param curves input geometry: curves or points.\r\n * @param localRange pre-allocated object to populate with the computed local range.\r\n * @param localToWorld optional pre-allocated object to populate with the computed frame.\r\n * @returns whether the frame was successfully computed.\r\n */\r\n public static computeLocalRange(curves: AnyCurve | MultiLineStringDataVariant, localRange: Range3d, localToWorld?: Transform): boolean {\r\n const builderData: any[] = [curves];\r\n if (localToWorld)\r\n builderData.push(localToWorld);\r\n localToWorld = FrameBuilder.createRightHandedFrame(Vector3d.unitZ(), ...builderData);\r\n if (!localToWorld)\r\n return false;\r\n const worldToLocal = localToWorld.inverse();\r\n localRange.setNull();\r\n if (Array.isArray(curves) || !(curves instanceof GeometryQuery))\r\n Range3d.createFromVariantData(curves, worldToLocal, localRange);\r\n else\r\n this.extendRange(localRange, curves, worldToLocal);\r\n return true;\r\n }\r\n /**\r\n * Check whether or not the curves are planar, and if so, return a localToWorld frame.\r\n * @param curves input geometry: curves or points.\r\n * @param tolerance optional maximum allowable planar deviation, default [[Geometry.smallMetricDistance]].\r\n * @param result optional pre-allocated object to populate and return.\r\n * @returns localToWorld frame `T` for coplanar curves, or undefined if they are not coplanar.\r\n * `T` satisfies:\r\n * * `T.origin` is in the plane.\r\n * * `T.matrix.columnZ()` is the plane unit normal (or its negative).\r\n * * `T.matrix.isRigid()` returns true.\r\n * * `T.inverse()` is worldToLocal; apply to input geometry to rotate it into the xy-plane.\r\n */\r\n public static isPlanar(curves: AnyCurve | MultiLineStringDataVariant, options?: PlanarColinearOptions): Transform | undefined {\r\n const localRange = Range3d.create();\r\n const localToWorld = options?.localToWorld ?? Transform.createIdentity();\r\n if (!this.computeLocalRange(curves, localRange, localToWorld))\r\n return undefined;\r\n const maxAltitude = options?.maxDeviation ?? Geometry.smallMetricDistance;\r\n return (localRange.zLength() <= Math.abs(maxAltitude)) ? localToWorld : undefined;\r\n }\r\n /**\r\n * Check whether or not the curves lie in a straight line, and if so, return a colinear ray.\r\n * * This test does not take curve traversal or point order into account.\r\n * @param curves input geometry: curves or points.\r\n * @param xyOnly whether to ignore z-coordinates of input geometry.\r\n * @param tolerance optional maximum allowable linear deviation, default [[Geometry.smallMetricDistance]].\r\n * @param result optional pre-allocated object to populate and return.\r\n * @returns ray colinear with input, or undefined if input is not colinear.\r\n */\r\n public static isColinear(curves: AnyCurve | MultiLineStringDataVariant, options?: PlanarColinearOptions): Ray3d | undefined {\r\n const localRange = Range3d.create();\r\n const localToWorld = options?.localToWorld ?? Transform.createIdentity();\r\n if (!this.computeLocalRange(curves, localRange, localToWorld))\r\n return undefined;\r\n const maxAltitude = Math.abs(options?.maxDeviation ?? Geometry.smallMetricDistance);\r\n if (localRange.zLength() > maxAltitude)\r\n return undefined; // non-planar\r\n\r\n const ray = options?.colinearRay ?? Ray3d.createZero();\r\n ray.origin.setFrom(localToWorld.origin);\r\n\r\n const xLength = localRange.xLength();\r\n const yLength = localRange.yLength();\r\n if (xLength <= maxAltitude && yLength <= maxAltitude) {\r\n ray.direction.setZero();\r\n return ray; // the input is essentially a point\r\n }\r\n if (yLength <= maxAltitude) {\r\n localToWorld.matrix.columnX(ray.direction);\r\n return ray; // the input lies along local x-axis\r\n }\r\n if (xLength <= maxAltitude) {\r\n localToWorld.matrix.columnY(ray.direction);\r\n return ray; // the input lies along local y-axis\r\n }\r\n if (!options?.xyColinear)\r\n return undefined; // non-colinear\r\n\r\n const angleTolerance = Math.abs(options?.radianTolerance ?? Geometry.smallAngleRadians);\r\n const verticalPlaneDeviation = Math.abs(localToWorld.matrix.columnDotXYZ(AxisIndex.Z, 0, 0, 1));\r\n if (verticalPlaneDeviation > angleTolerance) // cos(t + pi/2) = -sin(t) ~ -t for small t\r\n return undefined; // non-xy-colinear\r\n\r\n if (xLength > yLength)\r\n localToWorld.matrix.columnX(ray.direction);\r\n else\r\n localToWorld.matrix.columnY(ray.direction);\r\n ray.direction.z = 0.0;\r\n return ray; // xy-colinear (plane is vertical)\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"CurveOps.js","sourceRoot":"","sources":["../../../src/curve/CurveOps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE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AG,CAAC,CAAC,kCAAkC;IAChD,CAAC;CACF;AA1ND,4BA0NC","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 { AxisIndex, Geometry } from \"../Geometry\";\r\nimport { FrameBuilder } from \"../geometry3d/FrameBuilder\";\r\nimport { MultiLineStringDataVariant } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { BagOfCurves, CurveCollection } from \"./CurveCollection\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { AnyChain, AnyCurve } from \"./CurveTypes\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\nimport { MultiChainCollector } from \"./internalContexts/MultiChainCollector\";\r\nimport { CurveChainWireOffsetContext } from \"./internalContexts/PolygonOffsetContext\";\r\nimport { LineString3d } from \"./LineString3d\";\r\nimport { Loop } from \"./Loop\";\r\nimport { OffsetOptions } from \"./OffsetOptions\";\r\nimport { Path } from \"./Path\";\r\nimport { StrokeOptions } from \"./StrokeOptions\";\r\n\r\n /**\r\n * Options bundle for use in [[CurveOps.isPlanar]] and [[CurveOps.isColinear]].\r\n * @public\r\n */\r\n export interface PlanarColinearOptions {\r\n /** Maximum allowable distance that geometry can deviate from planarity/colinearity. Default is [[Geometry.smallMetricDistance]]. */\r\n maxDeviation?: number;\r\n /** Whether colinearity test ignores z-coordinates. Default is `false`. */\r\n xyColinear?: boolean;\r\n /** Radian tolerance for xy-colinearity, measuring maximum angular deviation from a vertical plane. Default is [[Geometry.smallAngleRadians]]. */\r\n radianTolerance?: number;\r\n /** Pre-allocated object to populate with the computed plane-to-world transformation and return when planarity test succeeds. */\r\n localToWorld?: Transform;\r\n /** Pre-allocated object to populate with the computed line and return when colinear test succeeds. */\r\n colinearRay?: Ray3d;\r\n }\r\n\r\n/**\r\n * Static methods for miscellaneous curve operations.\r\n * @public\r\n */\r\nexport class CurveOps {\r\n /** Recursively sum curve lengths, allowing CurvePrimitive, CurveCollection, or array of such at any level. */\r\n public static sumLengths(curves: AnyCurve | AnyCurve[]): number {\r\n let mySum = 0;\r\n if (curves instanceof CurvePrimitive) {\r\n mySum += curves.curveLength();\r\n } else if (curves instanceof CurveCollection) {\r\n mySum += curves.sumLengths();\r\n } else if (Array.isArray(curves)) {\r\n for (const data1 of curves)\r\n mySum += this.sumLengths(data1);\r\n }\r\n return mySum;\r\n }\r\n /** Recursively extend the range by each curve's range, allowing CurvePrimitive, CurveCollection, or array of such at any level. */\r\n public static extendRange(range: Range3d, curves: AnyCurve | AnyCurve[], transform?: Transform): Range3d {\r\n if (Array.isArray(curves)) {\r\n for (const data1 of curves)\r\n this.extendRange(range, data1, transform);\r\n } else {\r\n curves.extendRange(range, transform);\r\n }\r\n return range;\r\n }\r\n /**\r\n * Construct a separate xy-offset for each input curve.\r\n * * For best offset results, the inputs should be parallel to the xy-plane.\r\n * @param curves input curve(s), z-coordinates ignored. Only curves of type [[AnyChain]] are handled.\r\n * @param offset offset distance (positive to left of curve, negative to right)\r\n * @param result array to collect offset curves\r\n * @returns summed length of offset curves\r\n */\r\n public static appendXYOffsets(curves: AnyCurve | AnyCurve[] | undefined, offset: number, result: AnyCurve[]): number {\r\n let summedLengths = 0;\r\n if (curves instanceof CurvePrimitive) {\r\n const resultA = CurveChainWireOffsetContext.constructCurveXYOffset(Path.create(curves), offset);\r\n if (resultA) {\r\n summedLengths += this.sumLengths(resultA);\r\n result.push(resultA);\r\n }\r\n } else if (curves instanceof Loop || curves instanceof Path) {\r\n const resultA = CurveChainWireOffsetContext.constructCurveXYOffset(curves, offset);\r\n if (resultA) {\r\n summedLengths += this.sumLengths(resultA);\r\n result.push(resultA);\r\n }\r\n } else if (curves instanceof BagOfCurves) {\r\n for (const q of curves.children)\r\n summedLengths += this.appendXYOffsets(q, offset, result);\r\n } else if (Array.isArray(curves)) {\r\n for (const q of curves)\r\n summedLengths += this.appendXYOffsets(q, offset, result);\r\n }\r\n return summedLengths;\r\n }\r\n /**\r\n * Restructure curve fragments as Paths and Loops, and construct xy-offsets of the chains.\r\n * * If the inputs do not form Loop(s), the classification of offsets is suspect.\r\n * * For best offset results, the inputs should be parallel to the xy-plane.\r\n * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.\r\n * @param fragments fragments to be chained and offset\r\n * @param offsetDistance offset distance, applied to both sides of each fragment to produce inside and outside xy-offset curves.\r\n * @param gapTolerance distance to be treated as \"effectively zero\" when joining head-to-tail\r\n * @returns object with named chains, insideOffsets, outsideOffsets\r\n */\r\n public static collectInsideAndOutsideXYOffsets(fragments: AnyCurve[], offsetDistance: number, gapTolerance: number): { insideOffsets: AnyCurve[], outsideOffsets: AnyCurve[], chains?: AnyChain } {\r\n const collector = new MultiChainCollector(gapTolerance, gapTolerance);\r\n for (const s of fragments) {\r\n collector.captureCurve(s);\r\n }\r\n const chains = collector.grabResult(true);\r\n const myOffsetA: CurveCollection[] = [];\r\n const myOffsetB: CurveCollection[] = [];\r\n const offsetLengthA = CurveOps.appendXYOffsets(chains, offsetDistance, myOffsetA);\r\n const offsetLengthB = CurveOps.appendXYOffsets(chains, -offsetDistance, myOffsetB);\r\n if (offsetLengthA > offsetLengthB) {\r\n return { outsideOffsets: myOffsetA, insideOffsets: myOffsetB, chains };\r\n } else {\r\n return { insideOffsets: myOffsetA, outsideOffsets: myOffsetB, chains };\r\n }\r\n }\r\n /**\r\n * Construct curves that are offset from a Path or Loop as viewed in xy-plane (ignoring z).\r\n * * The construction will remove \"some\" local effects of features smaller than the offset distance, but will not detect self intersection among widely separated edges.\r\n * @param curves base curves.\r\n * @param offsetDistanceOrOptions offset distance (positive to left of curve, negative to right) or options object.\r\n */\r\n public static constructCurveXYOffset(curves: Path | Loop, offsetDistanceOrOptions: number | OffsetOptions): CurveCollection | undefined {\r\n return CurveChainWireOffsetContext.constructCurveXYOffset(curves, offsetDistanceOrOptions);\r\n }\r\n /**\r\n * Create the offset of a single curve primitive as viewed in the xy-plane (ignoring z).\r\n * @param curve primitive to offset\r\n * @param offsetDistanceOrOptions offset distance (positive to left of curve, negative to right) or options object\r\n */\r\n public static createSingleOffsetPrimitiveXY(curve: CurvePrimitive, offsetDistanceOrOptions: number | OffsetOptions): CurvePrimitive | CurvePrimitive[] | undefined {\r\n return CurveChainWireOffsetContext.createSingleOffsetPrimitiveXY(curve, offsetDistanceOrOptions);\r\n }\r\n /**\r\n * Restructure curve fragments as Paths and Loops.\r\n * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.\r\n * @param fragments fragments to be chained\r\n * @param gapTolerance distance to be treated as \"effectively zero\" when assembling fragments head-to-tail\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 * @returns chains, possibly wrapped in a [[BagOfCurves]].\r\n */\r\n public static collectChains(fragments: AnyCurve[], gapTolerance: number = Geometry.smallMetricDistance, planeTolerance?: number): AnyChain | undefined {\r\n const collector = new MultiChainCollector(gapTolerance, planeTolerance);\r\n for (const s of fragments) {\r\n collector.captureCurve(s);\r\n }\r\n return collector.grabResult(true);\r\n }\r\n /**\r\n * Restructure curve fragments, to be stroked and passed into the callback.\r\n * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed.\r\n * @param fragments fragments to be chained and stroked\r\n * @param announceChain callback to process each stroked Path and Loop\r\n * @param strokeOptions options for stroking the chains\r\n * @param gapTolerance distance to be treated as \"effectively zero\" when assembling fragments head-to-tail. Also used for removing duplicate points in the stroked chains.\r\n * @param _planeTolerance unused, pass undefined\r\n */\r\n public static collectChainsAsLineString3d(fragments: AnyCurve[], announceChain: (chainPoints: LineString3d) => void, strokeOptions?: StrokeOptions, gapTolerance: number = Geometry.smallMetricDistance, _planeTolerance?: number) {\r\n const collector = new MultiChainCollector(gapTolerance); // no planarity tolerance needed\r\n for (const s of fragments) {\r\n collector.captureCurve(s);\r\n }\r\n collector.announceChainsAsLineString3d(announceChain, strokeOptions);\r\n }\r\n /**\r\n * Compute the range of the curves in the local coordinates of a constructed localToWorld frame.\r\n * @param curves input geometry: curves or points.\r\n * @param localRange pre-allocated object to populate with the computed local range.\r\n * @param localToWorld optional pre-allocated object to populate with the computed frame.\r\n * @returns whether the frame was successfully computed.\r\n */\r\n public static computeLocalRange(curves: AnyCurve | MultiLineStringDataVariant, localRange: Range3d, localToWorld?: Transform): boolean {\r\n const builderData: any[] = [curves];\r\n if (localToWorld)\r\n builderData.push(localToWorld);\r\n localToWorld = FrameBuilder.createRightHandedFrame(Vector3d.unitZ(), ...builderData);\r\n if (!localToWorld)\r\n return false;\r\n const worldToLocal = localToWorld.inverse();\r\n localRange.setNull();\r\n if (Array.isArray(curves) || !(curves instanceof GeometryQuery))\r\n Range3d.createFromVariantData(curves, worldToLocal, localRange);\r\n else\r\n this.extendRange(localRange, curves, worldToLocal);\r\n return true;\r\n }\r\n /**\r\n * Check whether or not the curves are planar, and if so, return a localToWorld frame.\r\n * @param curves input geometry: curves or points.\r\n * @param options bundle of options.\r\n * @returns localToWorld frame `T` for coplanar curves, or undefined if they are not coplanar.\r\n * `T` satisfies:\r\n * * `T.origin` is in the plane.\r\n * * `T.matrix.columnZ()` is the plane unit normal (or its negative).\r\n * * `T.matrix.isRigid()` returns true.\r\n * * `T.inverse()` is worldToLocal; apply to input geometry to rotate it into the xy-plane.\r\n */\r\n public static isPlanar(curves: AnyCurve | MultiLineStringDataVariant, options?: PlanarColinearOptions): Transform | undefined {\r\n const localRange = Range3d.create();\r\n const localToWorld = options?.localToWorld ?? Transform.createIdentity();\r\n if (!this.computeLocalRange(curves, localRange, localToWorld))\r\n return undefined;\r\n const maxAltitude = options?.maxDeviation ?? Geometry.smallMetricDistance;\r\n return (localRange.zLength() <= Math.abs(maxAltitude)) ? localToWorld : undefined;\r\n }\r\n /**\r\n * Check whether or not the curves lie in a straight line, and if so, return a colinear ray.\r\n * * This test does not take curve traversal or point order into account.\r\n * @param curves input geometry: curves or points.\r\n * @param options bundle of options.\r\n * @returns ray colinear with input, or undefined if input is not colinear.\r\n */\r\n public static isColinear(curves: AnyCurve | MultiLineStringDataVariant, options?: PlanarColinearOptions): Ray3d | undefined {\r\n const localRange = Range3d.create();\r\n const localToWorld = options?.localToWorld ?? Transform.createIdentity();\r\n if (!this.computeLocalRange(curves, localRange, localToWorld))\r\n return undefined;\r\n const maxAltitude = Math.abs(options?.maxDeviation ?? Geometry.smallMetricDistance);\r\n if (localRange.zLength() > maxAltitude)\r\n return undefined; // non-planar\r\n\r\n const ray = options?.colinearRay ?? Ray3d.createZero();\r\n ray.origin.setFrom(localToWorld.origin);\r\n\r\n const xLength = localRange.xLength();\r\n const yLength = localRange.yLength();\r\n if (xLength <= maxAltitude && yLength <= maxAltitude) {\r\n ray.direction.setZero();\r\n return ray; // the input is essentially a point\r\n }\r\n if (yLength <= maxAltitude) {\r\n localToWorld.matrix.columnX(ray.direction);\r\n return ray; // the input lies along local x-axis\r\n }\r\n if (xLength <= maxAltitude) {\r\n localToWorld.matrix.columnY(ray.direction);\r\n return ray; // the input lies along local y-axis\r\n }\r\n if (!options?.xyColinear)\r\n return undefined; // non-colinear\r\n\r\n const angleTolerance = Math.abs(options?.radianTolerance ?? Geometry.smallAngleRadians);\r\n const verticalPlaneDeviation = Math.abs(localToWorld.matrix.columnDotXYZ(AxisIndex.Z, 0, 0, 1));\r\n if (verticalPlaneDeviation > angleTolerance) // cos(t + pi/2) = -sin(t) ~ -t for small t\r\n return undefined; // non-xy-colinear\r\n\r\n if (xLength > yLength)\r\n localToWorld.matrix.columnX(ray.direction);\r\n else\r\n localToWorld.matrix.columnY(ray.direction);\r\n ray.direction.z = 0.0;\r\n return ray; // xy-colinear (plane is vertical)\r\n }\r\n}\r\n"]}
|
|
@@ -8,20 +8,28 @@ import { ParityRegion } from "../ParityRegion";
|
|
|
8
8
|
*/
|
|
9
9
|
export declare class PlanarSubdivision {
|
|
10
10
|
/**
|
|
11
|
-
* Create a graph from
|
|
12
|
-
* Z-coordinates are ignored.
|
|
11
|
+
* Create a graph from curves and precomputed intersections.
|
|
12
|
+
* * Z-coordinates are ignored.
|
|
13
|
+
* @param primitives input curves
|
|
14
|
+
* @param allPairs array of curve-curve xy-intersections
|
|
15
|
+
* @param mergeTolerance optional distance tolerance for clustering vertices. Default value is [[Geometry.smallMetricDistance]].
|
|
13
16
|
*/
|
|
14
17
|
static assembleHalfEdgeGraph(primitives: CurvePrimitive[], allPairs: CurveLocationDetailPair[], mergeTolerance?: number): HalfEdgeGraph;
|
|
15
18
|
/**
|
|
16
|
-
*
|
|
17
|
-
* *
|
|
19
|
+
* Filter for trivial curve fragment: fast computation if line segment; otherwise clip, flatten, and measure.
|
|
20
|
+
* * Different metrics are employed for expedience.
|
|
21
|
+
*/
|
|
22
|
+
private static isCurveTrivialXY;
|
|
23
|
+
/**
|
|
24
|
+
* Create a pair of mated half edges referencing a non-trivial interval of a primitive.
|
|
18
25
|
* @param graph containing graph
|
|
19
26
|
* @param p the curve
|
|
20
27
|
* @param point0 start point
|
|
21
28
|
* @param fraction0 starting fraction
|
|
22
29
|
* @param point1 end point
|
|
23
30
|
* @param fraction1 end fraction
|
|
24
|
-
* @
|
|
31
|
+
* @param mergeTolerance optional maximum xy-length of a trivial edge
|
|
32
|
+
* @returns end point and fraction
|
|
25
33
|
*/
|
|
26
34
|
private static addHalfEdge;
|
|
27
35
|
/**
|
|
@@ -39,27 +47,54 @@ export declare class PlanarSubdivision {
|
|
|
39
47
|
/**
|
|
40
48
|
* Create a [[Loop]] for the given face or super face.
|
|
41
49
|
* @param face a node in the face loop, or an array of HalfEdges that comprise a loop (e.g., a super face).
|
|
42
|
-
* @param
|
|
43
|
-
* @param compress whether to consolidate adjacent curves in the output Loop (default `false`).
|
|
44
|
-
* If `announce` is provided, no compression is performed, as edges and curves would no longer be in 1-1 correspondence.
|
|
45
|
-
* @param closureTol absolute xy-distance for confirming the returned Loop is closed (default [[Geometry.smallMetricDistance]]).
|
|
50
|
+
* @param options bundle of options.
|
|
46
51
|
* @returns the Loop, or `undefined` if it is not closed within xy-tolerance.
|
|
47
52
|
*/
|
|
48
|
-
static createLoopInFace(face: HalfEdge | HalfEdge[],
|
|
53
|
+
static createLoopInFace(face: HalfEdge | HalfEdge[], options?: PlanarSubdivision.CreateRegionInFaceOptions): Loop | undefined;
|
|
49
54
|
/**
|
|
50
55
|
* Create a [[Loop]] or [[ParityRegion]] for the given face.
|
|
51
56
|
* * A ParityRegion is created for a split-washer type face by removing bridge edges.
|
|
52
57
|
* @param face a node in the face loop.
|
|
53
|
-
* @param
|
|
54
|
-
* @
|
|
55
|
-
* @param closureTol absolute xy-distance for confirming the returned Loop is closed (default [[Geometry.smallMetricDistance]]).
|
|
56
|
-
* @returns the Loop or ParityRegion, or `undefined` if one could not be computed
|
|
58
|
+
* @param options bundle of options.
|
|
59
|
+
* @returns the Loop or ParityRegion, or `undefined` if one could not be computed.
|
|
57
60
|
*/
|
|
58
|
-
static createLoopOrParityRegionInFace(face: HalfEdge,
|
|
61
|
+
static createLoopOrParityRegionInFace(face: HalfEdge, options?: PlanarSubdivision.CreateRegionInFaceOptions): Loop | ParityRegion | undefined;
|
|
59
62
|
/** Return true if there are only two edges in the face loop, and their start curvatures are the same. */
|
|
60
63
|
private static isNullFace;
|
|
61
64
|
/** Look across edge mates (possibly several) for a non-null mate face. */
|
|
62
65
|
private static getNonNullEdgeMate;
|
|
63
66
|
static collectSignedLoopSetsInHalfEdgeGraph(graph: HalfEdgeGraph, zeroAreaTolerance?: number): SignedLoops[];
|
|
64
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
export declare namespace PlanarSubdivision {
|
|
72
|
+
/** Options bundle for [[PlanarSubdivision.createLoopInFace]] and [[PlanarSubdivision.createLoopOrParityRegionInFace]]. */
|
|
73
|
+
interface CreateRegionInFaceOptions {
|
|
74
|
+
/**
|
|
75
|
+
* Optional callback invoked on each `edge` before its `curve` is added to `loop`.
|
|
76
|
+
* * Note that if a [[ParityRegion]] is being constructed, `curve` and `loop` may subsequently be reversed.
|
|
77
|
+
*/
|
|
78
|
+
announceEdge?: (edge: HalfEdge, curve: CurvePrimitive, loop: Loop) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Whether to consolidate adjacent curves in an output [[Loop]]. Default value is `false`.
|
|
81
|
+
* * If `announce` is defined, no compression is performed, as edges and curves would no longer be in 1-1 correspondence.
|
|
82
|
+
*/
|
|
83
|
+
compress?: boolean;
|
|
84
|
+
/** Absolute xy-distance for confirming a returned Loop is closed. Default value is [[Geometry.smallMetricDistance]]. */
|
|
85
|
+
closureTol?: number;
|
|
86
|
+
/**
|
|
87
|
+
* Mask preset on bridge edges. Default value is `HalfEdgeMask.BRIDGE_EDGE`.
|
|
88
|
+
* * This mask is used to distinguish a split-washer type face, which can result in a [[ParityRegion]].
|
|
89
|
+
*/
|
|
90
|
+
bridgeMask?: HalfEdgeMask;
|
|
91
|
+
/** Mask to use for visiting edges when creating a [[ParityRegion]] from a split-washer type face. Default value is `HalfEdgeMask.VISITED`. */
|
|
92
|
+
visitMask?: HalfEdgeMask;
|
|
93
|
+
/**
|
|
94
|
+
* Optional z-coordinate for the result region.
|
|
95
|
+
* * If undefined, graph z-coordinates are used, but this may result in a non-planar region if the graph is not planar!
|
|
96
|
+
*/
|
|
97
|
+
z?: number;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
65
100
|
//# sourceMappingURL=PlanarSubdivision.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlanarSubdivision.d.ts","sourceRoot":"","sources":["../../../../src/curve/Query/PlanarSubdivision.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3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ACzG,OAAO,CAAC,MAAM,CAAC,UAAU;IAWzB,0EAA0E;IAC1E,OAAO,CAAC,MAAM,CAAC,kBAAkB;WAWnB,oCAAoC,CAAC,KAAK,EAAE,aAAa,EAAE,iBAAiB,GAAE,MAAgB,GAAG,WAAW,EAAE;CAkC7H;AAED;;EAEE;AACF,yBAAiB,iBAAiB,CAAC;IACjC,0HAA0H;IAC1H,UAAiB,yBAAyB;QACxC;;;WAGG;QACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;QAC3E;;;WAGG;QACH,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,wHAAwH;QACxH,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB;;;WAGG;QACH,UAAU,CAAC,EAAE,YAAY,CAAC;QAC1B,8IAA8I;QAC9I,SAAS,CAAC,EAAE,YAAY,CAAC;QACzB;;;WAGG;QACH,CAAC,CAAC,EAAE,MAAM,CAAC;KACZ;CACF"}
|
|
@@ -7,6 +7,7 @@ exports.PlanarSubdivision = void 0;
|
|
|
7
7
|
*--------------------------------------------------------------------------------------------*/
|
|
8
8
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
9
9
|
const Geometry_1 = require("../../Geometry");
|
|
10
|
+
const Transform_1 = require("../../geometry3d/Transform");
|
|
10
11
|
const Graph_1 = require("../../topology/Graph");
|
|
11
12
|
const HalfEdgeGraphSearch_1 = require("../../topology/HalfEdgeGraphSearch");
|
|
12
13
|
const Merging_1 = require("../../topology/Merging");
|
|
@@ -21,6 +22,25 @@ const RegionOpsClassificationSweeps_1 = require("../RegionOpsClassificationSweep
|
|
|
21
22
|
/** @packageDocumentation
|
|
22
23
|
* @module Curve
|
|
23
24
|
*/
|
|
25
|
+
function computeSortAngle(curve, fraction, reverse) {
|
|
26
|
+
const ray = curve.fractionToPointAndDerivative(fraction);
|
|
27
|
+
const s = reverse ? -1.0 : 1.0;
|
|
28
|
+
return Math.atan2(s * ray.direction.y, s * ray.direction.x);
|
|
29
|
+
}
|
|
30
|
+
function getFractionOnCurve(pair, curve) {
|
|
31
|
+
if (pair.detailA.curve === curve)
|
|
32
|
+
return pair.detailA.fraction;
|
|
33
|
+
if (pair.detailB.curve === curve)
|
|
34
|
+
return pair.detailB.fraction;
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
function getDetailOnCurve(pair, curve) {
|
|
38
|
+
if (pair.detailA.curve === curve)
|
|
39
|
+
return pair.detailA;
|
|
40
|
+
if (pair.detailB.curve === curve)
|
|
41
|
+
return pair.detailB;
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
24
44
|
class MapCurvePrimitiveToCurveLocationDetailPairArray {
|
|
25
45
|
primitiveToPair = new Map();
|
|
26
46
|
// index assigned to this primitive (for debugging)
|
|
@@ -83,8 +103,11 @@ class MapCurvePrimitiveToCurveLocationDetailPairArray {
|
|
|
83
103
|
*/
|
|
84
104
|
class PlanarSubdivision {
|
|
85
105
|
/**
|
|
86
|
-
* Create a graph from
|
|
87
|
-
* Z-coordinates are ignored.
|
|
106
|
+
* Create a graph from curves and precomputed intersections.
|
|
107
|
+
* * Z-coordinates are ignored.
|
|
108
|
+
* @param primitives input curves
|
|
109
|
+
* @param allPairs array of curve-curve xy-intersections
|
|
110
|
+
* @param mergeTolerance optional distance tolerance for clustering vertices. Default value is [[Geometry.smallMetricDistance]].
|
|
88
111
|
*/
|
|
89
112
|
static assembleHalfEdgeGraph(primitives, allPairs, mergeTolerance = Geometry_1.Geometry.smallMetricDistance) {
|
|
90
113
|
// map from key CurvePrimitive to CurveLocationDetailPair
|
|
@@ -130,31 +153,45 @@ class PlanarSubdivision {
|
|
|
130
153
|
return graph;
|
|
131
154
|
}
|
|
132
155
|
/**
|
|
133
|
-
*
|
|
134
|
-
* *
|
|
156
|
+
* Filter for trivial curve fragment: fast computation if line segment; otherwise clip, flatten, and measure.
|
|
157
|
+
* * Different metrics are employed for expedience.
|
|
158
|
+
*/
|
|
159
|
+
static isCurveTrivialXY(p, point0, fraction0, point1, fraction1, mergeTolerance) {
|
|
160
|
+
if (Geometry_1.Geometry.isSmallRelative(fraction0 - fraction1))
|
|
161
|
+
return true;
|
|
162
|
+
if (!(p instanceof LineSegment3d_1.LineSegment3d)) {
|
|
163
|
+
const p0 = p.clonePartialCurve(fraction0, fraction1);
|
|
164
|
+
if (p0?.tryTransformInPlace(Transform_1.Transform.createRowValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0))) // flatten
|
|
165
|
+
return p0.curveLength() <= mergeTolerance; // Euclidean
|
|
166
|
+
}
|
|
167
|
+
return point0.isAlmostEqualXY(point1, mergeTolerance); // Manhattan
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Create a pair of mated half edges referencing a non-trivial interval of a primitive.
|
|
135
171
|
* @param graph containing graph
|
|
136
172
|
* @param p the curve
|
|
137
173
|
* @param point0 start point
|
|
138
174
|
* @param fraction0 starting fraction
|
|
139
175
|
* @param point1 end point
|
|
140
176
|
* @param fraction1 end fraction
|
|
141
|
-
* @
|
|
177
|
+
* @param mergeTolerance optional maximum xy-length of a trivial edge
|
|
178
|
+
* @returns end point and fraction
|
|
142
179
|
*/
|
|
143
180
|
static addHalfEdge(graph, p, point0, fraction0, point1, fraction1, mergeTolerance = Geometry_1.Geometry.smallMetricDistance) {
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return { point: point1, fraction: fraction1 };
|
|
181
|
+
if (!this.isCurveTrivialXY(p, point0, fraction0, point1, fraction1, mergeTolerance)) {
|
|
182
|
+
const halfEdge = graph.createEdgeXYAndZ(point0, 0, point1, 0);
|
|
183
|
+
if (p.parent && p.parent instanceof RegionOpsClassificationSweeps_1.RegionGroupMember && p.parent.parentGroup.groupOpType === RegionOpsClassificationSweeps_1.RegionGroupOpType.NonBounding)
|
|
184
|
+
halfEdge.setMaskAroundEdge(Graph_1.HalfEdgeMask.BRIDGE_EDGE);
|
|
185
|
+
const detail01 = CurveLocationDetail_1.CurveLocationDetail.createCurveEvaluatedFractionFraction(p, fraction0, fraction1);
|
|
186
|
+
const mate = halfEdge.edgeMate;
|
|
187
|
+
halfEdge.edgeTag = detail01;
|
|
188
|
+
halfEdge.sortData = 1.0;
|
|
189
|
+
mate.edgeTag = detail01;
|
|
190
|
+
mate.sortData = -1.0;
|
|
191
|
+
halfEdge.sortAngle = computeSortAngle(p, fraction0, false);
|
|
192
|
+
mate.sortAngle = computeSortAngle(p, fraction1, true);
|
|
193
|
+
}
|
|
194
|
+
return { point: point1, fraction: fraction1 }; // where the next curve fragment starts
|
|
158
195
|
}
|
|
159
196
|
/**
|
|
160
197
|
* Based on computed (and toleranced) area, push the loop (pointer) onto the appropriate array of positive, negative,
|
|
@@ -190,32 +227,31 @@ class PlanarSubdivision {
|
|
|
190
227
|
return undefined;
|
|
191
228
|
}
|
|
192
229
|
/** Create the geometry for a topological edge. */
|
|
193
|
-
static createCurveInEdge(edge) {
|
|
230
|
+
static createCurveInEdge(edge, z) {
|
|
231
|
+
let result;
|
|
194
232
|
const info = this.extractGeometryFromEdge(edge);
|
|
195
|
-
if (info) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
233
|
+
if (info && info.detail.curve && info.detail.fraction1) {
|
|
234
|
+
const f0 = info.reversed ? info.detail.fraction1 : info.detail.fraction;
|
|
235
|
+
const f1 = info.reversed ? info.detail.fraction : info.detail.fraction1;
|
|
236
|
+
result = info.detail.curve.clonePartialCurve(f0, f1);
|
|
237
|
+
if (result && z !== undefined)
|
|
238
|
+
result.tryTransformInPlace(Transform_1.Transform.createRowValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, z));
|
|
199
239
|
}
|
|
200
|
-
return
|
|
240
|
+
return result;
|
|
201
241
|
}
|
|
202
242
|
/**
|
|
203
243
|
* Create a [[Loop]] for the given face or super face.
|
|
204
244
|
* @param face a node in the face loop, or an array of HalfEdges that comprise a loop (e.g., a super face).
|
|
205
|
-
* @param
|
|
206
|
-
* @param compress whether to consolidate adjacent curves in the output Loop (default `false`).
|
|
207
|
-
* If `announce` is provided, no compression is performed, as edges and curves would no longer be in 1-1 correspondence.
|
|
208
|
-
* @param closureTol absolute xy-distance for confirming the returned Loop is closed (default [[Geometry.smallMetricDistance]]).
|
|
245
|
+
* @param options bundle of options.
|
|
209
246
|
* @returns the Loop, or `undefined` if it is not closed within xy-tolerance.
|
|
210
247
|
*/
|
|
211
|
-
static createLoopInFace(face,
|
|
212
|
-
if
|
|
213
|
-
compress = false;
|
|
248
|
+
static createLoopInFace(face, options) {
|
|
249
|
+
const consolidate = options?.announceEdge ? false : options?.compress ?? false; // can't compress if announcing
|
|
214
250
|
const loop = Loop_1.Loop.create();
|
|
215
|
-
const addEdgeCurve = (
|
|
216
|
-
const curve = this.createCurveInEdge(
|
|
251
|
+
const addEdgeCurve = (edge) => {
|
|
252
|
+
const curve = this.createCurveInEdge(edge, options?.z);
|
|
217
253
|
if (curve) {
|
|
218
|
-
|
|
254
|
+
options?.announceEdge?.(edge, curve, loop);
|
|
219
255
|
loop.tryAddChild(curve);
|
|
220
256
|
}
|
|
221
257
|
};
|
|
@@ -223,12 +259,12 @@ class PlanarSubdivision {
|
|
|
223
259
|
face.forEach(addEdgeCurve);
|
|
224
260
|
else
|
|
225
261
|
face.announceEdgesInFace(addEdgeCurve);
|
|
226
|
-
if (
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
RegionOps_1.RegionOps.consolidateAdjacentPrimitives(loop,
|
|
262
|
+
if (consolidate) {
|
|
263
|
+
const consolidateOptions = new RegionOps_1.ConsolidateAdjacentCurvePrimitivesOptions();
|
|
264
|
+
consolidateOptions.consolidateLoopSeam = true;
|
|
265
|
+
RegionOps_1.RegionOps.consolidateAdjacentPrimitives(loop, consolidateOptions);
|
|
230
266
|
}
|
|
231
|
-
if (loop.isPhysicallyClosedCurve(closureTol, true))
|
|
267
|
+
if (loop.isPhysicallyClosedCurve(options?.closureTol, true))
|
|
232
268
|
return loop;
|
|
233
269
|
(0, core_bentley_1.assert)(() => false, "face is not physically closed");
|
|
234
270
|
return undefined;
|
|
@@ -237,17 +273,19 @@ class PlanarSubdivision {
|
|
|
237
273
|
* Create a [[Loop]] or [[ParityRegion]] for the given face.
|
|
238
274
|
* * A ParityRegion is created for a split-washer type face by removing bridge edges.
|
|
239
275
|
* @param face a node in the face loop.
|
|
240
|
-
* @param
|
|
241
|
-
* @
|
|
242
|
-
* @param closureTol absolute xy-distance for confirming the returned Loop is closed (default [[Geometry.smallMetricDistance]]).
|
|
243
|
-
* @returns the Loop or ParityRegion, or `undefined` if one could not be computed
|
|
276
|
+
* @param options bundle of options.
|
|
277
|
+
* @returns the Loop or ParityRegion, or `undefined` if one could not be computed.
|
|
244
278
|
*/
|
|
245
|
-
static createLoopOrParityRegionInFace(face,
|
|
279
|
+
static createLoopOrParityRegionInFace(face, options) {
|
|
246
280
|
let region;
|
|
247
|
-
|
|
281
|
+
const visitMask = options?.visitMask ?? Graph_1.HalfEdgeMask.VISITED;
|
|
282
|
+
const bridgeMask = options?.bridgeMask ?? Graph_1.HalfEdgeMask.BRIDGE_EDGE;
|
|
283
|
+
let startBridgeEdge;
|
|
284
|
+
// is it a split-washer face?
|
|
285
|
+
if (face.isSplitWasherFace(bridgeMask) && (startBridgeEdge = face.findMaskAroundFace(bridgeMask, true))) {
|
|
248
286
|
const loops = [];
|
|
249
287
|
const loopEdges = [];
|
|
250
|
-
const bridgeStack = [
|
|
288
|
+
const bridgeStack = [startBridgeEdge];
|
|
251
289
|
const announceEdge = (he) => { he.setMask(visitMask); loopEdges.push(he); };
|
|
252
290
|
const announceBridge = (he) => { if (!he.isMaskSet(visitMask))
|
|
253
291
|
bridgeStack.push(he); };
|
|
@@ -261,7 +299,7 @@ class PlanarSubdivision {
|
|
|
261
299
|
continue;
|
|
262
300
|
loopEdges.length = 0;
|
|
263
301
|
if (loopSeed.announceEdgesInSuperFace(bridgeMask, announceEdge, announceBridge)) {
|
|
264
|
-
const loop = this.createLoopInFace(loopEdges,
|
|
302
|
+
const loop = this.createLoopInFace(loopEdges, options);
|
|
265
303
|
if (loop) {
|
|
266
304
|
loops.push(loop);
|
|
267
305
|
continue;
|
|
@@ -273,7 +311,7 @@ class PlanarSubdivision {
|
|
|
273
311
|
region = RegionOps_1.RegionOps.simplifyRegion(region);
|
|
274
312
|
}
|
|
275
313
|
else {
|
|
276
|
-
region = this.createLoopInFace(face,
|
|
314
|
+
region = this.createLoopInFace(face, options);
|
|
277
315
|
}
|
|
278
316
|
return (region && (region instanceof Loop_1.Loop || region instanceof ParityRegion_1.ParityRegion)) ? region : undefined;
|
|
279
317
|
}
|
|
@@ -310,24 +348,23 @@ class PlanarSubdivision {
|
|
|
310
348
|
const edges = [];
|
|
311
349
|
for (const faceSeed of faceSeeds) {
|
|
312
350
|
const isNullFace = this.isNullFace(faceSeed);
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
edgeMap.delete(mate);
|
|
327
|
-
}
|
|
351
|
+
const announceEdge = isNullFace ? undefined : (he, curveC, loopC) => {
|
|
352
|
+
const mate = this.getNonNullEdgeMate(graph, he);
|
|
353
|
+
if (mate !== undefined) {
|
|
354
|
+
const e = edgeMap.get(mate);
|
|
355
|
+
if (e === undefined) {
|
|
356
|
+
// Record this as loopA,edgeA of a shared edge to be completed later from the other side of the edge
|
|
357
|
+
const e1 = new Loop_1.LoopCurveLoopCurve(loopC, curveC, undefined, undefined);
|
|
358
|
+
edgeMap.set(he, e1);
|
|
359
|
+
}
|
|
360
|
+
else if (e instanceof Loop_1.LoopCurveLoopCurve) {
|
|
361
|
+
e.setB(loopC, curveC);
|
|
362
|
+
edges.push(e);
|
|
363
|
+
edgeMap.delete(mate);
|
|
328
364
|
}
|
|
329
365
|
}
|
|
330
|
-
}
|
|
366
|
+
};
|
|
367
|
+
const loop = this.createLoopInFace(faceSeed, { announceEdge });
|
|
331
368
|
if (loop)
|
|
332
369
|
this.collectSignedLoop(loop, componentAreas, zeroAreaTolerance, isNullFace);
|
|
333
370
|
}
|
|
@@ -339,23 +376,4 @@ class PlanarSubdivision {
|
|
|
339
376
|
}
|
|
340
377
|
}
|
|
341
378
|
exports.PlanarSubdivision = PlanarSubdivision;
|
|
342
|
-
function sortAngle(curve, fraction, reverse) {
|
|
343
|
-
const ray = curve.fractionToPointAndDerivative(fraction);
|
|
344
|
-
const s = reverse ? -1.0 : 1.0;
|
|
345
|
-
return Math.atan2(s * ray.direction.y, s * ray.direction.x);
|
|
346
|
-
}
|
|
347
|
-
function getFractionOnCurve(pair, curve) {
|
|
348
|
-
if (pair.detailA.curve === curve)
|
|
349
|
-
return pair.detailA.fraction;
|
|
350
|
-
if (pair.detailB.curve === curve)
|
|
351
|
-
return pair.detailB.fraction;
|
|
352
|
-
return undefined;
|
|
353
|
-
}
|
|
354
|
-
function getDetailOnCurve(pair, curve) {
|
|
355
|
-
if (pair.detailA.curve === curve)
|
|
356
|
-
return pair.detailA;
|
|
357
|
-
if (pair.detailB.curve === curve)
|
|
358
|
-
return pair.detailB;
|
|
359
|
-
return undefined;
|
|
360
|
-
}
|
|
361
379
|
//# sourceMappingURL=PlanarSubdivision.js.map
|