@itwin/core-geometry 5.1.0-dev.65 → 5.1.0-dev.69

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":"ReusableObjectCache.js","sourceRoot":"","sources":["../../../src/geometry3d/ReusableObjectCache.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD;;GAEG;AACH;;;;;;GAMG;AACH,MAAM,OAAgB,mBAAmB;IAG/B,cAAc,CAAM;IACrB,OAAO,CAAS;IAChB,SAAS,CAAS;IAClB,QAAQ,CAAS;IACxB;;OAEG;IACH;QACE,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;IACpB,CAAC;IACD;;;OAGG;IACI,WAAW,CAAC,IAAmB;QACpC,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YACzB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IACD;;;;;OAKG;IACI,aAAa;QAClB,IAAI,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC;QACrC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,IAAI,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;YAC7B,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD;;OAEG;IACI,cAAc,CAAC,IAAS;QAC7B,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;CACF;AACD;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,mBAAqC;IACpE,aAAa,CAAC,IAAsB,IAAU,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IAChE,cAAc,KAAuB,OAAO,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACjF,gBAAuB,KAAK,EAAE,CAAC,CAAC,CAAC;IACjC;;;OAGG;IACI,WAAW,CAAC,MAA4B;QAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAClC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtB,OAAO,IAAI,CAAC;IAEd,CAAC;CACF","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*--------------------------------------------------------------------------------------------*/\nimport { GrowableXYZArray } from \"./GrowableXYZArray\";\nimport { IndexedXYZCollection } from \"./IndexedXYZCollection\";\n\n/** @packageDocumentation\n * @module ArraysAndInterfaces\n */\n/**\n * abstract class managing an array of objects of type T, available for reuse by trusted callers.\n * * Derived class must implement these methods:\n * * `createForCache()` -- create a new, ready-to-use object\n * * `clearForCache (data: T)` -- tidy up `data` so it can be reused.\n * @internal\n */\nexport abstract class ReusableObjectCache<T> {\n protected abstract clearForCache(data: T): void;\n protected abstract createForCache(): T;\n private _cachedObjects: T[];\n public numDrop: number;\n public numCreate: number;\n public numReuse: number;\n /**\n * create a new cache for objects of type T\n */\n protected constructor() {\n this._cachedObjects = [];\n this.numDrop = 0;\n this.numCreate = 0;\n this.numReuse = 0;\n }\n /** Present `data` for storage in the cache, and hence reuse by any subsequent `grabFromCache`\n * * `data` will be sent to `clearForCache`.\n * * caller should never refer to this instance again.\n */\n public dropToCache(data: T | undefined) {\n if (data) {\n this.numDrop++;\n this.clearForCache(data);\n this._cachedObjects.push(data);\n }\n }\n /**\n * grab an object from the cache.\n * * The returned object becomes property of the caller.\n * * That is, the cache does not remember it for any further management\n * @param data\n */\n public grabFromCache(): T {\n let data = this._cachedObjects.pop();\n if (data === undefined) {\n data = this.createForCache();\n this.numCreate++;\n } else {\n this.numReuse++;\n }\n return data;\n }\n /** Drop all entries of data[] to the cache.\n * @param data on input, the data to drop. on output, data is an empty array.\n */\n public dropAllToCache(data: T[]) {\n while (data.length > 0) {\n this.dropToCache(data.pop());\n }\n }\n}\n/**\n * Cache of GrowableXYZArray.\n * Intended for use by (for instance) clipping methods that can be structured to have disciplined reuse of a small number of arrays for a large number of steps.\n * @internal\n */\nexport class GrowableXYZArrayCache extends ReusableObjectCache<GrowableXYZArray> {\n protected clearForCache(data: GrowableXYZArray): void { data.length = 0; }\n protected createForCache(): GrowableXYZArray { return new GrowableXYZArray(10); }\n public constructor() { super(); }\n /**\n * Grab an array from the cache and immediately fill from a source\n * @param source\n */\n public grabAndFill(source: IndexedXYZCollection): GrowableXYZArray {\n const dest = this.grabFromCache();\n dest.pushFrom(source);\n return dest;\n\n }\n}\n"]}
1
+ {"version":3,"file":"ReusableObjectCache.js","sourceRoot":"","sources":["../../../src/geometry3d/ReusableObjectCache.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD;;;;GAIG;AACH,MAAM,OAAgB,mBAAmB;IAC/B,cAAc,CAAM;IACpB,QAAQ,CAAS;IACjB,UAAU,CAAS;IACnB,SAAS,CAAS;IAC1B;;OAEG;IACH;QACE,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC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AAC;QAClC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","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/** @packageDocumentation\n * @module ArraysAndInterfaces\n */\n\nimport { GrowableXYZArray } from \"./GrowableXYZArray\";\nimport { IndexedXYZCollection } from \"./IndexedXYZCollection\";\n\n/**\n * Abstract class managing an array of objects of type T, available for reuse by trusted callers.\n * * Derived class must implement `createForCache` and `clearForCache`.\n * @public\n */\nexport abstract class ReusableObjectCache<T> {\n private _cachedObjects: T[];\n private _numDrop: number;\n private _numCreate: number;\n private _numReuse: number;\n /**\n * Create a new cache for objects of type T.\n */\n protected constructor() {\n this._cachedObjects = [];\n this._numDrop = 0;\n this._numCreate = 0;\n this._numReuse = 0;\n }\n /** Create a new, ready-to-use object. */\n protected abstract createForCache(): T;\n /** Tidy up `data` so it can be reused. */\n protected abstract clearForCache(data: T): void;\n /**\n * Present `data` for storage in the cache, and hence reuse by any subsequent [[grabFromCache]].\n * * `data` will be sent to [[clearForCache]].\n * * The caller should never refer to `data` again.\n * @param data object to return to the cache.\n */\n public dropToCache(data: T | undefined) {\n if (data) {\n this._numDrop++;\n this.clearForCache(data);\n this._cachedObjects.push(data);\n }\n }\n /**\n * Grab an object from the cache.\n * * The returned object becomes property of the caller: the cache does not remember it for any further management.\n */\n public grabFromCache(): T {\n let data = this._cachedObjects.pop();\n if (data === undefined) {\n data = this.createForCache();\n this._numCreate++;\n } else {\n this._numReuse++;\n }\n return data;\n }\n /**\n * Drop multiple objects to the cache.\n * @param data on input, the data to drop. On output, data is an empty array.\n */\n public dropAllToCache(data: T[]) {\n while (data.length > 0) {\n this.dropToCache(data.pop());\n }\n }\n}\n/**\n * Cache of [[GrowableXYZArray]].\n * * Example usage includes clipping methods that can be structured to have disciplined reuse of a small number of arrays for a large number of steps.\n * @public\n */\nexport class GrowableXYZArrayCache extends ReusableObjectCache<GrowableXYZArray> {\n /**\n * Create a new cache for [[GrowableXYZArray]] objects.\n */\n public constructor() {\n super();\n }\n /**\n * Create a new, ready-to-use [[GrowableXYZArray]].\n * @param numPoints initial capacity in xyz triples (default 10)\n * @param growthFactor reallocation expansion (default 1.5)\n */\n protected createForCache(numPoints: number = 10, growthFactor: number = 1.5): GrowableXYZArray {\n return new GrowableXYZArray(numPoints, growthFactor);\n }\n /** Tidy up `data` so it can be reused. */\n protected clearForCache(data: GrowableXYZArray): void {\n data.length = 0;\n }\n /**\n * Grab an array from the cache and immediately fill from a source.\n * @param source xyz to copy into the returned array.\n */\n public grabAndFill(source: IndexedXYZCollection): GrowableXYZArray {\n const dest = this.grabFromCache();\n dest.pushFrom(source);\n return dest;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-geometry",
3
- "version": "5.1.0-dev.65",
3
+ "version": "5.1.0-dev.69",
4
4
  "description": "iTwin.js Core Geometry library",
5
5
  "main": "lib/cjs/core-geometry.js",
6
6
  "module": "lib/esm/core-geometry.js",
@@ -31,11 +31,11 @@
31
31
  "rimraf": "^6.0.1",
32
32
  "typescript": "~5.6.2",
33
33
  "vitest": "^3.0.6",
34
- "@itwin/build-tools": "5.1.0-dev.65"
34
+ "@itwin/build-tools": "5.1.0-dev.69"
35
35
  },
36
36
  "dependencies": {
37
37
  "flatbuffers": "~1.12.0",
38
- "@itwin/core-bentley": "5.1.0-dev.65"
38
+ "@itwin/core-bentley": "5.1.0-dev.69"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "npm run -s build:cjs && npm run -s build:esm",