@itwin/core-geometry 5.2.0 → 5.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.
Files changed (90) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  3. package/lib/cjs/curve/Arc3d.js +5 -7
  4. package/lib/cjs/curve/Arc3d.js.map +1 -1
  5. package/lib/cjs/curve/CurveOps.d.ts +2 -5
  6. package/lib/cjs/curve/CurveOps.d.ts.map +1 -1
  7. package/lib/cjs/curve/CurveOps.js +2 -5
  8. package/lib/cjs/curve/CurveOps.js.map +1 -1
  9. package/lib/cjs/curve/Query/PlanarSubdivision.d.ts +50 -15
  10. package/lib/cjs/curve/Query/PlanarSubdivision.d.ts.map +1 -1
  11. package/lib/cjs/curve/Query/PlanarSubdivision.js +102 -84
  12. package/lib/cjs/curve/Query/PlanarSubdivision.js.map +1 -1
  13. package/lib/cjs/curve/RegionOps.d.ts +44 -25
  14. package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
  15. package/lib/cjs/curve/RegionOps.js +74 -39
  16. package/lib/cjs/curve/RegionOps.js.map +1 -1
  17. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
  18. package/lib/cjs/curve/RegionOpsClassificationSweeps.js +8 -8
  19. package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
  20. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -0
  21. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  22. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +102 -92
  23. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  24. package/lib/cjs/geometry3d/GrowableXYArray.d.ts +2 -1
  25. package/lib/cjs/geometry3d/GrowableXYArray.d.ts.map +1 -1
  26. package/lib/cjs/geometry3d/GrowableXYArray.js +2 -1
  27. package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
  28. package/lib/cjs/geometry3d/GrowableXYZArray.d.ts +2 -1
  29. package/lib/cjs/geometry3d/GrowableXYZArray.d.ts.map +1 -1
  30. package/lib/cjs/geometry3d/GrowableXYZArray.js +2 -1
  31. package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
  32. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +9 -16
  33. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  34. package/lib/cjs/geometry3d/IndexedXYZCollection.js +3 -3
  35. package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
  36. package/lib/cjs/geometry3d/PolylineOps.d.ts +2 -2
  37. package/lib/cjs/geometry3d/PolylineOps.js +2 -2
  38. package/lib/cjs/geometry3d/PolylineOps.js.map +1 -1
  39. package/lib/cjs/numerics/ClusterableArray.d.ts.map +1 -1
  40. package/lib/cjs/numerics/ClusterableArray.js +2 -2
  41. package/lib/cjs/numerics/ClusterableArray.js.map +1 -1
  42. package/lib/cjs/topology/Merging.d.ts +15 -7
  43. package/lib/cjs/topology/Merging.d.ts.map +1 -1
  44. package/lib/cjs/topology/Merging.js +15 -10
  45. package/lib/cjs/topology/Merging.js.map +1 -1
  46. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  47. package/lib/esm/curve/Arc3d.js +5 -7
  48. package/lib/esm/curve/Arc3d.js.map +1 -1
  49. package/lib/esm/curve/CurveOps.d.ts +2 -5
  50. package/lib/esm/curve/CurveOps.d.ts.map +1 -1
  51. package/lib/esm/curve/CurveOps.js +2 -5
  52. package/lib/esm/curve/CurveOps.js.map +1 -1
  53. package/lib/esm/curve/Query/PlanarSubdivision.d.ts +50 -15
  54. package/lib/esm/curve/Query/PlanarSubdivision.d.ts.map +1 -1
  55. package/lib/esm/curve/Query/PlanarSubdivision.js +102 -84
  56. package/lib/esm/curve/Query/PlanarSubdivision.js.map +1 -1
  57. package/lib/esm/curve/RegionOps.d.ts +44 -25
  58. package/lib/esm/curve/RegionOps.d.ts.map +1 -1
  59. package/lib/esm/curve/RegionOps.js +72 -37
  60. package/lib/esm/curve/RegionOps.js.map +1 -1
  61. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
  62. package/lib/esm/curve/RegionOpsClassificationSweeps.js +8 -8
  63. package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
  64. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -0
  65. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  66. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +102 -92
  67. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  68. package/lib/esm/geometry3d/GrowableXYArray.d.ts +2 -1
  69. package/lib/esm/geometry3d/GrowableXYArray.d.ts.map +1 -1
  70. package/lib/esm/geometry3d/GrowableXYArray.js +2 -1
  71. package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
  72. package/lib/esm/geometry3d/GrowableXYZArray.d.ts +2 -1
  73. package/lib/esm/geometry3d/GrowableXYZArray.d.ts.map +1 -1
  74. package/lib/esm/geometry3d/GrowableXYZArray.js +2 -1
  75. package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
  76. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +9 -16
  77. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  78. package/lib/esm/geometry3d/IndexedXYZCollection.js +3 -3
  79. package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
  80. package/lib/esm/geometry3d/PolylineOps.d.ts +2 -2
  81. package/lib/esm/geometry3d/PolylineOps.js +2 -2
  82. package/lib/esm/geometry3d/PolylineOps.js.map +1 -1
  83. package/lib/esm/numerics/ClusterableArray.d.ts.map +1 -1
  84. package/lib/esm/numerics/ClusterableArray.js +2 -2
  85. package/lib/esm/numerics/ClusterableArray.js.map +1 -1
  86. package/lib/esm/topology/Merging.d.ts +15 -7
  87. package/lib/esm/topology/Merging.d.ts.map +1 -1
  88. package/lib/esm/topology/Merging.js +15 -10
  89. package/lib/esm/topology/Merging.js.map +1 -1
  90. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"IndexedXYZCollection.js","sourceRoot":"","sources":["../../../src/geometry3d/IndexedXYZCollection.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AACvC,uDAA2D;AAC3D,mCAAkC;AAIlC,MAAM,cAAc;IACD,WAAW,CAAuB;IAC3C,SAAS,GAAG,CAAC,CAAC,CAAC;IAEvB,YAAmB,UAAgC;QACjD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAEM,IAAI;QACT,IAAI,EAAE,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;YAChD,0JAA0J;YAC1J,OAAO,EAAE,IAAI,EAAE,IAAI,EAAoC,CAAC;QAC1D,CAAC;QAED,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,+BAA+B,CAAC,IAAI,CAAC,SAAS,CAAC;YACvE,IAAI,EAAE,KAAK;SACZ,CAAC;IACJ,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAwB,OAAO,IAAI,CAAC,CAAC,CAAC;CAC/D;AACD;;;;;;;;GAQG;AACH,MAAsB,oBAAoB;IAsCxC;;;;;;OAMG;IACI,iBAAiB,CAAC,MAAc,EAAE,MAAc,EAAE,MAAiB;QACxE,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAChE,OAAO,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IACD;;;;;;OAMG;IACI,yBAAyB,CAAC,MAAc,EAAE,MAAc,EAAE,MAAc;QAC7E,IAAI,MAAM,GAAG,CAAC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,MAAM,CAAC,EAAE,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;eACpH,mBAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;IAC5H,CAAC;IACD;;;;;;OAMG;IACI,uBAAuB,CAAC,MAAc,EAAE,MAAc,EAAE,SAAS,GAAG,mBAAQ,CAAC,mBAAmB;QACrG,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,IAAI,IAAI,CAAC,MAAM,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,IAAI,IAAI,CAAC,MAAM;YAC5E,OAAO,SAAS,CAAC;QACnB,OAAO,mBAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;eACtH,mBAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;IAC5H,CAAC;CACF;AA7TD,oDA6TC;AACD;;;GAGG;AACH,MAAsB,6BAA8B,SAAQ,oBAAoB;CAkB/E;AAlBD,sEAkBC","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 ArraysAndInterfaces\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Point3d, Vector3d, XYZ } from \"./Point3dVector3d\";\r\nimport { Range3d } from \"./Range\";\r\nimport { Transform } from \"./Transform\";\r\nimport { XAndY, XYAndZ } from \"./XYZProps\";\r\n\r\nclass PointsIterator implements Iterator<Point3d>, Iterable<Point3d> {\r\n private readonly _collection: IndexedXYZCollection;\r\n private _curIndex = -1;\r\n\r\n public constructor(collection: IndexedXYZCollection) {\r\n this._collection = collection;\r\n }\r\n\r\n public next(): IteratorResult<Point3d> {\r\n if (++this._curIndex >= this._collection.length) {\r\n // The ECMAScript spec states that value=undefined is valid if done=true. The TypeScript interface violates the spec hence the cast to any and back below.\r\n return { done: true } as any as IteratorResult<Point3d>;\r\n }\r\n\r\n return {\r\n value: this._collection.getPoint3dAtUncheckedPointIndex(this._curIndex),\r\n done: false,\r\n };\r\n }\r\n\r\n public [Symbol.iterator](): Iterator<Point3d> { return this; }\r\n}\r\n/**\r\n * abstract base class for read-only access to XYZ data with indexed reference.\r\n * * This allows algorithms to work with Point3d[] or GrowableXYZ.\r\n * * GrowableXYZArray implements these for its data.\r\n * * Point3dArrayCarrier carries a (reference to) a Point3d[] and implements the methods with calls on that array reference.\r\n * * In addition to \"point by point\" accessors, other abstract members compute commonly useful vector data \"between points\".\r\n * * Methods that create vectors among multiple indices allow callers to avoid creating temporaries.\r\n * @public\r\n */\r\nexport abstract class IndexedXYZCollection {\r\n /**\r\n * Return the point at `index` as a strongly typed Point3d.\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public abstract getPoint3dAtCheckedPointIndex(index: number, result?: Point3d): Point3d | undefined;\r\n /**\r\n * Return the point at `index` as a strongly typed Point3d, without checking the point index validity.\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public abstract getPoint3dAtUncheckedPointIndex(index: number, result?: Point3d): Point3d;\r\n /**\r\n * Get from `index` as a strongly typed Vector3d.\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public abstract getVector3dAtCheckedVectorIndex(index: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return a vector from the point at `indexA` to the point at `indexB`\r\n * @param indexA index of point within the array\r\n * @param indexB index of point within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public abstract vectorIndexIndex(indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return a vector from `origin` to the point at `indexB`\r\n * @param origin origin for vector\r\n * @param indexB index of point within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if index is out of bounds\r\n */\r\n public abstract vectorXYAndZIndex(origin: XYAndZ, indexB: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return a vector from the point at `indexA` to `target`\r\n * @param indexA index of point within the array\r\n * @param target target for vector\r\n * @param result caller-allocated vector.\r\n * @returns undefined if index is out of bounds\r\n */\r\n public vectorIndexXYAndZ(indexA: number, target: XYAndZ, result?: Vector3d): Vector3d | undefined {\r\n const reversed = this.vectorXYAndZIndex(target, indexA, result);\r\n return reversed?.negate(reversed);\r\n }\r\n /**\r\n * Return the dot product of the vectors from the point at `origin` to the points at `indexA` and `indexB`.\r\n * @param origin index of point within the array; origin of both vectors\r\n * @param indexA index of point within the array; target of the first vector\r\n * @param indexA index of point within the array; target of the second vector\r\n * @returns undefined if index is out of bounds\r\n */\r\n public dotProductIndexIndexIndex(origin: number, indexA: number, indexB: number): number | undefined {\r\n if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length || indexB < 0 || indexB >= this.length)\r\n return undefined;\r\n const x0 = this.getXAtUncheckedPointIndex(origin);\r\n const y0 = this.getYAtUncheckedPointIndex(origin);\r\n const z0 = this.getZAtUncheckedPointIndex(origin);\r\n return (this.getXAtUncheckedPointIndex(indexA) - x0) * (this.getXAtUncheckedPointIndex(indexB) - x0) +\r\n (this.getYAtUncheckedPointIndex(indexA) - y0) * (this.getYAtUncheckedPointIndex(indexB) - y0) +\r\n (this.getZAtUncheckedPointIndex(indexA) - z0) * (this.getZAtUncheckedPointIndex(indexB) - z0);\r\n }\r\n /**\r\n * Return the dot product of the vectors from the point at `origin` to the point at `indexA` and to `targetB`.\r\n * @param origin index of point within the array; origin of both vectors\r\n * @param indexA index of point within the array; target of the first vector\r\n * @param targetB target for second vector\r\n * @returns undefined if index is out of bounds\r\n */\r\n public dotProductIndexIndexXYAndZ(origin: number, indexA: number, targetB: XYAndZ): number | undefined {\r\n if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length)\r\n return undefined;\r\n const x0 = this.getXAtUncheckedPointIndex(origin);\r\n const y0 = this.getYAtUncheckedPointIndex(origin);\r\n const z0 = this.getZAtUncheckedPointIndex(origin);\r\n return (this.getXAtUncheckedPointIndex(indexA) - x0) * (targetB.x - x0) +\r\n (this.getYAtUncheckedPointIndex(indexA) - y0) * (targetB.y - y0) +\r\n (this.getZAtUncheckedPointIndex(indexA) - z0) * (targetB.z - z0);\r\n }\r\n /**\r\n * Return the cross product of the vectors from `origin` to points at `indexA` and `indexB`\r\n * @param origin origin for vector\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public abstract crossProductXYAndZIndexIndex(origin: XYAndZ, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return the cross product of the vectors from `origin` to the point at `indexA` and to `targetB`\r\n * @param origin index of point within the array; origin of both vectors\r\n * @param indexA index of point within the array; target of the first vector\r\n * @param targetB target of second vector\r\n * @param result optional caller-allocated result to fill and return\r\n * @returns undefined if an index is out of bounds\r\n */\r\n public crossProductIndexIndexXYAndZ(origin: number, indexA: number, targetB: XYAndZ, result?: Vector3d): Vector3d | undefined {\r\n if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length)\r\n return undefined;\r\n const x0 = this.getXAtUncheckedPointIndex(origin);\r\n const y0 = this.getYAtUncheckedPointIndex(origin);\r\n const z0 = this.getZAtUncheckedPointIndex(origin);\r\n return Vector3d.createCrossProduct(this.getXAtUncheckedPointIndex(indexA) - x0,\r\n this.getYAtUncheckedPointIndex(indexA) - y0,\r\n this.getZAtUncheckedPointIndex(indexA) - z0,\r\n targetB.x - x0,\r\n targetB.y - y0,\r\n targetB.z - z0, result);\r\n }\r\n /**\r\n * Return the cross product of vectors from `origin` to points at `indexA` and `indexB`\r\n * @param origin origin for vector\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result optional caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public abstract crossProductIndexIndexIndex(origin: number, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return the cross product of vectors from origin point at `indexA` to target points at `indexB` and `indexC`\r\n * @param origin index of origin\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result caller-allocated vector.\r\n * @returns return true if indexA, indexB both valid\r\n */\r\n public abstract accumulateCrossProductIndexIndexIndex(origin: number, indexA: number, indexB: number, result: Vector3d): void;\r\n\r\n /**\r\n * read-only property for number of XYZ in the collection.\r\n */\r\n public abstract get length(): number;\r\n /**\r\n * Return distance squared between indicated points.\r\n * @param index0 first point index\r\n * @param index1 second point index\r\n */\r\n public abstract distanceSquaredIndexIndex(index0: number, index1: number): number | undefined;\r\n /**\r\n * Return distance squared between the point at index0 and target.\r\n * @param index0 first point index\r\n * @param target second point\r\n */\r\n public distanceSquaredIndexXYAndZ(index0: number, target: XYAndZ): number | undefined {\r\n if (index0 < 0 || index0 >= this.length)\r\n return undefined;\r\n return Geometry.hypotenuseSquaredXYZ(\r\n target.x - this.getXAtUncheckedPointIndex(index0),\r\n target.y - this.getYAtUncheckedPointIndex(index0),\r\n target.z - this.getZAtUncheckedPointIndex(index0));\r\n }\r\n /**\r\n * Return distance between indicated points.\r\n * @param index0 first point index\r\n * @param index1 second point index\r\n */\r\n public abstract distanceIndexIndex(index0: number, index1: number): number | undefined;\r\n /**\r\n * Test if index is valid for an xyz within this array.\r\n * @param index xyz index to test.\r\n */\r\n public isIndexValid(index: number): boolean {\r\n return index >= 0 && index < this.length;\r\n }\r\n /** Adjust index into range by modulo with the length. */\r\n public cyclicIndex(i: number): number {\r\n return (i % this.length);\r\n }\r\n /** Return the range of the points. */\r\n public getRange(transform?: Transform, result?: Range3d): Range3d {\r\n let range = result;\r\n if (range)\r\n range.setNull();\r\n else\r\n range = Range3d.createNull();\r\n const n = this.length;\r\n const point = Point3d.create();\r\n for (let i = 0; i < n; i++) {\r\n this.getPoint3dAtUncheckedPointIndex(i, point);\r\n range.extendPoint(point, transform);\r\n }\r\n return range;\r\n }\r\n\r\n /**\r\n * For each subset of `k` successive points within tolerance of the first point in the subset, return the indices of\r\n * the last `k-1` duplicates.\r\n * * Index `0` is never returned.\r\n * @param tolerance optional distance tol for compression (default [[Geometry.smallMetricDistance]])\r\n * @param preserveLast if the last `k < this.length` points of the instance are duplicates, whether to return the\r\n * indices of the *first* `k-1` duplicates for this last run. If true, index `this.length - 1` is not returned\r\n * unless all points are duplicates, in which case all indices but `0` are returned. Default value is false.\r\n * @return ordered array of 0-based indices of duplicate points\r\n */\r\n public findOrderedDuplicates(tolerance: number = Geometry.smallMetricDistance, preserveLast: boolean = false): number[] {\r\n const indices: number[] = [];\r\n if (this.length > 1) {\r\n for (let i = 0; i < this.length - 1;) {\r\n let j = i + 1;\r\n for (; this.almostEqualIndexIndex(i, j, tolerance); ++j)\r\n indices.push(j);\r\n i = j; // found next unique point\r\n }\r\n if (preserveLast && indices.length > 0 && indices.length < this.length - 1) { // not all points are duplicate\r\n let numLastRun = 0;\r\n for (; numLastRun <= indices.length - 1 && indices[indices.length - 1 - numLastRun] === this.length - 1 - numLastRun; ++numLastRun);\r\n for (let i = 0; i < numLastRun; ++i)\r\n indices[indices.length - 1 - i] -= 1; // decrement the indices of the last run so that the last point is preserved\r\n }\r\n }\r\n return indices;\r\n }\r\n\r\n /** Accumulate scale times the x,y,z values at index.\r\n * * No action if index is out of bounds.\r\n */\r\n public abstract accumulateScaledXYZ(index: number, scale: number, sum: Point3d): void;\r\n\r\n /** Compute the linear combination s of the indexed p_i and given scales s_i.\r\n * @param scales array of scales. For best results, scales should have same length as the instance.\r\n * @param result optional pre-allocated object to fill and return\r\n * @return s = sum(p_i * s_i), where i ranges from 0 to min(this.length, scales.length).\r\n */\r\n public linearCombination(scales: number[], result?: Point3d | Vector3d): XYZ {\r\n const n = Math.min(this.length, scales.length);\r\n const sum = (result instanceof Vector3d) ? Vector3d.createZero(result) : Point3d.createZero(result);\r\n for (let i = 0; i < n; ++i) {\r\n sum.x += scales[i] * this.getXAtUncheckedPointIndex(i);\r\n sum.y += scales[i] * this.getYAtUncheckedPointIndex(i);\r\n sum.z += scales[i] * this.getZAtUncheckedPointIndex(i);\r\n }\r\n return sum;\r\n }\r\n\r\n /**\r\n * Interpolate the points at the given indices.\r\n * @param index0 index of point p0 within the array\r\n * @param fraction fraction f such that returned point is p0 + f * (p1 - p0)\r\n * @param index1 index of point p1 within the array\r\n * @param result optional caller-allocated result to fill and return\r\n * @returns undefined if an index is out of bounds\r\n */\r\n public interpolateIndexIndex(index0: number, fraction: number, index1: number, result?: Point3d): Point3d | undefined {\r\n if (index0 < 0 || index0 >= this.length || index1 < 0 || index1 >= this.length)\r\n return undefined;\r\n return Point3d.create(Geometry.interpolate(this.getXAtUncheckedPointIndex(index0), fraction, this.getXAtUncheckedPointIndex(index1)),\r\n Geometry.interpolate(this.getYAtUncheckedPointIndex(index0), fraction, this.getYAtUncheckedPointIndex(index1)),\r\n Geometry.interpolate(this.getZAtUncheckedPointIndex(index0), fraction, this.getZAtUncheckedPointIndex(index1)), result);\r\n }\r\n\r\n /** access x of indexed point */\r\n public abstract getXAtUncheckedPointIndex(pointIndex: number): number;\r\n\r\n /** access y of indexed point */\r\n public abstract getYAtUncheckedPointIndex(pointIndex: number): number;\r\n\r\n /** access z of indexed point */\r\n public abstract getZAtUncheckedPointIndex(pointIndex: number): number;\r\n\r\n /** Return iterator over the points in this collection. Usage:\r\n * ```ts\r\n * for (const point: Point3d of collection.points) { ... }\r\n * ```\r\n */\r\n public get points(): Iterable<Point3d> {\r\n return new PointsIterator(this);\r\n }\r\n /** convert to Point3d[] */\r\n public getArray(): Point3d[] {\r\n const result = [];\r\n for (const p of this.points)\r\n result.push(p);\r\n return result;\r\n }\r\n /** Return the first point, or undefined if the array is empty. */\r\n public front(result?: Point3d): Point3d | undefined {\r\n if (this.length === 0)\r\n return undefined;\r\n return this.getPoint3dAtUncheckedPointIndex(0, result);\r\n }\r\n /** Return the last point, or undefined if the array is empty. */\r\n public back(result?: Point3d): Point3d | undefined {\r\n if (this.length === 0)\r\n return undefined;\r\n return this.getPoint3dAtUncheckedPointIndex(this.length - 1, result);\r\n }\r\n /**\r\n * Test whether the indexed points are equal within tolerance.\r\n * @param index0 index of first point\r\n * @param index1 index of second point\r\n * @param tolerance max coordinate difference to be considered equal. For exact test, pass 0. Defaults to `Geometry.smallMetricDistance`.\r\n * @returns whether the points are equal within tolerance, or `undefined` if either index is invalid.\r\n */\r\n public almostEqualIndexIndex(index0: number, index1: number, tolerance = Geometry.smallMetricDistance): boolean | undefined {\r\n if (index0 < 0 || index0 >= this.length || index1 < 0 || index1 >= this.length)\r\n return undefined;\r\n return Geometry.isSameCoordinate(this.getXAtUncheckedPointIndex(index0), this.getXAtUncheckedPointIndex(index1), tolerance)\r\n && Geometry.isSameCoordinate(this.getYAtUncheckedPointIndex(index0), this.getYAtUncheckedPointIndex(index1), tolerance)\r\n && Geometry.isSameCoordinate(this.getZAtUncheckedPointIndex(index0), this.getZAtUncheckedPointIndex(index1), tolerance);\r\n }\r\n /**\r\n * Test whether the xy-coordinates of the indexed points are equal within tolerance. The z-coordinates are ignored.\r\n * @param index0 index of first point\r\n * @param index1 index of second point\r\n * @param tolerance max coordinate difference to be considered equal. For exact test, pass 0. Defaults to `Geometry.smallMetricDistance`.\r\n * @returns whether the xy-coordinates of the points are equal within tolerance, or `undefined` if either index is invalid.\r\n */\r\n public almostEqualXYIndexIndex(index0: number, index1: number, tolerance = Geometry.smallMetricDistance): boolean | undefined {\r\n if (index0 < 0 || index0 >= this.length || index1 < 0 || index1 >= this.length)\r\n return undefined;\r\n return Geometry.isSameCoordinate(this.getXAtUncheckedPointIndex(index0), this.getXAtUncheckedPointIndex(index1), tolerance)\r\n && Geometry.isSameCoordinate(this.getYAtUncheckedPointIndex(index0), this.getYAtUncheckedPointIndex(index1), tolerance);\r\n }\r\n}\r\n/**\r\n * abstract base class extends IndexedXYZCollection, adding methods to push, peek, and pop, and rewrite.\r\n * @public\r\n */\r\nexport abstract class IndexedReadWriteXYZCollection extends IndexedXYZCollection {\r\n /** push a (clone of) point onto the collection\r\n * * point itself is not pushed -- xyz data is extracted into the native form of the collection.\r\n */\r\n public abstract push(data: XYAndZ): void;\r\n /**\r\n * push a new point (given by coordinates) onto the collection\r\n * @param x x coordinate\r\n * @param y y coordinate\r\n * @param z z coordinate\r\n */\r\n public abstract pushXYZ(x?: number, y?: number, z?: number): void;\r\n /** remove the final point. */\r\n public abstract pop(): void;\r\n /** clear all entries */\r\n public abstract clear(): void;\r\n /** reverse the points in place. */\r\n public abstract reverseInPlace(): void;\r\n}\r\n\r\n/**\r\n * Type for use as signature for xyz data of a single linestring appearing in a parameter list.\r\n * @public\r\n */\r\nexport type LineStringDataVariant = IndexedXYZCollection | XYAndZ[] | XAndY[] | number[][];\r\n\r\n/**\r\n * Type for use as signature for multiple xyz data of multiple linestrings appearing in a parameter list.\r\n * @public\r\n */\r\nexport type MultiLineStringDataVariant = LineStringDataVariant | LineStringDataVariant[];\r\n"]}
