@itwin/core-geometry 3.3.0-dev.8 → 3.3.0-dev.80
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 +26 -1
- package/lib/cjs/curve/Arc3d.d.ts +13 -2
- package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
- package/lib/cjs/curve/Arc3d.js +21 -3
- package/lib/cjs/curve/Arc3d.js.map +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +36 -2
- package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js +157 -7
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/cjs/curve/CurveCollection.d.ts +2 -0
- package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCollection.js +8 -0
- package/lib/cjs/curve/CurveCollection.js.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.d.ts +23 -0
- package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.js +65 -0
- package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
- package/lib/cjs/curve/LineSegment3d.d.ts +5 -0
- package/lib/cjs/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineSegment3d.js +21 -0
- package/lib/cjs/curve/LineSegment3d.js.map +1 -1
- package/lib/cjs/curve/LineString3d.d.ts +2 -0
- package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineString3d.js +28 -0
- package/lib/cjs/curve/LineString3d.js.map +1 -1
- package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts +2 -5
- package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/DirectSpiral3d.js +6 -8
- package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
- package/lib/cjs/curve/spiral/IntegratedSpiral3d.d.ts +0 -3
- package/lib/cjs/curve/spiral/IntegratedSpiral3d.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/IntegratedSpiral3d.js +0 -4
- package/lib/cjs/curve/spiral/IntegratedSpiral3d.js.map +1 -1
- package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts +7 -0
- package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/TransitionSpiral3d.js +17 -0
- package/lib/cjs/curve/spiral/TransitionSpiral3d.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableBlockedArray.d.ts +32 -3
- package/lib/cjs/geometry3d/GrowableBlockedArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableBlockedArray.js +63 -14
- package/lib/cjs/geometry3d/GrowableBlockedArray.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableFloat64Array.d.ts +24 -8
- package/lib/cjs/geometry3d/GrowableFloat64Array.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableFloat64Array.js +72 -54
- package/lib/cjs/geometry3d/GrowableFloat64Array.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.d.ts +51 -26
- package/lib/cjs/geometry3d/GrowableXYArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.js +136 -116
- package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts +35 -21
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.js +124 -137
- package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +2 -3
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.d.ts +8 -2
- package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.js +40 -3
- package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
- package/lib/cjs/geometry3d/Range.d.ts +12 -0
- package/lib/cjs/geometry3d/Range.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Range.js +32 -0
- package/lib/cjs/geometry3d/Range.js.map +1 -1
- package/lib/cjs/geometry3d/Transform.d.ts +1 -1
- package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Transform.js +1 -1
- package/lib/cjs/geometry3d/Transform.js.map +1 -1
- package/lib/cjs/geometry3d/XYZProps.d.ts +10 -3
- package/lib/cjs/geometry3d/XYZProps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/XYZProps.js +21 -0
- package/lib/cjs/geometry3d/XYZProps.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceClip.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceClip.js +1 -1
- package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.d.ts +4 -2
- package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js +10 -6
- package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/cjs/topology/Merging.js +3 -3
- package/lib/cjs/topology/Merging.js.map +1 -1
- package/lib/cjs/topology/Triangulation.d.ts +1 -3
- package/lib/cjs/topology/Triangulation.d.ts.map +1 -1
- package/lib/cjs/topology/Triangulation.js +31 -21
- package/lib/cjs/topology/Triangulation.js.map +1 -1
- package/lib/esm/curve/Arc3d.d.ts +13 -2
- package/lib/esm/curve/Arc3d.d.ts.map +1 -1
- package/lib/esm/curve/Arc3d.js +22 -4
- package/lib/esm/curve/Arc3d.js.map +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +36 -2
- package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.js +157 -7
- package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/esm/curve/CurveCollection.d.ts +2 -0
- package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
- package/lib/esm/curve/CurveCollection.js +8 -0
- package/lib/esm/curve/CurveCollection.js.map +1 -1
- package/lib/esm/curve/CurvePrimitive.d.ts +23 -0
- package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/esm/curve/CurvePrimitive.js +65 -0
- package/lib/esm/curve/CurvePrimitive.js.map +1 -1
- package/lib/esm/curve/LineSegment3d.d.ts +5 -0
- package/lib/esm/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/esm/curve/LineSegment3d.js +21 -0
- package/lib/esm/curve/LineSegment3d.js.map +1 -1
- package/lib/esm/curve/LineString3d.d.ts +2 -0
- package/lib/esm/curve/LineString3d.d.ts.map +1 -1
- package/lib/esm/curve/LineString3d.js +28 -0
- package/lib/esm/curve/LineString3d.js.map +1 -1
- package/lib/esm/curve/spiral/DirectSpiral3d.d.ts +2 -5
- package/lib/esm/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
- package/lib/esm/curve/spiral/DirectSpiral3d.js +6 -8
- package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
- package/lib/esm/curve/spiral/IntegratedSpiral3d.d.ts +0 -3
- package/lib/esm/curve/spiral/IntegratedSpiral3d.d.ts.map +1 -1
- package/lib/esm/curve/spiral/IntegratedSpiral3d.js +0 -4
- package/lib/esm/curve/spiral/IntegratedSpiral3d.js.map +1 -1
- package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts +7 -0
- package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
- package/lib/esm/curve/spiral/TransitionSpiral3d.js +17 -0
- package/lib/esm/curve/spiral/TransitionSpiral3d.js.map +1 -1
- package/lib/esm/geometry3d/GrowableBlockedArray.d.ts +32 -3
- package/lib/esm/geometry3d/GrowableBlockedArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableBlockedArray.js +63 -14
- package/lib/esm/geometry3d/GrowableBlockedArray.js.map +1 -1
- package/lib/esm/geometry3d/GrowableFloat64Array.d.ts +24 -8
- package/lib/esm/geometry3d/GrowableFloat64Array.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableFloat64Array.js +72 -54
- package/lib/esm/geometry3d/GrowableFloat64Array.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.d.ts +51 -26
- package/lib/esm/geometry3d/GrowableXYArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.js +136 -116
- package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts +35 -21
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.js +124 -137
- package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +2 -3
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.d.ts +8 -2
- package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.js +40 -3
- package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
- package/lib/esm/geometry3d/Range.d.ts +12 -0
- package/lib/esm/geometry3d/Range.d.ts.map +1 -1
- package/lib/esm/geometry3d/Range.js +32 -0
- package/lib/esm/geometry3d/Range.js.map +1 -1
- package/lib/esm/geometry3d/Transform.d.ts +1 -1
- package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
- package/lib/esm/geometry3d/Transform.js +1 -1
- package/lib/esm/geometry3d/Transform.js.map +1 -1
- package/lib/esm/geometry3d/XYZProps.d.ts +10 -3
- package/lib/esm/geometry3d/XYZProps.d.ts.map +1 -1
- package/lib/esm/geometry3d/XYZProps.js +20 -1
- package/lib/esm/geometry3d/XYZProps.js.map +1 -1
- package/lib/esm/polyface/PolyfaceClip.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceClip.js +1 -1
- package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.d.ts +4 -2
- package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js +10 -6
- package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/esm/topology/Merging.js +3 -3
- package/lib/esm/topology/Merging.js.map +1 -1
- package/lib/esm/topology/Triangulation.d.ts +1 -3
- package/lib/esm/topology/Triangulation.d.ts.map +1 -1
- package/lib/esm/topology/Triangulation.js +31 -21
- package/lib/esm/topology/Triangulation.js.map +1 -1
- package/package.json +7 -7
|
@@ -19,59 +19,81 @@ const Transform_1 = require("./Transform");
|
|
|
19
19
|
*/
|
|
20
20
|
class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollection {
|
|
21
21
|
/** Construct a new GrowablePoint3d array.
|
|
22
|
-
* @param numPoints
|
|
22
|
+
* @param numPoints initial capacity in xyz triples (default 8)
|
|
23
|
+
* @param growthFactor used by ensureCapacity to expand requested reallocation size (default 1.5)
|
|
23
24
|
*/
|
|
24
|
-
constructor(numPoints = 8) {
|
|
25
|
+
constructor(numPoints = 8, growthFactor) {
|
|
25
26
|
super();
|
|
26
|
-
this._data = new Float64Array(numPoints * 3); //
|
|
27
|
+
this._data = new Float64Array(numPoints * 3); // 3 values per point
|
|
27
28
|
this._xyzInUse = 0;
|
|
28
29
|
this._xyzCapacity = numPoints;
|
|
30
|
+
this._growthFactor = (undefined !== growthFactor && growthFactor >= 1.0) ? growthFactor : 1.5;
|
|
31
|
+
}
|
|
32
|
+
/** Copy xyz points from source array. Does not reallocate or change active point count.
|
|
33
|
+
* @param source array to copy from
|
|
34
|
+
* @param sourceCount copy the first sourceCount points; all points if undefined
|
|
35
|
+
* @param destOffset copy to instance array starting at this point index; zero if undefined
|
|
36
|
+
* @return count and offset of points copied
|
|
37
|
+
*/
|
|
38
|
+
copyData(source, sourceCount, destOffset) {
|
|
39
|
+
// validate inputs and convert from points to entries
|
|
40
|
+
let myOffset = (undefined !== destOffset) ? destOffset * 3 : 0;
|
|
41
|
+
if (myOffset < 0)
|
|
42
|
+
myOffset = 0;
|
|
43
|
+
if (myOffset >= this._data.length)
|
|
44
|
+
return { count: 0, offset: 0 };
|
|
45
|
+
let myCount = (undefined !== sourceCount) ? sourceCount * 3 : source.length;
|
|
46
|
+
if (myCount > 0) {
|
|
47
|
+
if (myCount > source.length)
|
|
48
|
+
myCount = source.length;
|
|
49
|
+
if (myOffset + myCount > this._data.length)
|
|
50
|
+
myCount = this._data.length - myOffset;
|
|
51
|
+
if (myCount % 3 !== 0)
|
|
52
|
+
myCount -= myCount % 3;
|
|
53
|
+
}
|
|
54
|
+
if (myCount <= 0)
|
|
55
|
+
return { count: 0, offset: 0 };
|
|
56
|
+
if (myCount === source.length)
|
|
57
|
+
this._data.set(source, myOffset);
|
|
58
|
+
else if (source instanceof Float64Array)
|
|
59
|
+
this._data.set(source.subarray(0, myCount), myOffset);
|
|
60
|
+
else
|
|
61
|
+
this._data.set(source.slice(0, myCount), myOffset);
|
|
62
|
+
return { count: myCount / 3, offset: myOffset / 3 };
|
|
29
63
|
}
|
|
30
64
|
/** The number of points in use. When the length is increased, the array is padded with zeroes. */
|
|
31
65
|
get length() { return this._xyzInUse; }
|
|
32
|
-
set length(newLength) {
|
|
33
|
-
let oldLength = this.length;
|
|
34
|
-
if (newLength < oldLength) {
|
|
35
|
-
this._xyzInUse = newLength;
|
|
36
|
-
}
|
|
37
|
-
else if (newLength > oldLength) {
|
|
38
|
-
this.ensureCapacity(newLength);
|
|
39
|
-
while (oldLength++ < newLength)
|
|
40
|
-
this.pushXYZ(0, 0, 0);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
66
|
+
set length(newLength) { this.resize(newLength, true); }
|
|
43
67
|
/** Return the number of float64 in use. */
|
|
44
68
|
get float64Length() { return this._xyzInUse * 3; }
|
|
45
69
|
/** Return the raw packed data.
|
|
46
70
|
* * Note that the length of the returned Float64Array is a count of doubles, and includes the excess capacity
|
|
47
71
|
*/
|
|
48
72
|
float64Data() { return this._data; }
|
|
49
|
-
/** If necessary, increase the capacity to
|
|
50
|
-
ensureCapacity(pointCapacity) {
|
|
73
|
+
/** If necessary, increase the capacity to the new number of points. Current coordinates and point count (length) are unchanged. */
|
|
74
|
+
ensureCapacity(pointCapacity, applyGrowthFactor = true) {
|
|
51
75
|
if (pointCapacity > this._xyzCapacity) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.
|
|
76
|
+
if (applyGrowthFactor)
|
|
77
|
+
pointCapacity *= this._growthFactor;
|
|
78
|
+
const prevData = this._data;
|
|
79
|
+
this._data = new Float64Array(pointCapacity * 3);
|
|
80
|
+
this.copyData(prevData, this._xyzInUse);
|
|
57
81
|
this._xyzCapacity = pointCapacity;
|
|
58
82
|
}
|
|
59
83
|
}
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
this._data = newArray;
|
|
74
|
-
this._xyzCapacity = pointCount;
|
|
84
|
+
/**
|
|
85
|
+
* * If pointCount is less than current length, just reset current length to pointCount, effectively trimming active points but preserving original capacity.
|
|
86
|
+
* * If pointCount is greater than current length, reallocate to exactly pointCount, copy existing points, and optionally pad excess with zero.
|
|
87
|
+
* @param pointCount new number of active points in array
|
|
88
|
+
* @param padWithZero when increasing point count, whether to zero out new points (default false)
|
|
89
|
+
*/
|
|
90
|
+
resize(pointCount, padWithZero) {
|
|
91
|
+
if (pointCount >= 0 && pointCount < this._xyzInUse)
|
|
92
|
+
this._xyzInUse = pointCount;
|
|
93
|
+
else if (pointCount > this._xyzInUse) {
|
|
94
|
+
this.ensureCapacity(pointCount, false);
|
|
95
|
+
if (padWithZero !== null && padWithZero !== void 0 ? padWithZero : false)
|
|
96
|
+
this._data.fill(0, this._xyzInUse * 3);
|
|
75
97
|
this._xyzInUse = pointCount;
|
|
76
98
|
}
|
|
77
99
|
}
|
|
@@ -80,17 +102,14 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
80
102
|
* (The clone does NOT get excess capacity)
|
|
81
103
|
*/
|
|
82
104
|
clone(result) {
|
|
83
|
-
const numValue = this.length * 3;
|
|
84
105
|
if (!result)
|
|
85
106
|
result = new GrowableXYZArray(this.length);
|
|
86
107
|
else {
|
|
87
|
-
result.
|
|
88
|
-
|
|
108
|
+
if (result.length !== this.length)
|
|
109
|
+
result.clear(); // force resize to trim excess capacity
|
|
110
|
+
result.resize(this.length);
|
|
89
111
|
}
|
|
90
|
-
|
|
91
|
-
const data = this._data;
|
|
92
|
-
for (let i = 0; i < numValue; i++)
|
|
93
|
-
newData[i] = data[i];
|
|
112
|
+
result.copyData(this._data, this.length);
|
|
94
113
|
result._xyzInUse = this.length;
|
|
95
114
|
return result;
|
|
96
115
|
}
|
|
@@ -125,6 +144,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
125
144
|
}
|
|
126
145
|
/** push all points of an array */
|
|
127
146
|
pushAll(points) {
|
|
147
|
+
this.ensureCapacity(this._xyzInUse + points.length, false);
|
|
128
148
|
for (const p of points)
|
|
129
149
|
this.push(p);
|
|
130
150
|
}
|
|
@@ -139,7 +159,6 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
139
159
|
* * Any json object satisfying Point3d.isXAndY
|
|
140
160
|
* * A Float64Array of doubles, interpreted as xyzxyz
|
|
141
161
|
* * An array of any of the above
|
|
142
|
-
* @returns the number of points added.
|
|
143
162
|
*/
|
|
144
163
|
pushFrom(p) {
|
|
145
164
|
if (p instanceof Point3dVector3d_1.Point3d)
|
|
@@ -148,10 +167,11 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
148
167
|
this.pushFromGrowableXYZArray(p);
|
|
149
168
|
else if (p instanceof Point2dVector2d_1.Point2d)
|
|
150
169
|
this.pushXYZ(p.x, p.y, 0.0);
|
|
151
|
-
else if (Geometry_1.Geometry.isNumberArray(p, 4)) {
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
170
|
+
else if (Geometry_1.Geometry.isNumberArray(p, 4) || p instanceof Float64Array) {
|
|
171
|
+
const xyzToAdd = Math.trunc(p.length / 3);
|
|
172
|
+
this.ensureCapacity(this._xyzInUse + xyzToAdd, false);
|
|
173
|
+
this.copyData(p, xyzToAdd, this._xyzInUse);
|
|
174
|
+
this._xyzInUse += xyzToAdd;
|
|
155
175
|
}
|
|
156
176
|
else if (Geometry_1.Geometry.isNumberArray(p, 3))
|
|
157
177
|
this.pushXYZ(p[0], p[1], p[2]);
|
|
@@ -166,13 +186,10 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
166
186
|
this.pushXYZ(p.x, p.y, p.z);
|
|
167
187
|
else if (Point3dVector3d_1.Point3d.isXAndY(p))
|
|
168
188
|
this.pushXYZ(p.x, p.y, 0.0);
|
|
169
|
-
else if (p instanceof Float64Array) {
|
|
170
|
-
const n = p.length;
|
|
171
|
-
for (let i = 0; i + 2 < n; i += 3)
|
|
172
|
-
this.pushXYZ(p[i], p[i + 1], p[i + 2]);
|
|
173
|
-
}
|
|
174
189
|
else if (p instanceof IndexedXYZCollection_1.IndexedXYZCollection) {
|
|
175
|
-
|
|
190
|
+
const n = p.length;
|
|
191
|
+
this.ensureCapacity(this._xyzInUse + n, false);
|
|
192
|
+
for (let i = 0; i < n; i++)
|
|
176
193
|
this.pushXYZ(p.getXAtUncheckedPointIndex(i), p.getYAtUncheckedPointIndex(i), p.getZAtUncheckedPointIndex(i));
|
|
177
194
|
}
|
|
178
195
|
}
|
|
@@ -181,19 +198,18 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
181
198
|
* @param numWrap number of xyz values to replicate
|
|
182
199
|
*/
|
|
183
200
|
pushWrap(numWrap) {
|
|
184
|
-
if (this._xyzInUse
|
|
185
|
-
|
|
201
|
+
if (this._xyzInUse >= numWrap) {
|
|
202
|
+
this.ensureCapacity(this._xyzInUse + numWrap, false);
|
|
186
203
|
for (let i = 0; i < numWrap; i++) {
|
|
187
|
-
k = 3 * i;
|
|
204
|
+
const k = 3 * i;
|
|
188
205
|
this.pushXYZ(this._data[k], this._data[k + 1], this._data[k + 2]);
|
|
189
206
|
}
|
|
190
207
|
}
|
|
191
208
|
}
|
|
192
209
|
/** append a new point with given x,y,z */
|
|
193
210
|
pushXYZ(x, y, z) {
|
|
211
|
+
this.ensureCapacity(this._xyzInUse + 1);
|
|
194
212
|
const index = this._xyzInUse * 3;
|
|
195
|
-
if (index >= this._data.length)
|
|
196
|
-
this.ensureCapacity(this.length === 0 ? 4 : this.length * 2);
|
|
197
213
|
this._data[index] = x;
|
|
198
214
|
this._data[index + 1] = y;
|
|
199
215
|
this._data[index + 2] = z;
|
|
@@ -206,11 +222,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
206
222
|
shiftForward(numPoints) {
|
|
207
223
|
if (numPoints <= 0)
|
|
208
224
|
return;
|
|
209
|
-
|
|
210
|
-
if (newCapacity > this._xyzCapacity) {
|
|
211
|
-
newCapacity = Math.max(4, 2 * this._xyzCapacity);
|
|
212
|
-
this.ensureCapacity(newCapacity);
|
|
213
|
-
}
|
|
225
|
+
this.ensureCapacity(this._xyzInUse + numPoints);
|
|
214
226
|
const numAddedDouble = 3 * numPoints;
|
|
215
227
|
const lastIndex = this._xyzInUse * 3;
|
|
216
228
|
this._data.copyWithin(numAddedDouble, 0, lastIndex);
|
|
@@ -286,14 +298,9 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
286
298
|
}
|
|
287
299
|
/** copy xyz into strongly typed Point3d */
|
|
288
300
|
getPoint3dAtCheckedPointIndex(pointIndex, result) {
|
|
289
|
-
const index = 3 * pointIndex;
|
|
290
301
|
if (this.isIndexValid(pointIndex)) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
result.x = this._data[index];
|
|
294
|
-
result.y = this._data[index + 1];
|
|
295
|
-
result.z = this._data[index + 2];
|
|
296
|
-
return result;
|
|
302
|
+
const index = 3 * pointIndex;
|
|
303
|
+
return Point3dVector3d_1.Point3d.create(this._data[index], this._data[index + 1], this._data[index + 2], result);
|
|
297
304
|
}
|
|
298
305
|
return undefined;
|
|
299
306
|
}
|
|
@@ -314,26 +321,17 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
314
321
|
}
|
|
315
322
|
/** copy xy into strongly typed Point2d */
|
|
316
323
|
getPoint2dAtCheckedPointIndex(pointIndex, result) {
|
|
317
|
-
const index = 3 * pointIndex;
|
|
318
324
|
if (this.isIndexValid(pointIndex)) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
result.x = this._data[index];
|
|
322
|
-
result.y = this._data[index + 1];
|
|
323
|
-
return result;
|
|
325
|
+
const index = 3 * pointIndex;
|
|
326
|
+
return Point2dVector2d_1.Point2d.create(this._data[index], this._data[index + 1], result);
|
|
324
327
|
}
|
|
325
328
|
return undefined;
|
|
326
329
|
}
|
|
327
330
|
/** copy xyz into strongly typed Vector3d */
|
|
328
331
|
getVector3dAtCheckedVectorIndex(vectorIndex, result) {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
result = Point3dVector3d_1.Vector3d.create();
|
|
333
|
-
result.x = this._data[index];
|
|
334
|
-
result.y = this._data[index + 1];
|
|
335
|
-
result.z = this._data[index + 2];
|
|
336
|
-
return result;
|
|
332
|
+
if (this.isIndexValid(vectorIndex)) {
|
|
333
|
+
const index = 3 * vectorIndex;
|
|
334
|
+
return Point3dVector3d_1.Vector3d.create(this._data[index], this._data[index + 1], this._data[index + 2], result);
|
|
337
335
|
}
|
|
338
336
|
return undefined;
|
|
339
337
|
}
|
|
@@ -365,11 +363,8 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
365
363
|
// full array push . . .
|
|
366
364
|
if (sourceIndex === undefined) {
|
|
367
365
|
const numXYZAdd = source.length;
|
|
368
|
-
this.ensureCapacity(this.length + numXYZAdd);
|
|
369
|
-
|
|
370
|
-
const i0 = this._xyzInUse * 3;
|
|
371
|
-
for (let i = 0; i < nXAdd; i++)
|
|
372
|
-
this._data[i0 + i] = source._data[i];
|
|
366
|
+
this.ensureCapacity(this.length + numXYZAdd, false);
|
|
367
|
+
this.copyData(source._data, numXYZAdd, this.length);
|
|
373
368
|
this._xyzInUse += numXYZAdd;
|
|
374
369
|
return numXYZAdd;
|
|
375
370
|
}
|
|
@@ -431,12 +426,11 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
431
426
|
* Copy all points into a simple array of Point3d
|
|
432
427
|
*/
|
|
433
428
|
getPoint3dArray() {
|
|
429
|
+
const n = 3 * this._xyzInUse;
|
|
434
430
|
const result = [];
|
|
435
431
|
const data = this._data;
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
result.push(Point3dVector3d_1.Point3d.create(data[i * 3], data[i * 3 + 1], data[i * 3 + 2]));
|
|
439
|
-
}
|
|
432
|
+
for (let i = 0; i < n; i += 3)
|
|
433
|
+
result.push(Point3dVector3d_1.Point3d.create(data[i], data[i + 1], data[i + 2]));
|
|
440
434
|
return result;
|
|
441
435
|
}
|
|
442
436
|
/** multiply each point by the transform, replace values. */
|
|
@@ -589,7 +583,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
589
583
|
let x = 0;
|
|
590
584
|
let y = 0;
|
|
591
585
|
let z = 0;
|
|
592
|
-
for (let i = 0; i +
|
|
586
|
+
for (let i = 0; i + 2 < nDouble; i += 3) {
|
|
593
587
|
x = data[i] - x0;
|
|
594
588
|
y = data[i + 1] - y0;
|
|
595
589
|
z = data[i + 2] - z0;
|
|
@@ -604,11 +598,11 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
604
598
|
const numDouble = this.float64Length;
|
|
605
599
|
const data = this._data;
|
|
606
600
|
if (transform) {
|
|
607
|
-
for (let i = 0; i +
|
|
601
|
+
for (let i = 0; i + 2 < numDouble; i += 3)
|
|
608
602
|
rangeToExtend.extendTransformedXYZ(transform, data[i], data[i + 1], data[i + 2]);
|
|
609
603
|
}
|
|
610
604
|
else {
|
|
611
|
-
for (let i = 0; i +
|
|
605
|
+
for (let i = 0; i + 2 < numDouble; i += 3)
|
|
612
606
|
rangeToExtend.extendXYZ(data[i], data[i + 1], data[i + 2]);
|
|
613
607
|
}
|
|
614
608
|
}
|
|
@@ -719,15 +713,10 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
719
713
|
vectorIndexIndex(i, j, result) {
|
|
720
714
|
if (!this.isIndexValid(i) || !this.isIndexValid(j))
|
|
721
715
|
return undefined;
|
|
722
|
-
if (!result)
|
|
723
|
-
result = Point3dVector3d_1.Vector3d.create();
|
|
724
716
|
const data = this._data;
|
|
725
717
|
i = 3 * i;
|
|
726
718
|
j = 3 * j;
|
|
727
|
-
|
|
728
|
-
result.y = data[j + 1] - data[i + 1];
|
|
729
|
-
result.z = data[j + 2] - data[i + 2];
|
|
730
|
-
return result;
|
|
719
|
+
return Point3dVector3d_1.Vector3d.create(data[j] - data[i], data[j + 1] - data[i + 1], data[j + 2] - data[i + 2], result);
|
|
731
720
|
}
|
|
732
721
|
/** Compute a vector from origin to indexed target j */
|
|
733
722
|
vectorXYAndZIndex(origin, j, result) {
|
|
@@ -740,12 +729,13 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
740
729
|
}
|
|
741
730
|
/** Compute the cross product of vectors from from indexed origin to indexed targets i and j */
|
|
742
731
|
crossProductIndexIndexIndex(originIndex, targetAIndex, targetBIndex, result) {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
732
|
+
if (this.isIndexValid(originIndex) && this.isIndexValid(targetAIndex) && this.isIndexValid(targetBIndex)) {
|
|
733
|
+
const i = originIndex * 3;
|
|
734
|
+
const j = targetAIndex * 3;
|
|
735
|
+
const k = targetBIndex * 3;
|
|
736
|
+
const data = this._data;
|
|
748
737
|
return Geometry_1.Geometry.crossProductXYZXYZ(data[j] - data[i], data[j + 1] - data[i + 1], data[j + 2] - data[i + 2], data[k] - data[i], data[k + 1] - data[i + 1], data[k + 2] - data[i + 2], result);
|
|
738
|
+
}
|
|
749
739
|
return undefined;
|
|
750
740
|
}
|
|
751
741
|
/** Compute the dot product of pointIndex with [x,y,z] */
|
|
@@ -765,22 +755,22 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
765
755
|
* * accumulate it to the result.
|
|
766
756
|
*/
|
|
767
757
|
accumulateCrossProductIndexIndexIndex(originIndex, targetAIndex, targetBIndex, result) {
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
758
|
+
if (this.isIndexValid(originIndex) && this.isIndexValid(targetAIndex) && this.isIndexValid(targetBIndex)) {
|
|
759
|
+
const i = originIndex * 3;
|
|
760
|
+
const j = targetAIndex * 3;
|
|
761
|
+
const k = targetBIndex * 3;
|
|
762
|
+
const data = this._data;
|
|
773
763
|
result.addCrossProductToTargetsInPlace(data[i], data[i + 1], data[i + 2], data[j], data[j + 1], data[j + 2], data[k], data[k + 1], data[k + 2]);
|
|
774
|
-
|
|
764
|
+
}
|
|
775
765
|
}
|
|
776
766
|
/**
|
|
777
767
|
* * compute the cross product from indexed origin t indexed targets targetAIndex and targetB index.
|
|
778
768
|
* * accumulate it to the result.
|
|
779
769
|
*/
|
|
780
770
|
accumulateScaledXYZ(index, scale, sum) {
|
|
781
|
-
const i = index * 3;
|
|
782
|
-
const data = this._data;
|
|
783
771
|
if (this.isIndexValid(index)) {
|
|
772
|
+
const i = index * 3;
|
|
773
|
+
const data = this._data;
|
|
784
774
|
sum.x += scale * data[i];
|
|
785
775
|
sum.y += scale * data[i + 1];
|
|
786
776
|
sum.z += scale * data[i + 2];
|
|
@@ -788,16 +778,17 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
788
778
|
}
|
|
789
779
|
/** Compute the cross product of vectors from from origin to indexed targets i and j */
|
|
790
780
|
crossProductXYAndZIndexIndex(origin, targetAIndex, targetBIndex, result) {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
781
|
+
if (this.isIndexValid(targetAIndex) && this.isIndexValid(targetBIndex)) {
|
|
782
|
+
const j = targetAIndex * 3;
|
|
783
|
+
const k = targetBIndex * 3;
|
|
784
|
+
const data = this._data;
|
|
795
785
|
return Geometry_1.Geometry.crossProductXYZXYZ(data[j] - origin.x, data[j + 1] - origin.y, data[j + 2] - origin.z, data[k] - origin.x, data[k + 1] - origin.y, data[k + 2] - origin.z, result);
|
|
786
|
+
}
|
|
796
787
|
return undefined;
|
|
797
788
|
}
|
|
798
789
|
/** Return the distance between an array point and the input point. */
|
|
799
790
|
distanceIndexToPoint(i, spacePoint) {
|
|
800
|
-
if (
|
|
791
|
+
if (this.isIndexValid(i)) {
|
|
801
792
|
const i0 = 3 * i;
|
|
802
793
|
return Geometry_1.Geometry.hypotenuseXYZ(spacePoint.x - this._data[i0], spacePoint.y - this._data[i0 + 1], spacePoint.z - this._data[i0 + 2]);
|
|
803
794
|
}
|
|
@@ -805,14 +796,11 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
805
796
|
}
|
|
806
797
|
/**
|
|
807
798
|
* Return distance squared between indicated points.
|
|
808
|
-
*
|
|
809
|
-
* @param
|
|
810
|
-
* @param index1 second point index
|
|
811
|
-
* @param defaultDistanceSquared distance squared to return if either point index is invalid.
|
|
812
|
-
*
|
|
799
|
+
* @param i first point index
|
|
800
|
+
* @param j second point index
|
|
813
801
|
*/
|
|
814
802
|
distanceSquaredIndexIndex(i, j) {
|
|
815
|
-
if (i
|
|
803
|
+
if (this.isIndexValid(i) && this.isIndexValid(j)) {
|
|
816
804
|
const i0 = 3 * i;
|
|
817
805
|
const j0 = 3 * j;
|
|
818
806
|
return Geometry_1.Geometry.hypotenuseSquaredXYZ(this._data[j0] - this._data[i0], this._data[j0 + 1] - this._data[i0 + 1], this._data[j0 + 2] - this._data[i0 + 2]);
|
|
@@ -821,13 +809,11 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
821
809
|
}
|
|
822
810
|
/**
|
|
823
811
|
* Return distance between indicated points.
|
|
824
|
-
*
|
|
825
|
-
* @param
|
|
826
|
-
* @param index1 second point index
|
|
827
|
-
* @param defaultDistanceSquared distance squared to return if either point index is invalid.
|
|
812
|
+
* @param i first point index
|
|
813
|
+
* @param j second point index
|
|
828
814
|
*/
|
|
829
815
|
distanceIndexIndex(i, j) {
|
|
830
|
-
if (i
|
|
816
|
+
if (this.isIndexValid(i) && this.isIndexValid(j)) {
|
|
831
817
|
const i0 = 3 * i;
|
|
832
818
|
const j0 = 3 * j;
|
|
833
819
|
return Geometry_1.Geometry.hypotenuseXYZ(this._data[j0] - this._data[i0], this._data[j0 + 1] - this._data[i0 + 1], this._data[j0 + 2] - this._data[i0 + 2]);
|
|
@@ -836,7 +822,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
836
822
|
}
|
|
837
823
|
/** Return the distance between points in distinct arrays. */
|
|
838
824
|
static distanceBetweenPointsIn2Arrays(arrayA, i, arrayB, j) {
|
|
839
|
-
if (
|
|
825
|
+
if (arrayA.isIndexValid(i) && arrayB.isIndexValid(j)) {
|
|
840
826
|
const i0 = 3 * i;
|
|
841
827
|
const j0 = 3 * j;
|
|
842
828
|
return Geometry_1.Geometry.hypotenuseXYZ(arrayB._data[j0] - arrayA._data[i0], arrayB._data[j0 + 1] - arrayA._data[i0 + 1], arrayB._data[j0 + 2] - arrayA._data[i0 + 2]);
|
|
@@ -900,6 +886,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
900
886
|
let b0 = pointIndex0 * 3;
|
|
901
887
|
const nb = other.length * 3;
|
|
902
888
|
let numAdded = 0;
|
|
889
|
+
this.ensureCapacity(this._xyzInUse + numAdd, false);
|
|
903
890
|
while (b0 >= 0 && b0 + 2 < nb && numAdded < numAdd) {
|
|
904
891
|
this.pushXYZ(dataB[b0], dataB[b0 + 1], dataB[b0 + 2]);
|
|
905
892
|
b0 += step * 3;
|
|
@@ -935,11 +922,11 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
935
922
|
points.pop();
|
|
936
923
|
}
|
|
937
924
|
/**
|
|
938
|
-
*
|
|
925
|
+
* Compute frame for a triangle formed by three (unchecked!) points identified by index.
|
|
939
926
|
* * z direction of frame is 001.
|
|
940
|
-
* * Transform axes from origin to
|
|
927
|
+
* * Transform axes from origin to targetA and targetB
|
|
941
928
|
* * in local coordinates (u,v,w) the xy interior of the triangle is `u>=0, v>= 0, w>= 0, u+v+w<1`
|
|
942
|
-
* * Return undefined if transform is invertible
|
|
929
|
+
* * Return undefined if transform is not invertible, e.g. if points are in a vertical plane.
|
|
943
930
|
*/
|
|
944
931
|
fillLocalXYTriangleFrame(originIndex, targetAIndex, targetBIndex, result) {
|
|
945
932
|
if (this.isIndexValid(originIndex) && this.isIndexValid(targetAIndex) && this.isIndexValid(targetBIndex)) {
|
|
@@ -962,7 +949,7 @@ class GrowableXYZArray extends IndexedXYZCollection_1.IndexedReadWriteXYZCollect
|
|
|
962
949
|
return undefined;
|
|
963
950
|
}
|
|
964
951
|
/**
|
|
965
|
-
* Pass the (x,y,z) of each point to a function which returns a replacement for
|
|
952
|
+
* Pass the (x,y,z) of each point to a function which returns a replacement for one of the 3 components.
|
|
966
953
|
* @param componentIndex Index (0,1,2) of component to be replaced.
|
|
967
954
|
* @param func function to be called as `func(x,y,z)`, returning a replacement value for componentIndex
|
|
968
955
|
*/
|