@itwin/core-backend 5.1.0-dev.52 → 5.1.0-dev.53

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 (35) hide show
  1. package/lib/cjs/Element.d.ts +3 -0
  2. package/lib/cjs/Element.d.ts.map +1 -1
  3. package/lib/cjs/Element.js +15 -0
  4. package/lib/cjs/Element.js.map +1 -1
  5. package/lib/cjs/Entity.d.ts +5 -4
  6. package/lib/cjs/Entity.d.ts.map +1 -1
  7. package/lib/cjs/Entity.js +19 -11
  8. package/lib/cjs/Entity.js.map +1 -1
  9. package/lib/cjs/Relationship.d.ts +3 -0
  10. package/lib/cjs/Relationship.d.ts.map +1 -1
  11. package/lib/cjs/Relationship.js +15 -0
  12. package/lib/cjs/Relationship.js.map +1 -1
  13. package/lib/cjs/annotations/FrameGeometry.js +3 -3
  14. package/lib/cjs/annotations/FrameGeometry.js.map +1 -1
  15. package/lib/esm/Element.d.ts +3 -0
  16. package/lib/esm/Element.d.ts.map +1 -1
  17. package/lib/esm/Element.js +15 -0
  18. package/lib/esm/Element.js.map +1 -1
  19. package/lib/esm/Entity.d.ts +5 -4
  20. package/lib/esm/Entity.d.ts.map +1 -1
  21. package/lib/esm/Entity.js +20 -12
  22. package/lib/esm/Entity.js.map +1 -1
  23. package/lib/esm/Relationship.d.ts +3 -0
  24. package/lib/esm/Relationship.d.ts.map +1 -1
  25. package/lib/esm/Relationship.js +15 -0
  26. package/lib/esm/Relationship.js.map +1 -1
  27. package/lib/esm/annotations/FrameGeometry.js +3 -3
  28. package/lib/esm/annotations/FrameGeometry.js.map +1 -1
  29. package/lib/esm/test/annotations/FrameGeometry.test.d.ts +2 -0
  30. package/lib/esm/test/annotations/FrameGeometry.test.d.ts.map +1 -0
  31. package/lib/esm/test/annotations/FrameGeometry.test.js +90 -0
  32. package/lib/esm/test/annotations/FrameGeometry.test.js.map +1 -0
  33. package/lib/esm/test/imodel/IModel.test.js +58 -0
  34. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  35. package/package.json +11 -11
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FrameGeometry.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FrameGeometry.test.d.ts","sourceRoot":"","sources":["../../../../src/test/annotations/FrameGeometry.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,90 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import { expect } from "chai";
6
+ import { Geometry, Point3d, Range2d, Transform, Vector3d } from "@itwin/core-geometry";
7
+ import { ColorDef, ElementGeometry, GeometryParams, textAnnotationFrameShapes } from "@itwin/core-common";
8
+ import { appendFrameToBuilder, computeFrame } from "../../annotations/FrameGeometry";
9
+ import { Id64 } from "@itwin/core-bentley";
10
+ // Extending this because the ElementGeometry.Builder.entries attribute is hard to parse
11
+ class MockBuilder extends ElementGeometry.Builder {
12
+ params = [];
13
+ geometries = [];
14
+ appendGeometryParamsChange(params) {
15
+ this.params.push(params.clone());
16
+ return super.appendGeometryParamsChange(params);
17
+ }
18
+ appendGeometryQuery(geometry) {
19
+ this.geometries.push(geometry);
20
+ return super.appendGeometryQuery(geometry);
21
+ }
22
+ }
23
+ function isContinuous(geometries) {
24
+ return geometries.every((current, index) => {
25
+ // If the index is 0, get the last geometry in the list to see if they connect and form a loop
26
+ const previous = (index === 0) ? geometries[geometries.length - 1] : geometries[index - 1];
27
+ return previous.endPoint().isAlmostEqual(current.startPoint(), Geometry.smallMetricDistance);
28
+ });
29
+ }
30
+ describe("FrameGeometry", () => {
31
+ const defaultRange = Range2d.createXYXY(0, 0, 10, 20);
32
+ const defaultTransform = Transform.createIdentity();
33
+ const defaultParams = new GeometryParams(Id64.invalid);
34
+ describe("appendFrameToBuilder", () => {
35
+ it("should append a frame", () => {
36
+ const builder = new MockBuilder();
37
+ const frame = { shape: "rectangle" };
38
+ const result = appendFrameToBuilder(builder, frame, defaultRange, defaultTransform, defaultParams);
39
+ expect(result).to.be.true;
40
+ expect(builder.geometries.length).to.be.equal(1);
41
+ });
42
+ it("should not append frame if shape is undefined or 'none'", () => {
43
+ const builder = new MockBuilder();
44
+ expect(appendFrameToBuilder(builder, { shape: undefined }, defaultRange, defaultTransform, defaultParams)).to.be.false;
45
+ expect(appendFrameToBuilder(builder, { shape: "none" }, defaultRange, defaultTransform, defaultParams)).to.be.false;
46
+ });
47
+ it("should set fill and border colors from frame", () => {
48
+ const builder = new MockBuilder();
49
+ const frame = {
50
+ shape: "rectangle",
51
+ fill: ColorDef.blue.toJSON(),
52
+ border: ColorDef.red.toJSON(),
53
+ borderWeight: 3,
54
+ };
55
+ appendFrameToBuilder(builder, frame, defaultRange, defaultTransform, defaultParams);
56
+ const params = builder.params[builder.params.length - 1];
57
+ expect(params.fillColor?.tbgr).to.equal(ColorDef.blue.tbgr);
58
+ expect(params.lineColor?.tbgr).to.equal(ColorDef.red.tbgr);
59
+ expect(params.weight).to.equal(3);
60
+ });
61
+ });
62
+ describe("computeGeometry", () => {
63
+ const shapes = textAnnotationFrameShapes.filter(shape => shape !== "none");
64
+ it("should compute different frame shapes and they should be continuous", () => {
65
+ for (const shape of shapes) {
66
+ const frame = computeFrame({ frame: shape, range: defaultRange, transform: defaultTransform });
67
+ expect(frame).to.exist;
68
+ const curvePrimitives = frame.collectCurvePrimitives(undefined, true);
69
+ if (curvePrimitives.length > 1) {
70
+ // The start point of a given segment should be the end point of the previous segment
71
+ const isContinuousShape = isContinuous(frame.collectCurvePrimitives(undefined, true));
72
+ expect(isContinuousShape, `Frame shape ${shape} should be continuous`).to.be.true;
73
+ }
74
+ }
75
+ });
76
+ it("should apply transform", () => {
77
+ const origin = Point3d.create(5, 6, 7);
78
+ const vector = Vector3d.create(1, 2, 3);
79
+ vector.tryNormalizeInPlace();
80
+ const transform = Transform.createRigidFromOriginAndVector(origin, vector); // This transform is something I made up for this test. It should exist.
81
+ for (const shape of shapes) {
82
+ const rotatedFrame = computeFrame({ frame: shape, range: defaultRange, transform });
83
+ const unRotatedFrame = computeFrame({ frame: shape, range: defaultRange, transform: defaultTransform });
84
+ const control = unRotatedFrame.cloneTransformed(transform); // This transform is something I made up for this test. It should exist.
85
+ expect(rotatedFrame.isAlmostEqual(control), `Rotated frame for shape ${shape} should match control`).to.be.true;
86
+ }
87
+ });
88
+ });
89
+ });
90
+ //# sourceMappingURL=FrameGeometry.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FrameGeometry.test.js","sourceRoot":"","sources":["../../../../src/test/annotations/FrameGeometry.test.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAqC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1H,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,yBAAyB,EAAuB,MAAM,oBAAoB,CAAC;AAC/H,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,wFAAwF;AACxF,MAAM,WAAY,SAAQ,eAAe,CAAC,OAAO;IACxC,MAAM,GAAqB,EAAE,CAAC;IAC9B,UAAU,GAAwB,EAAE,CAAC;IAC5B,0BAA0B,CAAC,MAAsB;QAC/D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QACjC,OAAO,KAAK,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC;IAClD,CAAC;IACe,mBAAmB,CAAC,QAA2B;QAC7D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/B,OAAO,KA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C,EAAE,CAAC,CAAC,CAAC;YACxC,MAAM,CAAC,mBAAmB,EAAE,CAAC;YAC7B,MAAM,SAAS,GAAG,SAAS,CAAC,8BAA8B,CAAC,MAAM,EAAE,MAAM,CAAE,CAAC,CAAC,wEAAwE;YAErJ,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC3B,MAAM,YAAY,GAAG,YAAY,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC,CAAC;gBACpF,MAAM,cAAc,GAAG,YAAY,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC,CAAC;gBAExG,MAAM,OAAO,GAAG,cAAc,CAAC,gBAAgB,CAAC,SAAS,CAAE,CAAC,CAAC,wEAAwE;gBACrI,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,2BAA2B,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;YAClH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { expect } from \"chai\";\nimport { AnyCurvePrimitive, CurvePrimitive, Geometry, Point3d, Range2d, Transform, Vector3d } from \"@itwin/core-geometry\";\nimport { ColorDef, ElementGeometry, GeometryParams, textAnnotationFrameShapes, TextFrameStyleProps } from \"@itwin/core-common\";\nimport { appendFrameToBuilder, computeFrame } from \"../../annotations/FrameGeometry\";\nimport { Id64 } from \"@itwin/core-bentley\";\n\n// Extending this because the ElementGeometry.Builder.entries attribute is hard to parse\nclass MockBuilder extends ElementGeometry.Builder {\n public params: GeometryParams[] = [];\n public geometries: AnyCurvePrimitive[] = [];\n public override appendGeometryParamsChange(params: GeometryParams): boolean {\n this.params.push(params.clone());\n return super.appendGeometryParamsChange(params);\n }\n public override appendGeometryQuery(geometry: AnyCurvePrimitive): boolean {\n this.geometries.push(geometry);\n return super.appendGeometryQuery(geometry);\n }\n}\n\nfunction isContinuous(geometries: CurvePrimitive[]): boolean {\n return geometries.every((current, index) => {\n // If the index is 0, get the last geometry in the list to see if they connect and form a loop\n const previous = (index === 0) ? geometries[geometries.length - 1] : geometries[index - 1];\n\n return previous.endPoint().isAlmostEqual(current.startPoint(), Geometry.smallMetricDistance);\n });\n}\n\ndescribe(\"FrameGeometry\", () => {\n const defaultRange = Range2d.createXYXY(0, 0, 10, 20);\n const defaultTransform = Transform.createIdentity();\n const defaultParams = new GeometryParams(Id64.invalid);\n\n describe(\"appendFrameToBuilder\", () => {\n it(\"should append a frame\", () => {\n const builder = new MockBuilder();\n const frame: TextFrameStyleProps = { shape: \"rectangle\" };\n const result = appendFrameToBuilder(builder, frame, defaultRange, defaultTransform, defaultParams);\n expect(result).to.be.true;\n expect(builder.geometries.length).to.be.equal(1);\n\n });\n\n it(\"should not append frame if shape is undefined or 'none'\", () => {\n const builder = new MockBuilder();\n expect(appendFrameToBuilder(builder, { shape: undefined }, defaultRange, defaultTransform, defaultParams)).to.be.false;\n expect(appendFrameToBuilder(builder, { shape: \"none\" }, defaultRange, defaultTransform, defaultParams)).to.be.false;\n });\n\n it(\"should set fill and border colors from frame\", () => {\n const builder = new MockBuilder();\n const frame: TextFrameStyleProps = {\n shape: \"rectangle\",\n fill: ColorDef.blue.toJSON(),\n border: ColorDef.red.toJSON(),\n borderWeight: 3,\n };\n appendFrameToBuilder(builder, frame, defaultRange, defaultTransform, defaultParams);\n const params = builder.params[builder.params.length - 1];\n expect(params.fillColor?.tbgr).to.equal(ColorDef.blue.tbgr);\n expect(params.lineColor?.tbgr).to.equal(ColorDef.red.tbgr);\n expect(params.weight).to.equal(3);\n });\n\n });\n describe(\"computeGeometry\", () => {\n const shapes = textAnnotationFrameShapes.filter(shape => shape !== \"none\");\n it(\"should compute different frame shapes and they should be continuous\", () => {\n for (const shape of shapes) {\n const frame = computeFrame({ frame: shape, range: defaultRange, transform: defaultTransform });\n expect(frame).to.exist;\n\n const curvePrimitives = frame.collectCurvePrimitives(undefined, true);\n\n if (curvePrimitives.length > 1) {\n // The start point of a given segment should be the end point of the previous segment\n const isContinuousShape = isContinuous(frame.collectCurvePrimitives(undefined, true))\n expect(isContinuousShape, `Frame shape ${shape} should be continuous`).to.be.true;\n }\n }\n });\n\n it(\"should apply transform\", () => {\n const origin = Point3d.create(5, 6, 7);\n const vector = Vector3d.create(1, 2, 3);\n vector.tryNormalizeInPlace();\n const transform = Transform.createRigidFromOriginAndVector(origin, vector)!; // This transform is something I made up for this test. It should exist.\n\n for (const shape of shapes) {\n const rotatedFrame = computeFrame({ frame: shape, range: defaultRange, transform });\n const unRotatedFrame = computeFrame({ frame: shape, range: defaultRange, transform: defaultTransform });\n\n const control = unRotatedFrame.cloneTransformed(transform)!; // This transform is something I made up for this test. It should exist.\n expect(rotatedFrame.isAlmostEqual(control), `Rotated frame for shape ${shape} should match control`).to.be.true;\n }\n });\n });\n});"]}
@@ -999,12 +999,70 @@ describe("iModel", () => {
999
999
  assert.equal(federationGuid.extendedTypeName, "BeGuid");
1000
1000
  }
1001
1001
  }
