@itwin/core-geometry 5.3.0-dev.12 → 5.3.0-dev.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -1
- package/lib/cjs/curve/CurveFactory.d.ts +25 -8
- package/lib/cjs/curve/CurveFactory.d.ts.map +1 -1
- package/lib/cjs/curve/CurveFactory.js +51 -55
- package/lib/cjs/curve/CurveFactory.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.d.ts +96 -98
- package/lib/cjs/geometry3d/GrowableXYArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.js +121 -110
- package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts +135 -142
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.js +165 -160
- package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYCollection.d.ts +51 -34
- package/lib/cjs/geometry3d/IndexedXYCollection.d.ts.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYCollection.js +16 -6
- package/lib/cjs/geometry3d/IndexedXYCollection.js.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +78 -77
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.js +38 -35
- package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/esm/curve/CurveFactory.d.ts +25 -8
- package/lib/esm/curve/CurveFactory.d.ts.map +1 -1
- package/lib/esm/curve/CurveFactory.js +51 -55
- package/lib/esm/curve/CurveFactory.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.d.ts +96 -98
- package/lib/esm/geometry3d/GrowableXYArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.js +122 -111
- package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts +135 -142
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.js +165 -160
- package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/esm/geometry3d/IndexedXYCollection.d.ts +51 -34
- package/lib/esm/geometry3d/IndexedXYCollection.d.ts.map +1 -1
- package/lib/esm/geometry3d/IndexedXYCollection.js +14 -5
- package/lib/esm/geometry3d/IndexedXYCollection.js.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +78 -77
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.js +38 -35
- package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/package.json +3 -3
|
@@ -15,42 +15,38 @@ const Point3dVector3d_1 = require("./Point3dVector3d");
|
|
|
15
15
|
const PointStreaming_1 = require("./PointStreaming");
|
|
16
16
|
const Range_1 = require("./Range");
|
|
17
17
|
const Transform_1 = require("./Transform");
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* `GrowableXYZArray` manages a (possibly growing) Float64Array to pack xyz coordinates.
|
|
19
20
|
* @public
|
|
20
21
|
*/
|
|
21
22
|
class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollection {
|
|
22
|
-
/**
|
|
23
|
-
* array of packed xyz xyz xyz components
|
|
24
|
-
*/
|
|
23
|
+
/** Array of packed xyz xyz xyz components. */
|
|
25
24
|
_data;
|
|
26
|
-
/**
|
|
27
|
-
* Number of xyz triples (not floats) in the array
|
|
28
|
-
*/
|
|
25
|
+
/** Number of xyz triples (not floats) in the array. */
|
|
29
26
|
_xyzInUse;
|
|
30
|
-
/**
|
|
31
|
-
* capacity in xyz triples. (not floats)
|
|
32
|
-
*/
|
|
27
|
+
/** Capacity in xyz triples (not floats). */
|
|
33
28
|
_xyzCapacity;
|
|
34
|
-
/**
|
|
35
|
-
* multiplier used by ensureCapacity to expand requested reallocation size
|
|
36
|
-
*/
|
|
29
|
+
/** Multiplier used by ensureCapacity to expand requested reallocation size. */
|
|
37
30
|
_growthFactor;
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
* @param
|
|
31
|
+
/**
|
|
32
|
+
* Construct a new GrowablePoint3d array.
|
|
33
|
+
* @param numPoints initial capacity in xyz triples (default 8).
|
|
34
|
+
* @param growthFactor used by ensureCapacity to expand requested reallocation size (default 1.5).
|
|
35
|
+
* @param data optional pre-existing Float64Array to use as the backing memory. If supplied, numPoints is ignored.
|
|
41
36
|
*/
|
|
42
|
-
constructor(numPoints = 8, growthFactor) {
|
|
37
|
+
constructor(numPoints = 8, growthFactor, data) {
|
|
43
38
|
super();
|
|
44
|
-
this._data = new Float64Array(numPoints * 3); // 3 values per point
|
|
39
|
+
this._data = data || new Float64Array(numPoints * 3); // 3 values per point
|
|
45
40
|
this._xyzInUse = 0;
|
|
46
|
-
this._xyzCapacity = numPoints;
|
|
41
|
+
this._xyzCapacity = data ? data.length / 3 : numPoints;
|
|
47
42
|
this._growthFactor = (undefined !== growthFactor && growthFactor >= 1.0) ? growthFactor : 1.5;
|
|
48
43
|
}
|
|
49
|
-
/**
|
|
50
|
-
*
|
|
51
|
-
* @param
|
|
52
|
-
* @param
|
|
53
|
-
* @
|
|
44
|
+
/**
|
|
45
|
+
* Copy xyz points from source array. Does not reallocate or change active point count.
|
|
46
|
+
* @param source array to copy from.
|
|
47
|
+
* @param sourceCount copy the first sourceCount points; all points if undefined.
|
|
48
|
+
* @param destOffset copy to instance array starting at this point index; zero if undefined.
|
|
49
|
+
* @return count and offset of points copied.
|
|
54
50
|
*/
|
|
55
51
|
copyData(source, sourceCount, destOffset) {
|
|
56
52
|
// validate inputs and convert from points to entries
|
|
@@ -79,30 +75,47 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
79
75
|
return { count: myCount / 3, offset: myOffset / 3 };
|
|
80
76
|
}
|
|
81
77
|
/** The number of points in use. When the length is increased, the array is padded with zeroes. */
|
|
82
|
-
get length() {
|
|
83
|
-
|
|
78
|
+
get length() {
|
|
79
|
+
return this._xyzInUse;
|
|
80
|
+
}
|
|
81
|
+
set length(newLength) {
|
|
82
|
+
this.resize(newLength, true);
|
|
83
|
+
}
|
|
84
84
|
/** Return the number of float64 in use. */
|
|
85
|
-
get float64Length() {
|
|
86
|
-
|
|
85
|
+
get float64Length() {
|
|
86
|
+
return this._xyzInUse * 3;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Return the raw packed data.
|
|
87
90
|
* * Note that the length of the returned Float64Array is a count of doubles, and includes the excess capacity
|
|
88
91
|
*/
|
|
89
|
-
float64Data() {
|
|
90
|
-
|
|
92
|
+
float64Data() {
|
|
93
|
+
return this._data;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* If necessary, increase the capacity to the new number of points. Current coordinates and point count (length) are
|
|
97
|
+
* unchanged.
|
|
98
|
+
*/
|
|
91
99
|
ensureCapacity(pointCapacity, applyGrowthFactor = true) {
|
|
92
100
|
if (pointCapacity > this._xyzCapacity) {
|
|
93
101
|
if (applyGrowthFactor)
|
|
94
|
-
pointCapacity
|
|
102
|
+
pointCapacity = Math.trunc(pointCapacity * this._growthFactor);
|
|
95
103
|
const prevData = this._data;
|
|
96
|
-
this._data
|
|
104
|
+
if (this._data.buffer instanceof ArrayBuffer)
|
|
105
|
+
this._data = new Float64Array(new ArrayBuffer(pointCapacity * 3 * this._data.BYTES_PER_ELEMENT));
|
|
106
|
+
else
|
|
107
|
+
this._data = new Float64Array(new SharedArrayBuffer(pointCapacity * 3 * this._data.BYTES_PER_ELEMENT));
|
|
97
108
|
this.copyData(prevData, this._xyzInUse);
|
|
98
109
|
this._xyzCapacity = pointCapacity;
|
|
99
110
|
}
|
|
100
111
|
}
|
|
101
112
|
/**
|
|
102
|
-
* * If pointCount is less than current length, just reset current length to pointCount, effectively trimming active
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
113
|
+
* * If pointCount is less than current length, just reset current length to pointCount, effectively trimming active
|
|
114
|
+
* points but preserving original capacity.
|
|
115
|
+
* * If pointCount is greater than current length, reallocate to exactly pointCount, copy existing points, and
|
|
116
|
+
* optionally pad excess with zero.
|
|
117
|
+
* @param pointCount new number of active points in array.
|
|
118
|
+
* @param padWithZero when increasing point count, whether to zero out new points (default false).
|
|
106
119
|
*/
|
|
107
120
|
resize(pointCount, padWithZero) {
|
|
108
121
|
if (pointCount >= 0 && pointCount < this._xyzInUse)
|
|
@@ -114,10 +127,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
114
127
|
this._xyzInUse = pointCount;
|
|
115
128
|
}
|
|
116
129
|
}
|
|
117
|
-
/**
|
|
118
|
-
* Make a copy of the (active) points in this array.
|
|
119
|
-
* (The clone does NOT get excess capacity)
|
|
120
|
-
*/
|
|
130
|
+
/** Make a copy of the (active) points in this array (the clone does NOT get excess capacity). */
|
|
121
131
|
clone(result) {
|
|
122
132
|
if (!result)
|
|
123
133
|
result = new GrowableXYZArray(this.length);
|
|
@@ -133,11 +143,11 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
133
143
|
/**
|
|
134
144
|
* Clone the input array with each successive duplicate point removed.
|
|
135
145
|
* * First and last points are always preserved.
|
|
136
|
-
* @param source the source array
|
|
137
|
-
* @param tolerance optional distance tol for compression (default [[Geometry.smallMetricDistance]])
|
|
146
|
+
* @param source the source array.
|
|
147
|
+
* @param tolerance optional distance tol for compression (default [[Geometry.smallMetricDistance]]).
|
|
138
148
|
* @param result optional pre-allocated object to populate and return. Can be a reference to `source`, in
|
|
139
149
|
* which case the array is compressed in place and returned.
|
|
140
|
-
* @see [[cloneCompressed]], [[compressInPlace]], [[PolylineOps.compressShortEdges]]
|
|
150
|
+
* @see [[cloneCompressed]], [[compressInPlace]], [[PolylineOps.compressShortEdges]].
|
|
141
151
|
*/
|
|
142
152
|
static createCompressed(source, tolerance = Geometry_1.Geometry.smallMetricDistance, result) {
|
|
143
153
|
const dupIndices = source.findOrderedDuplicates(tolerance, true);
|
|
@@ -171,9 +181,9 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
171
181
|
/**
|
|
172
182
|
* Compress the input array by removing successive duplicate points.
|
|
173
183
|
* * First and last points are always preserved.
|
|
174
|
-
* @param tolerance optional distance tol for compression (default [[Geometry.smallMetricDistance]])
|
|
184
|
+
* @param tolerance optional distance tol for compression (default [[Geometry.smallMetricDistance]]).
|
|
175
185
|
* @returns the instance array.
|
|
176
|
-
* @see [[createCompressed]], [[cloneCompressed]], [[PolylineOps.compressShortEdges]]
|
|
186
|
+
* @see [[createCompressed]], [[cloneCompressed]], [[PolylineOps.compressShortEdges]].
|
|
177
187
|
*/
|
|
178
188
|
compressInPlace(tolerance = Geometry_1.Geometry.smallMetricDistance) {
|
|
179
189
|
return GrowableXYZArray.createCompressed(this, tolerance, this);
|
|
@@ -204,23 +214,32 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
204
214
|
result.pushFrom(data);
|
|
205
215
|
return result;
|
|
206
216
|
}
|
|
207
|
-
/**
|
|
217
|
+
/**
|
|
218
|
+
* Create a new GrowableXYZArray capturing the provided data. The data is not copied, just referenced.
|
|
219
|
+
* @param data source data to capture.
|
|
220
|
+
* @returns a new GrowableXYZArray object that references the provided data.
|
|
221
|
+
*/
|
|
222
|
+
static createCapture(data) {
|
|
223
|
+
return new GrowableXYZArray(0, undefined, data);
|
|
224
|
+
}
|
|
225
|
+
/** Restructure MultiLineStringDataVariant as array of GrowableXYZArray. */
|
|
208
226
|
static createArrayOfGrowableXYZArray(data) {
|
|
209
227
|
const collector = new PointStreaming_1.PointStreamGrowableXYZArrayCollector();
|
|
210
228
|
PointStreaming_1.VariantPointDataStream.streamXYZ(data, collector);
|
|
211
229
|
return collector.claimArrayOfGrowableXYZArray();
|
|
212
230
|
}
|
|
213
|
-
/**
|
|
231
|
+
/** Push a point to the end of the array. */
|
|
214
232
|
push(toPush) {
|
|
215
233
|
this.pushXYZ(toPush.x, toPush.y, toPush.z);
|
|
216
234
|
}
|
|
217
|
-
/**
|
|
235
|
+
/** Push all points of an array. */
|
|
218
236
|
pushAll(points) {
|
|
219
237
|
this.ensureCapacity(this._xyzInUse + points.length, false);
|
|
220
238
|
for (const p of points)
|
|
221
239
|
this.push(p);
|
|
222
240
|
}
|
|
223
|
-
/**
|
|
241
|
+
/**
|
|
242
|
+
* Push copies of points from variant sources.
|
|
224
243
|
* Valid inputs are:
|
|
225
244
|
* * Point2d
|
|
226
245
|
* * Point3d
|
|
@@ -230,7 +249,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
230
249
|
* * Any json object satisfying Point3d.isXYAndZ
|
|
231
250
|
* * Any json object satisfying Point3d.isXAndY
|
|
232
251
|
* * A Float64Array of doubles, interpreted as xyzxyz
|
|
233
|
-
* * An array of any of the above
|
|
252
|
+
* * An array of any of the above.
|
|
234
253
|
*/
|
|
235
254
|
pushFrom(p) {
|
|
236
255
|
if (p instanceof Point3dVector3d_1.Point3d)
|
|
@@ -250,7 +269,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
250
269
|
else if (Geometry_1.Geometry.isNumberArray(p, 2))
|
|
251
270
|
this.pushXYZ(p[0], p[1], 0.0);
|
|
252
271
|
else if (Array.isArray(p)) {
|
|
253
|
-
// direct recursion re-wraps p and goes infinite
|
|
272
|
+
// direct recursion re-wraps p and goes infinite; unroll here.
|
|
254
273
|
for (const q of p)
|
|
255
274
|
this.pushFrom(q);
|
|
256
275
|
}
|
|
@@ -267,7 +286,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
267
286
|
}
|
|
268
287
|
/**
|
|
269
288
|
* Replicate numWrap xyz values from the front of the array as new values at the end.
|
|
270
|
-
* @param numWrap number of xyz values to replicate
|
|
289
|
+
* @param numWrap number of xyz values to replicate.
|
|
271
290
|
*/
|
|
272
291
|
pushWrap(numWrap) {
|
|
273
292
|
if (this._xyzInUse >= numWrap) {
|
|
@@ -278,7 +297,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
278
297
|
}
|
|
279
298
|
}
|
|
280
299
|
}
|
|
281
|
-
/**
|
|
300
|
+
/** Append a new point with given x,y,z. */
|
|
282
301
|
pushXYZ(x, y, z) {
|
|
283
302
|
this.ensureCapacity(this._xyzInUse + 1);
|
|
284
303
|
const index = this._xyzInUse * 3;
|
|
@@ -287,10 +306,11 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
287
306
|
this._data[index + 2] = z;
|
|
288
307
|
this._xyzInUse++;
|
|
289
308
|
}
|
|
290
|
-
/**
|
|
309
|
+
/**
|
|
310
|
+
* Shift all data forward to make space for numPoints at the front.
|
|
291
311
|
* * Leading (3*numPoints) doubles are left with prior contents.
|
|
292
|
-
* * _xyzInUse count is increased
|
|
293
|
-
|
|
312
|
+
* * _xyzInUse count is increased.
|
|
313
|
+
*/
|
|
294
314
|
shiftForward(numPoints) {
|
|
295
315
|
if (numPoints <= 0)
|
|
296
316
|
return;
|
|
@@ -300,7 +320,8 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
300
320
|
this._data.copyWithin(numAddedDouble, 0, lastIndex);
|
|
301
321
|
this._xyzInUse += numPoints;
|
|
302
322
|
}
|
|
303
|
-
/**
|
|
323
|
+
/**
|
|
324
|
+
* Prepend a new point with given x,y,z
|
|
304
325
|
* * Remark: this copies all content forward.
|
|
305
326
|
*/
|
|
306
327
|
pushFrontXYZ(x, y, z) {
|
|
@@ -309,13 +330,12 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
309
330
|
this._data[1] = y;
|
|
310
331
|
this._data[2] = z;
|
|
311
332
|
}
|
|
312
|
-
/**
|
|
313
|
-
*
|
|
314
|
-
*/
|
|
333
|
+
/** Prepend a new point at the front of the array. */
|
|
315
334
|
pushFront(toPush) {
|
|
316
335
|
this.pushFrontXYZ(toPush.x, toPush.y, toPush.z);
|
|
317
336
|
}
|
|
318
|
-
/**
|
|
337
|
+
/**
|
|
338
|
+
* Move the coordinates at fromIndex to toIndex.
|
|
319
339
|
* * No action if either index is invalid.
|
|
320
340
|
*/
|
|
321
341
|
moveIndexToIndex(fromIndex, toIndex) {
|
|
@@ -327,7 +347,8 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
327
347
|
this._data[iB] = this._data[iA];
|
|
328
348
|
}
|
|
329
349
|
}
|
|
330
|
-
/**
|
|
350
|
+
/**
|
|
351
|
+
* Remove one point from the back.
|
|
331
352
|
* * NOTE that (in the manner of std::vector native) this is "just" removing the point -- no point is NOT returned.
|
|
332
353
|
* * Use `back ()` to get the last x,y,z assembled into a `Point3d `
|
|
333
354
|
*/
|
|
@@ -335,40 +356,41 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
335
356
|
if (this._xyzInUse > 0)
|
|
336
357
|
this._xyzInUse--;
|
|
337
358
|
}
|
|
338
|
-
/**
|
|
339
|
-
* Clear all xyz data, but leave capacity unchanged.
|
|
340
|
-
*/
|
|
359
|
+
/** Clear all xyz data, but leave capacity unchanged. */
|
|
341
360
|
clear() {
|
|
342
361
|
this._xyzInUse = 0;
|
|
343
362
|
}
|
|
344
363
|
/**
|
|
345
|
-
* Get a point by index, strongly typed as a Point3d.
|
|
346
|
-
*
|
|
347
|
-
* @param
|
|
364
|
+
* Get a point by index, strongly typed as a Point3d. This is unchecked. Use [[getPoint3dAtCheckedPointIndex]] to
|
|
365
|
+
* have validity test.
|
|
366
|
+
* @param pointIndex index to access.
|
|
367
|
+
* @param result optional result.
|
|
348
368
|
*/
|
|
349
369
|
getPoint3dAtUncheckedPointIndex(pointIndex, result) {
|
|
350
370
|
const index = 3 * pointIndex;
|
|
351
371
|
return Point3dVector3d_1.Point3d.create(this._data[index], this._data[index + 1], this._data[index + 2], result);
|
|
352
372
|
}
|
|
353
373
|
/**
|
|
354
|
-
* Get a point by index, strongly typed as a Point2d. This is unchecked. Use [[getPoint2dAtCheckedPointIndex]] to
|
|
355
|
-
*
|
|
356
|
-
* @param
|
|
374
|
+
* Get a point by index, strongly typed as a Point2d. This is unchecked. Use [[getPoint2dAtCheckedPointIndex]] to
|
|
375
|
+
* have validity test.
|
|
376
|
+
* @param pointIndex index to access.
|
|
377
|
+
* @param result optional result.
|
|
357
378
|
*/
|
|
358
379
|
getPoint2dAtUncheckedPointIndex(pointIndex, result) {
|
|
359
380
|
const index = 3 * pointIndex;
|
|
360
381
|
return Point2dVector2d_1.Point2d.create(this._data[index], this._data[index + 1], result);
|
|
361
382
|
}
|
|
362
383
|
/**
|
|
363
|
-
* Get a vector by index, strongly typed as a Vector3d. This is unchecked. Use [[getVector3dAtCheckedVectorIndex]]
|
|
364
|
-
*
|
|
365
|
-
* @param
|
|
384
|
+
* Get a vector by index, strongly typed as a Vector3d. This is unchecked. Use [[getVector3dAtCheckedVectorIndex]]
|
|
385
|
+
* to have validity test.
|
|
386
|
+
* @param vectorIndex index to access.
|
|
387
|
+
* @param result optional result.
|
|
366
388
|
*/
|
|
367
389
|
getVector3dAtUncheckedVectorIndex(vectorIndex, result) {
|
|
368
390
|
const index = 3 * vectorIndex;
|
|
369
391
|
return Point3dVector3d_1.Vector3d.create(this._data[index], this._data[index + 1], this._data[index + 2], result);
|
|
370
392
|
}
|
|
371
|
-
/**
|
|
393
|
+
/** Copy xyz into strongly typed Point3d. */
|
|
372
394
|
getPoint3dAtCheckedPointIndex(pointIndex, result) {
|
|
373
395
|
if (this.isIndexValid(pointIndex)) {
|
|
374
396
|
const index = 3 * pointIndex;
|
|
@@ -376,22 +398,22 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
376
398
|
}
|
|
377
399
|
return undefined;
|
|
378
400
|
}
|
|
379
|
-
/**
|
|
401
|
+
/** Access x of indexed point. */
|
|
380
402
|
getXAtUncheckedPointIndex(pointIndex) {
|
|
381
403
|
const index = 3 * pointIndex;
|
|
382
404
|
return this._data[index];
|
|
383
405
|
}
|
|
384
|
-
/**
|
|
406
|
+
/** Access y of indexed point. */
|
|
385
407
|
getYAtUncheckedPointIndex(pointIndex) {
|
|
386
408
|
const index = 3 * pointIndex;
|
|
387
409
|
return this._data[index + 1];
|
|
388
410
|
}
|
|
389
|
-
/**
|
|
411
|
+
/** Access z of indexed point. */
|
|
390
412
|
getZAtUncheckedPointIndex(pointIndex) {
|
|
391
413
|
const index = 3 * pointIndex;
|
|
392
414
|
return this._data[index + 2];
|
|
393
415
|
}
|
|
394
|
-
/**
|
|
416
|
+
/** Copy xy into strongly typed Point2d. */
|
|
395
417
|
getPoint2dAtCheckedPointIndex(pointIndex, result) {
|
|
396
418
|
if (this.isIndexValid(pointIndex)) {
|
|
397
419
|
const index = 3 * pointIndex;
|
|
@@ -399,7 +421,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
399
421
|
}
|
|
400
422
|
return undefined;
|
|
401
423
|
}
|
|
402
|
-
/**
|
|
424
|
+
/** Copy xyz into strongly typed Vector3d. */
|
|
403
425
|
getVector3dAtCheckedVectorIndex(vectorIndex, result) {
|
|
404
426
|
if (this.isIndexValid(vectorIndex)) {
|
|
405
427
|
const index = 3 * vectorIndex;
|
|
@@ -409,9 +431,9 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
409
431
|
}
|
|
410
432
|
/**
|
|
411
433
|
* Read coordinates from source array, place them at index within this array.
|
|
412
|
-
* @param destIndex point index where coordinates are to be placed in this array
|
|
413
|
-
* @param source source array
|
|
414
|
-
* @param sourceIndex point index in source array
|
|
434
|
+
* @param destIndex point index where coordinates are to be placed in this array.
|
|
435
|
+
* @param source source array.
|
|
436
|
+
* @param sourceIndex point index in source array.
|
|
415
437
|
* @returns true if destIndex and sourceIndex are both valid.
|
|
416
438
|
*/
|
|
417
439
|
transferFromGrowableXYZArray(destIndex, source, sourceIndex) {
|
|
@@ -425,13 +447,13 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
425
447
|
return false;
|
|
426
448
|
}
|
|
427
449
|
/**
|
|
428
|
-
*
|
|
429
|
-
* @param source source array
|
|
430
|
-
* @param sourceIndex xyz index within the source.
|
|
450
|
+
* Push coordinates from the source array to the end of this array.
|
|
451
|
+
* @param source source array.
|
|
452
|
+
* @param sourceIndex xyz index within the source. If undefined, entire source is pushed.
|
|
431
453
|
* @returns number of points pushed.
|
|
432
454
|
*/
|
|
433
455
|
pushFromGrowableXYZArray(source, sourceIndex) {
|
|
434
|
-
// full array push
|
|
456
|
+
// full array push
|
|
435
457
|
if (sourceIndex === undefined) {
|
|
436
458
|
const numXYZAdd = source.length;
|
|
437
459
|
this.ensureCapacity(this.length + numXYZAdd, false);
|
|
@@ -439,7 +461,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
439
461
|
this._xyzInUse += numXYZAdd;
|
|
440
462
|
return numXYZAdd;
|
|
441
463
|
}
|
|
442
|
-
// single point push
|
|
464
|
+
// single point push
|
|
443
465
|
if (source.isIndexValid(sourceIndex)) {
|
|
444
466
|
const j = sourceIndex * 3;
|
|
445
467
|
this.pushXYZ(source._data[j], source._data[j + 1], source._data[j + 2]);
|
|
@@ -449,8 +471,8 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
449
471
|
}
|
|
450
472
|
/**
|
|
451
473
|
* Set the coordinates of a single point.
|
|
452
|
-
* @param pointIndex index of point to set
|
|
453
|
-
* @param value coordinates to set
|
|
474
|
+
* @param pointIndex index of point to set.
|
|
475
|
+
* @param value coordinates to set.
|
|
454
476
|
*/
|
|
455
477
|
setAtCheckedPointIndex(pointIndex, value) {
|
|
456
478
|
if (!this.isIndexValid(pointIndex))
|
|
@@ -462,11 +484,11 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
462
484
|
return true;
|
|
463
485
|
}
|
|
464
486
|
/**
|
|
465
|
-
* Set the coordinates of a single point given as coordinates
|
|
466
|
-
* @param pointIndex index of point to set
|
|
467
|
-
* @param x x coordinate
|
|
468
|
-
* @param y y coordinate
|
|
469
|
-
* @param z z coordinate
|
|
487
|
+
* Set the coordinates of a single point given as coordinates.
|
|
488
|
+
* @param pointIndex index of point to set.
|
|
489
|
+
* @param x x coordinate.
|
|
490
|
+
* @param y y coordinate.
|
|
491
|
+
* @param z z coordinate.
|
|
470
492
|
*/
|
|
471
493
|
setXYZAtCheckedPointIndex(pointIndex, x, y, z) {
|
|
472
494
|
if (!this.isIndexValid(pointIndex))
|
|
@@ -477,9 +499,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
477
499
|
this._data[index] = z;
|
|
478
500
|
return true;
|
|
479
501
|
}
|
|
480
|
-
/**
|
|
481
|
-
* Copy all points into a simple array of Point3d
|
|
482
|
-
*/
|
|
502
|
+
/** Copy all points into a simple array of Point3. */
|
|
483
503
|
getPoint3dArray() {
|
|
484
504
|
const n = 3 * this._xyzInUse;
|
|
485
505
|
const result = [];
|
|
@@ -488,7 +508,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
488
508
|
result.push(Point3dVector3d_1.Point3d.create(data[i], data[i + 1], data[i + 2]));
|
|
489
509
|
return result;
|
|
490
510
|
}
|
|
491
|
-
/**
|
|
511
|
+
/** Multiply each point by the transform, replace values. */
|
|
492
512
|
static multiplyTransformInPlace(transform, data) {
|
|
493
513
|
if (Array.isArray(data)) {
|
|
494
514
|
for (const d of data)
|
|
@@ -498,7 +518,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
498
518
|
data.multiplyTransformInPlace(transform);
|
|
499
519
|
}
|
|
500
520
|
}
|
|
501
|
-
/**
|
|
521
|
+
/** Multiply each point by the transform, replace values. */
|
|
502
522
|
multiplyTransformInPlace(transform) {
|
|
503
523
|
const data = this._data;
|
|
504
524
|
const nDouble = this.float64Length;
|
|
@@ -519,7 +539,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
519
539
|
data[i + 2] = coffs[6] * x + coffs[7] * y + coffs[8] * z + z0;
|
|
520
540
|
}
|
|
521
541
|
}
|
|
522
|
-
/**
|
|
542
|
+
/** Reverse the order of points. */
|
|
523
543
|
reverseInPlace() {
|
|
524
544
|
const n = this.length;
|
|
525
545
|
let j0, j1;
|
|
@@ -543,7 +563,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
543
563
|
data[j1] = a;
|
|
544
564
|
}
|
|
545
565
|
}
|
|
546
|
-
/**
|
|
566
|
+
/** Multiply each xyz (as a vector) by matrix, replace values. */
|
|
547
567
|
multiplyMatrix3dInPlace(matrix) {
|
|
548
568
|
const data = this._data;
|
|
549
569
|
const nDouble = this.float64Length;
|
|
@@ -560,9 +580,10 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
560
580
|
data[i + 2] = coffs[6] * x + coffs[7] * y + coffs[8] * z;
|
|
561
581
|
}
|
|
562
582
|
}
|
|
563
|
-
/**
|
|
564
|
-
*
|
|
565
|
-
*
|
|
583
|
+
/**
|
|
584
|
+
* Multiply each xyz (as a vector) by matrix inverse transpose, renormalize the vector, replace values.
|
|
585
|
+
* * This is the way to apply a matrix (possibly with skew and scale) to a surface normal, and have it end up
|
|
586
|
+
* perpendicular to the transformed in-surface vectors.
|
|
566
587
|
* * Return false if matrix is not invertible or if any normalization fails.
|
|
567
588
|
*/
|
|
568
589
|
multiplyAndRenormalizeMatrix3dInverseTransposeInPlace(matrix) {
|
|
@@ -590,7 +611,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
590
611
|
z1 = coffs[2] * x + coffs[5] * y + coffs[8] * z;
|
|
591
612
|
a = x1 * x1 + y1 * y1 + z1 * z1;
|
|
592
613
|
if (a < tol) {
|
|
593
|
-
// put the originals back
|
|
614
|
+
// put the originals back
|
|
594
615
|
x1 = x;
|
|
595
616
|
y1 = y;
|
|
596
617
|
z1 = z;
|
|
@@ -601,16 +622,14 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
601
622
|
x1 *= q;
|
|
602
623
|
y1 *= q;
|
|
603
624
|
z1 *= q;
|
|
604
|
-
} // else
|
|
625
|
+
} // else if q is near 1, no need to do the division
|
|
605
626
|
data[i] = x1;
|
|
606
627
|
data[i + 1] = y1;
|
|
607
628
|
data[i + 2] = z1;
|
|
608
629
|
}
|
|
609
630
|
return numFail === 0;
|
|
610
631
|
}
|
|
611
|
-
/**
|
|
612
|
-
*
|
|
613
|
-
*/
|
|
632
|
+
/** Multiply each xyz (as a point) by a homogeneous matrix and update as the normalized point. */
|
|
614
633
|
multiplyMatrix4dAndQuietRenormalizeMatrix4d(matrix) {
|
|
615
634
|
const data = this._data;
|
|
616
635
|
const nDouble = this.float64Length;
|
|
@@ -622,7 +641,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
622
641
|
data[i + 2] = xyz1.z;
|
|
623
642
|
}
|
|
624
643
|
}
|
|
625
|
-
/**
|
|
644
|
+
/** Multiply each point by the transform, replace values. */
|
|
626
645
|
tryTransformInverseInPlace(transform) {
|
|
627
646
|
const data = this._data;
|
|
628
647
|
const nDouble = this.float64Length;
|
|
@@ -661,7 +680,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
661
680
|
rangeToExtend.extendXYZ(data[i], data[i + 1], data[i + 2]);
|
|
662
681
|
}
|
|
663
682
|
}
|
|
664
|
-
/**
|
|
683
|
+
/** Get range of points. */
|
|
665
684
|
getRange(transform, result) {
|
|
666
685
|
let range = result;
|
|
667
686
|
if (range)
|
|
@@ -679,7 +698,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
679
698
|
/** Sum the lengths of segments between points. */
|
|
680
699
|
sumLengths() {
|
|
681
700
|
let sum = 0.0;
|
|
682
|
-
const n = 3 * (this._xyzInUse - 1); //
|
|
701
|
+
const n = 3 * (this._xyzInUse - 1); // length already takes into account what specifically is in use
|
|
683
702
|
const data = this._data;
|
|
684
703
|
for (let i = 0; i < n; i += 3)
|
|
685
704
|
sum += Geometry_1.Geometry.hypotenuseXYZ(data[i + 3] - data[i], data[i + 4] - data[i + 1], data[i + 5] - data[i + 2]);
|
|
@@ -687,7 +706,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
687
706
|
}
|
|
688
707
|
/**
|
|
689
708
|
* Multiply each x,y,z by the scale factor.
|
|
690
|
-
* @param factor
|
|
709
|
+
* @param factor scale factor.
|
|
691
710
|
*/
|
|
692
711
|
scaleInPlace(factor) {
|
|
693
712
|
if (this._data) {
|
|
@@ -696,7 +715,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
696
715
|
this._data[i] = this._data[i] * factor;
|
|
697
716
|
}
|
|
698
717
|
}
|
|
699
|
-
/**
|
|
718
|
+
/** Test if all points are within tolerance of a plane. */
|
|
700
719
|
isCloseToPlane(plane, tolerance = Geometry_1.Geometry.smallMetricDistance) {
|
|
701
720
|
const numCoordinate = 3 * this._xyzInUse;
|
|
702
721
|
const data = this._data;
|
|
@@ -707,13 +726,12 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
707
726
|
}
|
|
708
727
|
/**
|
|
709
728
|
* * If not already closed, push a copy of the first point.
|
|
710
|
-
* * If already closed within tolerance, force exact copy
|
|
711
|
-
* *
|
|
729
|
+
* * If already closed within tolerance, force exact copy.
|
|
730
|
+
* * Otherwise leave unchanged.
|
|
712
731
|
*/
|
|
713
732
|
forceClosure(tolerance = Geometry_1.Geometry.smallMetricDistance) {
|
|
714
733
|
const d = this.distanceIndexIndex(0, this.length - 1);
|
|
715
|
-
// leave the empty array alone
|
|
716
|
-
// Note that singleton will generate 0 distance and do nothing.
|
|
734
|
+
// leave the empty array alone; note that singleton will generate 0 distance and do nothing
|
|
717
735
|
if (d === undefined) {
|
|
718
736
|
}
|
|
719
737
|
else if (d > tolerance)
|
|
@@ -725,7 +743,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
725
743
|
this._data[i0 + i] = this._data[i];
|
|
726
744
|
}
|
|
727
745
|
}
|
|
728
|
-
/** Compute a point at fractional coordinate between points i and j */
|
|
746
|
+
/** Compute a point at fractional coordinate between points i and j. */
|
|
729
747
|
interpolate(i, fraction, j, result) {
|
|
730
748
|
if (this.isIndexValid(i) && this.isIndexValid(j)) {
|
|
731
749
|
const fraction0 = 1.0 - fraction;
|
|
@@ -736,10 +754,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
736
754
|
}
|
|
737
755
|
return undefined;
|
|
738
756
|
}
|
|
739
|
-
/**
|
|
740
|
-
* * Compute a point at fractional coordinate between points i and j of source
|
|
741
|
-
* * push onto this array.
|
|
742
|
-
*/
|
|
757
|
+
/** Compute a point at fractional coordinate between points i and j of source and push onto this array. */
|
|
743
758
|
pushInterpolatedFromGrowableXYZArray(source, i, fraction, j) {
|
|
744
759
|
if (source.isIndexValid(i) && source.isIndexValid(j)) {
|
|
745
760
|
const fraction0 = 1.0 - fraction;
|
|
@@ -749,10 +764,10 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
749
764
|
this.pushXYZ(fraction0 * data[i] + fraction * data[j], fraction0 * data[i + 1] + fraction * data[j + 1], fraction0 * data[i + 2] + fraction * data[j + 2]);
|
|
750
765
|
}
|
|
751
766
|
}
|
|
752
|
-
/** Sum the signed areas of the projection to xy plane */
|
|
767
|
+
/** Sum the signed areas of the projection to xy plane. */
|
|
753
768
|
areaXY() {
|
|
754
769
|
let area = 0.0;
|
|
755
|
-
const n = 3 * this._xyzInUse; // float count
|
|
770
|
+
const n = 3 * this._xyzInUse; // float count
|
|
756
771
|
if (n > 6) {
|
|
757
772
|
const x0 = this._data[n - 3];
|
|
758
773
|
const y0 = this._data[n - 2];
|
|
@@ -797,21 +812,21 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
797
812
|
}
|
|
798
813
|
return undefined;
|
|
799
814
|
}
|
|
800
|
-
/** Compute the dot product of pointIndex with [x,y,z] */
|
|
815
|
+
/** Compute the dot product of pointIndex with [x,y,z]. */
|
|
801
816
|
evaluateUncheckedIndexDotProductXYZ(pointIndex, x, y, z) {
|
|
802
817
|
const i = pointIndex * 3;
|
|
803
818
|
const data = this._data;
|
|
804
819
|
return data[i] * x + data[i + 1] * y + data[i + 2] * z;
|
|
805
820
|
}
|
|
806
|
-
/** Compute the dot product of pointIndex with [x,y,z] */
|
|
821
|
+
/** Compute the dot product of pointIndex with [x,y,z]. */
|
|
807
822
|
evaluateUncheckedIndexPlaneAltitude(pointIndex, plane) {
|
|
808
823
|
const i = pointIndex * 3;
|
|
809
824
|
const data = this._data;
|
|
810
825
|
return plane.altitudeXYZ(data[i], data[i + 1], data[i + 2]);
|
|
811
826
|
}
|
|
812
827
|
/**
|
|
813
|
-
*
|
|
814
|
-
* *
|
|
828
|
+
* Compute the cross product from indexed origin t indexed targets targetAIndex and targetB index.
|
|
829
|
+
* * Accumulate it to the result.
|
|
815
830
|
*/
|
|
816
831
|
accumulateCrossProductIndexIndexIndex(originIndex, targetAIndex, targetBIndex, result) {
|
|
817
832
|
if (this.isIndexValid(originIndex) && this.isIndexValid(targetAIndex) && this.isIndexValid(targetBIndex)) {
|
|
@@ -823,8 +838,8 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
823
838
|
}
|
|
824
839
|
}
|
|
825
840
|
/**
|
|
826
|
-
*
|
|
827
|
-
* *
|
|
841
|
+
* Compute the cross product from indexed origin t indexed targets targetAIndex and targetB index.
|
|
842
|
+
* * Accumulate it to the result.
|
|
828
843
|
*/
|
|
829
844
|
accumulateScaledXYZ(index, scale, sum) {
|
|
830
845
|
if (this.isIndexValid(index)) {
|
|
@@ -835,7 +850,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
835
850
|
sum.z += scale * data[i + 2];
|
|
836
851
|
}
|
|
837
852
|
}
|
|
838
|
-
/** Compute the cross product of vectors from from origin to indexed targets i and j */
|
|
853
|
+
/** Compute the cross product of vectors from from origin to indexed targets i and j. */
|
|
839
854
|
crossProductXYAndZIndexIndex(origin, targetAIndex, targetBIndex, result) {
|
|
840
855
|
if (this.isIndexValid(targetAIndex) && this.isIndexValid(targetBIndex)) {
|
|
841
856
|
const j = targetAIndex * 3;
|
|
@@ -855,8 +870,8 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
855
870
|
}
|
|
856
871
|
/**
|
|
857
872
|
* Return distance squared between indicated points.
|
|
858
|
-
* @param i first point index
|
|
859
|
-
* @param j second point index
|
|
873
|
+
* @param i first point index.
|
|
874
|
+
* @param j second point index.
|
|
860
875
|
*/
|
|
861
876
|
distanceSquaredIndexIndex(i, j) {
|
|
862
877
|
if (this.isIndexValid(i) && this.isIndexValid(j)) {
|
|
@@ -868,8 +883,8 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
868
883
|
}
|
|
869
884
|
/**
|
|
870
885
|
* Return distance between indicated points.
|
|
871
|
-
* @param i first point index
|
|
872
|
-
* @param j second point index
|
|
886
|
+
* @param i first point index.
|
|
887
|
+
* @param j second point index.
|
|
873
888
|
*/
|
|
874
889
|
distanceIndexIndex(i, j) {
|
|
875
890
|
if (this.isIndexValid(i) && this.isIndexValid(j)) {
|
|
@@ -888,7 +903,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
888
903
|
}
|
|
889
904
|
return undefined;
|
|
890
905
|
}
|
|
891
|
-
/**
|
|
906
|
+
/** Test for near equality between two `GrowableXYZArray`. */
|
|
892
907
|
static isAlmostEqual(dataA, dataB) {
|
|
893
908
|
if (dataA && dataB) {
|
|
894
909
|
if (dataA.length !== dataB.length)
|
|
@@ -901,7 +916,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
901
916
|
// if both are null it is equal, otherwise unequal
|
|
902
917
|
return (!dataA && !dataB);
|
|
903
918
|
}
|
|
904
|
-
/** Return an array of block indices sorted per compareLexicalBlock function */
|
|
919
|
+
/** Return an array of block indices sorted per compareLexicalBlock function. */
|
|
905
920
|
sortIndicesLexical() {
|
|
906
921
|
const n = this._xyzInUse;
|
|
907
922
|
// let numCompare = 0;
|
|
@@ -915,7 +930,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
915
930
|
// console.log (n, numCompare);
|
|
916
931
|
return result;
|
|
917
932
|
}
|
|
918
|
-
/**
|
|
933
|
+
/** Compare two blocks in simple lexical order. */
|
|
919
934
|
compareLexicalBlock(ia, ib) {
|
|
920
935
|
let ax = 0;
|
|
921
936
|
let bx = 0;
|
|
@@ -927,19 +942,13 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
927
942
|
if (ax < bx)
|
|
928
943
|
return -1;
|
|
929
944
|
}
|
|
930
|
-
return ia - ib; // so original order is maintained among duplicates
|
|
945
|
+
return ia - ib; // so original order is maintained among duplicates
|
|
931
946
|
}
|
|
932
|
-
/** Access a single double at offset within a block.
|
|
947
|
+
/** Access a single double at offset within a block. This has no index checking. */
|
|
933
948
|
component(pointIndex, componentIndex) {
|
|
934
949
|
return this._data[3 * pointIndex + componentIndex];
|
|
935
950
|
}
|
|
936
|
-
/**
|
|
937
|
-
* add points at regular steps from `other`
|
|
938
|
-
* @param source
|
|
939
|
-
* @param pointIndex0
|
|
940
|
-
* @param step
|
|
941
|
-
* @param numAdd
|
|
942
|
-
*/
|
|
951
|
+
/** Add points at regular steps from `other`. */
|
|
943
952
|
addSteppedPoints(other, pointIndex0, step, numAdd) {
|
|
944
953
|
const dataB = other._data;
|
|
945
954
|
let b0 = pointIndex0 * 3;
|
|
@@ -953,9 +962,9 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
953
962
|
}
|
|
954
963
|
}
|
|
955
964
|
/**
|
|
956
|
-
*
|
|
957
|
-
* @param arrayA first array
|
|
958
|
-
* @param arrayB second array
|
|
965
|
+
* Find the min and max distance between corresponding indexed points. Excess points are ignored.
|
|
966
|
+
* @param arrayA first array.
|
|
967
|
+
* @param arrayB second array.
|
|
959
968
|
*/
|
|
960
969
|
static distanceRangeBetweenCorrespondingPoints(arrayA, arrayB) {
|
|
961
970
|
const dataA = arrayA._data;
|
|
@@ -971,11 +980,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
971
980
|
}
|
|
972
981
|
return range;
|
|
973
982
|
}
|
|
974
|
-
/**
|
|
975
|
-
* remove trailing point(s) within tolerance of the start point.
|
|
976
|
-
* @param points
|
|
977
|
-
* @param tolerance
|
|
978
|
-
*/
|
|
983
|
+
/** Remove trailing point(s) within tolerance of the start point. */
|
|
979
984
|
static removeClosure(points, tolerance = Geometry_1.Geometry.smallMetricDistance) {
|
|
980
985
|
while (points.length > 1 && points.distanceIndexIndex(0, points.length - 1) < tolerance)
|
|
981
986
|
points.pop();
|
|
@@ -983,8 +988,8 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
983
988
|
/**
|
|
984
989
|
* Compute frame for a triangle formed by three (unchecked!) points identified by index.
|
|
985
990
|
* * z direction of frame is 001.
|
|
986
|
-
* * Transform axes from origin to targetA and targetB
|
|
987
|
-
* * in local coordinates (u,v,w) the xy interior of the triangle is `u>=0, v>= 0, w>= 0, u+v+w<1
|
|
991
|
+
* * Transform axes from origin to targetA and targetB.
|
|
992
|
+
* * in local coordinates (u,v,w) the xy interior of the triangle is `u>=0, v>= 0, w>= 0, u+v+w<1`.
|
|
988
993
|
* * Return undefined if transform is not invertible, e.g. if points are in a vertical plane.
|
|
989
994
|
*/
|
|
990
995
|
fillLocalXYTriangleFrame(originIndex, targetAIndex, targetBIndex, result) {
|
|
@@ -1010,7 +1015,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
1010
1015
|
/**
|
|
1011
1016
|
* Pass the (x,y,z) of each point to a function which returns a replacement for one of the 3 components.
|
|
1012
1017
|
* @param componentIndex Index (0,1,2) of component to be replaced.
|
|
1013
|
-
* @param func function to be called as `func(x,y,z)`, returning a replacement value for componentIndex
|
|
1018
|
+
* @param func function to be called as `func(x,y,z)`, returning a replacement value for componentIndex.
|
|
1014
1019
|
*/
|
|
1015
1020
|
mapComponent(componentIndex, func) {
|
|
1016
1021
|
const n = this._data.length;
|