@itwin/core-geometry 5.3.0-dev.9 → 5.4.0-dev.3

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 (162) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/lib/cjs/curve/Arc3d.d.ts +15 -1
  3. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  4. package/lib/cjs/curve/Arc3d.js +31 -2
  5. package/lib/cjs/curve/Arc3d.js.map +1 -1
  6. package/lib/cjs/curve/CurveFactory.d.ts +25 -8
  7. package/lib/cjs/curve/CurveFactory.d.ts.map +1 -1
  8. package/lib/cjs/curve/CurveFactory.js +51 -55
  9. package/lib/cjs/curve/CurveFactory.js.map +1 -1
  10. package/lib/cjs/curve/spiral/AustralianRailCorpXYEvaluator.d.ts +10 -13
  11. package/lib/cjs/curve/spiral/AustralianRailCorpXYEvaluator.d.ts.map +1 -1
  12. package/lib/cjs/curve/spiral/AustralianRailCorpXYEvaluator.js +23 -22
  13. package/lib/cjs/curve/spiral/AustralianRailCorpXYEvaluator.js.map +1 -1
  14. package/lib/cjs/curve/spiral/ClothoidSeries.d.ts +10 -6
  15. package/lib/cjs/curve/spiral/ClothoidSeries.d.ts.map +1 -1
  16. package/lib/cjs/curve/spiral/ClothoidSeries.js +36 -19
  17. package/lib/cjs/curve/spiral/ClothoidSeries.js.map +1 -1
  18. package/lib/cjs/curve/spiral/CubicEvaluator.d.ts +7 -6
  19. package/lib/cjs/curve/spiral/CubicEvaluator.d.ts.map +1 -1
  20. package/lib/cjs/curve/spiral/CubicEvaluator.js +29 -14
  21. package/lib/cjs/curve/spiral/CubicEvaluator.js.map +1 -1
  22. package/lib/cjs/curve/spiral/CzechSpiralEvaluator.d.ts +34 -44
  23. package/lib/cjs/curve/spiral/CzechSpiralEvaluator.d.ts.map +1 -1
  24. package/lib/cjs/curve/spiral/CzechSpiralEvaluator.js +47 -53
  25. package/lib/cjs/curve/spiral/CzechSpiralEvaluator.js.map +1 -1
  26. package/lib/cjs/curve/spiral/DirectHalfCosineSpiralEvaluator.d.ts +2 -2
  27. package/lib/cjs/curve/spiral/DirectHalfCosineSpiralEvaluator.d.ts.map +1 -1
  28. package/lib/cjs/curve/spiral/DirectHalfCosineSpiralEvaluator.js +17 -7
  29. package/lib/cjs/curve/spiral/DirectHalfCosineSpiralEvaluator.js.map +1 -1
  30. package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts +112 -104
  31. package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
  32. package/lib/cjs/curve/spiral/DirectSpiral3d.js +143 -117
  33. package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
  34. package/lib/cjs/curve/spiral/IntegratedSpiral3d.d.ts +71 -53
  35. package/lib/cjs/curve/spiral/IntegratedSpiral3d.d.ts.map +1 -1
  36. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js +99 -66
  37. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  38. package/lib/cjs/curve/spiral/MXCubicAlongArcSpiralEvaluator.d.ts +8 -12
  39. package/lib/cjs/curve/spiral/MXCubicAlongArcSpiralEvaluator.d.ts.map +1 -1
  40. package/lib/cjs/curve/spiral/MXCubicAlongArcSpiralEvaluator.js +11 -13
  41. package/lib/cjs/curve/spiral/MXCubicAlongArcSpiralEvaluator.js.map +1 -1
  42. package/lib/cjs/curve/spiral/NormalizedTransition.d.ts +36 -29
  43. package/lib/cjs/curve/spiral/NormalizedTransition.d.ts.map +1 -1
  44. package/lib/cjs/curve/spiral/NormalizedTransition.js +62 -40
  45. package/lib/cjs/curve/spiral/NormalizedTransition.js.map +1 -1
  46. package/lib/cjs/curve/spiral/PolishCubicSpiralEvaluator.d.ts +13 -18
  47. package/lib/cjs/curve/spiral/PolishCubicSpiralEvaluator.d.ts.map +1 -1
  48. package/lib/cjs/curve/spiral/PolishCubicSpiralEvaluator.js +21 -24
  49. package/lib/cjs/curve/spiral/PolishCubicSpiralEvaluator.js.map +1 -1
  50. package/lib/cjs/curve/spiral/TransitionConditionalProperties.d.ts +41 -27
  51. package/lib/cjs/curve/spiral/TransitionConditionalProperties.d.ts.map +1 -1
  52. package/lib/cjs/curve/spiral/TransitionConditionalProperties.js +50 -33
  53. package/lib/cjs/curve/spiral/TransitionConditionalProperties.js.map +1 -1
  54. package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts +45 -34
  55. package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
  56. package/lib/cjs/curve/spiral/TransitionSpiral3d.js +56 -38
  57. package/lib/cjs/curve/spiral/TransitionSpiral3d.js.map +1 -1
  58. package/lib/cjs/curve/spiral/XYCurveEvaluator.d.ts +27 -21
  59. package/lib/cjs/curve/spiral/XYCurveEvaluator.d.ts.map +1 -1
  60. package/lib/cjs/curve/spiral/XYCurveEvaluator.js +23 -18
  61. package/lib/cjs/curve/spiral/XYCurveEvaluator.js.map +1 -1
  62. package/lib/cjs/geometry3d/GrowableXYArray.d.ts +96 -98
  63. package/lib/cjs/geometry3d/GrowableXYArray.d.ts.map +1 -1
  64. package/lib/cjs/geometry3d/GrowableXYArray.js +121 -110
  65. package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
  66. package/lib/cjs/geometry3d/GrowableXYZArray.d.ts +135 -142
  67. package/lib/cjs/geometry3d/GrowableXYZArray.d.ts.map +1 -1
  68. package/lib/cjs/geometry3d/GrowableXYZArray.js +165 -160
  69. package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
  70. package/lib/cjs/geometry3d/IndexedXYCollection.d.ts +51 -34
  71. package/lib/cjs/geometry3d/IndexedXYCollection.d.ts.map +1 -1
  72. package/lib/cjs/geometry3d/IndexedXYCollection.js +16 -6
  73. package/lib/cjs/geometry3d/IndexedXYCollection.js.map +1 -1
  74. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +78 -77
  75. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  76. package/lib/cjs/geometry3d/IndexedXYZCollection.js +38 -35
  77. package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
  78. package/lib/cjs/geometry3d/PolygonOps.d.ts +27 -7
  79. package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
  80. package/lib/cjs/geometry3d/PolygonOps.js +30 -9
  81. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  82. package/lib/esm/curve/Arc3d.d.ts +15 -1
  83. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  84. package/lib/esm/curve/Arc3d.js +31 -2
  85. package/lib/esm/curve/Arc3d.js.map +1 -1
  86. package/lib/esm/curve/CurveFactory.d.ts +25 -8
  87. package/lib/esm/curve/CurveFactory.d.ts.map +1 -1
  88. package/lib/esm/curve/CurveFactory.js +51 -55
  89. package/lib/esm/curve/CurveFactory.js.map +1 -1
  90. package/lib/esm/curve/spiral/AustralianRailCorpXYEvaluator.d.ts +10 -13
  91. package/lib/esm/curve/spiral/AustralianRailCorpXYEvaluator.d.ts.map +1 -1
  92. package/lib/esm/curve/spiral/AustralianRailCorpXYEvaluator.js +23 -22
  93. package/lib/esm/curve/spiral/AustralianRailCorpXYEvaluator.js.map +1 -1
  94. package/lib/esm/curve/spiral/ClothoidSeries.d.ts +10 -6
  95. package/lib/esm/curve/spiral/ClothoidSeries.d.ts.map +1 -1
  96. package/lib/esm/curve/spiral/ClothoidSeries.js +36 -19
  97. package/lib/esm/curve/spiral/ClothoidSeries.js.map +1 -1
  98. package/lib/esm/curve/spiral/CubicEvaluator.d.ts +7 -6
  99. package/lib/esm/curve/spiral/CubicEvaluator.d.ts.map +1 -1
  100. package/lib/esm/curve/spiral/CubicEvaluator.js +29 -14
  101. package/lib/esm/curve/spiral/CubicEvaluator.js.map +1 -1
  102. package/lib/esm/curve/spiral/CzechSpiralEvaluator.d.ts +34 -44
  103. package/lib/esm/curve/spiral/CzechSpiralEvaluator.d.ts.map +1 -1
  104. package/lib/esm/curve/spiral/CzechSpiralEvaluator.js +47 -53
  105. package/lib/esm/curve/spiral/CzechSpiralEvaluator.js.map +1 -1
  106. package/lib/esm/curve/spiral/DirectHalfCosineSpiralEvaluator.d.ts +2 -2
  107. package/lib/esm/curve/spiral/DirectHalfCosineSpiralEvaluator.d.ts.map +1 -1
  108. package/lib/esm/curve/spiral/DirectHalfCosineSpiralEvaluator.js +17 -7
  109. package/lib/esm/curve/spiral/DirectHalfCosineSpiralEvaluator.js.map +1 -1
  110. package/lib/esm/curve/spiral/DirectSpiral3d.d.ts +112 -104
  111. package/lib/esm/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
  112. package/lib/esm/curve/spiral/DirectSpiral3d.js +143 -117
  113. package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
  114. package/lib/esm/curve/spiral/IntegratedSpiral3d.d.ts +71 -53
  115. package/lib/esm/curve/spiral/IntegratedSpiral3d.d.ts.map +1 -1
  116. package/lib/esm/curve/spiral/IntegratedSpiral3d.js +99 -66
  117. package/lib/esm/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  118. package/lib/esm/curve/spiral/MXCubicAlongArcSpiralEvaluator.d.ts +8 -12
  119. package/lib/esm/curve/spiral/MXCubicAlongArcSpiralEvaluator.d.ts.map +1 -1
  120. package/lib/esm/curve/spiral/MXCubicAlongArcSpiralEvaluator.js +11 -13
  121. package/lib/esm/curve/spiral/MXCubicAlongArcSpiralEvaluator.js.map +1 -1
  122. package/lib/esm/curve/spiral/NormalizedTransition.d.ts +36 -29
  123. package/lib/esm/curve/spiral/NormalizedTransition.d.ts.map +1 -1
  124. package/lib/esm/curve/spiral/NormalizedTransition.js +62 -40
  125. package/lib/esm/curve/spiral/NormalizedTransition.js.map +1 -1
  126. package/lib/esm/curve/spiral/PolishCubicSpiralEvaluator.d.ts +13 -18
  127. package/lib/esm/curve/spiral/PolishCubicSpiralEvaluator.d.ts.map +1 -1
  128. package/lib/esm/curve/spiral/PolishCubicSpiralEvaluator.js +21 -24
  129. package/lib/esm/curve/spiral/PolishCubicSpiralEvaluator.js.map +1 -1
  130. package/lib/esm/curve/spiral/TransitionConditionalProperties.d.ts +41 -27
  131. package/lib/esm/curve/spiral/TransitionConditionalProperties.d.ts.map +1 -1
  132. package/lib/esm/curve/spiral/TransitionConditionalProperties.js +50 -33
  133. package/lib/esm/curve/spiral/TransitionConditionalProperties.js.map +1 -1
  134. package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts +45 -34
  135. package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
  136. package/lib/esm/curve/spiral/TransitionSpiral3d.js +56 -38
  137. package/lib/esm/curve/spiral/TransitionSpiral3d.js.map +1 -1
  138. package/lib/esm/curve/spiral/XYCurveEvaluator.d.ts +27 -21
  139. package/lib/esm/curve/spiral/XYCurveEvaluator.d.ts.map +1 -1
  140. package/lib/esm/curve/spiral/XYCurveEvaluator.js +23 -18
  141. package/lib/esm/curve/spiral/XYCurveEvaluator.js.map +1 -1
  142. package/lib/esm/geometry3d/GrowableXYArray.d.ts +96 -98
  143. package/lib/esm/geometry3d/GrowableXYArray.d.ts.map +1 -1
  144. package/lib/esm/geometry3d/GrowableXYArray.js +122 -111
  145. package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
  146. package/lib/esm/geometry3d/GrowableXYZArray.d.ts +135 -142
  147. package/lib/esm/geometry3d/GrowableXYZArray.d.ts.map +1 -1
  148. package/lib/esm/geometry3d/GrowableXYZArray.js +165 -160
  149. package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
  150. package/lib/esm/geometry3d/IndexedXYCollection.d.ts +51 -34
  151. package/lib/esm/geometry3d/IndexedXYCollection.d.ts.map +1 -1
  152. package/lib/esm/geometry3d/IndexedXYCollection.js +14 -5
  153. package/lib/esm/geometry3d/IndexedXYCollection.js.map +1 -1
  154. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +78 -77
  155. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  156. package/lib/esm/geometry3d/IndexedXYZCollection.js +38 -35
  157. package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
  158. package/lib/esm/geometry3d/PolygonOps.d.ts +27 -7
  159. package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
  160. package/lib/esm/geometry3d/PolygonOps.js +30 -9
  161. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  162. package/package.json +3 -3
