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