1002
+ it("should get metadata for a relationship", async () => {
1003
+ const imodelPath = IModelTestUtils.prepareOutputFile("IModel", "relationshipMetadata.bim");
1004
+ const imodel = SnapshotDb.createEmpty(imodelPath, { rootSubject: { name: "relationshipMetadata" } });
1005
+ const partitionId = imodel.elements.insertElement({
1006
+ classFullName: "BisCore:PhysicalPartition",
1007
+ model: IModel.repositoryModelId,
1008
+ parent: {
1009
+ relClassName: "BisCore:SubjectOwnsPartitionElements",
1010
+ id: IModel.rootSubjectId,
1011
+ },
1012
+ code: new Code({
1013
+ spec: imodel.codeSpecs.getByName(BisCodeSpec.informationPartitionElement).id,
1014
+ scope: IModel.rootSubjectId,
1015
+ value: "physical model",
1016
+ }),
1017
+ });
1018
+ for await (const row of imodel.createQueryReader(`SELECT * FROM bis.Element LIMIT ${1}`)) {
1019
+ const relId = imodel.relationships.insertInstance({
1020
+ classFullName: "BisCore:ElementHasLinks",
1021
+ sourceId: partitionId,
1022
+ targetId: row.ECInstanceId,
1023
+ });
1024
+ const relationship = imodel.relationships.getInstance("BisCore:ElementHasLinks", relId);
1025
+ const metadata = await relationship.getMetaData();
1026
+ assert.isDefined(metadata, "metadata should be defined");
1027
+ }
1028
+ imodel.close();
1029
+ });
1002
1030
  it("should get metadata for class", () => {
1003
1031
  const metaData = imodel1.schemaContext.getSchemaItemSync(Element.classFullName, EntityClass);
1004
1032
  assert.exists(metaData);
1005
1033
  if (metaData !== undefined)
1006
1034
  checkElementMetaData(metaData);
1007
1035
  });
