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

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/lib/cjs/BriefcaseManager.d.ts +10 -2
  3. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  4. package/lib/cjs/BriefcaseManager.js +12 -0
  5. package/lib/cjs/BriefcaseManager.js.map +1 -1
  6. package/lib/cjs/ExportGraphics.d.ts +54 -8
  7. package/lib/cjs/ExportGraphics.d.ts.map +1 -1
  8. package/lib/cjs/ExportGraphics.js +158 -59
  9. package/lib/cjs/ExportGraphics.js.map +1 -1
  10. package/lib/cjs/IModelDb.d.ts.map +1 -1
  11. package/lib/cjs/IModelDb.js +3 -0
  12. package/lib/cjs/IModelDb.js.map +1 -1
  13. package/lib/esm/BriefcaseManager.d.ts +10 -2
  14. package/lib/esm/BriefcaseManager.d.ts.map +1 -1
  15. package/lib/esm/BriefcaseManager.js +12 -0
  16. package/lib/esm/BriefcaseManager.js.map +1 -1
  17. package/lib/esm/ExportGraphics.d.ts +54 -8
  18. package/lib/esm/ExportGraphics.d.ts.map +1 -1
  19. package/lib/esm/ExportGraphics.js +156 -58
  20. package/lib/esm/ExportGraphics.js.map +1 -1
  21. package/lib/esm/IModelDb.d.ts.map +1 -1
  22. package/lib/esm/IModelDb.js +3 -0
  23. package/lib/esm/IModelDb.js.map +1 -1
  24. package/lib/esm/test/standalone/ExportGraphics.test.js +53 -1
  25. package/lib/esm/test/standalone/ExportGraphics.test.js.map +1 -1
  26. package/lib/esm/test/standalone/IModelLimits.test.d.ts +2 -0
  27. package/lib/esm/test/standalone/IModelLimits.test.d.ts.map +1 -0
  28. package/lib/esm/test/standalone/IModelLimits.test.js +103 -0
  29. package/lib/esm/test/standalone/IModelLimits.test.js.map +1 -0
  30. package/lib/esm/test/standalone/SnapshotDb.test.js +19 -1
  31. package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
  32. package/package.json +12 -12
@@ -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