@itwin/core-geometry 4.5.0-dev.21 → 4.5.0-dev.24
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 +6 -1
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/curve/spiral/MXCubicAlongArcSpiralEvaluator.js +1 -1
- package/lib/cjs/curve/spiral/MXCubicAlongArcSpiralEvaluator.js.map +1 -1
- package/lib/cjs/curve/spiral/PolishCubicSpiralEvaluator.js +1 -1
- package/lib/cjs/curve/spiral/PolishCubicSpiralEvaluator.js.map +1 -1
- package/lib/cjs/geometry3d/FrameBuilder.d.ts.map +1 -1
- package/lib/cjs/geometry3d/FrameBuilder.js +3 -0
- package/lib/cjs/geometry3d/FrameBuilder.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts +8 -2
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.js +11 -2
- package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/cjs/polyface/Polyface.d.ts +9 -7
- package/lib/cjs/polyface/Polyface.d.ts.map +1 -1
- package/lib/cjs/polyface/Polyface.js +17 -10
- package/lib/cjs/polyface/Polyface.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts +18 -10
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.js +27 -21
- package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceData.d.ts +135 -84
- package/lib/cjs/polyface/PolyfaceData.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceData.js +279 -145
- package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
- package/lib/cjs/topology/Graph.d.ts +2 -8
- package/lib/cjs/topology/Graph.d.ts.map +1 -1
- package/lib/cjs/topology/Graph.js +0 -3
- package/lib/cjs/topology/Graph.js.map +1 -1
- package/lib/cjs/topology/Triangulation.d.ts +18 -7
- package/lib/cjs/topology/Triangulation.d.ts.map +1 -1
- package/lib/cjs/topology/Triangulation.js +50 -9
- package/lib/cjs/topology/Triangulation.js.map +1 -1
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/curve/spiral/MXCubicAlongArcSpiralEvaluator.js +1 -1
- package/lib/esm/curve/spiral/MXCubicAlongArcSpiralEvaluator.js.map +1 -1
- package/lib/esm/curve/spiral/PolishCubicSpiralEvaluator.js +1 -1
- package/lib/esm/curve/spiral/PolishCubicSpiralEvaluator.js.map +1 -1
- package/lib/esm/geometry3d/FrameBuilder.d.ts.map +1 -1
- package/lib/esm/geometry3d/FrameBuilder.js +3 -0
- package/lib/esm/geometry3d/FrameBuilder.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts +8 -2
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.js +11 -2
- package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/esm/polyface/Polyface.d.ts +9 -7
- package/lib/esm/polyface/Polyface.d.ts.map +1 -1
- package/lib/esm/polyface/Polyface.js +17 -10
- package/lib/esm/polyface/Polyface.js.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.d.ts +18 -10
- package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.js +27 -21
- package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/esm/polyface/PolyfaceData.d.ts +135 -84
- package/lib/esm/polyface/PolyfaceData.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceData.js +279 -145
- package/lib/esm/polyface/PolyfaceData.js.map +1 -1
- package/lib/esm/serialization/GeometrySamples.js.map +1 -1
- package/lib/esm/topology/Graph.d.ts +2 -8
- package/lib/esm/topology/Graph.d.ts.map +1 -1
- package/lib/esm/topology/Graph.js +0 -3
- package/lib/esm/topology/Graph.js.map +1 -1
- package/lib/esm/topology/Triangulation.d.ts +18 -7
- package/lib/esm/topology/Triangulation.d.ts.map +1 -1
- package/lib/esm/topology/Triangulation.js +50 -9
- package/lib/esm/topology/Triangulation.js.map +1 -1
- package/package.json +3 -3
|
@@ -15,39 +15,28 @@ import { Range3d } from "../geometry3d/Range";
|
|
|
15
15
|
import { ClusterableArray } from "../numerics/ClusterableArray";
|
|
16
16
|
import { PolyfaceAuxData } from "./AuxData";
|
|
17
17
|
import { TaggedNumericData } from "./TaggedNumericData";
|
|
18
|
+
// cspell:word internaldocs
|
|
18
19
|
/**
|
|
19
|
-
* PolyfaceData carries data arrays for point, normal,
|
|
20
|
-
*
|
|
21
|
-
* *
|
|
22
|
-
* *
|
|
23
|
-
* *
|
|
20
|
+
* `PolyfaceData` carries data arrays for point, normal, uv-parameters, and color, and index arrays for each.
|
|
21
|
+
* * Normal, uv-parameter, and color data are optional.
|
|
22
|
+
* * A given data array is defined if and only if its corresponding index array is defined.
|
|
23
|
+
* * All defined index arrays have parallel face loop order and structure, and thus the same length.
|
|
24
|
+
* * `IndexedPolyface` carries a PolyfaceData as a member (NOT as a base class; it already has `GeometryQuery` as base).
|
|
25
|
+
* * `IndexedPolyfaceVisitor` uses PolyfaceData as a base class. In this use, there is only a single facet in `PolyfaceData`.
|
|
26
|
+
* * `PolyfaceData` does not know what index range constitutes a given facet. This is managed by a derived/carrier class.
|
|
24
27
|
* @public
|
|
25
28
|
*/
|
|
26
29
|
class PolyfaceData {
|
|
27
|
-
/** boolean tag indicating if the facets are to be considered viewable from the back */
|
|
28
|
-
get twoSided() { return this._twoSided; }
|
|
29
|
-
set twoSided(value) { this._twoSided = value; }
|
|
30
|
-
/** set the `taggedNumericData` member */
|
|
31
|
-
setTaggedNumericData(data) {
|
|
32
|
-
this.taggedNumericData = data;
|
|
33
|
-
}
|
|
34
30
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
set expectedClosure(value) { this._expectedClosure = value; }
|
|
41
|
-
/** Constructor for facets.
|
|
42
|
-
* * The various params control whether respective arrays are to be allocated.
|
|
43
|
-
* * If arrayData is provided, all other params are IGNORED.
|
|
44
|
-
* *
|
|
31
|
+
* Constructor for facets.
|
|
32
|
+
* @param needNormals `true` to allocate empty normal data and index arrays; `false` (default) to leave undefined.
|
|
33
|
+
* @param needParams `true` to allocate empty uv parameter data and index arrays; `false` (default) to leave undefined.
|
|
34
|
+
* @param needColors `true` to allocate empty color data and index arrays; `false` (default) to leave undefined.
|
|
35
|
+
* @param twoSided `true` if the facets are to be considered viewable from the back; `false` (default) if not.
|
|
45
36
|
*/
|
|
46
37
|
constructor(needNormals = false, needParams = false, needColors = false, twoSided = false) {
|
|
47
|
-
this.face = [];
|
|
48
38
|
this.point = new GrowableXYZArray();
|
|
49
39
|
this.pointIndex = [];
|
|
50
|
-
this.edgeVisible = [];
|
|
51
40
|
if (needNormals) {
|
|
52
41
|
this.normal = new GrowableXYZArray();
|
|
53
42
|
this.normalIndex = [];
|
|
@@ -60,6 +49,8 @@ class PolyfaceData {
|
|
|
60
49
|
this.color = [];
|
|
61
50
|
this.colorIndex = [];
|
|
62
51
|
}
|
|
52
|
+
this.face = [];
|
|
53
|
+
this.edgeVisible = [];
|
|
63
54
|
this._twoSided = twoSided;
|
|
64
55
|
this._expectedClosure = 0;
|
|
65
56
|
}
|
|
@@ -68,30 +59,29 @@ class PolyfaceData {
|
|
|
68
59
|
const result = new PolyfaceData();
|
|
69
60
|
result.point = this.point.clone();
|
|
70
61
|
result.pointIndex = this.pointIndex.slice();
|
|
71
|
-
result.edgeVisible = this.edgeVisible.slice();
|
|
72
|
-
result.face = this.face.slice();
|
|
73
|
-
result.twoSided = this.twoSided;
|
|
74
|
-
result.expectedClosure = this.expectedClosure;
|
|
75
62
|
if (this.normal)
|
|
76
63
|
result.normal = this.normal.clone();
|
|
77
|
-
if (this.param)
|
|
78
|
-
result.param = this.param.clone();
|
|
79
|
-
if (this.color)
|
|
80
|
-
result.color = this.color.slice();
|
|
81
64
|
if (this.normalIndex)
|
|
82
65
|
result.normalIndex = this.normalIndex.slice();
|
|
66
|
+
if (this.param)
|
|
67
|
+
result.param = this.param.clone();
|
|
83
68
|
if (this.paramIndex)
|
|
84
69
|
result.paramIndex = this.paramIndex.slice();
|
|
70
|
+
if (this.color)
|
|
71
|
+
result.color = this.color.slice();
|
|
85
72
|
if (this.colorIndex)
|
|
86
73
|
result.colorIndex = this.colorIndex.slice();
|
|
74
|
+
result.face = this.face.slice();
|
|
87
75
|
if (this.auxData)
|
|
88
76
|
result.auxData = this.auxData.clone();
|
|
89
|
-
if (this.taggedNumericData)
|
|
77
|
+
if (this.taggedNumericData)
|
|
90
78
|
result.taggedNumericData = this.taggedNumericData.clone();
|
|
91
|
-
|
|
79
|
+
result.edgeVisible = this.edgeVisible.slice();
|
|
80
|
+
result.twoSided = this.twoSided;
|
|
81
|
+
result.expectedClosure = this.expectedClosure;
|
|
92
82
|
return result;
|
|
93
83
|
}
|
|
94
|
-
/** Test for equal indices and nearly equal coordinates */
|
|
84
|
+
/** Test for equal indices and nearly equal coordinates. */
|
|
95
85
|
isAlmostEqual(other) {
|
|
96
86
|
if (!GrowableXYZArray.isAlmostEqual(this.point, other.point))
|
|
97
87
|
return false;
|
|
@@ -109,77 +99,133 @@ class PolyfaceData {
|
|
|
109
99
|
return false;
|
|
110
100
|
if (!NumberArray.isExactEqual(this.colorIndex, other.colorIndex))
|
|
111
101
|
return false;
|
|
112
|
-
if (!NumberArray.isExactEqual(this.edgeVisible, other.edgeVisible))
|
|
113
|
-
return false;
|
|
114
102
|
if (!PolyfaceAuxData.isAlmostEqual(this.auxData, other.auxData))
|
|
115
103
|
return false;
|
|
104
|
+
if (!TaggedNumericData.areAlmostEqual(this.taggedNumericData, other.taggedNumericData))
|
|
105
|
+
return false;
|
|
106
|
+
if (!NumberArray.isExactEqual(this.edgeVisible, other.edgeVisible))
|
|
107
|
+
return false;
|
|
116
108
|
if (this.twoSided !== other.twoSided)
|
|
117
109
|
return false;
|
|
118
110
|
if (this.expectedClosure !== other.expectedClosure)
|
|
119
111
|
return false;
|
|
120
|
-
if (!TaggedNumericData.areAlmostEqual(this.taggedNumericData, other.taggedNumericData))
|
|
121
|
-
return false;
|
|
122
112
|
return true;
|
|
123
113
|
}
|
|
124
114
|
/** Ask if normals are required in this mesh. */
|
|
125
|
-
get requireNormals() {
|
|
115
|
+
get requireNormals() {
|
|
116
|
+
return undefined !== this.normal;
|
|
117
|
+
}
|
|
118
|
+
/** Ask if params are required in this mesh. */
|
|
119
|
+
get requireParams() {
|
|
120
|
+
return undefined !== this.param;
|
|
121
|
+
}
|
|
122
|
+
/** Ask if colors are required in this mesh. */
|
|
123
|
+
get requireColors() {
|
|
124
|
+
return undefined !== this.color;
|
|
125
|
+
}
|
|
126
126
|
/** Get the point count */
|
|
127
|
-
get pointCount() {
|
|
127
|
+
get pointCount() {
|
|
128
|
+
return this.point.length;
|
|
129
|
+
}
|
|
128
130
|
/** Get the normal count */
|
|
129
|
-
get normalCount() {
|
|
131
|
+
get normalCount() {
|
|
132
|
+
return this.normal ? this.normal.length : 0;
|
|
133
|
+
}
|
|
130
134
|
/** Get the param count */
|
|
131
|
-
get paramCount() {
|
|
135
|
+
get paramCount() {
|
|
136
|
+
return this.param ? this.param.length : 0;
|
|
137
|
+
}
|
|
132
138
|
/** Get the color count */
|
|
133
|
-
get colorCount() {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
/** Get the
|
|
139
|
+
get colorCount() {
|
|
140
|
+
return this.color ? this.color.length : 0;
|
|
141
|
+
}
|
|
142
|
+
/** Get the index count. Note that the point array is always indexed, and index arrays all have the same length. */
|
|
143
|
+
get indexCount() {
|
|
144
|
+
return this.pointIndex.length;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get the number of faces.
|
|
137
148
|
* * Note that a "face" is not a facet.
|
|
138
|
-
* * A
|
|
149
|
+
* * A face is a subset of the Polyface's facets grouped for application purposes.
|
|
139
150
|
*/
|
|
140
|
-
get faceCount() {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
|
|
157
|
-
this.
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
151
|
+
get faceCount() {
|
|
152
|
+
return this.face.length;
|
|
153
|
+
}
|
|
154
|
+
/** Return indexed point at index `i`. This is a COPY of the coordinates, not a reference. */
|
|
155
|
+
getPoint(i, result) {
|
|
156
|
+
return this.point.getPoint3dAtCheckedPointIndex(i, result);
|
|
157
|
+
}
|
|
158
|
+
/** Return indexed normal at index `i`. This is a COPY of the normal, not a reference. */
|
|
159
|
+
getNormal(i, result) {
|
|
160
|
+
return this.normal ? this.normal.getVector3dAtCheckedVectorIndex(i, result) : undefined;
|
|
161
|
+
}
|
|
162
|
+
/** Return indexed param at index `i`. This is a COPY of the coordinates, not a reference. */
|
|
163
|
+
getParam(i, result) {
|
|
164
|
+
return this.param ? this.param.getPoint2dAtCheckedPointIndex(i, result) : undefined;
|
|
165
|
+
}
|
|
166
|
+
/** Return indexed color at index `i`. Index `i` is not checked for validity. */
|
|
167
|
+
getColor(i) {
|
|
168
|
+
return this.color ? this.color[i] : 0;
|
|
169
|
+
}
|
|
170
|
+
/** Return indexed visibility. at index `i`. Index `i` is not checked for validity. */
|
|
171
|
+
getEdgeVisible(i) {
|
|
172
|
+
return this.edgeVisible[i];
|
|
173
|
+
}
|
|
174
|
+
/** Get boolean tag indicating if the facets are to be considered viewable from the back. */
|
|
175
|
+
get twoSided() {
|
|
176
|
+
return this._twoSided;
|
|
177
|
+
}
|
|
178
|
+
set twoSided(value) {
|
|
179
|
+
this._twoSided = value;
|
|
180
|
+
}
|
|
181
|
+
/** Get flag indicating if the mesh closure is unknown (0), open sheet (1), closed solid (2). */
|
|
182
|
+
get expectedClosure() {
|
|
183
|
+
return this._expectedClosure;
|
|
184
|
+
}
|
|
185
|
+
set expectedClosure(value) {
|
|
186
|
+
this._expectedClosure = value;
|
|
187
|
+
}
|
|
188
|
+
/** Set the tagged geometry data. */
|
|
189
|
+
setTaggedNumericData(data) {
|
|
190
|
+
this.taggedNumericData = data;
|
|
191
|
+
}
|
|
192
|
+
/** Copy the contents (not pointer) of `point[i]` into `dest`. Index `i` is not checked for validity. */
|
|
193
|
+
copyPointTo(i, dest) {
|
|
194
|
+
this.point.getPoint3dAtUncheckedPointIndex(i, dest);
|
|
195
|
+
}
|
|
196
|
+
/** Copy the contents (not pointer) of `normal[i]` into `dest`. Index `i` is not checked for validity. */
|
|
197
|
+
copyNormalTo(i, dest) {
|
|
198
|
+
if (this.normal)
|
|
199
|
+
this.normal.getVector3dAtUncheckedVectorIndex(i, dest);
|
|
200
|
+
}
|
|
201
|
+
/** Copy the contents (not pointer) of `param[i]` into `dest`. Index `i` is not checked for validity. */
|
|
202
|
+
copyParamTo(i, dest) {
|
|
203
|
+
if (this.param)
|
|
204
|
+
this.param.getPoint2dAtUncheckedPointIndex(i, dest);
|
|
205
|
+
}
|
|
206
|
+
/** Test if param at a index `i` matches the given uv */
|
|
207
|
+
isAlmostEqualParamIndexUV(i, u, v) {
|
|
208
|
+
if (this.param !== undefined && i >= 0 && i < this.param.length)
|
|
209
|
+
return Geometry.isSameCoordinate(u, this.param.getXAtUncheckedPointIndex(i))
|
|
210
|
+
&& Geometry.isSameCoordinate(v, this.param.getYAtUncheckedPointIndex(i));
|
|
166
211
|
return false;
|
|
167
212
|
}
|
|
168
213
|
/**
|
|
169
|
-
*
|
|
214
|
+
* Copy data from `other` to `this`.
|
|
170
215
|
* * This is the essence of transferring coordinates spread throughout a large polyface into a visitor's single facet.
|
|
171
|
-
* * "other" is the
|
|
172
|
-
* *
|
|
173
|
-
* * does NOT copy face data - visitors reference the FacetFaceData array for the whole polyface!!
|
|
216
|
+
* * Common usage: "other" is a Polyface, "this" is a PolyfaceVisitor to receive data from a single facet of the Polyface.
|
|
217
|
+
* * Does NOT copy face data - visitors reference the FacetFaceData array for the whole polyface.
|
|
174
218
|
* @param other polyface data being mined.
|
|
175
|
-
* @param index0 start index in other's index arrays
|
|
176
|
-
* @param index1 end index (one beyond last data
|
|
219
|
+
* @param index0 start index in other's index arrays.
|
|
220
|
+
* @param index1 end index (one beyond last data accessed) in other's index arrays.
|
|
177
221
|
* @param numWrap number of points to replicate as wraparound.
|
|
178
222
|
*/
|
|
179
223
|
gatherIndexedData(other, index0, index1, numWrap) {
|
|
180
224
|
const numEdge = index1 - index0;
|
|
225
|
+
if (numWrap > numEdge)
|
|
226
|
+
numWrap = numEdge;
|
|
181
227
|
const numTotal = numEdge + numWrap;
|
|
182
|
-
this.
|
|
228
|
+
this.resizeAllArrays(numTotal);
|
|
183
229
|
// copy wrapped points
|
|
184
230
|
for (let i = 0; i < numEdge; i++)
|
|
185
231
|
this.point.transferFromGrowableXYZArray(i, other.point, other.pointIndex[index0 + i]);
|
|
@@ -190,41 +236,48 @@ class PolyfaceData {
|
|
|
190
236
|
this.pointIndex[i] = other.pointIndex[index0 + i];
|
|
191
237
|
for (let i = 0; i < numWrap; i++)
|
|
192
238
|
this.pointIndex[numEdge + i] = this.pointIndex[i];
|
|
193
|
-
// copy wrapped
|
|
194
|
-
for (let i = 0; i < numEdge; i++)
|
|
195
|
-
this.edgeVisible[i] = other.edgeVisible[index0 + i];
|
|
196
|
-
for (let i = 0; i < numWrap; i++)
|
|
197
|
-
this.edgeVisible[numEdge + i] = this.edgeVisible[i];
|
|
239
|
+
// copy wrapped normals
|
|
198
240
|
if (this.normal && this.normalIndex && other.normal && other.normalIndex) {
|
|
199
241
|
for (let i = 0; i < numEdge; i++)
|
|
200
242
|
this.normal.transferFromGrowableXYZArray(i, other.normal, other.normalIndex[index0 + i]);
|
|
201
243
|
for (let i = 0; i < numWrap; i++)
|
|
202
244
|
this.normal.transferFromGrowableXYZArray(numEdge + i, this.normal, i);
|
|
245
|
+
// copy wrapped normalIndex
|
|
203
246
|
for (let i = 0; i < numEdge; i++)
|
|
204
247
|
this.normalIndex[i] = other.normalIndex[index0 + i];
|
|
205
248
|
for (let i = 0; i < numWrap; i++)
|
|
206
249
|
this.normalIndex[numEdge + i] = this.normalIndex[i];
|
|
207
250
|
}
|
|
251
|
+
// copy wrapped params
|
|
208
252
|
if (this.param && this.paramIndex && other.param && other.paramIndex) {
|
|
209
253
|
for (let i = 0; i < numEdge; i++)
|
|
210
254
|
this.param.transferFromGrowableXYArray(i, other.param, other.paramIndex[index0 + i]);
|
|
211
255
|
for (let i = 0; i < numWrap; i++)
|
|
212
256
|
this.param.transferFromGrowableXYArray(numEdge + i, this.param, i);
|
|
257
|
+
// copy wrapped paramIndex
|
|
213
258
|
for (let i = 0; i < numEdge; i++)
|
|
214
259
|
this.paramIndex[i] = other.paramIndex[index0 + i];
|
|
215
260
|
for (let i = 0; i < numWrap; i++)
|
|
216
261
|
this.paramIndex[numEdge + i] = this.paramIndex[i];
|
|
217
262
|
}
|
|
263
|
+
// copy wrapped colors
|
|
218
264
|
if (this.color && this.colorIndex && other.color && other.colorIndex) {
|
|
219
265
|
for (let i = 0; i < numEdge; i++)
|
|
220
266
|
this.color[i] = other.color[other.colorIndex[index0 + i]];
|
|
221
267
|
for (let i = 0; i < numWrap; i++)
|
|
222
268
|
this.color[numEdge + i] = this.color[i];
|
|
269
|
+
// copy wrapped colorIndex
|
|
223
270
|
for (let i = 0; i < numEdge; i++)
|
|
224
271
|
this.colorIndex[i] = other.colorIndex[index0 + i];
|
|
225
272
|
for (let i = 0; i < numWrap; i++)
|
|
226
273
|
this.colorIndex[numEdge + i] = this.colorIndex[i];
|
|
227
274
|
}
|
|
275
|
+
// copy wrapped edge visibility
|
|
276
|
+
for (let i = 0; i < numEdge; i++)
|
|
277
|
+
this.edgeVisible[i] = other.edgeVisible[index0 + i];
|
|
278
|
+
for (let i = 0; i < numWrap; i++)
|
|
279
|
+
this.edgeVisible[numEdge + i] = this.edgeVisible[i];
|
|
280
|
+
// copy wrapped auxData
|
|
228
281
|
if (this.auxData && other.auxData && this.auxData.channels.length === other.auxData.channels.length) {
|
|
229
282
|
for (let iChannel = 0; iChannel < this.auxData.channels.length; iChannel++) {
|
|
230
283
|
const thisChannel = this.auxData.channels[iChannel];
|
|
@@ -241,19 +294,21 @@ class PolyfaceData {
|
|
|
241
294
|
}
|
|
242
295
|
}
|
|
243
296
|
}
|
|
297
|
+
// copy wrapped auxData index
|
|
244
298
|
for (let i = 0; i < numEdge; i++)
|
|
245
299
|
this.auxData.indices[i] = other.auxData.indices[index0 + i];
|
|
246
300
|
for (let i = 0; i < numWrap; i++)
|
|
247
301
|
this.auxData.indices[numEdge + i] = this.auxData.indices[i];
|
|
248
302
|
}
|
|
249
303
|
}
|
|
304
|
+
/** Trim the `data` arrays to the stated `length`. */
|
|
250
305
|
static trimArray(data, length) {
|
|
251
306
|
if (data && length < data.length)
|
|
252
307
|
data.length = length;
|
|
253
308
|
}
|
|
254
309
|
/**
|
|
255
|
-
* Trim all index arrays to the stated length
|
|
256
|
-
* This is called by PolyfaceBuilder to clean up after an aborted construction sequence.
|
|
310
|
+
* Trim all index arrays to the stated `length`.
|
|
311
|
+
* * This is called by PolyfaceBuilder to clean up after an aborted construction sequence.
|
|
257
312
|
*/
|
|
258
313
|
trimAllIndexArrays(length) {
|
|
259
314
|
PolyfaceData.trimArray(this.pointIndex, length);
|
|
@@ -269,7 +324,78 @@ class PolyfaceData {
|
|
|
269
324
|
}
|
|
270
325
|
}
|
|
271
326
|
}
|
|
272
|
-
/**
|
|
327
|
+
/**
|
|
328
|
+
* Resize all data and index arrays to the specified `length`.
|
|
329
|
+
* * This is used by visitors, whose data and index arrays are all parallel.
|
|
330
|
+
*/
|
|
331
|
+
resizeAllArrays(length) {
|
|
332
|
+
if (length > this.point.length) {
|
|
333
|
+
while (this.point.length < length)
|
|
334
|
+
this.point.push(Point3d.create());
|
|
335
|
+
while (this.pointIndex.length < length)
|
|
336
|
+
this.pointIndex.push(-1);
|
|
337
|
+
if (this.normal)
|
|
338
|
+
while (this.normal.length < length)
|
|
339
|
+
this.normal.push(Vector3d.create());
|
|
340
|
+
if (this.normalIndex)
|
|
341
|
+
while (this.normalIndex.length < length)
|
|
342
|
+
this.normalIndex.push(-1);
|
|
343
|
+
if (this.param)
|
|
344
|
+
while (this.param.length < length)
|
|
345
|
+
this.param.push(Point2d.create());
|
|
346
|
+
if (this.paramIndex)
|
|
347
|
+
while (this.paramIndex.length < length)
|
|
348
|
+
this.paramIndex.push(-1);
|
|
349
|
+
if (this.color)
|
|
350
|
+
while (this.color.length < length)
|
|
351
|
+
this.color.push(0);
|
|
352
|
+
if (this.colorIndex)
|
|
353
|
+
while (this.colorIndex.length < length)
|
|
354
|
+
this.colorIndex.push(-1);
|
|
355
|
+
while (this.edgeVisible.length < length)
|
|
356
|
+
this.edgeVisible.push(false);
|
|
357
|
+
if (this.auxData) {
|
|
358
|
+
for (const channel of this.auxData.channels) {
|
|
359
|
+
for (const channelData of channel.data) {
|
|
360
|
+
while (channelData.values.length < length * channel.entriesPerValue)
|
|
361
|
+
channelData.values.push(0);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (this.auxData.indices)
|
|
365
|
+
this.auxData.indices.push(-1);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
else if (length < this.point.length) {
|
|
369
|
+
this.point.resize(length);
|
|
370
|
+
this.pointIndex.length = length;
|
|
371
|
+
if (this.normal)
|
|
372
|
+
this.normal.resize(length);
|
|
373
|
+
if (this.normalIndex)
|
|
374
|
+
this.normalIndex.length = length;
|
|
375
|
+
if (this.param)
|
|
376
|
+
this.param.resize(length);
|
|
377
|
+
if (this.paramIndex)
|
|
378
|
+
this.paramIndex.length = length;
|
|
379
|
+
if (this.color)
|
|
380
|
+
this.color.length = length;
|
|
381
|
+
if (this.colorIndex)
|
|
382
|
+
this.colorIndex.length = length;
|
|
383
|
+
this.edgeVisible.length = length;
|
|
384
|
+
if (this.auxData) {
|
|
385
|
+
for (const channel of this.auxData.channels) {
|
|
386
|
+
for (const channelData of channel.data) {
|
|
387
|
+
channelData.values.length = length * channel.entriesPerValue;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
if (this.auxData.indices)
|
|
391
|
+
this.auxData.indices.length = length;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Resize all data arrays to the specified `length`.
|
|
397
|
+
* @deprecated in 4.x because name is misleading. Call [[PolyfaceData.resizeAllArrays]] instead.
|
|
398
|
+
*/
|
|
273
399
|
resizeAllDataArrays(length) {
|
|
274
400
|
if (length > this.point.length) {
|
|
275
401
|
while (this.point.length < length)
|
|
@@ -315,19 +441,21 @@ class PolyfaceData {
|
|
|
315
441
|
}
|
|
316
442
|
}
|
|
317
443
|
}
|
|
318
|
-
/** Return the range of the point array (optionally transformed) */
|
|
444
|
+
/** Return the range of the point array (optionally transformed). */
|
|
319
445
|
range(result, transform) {
|
|
320
446
|
result = result ? result : Range3d.createNull();
|
|
321
447
|
result.extendArray(this.point, transform);
|
|
322
448
|
return result;
|
|
323
449
|
}
|
|
324
|
-
/**
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
* *
|
|
329
|
-
* *
|
|
330
|
-
|
|
450
|
+
/**
|
|
451
|
+
* Reverse the indices for the specified facets in the index arrays (pointIndex, normalIndex, paramIndex, colorIndex,
|
|
452
|
+
* and edgeVisible).
|
|
453
|
+
* @param facetStartIndex start indices of *consecutive* facets to be reversed.
|
|
454
|
+
* * Consecutive indices in this array define where a given facet is represented in each of the parallel index arrays.
|
|
455
|
+
* * The indices for facet k are `facetStartIndex[k]` up to (but not including) `facetStartIndex[k + 1]`.
|
|
456
|
+
* * This implies `facetStartIndex[k + 1]` is both the upper limit of facet k's indices, and the start index of facet k+1.
|
|
457
|
+
* * For example, passing an IndexedPolyface's _facetStart array into this method reverses every facet.
|
|
458
|
+
*/
|
|
331
459
|
reverseIndices(facetStartIndex) {
|
|
332
460
|
if (facetStartIndex && PolyfaceData.isValidFacetStartIndexArray(facetStartIndex)) {
|
|
333
461
|
PolyfaceData.reverseIndices(facetStartIndex, this.pointIndex, true);
|
|
@@ -340,31 +468,33 @@ class PolyfaceData {
|
|
|
340
468
|
PolyfaceData.reverseIndices(facetStartIndex, this.edgeVisible, false);
|
|
341
469
|
}
|
|
342
470
|
}
|
|
343
|
-
/**
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
* *
|
|
471
|
+
/**
|
|
472
|
+
* Reverse the indices for the specified facet in the index arrays (pointIndex, normalIndex, paramIndex, colorIndex,
|
|
473
|
+
* and edgeVisible).
|
|
474
|
+
* @param facetIndex index of the facet to reverse. The entries of each index array to be reversed are found at
|
|
475
|
+
* `facetStartIndex[facetIndex] <= i < facetStartIndex[facetIndex + 1]`.
|
|
476
|
+
* @param facetStartIndex start indices of *consecutive* facets, e.g., an IndexedPolyface's _facetStart array.
|
|
477
|
+
* See [[reverseIndices]].
|
|
349
478
|
*/
|
|
350
|
-
reverseIndicesSingleFacet(
|
|
351
|
-
PolyfaceData.reverseIndicesSingleFacet(
|
|
479
|
+
reverseIndicesSingleFacet(facetIndex, facetStartIndex) {
|
|
480
|
+
PolyfaceData.reverseIndicesSingleFacet(facetIndex, facetStartIndex, this.pointIndex, true);
|
|
352
481
|
if (this.normalIndex !== this.pointIndex)
|
|
353
|
-
PolyfaceData.reverseIndicesSingleFacet(
|
|
482
|
+
PolyfaceData.reverseIndicesSingleFacet(facetIndex, facetStartIndex, this.normalIndex, true);
|
|
354
483
|
if (this.paramIndex !== this.pointIndex)
|
|
355
|
-
PolyfaceData.reverseIndicesSingleFacet(
|
|
484
|
+
PolyfaceData.reverseIndicesSingleFacet(facetIndex, facetStartIndex, this.paramIndex, true);
|
|
356
485
|
if (this.colorIndex !== this.pointIndex)
|
|
357
|
-
PolyfaceData.reverseIndicesSingleFacet(
|
|
358
|
-
PolyfaceData.reverseIndicesSingleFacet(
|
|
486
|
+
PolyfaceData.reverseIndicesSingleFacet(facetIndex, facetStartIndex, this.colorIndex, true);
|
|
487
|
+
PolyfaceData.reverseIndicesSingleFacet(facetIndex, facetStartIndex, this.edgeVisible, false);
|
|
359
488
|
}
|
|
360
|
-
/** Scale all the normals by -1 */
|
|
489
|
+
/** Scale all the normals by -1. */
|
|
361
490
|
reverseNormals() {
|
|
362
491
|
if (this.normal)
|
|
363
492
|
this.normal.scaleInPlace(-1.0);
|
|
364
493
|
}
|
|
365
|
-
/**
|
|
366
|
-
*
|
|
367
|
-
* *
|
|
494
|
+
/**
|
|
495
|
+
* Apply `transform` to point and normal arrays and to auxData.
|
|
496
|
+
* * IMPORTANT This base class is just a data carrier. It does not know if the index order and normal directions
|
|
497
|
+
* have special meaning, i.e., caller must separately reverse index order and normal direction if needed.
|
|
368
498
|
*/
|
|
369
499
|
tryTransformInPlace(transform) {
|
|
370
500
|
this.point.multiplyTransformInPlace(transform);
|
|
@@ -377,13 +507,14 @@ class PolyfaceData {
|
|
|
377
507
|
* * Search for duplicates within points, normals, params, and colors.
|
|
378
508
|
* * Compress each data array.
|
|
379
509
|
* * Revise all indexing for the relocated data.
|
|
380
|
-
* @param tolerance optional tolerance for clustering mesh vertices. Default is [[Geometry.smallMetricDistance]].
|
|
510
|
+
* @param tolerance (optional) tolerance for clustering mesh vertices. Default is [[Geometry.smallMetricDistance]].
|
|
381
511
|
*/
|
|
382
512
|
compress(tolerance = Geometry.smallMetricDistance) {
|
|
513
|
+
// more info can be found at geometry/internaldocs/Polyface.md
|
|
383
514
|
const packedPoints = ClusterableArray.clusterGrowablePoint3dArray(this.point, tolerance);
|
|
384
515
|
this.point = packedPoints.growablePackedPoints;
|
|
385
516
|
packedPoints.updateIndices(this.pointIndex);
|
|
386
|
-
// for now, normals, params, and colors use the default tolerance for clustering
|
|
517
|
+
// for now, normals, params, and colors use the default tolerance for clustering
|
|
387
518
|
if (this.normalIndex && this.normal) {
|
|
388
519
|
const packedNormals = ClusterableArray.clusterGrowablePoint3dArray(this.normal);
|
|
389
520
|
this.normal = packedNormals.growablePackedPoints;
|
|
@@ -401,10 +532,11 @@ class PolyfaceData {
|
|
|
401
532
|
}
|
|
402
533
|
}
|
|
403
534
|
/**
|
|
404
|
-
* Test if facetStartIndex is (minimally
|
|
405
|
-
* *
|
|
535
|
+
* Test if `facetStartIndex` is (minimally) valid.
|
|
536
|
+
* * Length must be nonzero (recall that for "no facets", the `facetStartIndex` array still must contain a 0).
|
|
406
537
|
* * Each entry must be strictly smaller than the one that follows.
|
|
407
|
-
* @param facetStartIndex
|
|
538
|
+
* @param facetStartIndex start indices of all facets. Facet k starts at facetStartIndex[k] up to (but not including)
|
|
539
|
+
* `facetStartIndex[k + 1]`
|
|
408
540
|
*/
|
|
409
541
|
static isValidFacetStartIndexArray(facetStartIndex) {
|
|
410
542
|
// facetStartIndex for empty facets has a single entry "0" -- empty array is not allowed
|
|
@@ -415,8 +547,14 @@ class PolyfaceData {
|
|
|
415
547
|
return false;
|
|
416
548
|
return true;
|
|
417
549
|
}
|
|
418
|
-
/**
|
|
419
|
-
*
|
|
550
|
+
/**
|
|
551
|
+
* Reverse the indices for the specified facets in the given index array.
|
|
552
|
+
* * Parameterized over type T so non-number data (e.g., boolean visibility flags) can be reversed.
|
|
553
|
+
* @param facetStartIndex start indices of *consecutive* facets to be reversed, e.g., an IndexedPolyface's _facetStart
|
|
554
|
+
* array. See the non-static [[reverseIndices]].
|
|
555
|
+
* @param indices the index array, e.g., pointIndex, normalIndex, etc.
|
|
556
|
+
* @param preserveStart `true` to preserve the start index of each facet (e.g., facet [1,2,3,4] becomes [1,4,3,2]);
|
|
557
|
+
* `false` to reverse all indices (e.g., facet [1,2,3,4] becomes [4,3,2,1]).
|
|
420
558
|
*/
|
|
421
559
|
static reverseIndices(facetStartIndex, indices, preserveStart) {
|
|
422
560
|
if (!indices || indices.length === 0)
|
|
@@ -426,8 +564,7 @@ class PolyfaceData {
|
|
|
426
564
|
for (let i = 0; i + 1 < facetStartIndex.length; i++) {
|
|
427
565
|
let index0 = facetStartIndex[i];
|
|
428
566
|
let index1 = facetStartIndex[i + 1];
|
|
429
|
-
if (preserveStart) {
|
|
430
|
-
// leave [index0] as is so reversed facet starts at same vertex
|
|
567
|
+
if (preserveStart) { // leave "index0" as is so reversed facet starts at same vertex
|
|
431
568
|
while (index1 > index0 + 2) {
|
|
432
569
|
index1--;
|
|
433
570
|
index0++;
|
|
@@ -436,8 +573,7 @@ class PolyfaceData {
|
|
|
436
573
|
indices[index1] = a;
|
|
437
574
|
}
|
|
438
575
|
}
|
|
439
|
-
else {
|
|
440
|
-
// reverse all
|
|
576
|
+
else { // reverse all
|
|
441
577
|
while (index1 > index0 + 1) {
|
|
442
578
|
index1--;
|
|
443
579
|
const a = indices[index0];
|
|
@@ -452,19 +588,26 @@ class PolyfaceData {
|
|
|
452
588
|
}
|
|
453
589
|
return false;
|
|
454
590
|
}
|
|
455
|
-
/**
|
|
456
|
-
*
|
|
591
|
+
/**
|
|
592
|
+
* Reverse the indices for the specified facet in the specified index array.
|
|
593
|
+
* * Parameterized over type T so non-number data (e.g., boolean visibility flags) can be reversed.
|
|
594
|
+
* @param facetIndex index of the facet to reverse. The entries of `indices` to be reversed are found at
|
|
595
|
+
* `facetStartIndex[facetIndex] <= i < facetStartIndex[facetIndex + 1]`.
|
|
596
|
+
* @param facetStartIndex start indices of *consecutive* facets, e.g., an IndexedPolyface's _facetStart array.
|
|
597
|
+
* See [[reverseIndices]].
|
|
598
|
+
* @param indices the index array, e.g., pointIndex, normalIndex, etc.
|
|
599
|
+
* @param preserveStart `true` to preserve the start index of each facet (e.g., facet [1,2,3,4] becomes [1,4,3,2]);
|
|
600
|
+
* `false` to reverse all indices (e.g., facet [1,2,3,4] becomes [4,3,2,1]).
|
|
457
601
|
*/
|
|
458
|
-
static reverseIndicesSingleFacet(
|
|
602
|
+
static reverseIndicesSingleFacet(facetIndex, facetStartIndex, indices, preserveStart) {
|
|
459
603
|
if (!indices || indices.length === 0)
|
|
460
604
|
return true; // empty case
|
|
461
605
|
if (indices.length > 0) {
|
|
462
606
|
if (facetStartIndex[facetStartIndex.length - 1] === indices.length
|
|
463
|
-
&&
|
|
464
|
-
let index0 = facetStartIndex[
|
|
465
|
-
let index1 = facetStartIndex[
|
|
466
|
-
if (preserveStart) {
|
|
467
|
-
// leave [index0] as is so reversed facet starts at same vertex
|
|
607
|
+
&& facetIndex >= 0 && facetIndex + 1 < facetStartIndex.length) {
|
|
608
|
+
let index0 = facetStartIndex[facetIndex];
|
|
609
|
+
let index1 = facetStartIndex[facetIndex + 1];
|
|
610
|
+
if (preserveStart) { // leave "index0" as is so reversed facet starts at same vertex
|
|
468
611
|
while (index1 > index0 + 2) {
|
|
469
612
|
index1--;
|
|
470
613
|
index0++;
|
|
@@ -473,8 +616,7 @@ class PolyfaceData {
|
|
|
473
616
|
indices[index1] = a;
|
|
474
617
|
}
|
|
475
618
|
}
|
|
476
|
-
else {
|
|
477
|
-
// reverse all
|
|
619
|
+
else { // reverse all
|
|
478
620
|
while (index1 > index0 + 1) {
|
|
479
621
|
index1--;
|
|
480
622
|
const a = indices[index0];
|
|
@@ -489,18 +631,10 @@ class PolyfaceData {
|
|
|
489
631
|
return false;
|
|
490
632
|
}
|
|
491
633
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
// <li>all arrays are (independently) indexed.
|
|
495
|
-
// <li>with regret, the point, param, normal, and color arrays are exposed publicly.
|
|
496
|
-
// <li>getX methods are "trusting" -- no bounds check
|
|
497
|
-
// <li>getX methods return references to X.
|
|
498
|
-
// <li> EXCEPT -- for optional arrays, the return 000.
|
|
499
|
-
// <li>copyX methods move data to caller-supplied result..
|
|
500
|
-
// </ul>
|
|
501
|
-
/** Relative tolerance used in tests for planar facets
|
|
634
|
+
/**
|
|
635
|
+
* Relative tolerance used in tests for planar facets.
|
|
502
636
|
* @internal
|
|
503
|
-
|
|
637
|
+
*/
|
|
504
638
|
PolyfaceData.planarityLocalRelTol = 1.0e-13;
|
|
505
639
|
export { PolyfaceData };
|
|
506
640
|
//# sourceMappingURL=PolyfaceData.js.map
|