@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
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Serialization
|
|
7
7
|
*/
|
|
8
|
+
import { assert } from "@itwin/core-bentley";
|
|
8
9
|
import { AkimaCurve3d } from "../bspline/AkimaCurve3d";
|
|
9
10
|
import { BSplineCurve3d } from "../bspline/BSplineCurve";
|
|
10
11
|
import { BSplineCurve3dH } from "../bspline/BSplineCurve3dH";
|
|
@@ -340,24 +341,6 @@ export var IModelJson;
|
|
|
340
341
|
}
|
|
341
342
|
return undefined;
|
|
342
343
|
}
|
|
343
|
-
// For each nonzero index, Announce Math.abs (value) -1
|
|
344
|
-
static addZeroBasedIndicesFromSignedOneBased(data, numPerFace, f) {
|
|
345
|
-
if (data && Geometry.isNumberArray(data)) {
|
|
346
|
-
if (numPerFace > 1) {
|
|
347
|
-
// all indices are used ...
|
|
348
|
-
for (const value of data) {
|
|
349
|
-
f(Math.abs(value) - 1);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
else {
|
|
353
|
-
// ignore separator zeros ...
|
|
354
|
-
for (const value of data) {
|
|
355
|
-
if (value !== 0)
|
|
356
|
-
f(Math.abs(value) - 1);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
344
|
/** parse polyface aux data content to PolyfaceAuxData instance */
|
|
362
345
|
static parsePolyfaceAuxData(data = undefined, numPerFace = 0) {
|
|
363
346
|
if (!Array.isArray(data.channels) || !Array.isArray(data.indices))
|
|
@@ -374,7 +357,7 @@ export var IModelJson;
|
|
|
374
357
|
}
|
|
375
358
|
}
|
|
376
359
|
const auxData = new PolyfaceAuxData(outChannels, []);
|
|
377
|
-
|
|
360
|
+
SerializationHelpers.announceZeroBasedIndicesFromSignedOneBasedIndices(data.indices, numPerFace, (x) => { auxData.indices.push(x); });
|
|
378
361
|
return auxData;
|
|
379
362
|
}
|
|
380
363
|
/** parse indexed mesh content to an IndexedPolyface instance */
|
|
@@ -384,74 +367,49 @@ export var IModelJson;
|
|
|
384
367
|
if (data.hasOwnProperty("point") && Array.isArray(data.point)
|
|
385
368
|
&& data.hasOwnProperty("pointIndex") && Array.isArray(data.pointIndex)) {
|
|
386
369
|
const polyface = IndexedPolyface.create();
|
|
387
|
-
|
|
388
|
-
// for normals, addNormal() is overeager to detect the (common) case of duplicate normals in sequence.
|
|
389
|
-
// use addNormalXYZ which always creates a new one.
|
|
390
|
-
// likewise for params
|
|
391
|
-
for (const uvw of data.normal) {
|
|
392
|
-
if (Geometry.isNumberArray(uvw, 3))
|
|
393
|
-
polyface.addNormalXYZ(uvw[0], uvw[1], uvw[2]);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
370
|
+
const numPerFace = data.hasOwnProperty("numPerFace") ? data.numPerFace : 0;
|
|
396
371
|
if (data.hasOwnProperty("twoSided")) {
|
|
397
372
|
const q = data.twoSided;
|
|
398
373
|
if (q === true || q === false) {
|
|
399
374
|
polyface.twoSided = q;
|
|
400
375
|
}
|
|
401
376
|
}
|
|
402
|
-
const numPerFace = data.hasOwnProperty("numPerFace") ? data.numPerFace : 0;
|
|
403
377
|
if (data.hasOwnProperty("expectedClosure")) {
|
|
404
378
|
const q = data.expectedClosure;
|
|
405
379
|
if (Number.isFinite(q)) {
|
|
406
380
|
polyface.expectedClosure = q;
|
|
407
381
|
}
|
|
408
382
|
}
|
|
409
|
-
if (data.hasOwnProperty("
|
|
383
|
+
if (data.hasOwnProperty("normal") && Array.isArray(data.normal) && data.hasOwnProperty("normalIndex")) {
|
|
384
|
+
// For normals, addNormal() is overeager to detect the (common) case of duplicate normals in sequence.
|
|
385
|
+
// Use addNormalXYZ which always creates a new one. Likewise for params.
|
|
386
|
+
for (const uvw of data.normal) {
|
|
387
|
+
if (Geometry.isNumberArray(uvw, 3))
|
|
388
|
+
polyface.addNormalXYZ(uvw[0], uvw[1], uvw[2]);
|
|
389
|
+
}
|
|
390
|
+
SerializationHelpers.announceZeroBasedIndicesFromSignedOneBasedIndices(data.normalIndex, numPerFace, (x) => { polyface.addNormalIndex(x); });
|
|
391
|
+
}
|
|
392
|
+
if (data.hasOwnProperty("param") && Array.isArray(data.param) && data.hasOwnProperty("paramIndex")) {
|
|
410
393
|
for (const uv of data.param) {
|
|
411
394
|
if (Geometry.isNumberArray(uv, 2))
|
|
412
395
|
polyface.addParamUV(uv[0], uv[1]);
|
|
413
396
|
}
|
|
397
|
+
SerializationHelpers.announceZeroBasedIndicesFromSignedOneBasedIndices(data.paramIndex, numPerFace, (x) => { polyface.addParamIndex(x); });
|
|
414
398
|
}
|
|
415
|
-
if (data.hasOwnProperty("color") && Array.isArray(data.color)) {
|
|
416
|
-
for (const c of data.color)
|
|
399
|
+
if (data.hasOwnProperty("color") && Array.isArray(data.color) && data.hasOwnProperty("colorIndex")) {
|
|
400
|
+
for (const c of data.color)
|
|
417
401
|
polyface.addColor(c);
|
|
418
|
-
}
|
|
402
|
+
SerializationHelpers.announceZeroBasedIndicesFromSignedOneBasedIndices(data.colorIndex, numPerFace, (x) => { polyface.addColorIndex(x); });
|
|
419
403
|
}
|
|
420
404
|
for (const p of data.point)
|
|
421
405
|
polyface.addPointXYZ(p[0], p[1], p[2]);
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
const p0 = Math.abs(p) - 1;
|
|
426
|
-
polyface.addPointIndex(p0, p > 0);
|
|
427
|
-
if ((i + 1) % numPerFace === 0)
|
|
428
|
-
polyface.terminateFacet(false);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
else {
|
|
432
|
-
for (const p of data.pointIndex) {
|
|
433
|
-
if (p === 0)
|
|
434
|
-
polyface.terminateFacet(false); // we are responsible for index checking !!!
|
|
435
|
-
else {
|
|
436
|
-
const p0 = Math.abs(p) - 1;
|
|
437
|
-
polyface.addPointIndex(p0, p > 0);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
if (data.hasOwnProperty("normalIndex")) {
|
|
442
|
-
Reader.addZeroBasedIndicesFromSignedOneBased(data.normalIndex, numPerFace, (x) => { polyface.addNormalIndex(x); });
|
|
443
|
-
}
|
|
444
|
-
if (data.hasOwnProperty("paramIndex")) {
|
|
445
|
-
Reader.addZeroBasedIndicesFromSignedOneBased(data.paramIndex, numPerFace, (x) => { polyface.addParamIndex(x); });
|
|
446
|
-
}
|
|
447
|
-
if (data.hasOwnProperty("colorIndex")) {
|
|
448
|
-
Reader.addZeroBasedIndicesFromSignedOneBased(data.colorIndex, numPerFace, (x) => { polyface.addColorIndex(x); });
|
|
449
|
-
}
|
|
406
|
+
SerializationHelpers.announceZeroBasedIndicesFromSignedOneBasedIndices(data.pointIndex, numPerFace, (i, v) => { polyface.addPointIndex(i, v); }, () => { polyface.terminateFacet(false); });
|
|
407
|
+
if (!polyface.validateAllIndices())
|
|
408
|
+
return undefined;
|
|
450
409
|
if (data.hasOwnProperty("auxData"))
|
|
451
410
|
polyface.data.auxData = Reader.parsePolyfaceAuxData(data.auxData, numPerFace);
|
|
452
|
-
if (data.hasOwnProperty("tags"))
|
|
411
|
+
if (data.hasOwnProperty("tags"))
|
|
453
412
|
polyface.data.taggedNumericData = Reader.parseTaggedNumericProps(data.tags);
|
|
454
|
-
}
|
|
455
413
|
return polyface;
|
|
456
414
|
}
|
|
457
415
|
return undefined;
|
|
@@ -1107,28 +1065,18 @@ export var IModelJson;
|
|
|
1107
1065
|
return out;
|
|
1108
1066
|
}
|
|
1109
1067
|
handlePolyfaceAuxData(auxData, pf) {
|
|
1110
|
-
|
|
1111
|
-
contents
|
|
1068
|
+
assert(auxData === pf.data.auxData);
|
|
1069
|
+
const contents = { indices: [], channels: [] };
|
|
1112
1070
|
const visitor = pf.createVisitor(0);
|
|
1113
|
-
if (!visitor.auxData)
|
|
1114
|
-
return;
|
|
1115
1071
|
while (visitor.moveToNextFacet()) {
|
|
1116
|
-
for (let i = 0; i < visitor.indexCount; i++)
|
|
1072
|
+
for (let i = 0; i < visitor.indexCount; i++)
|
|
1117
1073
|
contents.indices.push(visitor.auxData.indices[i] + 1);
|
|
1118
|
-
}
|
|
1119
1074
|
contents.indices.push(0); // facet terminator.
|
|
1120
1075
|
}
|
|
1121
|
-
contents.channels = [];
|
|
1122
1076
|
for (const inChannel of auxData.channels) {
|
|
1123
|
-
const outChannel = {};
|
|
1124
|
-
outChannel.dataType = inChannel.dataType;
|
|
1125
|
-
outChannel.name = inChannel.name;
|
|
1126
|
-
outChannel.inputName = inChannel.inputName;
|
|
1127
|
-
outChannel.data = [];
|
|
1077
|
+
const outChannel = { data: [], dataType: inChannel.dataType, name: inChannel.name, inputName: inChannel.inputName };
|
|
1128
1078
|
for (const inData of inChannel.data) {
|
|
1129
|
-
const outData = {};
|
|
1130
|
-
outData.input = inData.input;
|
|
1131
|
-
outData.values = inData.values.slice(0);
|
|
1079
|
+
const outData = { input: inData.input, values: inData.values.slice(0) };
|
|
1132
1080
|
outChannel.data.push(outData);
|
|
1133
1081
|
}
|
|
1134
1082
|
contents.channels.push(outChannel);
|