1
+ {"version":3,"file":"IndexedXYZCollection.js","sourceRoot":"","sources":["../../../src/geometry3d/IndexedXYZCollection.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AACvC,uDAA2D;AAC3D,mCAAkC;AAIlC,MAAM,cAAc;IACD,WAAW,CAAuB;IAC3C,SAAS,GAAG,CAAC,CAAC,CAAC;IAEvB,YAAmB,UAAgC;QACjD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IA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OAAO,SAAS,CAAC;QACnB,OAAO,mBAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;eACtH,mBAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;IAC5H,CAAC;CACF;AA7TD,oDA6TC;AACD;;;GAGG;AACH,MAAsB,6BAA8B,SAAQ,oBAAoB;CAW/E;AAXD,sEAWC","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 ArraysAndInterfaces\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Point3d, Vector3d, XYZ } from \"./Point3dVector3d\";\r\nimport { Range3d } from \"./Range\";\r\nimport { Transform } from \"./Transform\";\r\nimport { XAndY, XYAndZ } from \"./XYZProps\";\r\n\r\nclass PointsIterator implements Iterator<Point3d>, Iterable<Point3d> {\r\n private readonly _collection: IndexedXYZCollection;\r\n private _curIndex = -1;\r\n\r\n public constructor(collection: IndexedXYZCollection) {\r\n this._collection = collection;\r\n }\r\n\r\n public next(): IteratorResult<Point3d> {\r\n if (++this._curIndex >= this._collection.length) {\r\n // The ECMAScript spec states that value=undefined is valid if done=true. The TypeScript interface violates the spec hence the cast to any and back below.\r\n return { done: true } as any as IteratorResult<Point3d>;\r\n }\r\n\r\n return {\r\n value: this._collection.getPoint3dAtUncheckedPointIndex(this._curIndex),\r\n done: false,\r\n };\r\n }\r\n\r\n public [Symbol.iterator](): Iterator<Point3d> { return this; }\r\n}\r\n/**\r\n * Abstract base class for read-only access to XYZ data with indexed reference.\r\n * * This allows algorithms to work with Point3d[] or [[GrowableXYZArray]].\r\n * * GrowableXYZArray implements these for its data.\r\n * * Point3dArrayCarrier carries a (reference to) a Point3d[] and implements the methods with calls on that array reference.\r\n * * In addition to \"point by point\" accessors, other abstract members compute commonly useful vector data \"between points\".\r\n * * Methods that create vectors among multiple indices allow callers to avoid creating temporaries.\r\n * @public\r\n */\r\nexport abstract class IndexedXYZCollection {\r\n /**\r\n * Return the point at `index` as a strongly typed Point3d.\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public abstract getPoint3dAtCheckedPointIndex(index: number, result?: Point3d): Point3d | undefined;\r\n /**\r\n * Return the point at `index` as a strongly typed Point3d, without checking the point index validity.\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public abstract getPoint3dAtUncheckedPointIndex(index: number, result?: Point3d): Point3d;\r\n /**\r\n * Get from `index` as a strongly typed Vector3d.\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public abstract getVector3dAtCheckedVectorIndex(index: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return a vector from the point at `indexA` to the point at `indexB`\r\n * @param indexA index of point within the array\r\n * @param indexB index of point within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public abstract vectorIndexIndex(indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return a vector from `origin` to the point at `indexB`\r\n * @param origin origin for vector\r\n * @param indexB index of point within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if index is out of bounds\r\n */\r\n public abstract vectorXYAndZIndex(origin: XYAndZ, indexB: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return a vector from the point at `indexA` to `target`\r\n * @param indexA index of point within the array\r\n * @param target target for vector\r\n * @param result caller-allocated vector.\r\n * @returns undefined if index is out of bounds\r\n */\r\n public vectorIndexXYAndZ(indexA: number, target: XYAndZ, result?: Vector3d): Vector3d | undefined {\r\n const reversed = this.vectorXYAndZIndex(target, indexA, result);\r\n return reversed?.negate(reversed);\r\n }\r\n /**\r\n * Return the dot product of the vectors from the point at `origin` to the points at `indexA` and `indexB`.\r\n * @param origin index of point within the array; origin of both vectors\r\n * @param indexA index of point within the array; target of the first vector\r\n * @param indexA index of point within the array; target of the second vector\r\n * @returns undefined if index is out of bounds\r\n */\r\n public dotProductIndexIndexIndex(origin: number, indexA: number, indexB: number): number | undefined {\r\n if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length || indexB < 0 || indexB >= this.length)\r\n return undefined;\r\n const x0 = this.getXAtUncheckedPointIndex(origin);\r\n const y0 = this.getYAtUncheckedPointIndex(origin);\r\n const z0 = this.getZAtUncheckedPointIndex(origin);\r\n return (this.getXAtUncheckedPointIndex(indexA) - x0) * (this.getXAtUncheckedPointIndex(indexB) - x0) +\r\n (this.getYAtUncheckedPointIndex(indexA) - y0) * (this.getYAtUncheckedPointIndex(indexB) - y0) +\r\n (this.getZAtUncheckedPointIndex(indexA) - z0) * (this.getZAtUncheckedPointIndex(indexB) - z0);\r\n }\r\n /**\r\n * Return the dot product of the vectors from the point at `origin` to the point at `indexA` and to `targetB`.\r\n * @param origin index of point within the array; origin of both vectors\r\n * @param indexA index of point within the array; target of the first vector\r\n * @param targetB target for second vector\r\n * @returns undefined if index is out of bounds\r\n */\r\n public dotProductIndexIndexXYAndZ(origin: number, indexA: number, targetB: XYAndZ): number | undefined {\r\n if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length)\r\n return undefined;\r\n const x0 = this.getXAtUncheckedPointIndex(origin);\r\n const y0 = this.getYAtUncheckedPointIndex(origin);\r\n const z0 = this.getZAtUncheckedPointIndex(origin);\r\n return (this.getXAtUncheckedPointIndex(indexA) - x0) * (targetB.x - x0) +\r\n (this.getYAtUncheckedPointIndex(indexA) - y0) * (targetB.y - y0) +\r\n (this.getZAtUncheckedPointIndex(indexA) - z0) * (targetB.z - z0);\r\n }\r\n /**\r\n * Return the cross product of the vectors from `origin` to points at `indexA` and `indexB`\r\n * @param origin origin for vector\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public abstract crossProductXYAndZIndexIndex(origin: XYAndZ, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return the cross product of the vectors from `origin` to the point at `indexA` and to `targetB`\r\n * @param origin index of point within the array; origin of both vectors\r\n * @param indexA index of point within the array; target of the first vector\r\n * @param targetB target of second vector\r\n * @param result optional caller-allocated result to fill and return\r\n * @returns undefined if an index is out of bounds\r\n */\r\n public crossProductIndexIndexXYAndZ(origin: number, indexA: number, targetB: XYAndZ, result?: Vector3d): Vector3d | undefined {\r\n if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length)\r\n return undefined;\r\n const x0 = this.getXAtUncheckedPointIndex(origin);\r\n const y0 = this.getYAtUncheckedPointIndex(origin);\r\n const z0 = this.getZAtUncheckedPointIndex(origin);\r\n return Vector3d.createCrossProduct(this.getXAtUncheckedPointIndex(indexA) - x0,\r\n this.getYAtUncheckedPointIndex(indexA) - y0,\r\n this.getZAtUncheckedPointIndex(indexA) - z0,\r\n targetB.x - x0,\r\n targetB.y - y0,\r\n targetB.z - z0, result);\r\n }\r\n /**\r\n * Return the cross product of vectors from `origin` to points at `indexA` and `indexB`\r\n * @param origin origin for vector\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result optional caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public abstract crossProductIndexIndexIndex(origin: number, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return the cross product of vectors from origin point at `indexA` to target points at `indexB` and `indexC`\r\n * @param origin index of origin\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result caller-allocated vector.\r\n * @returns return true if indexA, indexB both valid\r\n */\r\n public abstract accumulateCrossProductIndexIndexIndex(origin: number, indexA: number, indexB: number, result: Vector3d): void;\r\n\r\n /**\r\n * read-only property for number of XYZ in the collection.\r\n */\r\n public abstract get length(): number;\r\n /**\r\n * Return distance squared between indicated points.\r\n * @param index0 first point index\r\n * @param index1 second point index\r\n */\r\n public abstract distanceSquaredIndexIndex(index0: number, index1: number): number | undefined;\r\n /**\r\n * Return distance squared between the point at index0 and target.\r\n * @param index0 first point index\r\n * @param target second point\r\n */\r\n public distanceSquaredIndexXYAndZ(index0: number, target: XYAndZ): number | undefined {\r\n if (index0 < 0 || index0 >= this.length)\r\n return undefined;\r\n return Geometry.hypotenuseSquaredXYZ(\r\n target.x - this.getXAtUncheckedPointIndex(index0),\r\n target.y - this.getYAtUncheckedPointIndex(index0),\r\n target.z - this.getZAtUncheckedPointIndex(index0));\r\n }\r\n /**\r\n * Return distance between indicated points.\r\n * @param index0 first point index\r\n * @param index1 second point index\r\n */\r\n public abstract distanceIndexIndex(index0: number, index1: number): number | undefined;\r\n /**\r\n * Test if index is valid for an xyz within this array.\r\n * @param index xyz index to test.\r\n */\r\n public isIndexValid(index: number): boolean {\r\n return index >= 0 && index < this.length;\r\n }\r\n /** Adjust index into range by modulo with the length. */\r\n public cyclicIndex(i: number): number {\r\n return (i % this.length);\r\n }\r\n /** Return the range of the points. */\r\n public getRange(transform?: Transform, result?: Range3d): Range3d {\r\n let range = result;\r\n if (range)\r\n range.setNull();\r\n else\r\n range = Range3d.createNull();\r\n const n = this.length;\r\n const point = Point3d.create();\r\n for (let i = 0; i < n; i++) {\r\n this.getPoint3dAtUncheckedPointIndex(i, point);\r\n range.extendPoint(point, transform);\r\n }\r\n return range;\r\n }\r\n\r\n /**\r\n * For each subset of `k` successive points within tolerance of the first point in the subset, return the indices of\r\n * the last `k-1` duplicates.\r\n * * Index `0` is never returned.\r\n * @param tolerance optional distance tol for compression (default [[Geometry.smallMetricDistance]])\r\n * @param preserveLast if the last `k < this.length` points of the instance are duplicates, whether to return the\r\n * indices of the *first* `k-1` duplicates for this last run. If true, index `this.length - 1` is not returned\r\n * unless all points are duplicates, in which case all indices but `0` are returned. Default value is false.\r\n * @return ordered array of 0-based indices of duplicate points\r\n */\r\n public findOrderedDuplicates(tolerance: number = Geometry.smallMetricDistance, preserveLast: boolean = false): number[] {\r\n const indices: number[] = [];\r\n if (this.length > 1) {\r\n for (let i = 0; i < this.length - 1;) {\r\n let j = i + 1;\r\n for (; this.almostEqualIndexIndex(i, j, tolerance); ++j)\r\n indices.push(j);\r\n i = j; // found next unique point\r\n }\r\n if (preserveLast && indices.length > 0 && indices.length < this.length - 1) { // not all points are duplicate\r\n let numLastRun = 0;\r\n for (; numLastRun <= indices.length - 1 && indices[indices.length - 1 - numLastRun] === this.length - 1 - numLastRun; ++numLastRun);\r\n for (let i = 0; i < numLastRun; ++i)\r\n indices[indices.length - 1 - i] -= 1; // decrement the indices of the last run so that the last point is preserved\r\n }\r\n }\r\n return indices;\r\n }\r\n\r\n /** Accumulate scale times the x,y,z values at index.\r\n * * No action if index is out of bounds.\r\n */\r\n public abstract accumulateScaledXYZ(index: number, scale: number, sum: Point3d): void;\r\n\r\n /** Compute the linear combination s of the indexed p_i and given scales s_i.\r\n * @param scales array of scales. For best results, scales should have same length as the instance.\r\n * @param result optional pre-allocated object to fill and return\r\n * @return s = sum(p_i * s_i), where i ranges from 0 to min(this.length, scales.length).\r\n */\r\n public linearCombination(scales: number[], result?: Point3d | Vector3d): XYZ {\r\n const n = Math.min(this.length, scales.length);\r\n const sum = (result instanceof Vector3d) ? Vector3d.createZero(result) : Point3d.createZero(result);\r\n for (let i = 0; i < n; ++i) {\r\n sum.x += scales[i] * this.getXAtUncheckedPointIndex(i);\r\n sum.y += scales[i] * this.getYAtUncheckedPointIndex(i);\r\n sum.z += scales[i] * this.getZAtUncheckedPointIndex(i);\r\n }\r\n return sum;\r\n }\r\n\r\n /**\r\n * Interpolate the points at the given indices.\r\n * @param index0 index of point p0 within the array\r\n * @param fraction fraction f such that returned point is p0 + f * (p1 - p0)\r\n * @param index1 index of point p1 within the array\r\n * @param result optional caller-allocated result to fill and return\r\n * @returns undefined if an index is out of bounds\r\n */\r\n public interpolateIndexIndex(index0: number, fraction: number, index1: number, result?: Point3d): Point3d | undefined {\r\n if (index0 < 0 || index0 >= this.length || index1 < 0 || index1 >= this.length)\r\n return undefined;\r\n return Point3d.create(Geometry.interpolate(this.getXAtUncheckedPointIndex(index0), fraction, this.getXAtUncheckedPointIndex(index1)),\r\n Geometry.interpolate(this.getYAtUncheckedPointIndex(index0), fraction, this.getYAtUncheckedPointIndex(index1)),\r\n Geometry.interpolate(this.getZAtUncheckedPointIndex(index0), fraction, this.getZAtUncheckedPointIndex(index1)), result);\r\n }\r\n\r\n /** access x of indexed point */\r\n public abstract getXAtUncheckedPointIndex(pointIndex: number): number;\r\n\r\n /** access y of indexed point */\r\n public abstract getYAtUncheckedPointIndex(pointIndex: number): number;\r\n\r\n /** access z of indexed point */\r\n public abstract getZAtUncheckedPointIndex(pointIndex: number): number;\r\n\r\n /** Return iterator over the points in this collection. Usage:\r\n * ```ts\r\n * for (const point: Point3d of collection.points) { ... }\r\n * ```\r\n */\r\n public get points(): Iterable<Point3d> {\r\n return new PointsIterator(this);\r\n }\r\n /** convert to Point3d[] */\r\n public getArray(): Point3d[] {\r\n const result = [];\r\n for (const p of this.points)\r\n result.push(p);\r\n return result;\r\n }\r\n /** Return the first point, or undefined if the array is empty. */\r\n public front(result?: Point3d): Point3d | undefined {\r\n if (this.length === 0)\r\n return undefined;\r\n return this.getPoint3dAtUncheckedPointIndex(0, result);\r\n }\r\n /** Return the last point, or undefined if the array is empty. */\r\n public back(result?: Point3d): Point3d | undefined {\r\n if (this.length === 0)\r\n return undefined;\r\n return this.getPoint3dAtUncheckedPointIndex(this.length - 1, result);\r\n }\r\n /**\r\n * Test whether the indexed points are equal within tolerance.\r\n * @param index0 index of first point\r\n * @param index1 index of second point\r\n * @param tolerance max coordinate difference to be considered equal. For exact test, pass 0. Defaults to `Geometry.smallMetricDistance`.\r\n * @returns whether the points are equal within tolerance, or `undefined` if either index is invalid.\r\n */\r\n public almostEqualIndexIndex(index0: number, index1: number, tolerance = Geometry.smallMetricDistance): boolean | undefined {\r\n if (index0 < 0 || index0 >= this.length || index1 < 0 || index1 >= this.length)\r\n return undefined;\r\n return Geometry.isSameCoordinate(this.getXAtUncheckedPointIndex(index0), this.getXAtUncheckedPointIndex(index1), tolerance)\r\n && Geometry.isSameCoordinate(this.getYAtUncheckedPointIndex(index0), this.getYAtUncheckedPointIndex(index1), tolerance)\r\n && Geometry.isSameCoordinate(this.getZAtUncheckedPointIndex(index0), this.getZAtUncheckedPointIndex(index1), tolerance);\r\n }\r\n /**\r\n * Test whether the xy-coordinates of the indexed points are equal within tolerance. The z-coordinates are ignored.\r\n * @param index0 index of first point\r\n * @param index1 index of second point\r\n * @param tolerance max coordinate difference to be considered equal. For exact test, pass 0. Defaults to `Geometry.smallMetricDistance`.\r\n * @returns whether the xy-coordinates of the points are equal within tolerance, or `undefined` if either index is invalid.\r\n */\r\n public almostEqualXYIndexIndex(index0: number, index1: number, tolerance = Geometry.smallMetricDistance): boolean | undefined {\r\n if (index0 < 0 || index0 >= this.length || index1 < 0 || index1 >= this.length)\r\n return undefined;\r\n return Geometry.isSameCoordinate(this.getXAtUncheckedPointIndex(index0), this.getXAtUncheckedPointIndex(index1), tolerance)\r\n && Geometry.isSameCoordinate(this.getYAtUncheckedPointIndex(index0), this.getYAtUncheckedPointIndex(index1), tolerance);\r\n }\r\n}\r\n/**\r\n * Abstract base class extends [[IndexedXYZCollection]] with methods that modify the collection.\r\n * @public\r\n */\r\nexport abstract class IndexedReadWriteXYZCollection extends IndexedXYZCollection {\r\n /** Push a (clone of) point onto the collection. */\r\n public abstract push(point: XYAndZ): void;\r\n /** Push a new point (given by xyz coordinates) onto the collection. */\r\n public abstract pushXYZ(x?: number, y?: number, z?: number): void;\r\n /** Remove the final point. */\r\n public abstract pop(): void;\r\n /** Remove all entries. */\r\n public abstract clear(): void;\r\n /** Reverse the points in place. */\r\n public abstract reverseInPlace(): void;\r\n}\r\n\r\n/**\r\n * Type for use as signature for xyz data of a single linestring appearing in a parameter list.\r\n * @public\r\n */\r\nexport type LineStringDataVariant = IndexedXYZCollection | XYAndZ[] | XAndY[] | number[][];\r\n\r\n/**\r\n * Type for use as signature for multiple xyz data of multiple linestrings appearing in a parameter list.\r\n * @public\r\n */\r\nexport type MultiLineStringDataVariant = LineStringDataVariant | LineStringDataVariant[];\r\n"]}
@@ -118,8 +118,8 @@ export declare class PolylineOps {
118
118
  * Checks if all points are colinear.
119
119
  * * This test does not take point order into account.
120
120
  * @param points array of points to check.
121
- * @param distanceTol tolerance for co-linearity check, default is Geometry.smallMetricDistance.
122
- * @param xyOnly if true, only XY coordinates are used for the check, ignoring z coordinate.
121
+ * @param distanceTol maximum allowable distance that geometry can deviate from colinearity.Default is [[Geometry.smallMetricDistance]].
122
+ * @param xyOnly whether to ignore z-coordinates in the colinearity test.
123
123
  */
124
124
  static isColinear(points: Point3d[], distanceTol?: number, xyOnly?: boolean): boolean;
125
125
  }