1036
+ it("should iterate through metadata for a relationship", async () => {
1037
+ const imodelPath = IModelTestUtils.prepareOutputFile("IModel", "relationshipMetadata.bim");
1038
+ const imodel = SnapshotDb.createEmpty(imodelPath, { rootSubject: { name: "relationshipMetadata" } });
1039
+ const partitionId = imodel.elements.insertElement({
1040
+ classFullName: "BisCore:PhysicalPartition",
1041
+ model: IModel.repositoryModelId,
1042
+ parent: {
1043
+ relClassName: "BisCore:SubjectOwnsPartitionElements",
1044
+ id: IModel.rootSubjectId,
1045
+ },
1046
+ code: new Code({
1047
+ spec: imodel.codeSpecs.getByName(BisCodeSpec.informationPartitionElement).id,
1048
+ scope: IModel.rootSubjectId,
1049
+ value: "physical model",
1050
+ }),
1051
+ });
1052
+ for await (const row of imodel.createQueryReader(`SELECT * FROM bis.Element LIMIT ${1}`)) {
1053
+ const relId = imodel.relationships.insertInstance({
1054
+ classFullName: "BisCore:ElementHasLinks",
1055
+ sourceId: partitionId,
1056
+ targetId: row.ECInstanceId,
1057
+ });
1058
+ const relationship = imodel.relationships.getInstance("BisCore:ElementHasLinks", relId);
1059
+ relationship.forEach((propName, propMeta) => {
1060
+ assert.isDefined(propName, "Property name should be defined");
1061
+ assert.isDefined(propMeta, "Property metadata should be defined");
1062
+ });
1063
+ }
1064
+ imodel.close();
1065
+ });
1008
1066
  it("update the project extents", async () => {
1009
1067
  const originalExtents = imodel1.projectExtents;
1010
1068
  const newExtents = Range3d.create(originalExtents.low, originalExtents.high);