@itwin/core-backend 3.4.0-dev.26 → 3.4.0-dev.29
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomViewState3dCreator.d.ts","sourceRoot":"","sources":["../../src/CustomViewState3dCreator.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAA6C,MAAM,oBAAoB,CAAC;AAExI,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;GAGG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,OAAO,CAAW;gBACP,MAAM,EAAE,QAAQ;IAGnC;;;;;OAKG;IACU,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,OAAO,CAAC,sBAAsB,CAAC;YAclG,iBAAiB;IAQ/B;;;;OAIG;YACW,gBAAgB;
|
|
1
|
+
{"version":3,"file":"CustomViewState3dCreator.d.ts","sourceRoot":"","sources":["../../src/CustomViewState3dCreator.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAA6C,MAAM,oBAAoB,CAAC;AAExI,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;GAGG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,OAAO,CAAW;gBACP,MAAM,EAAE,QAAQ;IAGnC;;;;;OAKG;IACU,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,OAAO,CAAC,sBAAsB,CAAC;YAclG,iBAAiB;IAQ/B;;;;OAIG;YACW,gBAAgB;IAsB9B;;OAEG;YACW,aAAa;IAe3B;;OAEG;IACH,OAAO,CAAC,aAAa,CAMnB;CACH"}
|
|
@@ -62,6 +62,7 @@ class CustomViewState3dCreator {
|
|
|
62
62
|
const modelIds = new Set(modelIdsList);
|
|
63
63
|
for (const id of modelIds) {
|
|
64
64
|
try {
|
|
65
|
+
await new Promise((resolve) => setImmediate(resolve)); // Free up main thread temporarily. Ideally we get queryModelExtents off the main thread and do not need to do this.
|
|
65
66
|
const props = this._imodel.nativeDb.queryModelExtents({ id }).modelExtents;
|
|
66
67
|
modelExtents.union(core_geometry_1.Range3d.fromJSON(props), modelExtents);
|
|
67
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomViewState3dCreator.js","sourceRoot":"","sources":["../../src/CustomViewState3dCreator.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA+E;AAC/E,oDAAwI;AACxI,wDAA+C;AAG/C;;;GAGG;AACH,MAAa,wBAAwB;IAEnC,YAAmB,MAAgB;
|
|
1
|
+
{"version":3,"file":"CustomViewState3dCreator.js","sourceRoot":"","sources":["../../src/CustomViewState3dCreator.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA+E;AAC/E,oDAAwI;AACxI,wDAA+C;AAG/C;;;GAGG;AACH,MAAa,wBAAwB;IAEnC,YAAmB,MAAgB;QA4EnC;;WAEG;QACK,kBAAa,GAAG,KAAK,EAAE,KAAa,EAAE,EAAE;YAC9C,MAAM,IAAI,GAAG,EAAE,CAAC;YAChB,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,4BAAc,CAAC,kBAAkB,EAAE,CAAC;gBAC5G,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAEpB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;QApFA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IACD;;;;;OAKG;IACI,KAAK,CAAC,wBAAwB,CAAC,OAAwC;QAC5E,IAAI,oBAAoB,CAAC;QACzB,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,MAAK,SAAS;YACjC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Y,CAAC,KAAK,CAAC,uBAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,CAAC;aAC3D;YAAC,OAAO,GAAQ,EAAE;gBACjB,IAAK,GAAmB,CAAC,WAAW,KAAK,0BAAY,CAAC,UAAU,EAAE,EAAE,mDAAmD;oBACrH,SAAS;iBACV;gBACD,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC;oBACrB,MAAM,GAAG,CAAC,CAAC,mEAAmE;gBAChF,SAAS;aACV;SACF;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,aAAa;QACzB,yFAAyF;QACzF,sGAAsG;QACtG,6JAA6J;QAC7J,MAAM,MAAM,GAAG,8FAA8F,CAAC;QAC9G,MAAM,gBAAgB,GAAG,sEAAsE,CAAC;QAChG,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI;YACF,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,MAAM,IAAI,gBAAgB,EAAE,CAAC,CAAC;SACpE;QAAC,MAAM;YACN,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;SAC3C;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CAWF;AAxFD,4DAwFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { CompressedId64Set, Id64Array, Id64String } from \"@itwin/core-bentley\";\r\nimport { CustomViewState3dCreatorOptions, CustomViewState3dProps, IModelError, IModelStatus, QueryRowFormat } from \"@itwin/core-common\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\n/**\r\n * Class which helps to generate a custom ViewState3d.\r\n * @internal\r\n */\r\nexport class CustomViewState3dCreator {\r\n private _imodel: IModelDb;\r\n public constructor(iModel: IModelDb) {\r\n this._imodel = iModel;\r\n }\r\n /**\r\n * Gets default view state data such as category Ids and modelextents. If no model ids are passed in, all 3D models in the iModel are used.\r\n * @param [modelIds] Ids of models to display in the view.\r\n * @throws [IModelError]($common) If no 3d models are found in the iModel.\r\n * @returns CustomViewState3dProps\r\n */\r\n public async getCustomViewState3dData(options: CustomViewState3dCreatorOptions): Promise<CustomViewState3dProps> {\r\n let decompressedModelIds;\r\n if (options?.modelIds !== undefined)\r\n decompressedModelIds = CompressedId64Set.decompressArray(options.modelIds);\r\n const models: Id64Array = decompressedModelIds ?? await this._getAllModels();\r\n const categories: Id64Array = await this._getAllCategories();\r\n const modelExtents: Range3d = await this._getModelExtents(models);\r\n return {\r\n modelIds: CompressedId64Set.sortAndCompress(models),\r\n categoryIds: CompressedId64Set.sortAndCompress(categories),\r\n modelExtents: modelExtents.toJSON(),\r\n };\r\n }\r\n\r\n private async _getAllCategories(): Promise<Id64Array> {\r\n // Only use categories with elements in them\r\n const query = `SELECT DISTINCT Category.Id AS id FROM BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId FROM BisCore.SpatialCategory)`;\r\n const categories: Id64Array = await this._executeQuery(query);\r\n\r\n return categories;\r\n }\r\n\r\n /**\r\n * Gets the union of the extents of each model id passed in. Can return null range if no ids are passed, or no geometry found for the models.\r\n * @param modelIdsList array of modelIds to get extents for\r\n * @returns Range3d, the union of the extents of each model id\r\n */\r\n private async _getModelExtents(modelIdsList: Id64String[]): Promise<Range3d> {\r\n const modelExtents = new Range3d();\r\n if (modelIdsList.length === 0)\r\n return modelExtents;\r\n const modelIds = new Set(modelIdsList);\r\n for (const id of modelIds) {\r\n try {\r\n await new Promise((resolve) => setImmediate(resolve)); // Free up main thread temporarily. Ideally we get queryModelExtents off the main thread and do not need to do this.\r\n const props = this._imodel.nativeDb.queryModelExtents({ id }).modelExtents;\r\n modelExtents.union(Range3d.fromJSON(props), modelExtents);\r\n } catch (err: any) {\r\n if ((err as IModelError).errorNumber === IModelStatus.NoGeometry) { // if there was no geometry, just return null range\r\n continue;\r\n }\r\n if (modelIds.size === 1)\r\n throw err; // if they're asking for more than one model, don't throw on error.\r\n continue;\r\n }\r\n }\r\n return modelExtents;\r\n }\r\n\r\n /**\r\n * Get all PhysicalModel ids in the iModel\r\n */\r\n private async _getAllModels(): Promise<Id64Array> {\r\n // Note: IsNotSpatiallyLocated was introduced in a later version of the BisCore ECSchema.\r\n // If the iModel has an earlier version, the statement will throw because the property does not exist.\r\n // If the iModel was created from an earlier version and later upgraded to a newer version, the property may be NULL for models created prior to the upgrade.\r\n const select = \"SELECT ECInstanceId FROM Bis.GeometricModel3D WHERE IsPrivate = false AND IsTemplate = false\";\r\n const spatialCriterion = \"AND (IsNotSpatiallyLocated IS NULL OR IsNotSpatiallyLocated = false)\";\r\n let models = [];\r\n try {\r\n models = await this._executeQuery(`${select} ${spatialCriterion}`);\r\n } catch {\r\n models = await this._executeQuery(select);\r\n }\r\n\r\n return models;\r\n }\r\n /**\r\n * Helper function to execute ECSql queries.\r\n */\r\n private _executeQuery = async (query: string) => {\r\n const rows = [];\r\n for await (const row of this._imodel.query(query, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }))\r\n rows.push(row.id);\r\n\r\n return rows;\r\n };\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-backend",
|
|
3
|
-
"version": "3.4.0-dev.
|
|
3
|
+
"version": "3.4.0-dev.29",
|
|
4
4
|
"description": "iTwin.js backend components",
|
|
5
5
|
"main": "lib/cjs/core-backend.js",
|
|
6
6
|
"typings": "lib/cjs/core-backend",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"url": "http://www.bentley.com"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@itwin/core-bentley": "^3.4.0-dev.
|
|
28
|
-
"@itwin/core-common": "^3.4.0-dev.
|
|
29
|
-
"@itwin/core-geometry": "^3.4.0-dev.
|
|
30
|
-
"@itwin/ecschema-metadata": "^3.4.0-dev.
|
|
27
|
+
"@itwin/core-bentley": "^3.4.0-dev.29",
|
|
28
|
+
"@itwin/core-common": "^3.4.0-dev.29",
|
|
29
|
+
"@itwin/core-geometry": "^3.4.0-dev.29",
|
|
30
|
+
"@itwin/ecschema-metadata": "^3.4.0-dev.29",
|
|
31
31
|
"@opentelemetry/api": "^1.0.4"
|
|
32
32
|
},
|
|
33
33
|
"peerDependenciesMeta": {
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"NOTE: All tools used by scripts in this package must be listed as devDependencies"
|
|
44
44
|
],
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@itwin/build-tools": "3.4.0-dev.
|
|
47
|
-
"@itwin/core-bentley": "3.4.0-dev.
|
|
48
|
-
"@itwin/core-common": "3.4.0-dev.
|
|
49
|
-
"@itwin/core-geometry": "3.4.0-dev.
|
|
50
|
-
"@itwin/core-webpack-tools": "3.4.0-dev.
|
|
51
|
-
"@itwin/ecschema-metadata": "3.4.0-dev.
|
|
52
|
-
"@itwin/eslint-plugin": "3.4.0-dev.
|
|
46
|
+
"@itwin/build-tools": "3.4.0-dev.29",
|
|
47
|
+
"@itwin/core-bentley": "3.4.0-dev.29",
|
|
48
|
+
"@itwin/core-common": "3.4.0-dev.29",
|
|
49
|
+
"@itwin/core-geometry": "3.4.0-dev.29",
|
|
50
|
+
"@itwin/core-webpack-tools": "3.4.0-dev.29",
|
|
51
|
+
"@itwin/ecschema-metadata": "3.4.0-dev.29",
|
|
52
|
+
"@itwin/eslint-plugin": "3.4.0-dev.29",
|
|
53
53
|
"@opentelemetry/api": "^1.0.4",
|
|
54
54
|
"@types/chai": "4.3.1",
|
|
55
55
|
"@types/chai-as-promised": "^7",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@azure/storage-blob": "^12.7.0",
|
|
82
82
|
"@bentley/imodeljs-native": "3.4.9",
|
|
83
|
-
"@itwin/core-telemetry": "3.4.0-dev.
|
|
83
|
+
"@itwin/core-telemetry": "3.4.0-dev.29",
|
|
84
84
|
"form-data": "^2.3.2",
|
|
85
85
|
"fs-extra": "^8.1.0",
|
|
86
86
|
"json5": "^2.2.0",
|