@itwin/core-backend 5.0.0-dev.113 → 5.0.0-dev.114

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.
@@ -49,7 +49,7 @@ export interface ExportGraphicsMesh {
49
49
  normals: Float32Array;
50
50
  /** Parameters (uvs) for this mesh, laid out in the pattern XYXY */
51
51
  params: Float32Array;
52
- /** If true, clients should assume both sides of the mesh are visible and not cull backfaces. */
52
+ /** If true, clients should assume both sides of the mesh are visible and not cull back faces. */
53
53
  isTwoSided: boolean;
54
54
  }
55
55
  /** Info provided to ExportGraphicsFunction about graphics.
@@ -273,18 +273,19 @@ export declare class ExportGraphicsMeshVisitor extends PolyfaceData implements P
273
273
  private _nextFacetIndex;
274
274
  private _numWrap;
275
275
  private _polyface;
276
- private constructor();
276
+ protected constructor(facets: ExportGraphicsMesh, numWrap: number);
277
277
  /** Create a visitor for iterating the facets of `polyface`, with indicated number of points to be added to each facet to produce closed point arrays
278
278
  * Typical wrap counts are:
279
- * * 0 -- leave the point arrays with "missing final edge"
279
+ * * 0 -- leave the point arrays with "missing final edge" (default)
280
280
  * * 1 -- add point 0 as closure point
281
281
  * * 2 -- add points 0 and 1 as closure and wrap point. This is useful when vertex visit requires two adjacent vectors, e.g. for cross products.
282
282
  */
283
- static create(polyface: ExportGraphicsMesh, numWrap: number): ExportGraphicsMeshVisitor;
284
- /** Reset the iterator to start at the first facet of the polyface. */
283
+ static create(polyface: ExportGraphicsMesh, numWrap?: number): ExportGraphicsMeshVisitor;
284
+ /** Restart the visitor at the first facet. */
285
285
  reset(): void;
286
286
  /** Select a facet by simple index. */
287
287
  moveToReadIndex(facetIndex: number): boolean;
288
+ /** Load data for the next facet. */
288
289
  moveToNextFacet(): boolean;
289
290
  /** Set the number of vertices to replicate in visitor arrays. */
290
291
  setNumWrap(numWrap: number): void;
@@ -300,12 +301,12 @@ export declare class ExportGraphicsMeshVisitor extends PolyfaceData implements P
300
301
  * Use the artificial paramIndex, which matches pointIndex.
301
302
  */
302
303
  clientNormalIndex(i: number): number;
303
- /** Return the color index of vertex i within the currently loaded facet */
304
+ /** Always returns -1 since we never have colors. */
304
305
  clientColorIndex(_i: number): number;
305
- /** Return the aux data index of vertex i within the currently loaded facet */
306
+ /** Always returns -1 since we never have auxiliary data. */
306
307
  clientAuxIndex(_i: number): number;
307
308
  /** return the client polyface */
308
- clientPolyface(): Polyface;
309
+ clientPolyface(): Polyface | undefined;
309
310
  /** clear the contents of all arrays. Use this along with transferDataFrom methods to build up new facets */
310
311
  clearArrays(): void;
311
312
  /** transfer interpolated data from the other visitor.
@@ -314,5 +315,50 @@ export declare class ExportGraphicsMeshVisitor extends PolyfaceData implements P
314
315
  pushInterpolatedDataFrom(other: PolyfaceVisitor, index0: number, fraction: number, index1: number): void;
315
316
  /** transfer data from a specified index of the other visitor as new data in this visitor. */
316
317
  pushDataFrom(other: PolyfaceVisitor, index: number): void;
318
+ /** Return the number of facets this visitor is able to visit */
319
+ getVisitableFacetCount(): number;
320
+ /** Create a visitor for a subset of the facets visitable by the instance. */
321
+ createSubsetVisitor(facetIndices: number[], numWrap?: number): ExportGraphicsMeshSubsetVisitor;
322
+ }
323
+ /**
324
+ * An `ExportGraphicsMeshSubsetVisitor` is an `ExportGraphicsMeshVisitor` which only visits a subset of the facets.
325
+ * * The subset is defined by an array of facet indices provided when this visitor is created.
326
+ * * Input indices (e.g., for `moveToReadIndex`) are understood to be indices into the subset array.
327
+ * @public
328
+ */
329
+ export declare class ExportGraphicsMeshSubsetVisitor extends ExportGraphicsMeshVisitor {
330
+ private _facetIndices;
331
+ private _currentSubsetIndex;
332
+ private _nextSubsetIndex;
333
+ private constructor();
334
+ private isValidSubsetIndex;
335
+ /**
336
+ * Create a visitor for iterating a subset of the facets of `polyface`.
337
+ * @param polyface reference to the client polyface, supplying facets
338
+ * @param facetIndices array of indices of facets in the client polyface to visit. This array is cloned.
339
+ * @param numWrap number of vertices replicated in the visitor arrays to facilitate simpler caller code. Default is zero.
340
+ */
341
+ static createSubsetVisitor(polyface: ExportGraphicsMesh, facetIndices: number[], numWrap?: number): ExportGraphicsMeshSubsetVisitor;
342
+ /**
343
+ * Advance the iterator to a particular facet in the subset of client polyface facets.
344
+ * @param subsetIndex index into the subset array, not to be confused with the client facet index.
345
+ * @return whether the iterator was successfully moved.
346
+ */
347
+ moveToReadIndex(subsetIndex: number): boolean;
348
+ /**
349
+ * Advance the iterator to the next facet in the subset of client polyface facets.
350
+ * @return whether the iterator was successfully moved.
351
+ */
352
+ moveToNextFacet(): boolean;
353
+ /** Restart the visitor at the first facet. */
354
+ reset(): void;
355
+ /**
356
+ * Return the client polyface facet index (aka "readIndex") for the given subset index.
357
+ * @param subsetIndex index into the subset array. Default is the subset index of the currently visited facet.
358
+ * @return valid client polyface facet index, or `undefined` if invalid subset index.
359
+ */
360
+ parentFacetIndex(subsetIndex?: number): number | undefined;
361
+ /** Return the number of facets this visitor is able to visit. */
362
+ getVisitableFacetCount(): number;
317
363
  }
318
364
  //# sourceMappingURL=ExportGraphics.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExportGraphics.d.ts","sourceRoot":"","sources":["../../src/ExportGraphics.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,SAAS,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAElE;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,4EAA4E;IAC5E,OAAO,EAAE,UAAU,CAAC;IACpB,+DAA+D;IAC/D,MAAM,EAAE,YAAY,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,kEAAkE;IAClE,SAAS,EAAE,UAAU,CAAC;IACtB,kEAAkE;IAClE,WAAW,EAAE,UAAU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B,IAAI,MAAM;IAGvC,6EAA6E;IACtE,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,MAAU,GAAG,+BAA+B;CAGzG;AAED;;;;;GAKG;AACH,qBAAa,+BAAgC,SAAQ,yBAAyB;IAC5E,OAAO,CAAC,aAAa,CAAW;IAChC,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,gBAAgB,CAAS;IAEjC,OAAO;IAOP,OAAO,CAAC,kBAAkB;IAG1B;;;;;OAKG;WACW,mBAAmB,CAC/B,QAAQ,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,MAAU,GACxE,+BAA+B;IAGlC;;;;OAIG;IACa,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAQ7D;;;OAGG;IACa,eAAe,IAAI,OAAO;IAM1C,8CAA8C;IAC9B,KAAK,IAAI,IAAI;IAM7B;;;;OAIG;IACI,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAKjE,iEAAiE;IACjD,sBAAsB,IAAI,MAAM;CAGjD"}
