@itwin/core-geometry 4.7.0-dev.6 → 4.7.0-dev.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +7 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +20 -4
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +3 -3
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +4 -3
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts +7 -0
- package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.js +19 -0
- package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
- package/lib/cjs/polyface/AuxData.d.ts +18 -10
- package/lib/cjs/polyface/AuxData.d.ts.map +1 -1
- package/lib/cjs/polyface/AuxData.js +24 -12
- package/lib/cjs/polyface/AuxData.js.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts +2 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js +2 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/cjs/polyface/Polyface.d.ts +10 -2
- package/lib/cjs/polyface/Polyface.d.ts.map +1 -1
- package/lib/cjs/polyface/Polyface.js +29 -17
- package/lib/cjs/polyface/Polyface.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceData.d.ts +10 -9
- package/lib/cjs/polyface/PolyfaceData.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceData.js +17 -2
- package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.d.ts +302 -251
- package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js +363 -309
- package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/cjs/serialization/BGFBReader.d.ts +18 -20
- package/lib/cjs/serialization/BGFBReader.d.ts.map +1 -1
- package/lib/cjs/serialization/BGFBReader.js +119 -84
- package/lib/cjs/serialization/BGFBReader.js.map +1 -1
- package/lib/cjs/serialization/BGFBWriter.d.ts +1 -1
- package/lib/cjs/serialization/BGFBWriter.d.ts.map +1 -1
- package/lib/cjs/serialization/BGFBWriter.js +10 -15
- package/lib/cjs/serialization/BGFBWriter.js.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.d.ts +52 -7
- package/lib/cjs/serialization/IModelJsonSchema.d.ts.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.js +26 -78
- package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/cjs/serialization/SerializationHelpers.d.ts +17 -0
- package/lib/cjs/serialization/SerializationHelpers.d.ts.map +1 -1
- package/lib/cjs/serialization/SerializationHelpers.js +85 -0
- package/lib/cjs/serialization/SerializationHelpers.js.map +1 -1
- package/lib/cjs/solid/Sphere.d.ts +1 -0
- package/lib/cjs/solid/Sphere.d.ts.map +1 -1
- package/lib/cjs/solid/Sphere.js +4 -2
- package/lib/cjs/solid/Sphere.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +7 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +20 -4
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +3 -3
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +4 -3
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts +7 -0
- package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.js +19 -0
- package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
- package/lib/esm/polyface/AuxData.d.ts +18 -10
- package/lib/esm/polyface/AuxData.d.ts.map +1 -1
- package/lib/esm/polyface/AuxData.js +24 -12
- package/lib/esm/polyface/AuxData.js.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts +2 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js +2 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/esm/polyface/Polyface.d.ts +10 -2
- package/lib/esm/polyface/Polyface.d.ts.map +1 -1
- package/lib/esm/polyface/Polyface.js +29 -17
- package/lib/esm/polyface/Polyface.js.map +1 -1
- package/lib/esm/polyface/PolyfaceData.d.ts +10 -9
- package/lib/esm/polyface/PolyfaceData.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceData.js +17 -2
- package/lib/esm/polyface/PolyfaceData.js.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.d.ts +302 -251
- package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js +363 -309
- package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/esm/serialization/BGFBReader.d.ts +18 -20
- package/lib/esm/serialization/BGFBReader.d.ts.map +1 -1
- package/lib/esm/serialization/BGFBReader.js +119 -84
- package/lib/esm/serialization/BGFBReader.js.map +1 -1
- package/lib/esm/serialization/BGFBWriter.d.ts +1 -1
- package/lib/esm/serialization/BGFBWriter.d.ts.map +1 -1
- package/lib/esm/serialization/BGFBWriter.js +10 -15
- package/lib/esm/serialization/BGFBWriter.js.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.d.ts +52 -7
- package/lib/esm/serialization/IModelJsonSchema.d.ts.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.js +26 -78
- package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/esm/serialization/SerializationHelpers.d.ts +17 -0
- package/lib/esm/serialization/SerializationHelpers.d.ts.map +1 -1
- package/lib/esm/serialization/SerializationHelpers.js +85 -0
- package/lib/esm/serialization/SerializationHelpers.js.map +1 -1
- package/lib/esm/solid/Sphere.d.ts +1 -0
- package/lib/esm/solid/Sphere.d.ts.map +1 -1
- package/lib/esm/solid/Sphere.js +4 -2
- package/lib/esm/solid/Sphere.js.map +1 -1
- package/package.json +4 -4
|
@@ -55,30 +55,28 @@ export declare class BGFBReader {
|
|
|
55
55
|
* @param variant read position in the flat buffer.
|
|
56
56
|
*/
|
|
57
57
|
readPointStringFromVariant(variant: BGFBAccessors.VariantGeometry): PointString3d | undefined;
|
|
58
|
-
/**
|
|
59
|
-
* Extract auxData for a mesh
|
|
60
|
-
* @param variant read position in the flat buffer.
|
|
61
|
-
*/
|
|
58
|
+
/** Extract auxData channel data for a mesh */
|
|
62
59
|
readPolyfaceAuxChannelData(channelDataHeader: BGFBAccessors.PolyfaceAuxChannelData | null): AuxChannelData | undefined;
|
|
63
|
-
/**
|
|
64
|
-
* Extract auxData for a mesh
|
|
65
|
-
* @param variant read position in the flat buffer.
|
|
66
|
-
*/
|
|
60
|
+
/** Extract auxData channel for a mesh */
|
|
67
61
|
readPolyfaceAuxChannel(channelHeader: BGFBAccessors.PolyfaceAuxChannel | null): AuxChannel | undefined;
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
62
|
+
/** Compute the number of logical entries in every flat data array in the AuxData */
|
|
63
|
+
private static channelDataLength;
|
|
64
|
+
/** Examine int array for range and zero count */
|
|
65
|
+
private countIntArray;
|
|
66
|
+
/**
|
|
67
|
+
* Extract auxData for a mesh.
|
|
68
|
+
* Typescript object format for Polyface/PolyfaceAuxData indices is 0-based, unterminated.
|
|
69
|
+
* FlatBuffer format for Polyface/PolyfaceAuxData indices is 1-based, 0-terminated/padded.
|
|
70
|
+
* Typescript API previously wrote FlatBuffer PolyfaceAuxData indices as 0-based, unterminated;
|
|
71
|
+
* heuristics are used herein to identify this legacy format so it can still be read.
|
|
72
|
+
*/
|
|
73
|
+
readPolyfaceAuxData(fbPolyface: BGFBAccessors.Polyface | null, fbAuxData: BGFBAccessors.PolyfaceAuxData | null): PolyfaceAuxData | undefined;
|
|
74
|
+
/** Extract tagged numeric data for a mesh */
|
|
77
75
|
readTaggedNumericData(accessor: BGFBAccessors.TaggedNumericData | undefined): TaggedNumericData | undefined;
|
|
78
76
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
* Extract a mesh
|
|
78
|
+
* @param variant read position in the flat buffer.
|
|
79
|
+
*/
|
|
82
80
|
readPolyfaceFromVariant(variant: BGFBAccessors.VariantGeometry): IndexedPolyface | undefined;
|
|
83
81
|
readCurveCollectionFromCurveVectorTable(cvTable: BGFBAccessors.CurveVector): CurveCollection;
|
|
84
82
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BGFBReader.d.ts","sourceRoot":"","sources":["../../../src/serialization/BGFBReader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BGFBReader.d.ts","sourceRoot":"","sources":["../../../src/serialization/BGFBReader.ts"],"names":[],"mappings":"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"}
|
|
@@ -6,6 +6,7 @@ exports.DgnSpiralTypeQueries = exports.BGFBReader = void 0;
|
|
|
6
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
7
|
*--------------------------------------------------------------------------------------------*/
|
|
8
8
|
const flatbuffers_1 = require("flatbuffers");
|
|
9
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
9
10
|
const AkimaCurve3d_1 = require("../bspline/AkimaCurve3d");
|
|
10
11
|
const BSplineCurve_1 = require("../bspline/BSplineCurve");
|
|
11
12
|
const BSplineCurve3dH_1 = require("../bspline/BSplineCurve3dH");
|
|
@@ -253,10 +254,7 @@ class BGFBReader {
|
|
|
253
254
|
}
|
|
254
255
|
return undefined;
|
|
255
256
|
}
|
|
256
|
-
/**
|
|
257
|
-
* Extract auxData for a mesh
|
|
258
|
-
* @param variant read position in the flat buffer.
|
|
259
|
-
*/
|
|
257
|
+
/** Extract auxData channel data for a mesh */
|
|
260
258
|
readPolyfaceAuxChannelData(channelDataHeader) {
|
|
261
259
|
if (channelDataHeader !== null) {
|
|
262
260
|
const input = channelDataHeader.input();
|
|
@@ -266,10 +264,7 @@ class BGFBReader {
|
|
|
266
264
|
}
|
|
267
265
|
return undefined;
|
|
268
266
|
}
|
|
269
|
-
/**
|
|
270
|
-
* Extract auxData for a mesh
|
|
271
|
-
* @param variant read position in the flat buffer.
|
|
272
|
-
*/
|
|
267
|
+
/** Extract auxData channel for a mesh */
|
|
273
268
|
readPolyfaceAuxChannel(channelHeader) {
|
|
274
269
|
if (channelHeader) {
|
|
275
270
|
const dataType = channelHeader.dataType();
|
|
@@ -286,36 +281,100 @@ class BGFBReader {
|
|
|
286
281
|
}
|
|
287
282
|
return undefined;
|
|
288
283
|
}
|
|
284
|
+
/** Compute the number of logical entries in every flat data array in the AuxData */
|
|
285
|
+
static channelDataLength(fbAuxData) {
|
|
286
|
+
if (fbAuxData.channelsLength() <= 0)
|
|
287
|
+
return 0;
|
|
288
|
+
const fbChannel0 = nullToUndefined(fbAuxData.channels(0));
|
|
289
|
+
if (!fbChannel0)
|
|
290
|
+
return 0;
|
|
291
|
+
const numChannel0Data = fbChannel0.dataLength();
|
|
292
|
+
if (numChannel0Data <= 0)
|
|
293
|
+
return 0;
|
|
294
|
+
const fbChannel0Data0 = nullToUndefined(fbChannel0.data(0));
|
|
295
|
+
if (!fbChannel0Data0)
|
|
296
|
+
return 0;
|
|
297
|
+
const numChannelDataValues = fbChannel0Data0.valuesLength();
|
|
298
|
+
if (numChannelDataValues <= 0)
|
|
299
|
+
return 0;
|
|
300
|
+
return numChannelDataValues / AuxData_1.AuxChannel.entriesPerValue(fbChannel0.dataType());
|
|
301
|
+
}
|
|
302
|
+
/** Examine int array for range and zero count */
|
|
303
|
+
countIntArray(ints) {
|
|
304
|
+
let min = Infinity;
|
|
305
|
+
let max = -Infinity;
|
|
306
|
+
let numZeroes = 0;
|
|
307
|
+
for (const i of ints) {
|
|
308
|
+
if (min > i)
|
|
309
|
+
min = i;
|
|
310
|
+
if (max < i)
|
|
311
|
+
max = i;
|
|
312
|
+
if (0 === i)
|
|
313
|
+
++numZeroes;
|
|
314
|
+
}
|
|
315
|
+
return { min, max, numZeroes };
|
|
316
|
+
}
|
|
289
317
|
/**
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
318
|
+
* Extract auxData for a mesh.
|
|
319
|
+
* Typescript object format for Polyface/PolyfaceAuxData indices is 0-based, unterminated.
|
|
320
|
+
* FlatBuffer format for Polyface/PolyfaceAuxData indices is 1-based, 0-terminated/padded.
|
|
321
|
+
* Typescript API previously wrote FlatBuffer PolyfaceAuxData indices as 0-based, unterminated;
|
|
322
|
+
* heuristics are used herein to identify this legacy format so it can still be read.
|
|
323
|
+
*/
|
|
324
|
+
readPolyfaceAuxData(fbPolyface, fbAuxData) {
|
|
325
|
+
if (!fbPolyface || !fbAuxData)
|
|
326
|
+
return undefined;
|
|
327
|
+
const fbPointIndices = nullToUndefined(fbPolyface.pointIndexArray());
|
|
328
|
+
const fbAuxIndices = nullToUndefined(fbAuxData.indicesArray());
|
|
329
|
+
const numChannels = fbAuxData.channelsLength();
|
|
330
|
+
const fbNumData = BGFBReader.channelDataLength(fbAuxData);
|
|
331
|
+
if (!fbPointIndices || !fbPointIndices.length || !fbAuxIndices || !fbAuxIndices.length || numChannels <= 0 || fbNumData <= 0)
|
|
332
|
+
return undefined;
|
|
333
|
+
const numPerFace = fbPolyface.numPerFace();
|
|
334
|
+
// HEURISTICS to detect legacy AuxData indices, previously mistakenly serialized by BGFBWriter.writePolyfaceAsFBVariantGeometry as 0-based unblocked indices
|
|
335
|
+
let isLegacy = false;
|
|
336
|
+
const pointIndicesPadCount = fbPointIndices.filter((index) => index === 0).length;
|
|
337
|
+
if (numPerFace > 1) {
|
|
338
|
+
const auxIndexCounts = this.countIntArray(fbAuxIndices);
|
|
339
|
+
if (auxIndexCounts.max > fbNumData) // auxIndices invalid
|
|
340
|
+
return undefined;
|
|
341
|
+
if (auxIndexCounts.max === fbNumData) // auxIndices 1-based
|
|
342
|
+
isLegacy = false;
|
|
343
|
+
else if (auxIndexCounts.max <= 0 || auxIndexCounts.min < 0) // auxIndices 1-based (signed)
|
|
344
|
+
isLegacy = false;
|
|
345
|
+
else if (auxIndexCounts.min === 0) // auxIndices likely legacy 0-based index, but could be modern with padding
|
|
346
|
+
isLegacy = pointIndicesPadCount !== auxIndexCounts.numZeroes;
|
|
347
|
+
else if (auxIndexCounts.min > 0) // auxIndices likely modern without padding, but could be legacy if first datum not indexed
|
|
348
|
+
isLegacy = pointIndicesPadCount > 0;
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
isLegacy = (fbAuxIndices.length < fbPointIndices.length) && (fbAuxIndices.length + pointIndicesPadCount === fbPointIndices.length);
|
|
352
|
+
}
|
|
353
|
+
if (!isLegacy && fbAuxIndices.length !== fbPointIndices.length)
|
|
354
|
+
return undefined; // auxIndices invalid
|
|
355
|
+
const indices = [];
|
|
356
|
+
if (isLegacy)
|
|
357
|
+
SerializationHelpers_1.SerializationHelpers.announceZeroBasedIndicesWithExternalBlocking(fbAuxIndices, fbPointIndices, numPerFace, (i0) => { indices.push(i0); });
|
|
358
|
+
else
|
|
359
|
+
SerializationHelpers_1.SerializationHelpers.announceZeroBasedIndicesFromSignedOneBasedIndices(fbAuxIndices, numPerFace, (i0) => { indices.push(i0); });
|
|
360
|
+
if (indices.length + pointIndicesPadCount !== fbPointIndices.length)
|
|
361
|
+
return undefined;
|
|
362
|
+
const maxIndex = Math.max(...indices);
|
|
363
|
+
const channels = [];
|
|
364
|
+
for (let i = 0; i < numChannels; i++) {
|
|
365
|
+
const channelHeader = fbAuxData.channels(i);
|
|
366
|
+
const channelContent = this.readPolyfaceAuxChannel(channelHeader);
|
|
367
|
+
if (channelContent) {
|
|
368
|
+
if (maxIndex >= channelContent.valueCount)
|
|
369
|
+
return undefined; // invalid index
|
|
370
|
+
channels.push(channelContent);
|
|
310
371
|
}
|
|
311
|
-
return new AuxData_1.PolyfaceAuxData(channels, indices);
|
|
312
372
|
}
|
|
313
|
-
|
|
373
|
+
if (!channels.length)
|
|
374
|
+
return undefined;
|
|
375
|
+
return new AuxData_1.PolyfaceAuxData(channels, indices);
|
|
314
376
|
}
|
|
315
|
-
/**
|
|
316
|
-
* Extract auxData for a mesh
|
|
317
|
-
* @param variant read position in the flat buffer.
|
|
318
|
-
*/
|
|
377
|
+
/** Extract tagged numeric data for a mesh */
|
|
319
378
|
readTaggedNumericData(accessor) {
|
|
320
379
|
if (accessor) {
|
|
321
380
|
const taggedNumericData = new TaggedNumericData_1.TaggedNumericData(accessor.tagA(), accessor.tagB());
|
|
@@ -336,9 +395,9 @@ class BGFBReader {
|
|
|
336
395
|
return undefined;
|
|
337
396
|
}
|
|
338
397
|
/**
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
398
|
+
* Extract a mesh
|
|
399
|
+
* @param variant read position in the flat buffer.
|
|
400
|
+
*/
|
|
342
401
|
readPolyfaceFromVariant(variant) {
|
|
343
402
|
const geometryType = variant.geometryType();
|
|
344
403
|
if (geometryType === BGFBAccessors_1.BGFBAccessors.VariantGeometryUnion.tagPolyface) {
|
|
@@ -357,59 +416,35 @@ class BGFBReader {
|
|
|
357
416
|
const normalIndexI32 = nullToUndefined(polyfaceHeader.normalIndexArray());
|
|
358
417
|
const colorIndexI32 = nullToUndefined(polyfaceHeader.colorIndexArray());
|
|
359
418
|
const taggedNumericDataOffset = polyfaceHeader.taggedNumericData();
|
|
419
|
+
(0, core_bentley_1.assert)(meshStyle === 1, "Unrecognized flatbuffer mesh style");
|
|
420
|
+
// The flatbuffer data is one based.
|
|
421
|
+
// If numPerFace is less than 2, facets are variable size and zero terminated
|
|
422
|
+
// If numPerFace is 2 or more, indices are blocked
|
|
360
423
|
if (meshStyle === 1 && pointF64 && pointIndexI32) {
|
|
361
|
-
const polyface = Polyface_1.IndexedPolyface.create(
|
|
424
|
+
const polyface = Polyface_1.IndexedPolyface.create();
|
|
425
|
+
polyface.twoSided = twoSided;
|
|
362
426
|
polyface.expectedClosure = expectedClosure;
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
polyface.data.param.pushXY(paramF64[i], paramF64[i + 1]);
|
|
427
|
+
if (normalF64 && normalIndexI32) {
|
|
428
|
+
for (let i = 0; i + 2 < normalF64.length; i += 3)
|
|
429
|
+
polyface.addNormalXYZ(normalF64[i], normalF64[i + 1], normalF64[i + 2]);
|
|
430
|
+
SerializationHelpers_1.SerializationHelpers.announceZeroBasedIndicesFromSignedOneBasedIndices(normalIndexI32, numPerFace, (i) => { polyface.addNormalIndex(i); });
|
|
368
431
|
}
|
|
369
|
-
if (
|
|
370
|
-
for (let i = 0; i +
|
|
371
|
-
polyface.
|
|
432
|
+
if (paramF64 && paramIndexI32) {
|
|
433
|
+
for (let i = 0; i + 1 < paramF64.length; i += 2)
|
|
434
|
+
polyface.addParamUV(paramF64[i], paramF64[i + 1]);
|
|
435
|
+
SerializationHelpers_1.SerializationHelpers.announceZeroBasedIndicesFromSignedOneBasedIndices(paramIndexI32, numPerFace, (i) => { polyface.addParamIndex(i); });
|
|
372
436
|
}
|
|
373
|
-
if (intColorU32) {
|
|
437
|
+
if (intColorU32 && colorIndexI32) {
|
|
374
438
|
for (const c of intColorU32)
|
|
375
|
-
polyface.
|
|
376
|
-
|
|
377
|
-
// The flatbuffer data is one based.
|
|
378
|
-
// If numPerFace is less than 2, facets are variable size and zero terminated
|
|
379
|
-
// If numPerFace is 2 or more, indices are blocked
|
|
380
|
-
const numIndex = pointIndexI32.length;
|
|
381
|
-
const addIndicesInBlock = (k0, k1) => {
|
|
382
|
-
for (let k = k0; k < k1; k++) {
|
|
383
|
-
const q = pointIndexI32[k];
|
|
384
|
-
polyface.addPointIndex(Math.abs(q) - 1, q > 0);
|
|
385
|
-
if (normalF64 && normalIndexI32) {
|
|
386
|
-
polyface.addNormalIndex(Math.abs(normalIndexI32[k]) - 1);
|
|
387
|
-
}
|
|
388
|
-
if (paramF64 && paramIndexI32) {
|
|
389
|
-
polyface.addParamIndex(Math.abs(paramIndexI32[k]) - 1);
|
|
390
|
-
}
|
|
391
|
-
if (intColorU32 && colorIndexI32) {
|
|
392
|
-
polyface.addColorIndex(Math.abs(colorIndexI32[k]) - 1);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
|
-
if (numPerFace > 1) {
|
|
397
|
-
for (let i0 = 0; i0 + numPerFace <= numIndex; i0 += numPerFace) {
|
|
398
|
-
addIndicesInBlock(i0, i0 + numPerFace);
|
|
399
|
-
polyface.terminateFacet(true);
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
let i0 = 0;
|
|
404
|
-
for (let i1 = i0; i1 < numIndex; i1++) {
|
|
405
|
-
if (pointIndexI32[i1] === 0) {
|
|
406
|
-
addIndicesInBlock(i0, i1);
|
|
407
|
-
polyface.terminateFacet(true);
|
|
408
|
-
i0 = i1 + 1;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
439
|
+
polyface.addColor(c);
|
|
440
|
+
SerializationHelpers_1.SerializationHelpers.announceZeroBasedIndicesFromSignedOneBasedIndices(colorIndexI32, numPerFace, (i) => { polyface.addColorIndex(i); });
|
|
411
441
|
}
|
|
412
|
-
|
|
442
|
+
for (let i = 0; i + 2 < pointF64.length; i += 3)
|
|
443
|
+
polyface.addPointXYZ(pointF64[i], pointF64[i + 1], pointF64[i + 2]);
|
|
444
|
+
SerializationHelpers_1.SerializationHelpers.announceZeroBasedIndicesFromSignedOneBasedIndices(pointIndexI32, numPerFace, (i, v) => { polyface.addPointIndex(i, v); }, () => { polyface.terminateFacet(false); });
|
|
445
|
+
if (!polyface.validateAllIndices())
|
|
446
|
+
return undefined;
|
|
447
|
+
polyface.data.auxData = this.readPolyfaceAuxData(polyfaceHeader, polyfaceHeader.auxData());
|
|
413
448
|
if (taggedNumericDataOffset) {
|
|
414
449
|
const taggedNumericDataAccessor = nullToUndefined(taggedNumericDataOffset);
|
|
415
450
|
if (taggedNumericDataAccessor !== undefined) {
|