@@ -13,42 +13,38 @@ const GrowableXYZArray_1 = require("./GrowableXYZArray");
13
13
  const IndexedXYCollection_1 = require("./IndexedXYCollection");
14
14
  const Point2dVector2d_1 = require("./Point2dVector2d");
15
15
  const Point3dVector3d_1 = require("./Point3dVector3d");
16
- /** `GrowableXYArray` manages a (possibly growing) Float64Array to pack xy coordinates.
16
+ /**
17
+ * `GrowableXYArray` manages a (possibly growing) Float64Array to pack xy coordinates.
17
18
  * @public
18
19
  */
19
- class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
20
- /**
21
- * array of packed xy xy xy components
22
- */
20
+ class GrowableXYArray extends IndexedXYCollection_1.IndexedReadWriteXYCollection {
21
+ /** Array of packed xy xy xy components. */
23
22
  _data;
24
- /**
25
- * Number of xy tuples (not floats) in the array
26
- */
23
+ /** Number of xy tuples (not floats) in the array. */
27
24
  _xyInUse;
28
- /**
29
- * capacity in xy tuples. (not floats)
30
- */
25
+ /** Capacity in xy tuples. (not floats). */
31
26
  _xyCapacity;
32
- /**
33
- * multiplier used by ensureCapacity to expand requested reallocation size
34
- */
27
+ /** Multiplier used by ensureCapacity to expand requested reallocation size. */
35
28
  _growthFactor;
36
- /** Construct a new GrowablePoint2d array.
37
- * @param numPoints initial capacity in xy tuples (default 8)
38
- * @param growthFactor used by ensureCapacity to expand requested reallocation size (default 1.5)
29
+ /**
30
+ * Construct a new GrowablePoint2d array.
31
+ * @param numPoints initial capacity in xy tuples (default 8).
32
+ * @param growthFactor used by ensureCapacity to expand requested reallocation size (default 1.5).
33
+ * @param data optional pre-existing Float64Array to use as the backing memory. If supplied, numPoints is ignored.
39
34
  */
40
- constructor(numPoints = 8, growthFactor) {
35
+ constructor(numPoints = 8, growthFactor, data) {
41
36
  super();
42
- this._data = new Float64Array(numPoints * 2); // 2 values per point
37
+ this._data = data || new Float64Array(numPoints * 2); // 2 values per point
43
38
  this._xyInUse = 0;
44
- this._xyCapacity = numPoints;
39
+ this._xyCapacity = data ? data.length / 2 : numPoints;
45
40
  this._growthFactor = (undefined !== growthFactor && growthFactor >= 1.0) ? growthFactor : 1.5;
46
41
  }
47
- /** Copy xy points from source array. Does not reallocate or change active point count.
48
- * @param source array to copy from
49
- * @param sourceCount copy the first sourceCount points; all points if undefined
50
- * @param destOffset copy to instance array starting at this point index; zero if undefined
51
- * @return count and offset of points copied
42
+ /**
43
+ * Copy xy points from source array. Does not reallocate or change active point count.
44
+ * @param source array to copy from.
45
+ * @param sourceCount copy the first sourceCount points; all points if undefined.
46
+ * @param destOffset copy to instance array starting at this point index; zero if undefined.
47
+ * @return count and offset of points copied.
52
48
  */
53
49
  copyData(source, sourceCount, destOffset) {
54
50
  // validate inputs and convert from points to entries
@@ -77,30 +73,45 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
77
73
  return { count: myCount / 2, offset: myOffset / 2 };
78
74
  }
79
75
  /** The number of points in use. When the length is increased, the array is padded with zeroes. */
80
- get length() { return this._xyInUse; }
81
- set length(newLength) { this.resize(newLength, true); }
76
+ get length() {
77
+ return this._xyInUse;
78
+ }
79
+ set length(newLength) {
80
+ this.resize(newLength, true);
81
+ }
82
82
  /** Return the number of float64 in use. */
83
- get float64Length() { return this._xyInUse * 2; }
84
- /** Return the raw packed data.
83
+ get float64Length() {
84
+ return this._xyInUse * 2;
85
+ }
86
+ /**
87
+ * Return the raw packed data.
85
88
  * * Note that the length of the returned Float64Array is a count of doubles, and includes the excess capacity
86
89
  */
87
- float64Data() { return this._data; }
88
- /** If necessary, increase the capacity to a new pointCount. Current coordinates and point count (length) are unchanged. */
90
+ float64Data() {
91
+ return this._data;
92
+ }
93
+ /** If necessary, increase the capacity to a new pointCount. Current coordinates and point count (length) are unchanged. */
89
94
  ensureCapacity(pointCapacity, applyGrowthFactor = true) {
90
95
  if (pointCapacity > this._xyCapacity) {
91
96
  if (applyGrowthFactor)
92
- pointCapacity *= this._growthFactor;
97
+ pointCapacity = Math.trunc(pointCapacity * this._growthFactor);
93
98
  const prevData = this._data;
94
- this._data = new Float64Array(pointCapacity * 2);
99
+ if (this._data.buffer instanceof ArrayBuffer)
100
+ this._data = new Float64Array(new ArrayBuffer(pointCapacity * 2 * this._data.BYTES_PER_ELEMENT));
101
+ else
102
+ this._data = new Float64Array(new SharedArrayBuffer(pointCapacity * 2 * this._data.BYTES_PER_ELEMENT));
95
103
  this.copyData(prevData, this._xyInUse);
96
104
  this._xyCapacity = pointCapacity;
97
105
  }
98
106
  }
99
107
  /**
100
- * * If pointCount is less than current length, just reset current length to pointCount, effectively trimming active points but preserving original capacity.
101
- * * If pointCount is greater than current length, reallocate to exactly pointCount, copy existing points, and optionally pad excess with zero.
102
- * @param pointCount new number of active points in array
103
- * @param padWithZero when increasing point count, whether to zero out new points (default false)
108
+ * Resize the internal storage to hold a new number of points.
109
+ * * If pointCount is less than current length, just reset current length to pointCount, effectively trimming active
110
+ * points but preserving original capacity.
111
+ * * If pointCount is greater than current length, reallocate to exactly pointCount, copy existing points, and
112
+ * optionally pad excess with zero.
113
+ * @param pointCount new number of active points in array.
114
+ * @param padWithZero when increasing point count, whether to zero out new points (default false).
104
115
  */
105
116
  resize(pointCount, padWithZero) {
106
117
  if (pointCount >= 0 && pointCount < this._xyInUse)
@@ -112,10 +123,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
112
123
  this._xyInUse = pointCount;
113
124
  }
114
125
  }
115
- /**
116
- * Make a copy of the (active) points in this array.
117
- * (The clone does NOT get excess capacity)
118
- */
126
+ /** Make a copy of the (active) points in this array (the clone does NOT get excess capacity). */
119
127
  clone() {
120
128
  const newPoints = new GrowableXYArray(this.length);
121
129
  newPoints.copyData(this._data, this.length);
@@ -133,7 +141,9 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
133
141
  * * A GrowableXYArray
134
142
  * * Any json object satisfying Point3d.isXAndY
135
143
  * * A Float64Array of doubles, interpreted as xyxy
136
- * * An array of any of the above
144
+ * * An array of any of the above.
145
+ * @param data source points.
146
+ * @param result optional pre-allocated GrowableXYArray to clear and fill.
137
147
  */
138
148
  static create(data, result) {
139
149
  if (result) {
@@ -146,23 +156,32 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
146
156
  result.pushFrom(data);
147
157
  return result;
148
158
  }
149
- /** Restructure MultiLineStringDataVariant as array of GrowableXYZArray
159
+ /**
160
+ * Create a new GrowableXYArray capturing the provided data. The data is not copied, just referenced.
161
+ * @param data source data to capture.
162
+ * @returns a new GrowableXYArray object that references the provided data.
163
+ */
164
+ static createCapture(data) {
165
+ return new GrowableXYArray(0, undefined, data);
166
+ }
167
+ /**
168
+ * Restructure MultiLineStringDataVariant as array of GrowableXYZArray
150
169
  * @deprecated in 4.2.0 - will not be removed until after 2026-06-13. Moved to GrowableXYZArray class.
151
170
  */
152
171
  static createArrayOfGrowableXYZArray(data) {
153
172
  return GrowableXYZArray_1.GrowableXYZArray.createArrayOfGrowableXYZArray(data);
154
173
  }
155
- /** push a point to the end of the array */
174
+ /** Push a point to the end of the array. */
156
175
  push(toPush) {
157
176
  this.pushXY(toPush.x, toPush.y);
158
177
  }
159
- /** push all points of an array */
178
+ /** Push all points of an array. */
160
179
  pushAll(points) {
161
180
  this.ensureCapacity(this._xyInUse + points.length, false);
162
181
  for (const p of points)
163
182
  this.push(p);
164
183
  }
165
- /** push all points of an array */
184
+ /** Push all points of an array. */
166
185
  pushAllXYAndZ(points) {
167
186
  this.ensureCapacity(this._xyInUse + points.length, false);
168
187
  if (points instanceof GrowableXYZArray_1.GrowableXYZArray) {
@@ -176,7 +195,8 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
176
195
  this.pushXY(p.x, p.y);
177
196
  }
178
197
  }
179
- /** Push copies of points from variant sources.
198
+ /**
199
+ * Push copies of points from variant sources.
180
200
  * Valid inputs are:
181
201
  * * Point2d
182
202
  * * Point3d
@@ -185,7 +205,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
185
205
  * * A GrowableXYZArray
186
206
  * * Any json object satisfying Point3d.isXAndY
187
207
  * * A Float64Array of doubles, interpreted as xyxy
188
- * * An array of any of the above
208
+ * * An array of any of the above.
189
209
  */
190
210
  pushFrom(p) {
191
211
  if (p instanceof Point3dVector3d_1.Point3d) {
@@ -207,7 +227,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
207
227
  this.pushXY(p[0], p[1]);
208
228
  }
209
229
  else if (Array.isArray(p)) {
210
- // direct recursion re-wraps p and goes infinite. Unroll here.
230
+ // direct recursion re-wraps p and goes infinite; unroll here.
211
231
  for (const q of p)
212
232
  this.pushFrom(q);
213
233
  }
@@ -223,7 +243,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
223
243
  }
224
244
  /**
225
245
  * Replicate numWrap xy values from the front of the array as new values at the end.
226
- * @param numWrap number of xy values to replicate
246
+ * @param numWrap number of xy values to replicate.
227
247
  */
228
248
  pushWrap(numWrap) {
229
249
  if (this._xyInUse >= numWrap) {
@@ -242,16 +262,17 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
242
262
  this._data[index + 1] = y;
243
263
  this._xyInUse++;
244
264
  }
245
- /** Remove one point from the back.
265
+ /**
266
+ * Remove one point from the back.
246
267
  * * NOTE that (in the manner of std::vector native) this is "just" removing the point -- no point is NOT returned.
247
- * * Use `back ()` to get the last x,y assembled into a `Point2d `
268
+ * * Use `back ()` to get the last x,y assembled into a `Point2d`.
248
269
  */
249
270
  pop() {
250
271
  if (this._xyInUse > 0)
251
272
  this._xyInUse--;
252
273
  }
253
274
  /**
254
- * Test if index is valid for an xy (point or vector) within this array
275
+ * Test if index is valid for an xy (point or vector) within this array.
255
276
  * @param index xy index to test.
256
277
  */
257
278
  isIndexValid(index) {
@@ -259,38 +280,34 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
259
280
  return false;
260
281
  return true;
261
282
  }
262
- /**
263
- * Clear all xy data, but leave capacity unchanged.
264
- */
283
+ /** Clear all xy data, but leave capacity unchanged. */
265
284
  clear() {
266
285
  this._xyInUse = 0;
267
286
  }
268
287
  /**
269
- * Get a point by index, strongly typed as a Point2d. This is unchecked. Use atPoint2dIndex to have validity test.
270
- * @param pointIndex index to access
271
- * @param result optional result
288
+ * Get a point by index, strongly typed as a `Point2d`. This is unchecked. Use atPoint2dIndex to have validity test.
289
+ * @param pointIndex index to access.
290
+ * @param result optional result.
272
291
  */
273
292
  getPoint2dAtUncheckedPointIndex(pointIndex, result) {
274
293
  const index = 2 * pointIndex;
275
294
  return Point2dVector2d_1.Point2d.create(this._data[index], this._data[index + 1], result);
276
295
  }
277
296
  /**
278
- * Get x coordinate by point index, with no index checking
279
- * @param pointIndex index to access
297
+ * Get x coordinate by point index, with no index checking.
298
+ * @param pointIndex index to access.
280
299
  */
281
300
  getXAtUncheckedPointIndex(pointIndex) {
282
301
  return this._data[2 * pointIndex];
283
302
  }
284
303
  /**
285
- * Get y coordinate by point index, with no index checking
286
- * @param pointIndex index to access
304
+ * Get y coordinate by point index, with no index checking.
305
+ * @param pointIndex index to access.
287
306
  */
288
307
  getYAtUncheckedPointIndex(pointIndex) {
289
308
  return this._data[2 * pointIndex + 1];
290
309
  }
291
- /**
292
- * Gather all points as a Point2d[]
293
- */
310
+ /** Gather all points as a Point2d[]. */
294
311
  getPoint2dArray() {
295
312
  const n = 2 * this._xyInUse;
296
313
  const result = [];
@@ -299,7 +316,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
299
316
  result.push(Point2dVector2d_1.Point2d.create(data[i], data[i + 1]));
300
317
  return result;
301
318
  }
302
- /** copy xy into strongly typed Point2d */
319
+ /** Copy xy into strongly typed Point2d. */
303
320
  getPoint2dAtCheckedPointIndex(pointIndex, result) {
304
321
  if (this.isIndexValid(pointIndex)) {
305
322
  const index = 2 * pointIndex;
@@ -307,7 +324,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
307
324
  }
308
325
  return undefined;
309
326
  }
310
- /** copy xy into strongly typed Vector2d */
327
+ /** Copy xy into strongly typed Vector2d. */
311
328
  getVector2dAtCheckedVectorIndex(vectorIndex, result) {
312
329
  if (this.isIndexValid(vectorIndex)) {
313
330
  const index = 2 * vectorIndex;
@@ -317,9 +334,9 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
317
334
  }
318
335
  /**
319
336
  * Read coordinates from source array, place them at index within this array.
320
- * @param destIndex point index where coordinates are to be placed in this array
321
- * @param source source array
322
- * @param sourceIndex point index in source array
337
+ * @param destIndex point index where coordinates are to be placed in this array.
338
+ * @param source source array.
339
+ * @param sourceIndex point index in source array.
323
340
  * @returns true if destIndex and sourceIndex are both valid.
324
341
  */
325
342
  transferFromGrowableXYArray(destIndex, source, sourceIndex) {
@@ -333,13 +350,13 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
333
350
  return false;
334
351
  }
335
352
  /**
336
- * push coordinates from the source array to the end of this array.
337
- * @param source source array
338
- * @param sourceIndex xy index within the source. If undefined, push entire contents of source
353
+ * Push coordinates from the source array to the end of this array.
354
+ * @param source source array.
355
+ * @param sourceIndex xy index within the source. If undefined, push entire contents of source.
339
356
  * @returns number of points pushed.
340
357
  */
341
358
  pushFromGrowableXYArray(source, sourceIndex) {
342
- // full array push . . .
359
+ // full array push
343
360
  if (sourceIndex === undefined) {
344
361
  const numXYAdd = source.length;
345
362
  this.ensureCapacity(this.length + numXYAdd, false);
@@ -347,7 +364,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
347
364
  this._xyInUse += numXYAdd;
348
365
  return numXYAdd;
349
366
  }
350
- // single point push . . .
367
+ // single point push
351
368
  if (source.isIndexValid(sourceIndex)) {
352
369
  const j = sourceIndex * 2;
353
370
  this.pushXY(source._data[j], source._data[j + 1]);
@@ -356,8 +373,8 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
356
373
  return 0;
357
374
  }
358
375
  /**
359
- * * Compute a point at fractional coordinate between points i and j of source
360
- * * push onto this array.
376
+ * * Compute a point at fractional coordinate between points i and j of source.
377
+ * * Push onto this array.
361
378
  */
362
379
  pushInterpolatedFromGrowableXYArray(source, i, fraction, j) {
363
380
  if (source.isIndexValid(i) && source.isIndexValid(j)) {
@@ -370,7 +387,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
370
387
  }
371
388
  /**
372
389
  * Create an array of xy points from source xyz points.
373
- * @param source source array of xyz
390
+ * @param source source array of xyz.
374
391
  * @param transform optional transform to apply to xyz points.
375
392
  * @param dest optional result.
376
393
  */
@@ -398,17 +415,13 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
398
415
  }
399
416
  return dest;
400
417
  }
401
- /**
402
- * Return the first point, or undefined if the array is empty.
403
- */
418
+ /** Return the first point, or undefined if the array is empty. */
404
419
  front(result) {
405
420
  if (this._xyInUse === 0)
406
421
  return undefined;
407
422
  return this.getPoint2dAtUncheckedPointIndex(0, result);
408
423
  }
409
- /**
410
- * Return the last point, or undefined if the array is empty.
411
- */
424
+ /** Return the last point, or undefined if the array is empty. */
412
425
  back(result) {
413
426
  if (this._xyInUse < 1)
414
427
  return undefined;
@@ -416,8 +429,8 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
416
429
  }
417
430
  /**
418
431
  * Set the coordinates of a single point.
419
- * @param pointIndex index of point to set
420
- * @param value coordinates to set
432
+ * @param pointIndex index of point to set.
433
+ * @param value coordinates to set.
421
434
  */
422
435
  setAtCheckedPointIndex(pointIndex, value) {
423
436
  if (!this.isIndexValid(pointIndex))
@@ -429,9 +442,9 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
429
442
  }
430
443
  /**
431
444
  * Set the coordinates of a single point given as coordinates.
432
- * @param pointIndex index of point to set
433
- * @param x x coordinate
434
- * @param y y coordinate
445
+ * @param pointIndex index of point to set.
446
+ * @param x x coordinate.
447
+ * @param y y coordinate.
435
448
  */
436
449
  setXYAtCheckedPointIndex(pointIndex, x, y) {
437
450
  if (!this.isIndexValid(pointIndex))
@@ -441,9 +454,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
441
454
  this._data[index + 1] = y;
442
455
  return true;
443
456
  }
444
- /**
445
- * Copy all points into a simple array of Point3d with given z.
446
- */
457
+ /** Copy all points into a simple array of Point3d with given z. */
447
458
  getPoint3dArray(z = 0) {
448
459
  const n = 2 * this._xyInUse;
449
460
  const result = [];
@@ -452,7 +463,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
452
463
  result.push(Point3dVector3d_1.Point3d.create(data[i], data[i + 1], z));
453
464
  return result;
454
465
  }
455
- /** reverse the order of points. */
466
+ /** Reverse the order of points. */
456
467
  reverseInPlace() {
457
468
  const n = this.length;
458
469
  let j0, j1;
@@ -471,7 +482,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
471
482
  data[j1] = a;
472
483
  }
473
484
  }
474
- /** multiply each point by the transform, replace values. */
485
+ /** Multiply each point by the transform, replace values. */
475
486
  multiplyTransformInPlace(transform) {
476
487
  const data = this._data;
477
488
  const nDouble = this.float64Length;
@@ -488,7 +499,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
488
499
  data[i + 1] = coffs[3] * x + coffs[4] * y + y0;
489
500
  }
490
501
  }
491
- /** multiply each xy (as a vector) by matrix, replace values. */
502
+ /** Multiply each xy (as a vector) by matrix, replace values. */
492
503
  multiplyMatrix3dInPlace(matrix) {
493
504
  const data = this._data;
494
505
  const nDouble = this.float64Length;
@@ -502,7 +513,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
502
513
  data[i + 1] = coffs[3] * x + coffs[4] * y;
503
514
  }
504
515
  }
505
- /** multiply each point by the transform, replace values. */
516
+ /** Multiply each point by the transform, replace values. */
506
517
  tryTransformInverseInPlace(transform) {
507
518
  const data = this._data;
508
519
  const nDouble = this.float64Length;
@@ -537,7 +548,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
537
548
  rangeToExtend.extendXY(data[i], data[i + 1]);
538
549
  }
539
550
  }
540
- /** sum the lengths of segments between points. */
551
+ /** Sum the lengths of segments between points. */
541
552
  sumLengths() {
542
553
  let sum = 0.0;
543
554
  const n = 2 * (this._xyInUse - 1); // Length already takes into account what specifically is in use
@@ -548,7 +559,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
548
559
  }
549
560
  /**
550
561
  * Multiply each x,y by the scale factor.
551
- * @param factor
562
+ * @param factor scale factor.
552
563
  */
553
564
  scaleInPlace(factor) {
554
565
  if (this._data) {
@@ -557,7 +568,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
557
568
  this._data[i] = this._data[i] * factor;
558
569
  }
559
570
  }
560
- /** Compute a point at fractional coordinate between points i and j */
571
+ /** Compute a point at fractional coordinate between points i and j. */
561
572
  interpolate(i, fraction, j, result) {
562
573
  if (this.isIndexValid(i) && this.isIndexValid(j)) {
563
574
  const fraction0 = 1.0 - fraction;
@@ -568,10 +579,10 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
568
579
  }
569
580
  return undefined;
570
581
  }
571
- /** Sum the signed areas of the projection to xy plane */
582
+ /** Sum the signed areas of the projection to xy plane. */
572
583
  areaXY() {
573
584
  let area = 0.0;
574
- const n = 2 * this._xyInUse; // float count !!
585
+ const n = 2 * this._xyInUse; // float count
575
586
  if (n > 4) {
576
587
  const x0 = this._data[n - 2];
577
588
  const y0 = this._data[n - 1];
@@ -587,7 +598,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
587
598
  }
588
599
  return 0.5 * area;
589
600
  }
590
- /** Compute a vector from index origin i to indexed target j */
601
+ /** Compute a vector from index origin i to indexed target j. */
591
602
  vectorIndexIndex(i, j, result) {
592
603
  if (!this.isIndexValid(i) || !this.isIndexValid(j))
593
604
  return undefined;
@@ -596,7 +607,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
596
607
  j = 2 * j;
597
608
  return Point2dVector2d_1.Vector2d.create(data[j] - data[i], data[j + 1] - data[i + 1], result);
598
609
  }
599
- /** Compute a vector from origin to indexed target j */
610
+ /** Compute a vector from origin to indexed target j. */
600
611
  vectorXAndYIndex(origin, j, result) {
601
612
  if (this.isIndexValid(j)) {
602
613
  const data = this._data;
@@ -605,7 +616,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
605
616
  }
606
617
  return undefined;
607
618
  }
608
- /** Compute the cross product of vectors from from indexed origin to indexed targets i and j */
619
+ /** Compute the cross product of vectors from from indexed origin to indexed targets i and j. */
609
620
  crossProductIndexIndexIndex(originIndex, targetAIndex, targetBIndex) {
610
621
  if (this.isIndexValid(originIndex) && this.isIndexValid(targetAIndex) && this.isIndexValid(targetBIndex)) {
611
622
  const i = originIndex * 2;
@@ -616,7 +627,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
616
627
  }
617
628
  return undefined;
618
629
  }
619
- /** Compute the cross product of vectors from from origin to indexed targets i and j */
630
+ /** Compute the cross product of vectors from from origin to indexed targets i and j. */
620
631
  crossProductXAndYIndexIndex(origin, targetAIndex, targetBIndex) {
621
632
  if (this.isIndexValid(targetAIndex) && this.isIndexValid(targetBIndex)) {
622
633
  const j = targetAIndex * 2;
@@ -656,7 +667,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
656
667
  // if both are null it is equal, otherwise unequal
657
668
  return (!dataA && !dataB);
658
669
  }
659
- /** Return an array of block indices sorted per compareLexicalBlock function */
670
+ /** Return an array of block indices sorted per compareLexicalBlock function. */
660
671
  sortIndicesLexical() {
661
672
  const n = this._xyInUse;
662
673
  // let numCompare = 0;
@@ -682,13 +693,13 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
682
693
  if (ax < bx)
683
694
  return -1;
684
695
  }
685
- return ia - ib; // so original order is maintained among duplicates !!!!
696
+ return ia - ib; // so original order is maintained among duplicates
686
697
  }
687
- /** Access a single double at offset within a block. This has no index checking. */
698
+ /** Access a single double at offset within a block. This has no index checking. */
688
699
  component(pointIndex, componentIndex) {
689
700
  return this._data[2 * pointIndex + componentIndex];
690
701
  }
691
- /** Toleranced equality test */
702
+ /** Toleranced equality test. */
692
703
  isAlmostEqual(other, tolerance = Geometry_1.Geometry.smallMetricDistance) {
693
704
  const numXY = this._xyInUse;
694
705
  if (other._xyInUse !== numXY)