@@ -76,105 +76,122 @@ export class ExportGraphicsMeshVisitor extends PolyfaceData {
76
76
  _nextFacetIndex;
77
77
  _numWrap;
78
78
  _polyface;
79
- // to be called from static factory method that validates the polyface ...
80
79
  constructor(facets, numWrap) {
81
80
  super(facets.normals.length > 0, facets.params.length > 0, false, facets.isTwoSided);
82
81
  this._polyface = facets;
83
82
  this._numWrap = numWrap;
84
83
  this._nextFacetIndex = 0;
85
84
  this._currentFacetIndex = -1;
86
- this.twoSided = facets.isTwoSided;
87
85
  this.reset();
88
86
  }
89
87
  /** Create a visitor for iterating the facets of `polyface`, with indicated number of points to be added to each facet to produce closed point arrays
90
88
  * Typical wrap counts are:
91
- * * 0 -- leave the point arrays with "missing final edge"
89
+ * * 0 -- leave the point arrays with "missing final edge" (default)
92
90
  * * 1 -- add point 0 as closure point
93
91
  * * 2 -- add points 0 and 1 as closure and wrap point. This is useful when vertex visit requires two adjacent vectors, e.g. for cross products.
94
92
  */
95
- static create(polyface, numWrap) {
93
+ static create(polyface, numWrap = 0) {
96
94
  return new ExportGraphicsMeshVisitor(polyface, numWrap);
97
95
  }
98
- /** Reset the iterator to start at the first facet of the polyface. */
96
+ /** Restart the visitor at the first facet. */
99
97
  reset() {
100
98
  this.moveToReadIndex(0);
101
- this._nextFacetIndex = 0; // so immediate moveToNextFacet stays here.
99
+ this._nextFacetIndex = 0; // so immediate moveToNextFacet stays here
102
100
  }
103
101
  /** Select a facet by simple index. */
104
102
  moveToReadIndex(facetIndex) {
105
103
  if (facetIndex < 0 || 2 + facetIndex * 3 >= this._polyface.indices.length)
106
104
  return false;
107
- this._currentFacetIndex = facetIndex;
108
- this._nextFacetIndex = facetIndex + 1;
109
- this.point.length = 0;
110
- const points = this.point;
111
- points.length = 0;
112
- this.pointIndex.length = 0;
113
- this.point.length = 0;
114
- this.edgeVisible.length = 0;
115
- const sourcePoints = this._polyface.points;
116
- const indices = this._polyface.indices;
117
- const i0 = 3 * facetIndex;
118
- for (let i = i0; i < i0 + 3; i++) {
119
- const k = 3 * indices[i];
120
- this.pointIndex.push(indices[i]);
121
- this.point.pushXYZ(sourcePoints[k], sourcePoints[k + 1], sourcePoints[k + 2]);
122
- this.edgeVisible.push(true);
123
- }
124
- for (let i = 0; i < this._numWrap; i++) {
125
- this.point.pushFromGrowableXYZArray(this.point, i);
126
- }
127
- const sourceParams = this._polyface.params;
128
- if (sourceParams.length > 0 && this.paramIndex && this.param) {
129
- this.paramIndex.length = 0;
130
- this.param.length = 0;
105
+ if (this._currentFacetIndex !== facetIndex || 3 + this._numWrap !== this.point.length) {
106
+ this._currentFacetIndex = facetIndex;
107
+ this.point.length = 0;
108
+ this.pointIndex.length = 0;
109
+ this.edgeVisible.length = 0;
110
+ const sourcePoints = this._polyface.points;
111
+ const indices = this._polyface.indices;
112
+ const i0 = 3 * facetIndex;
131
113
  for (let i = i0; i < i0 + 3; i++) {
132
- const k = 2 * indices[i];
133
- this.paramIndex.push(indices[i]);
134
- this.param.pushXY(sourceParams[k], sourceParams[k + 1]);
114
+ const k = 3 * indices[i];
115
+ this.pointIndex.push(indices[i]);
116
+ this.point.pushXYZ(sourcePoints[k], sourcePoints[k + 1], sourcePoints[k + 2]);
117
+ this.edgeVisible.push(true);
135
118
  }
136
119
  for (let i = 0; i < this._numWrap; i++) {
137
- this.param.pushFromGrowableXYArray(this.param, i);
120
+ this.point.pushFromGrowableXYZArray(this.point, i);
138
121
  }
139
- }
140
- const sourceNormals = this._polyface.normals;
141
- if (sourceNormals.length > 0 && this.normalIndex && this.normal) {
142
- this.normalIndex.length = 0;
143
- this.normal.length = 0;
144
- for (let i = i0; i < i0 + 3; i++) {
145
- const k = 3 * indices[i];
146
- this.normalIndex.push(indices[i]);
147
- this.normal.pushXYZ(sourceNormals[k], sourceNormals[k + 1], sourceNormals[k + 2]);
122
+ const sourceParams = this._polyface.params;
123
+ if (sourceParams.length > 0 && this.paramIndex && this.param) {
124
+ this.paramIndex.length = 0;
125
+ this.param.length = 0;
126
+ for (let i = i0; i < i0 + 3; i++) {
127
+ const k = 2 * indices[i];
128
+ this.paramIndex.push(indices[i]);
129
+ this.param.pushXY(sourceParams[k], sourceParams[k + 1]);
130
+ }
131
+ for (let i = 0; i < this._numWrap; i++) {
132
+ this.param.pushFromGrowableXYArray(this.param, i);
133
+ }
148
134
  }
149
- for (let i = 0; i < this._numWrap; i++) {
150
- this.normal.pushFromGrowableXYZArray(this.normal, i);
135
+ const sourceNormals = this._polyface.normals;
136
+ if (sourceNormals.length > 0 && this.normalIndex && this.normal) {
137
+ this.normalIndex.length = 0;
138
+ this.normal.length = 0;
139
+ for (let i = i0; i < i0 + 3; i++) {
140
+ const k = 3 * indices[i];
141
+ this.normalIndex.push(indices[i]);
142
+ this.normal.pushXYZ(sourceNormals[k], sourceNormals[k + 1], sourceNormals[k + 2]);
143
+ }
144
+ for (let i = 0; i < this._numWrap; i++) {
145
+ this.normal.pushFromGrowableXYZArray(this.normal, i);
146
+ }
151
147
  }
152
148
  }
149
+ this._nextFacetIndex = facetIndex + 1;
153
150
  return true;
154
151
  }
152
+ /** Load data for the next facet. */
155
153
  moveToNextFacet() {
156
- return this.moveToReadIndex(this._nextFacetIndex);
154
+ if (this._nextFacetIndex !== this._currentFacetIndex)
155
+ return this.moveToReadIndex(this._nextFacetIndex);
156
+ this._nextFacetIndex++;
157
+ return true;
157
158
  }
158
159
  /** Set the number of vertices to replicate in visitor arrays. */
159
- setNumWrap(numWrap) { this._numWrap = numWrap; }
160
+ setNumWrap(numWrap) {
161
+ this._numWrap = numWrap;
162
+ }
160
163
  /** Return the index (in the client polyface) of the current facet */
161
- currentReadIndex() { return this._currentFacetIndex; }
164
+ currentReadIndex() {
165
+ return this._currentFacetIndex;
166
+ }
162
167
  /** Return the point index of vertex i within the currently loaded facet */
163
- clientPointIndex(i) { return this.pointIndex[i]; }
168
+ clientPointIndex(i) {
169
+ return this.pointIndex[i];
170
+ }
164
171
  /** Return the param index of vertex i within the currently loaded facet.
165
172
  * Use the artificial paramIndex, which matches pointIndex.
166
173
  */
167
- clientParamIndex(i) { return this.paramIndex ? this.paramIndex[i] : -1; }
174
+ clientParamIndex(i) {
175
+ return this.paramIndex ? this.paramIndex[i] : -1;
176
+ }
168
177
  /** Return the normal index of vertex i within the currently loaded facet.
169
178
  * Use the artificial paramIndex, which matches pointIndex.
170
179
  */
171
- clientNormalIndex(i) { return this.normalIndex ? this.normalIndex[i] : -1; }
172
- /** Return the color index of vertex i within the currently loaded facet */
173
- clientColorIndex(_i) { return 1; }
174
- /** Return the aux data index of vertex i within the currently loaded facet */
175
- clientAuxIndex(_i) { return -1; }
180
+ clientNormalIndex(i) {
181
+ return this.normalIndex ? this.normalIndex[i] : -1;
182
+ }
183
+ /** Always returns -1 since we never have colors. */
184
+ clientColorIndex(_i) {
185
+ return -1;
186
+ }
187
+ /** Always returns -1 since we never have auxiliary data. */
188
+ clientAuxIndex(_i) {
189
+ return -1;
190
+ }
176
191
  /** return the client polyface */
177
- clientPolyface() { return undefined; }
192
+ clientPolyface() {
193
+ return undefined;
194
+ }
178
195
  /** clear the contents of all arrays. Use this along with transferDataFrom methods to build up new facets */
179
196
  clearArrays() {
180
197
  if (this.point !== undefined)
@@ -198,12 +215,93 @@ export class ExportGraphicsMeshVisitor extends PolyfaceData {
198
215
  /** transfer data from a specified index of the other visitor as new data in this visitor. */
199
216
  pushDataFrom(other, index) {
200
217
  this.point.pushFromGrowableXYZArray(other.point, index);
201
- if (this.color && other.color && index < other.color.length)
202
- this.color.push(other.color[index]);
203
218
  if (this.param && other.param && index < other.param.length)
204
219
  this.param.pushFromGrowableXYArray(other.param, index);
205
220
  if (this.normal && other.normal && index < other.normal.length)
206
221
  this.normal.pushFromGrowableXYZArray(other.normal, index);
222
+ // ignore color and aux -- they never exist.
223
+ }
224
+ /** Return the number of facets this visitor is able to visit */
225
+ getVisitableFacetCount() {
226
+ return Math.floor(this._polyface.indices.length / 3);
227
+ }
228
+ /** Create a visitor for a subset of the facets visitable by the instance. */
229
+ createSubsetVisitor(facetIndices, numWrap = 0) {
230
+ return ExportGraphicsMeshSubsetVisitor.createSubsetVisitor(this._polyface, facetIndices, numWrap);
231
+ }
232
+ }
233
+ /**
234
+ * An `ExportGraphicsMeshSubsetVisitor` is an `ExportGraphicsMeshVisitor` which only visits a subset of the facets.
235
+ * * The subset is defined by an array of facet indices provided when this visitor is created.
236
+ * * Input indices (e.g., for `moveToReadIndex`) are understood to be indices into the subset array.
237
+ * @public
238
+ */
239
+ export class ExportGraphicsMeshSubsetVisitor extends ExportGraphicsMeshVisitor {
240
+ _facetIndices;
241
+ _currentSubsetIndex; // index within _parentFacetIndices, or -1 after construction
242
+ _nextSubsetIndex; // index within _parentFacetIndices
243
+ constructor(polyface, facetIndices, numWrap) {
244
+ super(polyface, numWrap);
245
+ this._facetIndices = facetIndices.slice();
246
+ this._currentSubsetIndex = -1;
247
+ this._nextSubsetIndex = 0;
248
+ this.reset();
249
+ }
250
+ isValidSubsetIndex(index) {
251
+ return index >= 0 && index < this._facetIndices.length;
252
+ }
253
+ /**
254
+ * Create a visitor for iterating a subset of the facets of `polyface`.
255
+ * @param polyface reference to the client polyface, supplying facets
256
+ * @param facetIndices array of indices of facets in the client polyface to visit. This array is cloned.
257
+ * @param numWrap number of vertices replicated in the visitor arrays to facilitate simpler caller code. Default is zero.
258
+ */
259
+ static createSubsetVisitor(polyface, facetIndices, numWrap = 0) {
260
+ return new ExportGraphicsMeshSubsetVisitor(polyface, facetIndices, numWrap);
261
+ }
262
+ /**
263
+ * Advance the iterator to a particular facet in the subset of client polyface facets.
264
+ * @param subsetIndex index into the subset array, not to be confused with the client facet index.
265
+ * @return whether the iterator was successfully moved.
266
+ */
267
+ moveToReadIndex(subsetIndex) {
268
+ if (this.isValidSubsetIndex(subsetIndex)) {
269
+ this._currentSubsetIndex = subsetIndex;
270
+ this._nextSubsetIndex = subsetIndex + 1;
271
+ return super.moveToReadIndex(this._facetIndices[subsetIndex]);
272
+ }
273
+ return false;
274
+ }
275
+ /**
276
+ * Advance the iterator to the next facet in the subset of client polyface facets.
277
+ * @return whether the iterator was successfully moved.
278
+ */
279
+ moveToNextFacet() {
280
+ if (this._nextSubsetIndex !== this._currentSubsetIndex)
281
+ return this.moveToReadIndex(this._nextSubsetIndex);
282
+ this._nextSubsetIndex++;
283
+ return true;
284
+ }
285
+ /** Restart the visitor at the first facet. */
286
+ reset() {
287
+ if (this._facetIndices) { // avoid crash during super ctor when we aren't yet initialized
288
+ this.moveToReadIndex(0);
289
+ this._nextSubsetIndex = 0; // so immediate moveToNextFacet stays here
290
+ }
291
+ }
292
+ /**
293
+ * Return the client polyface facet index (aka "readIndex") for the given subset index.
294
+ * @param subsetIndex index into the subset array. Default is the subset index of the currently visited facet.
295
+ * @return valid client polyface facet index, or `undefined` if invalid subset index.
296
+ */
297
+ parentFacetIndex(subsetIndex) {
298
+ if (undefined === subsetIndex)
299
+ subsetIndex = this._currentSubsetIndex;
300
+ return this.isValidSubsetIndex(subsetIndex) ? this._facetIndices[subsetIndex] : undefined;
301
+ }
302
+ /** Return the number of facets this visitor is able to visit. */
303
+ getVisitableFacetCount() {
304
+ return this._facetIndices.length;
207
305
  }
208
306
  }
209
307
  //# sourceMappingURL=ExportGraphics.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExportGraphics.js","sourceRoot":"","sources":["../../src/ExportGraphics.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAyB,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAY,YAAY,EAAmB,MAAM,sBAAsB,CAAC;AAkQhG;;GAEG;AACH,MAAM,KAAW,cAAc,CAuD9B;AAvDD,WAAiB,cAAc;IAC7B;;OAEG;IACH,SAAgB,wBAAwB,CAAC,GAA0B,EAAE,GAA0B;QAC7F,IAAI,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,UAAU;YACnC,OAAO,KAAK,CAAC;QACf,IAAI,GAAG,CAAC,aAAa,KAAK,GAAG,CAAC,aAAa;YACzC,OAAO,KAAK,CAAC;QACf,IAAI,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,UAAU;YACnC,OAAO,KAAK,CAAC;QACf,IAAI,GAAG,CAAC,eAAe,KAAK,GAAG,CAAC,eAAe;YAC7C,OAAO,KAAK,CAAC;QACf,IAAI,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC,SAAS;YACjC,OAAO,KAAK,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAZe,uCAAwB,2BAYvC,CAAA;IAED;;;;OAIG;IACH,SAAgB,wBAAwB,CAAC,IAAwB;QAC/D,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAE5E,MAAM,CAAC,GAA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,wBAAwB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;CAEF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ExportGraphics\n */\n\nimport { assert, Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport { IndexedPolyface, Polyface, PolyfaceData, PolyfaceVisitor } from \"@itwin/core-geometry\";\nimport { ColorDefProps, GeometryClass } from \"@itwin/core-common\";\n\n/** A collection of line segments, suitable for direct use with graphics APIs.\n * The structure of this data matches GL_LINES in OpenGL.\n * See [IModelDb.exportGraphics]($core-backend)\n * @public\n */\nexport interface ExportGraphicsLines {\n /** Zero-based vertex indices, every two indices represent a line segment */\n indices: Int32Array;\n /** Vertices for these lines, laid out in the pattern XYZXYZ */\n points: Float64Array;\n}\n\n/** Info provided to ExportLinesFunction about linework graphics.\n * See [IModelDb.exportGraphics]($core-backend)\n * @public\n */\nexport interface ExportLinesInfo {\n /** The element ID for the element the graphics originated from */\n elementId: Id64String;\n /** ID for the [SubCategory]($core-backend) for these graphics */\n subCategory: Id64String;\n /** The color and transparency for these graphics */\n color: ColorDefProps;\n /** GeometryClass for these graphics */\n geometryClass: GeometryClass;\n /** The linework for these graphics */\n lines: ExportGraphicsLines;\n}\n\n/** A callback function that receives generated line graphics.\n * See [IModelDb.exportGraphics]($core-backend)\n * @public\n */\nexport type ExportLinesFunction = (info: ExportLinesInfo) => void;\n\n/** A triangulated mesh with unified indices, suitable for direct use with graphics APIs.\n * See [IModelDb.exportGraphics]($core-backend)\n * @public\n */\nexport interface ExportGraphicsMesh {\n /** Zero-based vertex indices, every three indices represent a triangle */\n indices: Int32Array;\n /** Vertices for this mesh, laid out in the pattern XYZXYZ */\n points: Float64Array;\n /** Normals for this mesh, laid out in the pattern XYZXYZ */\n normals: Float32Array;\n /** Parameters (uvs) for this mesh, laid out in the pattern XYXY */\n params: Float32Array;\n /** If true, clients should assume both sides of the mesh are visible and not cull backfaces. */\n isTwoSided: boolean;\n}\n\n/** Info provided to ExportGraphicsFunction about graphics.\n * See [IModelDb.exportGraphics]($core-backend)\n * @public\n */\nexport interface ExportGraphicsInfo {\n /** The element ID for the element the graphics originated from */\n elementId: Id64String;\n /** ID for the [SubCategory]($core-backend) for these graphics */\n subCategory: Id64String;\n /** The color and transparency for these graphics */\n color: ColorDefProps;\n /** GeometryClass for these graphics */\n geometryClass: GeometryClass;\n /** If defined, ID for the [RenderMaterialElement]($core-backend) for these graphics */\n materialId?: Id64String;\n /** If defined, ID for the [Texture]($core-backend) for these graphics */\n textureId?: Id64String;\n /** The mesh for these graphics */\n mesh: ExportGraphicsMesh;\n}\n\n/** Information about the base display properties when a [GeometryPart]($core-backend) was\n * referenced. This is intended to be used with [IModelDb.exportPartGraphics]($core-backend).\n * * If two ExportPartInstanceInfo have the same ExportPartDisplayInfos, they will result in the\n * same graphics (with a different transform).\n * * If two ExportPartInstanceInfo have different ExportPartDisplayInfos, they may result in different\n * graphics.\n * @public\n */\nexport interface ExportPartDisplayInfo {\n categoryId: Id64String;\n subCategoryId: Id64String;\n geometryClass: GeometryClass;\n materialId: Id64String;\n elmTransparency: number;\n lineColor: number;\n}\n\n/** Information about references to [GeometryPart]($core-backend) elements found during\n * a call to [IModelDb.exportGraphics]($core-backend).\n * See [IModelDb.exportPartGraphics]($core-backend) for the intended use case.\n * @public\n */\nexport interface ExportPartInstanceInfo {\n /** ID for the [GeometryPart]($core-backend) */\n partId: Id64String;\n /** ID for the element that contained the reference to the [GeometryPart]($core-backend) */\n partInstanceId: Id64String;\n /** The base display properties when the [GeometryPart]($core-backend) was referenced. */\n displayProps: ExportPartDisplayInfo;\n /** A row-major storage 4x3 transform for this instance.\n * See export-gltf under test-apps in the iTwin.js monorepo for a working reference.\n */\n transform?: Float64Array;\n}\n\n/** A callback function that receives generated graphics.\n * See [IModelDb.exportGraphics]($core-backend)\n * @public\n */\nexport type ExportGraphicsFunction = (info: ExportGraphicsInfo) => void;\n\n/** Parameters for [IModelDb.exportGraphics]($core-backend)\n * @public\n */\nexport interface ExportGraphicsOptions {\n /** The source elements for the exported graphics */\n elementIdArray: Id64Array;\n /** A function to call for each unique element ID, color and texture combination */\n onGraphics: ExportGraphicsFunction;\n /** An optional function to call if line graphics are desired. */\n onLineGraphics?: ExportLinesFunction;\n /** If supplied, any references to [GeometryPart]($core-backend) elements found will be\n * recorded in this array. In this case, graphics that would result from the GeometryPart\n * will not be supplied via onGraphics. See [IModelDb.exportPartGraphics]($core-backend)\n */\n partInstanceArray?: ExportPartInstanceInfo[];\n /** Max distance from a face to the original geometry, see [StrokeOptions]($core-geometry).\n * If not supplied, defaults to zero and angleTol will control the quality of the resulting mesh.\n */\n chordTol?: number;\n /** Max angle difference in radians for approximated face, see [StrokeOptions]($core-geometry).\n * If not supplied, defaults to PI/12 (15 degrees).\n */\n angleTol?: number;\n /** Max length of any edge in generated faces, see [StrokeOptions]($core-geometry).\n * If not supplied, there is no maximum length of an edge. Supplying this value can greatly increase the\n * size of the resulting geometry, and should only be done in cases where necessary (if you don't know\n * that it's necessary, it's almost certainly not!)\n */\n maxEdgeLength?: number;\n /** The longest dimension of a line style's largest component must be at least this size in order for\n * exportGraphics to evaluate and generate its graphics. If undefined, this defaults to 0.1.\n * Line styles can evaluate to 3D geometry that clients expect to receive from exportGraphics, but they\n * can also generate gigabytes of mesh data when line styles with small components are applied to long\n * line strings.\n */\n minLineStyleComponentSize?: number;\n /** Max distance between mesh vertices for them to be collapsed.\n * Meshes stored in GeometryStreams are unaffected by StrokeOptions settings. If decimationTol is undefined,\n * they are output from exportGraphics without any reduction in quality and can be too detailed for\n * some uses. However, decimation is a destructive operation that can introduce gaps and other visual\n * anomalies so it is important to choose an appropriate setting for your use case.\n */\n decimationTol?: number;\n /** BRep features with bounding boxes smaller than this size will not generate graphics.\n * This option can be used to ignore expensive details from [BRepEntity.DataProps]($core-common)\n * like screws and screw holes.\n */\n minBRepFeatureSize?: number;\n}\n\n/** Info provided to ExportPartFunction about graphics.\n * See [IModelDb.exportPartGraphics]($core-backend)\n * @public\n */\nexport interface ExportPartInfo {\n /** The color and transparency for these graphics */\n color: ColorDefProps;\n /** GeometryClass for these graphics */\n geometryClass: GeometryClass;\n /** If defined, ID for the [RenderMaterialElement]($core-backend) for these graphics */\n materialId?: Id64String;\n /** If defined, ID for the [Texture]($core-backend) for these graphics */\n textureId?: Id64String;\n /** The mesh for these graphics */\n mesh: ExportGraphicsMesh;\n}\n\n/** A callback function that receives generated graphics for a [GeometryPart]($core-backend).\n * See [IModelDb.exportPartGraphics]($core-backend)\n * @public\n */\nexport type ExportPartFunction = (info: ExportPartInfo) => void;\n\n/** Info provided to ExportPartFunction about line graphics.\n * See [IModelDb.exportPartGraphics]($core-backend)\n * @public\n */\nexport interface ExportPartLinesInfo {\n /** The color and transparency for these graphics */\n color: ColorDefProps;\n /** GeometryClass for these graphics */\n geometryClass: GeometryClass;\n /** The linework for these graphics */\n lines: ExportGraphicsLines;\n}\n\n/** A callback function that receives generated line graphics for a [GeometryPart]($core-backend).\n * See [IModelDb.exportPartGraphics]($core-backend)\n * @public\n */\nexport type ExportPartLinesFunction = (info: ExportPartLinesInfo) => void;\n\n/** Parameters for [IModelDb.exportPartGraphics]($core-backend)\n * @public\n */\nexport interface ExportPartGraphicsOptions {\n /** The ID for the source [GeometryPart]($core-backend) */\n elementId: Id64String;\n /** The base display properties to use for generating the graphics. This should come from an\n * ExportPartInstanceProps generated by [IModelDb.exportGraphics]($core-backend)\n */\n displayProps: ExportPartDisplayInfo;\n /** A function to call for each unique color and texture combination. */\n onPartGraphics: ExportPartFunction;\n /** An optional function to call if line graphics are desired. */\n onPartLineGraphics?: ExportPartLinesFunction;\n /** Max distance from a face to the original geometry, see [StrokeOptions]($core-geometry).\n * If not supplied, defaults to zero and angleTol will control the quality of the resulting mesh.\n */\n chordTol?: number;\n /** Max angle difference in radians for approximated face, see [StrokeOptions]($core-geometry).\n * If not supplied, defaults to PI/12 (15 degrees).\n */\n angleTol?: number;\n /** Max length of any edge in generated faces, see [StrokeOptions]($core-geometry)\n * If not supplied, there is no maximum length of an edge. Supplying this value can greatly increase the\n * size of the resulting geometry, and should only be done in cases where necessary (if you don't know\n * that it's necessary, it's almost certainly not!)\n */\n maxEdgeLength?: number;\n /** The longest dimension of a line style's largest component must be at least this size in order for\n * exportGraphics to evaluate and generate its graphics. If undefined, this defaults to 0.1.\n * Line styles can evaluate to 3D geometry that clients expect to receive from exportGraphics, but they\n * can also generate gigabytes of mesh data when line styles with small components are applied to long\n * line strings.\n */\n minLineStyleComponentSize?: number;\n /** Max distance between mesh vertices for them to be collapsed.\n * Meshes stored in GeometryStreams are unaffected by StrokeOptions settings. If decimationTol is undefined,\n * they are output from exportGraphics without any reduction in quality and can be too detailed for\n * some uses. However, decimation is a destructive operation that can introduce gaps and other visual\n * anomalies so it is important to choose an appropriate setting for your use case.\n */\n decimationTol?: number;\n /** BRep features with bounding boxes smaller than this size will not generate graphics.\n * This option can be used to ignore expensive details from [BRepEntity.DataProps]($core-common)\n * like screws and screw holes.\n */\n minBRepFeatureSize?: number;\n}\n\n/** Provides utility functions for working with data generated by [IModelDb.exportGraphics]($core-backend)\n * @public\n */\nexport namespace ExportGraphics {\n /** Test if ExportPartDisplayInfos have exactly the same values.\n * @public\n */\n export function arePartDisplayInfosEqual(lhs: ExportPartDisplayInfo, rhs: ExportPartDisplayInfo): boolean {\n if (lhs.categoryId !== rhs.categoryId)\n return false;\n if (lhs.subCategoryId !== rhs.subCategoryId)\n return false;\n if (lhs.materialId !== rhs.materialId)\n return false;\n if (lhs.elmTransparency !== rhs.elmTransparency)\n return false;\n if (lhs.lineColor !== rhs.lineColor)\n return false;\n return true;\n }\n\n /**\n * Convert an ExportGraphicsMesh to an IndexedPolyface usable by the geometry API.\n * @note The resulting IndexedPolyface may have duplicate points, normals and params. If problematic, call [PolyfaceData.compress]($core-geometry)\n * @public\n */\n export function convertToIndexedPolyface(mesh: ExportGraphicsMesh): IndexedPolyface {\n const polyface = IndexedPolyface.create(true, true, false, mesh.isTwoSided);\n\n const p: Float64Array = mesh.points;\n for (let i = 0; i < p.length; i += 3)\n polyface.data.point.pushXYZ(p[i], p[i + 1], p[i + 2]);\n\n const n: Float32Array = mesh.normals;\n assert(undefined !== polyface.data.normal);\n for (let i = 0; i < n.length; i += 3)\n polyface.data.normal.pushXYZ(n[i], n[i + 1], n[i + 2]);\n\n const uv: Float32Array = mesh.params;\n assert(undefined !== polyface.data.param);\n for (let i = 0; i < uv.length; i += 2)\n polyface.data.param.pushXY(uv[i], uv[i + 1]);\n\n const indices = mesh.indices;\n const addIndex = (idx: number) => {\n polyface.addPointIndex(idx, true);\n polyface.addNormalIndex(idx);\n polyface.addParamIndex(idx);\n };\n for (let i = 0; i < indices.length; i += 3) {\n addIndex(indices[i]);\n addIndex(indices[i + 1]);\n addIndex(indices[i + 2]);\n polyface.terminateFacet(false);\n }\n\n return polyface;\n }\n}\n/**\n * * Iterator to walk the facets of an ExportGraphicsMesh and present them to the world as if visiting a Polyface.\n * * Because the ExportGraphicsMesh has limited data:\n * * There is no auxData in this visitor.\n * * There is no color in this visitor.\n * * All edgeVisible are true.\n * @public\n */\nexport class ExportGraphicsMeshVisitor extends PolyfaceData implements PolyfaceVisitor {\n private _currentFacetIndex: number;\n private _nextFacetIndex: number;\n private _numWrap: number;\n private _polyface: ExportGraphicsMesh;\n // to be called from static factory method that validates the polyface ...\n private constructor(facets: ExportGraphicsMesh, numWrap: number) {\n super(facets.normals.length > 0, facets.params.length > 0, false, facets.isTwoSided);\n this._polyface = facets;\n this._numWrap = numWrap;\n\n this._nextFacetIndex = 0;\n this._currentFacetIndex = -1;\n this.twoSided = facets.isTwoSided;\n this.reset();\n }\n /** Create a visitor for iterating the facets of `polyface`, with indicated number of points to be added to each facet to produce closed point arrays\n * Typical wrap counts are:\n * * 0 -- leave the point arrays with \"missing final edge\"\n * * 1 -- add point 0 as closure point\n * * 2 -- add points 0 and 1 as closure and wrap point. This is useful when vertex visit requires two adjacent vectors, e.g. for cross products.\n */\n public static create(polyface: ExportGraphicsMesh, numWrap: number): ExportGraphicsMeshVisitor {\n return new ExportGraphicsMeshVisitor(polyface, numWrap);\n }\n /** Reset the iterator to start at the first facet of the polyface. */\n public reset(): void {\n this.moveToReadIndex(0);\n this._nextFacetIndex = 0; // so immediate moveToNextFacet stays here.\n }\n /** Select a facet by simple index. */\n public moveToReadIndex(facetIndex: number): boolean {\n if (facetIndex < 0 || 2 + facetIndex * 3 >= this._polyface.indices.length)\n return false;\n this._currentFacetIndex = facetIndex;\n this._nextFacetIndex = facetIndex + 1;\n this.point.length = 0;\n const points = this.point;\n points.length = 0;\n this.pointIndex.length = 0;\n this.point.length = 0;\n this.edgeVisible.length = 0;\n const sourcePoints = this._polyface.points;\n const indices = this._polyface.indices;\n const i0 = 3 * facetIndex;\n for (let i = i0; i < i0 + 3; i++) {\n const k = 3 * indices[i];\n this.pointIndex.push(indices[i]);\n this.point.pushXYZ(sourcePoints[k], sourcePoints[k + 1], sourcePoints[k + 2]);\n this.edgeVisible.push(true);\n }\n for (let i = 0; i < this._numWrap; i++) {\n this.point.pushFromGrowableXYZArray(this.point, i);\n }\n\n const sourceParams = this._polyface.params;\n if (sourceParams.length > 0 && this.paramIndex && this.param) {\n this.paramIndex.length = 0;\n this.param.length = 0;\n for (let i = i0; i < i0 + 3; i++) {\n const k = 2 * indices[i];\n this.paramIndex.push(indices[i]);\n this.param.pushXY(sourceParams[k], sourceParams[k + 1]);\n }\n for (let i = 0; i < this._numWrap; i++) {\n this.param.pushFromGrowableXYArray(this.param, i);\n }\n }\n\n const sourceNormals = this._polyface.normals;\n if (sourceNormals.length > 0 && this.normalIndex && this.normal) {\n this.normalIndex.length = 0;\n this.normal.length = 0;\n for (let i = i0; i < i0 + 3; i++) {\n const k = 3 * indices[i];\n this.normalIndex.push(indices[i]);\n this.normal.pushXYZ(sourceNormals[k], sourceNormals[k + 1], sourceNormals[k + 2]);\n }\n for (let i = 0; i < this._numWrap; i++) {\n this.normal.pushFromGrowableXYZArray(this.normal, i);\n }\n }\n return true;\n }\n public moveToNextFacet(): boolean {\n return this.moveToReadIndex(this._nextFacetIndex);\n }\n /** Set the number of vertices to replicate in visitor arrays. */\n public setNumWrap(numWrap: number): void { this._numWrap = numWrap; }\n\n /** Return the index (in the client polyface) of the current facet */\n public currentReadIndex(): number { return this._currentFacetIndex; }\n /** Return the point index of vertex i within the currently loaded facet */\n public clientPointIndex(i: number): number { return this.pointIndex[i]; }\n /** Return the param index of vertex i within the currently loaded facet.\n * Use the artificial paramIndex, which matches pointIndex.\n */\n public clientParamIndex(i: number): number { return this.paramIndex ? this.paramIndex[i] : -1; }\n /** Return the normal index of vertex i within the currently loaded facet.\n * Use the artificial paramIndex, which matches pointIndex.\n */\n public clientNormalIndex(i: number): number { return this.normalIndex ? this.normalIndex[i] : -1; }\n /** Return the color index of vertex i within the currently loaded facet */\n public clientColorIndex(_i: number): number { return 1; }\n /** Return the aux data index of vertex i within the currently loaded facet */\n public clientAuxIndex(_i: number): number { return -1; }\n\n /** return the client polyface */\n public clientPolyface(): Polyface { return (undefined as unknown) as Polyface; }\n /** clear the contents of all arrays. Use this along with transferDataFrom methods to build up new facets */\n public clearArrays(): void {\n if (this.point !== undefined)\n this.point.length = 0;\n if (this.param !== undefined)\n this.param.length = 0;\n if (this.normal !== undefined)\n this.normal.length = 0;\n // ignore color and aux -- they never exist.\n }\n /** transfer interpolated data from the other visitor.\n * * all data values are interpolated at `fraction` between `other` values at index0 and index1.\n */\n public pushInterpolatedDataFrom(other: PolyfaceVisitor, index0: number, fraction: number, index1: number): void {\n this.point.pushInterpolatedFromGrowableXYZArray(other.point, index0, fraction, index1);\n if (this.param && other.param && index0 < other.param.length && index1 < other.param.length)\n this.param.pushInterpolatedFromGrowableXYArray(other.param, index0, fraction, index1);\n if (this.normal && other.normal && index0 < other.normal.length && index1 < other.normal.length)\n this.normal.pushInterpolatedFromGrowableXYZArray(other.normal, index0, fraction, index1);\n }\n /** transfer data from a specified index of the other visitor as new data in this visitor. */\n public pushDataFrom(other: PolyfaceVisitor, index: number): void {\n this.point.pushFromGrowableXYZArray(other.point, index);\n if (this.color && other.color && index < other.color.length)\n this.color.push(other.color[index]);\n if (this.param && other.param && index < other.param.length)\n this.param.pushFromGrowableXYArray(other.param, index);\n if (this.normal && other.normal && index < other.normal.length)\n this.normal.pushFromGrowableXYZArray(other.normal, index);\n }\n\n}\n"]}
1
+ {"version":3,"file":"ExportGraphics.js","sourceRoot":"","sources":["../../src/ExportGraphics.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAyB,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAY,YAAY,EAAmB,MAAM,sBAAsB,CAAC;AAkQhG;;GAEG;AACH,MAAM,KAAW,cAAc,CAuD9B;AAvDD,WAAiB,cAAc;IAC7B;;OAEG;IACH,SAAgB,wBAAwB,CAAC,GAA0B,EAAE,GAA0B;QAC7F,IAAI,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,UAAU;YACnC,OAAO,KAAK,CAAC;QACf,IAAI,GAAG,CAAC,aAAa,KAAK,GAAG,CAAC,aAAa;YACzC,OAAO,KAAK,CAAC;QACf,IAAI,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,UAAU;YACnC,OAAO,KAAK,CAAC;QACf,IAAI,GAAG,CAAC,eAAe,KAAK,GAAG,CAAC,eAAe;YAC7C,OAAO,KAAK,CAAC;QACf,IAAI,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC,SAAS;YACjC,OAAO,KAAK,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAZe,uCAAwB,2BAYvC,CAAA;IAED;;;;OAIG;IACH,SAAgB,wBAAwB,CAAC,IAAwB;QAC/D,MAAM,QAAQ,GAAG,eAAe,CA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,EAAE,CAAC;YACzC,IAAI,CAAC,mBAAmB,GAAG,WAAW,CAAC;YACvC,IAAI,CAAC,gBAAgB,GAAG,WAAW,GAAG,CAAC,CAAC;YACxC,OAAO,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD;;;OAGG;IACa,eAAe;QAC7B,IAAI,IAAI,CAAC,gBAAgB,KAAK,IAAI,CAAC,mBAAmB;YACpD,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACrD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,8CAA8C;IAC9B,KAAK;QACnB,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,+DAA+D;YACvF,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;YACxB,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC,0CAA0C;QACvE,CAAC;IACH,CAAC;IACD;;;;OAIG;IACI,gBAAgB,CAAC,WAAoB;QAC1C,IAAI,SAAS,KAAK,WAAW;YAC3B,WAAW,GAAG,IAAI,CAAC,mBAAmB,CAAC;QACzC,OAAO,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5F,CAAC;IACD,iEAAiE;IACjD,sBAAsB;QACpC,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;IACnC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ExportGraphics\n */\n\nimport { assert, Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport { IndexedPolyface, Polyface, PolyfaceData, PolyfaceVisitor } from \"@itwin/core-geometry\";\nimport { ColorDefProps, GeometryClass } from \"@itwin/core-common\";\n\n/** A collection of line segments, suitable for direct use with graphics APIs.\n * The structure of this data matches GL_LINES in OpenGL.\n * See [IModelDb.exportGraphics]($core-backend)\n * @public\n */\nexport interface ExportGraphicsLines {\n /** Zero-based vertex indices, every two indices represent a line segment */\n indices: Int32Array;\n /** Vertices for these lines, laid out in the pattern XYZXYZ */\n points: Float64Array;\n}\n\n/** Info provided to ExportLinesFunction about linework graphics.\n * See [IModelDb.exportGraphics]($core-backend)\n * @public\n */\nexport interface ExportLinesInfo {\n /** The element ID for the element the graphics originated from */\n elementId: Id64String;\n /** ID for the [SubCategory]($core-backend) for these graphics */\n subCategory: Id64String;\n /** The color and transparency for these graphics */\n color: ColorDefProps;\n /** GeometryClass for these graphics */\n geometryClass: GeometryClass;\n /** The linework for these graphics */\n lines: ExportGraphicsLines;\n}\n\n/** A callback function that receives generated line graphics.\n * See [IModelDb.exportGraphics]($core-backend)\n * @public\n */\nexport type ExportLinesFunction = (info: ExportLinesInfo) => void;\n\n/** A triangulated mesh with unified indices, suitable for direct use with graphics APIs.\n * See [IModelDb.exportGraphics]($core-backend)\n * @public\n */\nexport interface ExportGraphicsMesh {\n /** Zero-based vertex indices, every three indices represent a triangle */\n indices: Int32Array;\n /** Vertices for this mesh, laid out in the pattern XYZXYZ */\n points: Float64Array;\n /** Normals for this mesh, laid out in the pattern XYZXYZ */\n normals: Float32Array;\n /** Parameters (uvs) for this mesh, laid out in the pattern XYXY */\n params: Float32Array;\n /** If true, clients should assume both sides of the mesh are visible and not cull back faces. */\n isTwoSided: boolean;\n}\n\n/** Info provided to ExportGraphicsFunction about graphics.\n * See [IModelDb.exportGraphics]($core-backend)\n * @public\n */\nexport interface ExportGraphicsInfo {\n /** The element ID for the element the graphics originated from */\n elementId: Id64String;\n /** ID for the [SubCategory]($core-backend) for these graphics */\n subCategory: Id64String;\n /** The color and transparency for these graphics */\n color: ColorDefProps;\n /** GeometryClass for these graphics */\n geometryClass: GeometryClass;\n /** If defined, ID for the [RenderMaterialElement]($core-backend) for these graphics */\n materialId?: Id64String;\n /** If defined, ID for the [Texture]($core-backend) for these graphics */\n textureId?: Id64String;\n /** The mesh for these graphics */\n mesh: ExportGraphicsMesh;\n}\n\n/** Information about the base display properties when a [GeometryPart]($core-backend) was\n * referenced. This is intended to be used with [IModelDb.exportPartGraphics]($core-backend).\n * * If two ExportPartInstanceInfo have the same ExportPartDisplayInfos, they will result in the\n * same graphics (with a different transform).\n * * If two ExportPartInstanceInfo have different ExportPartDisplayInfos, they may result in different\n * graphics.\n * @public\n */\nexport interface ExportPartDisplayInfo {\n categoryId: Id64String;\n subCategoryId: Id64String;\n geometryClass: GeometryClass;\n materialId: Id64String;\n elmTransparency: number;\n lineColor: number;\n}\n\n/** Information about references to [GeometryPart]($core-backend) elements found during\n * a call to [IModelDb.exportGraphics]($core-backend).\n * See [IModelDb.exportPartGraphics]($core-backend) for the intended use case.\n * @public\n */\nexport interface ExportPartInstanceInfo {\n /** ID for the [GeometryPart]($core-backend) */\n partId: Id64String;\n /** ID for the element that contained the reference to the [GeometryPart]($core-backend) */\n partInstanceId: Id64String;\n /** The base display properties when the [GeometryPart]($core-backend) was referenced. */\n displayProps: ExportPartDisplayInfo;\n /** A row-major storage 4x3 transform for this instance.\n * See export-gltf under test-apps in the iTwin.js monorepo for a working reference.\n */\n transform?: Float64Array;\n}\n\n/** A callback function that receives generated graphics.\n * See [IModelDb.exportGraphics]($core-backend)\n * @public\n */\nexport type ExportGraphicsFunction = (info: ExportGraphicsInfo) => void;\n\n/** Parameters for [IModelDb.exportGraphics]($core-backend)\n * @public\n */\nexport interface ExportGraphicsOptions {\n /** The source elements for the exported graphics */\n elementIdArray: Id64Array;\n /** A function to call for each unique element ID, color and texture combination */\n onGraphics: ExportGraphicsFunction;\n /** An optional function to call if line graphics are desired. */\n onLineGraphics?: ExportLinesFunction;\n /** If supplied, any references to [GeometryPart]($core-backend) elements found will be\n * recorded in this array. In this case, graphics that would result from the GeometryPart\n * will not be supplied via onGraphics. See [IModelDb.exportPartGraphics]($core-backend)\n */\n partInstanceArray?: ExportPartInstanceInfo[];\n /** Max distance from a face to the original geometry, see [StrokeOptions]($core-geometry).\n * If not supplied, defaults to zero and angleTol will control the quality of the resulting mesh.\n */\n chordTol?: number;\n /** Max angle difference in radians for approximated face, see [StrokeOptions]($core-geometry).\n * If not supplied, defaults to PI/12 (15 degrees).\n */\n angleTol?: number;\n /** Max length of any edge in generated faces, see [StrokeOptions]($core-geometry).\n * If not supplied, there is no maximum length of an edge. Supplying this value can greatly increase the\n * size of the resulting geometry, and should only be done in cases where necessary (if you don't know\n * that it's necessary, it's almost certainly not!)\n */\n maxEdgeLength?: number;\n /** The longest dimension of a line style's largest component must be at least this size in order for\n * exportGraphics to evaluate and generate its graphics. If undefined, this defaults to 0.1.\n * Line styles can evaluate to 3D geometry that clients expect to receive from exportGraphics, but they\n * can also generate gigabytes of mesh data when line styles with small components are applied to long\n * line strings.\n */\n minLineStyleComponentSize?: number;\n /** Max distance between mesh vertices for them to be collapsed.\n * Meshes stored in GeometryStreams are unaffected by StrokeOptions settings. If decimationTol is undefined,\n * they are output from exportGraphics without any reduction in quality and can be too detailed for\n * some uses. However, decimation is a destructive operation that can introduce gaps and other visual\n * anomalies so it is important to choose an appropriate setting for your use case.\n */\n decimationTol?: number;\n /** BRep features with bounding boxes smaller than this size will not generate graphics.\n * This option can be used to ignore expensive details from [BRepEntity.DataProps]($core-common)\n * like screws and screw holes.\n */\n minBRepFeatureSize?: number;\n}\n\n/** Info provided to ExportPartFunction about graphics.\n * See [IModelDb.exportPartGraphics]($core-backend)\n * @public\n */\nexport interface ExportPartInfo {\n /** The color and transparency for these graphics */\n color: ColorDefProps;\n /** GeometryClass for these graphics */\n geometryClass: GeometryClass;\n /** If defined, ID for the [RenderMaterialElement]($core-backend) for these graphics */\n materialId?: Id64String;\n /** If defined, ID for the [Texture]($core-backend) for these graphics */\n textureId?: Id64String;\n /** The mesh for these graphics */\n mesh: ExportGraphicsMesh;\n}\n\n/** A callback function that receives generated graphics for a [GeometryPart]($core-backend).\n * See [IModelDb.exportPartGraphics]($core-backend)\n * @public\n */\nexport type ExportPartFunction = (info: ExportPartInfo) => void;\n\n/** Info provided to ExportPartFunction about line graphics.\n * See [IModelDb.exportPartGraphics]($core-backend)\n * @public\n */\nexport interface ExportPartLinesInfo {\n /** The color and transparency for these graphics */\n color: ColorDefProps;\n /** GeometryClass for these graphics */\n geometryClass: GeometryClass;\n /** The linework for these graphics */\n lines: ExportGraphicsLines;\n}\n\n/** A callback function that receives generated line graphics for a [GeometryPart]($core-backend).\n * See [IModelDb.exportPartGraphics]($core-backend)\n * @public\n */\nexport type ExportPartLinesFunction = (info: ExportPartLinesInfo) => void;\n\n/** Parameters for [IModelDb.exportPartGraphics]($core-backend)\n * @public\n */\nexport interface ExportPartGraphicsOptions {\n /** The ID for the source [GeometryPart]($core-backend) */\n elementId: Id64String;\n /** The base display properties to use for generating the graphics. This should come from an\n * ExportPartInstanceProps generated by [IModelDb.exportGraphics]($core-backend)\n */\n displayProps: ExportPartDisplayInfo;\n /** A function to call for each unique color and texture combination. */\n onPartGraphics: ExportPartFunction;\n /** An optional function to call if line graphics are desired. */\n onPartLineGraphics?: ExportPartLinesFunction;\n /** Max distance from a face to the original geometry, see [StrokeOptions]($core-geometry).\n * If not supplied, defaults to zero and angleTol will control the quality of the resulting mesh.\n */\n chordTol?: number;\n /** Max angle difference in radians for approximated face, see [StrokeOptions]($core-geometry).\n * If not supplied, defaults to PI/12 (15 degrees).\n */\n angleTol?: number;\n /** Max length of any edge in generated faces, see [StrokeOptions]($core-geometry)\n * If not supplied, there is no maximum length of an edge. Supplying this value can greatly increase the\n * size of the resulting geometry, and should only be done in cases where necessary (if you don't know\n * that it's necessary, it's almost certainly not!)\n */\n maxEdgeLength?: number;\n /** The longest dimension of a line style's largest component must be at least this size in order for\n * exportGraphics to evaluate and generate its graphics. If undefined, this defaults to 0.1.\n * Line styles can evaluate to 3D geometry that clients expect to receive from exportGraphics, but they\n * can also generate gigabytes of mesh data when line styles with small components are applied to long\n * line strings.\n */\n minLineStyleComponentSize?: number;\n /** Max distance between mesh vertices for them to be collapsed.\n * Meshes stored in GeometryStreams are unaffected by StrokeOptions settings. If decimationTol is undefined,\n * they are output from exportGraphics without any reduction in quality and can be too detailed for\n * some uses. However, decimation is a destructive operation that can introduce gaps and other visual\n * anomalies so it is important to choose an appropriate setting for your use case.\n */\n decimationTol?: number;\n /** BRep features with bounding boxes smaller than this size will not generate graphics.\n * This option can be used to ignore expensive details from [BRepEntity.DataProps]($core-common)\n * like screws and screw holes.\n */\n minBRepFeatureSize?: number;\n}\n\n/** Provides utility functions for working with data generated by [IModelDb.exportGraphics]($core-backend)\n * @public\n */\nexport namespace ExportGraphics {\n /** Test if ExportPartDisplayInfos have exactly the same values.\n * @public\n */\n export function arePartDisplayInfosEqual(lhs: ExportPartDisplayInfo, rhs: ExportPartDisplayInfo): boolean {\n if (lhs.categoryId !== rhs.categoryId)\n return false;\n if (lhs.subCategoryId !== rhs.subCategoryId)\n return false;\n if (lhs.materialId !== rhs.materialId)\n return false;\n if (lhs.elmTransparency !== rhs.elmTransparency)\n return false;\n if (lhs.lineColor !== rhs.lineColor)\n return false;\n return true;\n }\n\n /**\n * Convert an ExportGraphicsMesh to an IndexedPolyface usable by the geometry API.\n * @note The resulting IndexedPolyface may have duplicate points, normals and params. If problematic, call [PolyfaceData.compress]($core-geometry)\n * @public\n */\n export function convertToIndexedPolyface(mesh: ExportGraphicsMesh): IndexedPolyface {\n const polyface = IndexedPolyface.create(true, true, false, mesh.isTwoSided);\n\n const p: Float64Array = mesh.points;\n for (let i = 0; i < p.length; i += 3)\n polyface.data.point.pushXYZ(p[i], p[i + 1], p[i + 2]);\n\n const n: Float32Array = mesh.normals;\n assert(undefined !== polyface.data.normal);\n for (let i = 0; i < n.length; i += 3)\n polyface.data.normal.pushXYZ(n[i], n[i + 1], n[i + 2]);\n\n const uv: Float32Array = mesh.params;\n assert(undefined !== polyface.data.param);\n for (let i = 0; i < uv.length; i += 2)\n polyface.data.param.pushXY(uv[i], uv[i + 1]);\n\n const indices = mesh.indices;\n const addIndex = (idx: number) => {\n polyface.addPointIndex(idx, true);\n polyface.addNormalIndex(idx);\n polyface.addParamIndex(idx);\n };\n for (let i = 0; i < indices.length; i += 3) {\n addIndex(indices[i]);\n addIndex(indices[i + 1]);\n addIndex(indices[i + 2]);\n polyface.terminateFacet(false);\n }\n\n return polyface;\n }\n}\n/**\n * * Iterator to walk the facets of an ExportGraphicsMesh and present them to the world as if visiting a Polyface.\n * * Because the ExportGraphicsMesh has limited data:\n * * There is no auxData in this visitor.\n * * There is no color in this visitor.\n * * All edgeVisible are true.\n * @public\n */\nexport class ExportGraphicsMeshVisitor extends PolyfaceData implements PolyfaceVisitor {\n private _currentFacetIndex: number;\n private _nextFacetIndex: number;\n private _numWrap: number;\n private _polyface: ExportGraphicsMesh;\n protected constructor(facets: ExportGraphicsMesh, numWrap: number) {\n super(facets.normals.length > 0, facets.params.length > 0, false, facets.isTwoSided);\n this._polyface = facets;\n this._numWrap = numWrap;\n this._nextFacetIndex = 0;\n this._currentFacetIndex = -1;\n this.reset();\n }\n /** Create a visitor for iterating the facets of `polyface`, with indicated number of points to be added to each facet to produce closed point arrays\n * Typical wrap counts are:\n * * 0 -- leave the point arrays with \"missing final edge\" (default)\n * * 1 -- add point 0 as closure point\n * * 2 -- add points 0 and 1 as closure and wrap point. This is useful when vertex visit requires two adjacent vectors, e.g. for cross products.\n */\n public static create(polyface: ExportGraphicsMesh, numWrap: number = 0): ExportGraphicsMeshVisitor {\n return new ExportGraphicsMeshVisitor(polyface, numWrap);\n }\n /** Restart the visitor at the first facet. */\n public reset(): void {\n this.moveToReadIndex(0);\n this._nextFacetIndex = 0; // so immediate moveToNextFacet stays here\n }\n /** Select a facet by simple index. */\n public moveToReadIndex(facetIndex: number): boolean {\n if (facetIndex < 0 || 2 + facetIndex * 3 >= this._polyface.indices.length)\n return false;\n if (this._currentFacetIndex !== facetIndex || 3 + this._numWrap !== this.point.length) {\n this._currentFacetIndex = facetIndex;\n this.point.length = 0;\n this.pointIndex.length = 0;\n this.edgeVisible.length = 0;\n const sourcePoints = this._polyface.points;\n const indices = this._polyface.indices;\n const i0 = 3 * facetIndex;\n for (let i = i0; i < i0 + 3; i++) {\n const k = 3 * indices[i];\n this.pointIndex.push(indices[i]);\n this.point.pushXYZ(sourcePoints[k], sourcePoints[k + 1], sourcePoints[k + 2]);\n this.edgeVisible.push(true);\n }\n for (let i = 0; i < this._numWrap; i++) {\n this.point.pushFromGrowableXYZArray(this.point, i);\n }\n\n const sourceParams = this._polyface.params;\n if (sourceParams.length > 0 && this.paramIndex && this.param) {\n this.paramIndex.length = 0;\n this.param.length = 0;\n for (let i = i0; i < i0 + 3; i++) {\n const k = 2 * indices[i];\n this.paramIndex.push(indices[i]);\n this.param.pushXY(sourceParams[k], sourceParams[k + 1]);\n }\n for (let i = 0; i < this._numWrap; i++) {\n this.param.pushFromGrowableXYArray(this.param, i);\n }\n }\n\n const sourceNormals = this._polyface.normals;\n if (sourceNormals.length > 0 && this.normalIndex && this.normal) {\n this.normalIndex.length = 0;\n this.normal.length = 0;\n for (let i = i0; i < i0 + 3; i++) {\n const k = 3 * indices[i];\n this.normalIndex.push(indices[i]);\n this.normal.pushXYZ(sourceNormals[k], sourceNormals[k + 1], sourceNormals[k + 2]);\n }\n for (let i = 0; i < this._numWrap; i++) {\n this.normal.pushFromGrowableXYZArray(this.normal, i);\n }\n }\n }\n this._nextFacetIndex = facetIndex + 1;\n return true;\n }\n /** Load data for the next facet. */\n public moveToNextFacet(): boolean {\n if (this._nextFacetIndex !== this._currentFacetIndex)\n return this.moveToReadIndex(this._nextFacetIndex);\n this._nextFacetIndex++;\n return true;\n }\n /** Set the number of vertices to replicate in visitor arrays. */\n public setNumWrap(numWrap: number): void {\n this._numWrap = numWrap;\n }\n\n /** Return the index (in the client polyface) of the current facet */\n public currentReadIndex(): number {\n return this._currentFacetIndex;\n }\n /** Return the point index of vertex i within the currently loaded facet */\n public clientPointIndex(i: number): number {\n return this.pointIndex[i];\n }\n /** Return the param index of vertex i within the currently loaded facet.\n * Use the artificial paramIndex, which matches pointIndex.\n */\n public clientParamIndex(i: number): number {\n return this.paramIndex ? this.paramIndex[i] : -1;\n }\n /** Return the normal index of vertex i within the currently loaded facet.\n * Use the artificial paramIndex, which matches pointIndex.\n */\n public clientNormalIndex(i: number): number {\n return this.normalIndex ? this.normalIndex[i] : -1;\n }\n /** Always returns -1 since we never have colors. */\n public clientColorIndex(_i: number): number {\n return -1;\n }\n /** Always returns -1 since we never have auxiliary data. */\n public clientAuxIndex(_i: number): number {\n return -1;\n }\n /** return the client polyface */\n public clientPolyface(): Polyface | undefined {\n return undefined;\n }\n /** clear the contents of all arrays. Use this along with transferDataFrom methods to build up new facets */\n public clearArrays(): void {\n if (this.point !== undefined)\n this.point.length = 0;\n if (this.param !== undefined)\n this.param.length = 0;\n if (this.normal !== undefined)\n this.normal.length = 0;\n // ignore color and aux -- they never exist.\n }\n /** transfer interpolated data from the other visitor.\n * * all data values are interpolated at `fraction` between `other` values at index0 and index1.\n */\n public pushInterpolatedDataFrom(other: PolyfaceVisitor, index0: number, fraction: number, index1: number): void {\n this.point.pushInterpolatedFromGrowableXYZArray(other.point, index0, fraction, index1);\n if (this.param && other.param && index0 < other.param.length && index1 < other.param.length)\n this.param.pushInterpolatedFromGrowableXYArray(other.param, index0, fraction, index1);\n if (this.normal && other.normal && index0 < other.normal.length && index1 < other.normal.length)\n this.normal.pushInterpolatedFromGrowableXYZArray(other.normal, index0, fraction, index1);\n }\n /** transfer data from a specified index of the other visitor as new data in this visitor. */\n public pushDataFrom(other: PolyfaceVisitor, index: number): void {\n this.point.pushFromGrowableXYZArray(other.point, index);\n if (this.param && other.param && index < other.param.length)\n this.param.pushFromGrowableXYArray(other.param, index);\n if (this.normal && other.normal && index < other.normal.length)\n this.normal.pushFromGrowableXYZArray(other.normal, index);\n // ignore color and aux -- they never exist.\n }\n /** Return the number of facets this visitor is able to visit */\n public getVisitableFacetCount(): number {\n return Math.floor(this._polyface.indices.length / 3);\n }\n /** Create a visitor for a subset of the facets visitable by the instance. */\n public createSubsetVisitor(facetIndices: number[], numWrap: number = 0): ExportGraphicsMeshSubsetVisitor {\n return ExportGraphicsMeshSubsetVisitor.createSubsetVisitor(this._polyface, facetIndices, numWrap);\n }\n}\n\n/**\n * An `ExportGraphicsMeshSubsetVisitor` is an `ExportGraphicsMeshVisitor` which only visits a subset of the facets.\n * * The subset is defined by an array of facet indices provided when this visitor is created.\n * * Input indices (e.g., for `moveToReadIndex`) are understood to be indices into the subset array.\n * @public\n */\nexport class ExportGraphicsMeshSubsetVisitor extends ExportGraphicsMeshVisitor {\n private _facetIndices: number[];\n private _currentSubsetIndex: number; // index within _parentFacetIndices, or -1 after construction\n private _nextSubsetIndex: number; // index within _parentFacetIndices\n\n private constructor(polyface: ExportGraphicsMesh, facetIndices: number[], numWrap: number) {\n super(polyface, numWrap);\n this._facetIndices = facetIndices.slice();\n this._currentSubsetIndex = -1;\n this._nextSubsetIndex = 0;\n this.reset();\n }\n private isValidSubsetIndex(index: number): boolean {\n return index >= 0 && index < this._facetIndices.length;\n }\n /**\n * Create a visitor for iterating a subset of the facets of `polyface`.\n * @param polyface reference to the client polyface, supplying facets\n * @param facetIndices array of indices of facets in the client polyface to visit. This array is cloned.\n * @param numWrap number of vertices replicated in the visitor arrays to facilitate simpler caller code. Default is zero.\n */\n public static createSubsetVisitor(\n polyface: ExportGraphicsMesh, facetIndices: number[], numWrap: number = 0,\n ): ExportGraphicsMeshSubsetVisitor {\n return new ExportGraphicsMeshSubsetVisitor(polyface, facetIndices, numWrap);\n }\n /**\n * Advance the iterator to a particular facet in the subset of client polyface facets.\n * @param subsetIndex index into the subset array, not to be confused with the client facet index.\n * @return whether the iterator was successfully moved.\n */\n public override moveToReadIndex(subsetIndex: number): boolean {\n if (this.isValidSubsetIndex(subsetIndex)) {\n this._currentSubsetIndex = subsetIndex;\n this._nextSubsetIndex = subsetIndex + 1;\n return super.moveToReadIndex(this._facetIndices[subsetIndex]);\n }\n return false;\n }\n /**\n * Advance the iterator to the next facet in the subset of client polyface facets.\n * @return whether the iterator was successfully moved.\n */\n public override moveToNextFacet(): boolean {\n if (this._nextSubsetIndex !== this._currentSubsetIndex)\n return this.moveToReadIndex(this._nextSubsetIndex);\n this._nextSubsetIndex++;\n return true;\n }\n /** Restart the visitor at the first facet. */\n public override reset(): void {\n if (this._facetIndices) { // avoid crash during super ctor when we aren't yet initialized\n this.moveToReadIndex(0);\n this._nextSubsetIndex = 0; // so immediate moveToNextFacet stays here\n }\n }\n /**\n * Return the client polyface facet index (aka \"readIndex\") for the given subset index.\n * @param subsetIndex index into the subset array. Default is the subset index of the currently visited facet.\n * @return valid client polyface facet index, or `undefined` if invalid subset index.\n */\n public parentFacetIndex(subsetIndex?: number): number | undefined {\n if (undefined === subsetIndex)\n subsetIndex = this._currentSubsetIndex;\n return this.isValidSubsetIndex(subsetIndex) ? this._facetIndices[subsetIndex] : undefined;\n }\n /** Return the number of facets this visitor is able to visit. */\n public override getVisitableFacetCount(): number {\n return this._facetIndices.length;\n }\n}\n"]}
@@ -6,7 +6,7 @@ import { assert } from "chai";
6
6
  import * as fs from "fs";
7
7
  import { DbResult, Id64 } from "@itwin/core-bentley";
8
8
  import { Code, ColorDef, FillDisplay, GeometryClass, GeometryParams, GeometryStreamBuilder, ImageSourceFormat, IModel, LineStyle, TextureMapUnits, } from "@itwin/core-common";
9
- import { Angle, Box, GrowableXYArray, GrowableXYZArray, LineSegment3d, LineString3d, Loop, Point3d, PolyfaceBuilder, Range3d, Sphere, StrokeOptions, Vector3d, } from "@itwin/core-geometry";
9
+ import { Angle, Box, Geometry, GrowableXYArray, GrowableXYZArray, LineSegment3d, LineString3d, Loop, NumberArray, Point2dArray, Point3d, Point3dArray, PolyfaceBuilder, Range3d, Sphere, StrokeOptions, Vector3d, Vector3dArray, } from "@itwin/core-geometry";
10
10
  import { ExportGraphics, ExportGraphicsMeshVisitor, LineStyleDefinition, PhysicalObject, RenderMaterialElement, SnapshotDb, Texture, } from "../../core-backend";
11
11
  import { GeometryPart } from "../../Element";
12
12
  import { IModelTestUtils } from "../IModelTestUtils";
@@ -1001,5 +1001,57 @@ describe("exportGraphics", () => {
1001
1001
  assert.strictEqual(infos[0].elementId, newId);
1002
1002
  assert.strictEqual(infos[0].mesh.indices.length, 6);
1003
1003
  });
1004
+ it("verifies subset visitor", () => {
1005
+ const options = StrokeOptions.createForFacets();
1006
+ options.needNormals = options.needParams = options.shouldTriangulate = true;
1007
+ const builder = PolyfaceBuilder.create(options);
1008
+ builder.addSphere(Sphere.createCenterRadius(Point3d.createZero(), 1), 5);
1009
+ const polyface = builder.claimPolyface();
1010
+ assert.isDefined(polyface.data.param);
1011
+ assert.isDefined(polyface.data.paramIndex);
1012
+ assert.strictEqual(polyface.data.paramIndex.length, polyface.data.pointIndex.length);
1013
+ assert.isDefined(polyface.data.normal);
1014
+ assert.isDefined(polyface.data.normalIndex);
1015
+ assert.strictEqual(polyface.data.normalIndex.length, polyface.data.pointIndex.length);
1016
+ // compress by-sector uv/normals to by-vertex; last datum wins
1017
+ const paramData = Array(2 * polyface.data.point.length);
1018
+ const normalData = Array(3 * polyface.data.point.length);
1019
+ for (let i = 0; i < polyface.data.pointIndex.length; i++) {
1020
+ const pointIndex = polyface.data.pointIndex[i];
1021
+ const param = polyface.data.getParam(polyface.data.paramIndex[i]);
1022
+ if (param) {
1023
+ paramData[2 * pointIndex] = param.x;
1024
+ paramData[2 * pointIndex + 1] = param.y;
1025
+ }
1026
+ const normal = polyface.data.getNormal(polyface.data.normalIndex[i]);
1027
+ if (normal) {
1028
+ normalData[3 * pointIndex] = normal.x;
1029
+ normalData[3 * pointIndex + 1] = normal.y;
1030
+ normalData[3 * pointIndex + 2] = normal.z;
1031
+ }
1032
+ }
1033
+ const mesh = {
1034
+ points: polyface.data.point.float64Data(),
1035
+ params: new Float32Array(paramData),
1036
+ normals: new Float32Array(normalData),
1037
+ indices: new Int32Array(polyface.data.pointIndex),
1038
+ isTwoSided: false,
1039
+ };
1040
+ const visitor = ExportGraphicsMeshVisitor.create(mesh);
1041
+ const numFacets = polyface.facetCount;
1042
+ const numSubset = Math.floor(numFacets / 2);
1043
+ const subset = Array(numSubset).fill(0).map((_v, i) => Math.floor(numFacets * Math.log2(1 + i / numSubset)));
1044
+ const subVisitor = visitor.createSubsetVisitor(subset);
1045
+ while (subVisitor.moveToNextFacet()) {
1046
+ const facetIndex = subVisitor.parentFacetIndex();
1047
+ assert.isDefined(facetIndex);
1048
+ const result = visitor.moveToReadIndex(facetIndex);
1049
+ assert.isTrue(result);
1050
+ assert.isTrue(NumberArray.isAlmostEqual(subVisitor.pointIndex, visitor.pointIndex, Geometry.smallFloatingPoint));
1051
+ assert.isTrue(Point3dArray.isAlmostEqual(subVisitor.point.float64Data(), visitor.point.float64Data(), Geometry.smallFloatingPoint));
1052
+ assert.isTrue(Point2dArray.isAlmostEqual(subVisitor.param?.getPoint2dArray(), visitor.param?.getPoint2dArray(), Geometry.smallFloatingPoint));
1053
+ assert.isTrue(Vector3dArray.isAlmostEqual(subVisitor.normal?.float64Data(), visitor.normal?.float64Data(), Geometry.smallFloatingPoint));
1054
+ }
1055
+ });
1004
1056
  });
1005
1057
  //# sourceMappingURL=ExportGraphics.test.js.map