@@ -355,8 +355,8 @@ class PolylineOps {
355
355
  * Checks if all points are colinear.
356
356
  * * This test does not take point order into account.
357
357
  * @param points array of points to check.
358
- * @param distanceTol tolerance for co-linearity check, default is Geometry.smallMetricDistance.
359
- * @param xyOnly if true, only XY coordinates are used for the check, ignoring z coordinate.
358
+ * @param distanceTol maximum allowable distance that geometry can deviate from colinearity.Default is [[Geometry.smallMetricDistance]].
359
+ * @param xyOnly whether to ignore z-coordinates in the colinearity test.
360
360
  */
361
361
  static isColinear(points, distanceTol = Geometry_1.Geometry.smallMetricDistance, xyOnly = false) {
362
362
  if (points.length < 3)
@@ -1 +1 @@
1
- {"version":3,"file":"PolylineOps.js","sourceRoot":"","sources":["../../../src/geometry3d/PolylineOps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;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AAM,GAAG,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,4BAA4B;wBAC9E,2BAAY,CAAC,0BAA0B,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;wBACtG,2BAAY,CAAC,0BAA0B,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;wBACtG,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW;4BAC1D,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,uCAAuC;wBAC1H,IAAI,GAAG,CAAC,CAAC;wBACT,QAAQ,GAAG,IAAI,CAAC;oBAClB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IACvC,CAAC;IACD;;;;;;OAMG;IACI,MAAM,CAAC,UAAU,CACtB,MAAiB,EAAE,cAAsB,mBAAQ,CAAC,mBAAmB,EAAE,SAAkB,KAAK;QAE9F,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YACnB,OAAO,IAAI,CAAC;QACd,OAAO,SAAS,KAAK,mBAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;IACtG,CAAC;CACF;AA7VD,kCA6VC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { CurveExtendMode, CurveExtendOptions, VariantCurveExtendParameter } from \"../curve/CurveExtendMode\";\r\nimport { CurveLocationDetailPair } from \"../curve/CurveLocationDetail\";\r\nimport { CurveOps } from \"../curve/CurveOps\";\r\nimport { LineSegment3d } from \"../curve/LineSegment3d\";\r\nimport { LineString3d } from \"../curve/LineString3d\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GrowableXYZArray } from \"./GrowableXYZArray\";\r\nimport { IndexedXYZCollection } from \"./IndexedXYZCollection\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"./Plane3dByOriginAndUnitNormal\";\r\nimport { Point3dArrayCarrier } from \"./Point3dArrayCarrier\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { PolylineCompressionContext } from \"./PolylineCompressionByEdgeOffset\";\r\nimport { Range1d } from \"./Range\";\r\n\r\n// cspell:word Puecker\r\n/**\r\n * PolylineOps is a collection of static methods operating on polylines.\r\n * @public\r\n */\r\nexport class PolylineOps {\r\n /**\r\n * Return a Range1d with the shortest and longest edge lengths of the polyline.\r\n * @param points points to examine.\r\n */\r\n public static edgeLengthRange(points: Point3d[]): Range1d {\r\n const range = Range1d.createNull();\r\n for (let i = 1; i < points.length; i++) {\r\n range.extendX(points[i - 1].distance(points[i]));\r\n }\r\n return range;\r\n }\r\n /**\r\n * Return a simplified subset of given points.\r\n * * Points are removed by the Douglas-Puecker algorithm, viz https://en.wikipedia.org/wiki/Ramer–Douglas–Peucker_algorithm\r\n * * This is a global search, with multiple passes over the data.\r\n * @param source input points.\r\n * @param chordTolerance Points less than this distance from a retained edge may be ignored.\r\n * Default is [[Geometry.smallMetricDistance]].\r\n * @param keepSeam whether to preserve the endpoints of physically closed input.\r\n * Default is false, meaning physically closed input points are treated cyclically, allowing removal of the seam.\r\n */\r\n public static compressByChordError(source: Point3d[], chordTolerance: number = Geometry.smallMetricDistance, keepSeam: boolean = false): Point3d[] {\r\n return PolylineCompressionContext.compressPoint3dArrayByChordError(source, chordTolerance, keepSeam);\r\n }\r\n /**\r\n * Return a simplified subset of given points, omitting a point if very close to its predecessor.\r\n * * This is a local search, with a single pass over the data.\r\n * * First and last points are always retained.\r\n * @param source input points\r\n * @param maxEdgeLength length of largest edge to be compressed out\r\n * @see [[GrowableXYZArray.cloneCompressed]]\r\n */\r\n public static compressShortEdges(source: Point3d[] | IndexedXYZCollection, maxEdgeLength: number): Point3d[] {\r\n const dest = GrowableXYZArray.create(source);\r\n PolylineCompressionContext.compressInPlaceByShortEdgeLength(dest, maxEdgeLength);\r\n return dest.getPoint3dArray();\r\n }\r\n /**\r\n * Return a simplified subset of given points, omitting the middle of three successive points if the triangle they form is small.\r\n * * This is a local search, with a single pass over the data.\r\n * @param source input points\r\n * @param maxTriangleArea area of largest triangle to compress\r\n */\r\n public static compressSmallTriangles(source: Point3d[], maxTriangleArea: number): Point3d[] {\r\n const dest = GrowableXYZArray.create(source);\r\n PolylineCompressionContext.compressInPlaceBySmallTriangleArea(dest, maxTriangleArea);\r\n return dest.getPoint3dArray();\r\n }\r\n\r\n /**\r\n * Return a simplified subset of given points, omitting points if close to the edge between neighboring points before and after\r\n * * This is a local search, with a single pass over the data for each pass.\r\n * @param source input points\r\n * @param maxDistance omit points if this close to edge between points before and after\r\n * @param numPass max number of times to run the filter. numPass=2 is observed to behave well.\r\n *\r\n */\r\n public static compressByPerpendicularDistance(source: Point3d[], maxDistance: number, numPass: number = 2): Point3d[] {\r\n const dest = GrowableXYZArray.create(source);\r\n let num0 = dest.length;\r\n for (let pass = 0; pass < numPass; pass++) {\r\n PolylineCompressionContext.compressInPlaceByPerpendicularDistance(dest, maxDistance);\r\n const num1 = dest.length;\r\n if (num1 === num0)\r\n break;\r\n num0 = num1;\r\n }\r\n return dest.getPoint3dArray();\r\n }\r\n private static squaredDistanceToInterpolatedPoint(pointQ: Point3d, point0: Point3d, fraction: number, point1: Point3d): number {\r\n const g = 1.0 - fraction;\r\n const dx = pointQ.x - (g * point0.x + fraction * point1.x);\r\n const dy = pointQ.y - (g * point0.y + fraction * point1.y);\r\n const dz = pointQ.z - (g * point0.z + fraction * point1.z);\r\n return dx * dx + dy * dy + dz * dz;\r\n }\r\n /**\r\n * test if either\r\n * * points[indexA] matches pointQ\r\n * * line from points[indexA] to points[indexB] overlaps points[indexA] to pointQ\r\n * @param points\r\n * @param pointQ\r\n * @param tolerance\r\n */\r\n private static isDanglerConfiguration(points: Point3d[], indexA: number, indexB: number, pointQ: Point3d, squaredDistanceTolerance: number): boolean {\r\n if (indexA < 0 || indexA >= points.length)\r\n return false;\r\n const pointA = points[indexA];\r\n // simple point match ...\r\n const d2Q = pointA.distanceSquared(pointQ);\r\n if (d2Q <= squaredDistanceTolerance)\r\n return true;\r\n if (indexB < 0 || indexB >= points.length)\r\n return false;\r\n const pointB = points[indexB];\r\n // The expensive test .. does newPoint double back to an interior or extrapolation of the final dest segment?\r\n //\r\n // or pointQ\r\n const dot = pointA.dotVectorsToTargets(pointB, pointQ);\r\n // simple case -- pointB..pointA..pointQ continues forward\r\n if (dot <= 0.0)\r\n return false;\r\n const d2B = pointA.distanceSquared(pointB);\r\n let distanceSquared;\r\n if (d2Q >= d2B) {\r\n // pointB----------------------------------->>>>>>> pointA\r\n // pointQ<<<<---------------------------------------------------------\r\n const fraction = dot / d2Q; // safe to divide because of earlier d2Q test.\r\n distanceSquared = this.squaredDistanceToInterpolatedPoint(pointB, pointA, fraction, pointQ);\r\n } else {\r\n // pointB----------------------------------->>>>>>> pointA\r\n // pointQ<<<<----------------------\r\n const fraction = dot / d2B;\r\n distanceSquared = this.squaredDistanceToInterpolatedPoint(pointQ, pointA, fraction, pointB);\r\n }\r\n return distanceSquared < squaredDistanceTolerance;\r\n }\r\n /**\r\n * Return a simplified subset of given points, omitting points on \"danglers\" that depart and return on a single path.\r\n * @param source input points\r\n * @param closed if true, an edge returning to point 0 is implied even if final point does not match.\r\n * @param tolerance tolerance for near-zero distance.\r\n */\r\n public static compressDanglers(source: Point3d[], closed: boolean = false, tolerance: number = Geometry.smallMetricDistance): Point3d[] {\r\n let n = source.length;\r\n const squaredDistanceTolerance = tolerance * tolerance;\r\n if (closed)\r\n while (n > 1 && source[n - 1].distanceSquared(source[0]) <= squaredDistanceTolerance)\r\n n--;\r\n const dest = [];\r\n dest.push(source[0].clone());\r\n for (let i = 1; i < n; i++) {\r\n const newPoint = source[i];\r\n while (this.isDanglerConfiguration(dest, dest.length - 1, dest.length - 2, newPoint, squaredDistanceTolerance))\r\n dest.pop();\r\n dest.push(newPoint.clone());\r\n }\r\n if (closed) {\r\n // No purge moving backwards. Last point\r\n let leftIndex = 0;\r\n let rightIndex = dest.length - 1;\r\n while (rightIndex > leftIndex + 2) {\r\n if (this.isDanglerConfiguration(dest, leftIndex, leftIndex + 1, dest[rightIndex], squaredDistanceTolerance)) {\r\n leftIndex++;\r\n } else if (this.isDanglerConfiguration(dest, rightIndex, rightIndex - 1, dest[leftIndex], squaredDistanceTolerance)) {\r\n rightIndex--;\r\n } else {\r\n break;\r\n }\r\n }\r\n if (rightIndex + 1 < dest.length)\r\n dest.length = rightIndex + 1;\r\n if (leftIndex > 0) {\r\n dest.splice(0, leftIndex);\r\n }\r\n }\r\n return dest;\r\n }\r\n /**\r\n * Add closure points to a polyline or array of polylines\r\n * @param data points.\r\n */\r\n public static addClosurePoint(data: Point3d[] | Point3d[][]) {\r\n if (data.length === 0)\r\n return;\r\n const q0 = data[0];\r\n if (Array.isArray(q0)) {\r\n for (const child of data) {\r\n if (Array.isArray(child))\r\n this.addClosurePoint(child);\r\n }\r\n return;\r\n }\r\n const q1 = data[data.length - 1];\r\n if (q0 instanceof Point3d && q1 instanceof Point3d && !q0.isAlmostEqual(q1)) {\r\n (data as Point3d[]).push(q0.clone());\r\n }\r\n }\r\n /**\r\n * Remove closure points of a polyline or array of polylines\r\n * @param data points.\r\n */\r\n public static removeClosurePoint(data: Point3d[] | Point3d[][]) {\r\n if (data.length === 0)\r\n return;\r\n const q0 = data[0];\r\n if (Array.isArray(q0)) {\r\n for (const child of data) {\r\n if (Array.isArray(child))\r\n this.removeClosurePoint(child);\r\n }\r\n return;\r\n }\r\n const q1 = data[data.length - 1];\r\n if (q0 instanceof Point3d && q1 instanceof Point3d && q0.isAlmostEqual(q1)) {\r\n (data as Point3d[]).pop();\r\n }\r\n }\r\n /**\r\n * Create an array of planes.\r\n * * First plane has origin at first centerline point, with unit normal directed at the next point.\r\n * * Intermediate planes have origin at intermediate points, with unit normals computed from the average of unit vectors\r\n * along the incoming and outgoing segments.\r\n * * Last plane has origin at last centerline point, with unit normal directed from previous point.\r\n * * All sets of adjacent coincident points are reduced to a single point.\r\n * * Hence the output array may have fewer points than the centerline.\r\n * * If there are one or fewer distinct input points, the return is undefined.\r\n * @param centerline points to reside in output planes.\r\n * @param wrapIfPhysicallyClosed if true and the first and last centerline points are the same, then the first and last\r\n * output planes are averaged and equated (cloned). Default false.\r\n */\r\n public static createBisectorPlanesForDistinctPoints(\r\n centerline: IndexedXYZCollection | Point3d[], wrapIfPhysicallyClosed: boolean = false,\r\n ): Plane3dByOriginAndUnitNormal[] | undefined {\r\n const packedPoints = PolylineOps.compressShortEdges(centerline, 2.0 * Geometry.smallMetricDistance); // double the tolerance to ensure normalized vectors exist.\r\n if (packedPoints.length < 2)\r\n return undefined;\r\n const bisectorPlanes: Plane3dByOriginAndUnitNormal[] = [];\r\n const point0 = packedPoints[0];\r\n const point1 = packedPoints[1];\r\n const unit01 = Vector3d.createNormalizedStartEnd(point0, point1)!;\r\n const perpendicular0 = Plane3dByOriginAndUnitNormal.create(point0, unit01)!;\r\n const perpendicular1 = Plane3dByOriginAndUnitNormal.createXYPlane();\r\n // FIRST point gets simple perpendicular\r\n bisectorPlanes.push(perpendicular0.clone());\r\n // Each intermediate point gets average of adjacent perpendiculars\r\n for (let i = 1; i + 1 < packedPoints.length; i++) {\r\n Vector3d.createNormalizedStartEnd(packedPoints[i], packedPoints[i + 1], unit01);\r\n // remark: the prior pack should ensure the normalization is ok. But if it fails, we ignore this point...\r\n if (undefined !== Plane3dByOriginAndUnitNormal.create(packedPoints[i], unit01, perpendicular1)) {\r\n const newBisectorNormal = perpendicular0.getNormalRef().interpolate(0.5, perpendicular1.getNormalRef());\r\n const newBisectorPlane = Plane3dByOriginAndUnitNormal.create(packedPoints[i], newBisectorNormal);\r\n if (undefined !== newBisectorPlane)\r\n bisectorPlanes.push(newBisectorPlane);\r\n perpendicular0.setFrom(perpendicular1);\r\n }\r\n }\r\n // LAST point gets simple perpendicular inherited from last pass\r\n bisectorPlanes.push(Plane3dByOriginAndUnitNormal.create(packedPoints[packedPoints.length - 1], perpendicular0.getNormalRef())!);\r\n // reset end planes to their average plane, but leave them alone if the closure point is a cusp\r\n const lastIndex = bisectorPlanes.length - 1;\r\n if (lastIndex > 0 && wrapIfPhysicallyClosed) {\r\n const firstPlane = bisectorPlanes[0];\r\n const lastPlane = bisectorPlanes[lastIndex];\r\n if (Geometry.isSamePoint3d(firstPlane.getOriginRef(), lastPlane.getOriginRef())) {\r\n const newBisectorNormal = firstPlane.getNormalRef().plus(lastPlane.getNormalRef()); // could be zero vector at a cusp\r\n const newBisectorPlane = Plane3dByOriginAndUnitNormal.create(firstPlane.getOriginRef(), newBisectorNormal);\r\n if (undefined !== newBisectorPlane) {\r\n bisectorPlanes[0] = newBisectorPlane;\r\n bisectorPlanes[lastIndex] = Plane3dByOriginAndUnitNormal.create(lastPlane.getOriginRef(), newBisectorNormal)!;\r\n }\r\n }\r\n }\r\n return bisectorPlanes.length > 1 ? bisectorPlanes : undefined;\r\n }\r\n\r\n private static _workSegmentA?: LineSegment3d;\r\n private static _workSegmentB?: LineSegment3d;\r\n private static _workLocalDetailPair?: CurveLocationDetailPair;\r\n /**\r\n * Find smallest distance between polylines.\r\n * * For polylines with many points, it is more efficient to use [[LineString3dRangeTreeContext.searchForClosestApproach]].\r\n * @param pointsA first polyline\r\n * @param extendA how to extend polylineA forward/backward\r\n * @param pointsB second polyline\r\n * @param extendB how to extend polylineB forward/backward\r\n * @param dMax largest approach distance to consider\r\n * @param result optional pre-allocated object to populate and return\r\n * @returns pair of details, one for each polyline, with field values:\r\n * * `a` is the closest approach distance\r\n * * `point` is the point of closest approach\r\n * * `fraction` is the global polyline fraction\r\n * * `childDetail.a` is the segment index\r\n * * `childDetail.fraction` is the local segment fraction\r\n */\r\n public static closestApproach(\r\n pointsA: Point3d[] | IndexedXYZCollection,\r\n extendA: VariantCurveExtendParameter,\r\n pointsB: Point3d[] | IndexedXYZCollection,\r\n extendB: VariantCurveExtendParameter,\r\n dMax: number = Number.MAX_VALUE,\r\n result?: CurveLocationDetailPair,\r\n ): CurveLocationDetailPair | undefined {\r\n if (Array.isArray(pointsA))\r\n pointsA = new Point3dArrayCarrier(pointsA);\r\n if (Array.isArray(pointsB))\r\n pointsB = new Point3dArrayCarrier(pointsB);\r\n let dMin = dMax;\r\n let foundMin = false;\r\n const numSegmentA = pointsA.length - 1;\r\n const numSegmentB = pointsB.length - 1;\r\n const extendSegA = [CurveExtendMode.None, CurveExtendMode.None];\r\n const extendSegB = [CurveExtendMode.None, CurveExtendMode.None];\r\n // lambda to set extension for first and last segment of a polyline\r\n const convertExtend = (extendOut: CurveExtendMode[], extendIn: VariantCurveExtendParameter, segmentIndex: number, numSegments: number) => {\r\n extendOut[0] = extendOut[1] = CurveExtendMode.None;\r\n if (segmentIndex === 0)\r\n extendOut[0] = CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extendIn, 0);\r\n else if (segmentIndex === numSegments - 1)\r\n extendOut[1] = CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extendIn, 1);\r\n };\r\n // lambda to extract LineSegment3d from polyline\r\n const fillSegment = (points: IndexedXYZCollection, index: number, segment: LineSegment3d | undefined): LineSegment3d => {\r\n if (segment === undefined)\r\n return LineSegment3d.createCapture(points.getPoint3dAtUncheckedPointIndex(index), points.getPoint3dAtUncheckedPointIndex(index + 1));\r\n points.getPoint3dAtUncheckedPointIndex(index, segment.point0Ref);\r\n points.getPoint3dAtUncheckedPointIndex(index + 1, segment.point1Ref);\r\n return segment;\r\n };\r\n // just test the segments\r\n for (let indexA = 0; indexA < numSegmentA; indexA++) {\r\n this._workSegmentA = fillSegment(pointsA, indexA, this._workSegmentA);\r\n convertExtend(extendSegA, extendA, indexA, numSegmentA);\r\n for (let indexB = 0; indexB < numSegmentB; indexB++) {\r\n this._workSegmentB = fillSegment(pointsB, indexB, this._workSegmentB);\r\n convertExtend(extendSegB, extendB, indexB, numSegmentB);\r\n if (undefined !== (this._workLocalDetailPair = LineSegment3d.closestApproach(this._workSegmentA, extendSegA, this._workSegmentB, extendSegB, this._workLocalDetailPair))) {\r\n const d = this._workLocalDetailPair.detailA.a;\r\n if (d < dMin) {\r\n const childDetailA = result?.detailA.childDetail; // save and reuse\r\n const childDetailB = result?.detailB.childDetail;\r\n result = this._workLocalDetailPair.clone(result); // overwrite previous result\r\n LineString3d.convertLocalToGlobalDetail(result.detailA, indexA, numSegmentA, undefined, childDetailA);\r\n LineString3d.convertLocalToGlobalDetail(result.detailB, indexB, numSegmentB, undefined, childDetailB);\r\n if (result.detailA.childDetail && result.detailB.childDetail)\r\n result.detailA.childDetail.curve = result.detailB.childDetail.curve = undefined; // no CurvePrimitives survive in output\r\n dMin = d;\r\n foundMin = true;\r\n }\r\n }\r\n }\r\n }\r\n return foundMin ? result : undefined;\r\n }\r\n /**\r\n * Checks if all points are colinear.\r\n * * This test does not take point order into account.\r\n * @param points array of points to check.\r\n * @param distanceTol tolerance for co-linearity check, default is Geometry.smallMetricDistance.\r\n * @param xyOnly if true, only XY coordinates are used for the check, ignoring z coordinate.\r\n */\r\n public static isColinear(\r\n points: Point3d[], distanceTol: number = Geometry.smallMetricDistance, xyOnly: boolean = false,\r\n ): boolean {\r\n if (points.length < 3)\r\n return true;\r\n return undefined !== CurveOps.isColinear(points, { maxDeviation: distanceTol, xyColinear: xyOnly });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"PolylineOps.js","sourceRoot":"","sources":["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,MAAM,YAAY,GAAG,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC;wBACjD,MAAM,GAAG,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,4BAA4B;wBAC9E,2BAAY,CAAC,0BAA0B,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;wBACtG,2BAAY,CAAC,0BAA0B,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;wBACtG,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW;4BAC1D,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,uCAAuC;wBAC1H,IAAI,GAAG,CAAC,CAAC;wBACT,QAAQ,GAAG,IAAI,CAAC;oBAClB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IACvC,CAAC;IACD;;;;;;OAMG;IACI,MAAM,CAAC,UAAU,CACtB,MAAiB,EAAE,cAAsB,mBAAQ,CAAC,mBAAmB,EAAE,SAAkB,KAAK;QAE9F,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YACnB,OAAO,IAAI,CAAC;QACd,OAAO,SAAS,KAAK,mBAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;IACtG,CAAC;CACF;AA7VD,kCA6VC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { CurveExtendMode, CurveExtendOptions, VariantCurveExtendParameter } from \"../curve/CurveExtendMode\";\r\nimport { CurveLocationDetailPair } from \"../curve/CurveLocationDetail\";\r\nimport { CurveOps } from \"../curve/CurveOps\";\r\nimport { LineSegment3d } from \"../curve/LineSegment3d\";\r\nimport { LineString3d } from \"../curve/LineString3d\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GrowableXYZArray } from \"./GrowableXYZArray\";\r\nimport { IndexedXYZCollection } from \"./IndexedXYZCollection\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"./Plane3dByOriginAndUnitNormal\";\r\nimport { Point3dArrayCarrier } from \"./Point3dArrayCarrier\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { PolylineCompressionContext } from \"./PolylineCompressionByEdgeOffset\";\r\nimport { Range1d } from \"./Range\";\r\n\r\n// cspell:word Puecker\r\n/**\r\n * PolylineOps is a collection of static methods operating on polylines.\r\n * @public\r\n */\r\nexport class PolylineOps {\r\n /**\r\n * Return a Range1d with the shortest and longest edge lengths of the polyline.\r\n * @param points points to examine.\r\n */\r\n public static edgeLengthRange(points: Point3d[]): Range1d {\r\n const range = Range1d.createNull();\r\n for (let i = 1; i < points.length; i++) {\r\n range.extendX(points[i - 1].distance(points[i]));\r\n }\r\n return range;\r\n }\r\n /**\r\n * Return a simplified subset of given points.\r\n * * Points are removed by the Douglas-Puecker algorithm, viz https://en.wikipedia.org/wiki/Ramer–Douglas–Peucker_algorithm\r\n * * This is a global search, with multiple passes over the data.\r\n * @param source input points.\r\n * @param chordTolerance Points less than this distance from a retained edge may be ignored.\r\n * Default is [[Geometry.smallMetricDistance]].\r\n * @param keepSeam whether to preserve the endpoints of physically closed input.\r\n * Default is false, meaning physically closed input points are treated cyclically, allowing removal of the seam.\r\n */\r\n public static compressByChordError(source: Point3d[], chordTolerance: number = Geometry.smallMetricDistance, keepSeam: boolean = false): Point3d[] {\r\n return PolylineCompressionContext.compressPoint3dArrayByChordError(source, chordTolerance, keepSeam);\r\n }\r\n /**\r\n * Return a simplified subset of given points, omitting a point if very close to its predecessor.\r\n * * This is a local search, with a single pass over the data.\r\n * * First and last points are always retained.\r\n * @param source input points\r\n * @param maxEdgeLength length of largest edge to be compressed out\r\n * @see [[GrowableXYZArray.cloneCompressed]]\r\n */\r\n public static compressShortEdges(source: Point3d[] | IndexedXYZCollection, maxEdgeLength: number): Point3d[] {\r\n const dest = GrowableXYZArray.create(source);\r\n PolylineCompressionContext.compressInPlaceByShortEdgeLength(dest, maxEdgeLength);\r\n return dest.getPoint3dArray();\r\n }\r\n /**\r\n * Return a simplified subset of given points, omitting the middle of three successive points if the triangle they form is small.\r\n * * This is a local search, with a single pass over the data.\r\n * @param source input points\r\n * @param maxTriangleArea area of largest triangle to compress\r\n */\r\n public static compressSmallTriangles(source: Point3d[], maxTriangleArea: number): Point3d[] {\r\n const dest = GrowableXYZArray.create(source);\r\n PolylineCompressionContext.compressInPlaceBySmallTriangleArea(dest, maxTriangleArea);\r\n return dest.getPoint3dArray();\r\n }\r\n\r\n /**\r\n * Return a simplified subset of given points, omitting points if close to the edge between neighboring points before and after\r\n * * This is a local search, with a single pass over the data for each pass.\r\n * @param source input points\r\n * @param maxDistance omit points if this close to edge between points before and after\r\n * @param numPass max number of times to run the filter. numPass=2 is observed to behave well.\r\n *\r\n */\r\n public static compressByPerpendicularDistance(source: Point3d[], maxDistance: number, numPass: number = 2): Point3d[] {\r\n const dest = GrowableXYZArray.create(source);\r\n let num0 = dest.length;\r\n for (let pass = 0; pass < numPass; pass++) {\r\n PolylineCompressionContext.compressInPlaceByPerpendicularDistance(dest, maxDistance);\r\n const num1 = dest.length;\r\n if (num1 === num0)\r\n break;\r\n num0 = num1;\r\n }\r\n return dest.getPoint3dArray();\r\n }\r\n private static squaredDistanceToInterpolatedPoint(pointQ: Point3d, point0: Point3d, fraction: number, point1: Point3d): number {\r\n const g = 1.0 - fraction;\r\n const dx = pointQ.x - (g * point0.x + fraction * point1.x);\r\n const dy = pointQ.y - (g * point0.y + fraction * point1.y);\r\n const dz = pointQ.z - (g * point0.z + fraction * point1.z);\r\n return dx * dx + dy * dy + dz * dz;\r\n }\r\n /**\r\n * test if either\r\n * * points[indexA] matches pointQ\r\n * * line from points[indexA] to points[indexB] overlaps points[indexA] to pointQ\r\n * @param points\r\n * @param pointQ\r\n * @param tolerance\r\n */\r\n private static isDanglerConfiguration(points: Point3d[], indexA: number, indexB: number, pointQ: Point3d, squaredDistanceTolerance: number): boolean {\r\n if (indexA < 0 || indexA >= points.length)\r\n return false;\r\n const pointA = points[indexA];\r\n // simple point match ...\r\n const d2Q = pointA.distanceSquared(pointQ);\r\n if (d2Q <= squaredDistanceTolerance)\r\n return true;\r\n if (indexB < 0 || indexB >= points.length)\r\n return false;\r\n const pointB = points[indexB];\r\n // The expensive test .. does newPoint double back to an interior or extrapolation of the final dest segment?\r\n //\r\n // or pointQ\r\n const dot = pointA.dotVectorsToTargets(pointB, pointQ);\r\n // simple case -- pointB..pointA..pointQ continues forward\r\n if (dot <= 0.0)\r\n return false;\r\n const d2B = pointA.distanceSquared(pointB);\r\n let distanceSquared;\r\n if (d2Q >= d2B) {\r\n // pointB----------------------------------->>>>>>> pointA\r\n // pointQ<<<<---------------------------------------------------------\r\n const fraction = dot / d2Q; // safe to divide because of earlier d2Q test.\r\n distanceSquared = this.squaredDistanceToInterpolatedPoint(pointB, pointA, fraction, pointQ);\r\n } else {\r\n // pointB----------------------------------->>>>>>> pointA\r\n // pointQ<<<<----------------------\r\n const fraction = dot / d2B;\r\n distanceSquared = this.squaredDistanceToInterpolatedPoint(pointQ, pointA, fraction, pointB);\r\n }\r\n return distanceSquared < squaredDistanceTolerance;\r\n }\r\n /**\r\n * Return a simplified subset of given points, omitting points on \"danglers\" that depart and return on a single path.\r\n * @param source input points\r\n * @param closed if true, an edge returning to point 0 is implied even if final point does not match.\r\n * @param tolerance tolerance for near-zero distance.\r\n */\r\n public static compressDanglers(source: Point3d[], closed: boolean = false, tolerance: number = Geometry.smallMetricDistance): Point3d[] {\r\n let n = source.length;\r\n const squaredDistanceTolerance = tolerance * tolerance;\r\n if (closed)\r\n while (n > 1 && source[n - 1].distanceSquared(source[0]) <= squaredDistanceTolerance)\r\n n--;\r\n const dest = [];\r\n dest.push(source[0].clone());\r\n for (let i = 1; i < n; i++) {\r\n const newPoint = source[i];\r\n while (this.isDanglerConfiguration(dest, dest.length - 1, dest.length - 2, newPoint, squaredDistanceTolerance))\r\n dest.pop();\r\n dest.push(newPoint.clone());\r\n }\r\n if (closed) {\r\n // No purge moving backwards. Last point\r\n let leftIndex = 0;\r\n let rightIndex = dest.length - 1;\r\n while (rightIndex > leftIndex + 2) {\r\n if (this.isDanglerConfiguration(dest, leftIndex, leftIndex + 1, dest[rightIndex], squaredDistanceTolerance)) {\r\n leftIndex++;\r\n } else if (this.isDanglerConfiguration(dest, rightIndex, rightIndex - 1, dest[leftIndex], squaredDistanceTolerance)) {\r\n rightIndex--;\r\n } else {\r\n break;\r\n }\r\n }\r\n if (rightIndex + 1 < dest.length)\r\n dest.length = rightIndex + 1;\r\n if (leftIndex > 0) {\r\n dest.splice(0, leftIndex);\r\n }\r\n }\r\n return dest;\r\n }\r\n /**\r\n * Add closure points to a polyline or array of polylines\r\n * @param data points.\r\n */\r\n public static addClosurePoint(data: Point3d[] | Point3d[][]) {\r\n if (data.length === 0)\r\n return;\r\n const q0 = data[0];\r\n if (Array.isArray(q0)) {\r\n for (const child of data) {\r\n if (Array.isArray(child))\r\n this.addClosurePoint(child);\r\n }\r\n return;\r\n }\r\n const q1 = data[data.length - 1];\r\n if (q0 instanceof Point3d && q1 instanceof Point3d && !q0.isAlmostEqual(q1)) {\r\n (data as Point3d[]).push(q0.clone());\r\n }\r\n }\r\n /**\r\n * Remove closure points of a polyline or array of polylines\r\n * @param data points.\r\n */\r\n public static removeClosurePoint(data: Point3d[] | Point3d[][]) {\r\n if (data.length === 0)\r\n return;\r\n const q0 = data[0];\r\n if (Array.isArray(q0)) {\r\n for (const child of data) {\r\n if (Array.isArray(child))\r\n this.removeClosurePoint(child);\r\n }\r\n return;\r\n }\r\n const q1 = data[data.length - 1];\r\n if (q0 instanceof Point3d && q1 instanceof Point3d && q0.isAlmostEqual(q1)) {\r\n (data as Point3d[]).pop();\r\n }\r\n }\r\n /**\r\n * Create an array of planes.\r\n * * First plane has origin at first centerline point, with unit normal directed at the next point.\r\n * * Intermediate planes have origin at intermediate points, with unit normals computed from the average of unit vectors\r\n * along the incoming and outgoing segments.\r\n * * Last plane has origin at last centerline point, with unit normal directed from previous point.\r\n * * All sets of adjacent coincident points are reduced to a single point.\r\n * * Hence the output array may have fewer points than the centerline.\r\n * * If there are one or fewer distinct input points, the return is undefined.\r\n * @param centerline points to reside in output planes.\r\n * @param wrapIfPhysicallyClosed if true and the first and last centerline points are the same, then the first and last\r\n * output planes are averaged and equated (cloned). Default false.\r\n */\r\n public static createBisectorPlanesForDistinctPoints(\r\n centerline: IndexedXYZCollection | Point3d[], wrapIfPhysicallyClosed: boolean = false,\r\n ): Plane3dByOriginAndUnitNormal[] | undefined {\r\n const packedPoints = PolylineOps.compressShortEdges(centerline, 2.0 * Geometry.smallMetricDistance); // double the tolerance to ensure normalized vectors exist.\r\n if (packedPoints.length < 2)\r\n return undefined;\r\n const bisectorPlanes: Plane3dByOriginAndUnitNormal[] = [];\r\n const point0 = packedPoints[0];\r\n const point1 = packedPoints[1];\r\n const unit01 = Vector3d.createNormalizedStartEnd(point0, point1)!;\r\n const perpendicular0 = Plane3dByOriginAndUnitNormal.create(point0, unit01)!;\r\n const perpendicular1 = Plane3dByOriginAndUnitNormal.createXYPlane();\r\n // FIRST point gets simple perpendicular\r\n bisectorPlanes.push(perpendicular0.clone());\r\n // Each intermediate point gets average of adjacent perpendiculars\r\n for (let i = 1; i + 1 < packedPoints.length; i++) {\r\n Vector3d.createNormalizedStartEnd(packedPoints[i], packedPoints[i + 1], unit01);\r\n // remark: the prior pack should ensure the normalization is ok. But if it fails, we ignore this point...\r\n if (undefined !== Plane3dByOriginAndUnitNormal.create(packedPoints[i], unit01, perpendicular1)) {\r\n const newBisectorNormal = perpendicular0.getNormalRef().interpolate(0.5, perpendicular1.getNormalRef());\r\n const newBisectorPlane = Plane3dByOriginAndUnitNormal.create(packedPoints[i], newBisectorNormal);\r\n if (undefined !== newBisectorPlane)\r\n bisectorPlanes.push(newBisectorPlane);\r\n perpendicular0.setFrom(perpendicular1);\r\n }\r\n }\r\n // LAST point gets simple perpendicular inherited from last pass\r\n bisectorPlanes.push(Plane3dByOriginAndUnitNormal.create(packedPoints[packedPoints.length - 1], perpendicular0.getNormalRef())!);\r\n // reset end planes to their average plane, but leave them alone if the closure point is a cusp\r\n const lastIndex = bisectorPlanes.length - 1;\r\n if (lastIndex > 0 && wrapIfPhysicallyClosed) {\r\n const firstPlane = bisectorPlanes[0];\r\n const lastPlane = bisectorPlanes[lastIndex];\r\n if (Geometry.isSamePoint3d(firstPlane.getOriginRef(), lastPlane.getOriginRef())) {\r\n const newBisectorNormal = firstPlane.getNormalRef().plus(lastPlane.getNormalRef()); // could be zero vector at a cusp\r\n const newBisectorPlane = Plane3dByOriginAndUnitNormal.create(firstPlane.getOriginRef(), newBisectorNormal);\r\n if (undefined !== newBisectorPlane) {\r\n bisectorPlanes[0] = newBisectorPlane;\r\n bisectorPlanes[lastIndex] = Plane3dByOriginAndUnitNormal.create(lastPlane.getOriginRef(), newBisectorNormal)!;\r\n }\r\n }\r\n }\r\n return bisectorPlanes.length > 1 ? bisectorPlanes : undefined;\r\n }\r\n\r\n private static _workSegmentA?: LineSegment3d;\r\n private static _workSegmentB?: LineSegment3d;\r\n private static _workLocalDetailPair?: CurveLocationDetailPair;\r\n /**\r\n * Find smallest distance between polylines.\r\n * * For polylines with many points, it is more efficient to use [[LineString3dRangeTreeContext.searchForClosestApproach]].\r\n * @param pointsA first polyline\r\n * @param extendA how to extend polylineA forward/backward\r\n * @param pointsB second polyline\r\n * @param extendB how to extend polylineB forward/backward\r\n * @param dMax largest approach distance to consider\r\n * @param result optional pre-allocated object to populate and return\r\n * @returns pair of details, one for each polyline, with field values:\r\n * * `a` is the closest approach distance\r\n * * `point` is the point of closest approach\r\n * * `fraction` is the global polyline fraction\r\n * * `childDetail.a` is the segment index\r\n * * `childDetail.fraction` is the local segment fraction\r\n */\r\n public static closestApproach(\r\n pointsA: Point3d[] | IndexedXYZCollection,\r\n extendA: VariantCurveExtendParameter,\r\n pointsB: Point3d[] | IndexedXYZCollection,\r\n extendB: VariantCurveExtendParameter,\r\n dMax: number = Number.MAX_VALUE,\r\n result?: CurveLocationDetailPair,\r\n ): CurveLocationDetailPair | undefined {\r\n if (Array.isArray(pointsA))\r\n pointsA = new Point3dArrayCarrier(pointsA);\r\n if (Array.isArray(pointsB))\r\n pointsB = new Point3dArrayCarrier(pointsB);\r\n let dMin = dMax;\r\n let foundMin = false;\r\n const numSegmentA = pointsA.length - 1;\r\n const numSegmentB = pointsB.length - 1;\r\n const extendSegA = [CurveExtendMode.None, CurveExtendMode.None];\r\n const extendSegB = [CurveExtendMode.None, CurveExtendMode.None];\r\n // lambda to set extension for first and last segment of a polyline\r\n const convertExtend = (extendOut: CurveExtendMode[], extendIn: VariantCurveExtendParameter, segmentIndex: number, numSegments: number) => {\r\n extendOut[0] = extendOut[1] = CurveExtendMode.None;\r\n if (segmentIndex === 0)\r\n extendOut[0] = CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extendIn, 0);\r\n else if (segmentIndex === numSegments - 1)\r\n extendOut[1] = CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extendIn, 1);\r\n };\r\n // lambda to extract LineSegment3d from polyline\r\n const fillSegment = (points: IndexedXYZCollection, index: number, segment: LineSegment3d | undefined): LineSegment3d => {\r\n if (segment === undefined)\r\n return LineSegment3d.createCapture(points.getPoint3dAtUncheckedPointIndex(index), points.getPoint3dAtUncheckedPointIndex(index + 1));\r\n points.getPoint3dAtUncheckedPointIndex(index, segment.point0Ref);\r\n points.getPoint3dAtUncheckedPointIndex(index + 1, segment.point1Ref);\r\n return segment;\r\n };\r\n // just test the segments\r\n for (let indexA = 0; indexA < numSegmentA; indexA++) {\r\n this._workSegmentA = fillSegment(pointsA, indexA, this._workSegmentA);\r\n convertExtend(extendSegA, extendA, indexA, numSegmentA);\r\n for (let indexB = 0; indexB < numSegmentB; indexB++) {\r\n this._workSegmentB = fillSegment(pointsB, indexB, this._workSegmentB);\r\n convertExtend(extendSegB, extendB, indexB, numSegmentB);\r\n if (undefined !== (this._workLocalDetailPair = LineSegment3d.closestApproach(this._workSegmentA, extendSegA, this._workSegmentB, extendSegB, this._workLocalDetailPair))) {\r\n const d = this._workLocalDetailPair.detailA.a;\r\n if (d < dMin) {\r\n const childDetailA = result?.detailA.childDetail; // save and reuse\r\n const childDetailB = result?.detailB.childDetail;\r\n result = this._workLocalDetailPair.clone(result); // overwrite previous result\r\n LineString3d.convertLocalToGlobalDetail(result.detailA, indexA, numSegmentA, undefined, childDetailA);\r\n LineString3d.convertLocalToGlobalDetail(result.detailB, indexB, numSegmentB, undefined, childDetailB);\r\n if (result.detailA.childDetail && result.detailB.childDetail)\r\n result.detailA.childDetail.curve = result.detailB.childDetail.curve = undefined; // no CurvePrimitives survive in output\r\n dMin = d;\r\n foundMin = true;\r\n }\r\n }\r\n }\r\n }\r\n return foundMin ? result : undefined;\r\n }\r\n /**\r\n * Checks if all points are colinear.\r\n * * This test does not take point order into account.\r\n * @param points array of points to check.\r\n * @param distanceTol maximum allowable distance that geometry can deviate from colinearity.Default is [[Geometry.smallMetricDistance]].\r\n * @param xyOnly whether to ignore z-coordinates in the colinearity test.\r\n */\r\n public static isColinear(\r\n points: Point3d[], distanceTol: number = Geometry.smallMetricDistance, xyOnly: boolean = false,\r\n ): boolean {\r\n if (points.length < 3)\r\n return true;\r\n return undefined !== CurveOps.isColinear(points, { maxDeviation: distanceTol, xyColinear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ockIndex === ClusterableArray.clusterTerminator)
166
166
  continue; // nearby in sort direction but already in a cluster.
167
- if (this.component(candidateBlockIndex, 0) >= barrierU)
167
+ if (this.component(candidateBlockIndex, 0) > barrierU)
168
168
  break;
169
- if (this.distanceBetweenSubBlocks(clusterStartBlockIndex, candidateBlockIndex, k0, k1) < clusterTolerance) {
169
+ if (this.distanceBetweenSubBlocks(clusterStartBlockIndex, candidateBlockIndex, k0, k1) <= clusterTolerance) {
170
170
  clusterIndices[m++] = candidateBlockIndex; // The candidate is in the block
171
171
  firstSort[j] = ClusterableArray.clusterTerminator; // and it will not be reused as future block base
172
172
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ClusterableArray.js","sourceRoot":"","sources":["../../../src/numerics/ClusterableArray.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AACvC,6EAA0E;AAC1E,mEAAgE;AAChE,qEAAkE;AAClE,mEAAwD;AACxD,mEAAwD;AAExD;;;;GAIG;AACH,MAAa,gBAAiB,SAAQ,2CAAoB;IACxD,4BAA4B;IAC5B,qCAAqC;IACrC,kFAAkF;IAClF,6HAA6H;IACrH,MAAM,CAAU,aAAa,GAAG,MAAM,CAAC,CAAE,6BAA6B;IAC9E,6CAA6C;IACtC,MAAM,CAAC,mBAAmB,CAAC,KAAa;QAC7C,IAAI,CAAC,GAAG,GAAG,CAAC;QACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE;YAAE,CAAC,IAAI,gBAAgB,CAAC,aAAa,CAAC;QACpE,OAAO,CAAC,CAAC;IACX,CAAC;IACO,sBAAsB,CAAS;IAC/B,qBAAqB,CAAS;IACtC;;;;OAIG;IACH,YAAmB,qBAA6B,EAAE,oBAA4B,EAAE,oBAA4B;QAC1G,KAAK,CAAC,CAAC,GAAG,qBAAqB,GAAG,oBAAoB,EAAE,oBAAoB,CAAC,CAAC;QAC9E,IAAI,CAAC,qBAA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B,uCAAuC;IAChC,MAAM,CAAU,YAAY,GAAG,UAAU,CAAC;IAEjD;;;OAGG;IACH,YAAY,gBAAwB,EAAE,eAAuB;QAC3D,IAAI,CAAC,oBAAoB,GAAG,IAAI,iCAAe,CAAC,eAAe,CAAC,CAAC;QACjE,IAAI,CAAC,QAAQ,GAAG,IAAI,WAAW,CAAC,gBAAgB,CAAC,CAAC;QAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,uBAAuB,CAAC,YAAY,CAAC;QAC1D,CAAC;IACH,CAAC;IACD;;;;OAIG;IACI,aAAa,CAAC,OAAiB;QACpC,OAAO,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;;AAGH;;GAEG;AACF,MAAM,sBAAsB;IAC3B,uBAAuB;IAChB,aAAa,CAAW;IAC/B,uDAAuD;IAChD,QAAQ,CAAc;IAC7B,uCAAuC;IAChC,MAAM,CAAU,YAAY,GAAG,UAAU,CAAC;IAEjD;;;OAGG;IACH,YAAY,gBAAwB;QAClC,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,IAAI,WAAW,CAAC,gBAAgB,CAAC,CAAC;QAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,qBAAqB,CAAC,YAAY,CAAC;QACxD,CAAC;IACH,CAAC;IACD;;;;OAIG;IACI,aAAa,CAAC,OAAiB;QACpC,OAAO,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC","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 Numerics\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GrowableBlockedArray } from \"../geometry3d/GrowableBlockedArray\";\r\nimport { GrowableXYArray } from \"../geometry3d/GrowableXYArray\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { Point2d } from \"../geometry3d/Point2dVector2d\";\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\n\r\n/**\r\n * Blocked array with operations to sort and cluster with a tolerance.\r\n * * Primary sorting is along an \"arbitrary\" sort vector.\r\n * @internal\r\n */\r\nexport class ClusterableArray extends GrowableBlockedArray {\r\n // (This is pretty strange)\r\n // The sort vector is (1,c, c*c, ...)\r\n // Setting c = 1 makes it 1,1,1 which may be useful for visual scans during debug.\r\n // c with some non-obvious digits makes it unlikely that there will be multiple points on a perpendicular to the sort vector.\r\n private static readonly _vectorFactor = 0.8732; // use 1.0 to rig easy tests.\r\n /** Return a component of the sort vector. */\r\n public static sortVectorComponent(index: number): number {\r\n let c = 1.0;\r\n for (let i = 1; i < index; i++) c *= ClusterableArray._vectorFactor;\r\n return c;\r\n }\r\n private _numCoordinatePerPoint: number;\r\n private _numExtraDataPerPoint: number;\r\n /**\r\n * @param numCoordinatePerPoint number of coordinates per point\r\n * @param numExtraDataPerPoint of extra data values per point.\r\n * @param initialBlockCapacity predicted number of points. (This does not have to be accurate)\r\n */\r\n public constructor(numCoordinatePerPoint: number, numExtraDataPerPoint: number, initialBlockCapacity: number) {\r\n super(1 + numCoordinatePerPoint + numExtraDataPerPoint, initialBlockCapacity);\r\n this._numExtraDataPerPoint = numExtraDataPerPoint;\r\n this._numCoordinatePerPoint = numCoordinatePerPoint;\r\n }\r\n /** load a block, placing data[i] at block[i+1] to allow sort coordinate first.\r\n * @param data array of numDataPerBlock values.\r\n */\r\n public override addBlock(data: number[]) {\r\n const i0 = this.newBlockIndex() + 1;\r\n const n = Math.min(this.numPerBlock - 1, data.length);\r\n for (let i = 0; i < n; i++)\r\n this._data[i0 + i] = data[i];\r\n }\r\n /** add a block directly with 1 to 5 listed content parameters.\r\n * This assumes numDataPerPoint is sufficient for the parameters provided.\r\n */\r\n public addDirect(x0: number, x1?: number, x2?: number, x3?: number, x4?: number) {\r\n const i0 = this.newBlockIndex();\r\n this._data[i0 + 1] = x0;\r\n if (x1 !== undefined) this._data[i0 + 2] = x1;\r\n if (x2 !== undefined) this._data[i0 + 3] = x2;\r\n if (x3 !== undefined) this._data[i0 + 4] = x3;\r\n if (x4 !== undefined) this._data[i0 + 5] = x4;\r\n }\r\n\r\n /** add a block directly from a Point2d with 0 to 3 extras\r\n * This assumes numDataPerPoint is sufficient for the parameters provided.\r\n */\r\n public addPoint2d(xy: Point2d, a?: number, b?: number, c?: number) {\r\n const i0 = this.newBlockIndex();\r\n this._data[i0 + 1] = xy.x;\r\n this._data[i0 + 2] = xy.y;\r\n if (a !== undefined)\r\n this._data[i0 + 3] = a;\r\n if (b !== undefined)\r\n this._data[i0 + 4] = b;\r\n if (c !== undefined)\r\n this._data[i0 + 5] = c;\r\n }\r\n\r\n /** add a block with directly from a Point2d with 0 to 3 extras\r\n * This assumes numDataPerPoint is sufficient for the parameters provided.\r\n */\r\n public addPoint3d(xyz: Point3d, a?: number, b?: number, c?: number) {\r\n const i0 = this.newBlockIndex();\r\n this._data[i0 + 1] = xyz.x;\r\n this._data[i0 + 2] = xyz.y;\r\n this._data[i0 + 3] = xyz.z;\r\n if (a !== undefined)\r\n this._data[i0 + 4] = a;\r\n if (b !== undefined)\r\n this._data[i0 + 5] = b;\r\n if (c !== undefined)\r\n this._data[i0 + 6] = c;\r\n }\r\n /** Get the xy coordinates by point index. */\r\n public getPoint2d(blockIndex: number, result?: Point2d): Point2d {\r\n const i0 = this.blockIndexToDoubleIndex(blockIndex);\r\n return Point2d.create(this._data[i0 + 1], this._data[i0 + 2], result);\r\n }\r\n /** Get the xyZ coordinates by point index. */\r\n public getPoint3d(blockIndex: number, result?: Point3d): Point3d {\r\n const i0 = this.blockIndexToDoubleIndex(blockIndex);\r\n return Point3d.create(this._data[i0 + 1], this._data[i0 + 2], this._data[i0 + 3], result);\r\n }\r\n /** Return a single extra data value */\r\n public getExtraData(blockIndex: number, i: number): number {\r\n const i0 = this.blockIndexToDoubleIndex(blockIndex);\r\n return this._data[i0 + 1 + this._numCoordinatePerPoint + i];\r\n }\r\n /** Return a single data value */\r\n public getData(blockIndex: number, i: number): number {\r\n const i0 = this.blockIndexToDoubleIndex(blockIndex);\r\n return this._data[i0 + i];\r\n }\r\n\r\n /** Set a single extra data value */\r\n public setExtraData(blockIndex: number, i: number, value: number): void {\r\n const i0 = this.blockIndexToDoubleIndex(blockIndex);\r\n this._data[i0 + 1 + this._numCoordinatePerPoint + i] = value;\r\n }\r\n\r\n /** this value is used as cluster terminator in the Uint232Array of indices. */\r\n public static readonly clusterTerminator = 0xFFffFFff;\r\n /** Test if `x` is the cluster terminator value. */\r\n public static isClusterTerminator(x: number): boolean { return x === ClusterableArray.clusterTerminator; }\r\n /** Return an array giving clusters of blocks with similar coordinates.\r\n *\r\n * * The contents of each block is assumed to be set up so the primary sort coordinate is first.\r\n *\r\n * ** simple coordinate blocks (x,y) or (x,y,z) would work fine but have occasional performance problems because points with same x would generate big blocks of\r\n * candidates for clusters.\r\n * ** The usual solution is to sort by u value, which is a dot product along some skew direction, and have the blocks contain (u,x,y) or (u,x,y,z) for 2d versus 3d.\r\n * ** apply setupPrimaryClusterSort to prepare that!!!\r\n * * After a simple lexical sort, consecutive blocks that are within tolerance in the 0 component\r\n * are inspected. Within that candidate set, all blocks that are within tolerance for ALL components are clustered.\r\n * * In the output cluster array, clusters are terminated a invalid index. Test for the invalid index with GrowableBlockArray.isClusterTerminator (x)\r\n */\r\n public clusterIndicesLexical(clusterTolerance: number = Geometry.smallMetricDistance): Uint32Array {\r\n // install primary sort key\r\n this.setupPrimaryClusterSort();\r\n // presort by all coordinates ....\r\n const firstSort = this.sortIndicesLexical();\r\n const clusterIndices = new Uint32Array(2 * firstSort.length); // worst case: no duplicates, each index goes in followed by terminator.\r\n let m = 0; // number of cluster indices\r\n const n = this.numBlocks; // and this must match firstSort.length !!\r\n let clusterStartBlockIndex = 0;\r\n let candidateBlockIndex = 0;\r\n let barrierU = 0.0;\r\n let i = 0;\r\n let j = 0;\r\n\r\n const k0 = 1; // beginning of active column for distance\r\n const k1 = 1 + this._numCoordinatePerPoint;\r\n for (i = 0; i < n; i++) {\r\n clusterStartBlockIndex = firstSort[i];\r\n if (!ClusterableArray.isClusterTerminator(clusterStartBlockIndex)) {\r\n // unused block, so it becomes a cluster...\r\n clusterIndices[m++] = clusterStartBlockIndex;\r\n barrierU = this.component(clusterStartBlockIndex, 0) + clusterTolerance;\r\n firstSort[i] = ClusterableArray.clusterTerminator;\r\n for (j = i + 1; j < n; j++) {\r\n candidateBlockIndex = firstSort[j];\r\n if (candidateBlockIndex === ClusterableArray.clusterTerminator) continue; // nearby in sort direction but already in a cluster.\r\n if (this.component(candidateBlockIndex, 0) >= barrierU) break;\r\n if (this.distanceBetweenSubBlocks(clusterStartBlockIndex, candidateBlockIndex, k0, k1) < clusterTolerance) {\r\n clusterIndices[m++] = candidateBlockIndex; // The candidate is in the block\r\n firstSort[j] = ClusterableArray.clusterTerminator; // and it will not be reused as future block base\r\n }\r\n }\r\n clusterIndices[m++] = ClusterableArray.clusterTerminator;\r\n }\r\n }\r\n // Alas, the clusterIndices array has fluff at the end. So it has to be copied.\r\n return clusterIndices.slice(0, m);\r\n }\r\n /** setup (overwrite!!) the \"0\" component with the dot product of numClusterCoordinate later components with a non-axis aligned vector.\r\n * This is normally called before clusterIndicesLexical.\r\n */\r\n public setupPrimaryClusterSort() {\r\n const nb = this.numBlocks;\r\n const nc = this._numCoordinatePerPoint;\r\n const vector = new Float64Array(nc);\r\n vector[0] = 1.0;\r\n for (let c = 1; c < nc; c++) vector[c] = vector[c - 1] * ClusterableArray._vectorFactor;\r\n let k = 0;\r\n let dot = 0.0;\r\n const data = this._data;\r\n for (let b = 0; b < nb; b++) {\r\n k = this.blockIndexToDoubleIndex(b);\r\n dot = 0.0;\r\n for (let c = 0; c < nc; c++) { dot += vector[c] * data[k + 1 + c]; }\r\n data[k] = dot;\r\n }\r\n }\r\n /** Convert the cluster data to an array of tuples with point i in the form\r\n * `[i, primarySortCoordinate, [x,y,..], [extraData0, extraData1, ...]]`\r\n */\r\n public toJSON(): any[] {\r\n const result: any[] = [];\r\n for (let b = 0; b < this.numBlocks; b++) {\r\n let i = this.blockIndexToDoubleIndex(b);\r\n const chunk: any[] = [b, this._data[i++]];\r\n const coordinates = [];\r\n for (let c = 0; c < this._numCoordinatePerPoint; c++)coordinates.push(this._data[i++]);\r\n chunk.push(coordinates);\r\n for (let c = 0; c < this._numExtraDataPerPoint; c++)\r\n chunk.push(this._data[i++]);\r\n result.push(chunk);\r\n }\r\n return result;\r\n }\r\n /**\r\n * Return an array of indices from block index to cluster index.\r\n * @param clusteredBlocks clusters of block indices followed by separators.\r\n */\r\n public createIndexBlockToClusterIndex(clusteredBlocks: Uint32Array): Uint32Array {\r\n const numBlocks = this.numBlocks;\r\n const blockToCluster = new Uint32Array(numBlocks);\r\n blockToCluster.fill(ClusterableArray.clusterTerminator);\r\n let numCluster = 0;\r\n for (const b of clusteredBlocks) {\r\n if (b >= numBlocks) {\r\n numCluster++;\r\n } else {\r\n blockToCluster[b] = numCluster;\r\n }\r\n }\r\n return blockToCluster;\r\n }\r\n /**\r\n * Return an array of indices from block index to index of its cluster's start in the cluster index array.\r\n * @param clusteredBlocks clusters of block indices followed by separators.\r\n */\r\n public createIndexBlockToClusterStart(clusteredBlocks: Uint32Array): Uint32Array {\r\n const n = clusteredBlocks.length;\r\n const numBlocks = this.numBlocks;\r\n const blockToClusterStart = new Uint32Array(numBlocks);\r\n const terminator = ClusterableArray.clusterTerminator;\r\n blockToClusterStart.fill(terminator);\r\n let clusterStart = 0;\r\n for (let i = 0; i < n; i++) {\r\n const k = clusteredBlocks[i];\r\n if (k > numBlocks) {\r\n clusterStart = i + 1;\r\n } else {\r\n blockToClusterStart[k] = clusterStart;\r\n }\r\n }\r\n return blockToClusterStart;\r\n }\r\n /** count the clusters in the clusteredBlocks array. */\r\n public countClusters(clusteredBlocks: Uint32Array): number {\r\n let numClusters = 0;\r\n const terminator = ClusterableArray.clusterTerminator;\r\n for (const b of clusteredBlocks) {\r\n if (b === terminator)\r\n numClusters++;\r\n }\r\n return numClusters;\r\n }\r\n /** create a reverse index: given a cluster index k, clusterToClusterStart[k] is the place\r\n * the cluster's block indices appear in clusterBlocks\r\n */\r\n public createIndexClusterToClusterStart(clusteredBlocks: Uint32Array): Uint32Array {\r\n let numCluster = this.countClusters(clusteredBlocks);\r\n const clusterToClusterStart = new Uint32Array(numCluster);\r\n const terminator = ClusterableArray.clusterTerminator;\r\n clusterToClusterStart.fill(terminator);\r\n const n = clusteredBlocks.length;\r\n let clusterStart = 0;\r\n for (let i = 0; i < n; i++) {\r\n const k = clusteredBlocks[i];\r\n if (k === terminator) {\r\n clusterStart = i + 1;\r\n } else if (i === clusterStart) {\r\n clusterToClusterStart[numCluster++] = clusterStart;\r\n }\r\n }\r\n return clusterToClusterStart;\r\n }\r\n\r\n /**\r\n * Sort terminator-delimited subsets of an array of indices into the table, using a single data value as sort key.\r\n * @param blockedIndices indices, organized as blocks of good indices terminated by the clusterTerminator. Each block is individually sorted on return.\r\n * @param dataIndex index of the data key, e.g., if the sort key is the first extraData (angle) after x and y coordinate data, pass dataIndex = 2.\r\n */\r\n public sortSubsetsBySingleKey(blockedIndices: Uint32Array, dataIndex: number) {\r\n const dataOffset = 1 + dataIndex;\r\n let kBegin = 0;\r\n let swap;\r\n let key0, key1;\r\n const numK = blockedIndices.length;\r\n for (let kEnd = 0; kEnd < numK; kEnd++) {\r\n if (blockedIndices[kEnd] === ClusterableArray.clusterTerminator) {\r\n // bubble sort blockedIndices[kBegin <= k < kEnd].\r\n // (search for minimum remaining, swap . . )\r\n for (let k0 = kBegin; k0 + 1 < kEnd; k0++) {\r\n key0 = this.getWithinBlock(blockedIndices[k0], dataOffset);\r\n for (let k1 = k0 + 1; k1 < kEnd; k1++) {\r\n key1 = this.getWithinBlock(blockedIndices[k1], dataOffset);\r\n if (key1 < key0) {\r\n swap = blockedIndices[k0];\r\n blockedIndices[k0] = blockedIndices[k1];\r\n blockedIndices[k1] = swap;\r\n key0 = key1;\r\n }\r\n }\r\n }\r\n kBegin = kEnd + 1;\r\n }\r\n }\r\n }\r\n /**\r\n * Returns packed points with indices mapping old to new.\r\n * @param data points to cluster.\r\n */\r\n public static clusterPoint3dArray(data: Point3d[], tolerance: number = Geometry.smallMetricDistance):\r\n PackedPointsWithIndex {\r\n const clusterArray = new ClusterableArray(3, 0, data.length);\r\n data.forEach((p: Point3d) => {\r\n clusterArray.addDirect(p.x, p.y, p.z);\r\n });\r\n const order = clusterArray.clusterIndicesLexical(tolerance);\r\n const result = new PackedPointsWithIndex(data.length);\r\n let currentClusterIndex = 0;\r\n let numThisCluster = 0;\r\n order.forEach((k: number) => {\r\n if (ClusterableArray.isClusterTerminator(k)) {\r\n currentClusterIndex++;\r\n numThisCluster = 0;\r\n } else {\r\n if (numThisCluster === 0)\r\n result.packedPoints.push(data[k].clone());\r\n result.oldToNew[k] = currentClusterIndex;\r\n numThisCluster++;\r\n }\r\n });\r\n return result;\r\n }\r\n\r\n /**\r\n * Returns number array with indices mapping old to new.\r\n * @param data numbers to cluster.\r\n */\r\n public static clusterNumberArray(data: number[], tolerance: number = Geometry.smallMetricDistance): PackedNumbersWithIndex {\r\n const clusterArray = new ClusterableArray(1, 0, data.length);\r\n data.forEach((x: number) => {clusterArray.addDirect(x);});\r\n const order = clusterArray.clusterIndicesLexical(tolerance);\r\n const result = new PackedNumbersWithIndex(data.length);\r\n let currentClusterIndex = 0;\r\n let numThisCluster = 0;\r\n order.forEach((k: number) => {\r\n if (ClusterableArray.isClusterTerminator(k)) {\r\n currentClusterIndex++;\r\n numThisCluster = 0;\r\n } else {\r\n if (numThisCluster === 0)\r\n result.packedNumbers.push(data[k]);\r\n result.oldToNew[k] = currentClusterIndex;\r\n numThisCluster++;\r\n }\r\n });\r\n return result;\r\n }\r\n\r\n /**\r\n * Returns packed points with indices mapping old to new.\r\n * @param data points to cluster.\r\n */\r\n public static clusterGrowablePoint2dArray(source: GrowableXYArray, tolerance: number = Geometry.smallMetricDistance): PackedPoint2dsWithIndex {\r\n const clusterArray = new ClusterableArray(2, 0, source.length);\r\n const p = Point2d.create();\r\n const numSourcePoint = source.length;\r\n for (let i = 0; i < numSourcePoint; i++) {\r\n source.getPoint2dAtUncheckedPointIndex(i, p);\r\n clusterArray.addDirect(p.x, p.y);\r\n }\r\n const order = clusterArray.clusterIndicesLexical(tolerance);\r\n const numPackedPoints = clusterArray.countClusters(order);\r\n const result = new PackedPoint2dsWithIndex(source.length, numPackedPoints);\r\n let currentClusterIndex = 0;\r\n let numThisCluster = 0;\r\n order.forEach((k: number) => {\r\n if (ClusterableArray.isClusterTerminator(k)) {\r\n currentClusterIndex++;\r\n numThisCluster = 0;\r\n } else {\r\n if (numThisCluster === 0) // This is the first encounter with a new cluster\r\n result.growablePackedPoints.pushFromGrowableXYArray(source, k);\r\n result.oldToNew[k] = currentClusterIndex;\r\n numThisCluster++;\r\n }\r\n });\r\n return result;\r\n }\r\n\r\n /**\r\n * Returns packed points with indices mapping old to new.\r\n * @param data points to cluster.\r\n */\r\n public static clusterGrowablePoint3dArray(source: GrowableXYZArray, tolerance: number = Geometry.smallMetricDistance):\r\n PackedPointsWithIndex {\r\n const clusterArray = new ClusterableArray(3, 0, source.length);\r\n const p = Point3d.create();\r\n const numSourcePoint = source.length;\r\n for (let i = 0; i < numSourcePoint; i++) {\r\n source.getPoint3dAtUncheckedPointIndex(i, p);\r\n clusterArray.addDirect(p.x, p.y, p.z);\r\n }\r\n const order = clusterArray.clusterIndicesLexical(tolerance);\r\n const result = new PackedPointsWithIndex(source.length);\r\n const numPackedPoints = clusterArray.countClusters(order);\r\n result.growablePackedPoints = new GrowableXYZArray(numPackedPoints);\r\n let currentClusterIndex = 0;\r\n let numThisCluster = 0;\r\n order.forEach((k: number) => {\r\n if (ClusterableArray.isClusterTerminator(k)) {\r\n currentClusterIndex++;\r\n numThisCluster = 0;\r\n } else {\r\n if (numThisCluster === 0) // This is the first encounter with a new cluster\r\n result.growablePackedPoints!.pushFromGrowableXYZArray(source, k);\r\n result.oldToNew[k] = currentClusterIndex;\r\n numThisCluster++;\r\n }\r\n });\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nfunction updateIndices(indices: number[], oldToNew: Uint32Array): boolean {\r\n let numErrors = 0;\r\n indices.forEach((value: number, i: number, data: number[]) => {\r\n if (value < oldToNew.length) {\r\n data[i] = oldToNew[value];\r\n } else numErrors++;\r\n });\r\n return numErrors === 0;\r\n}\r\n\r\n/**\r\n * Data carrier class for\r\n * * packedPoints = an array of Point3d\r\n * * oldToNew = array of indices from some prior Point3d[] to the packed points.\r\n * @internal\r\n */\r\nclass PackedPointsWithIndex {\r\n /** Array of Point3d */\r\n public packedPoints: Point3d[];\r\n /** array of coordinates packed in GrowableXYZArray */\r\n public growablePackedPoints: GrowableXYZArray | undefined;\r\n /** mapping from old point index to new point index. */\r\n public oldToNew: Uint32Array;\r\n /** integer value for unknown index. */\r\n public static readonly invalidIndex = 0xFFFFffff;\r\n\r\n /** construct a PackedPoints object with\r\n * * empty packedPoints array\r\n * * oldToNew indices all initialized to PackedPoints.invalidIndex\r\n */\r\n constructor(numOldIndexEntry: number) {\r\n this.packedPoints = [];\r\n this.oldToNew = new Uint32Array(numOldIndexEntry);\r\n for (let i = 0; i < numOldIndexEntry; i++) {\r\n this.oldToNew[i] = PackedPointsWithIndex.invalidIndex;\r\n }\r\n }\r\n /**\r\n * Use the oldToNew array to update an array of \"old\" indices.\r\n * @param indices array of indices into prepacked array.\r\n * @returns true if all input indices were valid for the oldToNew array.\r\n */\r\n public updateIndices(indices: number[]): boolean {\r\n return updateIndices(indices, this.oldToNew);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nclass PackedPoint2dsWithIndex {\r\n /** array of coordinates packed in GrowableXYArray */\r\n public growablePackedPoints: GrowableXYArray;\r\n /** mapping from old point index to new point index. */\r\n public oldToNew: Uint32Array;\r\n /** integer value for unknown index. */\r\n public static readonly invalidIndex = 0xFFFFffff;\r\n\r\n /** construct a PackedPoints object with\r\n * * empty packedPoints array\r\n * * oldToNew indices all initialized to PackedPoints.invalidIndex\r\n */\r\n constructor(numOldIndexEntry: number, numPackedPoints: number) {\r\n this.growablePackedPoints = new GrowableXYArray(numPackedPoints);\r\n this.oldToNew = new Uint32Array(numOldIndexEntry);\r\n for (let i = 0; i < numOldIndexEntry; i++) {\r\n this.oldToNew[i] = PackedPoint2dsWithIndex.invalidIndex;\r\n }\r\n }\r\n /**\r\n * Use the oldToNew array to update an array of \"old\" indices.\r\n * @param indices array of indices into prepacked array.\r\n * @returns true if all input indices were valid for the oldToNew array.\r\n */\r\n public updateIndices(indices: number[]): boolean {\r\n return updateIndices(indices, this.oldToNew);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\n class PackedNumbersWithIndex {\r\n /** Array of numbers */\r\n public packedNumbers: number[];\r\n /** mapping from old point index to new point index. */\r\n public oldToNew: Uint32Array;\r\n /** integer value for unknown index. */\r\n public static readonly invalidIndex = 0xFFFFffff;\r\n\r\n /** construct a PackedNumbers object with\r\n * * empty packedNumbers array\r\n * * oldToNew indices all initialized to PackedNumbers.invalidIndex\r\n */\r\n constructor(numOldIndexEntry: number) {\r\n this.packedNumbers = [];\r\n this.oldToNew = new Uint32Array(numOldIndexEntry);\r\n for (let i = 0; i < numOldIndexEntry; i++) {\r\n this.oldToNew[i] = PackedPointsWithIndex.invalidIndex;\r\n }\r\n }\r\n /**\r\n * Use the oldToNew array to update an array of \"old\" indices.\r\n * @param indices array of indices into prepacked array.\r\n * @returns true if all input indices were valid for the oldToNew array.\r\n */\r\n public updateIndices(indices: number[]): boolean {\r\n return updateIndices(indices, this.oldToNew);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ClusterableArray.js","sourceRoot":"","sources":["../../../src/numerics/ClusterableArray.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AACvC,6EAA0E;AAC1E,mEAAgE;AAChE,qEAAkE;AAClE,mEAAwD;AACxD,mEAAwD;AAExD;;;;GAIG;AACH,MAAa,gBAAiB,SAAQ,2CAAoB;IACxD,4BAA4B;IAC5B,qCAAqC;IACrC,kFAAkF;IAClF,6HAA6H;IACrH,MAAM,CAAU,aAAa,GAAG,MAAM,CAAC,CAAE,6BAA6B;IAC9E,6CAA6C;IACtC,MAAM,CAAC,mBAAmB,CAAC,KAAa;QAC7C,IAAI,CAAC,GAAG,GAAG,CAAC;QACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE;YAAE,CAAC,IAAI,gBAAgB,CAAC,aAAa,CAAC;QACpE,OAAO,CAAC,CAAC;IACX,CAAC;IACO,sBAAsB,CAAS;IAC/B,qBAAqB,CAAS;IACtC;;;;OAIG;IACH,YAAmB,qBAA6B,EAAE,oBAA4B,EAAE,oBAA4B;QAC1G,KAAK,CAAC,CAAC,GAAG,qBAAqB,GAAG,oBAAoB,EAAE,oBAAoB,CAAC,CAAC;QAC9E,IAAI,CAAC,qBAAqB,GAAG,oBAAoB,CAAC;QAClD,IAAI,CAAC,sBAAsB,GAAG,qBAAqB,CAAC;IACtD,CAAC;IACD;;OAEG;IACa,QAAQ,CAAC,IAAc;QACrC,MAAM,EAAE,GAAG,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;QACpC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,GAAG,CAAC,E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AAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,uBAAuB,CAAC,YAAY,CAAC;QAC1D,CAAC;IACH,CAAC;IACD;;;;OAIG;IACI,aAAa,CAAC,OAAiB;QACpC,OAAO,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;;AAGH;;GAEG;AACF,MAAM,sBAAsB;IAC3B,uBAAuB;IAChB,aAAa,CAAW;IAC/B,uDAAuD;IAChD,QAAQ,CAAc;IAC7B,uCAAuC;IAChC,MAAM,CAAU,YAAY,GAAG,UAAU,CAAC;IAEjD;;;OAGG;IACH,YAAY,gBAAwB;QAClC,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,IAAI,WAAW,CAAC,gBAAgB,CAAC,CAAC;QAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,qBAAqB,CAAC,YAAY,CAAC;QACxD,CAAC;IACH,CAAC;IACD;;;;OAIG;IACI,aAAa,CAAC,OAAiB;QACpC,OAAO,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC","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 Numerics\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GrowableBlockedArray } from \"../geometry3d/GrowableBlockedArray\";\r\nimport { GrowableXYArray } from \"../geometry3d/GrowableXYArray\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { Point2d } from \"../geometry3d/Point2dVector2d\";\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\n\r\n/**\r\n * Blocked array with operations to sort and cluster with a tolerance.\r\n * * Primary sorting is along an \"arbitrary\" sort vector.\r\n * @internal\r\n */\r\nexport class ClusterableArray extends GrowableBlockedArray {\r\n // (This is pretty strange)\r\n // The sort vector is (1,c, c*c, ...)\r\n // Setting c = 1 makes it 1,1,1 which may be useful for visual scans during debug.\r\n // c with some non-obvious digits makes it unlikely that there will be multiple points on a perpendicular to the sort vector.\r\n private static readonly _vectorFactor = 0.8732; // use 1.0 to rig easy tests.\r\n /** Return a component of the sort vector. */\r\n public static sortVectorComponent(index: number): number {\r\n let c = 1.0;\r\n for (let i = 1; i < index; i++) c *= ClusterableArray._vectorFactor;\r\n return c;\r\n }\r\n private _numCoordinatePerPoint: number;\r\n private _numExtraDataPerPoint: number;\r\n /**\r\n * @param numCoordinatePerPoint number of coordinates per point\r\n * @param numExtraDataPerPoint of extra data values per point.\r\n * @param initialBlockCapacity predicted number of points. (This does not have to be accurate)\r\n */\r\n public constructor(numCoordinatePerPoint: number, numExtraDataPerPoint: number, initialBlockCapacity: number) {\r\n super(1 + numCoordinatePerPoint + numExtraDataPerPoint, initialBlockCapacity);\r\n this._numExtraDataPerPoint = numExtraDataPerPoint;\r\n this._numCoordinatePerPoint = numCoordinatePerPoint;\r\n }\r\n /** load a block, placing data[i] at block[i+1] to allow sort coordinate first.\r\n * @param data array of numDataPerBlock values.\r\n */\r\n public override addBlock(data: number[]) {\r\n const i0 = this.newBlockIndex() + 1;\r\n const n = Math.min(this.numPerBlock - 1, data.length);\r\n for (let i = 0; i < n; i++)\r\n this._data[i0 + i] = data[i];\r\n }\r\n /** add a block directly with 1 to 5 listed content parameters.\r\n * This assumes numDataPerPoint is sufficient for the parameters provided.\r\n */\r\n public addDirect(x0: number, x1?: number, x2?: number, x3?: number, x4?: number) {\r\n const i0 = this.newBlockIndex();\r\n this._data[i0 + 1] = x0;\r\n if (x1 !== undefined) this._data[i0 + 2] = x1;\r\n if (x2 !== undefined) this._data[i0 + 3] = x2;\r\n if (x3 !== undefined) this._data[i0 + 4] = x3;\r\n if (x4 !== undefined) this._data[i0 + 5] = x4;\r\n }\r\n\r\n /** add a block directly from a Point2d with 0 to 3 extras\r\n * This assumes numDataPerPoint is sufficient for the parameters provided.\r\n */\r\n public addPoint2d(xy: Point2d, a?: number, b?: number, c?: number) {\r\n const i0 = this.newBlockIndex();\r\n this._data[i0 + 1] = xy.x;\r\n this._data[i0 + 2] = xy.y;\r\n if (a !== undefined)\r\n this._data[i0 + 3] = a;\r\n if (b !== undefined)\r\n this._data[i0 + 4] = b;\r\n if (c !== undefined)\r\n this._data[i0 + 5] = c;\r\n }\r\n\r\n /** add a block with directly from a Point2d with 0 to 3 extras\r\n * This assumes numDataPerPoint is sufficient for the parameters provided.\r\n */\r\n public addPoint3d(xyz: Point3d, a?: number, b?: number, c?: number) {\r\n const i0 = this.newBlockIndex();\r\n this._data[i0 + 1] = xyz.x;\r\n this._data[i0 + 2] = xyz.y;\r\n this._data[i0 + 3] = xyz.z;\r\n if (a !== undefined)\r\n this._data[i0 + 4] = a;\r\n if (b !== undefined)\r\n this._data[i0 + 5] = b;\r\n if (c !== undefined)\r\n this._data[i0 + 6] = c;\r\n }\r\n /** Get the xy coordinates by point index. */\r\n public getPoint2d(blockIndex: number, result?: Point2d): Point2d {\r\n const i0 = this.blockIndexToDoubleIndex(blockIndex);\r\n return Point2d.create(this._data[i0 + 1], this._data[i0 + 2], result);\r\n }\r\n /** Get the xyZ coordinates by point index. */\r\n public getPoint3d(blockIndex: number, result?: Point3d): Point3d {\r\n const i0 = this.blockIndexToDoubleIndex(blockIndex);\r\n return Point3d.create(this._data[i0 + 1], this._data[i0 + 2], this._data[i0 + 3], result);\r\n }\r\n /** Return a single extra data value */\r\n public getExtraData(blockIndex: number, i: number): number {\r\n const i0 = this.blockIndexToDoubleIndex(blockIndex);\r\n return this._data[i0 + 1 + this._numCoordinatePerPoint + i];\r\n }\r\n /** Return a single data value */\r\n public getData(blockIndex: number, i: number): number {\r\n const i0 = this.blockIndexToDoubleIndex(blockIndex);\r\n return this._data[i0 + i];\r\n }\r\n\r\n /** Set a single extra data value */\r\n public setExtraData(blockIndex: number, i: number, value: number): void {\r\n const i0 = this.blockIndexToDoubleIndex(blockIndex);\r\n this._data[i0 + 1 + this._numCoordinatePerPoint + i] = value;\r\n }\r\n\r\n /** this value is used as cluster terminator in the Uint232Array of indices. */\r\n public static readonly clusterTerminator = 0xFFffFFff;\r\n /** Test if `x` is the cluster terminator value. */\r\n public static isClusterTerminator(x: number): boolean { return x === ClusterableArray.clusterTerminator; }\r\n /** Return an array giving clusters of blocks with similar coordinates.\r\n *\r\n * * The contents of each block is assumed to be set up so the primary sort coordinate is first.\r\n *\r\n * ** simple coordinate blocks (x,y) or (x,y,z) would work fine but have occasional performance problems because points with same x would generate big blocks of\r\n * candidates for clusters.\r\n * ** The usual solution is to sort by u value, which is a dot product along some skew direction, and have the blocks contain (u,x,y) or (u,x,y,z) for 2d versus 3d.\r\n * ** apply setupPrimaryClusterSort to prepare that!!!\r\n * * After a simple lexical sort, consecutive blocks that are within tolerance in the 0 component\r\n * are inspected. Within that candidate set, all blocks that are within tolerance for ALL components are clustered.\r\n * * In the output cluster array, clusters are terminated a invalid index. Test for the invalid index with GrowableBlockArray.isClusterTerminator (x)\r\n */\r\n public clusterIndicesLexical(clusterTolerance: number = Geometry.smallMetricDistance): Uint32Array {\r\n // install primary sort key\r\n this.setupPrimaryClusterSort();\r\n // presort by all coordinates ....\r\n const firstSort = this.sortIndicesLexical();\r\n const clusterIndices = new Uint32Array(2 * firstSort.length); // worst case: no duplicates, each index goes in followed by terminator.\r\n let m = 0; // number of cluster indices\r\n const n = this.numBlocks; // and this must match firstSort.length !!\r\n let clusterStartBlockIndex = 0;\r\n let candidateBlockIndex = 0;\r\n let barrierU = 0.0;\r\n let i = 0;\r\n let j = 0;\r\n const k0 = 1; // beginning of active column for distance\r\n const k1 = 1 + this._numCoordinatePerPoint;\r\n for (i = 0; i < n; i++) {\r\n clusterStartBlockIndex = firstSort[i];\r\n if (!ClusterableArray.isClusterTerminator(clusterStartBlockIndex)) {\r\n // unused block, so it becomes a cluster...\r\n clusterIndices[m++] = clusterStartBlockIndex;\r\n barrierU = this.component(clusterStartBlockIndex, 0) + clusterTolerance;\r\n firstSort[i] = ClusterableArray.clusterTerminator;\r\n for (j = i + 1; j < n; j++) {\r\n candidateBlockIndex = firstSort[j];\r\n if (candidateBlockIndex === ClusterableArray.clusterTerminator)\r\n continue; // nearby in sort direction but already in a cluster.\r\n if (this.component(candidateBlockIndex, 0) > barrierU)\r\n break;\r\n if (this.distanceBetweenSubBlocks(clusterStartBlockIndex, candidateBlockIndex, k0, k1) <= clusterTolerance) {\r\n clusterIndices[m++] = candidateBlockIndex; // The candidate is in the block\r\n firstSort[j] = ClusterableArray.clusterTerminator; // and it will not be reused as future block base\r\n }\r\n }\r\n clusterIndices[m++] = ClusterableArray.clusterTerminator;\r\n }\r\n }\r\n // Alas, the clusterIndices array has fluff at the end. So it has to be copied.\r\n return clusterIndices.slice(0, m);\r\n }\r\n /** setup (overwrite!!) the \"0\" component with the dot product of numClusterCoordinate later components with a non-axis aligned vector.\r\n * This is normally called before clusterIndicesLexical.\r\n */\r\n public setupPrimaryClusterSort() {\r\n const nb = this.numBlocks;\r\n const nc = this._numCoordinatePerPoint;\r\n const vector = new Float64Array(nc);\r\n vector[0] = 1.0;\r\n for (let c = 1; c < nc; c++) vector[c] = vector[c - 1] * ClusterableArray._vectorFactor;\r\n let k = 0;\r\n let dot = 0.0;\r\n const data = this._data;\r\n for (let b = 0; b < nb; b++) {\r\n k = this.blockIndexToDoubleIndex(b);\r\n dot = 0.0;\r\n for (let c = 0; c < nc; c++) { dot += vector[c] * data[k + 1 + c]; }\r\n data[k] = dot;\r\n }\r\n }\r\n /** Convert the cluster data to an array of tuples with point i in the form\r\n * `[i, primarySortCoordinate, [x,y,..], [extraData0, extraData1, ...]]`\r\n */\r\n public toJSON(): any[] {\r\n const result: any[] = [];\r\n for (let b = 0; b < this.numBlocks; b++) {\r\n let i = this.blockIndexToDoubleIndex(b);\r\n const chunk: any[] = [b, this._data[i++]];\r\n const coordinates = [];\r\n for (let c = 0; c < this._numCoordinatePerPoint; c++)coordinates.push(this._data[i++]);\r\n chunk.push(coordinates);\r\n for (let c = 0; c < this._numExtraDataPerPoint; c++)\r\n chunk.push(this._data[i++]);\r\n result.push(chunk);\r\n }\r\n return result;\r\n }\r\n /**\r\n * Return an array of indices from block index to cluster index.\r\n * @param clusteredBlocks clusters of block indices followed by separators.\r\n */\r\n public createIndexBlockToClusterIndex(clusteredBlocks: Uint32Array): Uint32Array {\r\n const numBlocks = this.numBlocks;\r\n const blockToCluster = new Uint32Array(numBlocks);\r\n blockToCluster.fill(ClusterableArray.clusterTerminator);\r\n let numCluster = 0;\r\n for (const b of clusteredBlocks) {\r\n if (b >= numBlocks) {\r\n numCluster++;\r\n } else {\r\n blockToCluster[b] = numCluster;\r\n }\r\n }\r\n return blockToCluster;\r\n }\r\n /**\r\n * Return an array of indices from block index to index of its cluster's start in the cluster index array.\r\n * @param clusteredBlocks clusters of block indices followed by separators.\r\n */\r\n public createIndexBlockToClusterStart(clusteredBlocks: Uint32Array): Uint32Array {\r\n const n = clusteredBlocks.length;\r\n const numBlocks = this.numBlocks;\r\n const blockToClusterStart = new Uint32Array(numBlocks);\r\n const terminator = ClusterableArray.clusterTerminator;\r\n blockToClusterStart.fill(terminator);\r\n let clusterStart = 0;\r\n for (let i = 0; i < n; i++) {\r\n const k = clusteredBlocks[i];\r\n if (k > numBlocks) {\r\n clusterStart = i + 1;\r\n } else {\r\n blockToClusterStart[k] = clusterStart;\r\n }\r\n }\r\n return blockToClusterStart;\r\n }\r\n /** count the clusters in the clusteredBlocks array. */\r\n public countClusters(clusteredBlocks: Uint32Array): number {\r\n let numClusters = 0;\r\n const terminator = ClusterableArray.clusterTerminator;\r\n for (const b of clusteredBlocks) {\r\n if (b === terminator)\r\n numClusters++;\r\n }\r\n return numClusters;\r\n }\r\n /** create a reverse index: given a cluster index k, clusterToClusterStart[k] is the place\r\n * the cluster's block indices appear in clusterBlocks\r\n */\r\n public createIndexClusterToClusterStart(clusteredBlocks: Uint32Array): Uint32Array {\r\n let numCluster = this.countClusters(clusteredBlocks);\r\n const clusterToClusterStart = new Uint32Array(numCluster);\r\n const terminator = ClusterableArray.clusterTerminator;\r\n clusterToClusterStart.fill(terminator);\r\n const n = clusteredBlocks.length;\r\n let clusterStart = 0;\r\n for (let i = 0; i < n; i++) {\r\n const k = clusteredBlocks[i];\r\n if (k === terminator) {\r\n clusterStart = i + 1;\r\n } else if (i === clusterStart) {\r\n clusterToClusterStart[numCluster++] = clusterStart;\r\n }\r\n }\r\n return clusterToClusterStart;\r\n }\r\n\r\n /**\r\n * Sort terminator-delimited subsets of an array of indices into the table, using a single data value as sort key.\r\n * @param blockedIndices indices, organized as blocks of good indices terminated by the clusterTerminator. Each block is individually sorted on return.\r\n * @param dataIndex index of the data key, e.g., if the sort key is the first extraData (angle) after x and y coordinate data, pass dataIndex = 2.\r\n */\r\n public sortSubsetsBySingleKey(blockedIndices: Uint32Array, dataIndex: number) {\r\n const dataOffset = 1 + dataIndex;\r\n let kBegin = 0;\r\n let swap;\r\n let key0, key1;\r\n const numK = blockedIndices.length;\r\n for (let kEnd = 0; kEnd < numK; kEnd++) {\r\n if (blockedIndices[kEnd] === ClusterableArray.clusterTerminator) {\r\n // bubble sort blockedIndices[kBegin <= k < kEnd].\r\n // (search for minimum remaining, swap . . )\r\n for (let k0 = kBegin; k0 + 1 < kEnd; k0++) {\r\n key0 = this.getWithinBlock(blockedIndices[k0], dataOffset);\r\n for (let k1 = k0 + 1; k1 < kEnd; k1++) {\r\n key1 = this.getWithinBlock(blockedIndices[k1], dataOffset);\r\n if (key1 < key0) {\r\n swap = blockedIndices[k0];\r\n blockedIndices[k0] = blockedIndices[k1];\r\n blockedIndices[k1] = swap;\r\n key0 = key1;\r\n }\r\n }\r\n }\r\n kBegin = kEnd + 1;\r\n }\r\n }\r\n }\r\n /**\r\n * Returns packed points with indices mapping old to new.\r\n * @param data points to cluster.\r\n */\r\n public static clusterPoint3dArray(data: Point3d[], tolerance: number = Geometry.smallMetricDistance):\r\n PackedPointsWithIndex {\r\n const clusterArray = new ClusterableArray(3, 0, data.length);\r\n data.forEach((p: Point3d) => {\r\n clusterArray.addDirect(p.x, p.y, p.z);\r\n });\r\n const order = clusterArray.clusterIndicesLexical(tolerance);\r\n const result = new PackedPointsWithIndex(data.length);\r\n let currentClusterIndex = 0;\r\n let numThisCluster = 0;\r\n order.forEach((k: number) => {\r\n if (ClusterableArray.isClusterTerminator(k)) {\r\n currentClusterIndex++;\r\n numThisCluster = 0;\r\n } else {\r\n if (numThisCluster === 0)\r\n result.packedPoints.push(data[k].clone());\r\n result.oldToNew[k] = currentClusterIndex;\r\n numThisCluster++;\r\n }\r\n });\r\n return result;\r\n }\r\n\r\n /**\r\n * Returns number array with indices mapping old to new.\r\n * @param data numbers to cluster.\r\n */\r\n public static clusterNumberArray(data: number[], tolerance: number = Geometry.smallMetricDistance): PackedNumbersWithIndex {\r\n const clusterArray = new ClusterableArray(1, 0, data.length);\r\n data.forEach((x: number) => {clusterArray.addDirect(x);});\r\n const order = clusterArray.clusterIndicesLexical(tolerance);\r\n const result = new PackedNumbersWithIndex(data.length);\r\n let currentClusterIndex = 0;\r\n let numThisCluster = 0;\r\n order.forEach((k: number) => {\r\n if (ClusterableArray.isClusterTerminator(k)) {\r\n currentClusterIndex++;\r\n numThisCluster = 0;\r\n } else {\r\n if (numThisCluster === 0)\r\n result.packedNumbers.push(data[k]);\r\n result.oldToNew[k] = currentClusterIndex;\r\n numThisCluster++;\r\n }\r\n });\r\n return result;\r\n }\r\n\r\n /**\r\n * Returns packed points with indices mapping old to new.\r\n * @param data points to cluster.\r\n */\r\n public static clusterGrowablePoint2dArray(source: GrowableXYArray, tolerance: number = Geometry.smallMetricDistance): PackedPoint2dsWithIndex {\r\n const clusterArray = new ClusterableArray(2, 0, source.length);\r\n const p = Point2d.create();\r\n const numSourcePoint = source.length;\r\n for (let i = 0; i < numSourcePoint; i++) {\r\n source.getPoint2dAtUncheckedPointIndex(i, p);\r\n clusterArray.addDirect(p.x, p.y);\r\n }\r\n const order = clusterArray.clusterIndicesLexical(tolerance);\r\n const numPackedPoints = clusterArray.countClusters(order);\r\n const result = new PackedPoint2dsWithIndex(source.length, numPackedPoints);\r\n let currentClusterIndex = 0;\r\n let numThisCluster = 0;\r\n order.forEach((k: number) => {\r\n if (ClusterableArray.isClusterTerminator(k)) {\r\n currentClusterIndex++;\r\n numThisCluster = 0;\r\n } else {\r\n if (numThisCluster === 0) // This is the first encounter with a new cluster\r\n result.growablePackedPoints.pushFromGrowableXYArray(source, k);\r\n result.oldToNew[k] = currentClusterIndex;\r\n numThisCluster++;\r\n }\r\n });\r\n return result;\r\n }\r\n\r\n /**\r\n * Returns packed points with indices mapping old to new.\r\n * @param data points to cluster.\r\n */\r\n public static clusterGrowablePoint3dArray(source: GrowableXYZArray, tolerance: number = Geometry.smallMetricDistance):\r\n PackedPointsWithIndex {\r\n const clusterArray = new ClusterableArray(3, 0, source.length);\r\n const p = Point3d.create();\r\n const numSourcePoint = source.length;\r\n for (let i = 0; i < numSourcePoint; i++) {\r\n source.getPoint3dAtUncheckedPointIndex(i, p);\r\n clusterArray.addDirect(p.x, p.y, p.z);\r\n }\r\n const order = clusterArray.clusterIndicesLexical(tolerance);\r\n const result = new PackedPointsWithIndex(source.length);\r\n const numPackedPoints = clusterArray.countClusters(order);\r\n result.growablePackedPoints = new GrowableXYZArray(numPackedPoints);\r\n let currentClusterIndex = 0;\r\n let numThisCluster = 0;\r\n order.forEach((k: number) => {\r\n if (ClusterableArray.isClusterTerminator(k)) {\r\n currentClusterIndex++;\r\n numThisCluster = 0;\r\n } else {\r\n if (numThisCluster === 0) // This is the first encounter with a new cluster\r\n result.growablePackedPoints!.pushFromGrowableXYZArray(source, k);\r\n result.oldToNew[k] = currentClusterIndex;\r\n numThisCluster++;\r\n }\r\n });\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nfunction updateIndices(indices: number[], oldToNew: Uint32Array): boolean {\r\n let numErrors = 0;\r\n indices.forEach((value: number, i: number, data: number[]) => {\r\n if (value < oldToNew.length) {\r\n data[i] = oldToNew[value];\r\n } else numErrors++;\r\n });\r\n return numErrors === 0;\r\n}\r\n\r\n/**\r\n * Data carrier class for\r\n * * packedPoints = an array of Point3d\r\n * * oldToNew = array of indices from some prior Point3d[] to the packed points.\r\n * @internal\r\n */\r\nclass PackedPointsWithIndex {\r\n /** Array of Point3d */\r\n public packedPoints: Point3d[];\r\n /** array of coordinates packed in GrowableXYZArray */\r\n public growablePackedPoints: GrowableXYZArray | undefined;\r\n /** mapping from old point index to new point index. */\r\n public oldToNew: Uint32Array;\r\n /** integer value for unknown index. */\r\n public static readonly invalidIndex = 0xFFFFffff;\r\n\r\n /** construct a PackedPoints object with\r\n * * empty packedPoints array\r\n * * oldToNew indices all initialized to PackedPoints.invalidIndex\r\n */\r\n constructor(numOldIndexEntry: number) {\r\n this.packedPoints = [];\r\n this.oldToNew = new Uint32Array(numOldIndexEntry);\r\n for (let i = 0; i < numOldIndexEntry; i++) {\r\n this.oldToNew[i] = PackedPointsWithIndex.invalidIndex;\r\n }\r\n }\r\n /**\r\n * Use the oldToNew array to update an array of \"old\" indices.\r\n * @param indices array of indices into prepacked array.\r\n * @returns true if all input indices were valid for the oldToNew array.\r\n */\r\n public updateIndices(indices: number[]): boolean {\r\n return updateIndices(indices, this.oldToNew);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nclass PackedPoint2dsWithIndex {\r\n /** array of coordinates packed in GrowableXYArray */\r\n public growablePackedPoints: GrowableXYArray;\r\n /** mapping from old point index to new point index. */\r\n public oldToNew: Uint32Array;\r\n /** integer value for unknown index. */\r\n public static readonly invalidIndex = 0xFFFFffff;\r\n\r\n /** construct a PackedPoints object with\r\n * * empty packedPoints array\r\n * * oldToNew indices all initialized to PackedPoints.invalidIndex\r\n */\r\n constructor(numOldIndexEntry: number, numPackedPoints: number) {\r\n this.growablePackedPoints = new GrowableXYArray(numPackedPoints);\r\n this.oldToNew = new Uint32Array(numOldIndexEntry);\r\n for (let i = 0; i < numOldIndexEntry; i++) {\r\n this.oldToNew[i] = PackedPoint2dsWithIndex.invalidIndex;\r\n }\r\n }\r\n /**\r\n * Use the oldToNew array to update an array of \"old\" indices.\r\n * @param indices array of indices into prepacked array.\r\n * @returns true if all input indices were valid for the oldToNew array.\r\n */\r\n public updateIndices(indices: number[]): boolean {\r\n return updateIndices(indices, this.oldToNew);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\n class PackedNumbersWithIndex {\r\n /** Array of numbers */\r\n public packedNumbers: number[];\r\n /** mapping from old point index to new point index. */\r\n public oldToNew: Uint32Array;\r\n /** integer value for unknown index. */\r\n public static readonly invalidIndex = 0xFFFFffff;\r\n\r\n /** construct a PackedNumbers object with\r\n * * empty packedNumbers array\r\n * * oldToNew indices all initialized to PackedNumbers.invalidIndex\r\n */\r\n constructor(numOldIndexEntry: number) {\r\n this.packedNumbers = [];\r\n this.oldToNew = new Uint32Array(numOldIndexEntry);\r\n for (let i = 0; i < numOldIndexEntry; i++) {\r\n this.oldToNew[i] = PackedPointsWithIndex.invalidIndex;\r\n }\r\n }\r\n /**\r\n * Use the oldToNew array to update an array of \"old\" indices.\r\n * @param indices array of indices into prepacked array.\r\n * @returns true if all input indices were valid for the oldToNew array.\r\n */\r\n public updateIndices(indices: number[]): boolean {\r\n return updateIndices(indices, this.oldToNew);\r\n }\r\n}\r\n"]}
@@ -117,13 +117,21 @@ export declare class HalfEdgeGraphMerge {
117
117
  static curvatureSortKey(node: HalfEdge): number;
118
118
  /** Whether the HalfEdge is part of a null face, as marked by [[clusterAndMergeXYTheta]]. */
119
119
  static isNullFace(node: HalfEdge): boolean;
120
- /** Simplest merge algorithm:
121
- * * collect array of (x,y,theta) at all nodes
122
- * * lexical sort of the array.
123
- * * twist all vertices together.
124
- * * This effectively creates valid face loops for a planar subdivision if there are no edge crossings.
125
- * * If there are edge crossings, the graph can be a (highly complicated) Klein bottle topology.
126
- * * Mask.NULL_FACE is cleared throughout and applied within null faces.
120
+ /**
121
+ * Cluster the HalfEdges so that xy-coordinates within `mergeTolerance` are equated.
122
+ * * Note that any additional data (e.g., edgeTag, faceTag) on the HalfEdges are ignored. In particular,
123
+ * [[CurveLocationDetail]]s attached to clustered HalfEdges do *not* get their points adjusted.
124
+ * * This is a simple merge algorithm:
125
+ * * untwist all edges from the vertex loops
126
+ * * collect array of (x,y,theta) at all nodes
127
+ * * lexical sort of the array
128
+ * * twist all edges together in sort order around each vertex
129
+ * * This effectively creates valid face loops for a planar subdivision if there are no edge crossings.
130
+ * * If there are edge crossings, the graph can be a (highly complicated) Klein bottle topology.
131
+ * * [[HalfEdgeMask.NULL_FACE]] is cleared throughout and applied within null faces.
132
+ * @param graph input graph
133
+ * @param outboundRadiansFunction optional function to compute the sort angle of an edge at its start vertex
134
+ * @param clusterTol optional distance tolerance for clustering vertices. Default value is [[Geometry.smallMetricDistance]].
127
135
  */
128
136
  static clusterAndMergeXYTheta(graph: HalfEdgeGraph, outboundRadiansFunction?: (he: HalfEdge) => number, clusterTol?: number): void;
129
137
  private static buildVerticalSweepPriorityQueue;
@@ -1 +1 @@
1
- {"version":3,"file":"Merging.d.ts","sourceRoot":"","sources":["../../../src/topology/Merging.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;A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