@itwin/core-common 3.7.0-dev.5 → 3.7.0-dev.6

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.
@@ -13,8 +13,8 @@ import { GeometryClass } from "./GeometryParams";
13
13
  * @public
14
14
  */
15
15
  export declare class Feature {
16
- readonly elementId: string;
17
- readonly subCategoryId: string;
16
+ readonly elementId: Id64String;
17
+ readonly subCategoryId: Id64String;
18
18
  readonly geometryClass: GeometryClass;
19
19
  constructor(elementId?: Id64String, subCategoryId?: Id64String, geometryClass?: GeometryClass);
20
20
  get isDefined(): boolean;
@@ -27,13 +27,41 @@ export declare class Feature {
27
27
  */
28
28
  compare(rhs: Feature): number;
29
29
  }
30
+ /** A [[Feature]] with a modelId identifying the model containing the feature.
31
+ * Typically produced from a PackedFeature.
32
+ * Prior to the introduction of MultiModelPackedFeatureTable, every (Packed)FeatureTable was associated with exactly one model.
33
+ * Now, each feature in a table may be associated with a different model.
34
+ * @internal
35
+ */
36
+ export interface ModelFeature {
37
+ modelId: Id64String;
38
+ elementId: Id64String;
39
+ subCategoryId: Id64String;
40
+ geometryClass: GeometryClass;
41
+ }
42
+ /** @internal */
43
+ export declare namespace ModelFeature {
44
+ function create(): ModelFeature;
45
+ function isDefined(feature: ModelFeature): boolean;
46
+ function unpack(packed: PackedFeature, result: ModelFeature, unpackedModelId?: Id64String): ModelFeature;
47
+ }
30
48
  /** @internal */
31
49
  export interface PackedFeature {
50
+ modelId: Id64.Uint32Pair;
32
51
  elementId: Id64.Uint32Pair;
33
52
  subCategoryId: Id64.Uint32Pair;
34
53
  geometryClass: GeometryClass;
35
54
  animationNodeId: number;
36
55
  }
56
+ /** @internal */
57
+ export interface PackedFeatureWithIndex extends PackedFeature {
58
+ index: number;
59
+ }
60
+ /** @internal */
61
+ export declare namespace PackedFeature {
62
+ function create(): PackedFeature;
63
+ function createWithIndex(): PackedFeatureWithIndex;
64
+ }
37
65
  /** Describes the type of a 'batch' of graphics representing multiple [[Feature]]s.
38
66
  * The most commonly-encountered batches are Tiles, which can be of either Primary or
39
67
  * Classifier type.
@@ -90,15 +118,44 @@ export declare class FeatureTable extends IndexMap<Feature> {
90
118
  }
91
119
  /** @alpha */
92
120
  export declare type ComputeNodeId = (elementId: Id64.Uint32Pair, featureIndex: number) => number;
121
+ /** Interface common to PackedFeatureTable and MultiModelPackedFeatureTable.
122
+ * @internal
123
+ */
124
+ export interface RenderFeatureTable {
125
+ /** The "model Id" of the tile tree containing the tile from which this feature table originated.
126
+ * It may be a transient Id if, for example, the tile tree represents a reality model or represents the geometry of multiple
127
+ * persistent models batched together.
128
+ */
129
+ readonly batchModelId: Id64String;
130
+ /** Split representation of batchModelId, so we're not constantly having to parse the string. */
131
+ readonly batchModelIdPair: Id64.Uint32Pair;
132
+ /** The number of features in the table; equivalently, one more than the largest feature index. */
133
+ readonly numFeatures: number;
134
+ /** Strictly for reporting memory usage. */
135
+ readonly byteLength: number;
136
+ readonly type: BatchType;
137
+ /** Get the feature at the specified index. Caller is responsible for validating featureIndex less than numFeatures. */
138
+ getFeature(featureIndex: number, result: ModelFeature): ModelFeature;
139
+ /** Find the specified feature. Returns undefined if featureIndex >= numFeatures. */
140
+ findFeature(featureIndex: number, result: ModelFeature): ModelFeature | undefined;
141
+ /** Find the Id of the element of the specified feature. */
142
+ findElementId(featureIndex: number): Id64String | undefined;
143
+ /** Get the Id of the element of the specified feature as a pair of 32-bit integers, asserting that feature index < numFeatures. */
144
+ getElementIdPair(featureIndex: number, out: Id64.Uint32Pair): Id64.Uint32Pair;
145
+ /** Get the feature at the specified index. Caller is responsible for validating featureIndex less than numFeatures. */
146
+ getPackedFeature(featureIndex: number, result: PackedFeature): PackedFeature;
147
+ /** Get an object that provides iteration over all features, in order. `output` is reused as the current value on each iteration. */
148
+ iterable(output: PackedFeatureWithIndex): Iterable<PackedFeatureWithIndex>;
149
+ }
93
150
  /**
94
151
  * An immutable, packed representation of a [[FeatureTable]]. The features are packed into a single array of 32-bit integer values,
95
152
  * wherein each feature occupies 3 32-bit integers.
96
153
  * @internal
97
154
  */
98
- export declare class PackedFeatureTable {
155
+ export declare class PackedFeatureTable implements RenderFeatureTable {
99
156
  private readonly _data;
100
- readonly modelId: Id64String;
101
- readonly maxFeatures: number;
157
+ readonly batchModelId: Id64String;
158
+ readonly batchModelIdPair: Id64.Uint32Pair;
102
159
  readonly numFeatures: number;
103
160
  readonly anyDefined: boolean;
104
161
  readonly type: BatchType;
@@ -109,13 +166,13 @@ export declare class PackedFeatureTable {
109
166
  * This is used internally when deserializing Tiles in iMdl format.
110
167
  * @internal
111
168
  */
112
- constructor(data: Uint32Array, modelId: Id64String, numFeatures: number, maxFeatures: number, type: BatchType, animationNodeIds?: Uint8Array | Uint16Array | Uint32Array);
169
+ constructor(data: Uint32Array, modelId: Id64String, numFeatures: number, type: BatchType, animationNodeIds?: Uint8Array | Uint16Array | Uint32Array);
113
170
  /** Create a packed feature table from a [[FeatureTable]]. */
114
171
  static pack(featureTable: FeatureTable): PackedFeatureTable;
115
172
  /** Retrieve the Feature associated with the specified index. */
116
- getFeature(featureIndex: number): Feature;
173
+ getFeature(featureIndex: number, result: ModelFeature): ModelFeature;
117
174
  /** Returns the Feature associated with the specified index, or undefined if the index is out of range. */
118
- findFeature(featureIndex: number): Feature | undefined;
175
+ findFeature(featureIndex: number, result: ModelFeature): ModelFeature | undefined;
119
176
  /** @internal */
120
177
  getElementIdPair(featureIndex: number, out?: Id64.Uint32Pair): Id64.Uint32Pair;
121
178
  /** @internal */
@@ -123,20 +180,70 @@ export declare class PackedFeatureTable {
123
180
  /** @internal */
124
181
  getAnimationNodeId(featureIndex: number): number;
125
182
  /** @internal */
126
- getPackedFeature(featureIndex: number): PackedFeature;
183
+ getPackedFeature(featureIndex: number, result: PackedFeature): PackedFeature;
127
184
  /** Returns the element ID of the Feature associated with the specified index, or undefined if the index is out of range. */
128
185
  findElementId(featureIndex: number): Id64String | undefined;
129
186
  /** Return true if this table contains exactly 1 feature. */
130
187
  get isUniform(): boolean;
131
188
  /** If this table contains exactly 1 feature, return it. */
132
- get uniform(): Feature | undefined;
189
+ getUniform(result: ModelFeature): ModelFeature | undefined;
133
190
  get isVolumeClassifier(): boolean;
134
191
  get isPlanarClassifier(): boolean;
135
192
  get isClassifier(): boolean;
136
193
  /** Unpack the features into a [[FeatureTable]]. */
137
194
  unpack(): FeatureTable;
138
195
  populateAnimationNodeIds(computeNodeId: ComputeNodeId, maxNodeId: number): void;
196
+ iterator(output: PackedFeatureWithIndex): Iterator<PackedFeatureWithIndex>;
197
+ iterable(output: PackedFeatureWithIndex): Iterable<PackedFeatureWithIndex>;
139
198
  private get _subCategoriesOffset();
140
199
  private readId;
141
200
  }
201
+ interface PackedFeatureModelEntry {
202
+ lastFeatureIndex: number;
203
+ idLower: number;
204
+ idUpper: number;
205
+ }
206
+ /** A table of model Ids associated with a [[MultiModelPackedFeatureTable]].
207
+ * The feature indices in the packed feature table are grouped together by model, such that the first N features belong to model 1, the next M features to model 2, and so on.
208
+ * The model table itself consists of one entry per model, where each entry looks like:
209
+ * indexOfLastFeatureInModel: u32
210
+ * modelId: u64
211
+ * The modelId associated with a feature can therefore be derived by finding the entry in the model table with the highest indexOfLastFeatureInModel no greater than the feature index.
212
+ * This lookup can be optimized using binary search.
213
+ * Moreover, while iterating the feature table in sequence, the model table can be iterated in parallel so that no per-feature lookup of model Id is required.
214
+ * @internal
215
+ */
216
+ export declare class PackedFeatureModelTable {
217
+ private readonly _data;
218
+ constructor(data: Uint32Array);
219
+ /** The number of models in the table. */
220
+ get length(): number;
221
+ get byteLength(): number;
222
+ private getLastFeatureIndex;
223
+ getEntry(modelIndex: number, result: PackedFeatureModelEntry): PackedFeatureModelEntry;
224
+ /** Get the Id of the model associated with the specified feature, or an invalid Id if the feature is not associated with any model. */
225
+ getModelIdPair(featureIndex: number, result?: Id64.Uint32Pair): Id64.Uint32Pair;
226
+ }
227
+ /** A PackedFeatureTable with a PackedFeatureModelTable appended to it, capable of storing features belonging to more than one model.
228
+ * @internal
229
+ */
230
+ export declare class MultiModelPackedFeatureTable implements RenderFeatureTable {
231
+ private readonly _features;
232
+ private readonly _models;
233
+ constructor(features: PackedFeatureTable, models: PackedFeatureModelTable);
234
+ static create(data: Uint32Array, batchModelId: Id64String, numFeatures: number, type: BatchType, numSubCategories: number): MultiModelPackedFeatureTable;
235
+ get batchModelId(): string;
236
+ get batchModelIdPair(): Id64.Uint32Pair;
237
+ get numFeatures(): number;
238
+ get type(): BatchType;
239
+ get byteLength(): number;
240
+ getPackedFeature(featureIndex: number, result: PackedFeature): PackedFeature;
241
+ getFeature(featureIndex: number, result: ModelFeature): ModelFeature;
242
+ findFeature(featureIndex: number, result: ModelFeature): ModelFeature | undefined;
243
+ getElementIdPair(featureIndex: number, out: Id64.Uint32Pair): Id64.Uint32Pair;
244
+ findElementId(featureIndex: number): Id64String | undefined;
245
+ iterator(output: PackedFeatureWithIndex): Iterator<PackedFeatureWithIndex>;
246
+ iterable(output: PackedFeatureWithIndex): Iterable<PackedFeatureWithIndex>;
247
+ }
248
+ export {};
142
249
  //# sourceMappingURL=FeatureTable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FeatureTable.d.ts","sourceRoot":"","sources":["../../src/FeatureTable.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAA0C,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACvH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;;;;;;;GAQG;AACH,qBAAa,OAAO;IAClB,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,aAAa,EAAE,MAAM,CAAC;IACtC,SAAgB,aAAa,EAAE,aAAa,CAAC;gBAE1B,SAAS,GAAE,UAAyB,EAAE,aAAa,GAAE,UAAyB,EAAE,aAAa,GAAE,aAAqC;IAMvJ,IAAW,SAAS,IAAI,OAAO,CAAmI;IAClK,IAAW,WA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,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU;IAI7E,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAIzD,QAAQ,CAAC,MAAM,EAAE,sBAAsB,GAAG,QAAQ,CAAC,sBAAsB,CAAC;IAiB5E,QAAQ,CAAC,MAAM,EAAE,sBAAsB,GAAG,QAAQ,CAAC,sBAAsB,CAAC;CAKlF"}
@@ -43,6 +43,52 @@ export class Feature {
43
43
  return cmp;
44
44
  }
45
45
  }
46
+ /** @internal */
47
+ export var ModelFeature;
48
+ (function (ModelFeature) {
49
+ function create() {
50
+ return {
51
+ modelId: Id64.invalid,
52
+ elementId: Id64.invalid,
53
+ subCategoryId: Id64.invalid,
54
+ geometryClass: GeometryClass.Primary,
55
+ };
56
+ }
57
+ ModelFeature.create = create;
58
+ function isDefined(feature) {
59
+ return !Id64.isInvalid(feature.modelId) || !Id64.isInvalid(feature.elementId) || !Id64.isInvalid(feature.subCategoryId) || feature.geometryClass !== GeometryClass.Primary;
60
+ }
61
+ ModelFeature.isDefined = isDefined;
62
+ function unpack(packed, result, unpackedModelId) {
63
+ result.modelId = unpackedModelId !== null && unpackedModelId !== void 0 ? unpackedModelId : Id64.fromUint32PairObject(packed.modelId);
64
+ result.elementId = Id64.fromUint32PairObject(packed.elementId);
65
+ result.subCategoryId = Id64.fromUint32PairObject(packed.subCategoryId);
66
+ result.geometryClass = packed.geometryClass;
67
+ return result;
68
+ }
69
+ ModelFeature.unpack = unpack;
70
+ })(ModelFeature || (ModelFeature = {}));
71
+ /** @internal */
72
+ export var PackedFeature;
73
+ (function (PackedFeature) {
74
+ function create() {
75
+ const pair = { upper: 0, lower: 0 };
76
+ return {
77
+ modelId: { ...pair },
78
+ elementId: { ...pair },
79
+ subCategoryId: { ...pair },
80
+ geometryClass: GeometryClass.Primary,
81
+ animationNodeId: 0,
82
+ };
83
+ }
84
+ PackedFeature.create = create;
85
+ function createWithIndex() {
86
+ const result = create();
87
+ result.index = 0;
88
+ return result;
89
+ }
90
+ PackedFeature.createWithIndex = createWithIndex;
91
+ })(PackedFeature || (PackedFeature = {}));
46
92
  /** Describes the type of a 'batch' of graphics representing multiple [[Feature]]s.
47
93
  * The most commonly-encountered batches are Tiles, which can be of either Primary or
48
94
  * Classifier type.
@@ -111,6 +157,7 @@ export class FeatureTable extends IndexMap {
111
157
  /** @internal */
112
158
  getArray() { return this._array; }
113
159
  }
160
+ const scratchPackedFeature = PackedFeature.create();
114
161
  /**
115
162
  * An immutable, packed representation of a [[FeatureTable]]. The features are packed into a single array of 32-bit integer values,
116
163
  * wherein each feature occupies 3 32-bit integers.
@@ -121,10 +168,10 @@ export class PackedFeatureTable {
121
168
  * This is used internally when deserializing Tiles in iMdl format.
122
169
  * @internal
123
170
  */
124
- constructor(data, modelId, numFeatures, maxFeatures, type, animationNodeIds) {
171
+ constructor(data, modelId, numFeatures, type, animationNodeIds) {
125
172
  this._data = data;
126
- this.modelId = modelId;
127
- this.maxFeatures = maxFeatures;
173
+ this.batchModelId = modelId;
174
+ this.batchModelIdPair = Id64.getUint32Pair(modelId);
128
175
  this.numFeatures = numFeatures;
129
176
  this.type = type;
130
177
  this._animationNodeIds = animationNodeIds;
@@ -133,14 +180,13 @@ export class PackedFeatureTable {
133
180
  this.anyDefined = false;
134
181
  break;
135
182
  case 1:
136
- this.anyDefined = this.getFeature(0).isDefined;
183
+ this.anyDefined = ModelFeature.isDefined(this.getFeature(0, ModelFeature.create()));
137
184
  break;
138
185
  default:
139
186
  this.anyDefined = true;
140
187
  break;
141
188
  }
142
189
  assert(this._data.length >= this._subCategoriesOffset);
143
- assert(this.maxFeatures >= this.numFeatures);
144
190
  assert(undefined === this._animationNodeIds || this._animationNodeIds.length === this.numFeatures);
145
191
  }
146
192
  get byteLength() { return this._data.byteLength; }
@@ -176,18 +222,16 @@ export class PackedFeatureTable {
176
222
  uint32s[index32 + 0] = Id64.getLowerUint32(id);
177
223
  uint32s[index32 + 1] = Id64.getUpperUint32(id);
178
224
  });
179
- return new PackedFeatureTable(uint32s, featureTable.modelId, featureTable.length, featureTable.maxFeatures, featureTable.type);
225
+ return new PackedFeatureTable(uint32s, featureTable.modelId, featureTable.length, featureTable.type);
180
226
  }
181
227
  /** Retrieve the Feature associated with the specified index. */
182
- getFeature(featureIndex) {
183
- const packed = this.getPackedFeature(featureIndex);
184
- const elemId = Id64.fromUint32Pair(packed.elementId.lower, packed.elementId.upper);
185
- const subcatId = Id64.fromUint32Pair(packed.subCategoryId.lower, packed.subCategoryId.upper);
186
- return new Feature(elemId, subcatId, packed.geometryClass);
228
+ getFeature(featureIndex, result) {
229
+ const packed = this.getPackedFeature(featureIndex, scratchPackedFeature);
230
+ return ModelFeature.unpack(packed, result, this.batchModelId);
187
231
  }
188
232
  /** Returns the Feature associated with the specified index, or undefined if the index is out of range. */
189
- findFeature(featureIndex) {
190
- return featureIndex < this.numFeatures ? this.getFeature(featureIndex) : undefined;
233
+ findFeature(featureIndex, result) {
234
+ return featureIndex < this.numFeatures ? this.getFeature(featureIndex, result) : undefined;
191
235
  }
192
236
  /** @internal */
193
237
  getElementIdPair(featureIndex, out) {
@@ -211,17 +255,21 @@ export class PackedFeatureTable {
211
255
  return undefined !== this._animationNodeIds && featureIndex < this.numFeatures ? this._animationNodeIds[featureIndex] : 0;
212
256
  }
213
257
  /** @internal */
214
- getPackedFeature(featureIndex) {
258
+ getPackedFeature(featureIndex, result) {
215
259
  assert(featureIndex < this.numFeatures);
216
260
  const index32 = 3 * featureIndex;
217
- const elementId = { lower: this._data[index32], upper: this._data[index32 + 1] };
261
+ result.elementId.lower = this._data[index32];
262
+ result.elementId.upper = this._data[index32 + 1];
218
263
  const subCatIndexAndClass = this._data[index32 + 2];
219
- const geometryClass = (subCatIndexAndClass >>> 24) & 0xff;
264
+ result.geometryClass = (subCatIndexAndClass >>> 24) & 0xff;
220
265
  let subCatIndex = (subCatIndexAndClass & 0x00ffffff) >>> 0;
221
266
  subCatIndex = subCatIndex * 2 + this._subCategoriesOffset;
222
- const subCategoryId = { lower: this._data[subCatIndex], upper: this._data[subCatIndex + 1] };
223
- const animationNodeId = this.getAnimationNodeId(featureIndex);
224
- return { elementId, subCategoryId, geometryClass, animationNodeId };
267
+ result.subCategoryId.lower = this._data[subCatIndex];
268
+ result.subCategoryId.upper = this._data[subCatIndex + 1];
269
+ result.animationNodeId = this.getAnimationNodeId(featureIndex);
270
+ result.modelId.lower = this.batchModelIdPair.lower;
271
+ result.modelId.upper = this.batchModelIdPair.upper;
272
+ return result;
225
273
  }
226
274
  /** Returns the element ID of the Feature associated with the specified index, or undefined if the index is out of range. */
227
275
  findElementId(featureIndex) {
@@ -233,16 +281,19 @@ export class PackedFeatureTable {
233
281
  /** Return true if this table contains exactly 1 feature. */
234
282
  get isUniform() { return 1 === this.numFeatures; }
235
283
  /** If this table contains exactly 1 feature, return it. */
236
- get uniform() { return this.isUniform ? this.getFeature(0) : undefined; }
284
+ getUniform(result) {
285
+ return this.isUniform ? this.getFeature(0, result) : undefined;
286
+ }
237
287
  get isVolumeClassifier() { return BatchType.VolumeClassifier === this.type; }
238
288
  get isPlanarClassifier() { return BatchType.VolumeClassifier === this.type; }
239
289
  get isClassifier() { return this.isVolumeClassifier || this.isPlanarClassifier; }
240
290
  /** Unpack the features into a [[FeatureTable]]. */
241
291
  unpack() {
242
- const table = new FeatureTable(this.maxFeatures, this.modelId);
292
+ const table = new FeatureTable(this.numFeatures, this.batchModelId);
293
+ const feature = ModelFeature.create();
243
294
  for (let i = 0; i < this.numFeatures; i++) {
244
- const feature = this.getFeature(i);
245
- table.insertWithIndex(feature, i);
295
+ this.getFeature(i, feature);
296
+ table.insertWithIndex(new Feature(feature.elementId, feature.subCategoryId, feature.geometryClass), i);
246
297
  }
247
298
  return table;
248
299
  }
@@ -265,9 +316,148 @@ export class PackedFeatureTable {
265
316
  if (haveNodes)
266
317
  this._animationNodeIds = nodeIds;
267
318
  }
319
+ *iterator(output) {
320
+ for (let i = 0; i < this.numFeatures; i++) {
321
+ this.getPackedFeature(i, output);
322
+ output.index = i;
323
+ yield output;
324
+ }
325
+ }
326
+ iterable(output) {
327
+ return {
328
+ [Symbol.iterator]: () => this.iterator(output),
329
+ };
330
+ }
268
331
  get _subCategoriesOffset() { return this.numFeatures * 3; }
269
332
  readId(offset32) {
270
333
  return Id64.fromUint32Pair(this._data[offset32], this._data[offset32 + 1]);
271
334
  }
272
335
  }
336
+ const scratchPackedFeatureModelEntry = { lastFeatureIndex: -1, idLower: -1, idUpper: -1 };
337
+ /** A table of model Ids associated with a [[MultiModelPackedFeatureTable]].
338
+ * The feature indices in the packed feature table are grouped together by model, such that the first N features belong to model 1, the next M features to model 2, and so on.
339
+ * The model table itself consists of one entry per model, where each entry looks like:
340
+ * indexOfLastFeatureInModel: u32
341
+ * modelId: u64
342
+ * The modelId associated with a feature can therefore be derived by finding the entry in the model table with the highest indexOfLastFeatureInModel no greater than the feature index.
343
+ * This lookup can be optimized using binary search.
344
+ * Moreover, while iterating the feature table in sequence, the model table can be iterated in parallel so that no per-feature lookup of model Id is required.
345
+ * @internal
346
+ */
347
+ export class PackedFeatureModelTable {
348
+ constructor(data) {
349
+ this._data = data;
350
+ assert(this._data.length % 3 === 0);
351
+ }
352
+ /** The number of models in the table. */
353
+ get length() {
354
+ return this._data.length / 3;
355
+ }
356
+ get byteLength() {
357
+ return this._data.byteLength;
358
+ }
359
+ getLastFeatureIndex(modelIndex) {
360
+ return this._data[modelIndex * 3];
361
+ }
362
+ getEntry(modelIndex, result) {
363
+ if (modelIndex >= this.length) {
364
+ result.idLower = result.idUpper = 0;
365
+ result.lastFeatureIndex = Number.MAX_SAFE_INTEGER;
366
+ return result;
367
+ }
368
+ const index = modelIndex * 3;
369
+ result.lastFeatureIndex = this._data[index + 0];
370
+ result.idLower = this._data[index + 1];
371
+ result.idUpper = this._data[index + 2];
372
+ return result;
373
+ }
374
+ /** Get the Id of the model associated with the specified feature, or an invalid Id if the feature is not associated with any model. */
375
+ getModelIdPair(featureIndex, result) {
376
+ if (!result)
377
+ result = { lower: 0, upper: 0 };
378
+ else
379
+ result.lower = result.upper = 0;
380
+ let first = 0;
381
+ const last = this.length;
382
+ let count = last;
383
+ while (count > 0) {
384
+ const step = Math.floor(count / 2);
385
+ const mid = first + step;
386
+ const lastFeatureIndex = this.getLastFeatureIndex(mid);
387
+ if (featureIndex > lastFeatureIndex) {
388
+ first = mid + 1;
389
+ count -= step + 1;
390
+ }
391
+ else {
392
+ count = step;
393
+ }
394
+ }
395
+ if (first < last) {
396
+ result.lower = this._data[first * 3 + 1];
397
+ result.upper = this._data[first * 3 + 2];
398
+ }
399
+ return result;
400
+ }
401
+ }
402
+ /** A PackedFeatureTable with a PackedFeatureModelTable appended to it, capable of storing features belonging to more than one model.
403
+ * @internal
404
+ */
405
+ export class MultiModelPackedFeatureTable {
406
+ constructor(features, models) {
407
+ this._features = features;
408
+ this._models = models;
409
+ }
410
+ static create(data, batchModelId, numFeatures, type, numSubCategories) {
411
+ const modelTableOffset = 3 * numFeatures + 2 * numSubCategories;
412
+ const featureData = data.subarray(0, modelTableOffset);
413
+ const features = new PackedFeatureTable(featureData, batchModelId, numFeatures, type);
414
+ const modelData = data.subarray(modelTableOffset);
415
+ const models = new PackedFeatureModelTable(modelData);
416
+ return new MultiModelPackedFeatureTable(features, models);
417
+ }
418
+ get batchModelId() { return this._features.batchModelId; }
419
+ get batchModelIdPair() { return this._features.batchModelIdPair; }
420
+ get numFeatures() { return this._features.numFeatures; }
421
+ get type() { return this._features.type; }
422
+ get byteLength() {
423
+ return this._features.byteLength + this._models.byteLength;
424
+ }
425
+ getPackedFeature(featureIndex, result) {
426
+ this._features.getPackedFeature(featureIndex, result);
427
+ this._models.getModelIdPair(featureIndex, result.modelId);
428
+ return result;
429
+ }
430
+ getFeature(featureIndex, result) {
431
+ const packed = this.getPackedFeature(featureIndex, scratchPackedFeature);
432
+ return ModelFeature.unpack(packed, result);
433
+ }
434
+ findFeature(featureIndex, result) {
435
+ return featureIndex < this.numFeatures ? this.getFeature(featureIndex, result) : undefined;
436
+ }
437
+ getElementIdPair(featureIndex, out) {
438
+ return this._features.getElementIdPair(featureIndex, out);
439
+ }
440
+ findElementId(featureIndex) {
441
+ return this._features.findElementId(featureIndex);
442
+ }
443
+ *iterator(output) {
444
+ // Rather than perform a binary search on the model table to find each feature's model Id, traverse the model table in parallel with the feature table.
445
+ let modelIndex = 0;
446
+ const modelEntry = this._models.getEntry(modelIndex, scratchPackedFeatureModelEntry);
447
+ for (let featureIndex = 0; featureIndex < this.numFeatures; featureIndex++) {
448
+ if (featureIndex > modelEntry.lastFeatureIndex)
449
+ this._models.getEntry(++modelIndex, modelEntry);
450
+ this._features.getPackedFeature(featureIndex, output);
451
+ output.modelId.lower = modelEntry.idLower;
452
+ output.modelId.upper = modelEntry.idUpper;
453
+ output.index = featureIndex;
454
+ yield output;
455
+ }
456
+ }
457
+ iterable(output) {
458
+ return {
459
+ [Symbol.iterator]: () => this.iterator(output),
460
+ };
461
+ }
462
+ }
273
463
  //# sourceMappingURL=FeatureTable.js.map