@itwin/core-backend 5.7.0-dev.6 → 5.7.0-dev.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -1
- package/lib/cjs/IModelDb.d.ts +53 -2
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +57 -2
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +53 -2
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +57 -2
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/test/standalone/ExportGraphics.test.js +89 -0
- package/lib/esm/test/standalone/ExportGraphics.test.js.map +1 -1
- package/package.json +13 -13
|
@@ -379,6 +379,27 @@ describe("exportGraphics", () => {
|
|
|
379
379
|
// Sorting since output order is arbitrary
|
|
380
380
|
assert.deepStrictEqual([infos[0].elementId, infos[1].elementId].sort(), [id0, id1].sort());
|
|
381
381
|
});
|
|
382
|
+
it("process multiple elements simultaneously using separate async calls", async () => {
|
|
383
|
+
const builder0 = new GeometryStreamBuilder();
|
|
384
|
+
builder0.appendGeometry(Loop.createPolygon([Point3d.createZero(), Point3d.create(1, 0, 0), Point3d.create(1, 1, 0), Point3d.create(0, 1, 0)]));
|
|
385
|
+
const id0 = insertPhysicalElement(builder0.geometryStream);
|
|
386
|
+
const builder1 = new GeometryStreamBuilder();
|
|
387
|
+
builder1.appendGeometry(Loop.createPolygon([Point3d.createZero(), Point3d.create(-1, 0, 0), Point3d.create(-1, -1, 0), Point3d.create(0, -1, 0)]));
|
|
388
|
+
const id1 = insertPhysicalElement(builder1.geometryStream);
|
|
389
|
+
const infos = [];
|
|
390
|
+
const onGraphics = (info) => infos.push(info);
|
|
391
|
+
const promises = [id0, id1].map(async (id) => iModel.exportGraphicsAsync({
|
|
392
|
+
elementIdArray: [id],
|
|
393
|
+
onGraphics,
|
|
394
|
+
}));
|
|
395
|
+
// onGraphics should not be called yet
|
|
396
|
+
assert.strictEqual(infos.length, 0);
|
|
397
|
+
await Promise.all(promises);
|
|
398
|
+
// once both promises are resolved, the results are available.
|
|
399
|
+
assert.strictEqual(infos.length, 2);
|
|
400
|
+
// Sorting since output order is arbitrary
|
|
401
|
+
assert.deepStrictEqual([infos[0].elementId, infos[1].elementId].sort(), [id0, id1].sort());
|
|
402
|
+
});
|
|
382
403
|
it("produces expected indices, points, normals, params in smoketest", () => {
|
|
383
404
|
const builder = new GeometryStreamBuilder();
|
|
384
405
|
builder.appendGeometry(Loop.createPolygon([Point3d.createZero(), Point3d.create(1, 0, 0), Point3d.create(1, 1, 0), Point3d.create(0, 1, 0)]));
|
|
@@ -692,6 +713,74 @@ describe("exportGraphics", () => {
|
|
|
692
713
|
assert.deepStrictEqual(Array.from(partInfos[0].mesh.normals), [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]);
|
|
693
714
|
assert.deepStrictEqual(Array.from(partInfos[0].mesh.params), [1, 0, 0, 1, 0, 0, 1, 1]);
|
|
694
715
|
});
|
|
716
|
+
it("exports multiple parts simultaneously with exportPartGraphicsAsync", async () => {
|
|
717
|
+
const partBuilder = new GeometryStreamBuilder();
|
|
718
|
+
partBuilder.appendGeometry(Loop.createPolygon([Point3d.createZero(), Point3d.create(1, 0, 0), Point3d.create(1, 1, 0), Point3d.create(0, 1, 0)]));
|
|
719
|
+
const partProps = {
|
|
720
|
+
classFullName: GeometryPart.classFullName,
|
|
721
|
+
model: IModel.dictionaryId,
|
|
722
|
+
code: Code.createEmpty(),
|
|
723
|
+
geom: partBuilder.geometryStream,
|
|
724
|
+
};
|
|
725
|
+
// Add two parts
|
|
726
|
+
const partId1 = iModel.elements.insertElement(partProps);
|
|
727
|
+
const partId2 = iModel.elements.insertElement(partProps);
|
|
728
|
+
const partInstanceBuilder = new GeometryStreamBuilder();
|
|
729
|
+
partInstanceBuilder.appendGeometryPart3d(partId1, Point3d.create(7, 8, 9));
|
|
730
|
+
partInstanceBuilder.appendGeometryPart3d(partId2, Point3d.create(10, 11, 12));
|
|
731
|
+
const partInstanceId = insertPhysicalElement(partInstanceBuilder.geometryStream);
|
|
732
|
+
const infos = [];
|
|
733
|
+
const partInstanceArray = [];
|
|
734
|
+
const exportGraphicsOptions = {
|
|
735
|
+
elementIdArray: [partInstanceId],
|
|
736
|
+
onGraphics: (info) => infos.push(info),
|
|
737
|
+
partInstanceArray,
|
|
738
|
+
};
|
|
739
|
+
await iModel.exportGraphicsAsync(exportGraphicsOptions);
|
|
740
|
+
assert.strictEqual(infos.length, 0);
|
|
741
|
+
assert.strictEqual(partInstanceArray.length, 2);
|
|
742
|
+
assert.isTrue(partInstanceArray[0].partId === partId1 || partInstanceArray[1].partId === partId1);
|
|
743
|
+
assert.isTrue(partInstanceArray[0].partId === partId2 || partInstanceArray[1].partId === partId2);
|
|
744
|
+
assert.isTrue(partInstanceArray[0].partId !== partInstanceArray[1].partId);
|
|
745
|
+
assert.strictEqual(partInstanceArray[0].partInstanceId, partInstanceId);
|
|
746
|
+
assert.strictEqual(partInstanceArray[1].partInstanceId, partInstanceId);
|
|
747
|
+
assert.isDefined(partInstanceArray[0].transform);
|
|
748
|
+
assert.deepStrictEqual(Array.from(partInstanceArray[0].transform), [1, 0, 0, 7, 0, 1, 0, 8, 0, 0, 1, 9]);
|
|
749
|
+
assert.isDefined(partInstanceArray[1].transform);
|
|
750
|
+
assert.deepStrictEqual(Array.from(partInstanceArray[1].transform), [1, 0, 0, 10, 0, 1, 0, 11, 0, 0, 1, 12]);
|
|
751
|
+
const partInfos = [];
|
|
752
|
+
const onPartGraphics = (partInfo) => partInfos.push(partInfo);
|
|
753
|
+
const promises = partInstanceArray.map(async (partInstance) => iModel.exportPartGraphicsAsync({
|
|
754
|
+
elementId: partInstance.partId,
|
|
755
|
+
displayProps: partInstance.displayProps,
|
|
756
|
+
onPartGraphics,
|
|
757
|
+
}));
|
|
758
|
+
// onPartGraphics should not be called yet
|
|
759
|
+
assert.strictEqual(partInfos.length, 0);
|
|
760
|
+
await Promise.all(promises);
|
|
761
|
+
// once both promises are resolved, the results are available.
|
|
762
|
+
assert.strictEqual(partInfos.length, 2);
|
|
763
|
+
// The ordering of these values is arbitrary, but should be consistent between runs.
|
|
764
|
+
// Baselines may need to be updated if native GeomLibs is refactored, but:
|
|
765
|
+
// * Lengths of all fields should remain the same
|
|
766
|
+
// * Actual point, normal and param values should remain the same
|
|
767
|
+
assert.strictEqual(partInfos[0].mesh.indices.length, 6);
|
|
768
|
+
assert.strictEqual(partInfos[0].mesh.points.length, 12);
|
|
769
|
+
assert.strictEqual(partInfos[0].mesh.normals.length, 12);
|
|
770
|
+
assert.strictEqual(partInfos[0].mesh.params.length, 8);
|
|
771
|
+
assert.strictEqual(partInfos[1].mesh.indices.length, 6);
|
|
772
|
+
assert.strictEqual(partInfos[1].mesh.points.length, 12);
|
|
773
|
+
assert.strictEqual(partInfos[1].mesh.normals.length, 12);
|
|
774
|
+
assert.strictEqual(partInfos[1].mesh.params.length, 8);
|
|
775
|
+
assert.deepStrictEqual(Array.from(partInfos[0].mesh.indices), [0, 1, 2, 1, 0, 3]);
|
|
776
|
+
assert.deepStrictEqual(Array.from(partInfos[0].mesh.points), [1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0]);
|
|
777
|
+
assert.deepStrictEqual(Array.from(partInfos[0].mesh.normals), [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]);
|
|
778
|
+
assert.deepStrictEqual(Array.from(partInfos[0].mesh.params), [1, 0, 0, 1, 0, 0, 1, 1]);
|
|
779
|
+
assert.deepStrictEqual(Array.from(partInfos[1].mesh.indices), [0, 1, 2, 1, 0, 3]);
|
|
780
|
+
assert.deepStrictEqual(Array.from(partInfos[1].mesh.points), [1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0]);
|
|
781
|
+
assert.deepStrictEqual(Array.from(partInfos[1].mesh.normals), [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]);
|
|
782
|
+
assert.deepStrictEqual(Array.from(partInfos[1].mesh.params), [1, 0, 0, 1, 0, 0, 1, 1]);
|
|
783
|
+
});
|
|
695
784
|
it("handles single geometryClass in GeometryStream", () => {
|
|
696
785
|
const builder = new GeometryStreamBuilder();
|
|
697
786
|
const geometryParams = new GeometryParams(seedCategory);
|