@itwin/core-common 3.0.0-dev.152 → 3.0.0-dev.156
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/lib/cjs/tile/ElementGraphics.d.ts +5 -1
- package/lib/cjs/tile/ElementGraphics.d.ts.map +1 -1
- package/lib/cjs/tile/ElementGraphics.js.map +1 -1
- package/lib/cjs/tile/TileMetadata.d.ts +14 -2
- package/lib/cjs/tile/TileMetadata.d.ts.map +1 -1
- package/lib/cjs/tile/TileMetadata.js +33 -17
- package/lib/cjs/tile/TileMetadata.js.map +1 -1
- package/lib/esm/tile/ElementGraphics.d.ts +5 -1
- package/lib/esm/tile/ElementGraphics.d.ts.map +1 -1
- package/lib/esm/tile/ElementGraphics.js.map +1 -1
- package/lib/esm/tile/TileMetadata.d.ts +14 -2
- package/lib/esm/tile/TileMetadata.d.ts.map +1 -1
- package/lib/esm/tile/TileMetadata.js +33 -17
- package/lib/esm/tile/TileMetadata.js.map +1 -1
- package/package.json +7 -7
|
@@ -6,7 +6,7 @@ import { TransformProps } from "@itwin/core-geometry";
|
|
|
6
6
|
import { Placement2dProps, Placement3dProps } from "../ElementProps";
|
|
7
7
|
import { ElementGeometryDataEntry } from "../geometry/ElementGeometry";
|
|
8
8
|
import { GeometryStreamProps } from "../geometry/GeometryStream";
|
|
9
|
-
import { ContentFlags, TreeFlags } from "../tile/TileMetadata";
|
|
9
|
+
import { ContentFlags, EdgeType, TreeFlags } from "../tile/TileMetadata";
|
|
10
10
|
/** Wire format describing properties common to [[PersistentGraphicsRequestProps]] and [[DynamicGraphicsRequestProps]].
|
|
11
11
|
* @see [[ElementGraphicsRequestProps]] for more details.
|
|
12
12
|
* @public
|
|
@@ -29,6 +29,10 @@ export interface GraphicsRequestProps {
|
|
|
29
29
|
readonly location?: TransformProps;
|
|
30
30
|
/** If true, surface edges will be omitted from the graphics. */
|
|
31
31
|
readonly omitEdges?: boolean;
|
|
32
|
+
/** If omitEdges is false, specifies the type of edges to produce. Generally determined by TileAdmin.requestElementGraphics.
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
readonly edgeType?: EdgeType;
|
|
32
36
|
/** If true, the element's graphics will be clipped against the iModel's project extents. */
|
|
33
37
|
readonly clipToProjectExtents?: boolean;
|
|
34
38
|
/** If defined, the compact string representation of a [ClipVector]($core-geometry) to be applied to the geometry to produce section-cut
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementGraphics.d.ts","sourceRoot":"","sources":["../../../src/tile/ElementGraphics.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ElementGraphics.d.ts","sourceRoot":"","sources":["../../../src/tile/ElementGraphics.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEzE;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,yGAAyG;IACz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,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,6BAA8B,SAAQ,2BAA2B;IAChF,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;CACpD;AAED;;;GAGG;AACH,MAAM,WAAW,6BAA8B,SAAQ,2BAA2B;IAChF,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;CACpD;AAED;;;;;GAKG;AACH,oBAAY,2BAA2B,GAAG,8BAA8B,GAAG,6BAA6B,GAAG,6BAA6B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementGraphics.js","sourceRoot":"","sources":["../../../src/tile/ElementGraphics.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG","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/** @packageDocumentation\r\n * @module Tile\r\n */\r\n\r\nimport { Id64String } from \"@itwin/core-bentley\";\r\nimport { TransformProps } from \"@itwin/core-geometry\";\r\nimport { Placement2dProps, Placement3dProps } from \"../ElementProps\";\r\nimport { ElementGeometryDataEntry } from \"../geometry/ElementGeometry\";\r\nimport { GeometryStreamProps } from \"../geometry/GeometryStream\";\r\nimport { ContentFlags, TreeFlags } from \"../tile/TileMetadata\";\r\n\r\n/** Wire format describing properties common to [[PersistentGraphicsRequestProps]] and [[DynamicGraphicsRequestProps]].\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface GraphicsRequestProps {\r\n /** Uniquely identifies this request among all [[ElementGraphicsRequestProps]] for a given [[IModel]]. */\r\n readonly id: string;\r\n /** Log10 of the chord tolerance with which to stroke the element's geometry. e.g., for a chord tolerance of 0.01 (10^-2) meters, supply -2. */\r\n readonly toleranceLog10: number;\r\n /** The major version of the \"iMdl\" format to use when producing the iMdl representation of the element's geometry.\r\n * If omitted, the most recent version known to the backend will be used.\r\n * @alpha\r\n */\r\n readonly formatVersion?: number;\r\n /** Optional flags. [[TreeFlags.UseProjectExtents]] has no effect. [[TreeFlags.EnforceDisplayPriority]] is not yet implemented. @alpha */\r\n readonly treeFlags?: TreeFlags;\r\n /** Optional flags. [[ContentFlags.ImprovedElision]] has no effect. @alpha */\r\n readonly contentFlags?: ContentFlags;\r\n /** Transform from element graphics to world coordinates. Defaults to identity. */\r\n readonly location?: TransformProps;\r\n /** If true, surface edges will be omitted from the graphics. */\r\n readonly omitEdges?: boolean;\r\n /** If true, the element's graphics will be clipped against the iModel's project extents. */\r\n readonly clipToProjectExtents?: boolean;\r\n /** If defined, the compact string representation of a [ClipVector]($core-geometry) to be applied to the geometry to produce section-cut\r\n * geometry at the intersections with the clip planes. Any geometry *not* intersecting the clip planes is omitted from the tiles.\r\n * @see [ClipVector.toCompactString]($core-geometry) to produce the string representation.\r\n */\r\n readonly sectionCut?: string;\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a single element.\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface PersistentGraphicsRequestProps extends GraphicsRequestProps {\r\n /** The element whose geometry is to be used to generate the graphics. */\r\n readonly elementId: Id64String;\r\n}\r\n\r\n/** As part of a [[DynamicGraphicsRequestProps]], specifies the geometry from which to generate the graphics in JSON format.\r\n * @public\r\n */\r\nexport interface JsonGeometryStream {\r\n /** Discriminator for [[DynamicGraphicsRequestProps.geometry]]. */\r\n format: \"json\";\r\n /** The geometry stream in JSON format. */\r\n data: GeometryStreamProps;\r\n}\r\n\r\n/** As part of a [[DynamicGraphicsRequestProps]], specifies the geometry from which to generate the graphics in binary flatbuffer-encoded format.\r\n * @public\r\n */\r\nexport interface FlatBufferGeometryStream {\r\n /** Discriminator for [[DynamicGraphicsRequestProps.geometry]]. */\r\n format: \"flatbuffer\";\r\n /** The geometry stream in flatbuffer format. */\r\n data: ElementGeometryDataEntry[];\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a single geometry stream.\r\n * @see [[DynamicGraphicsRequest2dProps]] and [[DynamicGraphicsRequest3dProps]].\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface DynamicGraphicsRequestProps extends GraphicsRequestProps {\r\n /** The geometry from which to generate the graphics. */\r\n readonly geometry: JsonGeometryStream | FlatBufferGeometryStream;\r\n /** The category to which the geometry belongs. This is required to identify a persistent [SpatialCategory]($backend) for 3d geometry or\r\n * [DrawingCategory]($backend) for 2d geometry.\r\n */\r\n readonly categoryId: Id64String;\r\n /** If specified, tools will recognize the generated graphics as being associated with this element. */\r\n readonly elementId?: Id64String;\r\n /** If specified, tools will recognize the generated graphics as being associated with this model.\r\n * It should identify a 3d model for 3d geometry or a 2d model for 2d geometry.\r\n * It needn't identify a persistent model - it can be a transient Id.\r\n */\r\n readonly modelId?: Id64String;\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a 2d geometry stream.\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface DynamicGraphicsRequest2dProps extends DynamicGraphicsRequestProps {\r\n /** Specifies the geometry is 2d. */\r\n readonly type: \"2d\";\r\n /** The origin and rotation of the geometry. */\r\n readonly placement: Omit<Placement2dProps, \"bbox\">;\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a 3d geometry stream.\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface DynamicGraphicsRequest3dProps extends DynamicGraphicsRequestProps {\r\n /** Specifies the geometry is 3d. */\r\n readonly type: \"3d\";\r\n /** The origin and rotation of the geometry. */\r\n readonly placement: Omit<Placement3dProps, \"bbox\">;\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a single element or geometry stream.\r\n * @note Every request must have an `id` that is unique amongst all extant requests for a given [[IModel]].\r\n * @see [TileAdmin.requestElementGraphics]($frontend) and [IModelDb.generateElementGraphics]($backend) to fulfill such a request.\r\n * @see [readElementGraphics]($frontend) to convert the result of a request to a [RenderGraphic]($frontend) for display.\r\n * @public\r\n */\r\nexport type ElementGraphicsRequestProps = PersistentGraphicsRequestProps | DynamicGraphicsRequest2dProps | DynamicGraphicsRequest3dProps;\r\n"]}
|
|
1
|
+
{"version":3,"file":"ElementGraphics.js","sourceRoot":"","sources":["../../../src/tile/ElementGraphics.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG","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/** @packageDocumentation\r\n * @module Tile\r\n */\r\n\r\nimport { Id64String } from \"@itwin/core-bentley\";\r\nimport { TransformProps } from \"@itwin/core-geometry\";\r\nimport { Placement2dProps, Placement3dProps } from \"../ElementProps\";\r\nimport { ElementGeometryDataEntry } from \"../geometry/ElementGeometry\";\r\nimport { GeometryStreamProps } from \"../geometry/GeometryStream\";\r\nimport { ContentFlags, EdgeType, TreeFlags } from \"../tile/TileMetadata\";\r\n\r\n/** Wire format describing properties common to [[PersistentGraphicsRequestProps]] and [[DynamicGraphicsRequestProps]].\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface GraphicsRequestProps {\r\n /** Uniquely identifies this request among all [[ElementGraphicsRequestProps]] for a given [[IModel]]. */\r\n readonly id: string;\r\n /** Log10 of the chord tolerance with which to stroke the element's geometry. e.g., for a chord tolerance of 0.01 (10^-2) meters, supply -2. */\r\n readonly toleranceLog10: number;\r\n /** The major version of the \"iMdl\" format to use when producing the iMdl representation of the element's geometry.\r\n * If omitted, the most recent version known to the backend will be used.\r\n * @alpha\r\n */\r\n readonly formatVersion?: number;\r\n /** Optional flags. [[TreeFlags.UseProjectExtents]] has no effect. [[TreeFlags.EnforceDisplayPriority]] is not yet implemented. @alpha */\r\n readonly treeFlags?: TreeFlags;\r\n /** Optional flags. [[ContentFlags.ImprovedElision]] has no effect. @alpha */\r\n readonly contentFlags?: ContentFlags;\r\n /** Transform from element graphics to world coordinates. Defaults to identity. */\r\n readonly location?: TransformProps;\r\n /** If true, surface edges will be omitted from the graphics. */\r\n readonly omitEdges?: boolean;\r\n /** If omitEdges is false, specifies the type of edges to produce. Generally determined by TileAdmin.requestElementGraphics.\r\n * @internal\r\n */\r\n readonly edgeType?: EdgeType;\r\n /** If true, the element's graphics will be clipped against the iModel's project extents. */\r\n readonly clipToProjectExtents?: boolean;\r\n /** If defined, the compact string representation of a [ClipVector]($core-geometry) to be applied to the geometry to produce section-cut\r\n * geometry at the intersections with the clip planes. Any geometry *not* intersecting the clip planes is omitted from the tiles.\r\n * @see [ClipVector.toCompactString]($core-geometry) to produce the string representation.\r\n */\r\n readonly sectionCut?: string;\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a single element.\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface PersistentGraphicsRequestProps extends GraphicsRequestProps {\r\n /** The element whose geometry is to be used to generate the graphics. */\r\n readonly elementId: Id64String;\r\n}\r\n\r\n/** As part of a [[DynamicGraphicsRequestProps]], specifies the geometry from which to generate the graphics in JSON format.\r\n * @public\r\n */\r\nexport interface JsonGeometryStream {\r\n /** Discriminator for [[DynamicGraphicsRequestProps.geometry]]. */\r\n format: \"json\";\r\n /** The geometry stream in JSON format. */\r\n data: GeometryStreamProps;\r\n}\r\n\r\n/** As part of a [[DynamicGraphicsRequestProps]], specifies the geometry from which to generate the graphics in binary flatbuffer-encoded format.\r\n * @public\r\n */\r\nexport interface FlatBufferGeometryStream {\r\n /** Discriminator for [[DynamicGraphicsRequestProps.geometry]]. */\r\n format: \"flatbuffer\";\r\n /** The geometry stream in flatbuffer format. */\r\n data: ElementGeometryDataEntry[];\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a single geometry stream.\r\n * @see [[DynamicGraphicsRequest2dProps]] and [[DynamicGraphicsRequest3dProps]].\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface DynamicGraphicsRequestProps extends GraphicsRequestProps {\r\n /** The geometry from which to generate the graphics. */\r\n readonly geometry: JsonGeometryStream | FlatBufferGeometryStream;\r\n /** The category to which the geometry belongs. This is required to identify a persistent [SpatialCategory]($backend) for 3d geometry or\r\n * [DrawingCategory]($backend) for 2d geometry.\r\n */\r\n readonly categoryId: Id64String;\r\n /** If specified, tools will recognize the generated graphics as being associated with this element. */\r\n readonly elementId?: Id64String;\r\n /** If specified, tools will recognize the generated graphics as being associated with this model.\r\n * It should identify a 3d model for 3d geometry or a 2d model for 2d geometry.\r\n * It needn't identify a persistent model - it can be a transient Id.\r\n */\r\n readonly modelId?: Id64String;\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a 2d geometry stream.\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface DynamicGraphicsRequest2dProps extends DynamicGraphicsRequestProps {\r\n /** Specifies the geometry is 2d. */\r\n readonly type: \"2d\";\r\n /** The origin and rotation of the geometry. */\r\n readonly placement: Omit<Placement2dProps, \"bbox\">;\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a 3d geometry stream.\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface DynamicGraphicsRequest3dProps extends DynamicGraphicsRequestProps {\r\n /** Specifies the geometry is 3d. */\r\n readonly type: \"3d\";\r\n /** The origin and rotation of the geometry. */\r\n readonly placement: Omit<Placement3dProps, \"bbox\">;\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a single element or geometry stream.\r\n * @note Every request must have an `id` that is unique amongst all extant requests for a given [[IModel]].\r\n * @see [TileAdmin.requestElementGraphics]($frontend) and [IModelDb.generateElementGraphics]($backend) to fulfill such a request.\r\n * @see [readElementGraphics]($frontend) to convert the result of a request to a [RenderGraphic]($frontend) for display.\r\n * @public\r\n */\r\nexport type ElementGraphicsRequestProps = PersistentGraphicsRequestProps | DynamicGraphicsRequest2dProps | DynamicGraphicsRequest3dProps;\r\n"]}
|
|
@@ -42,6 +42,7 @@ export interface TileOptions {
|
|
|
42
42
|
readonly useLargerTiles: boolean;
|
|
43
43
|
readonly disableMagnification: boolean;
|
|
44
44
|
readonly alwaysSubdivideIncompleteTiles: boolean;
|
|
45
|
+
readonly enableIndexedEdges: boolean;
|
|
45
46
|
}
|
|
46
47
|
/** @internal */
|
|
47
48
|
export declare namespace TileOptions {
|
|
@@ -74,14 +75,25 @@ export declare enum TreeFlags {
|
|
|
74
75
|
OptimizeBRepProcessing = 4,
|
|
75
76
|
UseLargerTiles = 8
|
|
76
77
|
}
|
|
78
|
+
/** Describes the type of edges to include in the graphics for a tile tree.
|
|
79
|
+
* @alpha
|
|
80
|
+
*/
|
|
81
|
+
export declare enum EdgeType {
|
|
82
|
+
/** Omit all edges. */
|
|
83
|
+
None = 0,
|
|
84
|
+
/** Include non-indexed edges, which consume more memory and are less efficient to draw than [[Indexed]] edges, but are compatible with WebGL 1. */
|
|
85
|
+
NonIndexed = 1,
|
|
86
|
+
/** Include indexed edges, which use less memory and draw more efficiently than [[NonIndexed]] edges, but require WebGL 2. */
|
|
87
|
+
Indexed = 2
|
|
88
|
+
}
|
|
77
89
|
/** Describes a tile tree used to draw the contents of a model, possibly with embedded animation.
|
|
78
90
|
* @internal
|
|
79
91
|
*/
|
|
80
92
|
export interface PrimaryTileTreeId {
|
|
81
93
|
/** Describes the type of tile tree. */
|
|
82
94
|
type: BatchType.Primary;
|
|
83
|
-
/**
|
|
84
|
-
|
|
95
|
+
/** The type of edges to include in tile content. */
|
|
96
|
+
edges: EdgeType;
|
|
85
97
|
/** Id of the [DisplayStyle]($backend) or [RenderTimeline]($backend) element holding the [[RenderSchedule]] script to be applied to the tiles. */
|
|
86
98
|
animationId?: Id64String;
|
|
87
99
|
/** If true, meshes within the tiles will be grouped into nodes based on the display priority associated with their subcategories,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileMetadata.d.ts","sourceRoot":"","sources":["../../../src/tile/TileMetadata.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACG,UAAU,
|
|
1
|
+
{"version":3,"file":"TileMetadata.d.ts","sourceRoot":"","sources":["../../../src/tile/TileMetadata.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACG,UAAU,EAA+E,UAAU,EAC5G,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAY,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAWzC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,cAAc,CAAC,EA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AAY;CAWhE"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module Tile
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.TileMetadataReader = exports.computeTileChordTolerance = exports.readTileContentDescription = exports.computeChildTileProps = exports.computeChildTileRanges = exports.bisectTileRange2d = exports.bisectTileRange3d = exports.ContentIdProvider = exports.ContentFlags = exports.compareIModelTileTreeIds = exports.iModelTileTreeIdToString = exports.TreeFlags = exports.getMaximumMajorTileFormatVersion = exports.defaultTileOptions = exports.parseTileTreeIdAndContentId = exports.TileOptions = void 0;
|
|
10
|
+
exports.TileMetadataReader = exports.computeTileChordTolerance = exports.readTileContentDescription = exports.computeChildTileProps = exports.computeChildTileRanges = exports.bisectTileRange2d = exports.bisectTileRange3d = exports.ContentIdProvider = exports.ContentFlags = exports.compareIModelTileTreeIds = exports.iModelTileTreeIdToString = exports.EdgeType = exports.TreeFlags = exports.getMaximumMajorTileFormatVersion = exports.defaultTileOptions = exports.parseTileTreeIdAndContentId = exports.TileOptions = void 0;
|
|
11
11
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
12
|
const core_geometry_1 = require("@itwin/core-geometry");
|
|
13
13
|
const FeatureTable_1 = require("../FeatureTable");
|
|
@@ -42,6 +42,7 @@ var TileOptions;
|
|
|
42
42
|
useLargerTiles: 0 !== (tree.flags & TreeFlags.UseLargerTiles),
|
|
43
43
|
disableMagnification: false,
|
|
44
44
|
alwaysSubdivideIncompleteTiles: false,
|
|
45
|
+
enableIndexedEdges: true,
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
TileOptions.fromTreeIdAndContentId = fromTreeIdAndContentId;
|
|
@@ -49,7 +50,7 @@ var TileOptions;
|
|
|
49
50
|
/** @internal */
|
|
50
51
|
function parseTileTreeIdAndContentId(treeId, contentId) {
|
|
51
52
|
let idx = 0;
|
|
52
|
-
let type, expansion, animationId,
|
|
53
|
+
let type, expansion, animationId, edges, sectionCut;
|
|
53
54
|
// Skip version and flags, they're handled by TileOptions.fromTreeIdAndContentId
|
|
54
55
|
while (idx < treeId.length && treeId[idx] !== "-")
|
|
55
56
|
idx++;
|
|
@@ -67,13 +68,13 @@ function parseTileTreeIdAndContentId(treeId, contentId) {
|
|
|
67
68
|
// eslint-disable-next-line prefer-const
|
|
68
69
|
({ idx, animationId } = parseAnimation(idx, treeId, animationId));
|
|
69
70
|
if (type === FeatureTable_1.BatchType.Primary) {
|
|
70
|
-
({ idx,
|
|
71
|
+
({ idx, edges, sectionCut } = parsePrimary(idx, treeId, edges, sectionCut));
|
|
71
72
|
}
|
|
72
73
|
const modelId = treeId.substr(idx);
|
|
73
74
|
if (!core_bentley_1.Id64.isId64(modelId))
|
|
74
75
|
throw new Error("Invalid tree Id");
|
|
75
76
|
const { flags: treeFlags } = treeFlagsAndFormatVersionFromId(treeId);
|
|
76
|
-
const parsedTreeId = getTreeId(type,
|
|
77
|
+
const parsedTreeId = getTreeId(type, edges, sectionCut, animationId, expansion, (treeFlags & TreeFlags.EnforceDisplayPriority) !== 0 ? true : undefined);
|
|
77
78
|
const options = TileOptions.fromTreeIdAndContentId(treeId, contentId);
|
|
78
79
|
let parsedContentId;
|
|
79
80
|
try {
|
|
@@ -92,11 +93,11 @@ function parseTileTreeIdAndContentId(treeId, contentId) {
|
|
|
92
93
|
};
|
|
93
94
|
}
|
|
94
95
|
exports.parseTileTreeIdAndContentId = parseTileTreeIdAndContentId;
|
|
95
|
-
function getTreeId(type,
|
|
96
|
+
function getTreeId(type, edges, sectionCut, animationId, expansion, enforceDisplayPriority) {
|
|
96
97
|
if (type === FeatureTable_1.BatchType.Primary)
|
|
97
98
|
return {
|
|
98
99
|
type,
|
|
99
|
-
|
|
100
|
+
edges,
|
|
100
101
|
sectionCut,
|
|
101
102
|
animationId,
|
|
102
103
|
enforceDisplayPriority,
|
|
@@ -108,15 +109,17 @@ function getTreeId(type, edgesRequired, sectionCut, animationId, expansion, enfo
|
|
|
108
109
|
animationId,
|
|
109
110
|
};
|
|
110
111
|
}
|
|
111
|
-
function parsePrimary(idx, treeId,
|
|
112
|
+
function parsePrimary(idx, treeId, edges = EdgeType.None, sectionCut) {
|
|
112
113
|
// Edges
|
|
113
|
-
|
|
114
|
-
if (idx < treeId.length
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
edges = EdgeType.NonIndexed;
|
|
115
|
+
if (idx < treeId.length) {
|
|
116
|
+
const noEdgesStr = "E:0_";
|
|
117
|
+
if (treeId.startsWith(noEdgesStr, idx))
|
|
118
|
+
edges = EdgeType.None;
|
|
119
|
+
else if (treeId.startsWith("E:2_", idx))
|
|
120
|
+
edges = EdgeType.Indexed;
|
|
121
|
+
if (EdgeType.NonIndexed !== edges)
|
|
122
|
+
idx += noEdgesStr.length;
|
|
120
123
|
}
|
|
121
124
|
// Section cut
|
|
122
125
|
if (idx + 1 < treeId.length && treeId[idx] === "S") {
|
|
@@ -129,7 +132,7 @@ function parsePrimary(idx, treeId, edgesRequired, sectionCut) {
|
|
|
129
132
|
throw new Error("Invalid tree Id");
|
|
130
133
|
idx++; // s
|
|
131
134
|
}
|
|
132
|
-
return { idx,
|
|
135
|
+
return { idx, edges, sectionCut };
|
|
133
136
|
}
|
|
134
137
|
function parseClassifier(idx, treeId, expansion) {
|
|
135
138
|
let type;
|
|
@@ -184,6 +187,7 @@ exports.defaultTileOptions = Object.freeze({
|
|
|
184
187
|
useLargerTiles: true,
|
|
185
188
|
disableMagnification: false,
|
|
186
189
|
alwaysSubdivideIncompleteTiles: false,
|
|
190
|
+
enableIndexedEdges: true,
|
|
187
191
|
});
|
|
188
192
|
function contentFlagsFromId(id) {
|
|
189
193
|
if (0 === id.length || "-" !== id[0])
|
|
@@ -239,6 +243,18 @@ var TreeFlags;
|
|
|
239
243
|
TreeFlags[TreeFlags["OptimizeBRepProcessing"] = 4] = "OptimizeBRepProcessing";
|
|
240
244
|
TreeFlags[TreeFlags["UseLargerTiles"] = 8] = "UseLargerTiles";
|
|
241
245
|
})(TreeFlags = exports.TreeFlags || (exports.TreeFlags = {}));
|
|
246
|
+
/** Describes the type of edges to include in the graphics for a tile tree.
|
|
247
|
+
* @alpha
|
|
248
|
+
*/
|
|
249
|
+
var EdgeType;
|
|
250
|
+
(function (EdgeType) {
|
|
251
|
+
/** Omit all edges. */
|
|
252
|
+
EdgeType[EdgeType["None"] = 0] = "None";
|
|
253
|
+
/** Include non-indexed edges, which consume more memory and are less efficient to draw than [[Indexed]] edges, but are compatible with WebGL 1. */
|
|
254
|
+
EdgeType[EdgeType["NonIndexed"] = 1] = "NonIndexed";
|
|
255
|
+
/** Include indexed edges, which use less memory and draw more efficiently than [[NonIndexed]] edges, but require WebGL 2. */
|
|
256
|
+
EdgeType[EdgeType["Indexed"] = 2] = "Indexed";
|
|
257
|
+
})(EdgeType = exports.EdgeType || (exports.EdgeType = {}));
|
|
242
258
|
function animationIdToString(animationId) {
|
|
243
259
|
return `A:${animationId}_`;
|
|
244
260
|
}
|
|
@@ -257,7 +273,7 @@ function iModelTileTreeIdToString(modelId, treeId, options) {
|
|
|
257
273
|
idStr = `${idStr}${animationIdToString(treeId.animationId)}`;
|
|
258
274
|
else if (treeId.enforceDisplayPriority) // animation and priority are currently mutually exclusive
|
|
259
275
|
flags |= TreeFlags.EnforceDisplayPriority;
|
|
260
|
-
const edges = treeId.
|
|
276
|
+
const edges = treeId.edges !== EdgeType.NonIndexed ? `E:${treeId.edges}_` : "";
|
|
261
277
|
const sectionCut = treeId.sectionCut ? `S${treeId.sectionCut}s` : "";
|
|
262
278
|
idStr = `${idStr}${edges}${sectionCut}`;
|
|
263
279
|
}
|
|
@@ -289,7 +305,7 @@ function compareIModelTileTreeIds(lhs, rhs) {
|
|
|
289
305
|
// NB: The redundant checks on BatchType below are to satisfy compiler.
|
|
290
306
|
(0, core_bentley_1.assert)(lhs.type === rhs.type);
|
|
291
307
|
if (FeatureTable_1.BatchType.Primary === lhs.type && FeatureTable_1.BatchType.Primary === rhs.type) {
|
|
292
|
-
cmp = (0, core_bentley_1.
|
|
308
|
+
cmp = (0, core_bentley_1.compareNumbers)(lhs.edges, rhs.edges);
|
|
293
309
|
if (0 === cmp) {
|
|
294
310
|
cmp = (0, core_bentley_1.compareBooleansOrUndefined)(lhs.enforceDisplayPriority, rhs.enforceDisplayPriority);
|
|
295
311
|
if (0 === cmp)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileMetadata.js","sourceRoot":"","sources":["../../../src/tile/TileMetadata.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAE6B;AAC7B,wDAAyD;AACzD,kDAA4C;AAE5C,iDAA+F;AAC/F,qCAAyD;AAEzD,mCAAmC;AAEnC,+DAA+D;AAC/D,IAAU,SAAS,CAElB;AAFD,WAAU,SAAS;IACJ,qCAA2B,GAAG,CAAC,CAAC;AAC/C,CAAC,EAFS,SAAS,KAAT,SAAS,QAElB;AA4CD,gBAAgB;AAChB,IAAiB,WAAW,CAwB3B;AAxBD,WAAiB,WAAW;IAC1B;;;;;OAKG;IACH,SAAgB,sBAAsB,CAAC,MAAc,EAAE,SAAiB;QACtE,MAAM,IAAI,GAAG,+BAA+B,CAAC,MAAM,CAAC,CAAC;QACrD,MAAM,YAAY,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;QAEnD,OAAO;YACL,6BAA6B,EAAE,IAAI,CAAC,OAAO;YAC3C,gBAAgB,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC,eAAe,CAAC;YACrE,qBAAqB,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC,eAAe,CAAC;YAC1E,kBAAkB,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC,kBAAkB,CAAC;YAC1E,sBAAsB,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC,gBAAgB,CAAC;YAC5E,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C,mBAAmB,GAAG,wBAAS,CAAC,gBAAgB,KAAK,IAAI,CAAC;QAC/D,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,MAAkB,EAAE,KAAgB;QAC9C,MAAM,OAAO,GAAG,0BAA0B,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC9H,OAAO;YACL,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;YAC5C,KAAK,EAAE,uBAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;YACpC,SAAS,EAAE,KAAK,CAAC,SAAS;SAC3B,CAAC;IACJ,CAAC;CACF;AAzBD,gDAyBC","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/** @packageDocumentation\r\n * @module Tile\r\n */\r\n\r\nimport {\r\n assert, ByteStream, compareBooleans, compareBooleansOrUndefined, compareNumbers, compareStringsOrUndefined, Id64, Id64String,\r\n} from \"@itwin/core-bentley\";\r\nimport { Range3d, Vector3d } from \"@itwin/core-geometry\";\r\nimport { BatchType } from \"../FeatureTable\";\r\nimport { TileProps } from \"../TileProps\";\r\nimport { CurrentImdlVersion, FeatureTableHeader, ImdlFlags, ImdlHeader } from \"./IModelTileIO\";\r\nimport { TileReadError, TileReadStatus } from \"./TileIO\";\r\n\r\n// cspell:ignore imdl mult bitfield\r\n\r\n// NB: These constants correspond to those defined in Tile.cpp.\r\nnamespace Constants {\r\n export const minToleranceRatioMultiplier = 2;\r\n}\r\n\r\n/** Describes an iModel tile tree.\r\n * @internal\r\n */\r\nexport interface TileTreeMetadata {\r\n readonly modelId: Id64String;\r\n readonly is2d: boolean;\r\n readonly contentRange?: Range3d;\r\n readonly tileScreenSize: number;\r\n}\r\n\r\n/** Describes the contents of an iModel tile.\r\n * @internal\r\n */\r\nexport interface TileContentMetadata {\r\n readonly contentRange: Range3d;\r\n readonly isLeaf: boolean;\r\n readonly sizeMultiplier?: number;\r\n readonly emptySubRangeMask: number;\r\n}\r\n\r\n/** Describes an iModel tile.\r\n * @internal\r\n */\r\nexport interface TileMetadata extends TileContentMetadata {\r\n readonly contentId: string;\r\n readonly range: Range3d;\r\n}\r\n\r\n/** @internal */\r\nexport interface TileOptions {\r\n readonly maximumMajorTileFormatVersion: number;\r\n readonly enableInstancing: boolean;\r\n readonly enableImprovedElision: boolean;\r\n readonly ignoreAreaPatterns: boolean;\r\n readonly enableExternalTextures: boolean;\r\n readonly useProjectExtents: boolean;\r\n readonly optimizeBRepProcessing: boolean;\r\n readonly useLargerTiles: boolean;\r\n readonly disableMagnification: boolean;\r\n readonly alwaysSubdivideIncompleteTiles: boolean;\r\n}\r\n\r\n/** @internal */\r\nexport namespace TileOptions {\r\n /** Given the string representation of an [[IModelTileTreeId]] and the contentId of a [Tile]($frontend) belonging to that [TileTree]($frontend),\r\n * compute the [[TileOptions]] that were used to generate the Ids.\r\n * @throws Error if `treeId` or `contentId` are not valid Ids.\r\n * @note `treeId` and `contentId` are assumed to be valid Ids. They are not fully parsed and validated - only the information required by this function is extracted.\r\n * @note `treeId` and `contentId` are assumed to have been produced for version 4 or later of the iMdl tile format.\r\n */\r\n export function fromTreeIdAndContentId(treeId: string, contentId: string): TileOptions {\r\n const tree = treeFlagsAndFormatVersionFromId(treeId);\r\n const contentFlags = contentFlagsFromId(contentId);\r\n\r\n return {\r\n maximumMajorTileFormatVersion: tree.version,\r\n enableInstancing: 0 !== (contentFlags & ContentFlags.AllowInstancing),\r\n enableImprovedElision: 0 !== (contentFlags & ContentFlags.ImprovedElision),\r\n ignoreAreaPatterns: 0 !== (contentFlags & ContentFlags.IgnoreAreaPatterns),\r\n enableExternalTextures: 0 !== (contentFlags & ContentFlags.ExternalTextures),\r\n useProjectExtents: 0 !== (tree.flags & TreeFlags.UseProjectExtents),\r\n optimizeBRepProcessing: 0 !== (tree.flags & TreeFlags.OptimizeBRepProcessing),\r\n useLargerTiles: 0 !== (tree.flags & TreeFlags.UseLargerTiles),\r\n disableMagnification: false,\r\n alwaysSubdivideIncompleteTiles: false,\r\n };\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function parseTileTreeIdAndContentId(treeId: string, contentId: string): { modelId: Id64String, treeId: IModelTileTreeId, contentId: ContentIdSpec, options: TileOptions } {\r\n let idx = 0;\r\n let type: BatchType,\r\n expansion: number | undefined,\r\n animationId: string | undefined,\r\n edgesRequired: boolean | undefined,\r\n sectionCut: string | undefined;\r\n\r\n // Skip version and flags, they're handled by TileOptions.fromTreeIdAndContentId\r\n while (idx < treeId.length && treeId[idx] !== \"-\")\r\n idx++;\r\n idx++; // -\r\n if (idx >= treeId.length)\r\n throw new Error(\"Invalid tree Id\");\r\n\r\n if (treeId[idx] === \"C\") {\r\n // PlanarClassifier or VolumeClassifier\r\n ({ idx, type, expansion } = parseClassifier(idx, treeId, expansion));\r\n } else {\r\n type = BatchType.Primary;\r\n }\r\n\r\n // Animation\r\n // eslint-disable-next-line prefer-const\r\n ({ idx, animationId } = parseAnimation(idx, treeId, animationId));\r\n\r\n if (type === BatchType.Primary) {\r\n ({ idx, edgesRequired, sectionCut } = parsePrimary(idx, treeId, edgesRequired, sectionCut));\r\n }\r\n\r\n const modelId = treeId.substr(idx);\r\n if (!Id64.isId64(modelId))\r\n throw new Error(\"Invalid tree Id\");\r\n\r\n const { flags: treeFlags } = treeFlagsAndFormatVersionFromId(treeId);\r\n const parsedTreeId = getTreeId(type, edgesRequired, sectionCut, animationId, expansion, (treeFlags & TreeFlags.EnforceDisplayPriority) !== 0 ? true : undefined);\r\n const options = TileOptions.fromTreeIdAndContentId(treeId, contentId);\r\n\r\n let parsedContentId: ContentIdSpec;\r\n try {\r\n parsedContentId = ContentIdProvider.create(true, options).specFromId(contentId);\r\n } catch (e) {\r\n throw new Error(\"Invalid content Id\");\r\n }\r\n\r\n if (Object.keys(parsedContentId).some((key) => parsedContentId.hasOwnProperty(key) && typeof parsedContentId[key as keyof ContentIdSpec] === \"number\" && !Number.isFinite(parsedContentId[key as keyof ContentIdSpec])))\r\n throw new Error(\"Invalid content Id\");\r\n\r\n return {\r\n contentId: parsedContentId,\r\n modelId,\r\n options,\r\n treeId: parsedTreeId,\r\n };\r\n}\r\n\r\nfunction getTreeId(type: BatchType, edgesRequired?: boolean, sectionCut?: string, animationId?: string, expansion?: number, enforceDisplayPriority?: boolean): IModelTileTreeId {\r\n if (type === BatchType.Primary)\r\n return {\r\n type,\r\n edgesRequired,\r\n sectionCut,\r\n animationId,\r\n enforceDisplayPriority,\r\n } as PrimaryTileTreeId;\r\n else\r\n return {\r\n type,\r\n expansion,\r\n animationId,\r\n } as ClassifierTileTreeId;\r\n}\r\n\r\nfunction parsePrimary(idx: number, treeId: string, edgesRequired: boolean | undefined, sectionCut: string | undefined) {\r\n // Edges\r\n const edgesStr = \"E:0_\";\r\n if (idx < treeId.length && treeId.startsWith(edgesStr, idx)) {\r\n edgesRequired = false;\r\n idx += edgesStr.length;\r\n } else {\r\n edgesRequired = true;\r\n }\r\n\r\n // Section cut\r\n if (idx + 1 < treeId.length && treeId[idx] === \"S\") {\r\n idx++; // S\r\n sectionCut = \"\";\r\n while (idx < treeId.length && treeId[idx] !== \"s\") {\r\n sectionCut += treeId[idx++];\r\n }\r\n if (idx === treeId.length)\r\n throw new Error(\"Invalid tree Id\");\r\n idx++; // s\r\n }\r\n return { idx, edgesRequired, sectionCut };\r\n}\r\n\r\nfunction parseClassifier(idx: number, treeId: string, expansion: number | undefined) {\r\n let type: BatchType;\r\n idx++; // C\r\n if (idx + 1 < treeId.length && treeId[idx] === \"P\" && treeId[idx + 1] === \":\") {\r\n type = BatchType.PlanarClassifier;\r\n idx += 2; // P:\r\n } else if (idx < treeId.length && treeId[idx] === \":\") {\r\n type = BatchType.VolumeClassifier;\r\n idx++; // :\r\n } else {\r\n throw new Error(\"Invalid tree Id\");\r\n }\r\n\r\n // C: or CP: is always followed by {expansion}_\r\n let expansionStr = \"\";\r\n while (idx < treeId.length && (treeId[idx] >= \"0\" && treeId[idx] <= \"9\" || treeId[idx] === \".\")) {\r\n expansionStr += treeId[idx++];\r\n }\r\n\r\n if (idx === treeId.length || treeId[idx] !== \"_\")\r\n throw new Error(\"Invalid tree Id\");\r\n idx++; // _\r\n\r\n expansion = Number.parseFloat(expansionStr);\r\n return { idx, type, expansion };\r\n}\r\n\r\nfunction parseAnimation(idx: number, treeId: string, animationId: string | undefined) {\r\n if (idx < treeId.length && treeId[idx] === \"A\") {\r\n if (idx + 1 < treeId.length && treeId[idx + 1] !== \":\")\r\n throw new Error(\"Invalid tree Id\");\r\n idx += 2;\r\n\r\n // Parse animation id\r\n animationId = \"\";\r\n while (idx < treeId.length && treeId[idx] !== \"_\") {\r\n animationId += treeId[idx++];\r\n }\r\n\r\n if (!Id64.isId64(animationId) || idx === treeId.length)\r\n throw new Error(\"Invalid tree Id\");\r\n idx++; // _\r\n }\r\n\r\n return { idx, animationId };\r\n}\r\n\r\n/** @internal */\r\nexport const defaultTileOptions: TileOptions = Object.freeze({\r\n maximumMajorTileFormatVersion: CurrentImdlVersion.Major,\r\n enableInstancing: true,\r\n enableImprovedElision: true,\r\n ignoreAreaPatterns: false,\r\n enableExternalTextures: true,\r\n useProjectExtents: true,\r\n optimizeBRepProcessing: true,\r\n useLargerTiles: true,\r\n disableMagnification: false,\r\n alwaysSubdivideIncompleteTiles: false,\r\n});\r\n\r\nfunction contentFlagsFromId(id: string): ContentFlags {\r\n if (0 === id.length || \"-\" !== id[0])\r\n throw new Error(\"Invalid content Id\");\r\n\r\n // V4: -flags-d-i-j-k-m - version in tree Id\r\n const end = id.indexOf(\"-\", 1);\r\n if (-1 !== end) {\r\n const flags = Number.parseInt(id.substring(1, end), 16);\r\n if (!Number.isNaN(flags))\r\n return flags;\r\n }\r\n\r\n throw new Error(\"Invalid content Id\");\r\n}\r\n\r\nfunction treeFlagsAndFormatVersionFromId(id: string): { flags: TreeFlags, version: number } {\r\n if (0 === id.length)\r\n throw new Error(\"Invalid tree Id\");\r\n\r\n let parts = id.split(\"-\");\r\n if (parts.length > 0) {\r\n parts = parts[0].split(\"_\");\r\n if (parts.length === 2) {\r\n const version = Number.parseInt(parts[0], 16);\r\n const flags = Number.parseInt(parts[1], 16);\r\n if (!Number.isNaN(version) || !Number.isNaN(flags))\r\n return { version, flags };\r\n }\r\n }\r\n\r\n throw new Error(\"Invalid tree Id\");\r\n}\r\n\r\n/** @internal */\r\nexport function getMaximumMajorTileFormatVersion(maxMajorVersion: number, formatVersion?: number): number {\r\n // The `formatVersion` input is from the backend, telling us precisely the maximum major+minor version it can produce.\r\n // Ensure we do not request tiles of a newer major version than backend can supply or it can read; and also limit major version\r\n // to that optionally configured by the app.\r\n let majorVersion = maxMajorVersion;\r\n if (undefined !== formatVersion)\r\n majorVersion = Math.min((formatVersion >>> 0x10), majorVersion);\r\n\r\n // Version number less than 1 is invalid - ignore\r\n majorVersion = Math.max(majorVersion, 1);\r\n\r\n // Version number greater than current known version ignored\r\n majorVersion = Math.min(majorVersion, CurrentImdlVersion.Major);\r\n\r\n // Version numbers are integers - round down\r\n return Math.max(Math.floor(majorVersion), 1);\r\n}\r\n\r\n/** Flags controlling the structure of a tile tree. The flags are part of the tile tree's Id.\r\n * @alpha\r\n */\r\nexport enum TreeFlags {\r\n None = 0,\r\n UseProjectExtents = 1 << 0, // Use project extents as the basis of the tile tree's range.\r\n EnforceDisplayPriority = 1 << 1, // For 3d plan projection models, group graphics into layers based on subcategory.\r\n OptimizeBRepProcessing = 1 << 2, // Use an optimized pipeline for producing facets from BRep entities.\r\n UseLargerTiles = 1 << 3, // Produce tiles of larger size in screen pixels.\r\n}\r\n\r\n/** Describes a tile tree used to draw the contents of a model, possibly with embedded animation.\r\n * @internal\r\n */\r\nexport interface PrimaryTileTreeId {\r\n /** Describes the type of tile tree. */\r\n type: BatchType.Primary;\r\n /** Whether to include edges in tile content. */\r\n edgesRequired: boolean;\r\n /** Id of the [DisplayStyle]($backend) or [RenderTimeline]($backend) element holding the [[RenderSchedule]] script to be applied to the tiles. */\r\n animationId?: Id64String;\r\n /** If true, meshes within the tiles will be grouped into nodes based on the display priority associated with their subcategories,\r\n * for ensuring the graphics display with correct priority.\r\n */\r\n enforceDisplayPriority?: boolean;\r\n /** If defined, the compact string representation of a clip vector applied to the tiles to produce cut geometry at the intersections with the clip planes.\r\n * Any geometry *not* intersecting the clip planes is omitted from the tiles.\r\n * @see [ClipVector.toCompactString[($core-geometry).\r\n */\r\n sectionCut?: string;\r\n}\r\n\r\n/** Describes a tile tree that can classify the contents of other tile trees using the model's geometry.\r\n * @internal\r\n */\r\nexport interface ClassifierTileTreeId {\r\n type: BatchType.VolumeClassifier | BatchType.PlanarClassifier;\r\n expansion: number;\r\n animationId?: Id64String;\r\n}\r\n\r\nfunction animationIdToString(animationId: Id64String): string {\r\n return `A:${animationId}_`;\r\n}\r\n\r\n/** Describes the Id of an iModel tile tree.\r\n * @internal\r\n */\r\nexport type IModelTileTreeId = PrimaryTileTreeId | ClassifierTileTreeId;\r\n\r\n/** Convert a tile tree Id to its string representation.\r\n * @internal\r\n */\r\nexport function iModelTileTreeIdToString(modelId: Id64String, treeId: IModelTileTreeId, options: TileOptions): string {\r\n let idStr = \"\";\r\n let flags = options.useProjectExtents ? TreeFlags.UseProjectExtents : TreeFlags.None;\r\n if (options.optimizeBRepProcessing)\r\n flags |= TreeFlags.OptimizeBRepProcessing;\r\n\r\n if (options.useLargerTiles)\r\n flags |= TreeFlags.UseLargerTiles;\r\n\r\n if (BatchType.Primary === treeId.type) {\r\n if (undefined !== treeId.animationId)\r\n idStr = `${idStr}${animationIdToString(treeId.animationId)}`;\r\n else if (treeId.enforceDisplayPriority) // animation and priority are currently mutually exclusive\r\n flags |= TreeFlags.EnforceDisplayPriority;\r\n\r\n const edges = treeId.edgesRequired ? \"\" : \"E:0_\";\r\n const sectionCut = treeId.sectionCut ? `S${treeId.sectionCut}s` : \"\";\r\n idStr = `${idStr}${edges}${sectionCut}`;\r\n } else {\r\n const typeStr = BatchType.PlanarClassifier === treeId.type ? \"CP\" : \"C\";\r\n idStr = `${idStr + typeStr}:${treeId.expansion.toFixed(6)}_`;\r\n\r\n if (BatchType.VolumeClassifier === treeId.type)\r\n flags |= TreeFlags.UseProjectExtents;\r\n\r\n if (undefined !== treeId.animationId)\r\n idStr = `${idStr}${animationIdToString(treeId.animationId)}`;\r\n }\r\n\r\n const version = getMaximumMajorTileFormatVersion(options.maximumMajorTileFormatVersion);\r\n if (version >= 4) {\r\n const prefix = `${version.toString(16)}_${flags.toString(16)}-`;\r\n idStr = prefix + idStr;\r\n }\r\n\r\n return idStr + modelId;\r\n}\r\n\r\n/** Ordinal comparison of two tile tree Ids, e.g., for use in sorted containers.\r\n * @internal\r\n */\r\nexport function compareIModelTileTreeIds(lhs: IModelTileTreeId, rhs: IModelTileTreeId): number {\r\n let cmp = compareNumbers(lhs.type, rhs.type);\r\n if (0 === cmp)\r\n cmp = compareStringsOrUndefined(lhs.animationId, rhs.animationId);\r\n\r\n if (0 !== cmp)\r\n return cmp;\r\n\r\n // NB: The redundant checks on BatchType below are to satisfy compiler.\r\n assert(lhs.type === rhs.type);\r\n if (BatchType.Primary === lhs.type && BatchType.Primary === rhs.type) {\r\n cmp = compareBooleans(lhs.edgesRequired, rhs.edgesRequired);\r\n if (0 === cmp) {\r\n cmp = compareBooleansOrUndefined(lhs.enforceDisplayPriority, rhs.enforceDisplayPriority);\r\n if (0 === cmp)\r\n cmp = compareStringsOrUndefined(lhs.sectionCut, rhs.sectionCut);\r\n }\r\n } else if (BatchType.Primary !== lhs.type && BatchType.Primary !== rhs.type) {\r\n cmp = compareNumbers(lhs.expansion, rhs.expansion);\r\n }\r\n\r\n return cmp;\r\n}\r\n\r\n/** Flags controlling how tile content is produced. The flags are part of the ContentId.\r\n * @alpha\r\n */\r\nexport enum ContentFlags {\r\n None = 0,\r\n AllowInstancing = 1 << 0,\r\n ImprovedElision = 1 << 1,\r\n IgnoreAreaPatterns = 1 << 2,\r\n ExternalTextures = 1 << 3,\r\n}\r\n\r\n/** Describes the components of a tile's content Id.\r\n *\r\n * The depth specifies how many subdivisions from the root tile are to be performed to reach the sub-volume of interest.\r\n *\r\n * The i, j, and k parameters specify how to subdivide the tile's volume. Each sub-division is performed along the longest axis of the\r\n * volume. The volume is first sub-divided based on `i`, then the result sub-divided based on `j`, and finally that result sub-divided\r\n * based on `k`.\r\n *\r\n * The multiplier is an integer - generally a power of two - multiplied by the screen size of a tile (512 pixels) used to\r\n * produce a higher-resolution tile for the same volume.\r\n * @internal\r\n */\r\ninterface ContentIdSpec {\r\n depth: number;\r\n i: number;\r\n j: number;\r\n k: number;\r\n multiplier: number;\r\n}\r\n\r\n/** Contains logic for working with tile content Ids according to a specific content Id scheme. Which scheme is used depends on\r\n * the major version of the tile format.\r\n * @internal\r\n */\r\nexport abstract class ContentIdProvider {\r\n public readonly majorFormatVersion: number;\r\n public readonly contentFlags: ContentFlags;\r\n\r\n protected constructor(formatVersion: number, contentFlags: ContentFlags) {\r\n this.majorFormatVersion = formatVersion;\r\n this.contentFlags = contentFlags;\r\n }\r\n\r\n public get rootContentId(): string {\r\n return this.computeId(0, 0, 0, 0, 1);\r\n }\r\n\r\n public idFromParentAndMultiplier(parentId: string, multiplier: number): string {\r\n const lastSepPos = parentId.lastIndexOf(this._separator);\r\n assert(-1 !== lastSepPos);\r\n return parentId.substring(0, lastSepPos + 1) + multiplier.toString(16);\r\n }\r\n\r\n public specFromId(id: string): ContentIdSpec {\r\n const parts = id.split(this._separator);\r\n const len = parts.length;\r\n assert(len >= 5);\r\n return {\r\n depth: parseInt(parts[len - 5], 16),\r\n i: parseInt(parts[len - 4], 16),\r\n j: parseInt(parts[len - 3], 16),\r\n k: parseInt(parts[len - 2], 16),\r\n multiplier: parseInt(parts[len - 1], 16),\r\n };\r\n }\r\n\r\n public idFromSpec(spec: ContentIdSpec): string {\r\n return this.computeId(spec.depth, spec.i, spec.j, spec.k, spec.multiplier);\r\n }\r\n\r\n protected join(depth: number, i: number, j: number, k: number, mult: number): string {\r\n const sep = this._separator;\r\n return depth.toString(16) + sep + i.toString(16) + sep + j.toString(16) + sep + k.toString(16) + sep + mult.toString(16);\r\n }\r\n\r\n protected abstract get _separator(): string;\r\n protected abstract computeId(depth: number, i: number, j: number, k: number, mult: number): string;\r\n\r\n /** formatVersion is the maximum major version supported by the back-end supplying the tile tree.\r\n * Must ensure front-end does not request tiles of a format the back-end cannot supply, and back-end does\r\n * not supply tiles of a format the front-end doesn't recognize.\r\n */\r\n public static create(allowInstancing: boolean, options: TileOptions, formatVersion?: number): ContentIdProvider {\r\n const majorVersion = getMaximumMajorTileFormatVersion(options.maximumMajorTileFormatVersion, formatVersion);\r\n assert(majorVersion > 0);\r\n assert(Math.floor(majorVersion) === majorVersion);\r\n switch (majorVersion) {\r\n case 0:\r\n case 1:\r\n return new ContentIdV1Provider(majorVersion);\r\n case 2:\r\n case 3:\r\n return new ContentIdV2Provider(majorVersion, allowInstancing, options);\r\n default:\r\n return new ContentIdV4Provider(allowInstancing, options, majorVersion);\r\n }\r\n }\r\n}\r\n\r\n/** The original (major version 1) tile format used a content Id scheme of the format\r\n * `depth/i/j/k/multiplier`.\r\n * @internal\r\n */\r\nclass ContentIdV1Provider extends ContentIdProvider {\r\n public constructor(majorVersion: number) {\r\n super(majorVersion, ContentFlags.None);\r\n }\r\n\r\n protected get _separator() { return \"/\"; }\r\n protected computeId(depth: number, i: number, j: number, k: number, mult: number): string {\r\n return this.join(depth, i, j, k, mult);\r\n }\r\n}\r\n\r\n/** Tile formats 2 and 3 use a content Id scheme encoding styling flags and the major format version\r\n * into the content Id, of the format `_majorVersion_flags_depth_i_j_k_multiplier`.\r\n * @internal\r\n */\r\nclass ContentIdV2Provider extends ContentIdProvider {\r\n private readonly _prefix: string;\r\n\r\n public constructor(majorVersion: number, allowInstancing: boolean, options: TileOptions) {\r\n const flags = (allowInstancing && options.enableInstancing) ? ContentFlags.AllowInstancing : ContentFlags.None;\r\n super(majorVersion, flags);\r\n this._prefix = this._separator + majorVersion.toString(16) + this._separator + flags.toString(16) + this._separator;\r\n }\r\n\r\n protected get _separator() { return \"_\"; }\r\n protected computeId(depth: number, i: number, j: number, k: number, mult: number): string {\r\n return this._prefix + this.join(depth, i, j, k, mult);\r\n }\r\n}\r\n\r\n/** Tile formats 4+ encode styling flags but not major format version. (The version is specified by the tile tree's Id).\r\n * Format: `-flags-depth-i-j-k-multiplier`.\r\n * @internal\r\n */\r\nclass ContentIdV4Provider extends ContentIdProvider {\r\n private readonly _prefix: string;\r\n\r\n public constructor(allowInstancing: boolean, options: TileOptions, majorVersion: number) {\r\n let flags = (allowInstancing && options.enableInstancing) ? ContentFlags.AllowInstancing : ContentFlags.None;\r\n if (options.enableImprovedElision)\r\n flags = flags | ContentFlags.ImprovedElision;\r\n\r\n if (options.ignoreAreaPatterns)\r\n flags = flags | ContentFlags.IgnoreAreaPatterns;\r\n\r\n if (options.enableExternalTextures)\r\n flags = flags | ContentFlags.ExternalTextures;\r\n\r\n super(majorVersion, flags);\r\n this._prefix = this._separator + flags.toString(16) + this._separator;\r\n }\r\n\r\n protected get _separator() { return \"-\"; }\r\n protected computeId(depth: number, i: number, j: number, k: number, mult: number): string {\r\n return this._prefix + this.join(depth, i, j, k, mult);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function bisectTileRange3d(range: Range3d, takeUpper: boolean): void {\r\n const diag = range.diagonal();\r\n const pt = takeUpper ? range.high : range.low;\r\n if (diag.x > diag.y && diag.x > diag.z)\r\n pt.x = (range.low.x + range.high.x) / 2.0;\r\n else if (diag.y > diag.z)\r\n pt.y = (range.low.y + range.high.y) / 2.0;\r\n else\r\n pt.z = (range.low.z + range.high.z) / 2.0;\r\n}\r\n\r\n/** @internal */\r\nexport function bisectTileRange2d(range: Range3d, takeUpper: boolean): void {\r\n const diag = range.diagonal();\r\n const pt = takeUpper ? range.high : range.low;\r\n if (diag.x > diag.y)\r\n pt.x = (range.low.x + range.high.x) / 2.0;\r\n else\r\n pt.y = (range.low.y + range.high.y) / 2.0;\r\n}\r\n\r\n/** Given a description of a tile, compute the ranges which would result from sub-dividing its range into 4 or 8 sub-volumes.\r\n * @internal\r\n */\r\nexport function computeChildTileRanges(tile: TileMetadata, root: TileTreeMetadata): Array<{ range: Range3d, isEmpty: boolean }> {\r\n const emptyMask = tile.emptySubRangeMask;\r\n const is2d = root.is2d;\r\n const bisectRange = is2d ? bisectTileRange2d : bisectTileRange3d;\r\n\r\n const ranges: Array<{ range: Range3d, isEmpty: boolean }> = [];\r\n for (let i = 0; i < 2; i++) {\r\n for (let j = 0; j < 2; j++) {\r\n for (let k = 0; k < (is2d ? 1 : 2); k++) {\r\n const emptyBit = 1 << (i + j * 2 + k * 4);\r\n const isEmpty = 0 !== (emptyMask & emptyBit);\r\n\r\n const range = tile.range.clone();\r\n bisectRange(range, 0 === i);\r\n bisectRange(range, 0 === j);\r\n if (!is2d)\r\n bisectRange(range, 0 === k);\r\n\r\n ranges.push({ range, isEmpty });\r\n }\r\n }\r\n }\r\n\r\n return ranges;\r\n}\r\n\r\n/** Given a description of the parent tile, obtain the properties of its child tiles, and the number of empty children.\r\n * @internal\r\n */\r\nexport function computeChildTileProps(parent: TileMetadata, idProvider: ContentIdProvider, root: TileTreeMetadata): { children: TileProps[], numEmpty: number } {\r\n let numEmpty = 0;\r\n const children: TileProps[] = [];\r\n\r\n // Leaf nodes have no children\r\n if (parent.isLeaf)\r\n return { children, numEmpty };\r\n\r\n // One child, same volume as parent, but higher-resolution.\r\n if (undefined !== parent.sizeMultiplier) {\r\n const sizeMultiplier = parent.sizeMultiplier * 2;\r\n const contentId = idProvider.idFromParentAndMultiplier(parent.contentId, sizeMultiplier);\r\n children.push({\r\n contentId,\r\n range: parent.range,\r\n contentRange: parent.contentRange,\r\n sizeMultiplier,\r\n isLeaf: false,\r\n maximumSize: root.tileScreenSize,\r\n });\r\n\r\n return { children, numEmpty };\r\n }\r\n\r\n // Sub-divide parent's range into 4 (for 2d trees) or 8 (for 3d trees) child tiles.\r\n const parentSpec = idProvider.specFromId(parent.contentId);\r\n const childSpec: ContentIdSpec = { ...parentSpec };\r\n childSpec.depth = parentSpec.depth + 1;\r\n\r\n // This mask is a bitfield in which an 'on' bit indicates sub-volume containing no geometry.\r\n // Don't bother creating children or requesting content for such empty volumes.\r\n const emptyMask = parent.emptySubRangeMask;\r\n\r\n // Spatial tree range == project extents; content range == model range.\r\n // Trivially reject children whose ranges are entirely outside model range.\r\n let treeContentRange = root.contentRange;\r\n if (undefined !== treeContentRange && treeContentRange.containsRange(parent.range)) {\r\n // Parent is wholly within model range - don't bother testing child ranges against it.\r\n treeContentRange = undefined;\r\n }\r\n\r\n const is2d = root.is2d;\r\n const bisectRange = is2d ? bisectTileRange2d : bisectTileRange3d;\r\n for (let i = 0; i < 2; i++) {\r\n for (let j = 0; j < 2; j++) {\r\n for (let k = 0; k < (is2d ? 1 : 2); k++) {\r\n const emptyBit = 1 << (i + j * 2 + k * 4);\r\n if (0 !== (emptyMask & emptyBit)) {\r\n // volume is known to contain no geometry.\r\n ++numEmpty;\r\n continue;\r\n }\r\n\r\n const range = parent.range.clone();\r\n bisectRange(range, 0 === i);\r\n bisectRange(range, 0 === j);\r\n if (!is2d)\r\n bisectRange(range, 0 === k);\r\n\r\n if (undefined !== treeContentRange && !range.intersectsRange(treeContentRange)) {\r\n // volume is within project extents but entirely outside model range\r\n ++numEmpty;\r\n continue;\r\n }\r\n\r\n childSpec.i = parentSpec.i * 2 + i;\r\n childSpec.j = parentSpec.j * 2 + j;\r\n childSpec.k = parentSpec.k * 2 + k;\r\n\r\n const childId = idProvider.idFromSpec(childSpec);\r\n children.push({ contentId: childId, range, maximumSize: root.tileScreenSize });\r\n }\r\n }\r\n }\r\n\r\n return { children, numEmpty };\r\n}\r\n\r\n/** @internal */\r\nexport interface TileContentDescription extends TileContentMetadata {\r\n readonly featureTableStartPos: number;\r\n}\r\n\r\n/** Deserializes tile content metadata.\r\n * @throws [[TileReadError]]\r\n * @internal\r\n */\r\nexport function readTileContentDescription(stream: ByteStream, sizeMultiplier: number | undefined, is2d: boolean, options: TileOptions, isVolumeClassifier: boolean): TileContentDescription {\r\n stream.reset();\r\n\r\n const header = new ImdlHeader(stream);\r\n if (!header.isValid)\r\n throw new TileReadError(TileReadStatus.InvalidHeader);\r\n else if (!header.isReadableVersion)\r\n throw new TileReadError(TileReadStatus.NewerMajorVersion);\r\n\r\n // Skip the feature table.\r\n const featureTableStartPos = stream.curPos;\r\n const ftHeader = FeatureTableHeader.readFrom(stream);\r\n if (undefined === ftHeader)\r\n throw new TileReadError(TileReadStatus.InvalidFeatureTable);\r\n\r\n stream.curPos = featureTableStartPos + ftHeader.length;\r\n\r\n // Determine subdivision based on header data.\r\n const completeTile = 0 === (header.flags & ImdlFlags.Incomplete);\r\n const emptyTile = completeTile && 0 === header.numElementsIncluded && 0 === header.numElementsExcluded;\r\n let isLeaf = (emptyTile || isVolumeClassifier); // Current classifier algorithm supports only a single tile.\r\n if (!isLeaf) {\r\n // Non-spatial (2d) models are of arbitrary scale and contain geometry like line work and especially text which\r\n // can be adversely affected by quantization issues when zooming in closely.\r\n const maxLeafTolerance = 1.0;\r\n\r\n // Must sub-divide if tile explicitly specifies...\r\n let canSkipSubdivision = 0 === (header.flags & ImdlFlags.DisallowMagnification);\r\n // ...or in 2d, or if app explicitly disabled magnification, or tolerance large enough to risk quantization error...\r\n canSkipSubdivision = canSkipSubdivision && !is2d && !options.disableMagnification && header.tolerance <= maxLeafTolerance;\r\n // ...or app specifies incomplete tiles must always be sub-divided.\r\n canSkipSubdivision = canSkipSubdivision && (completeTile || !options.alwaysSubdivideIncompleteTiles);\r\n if (canSkipSubdivision) {\r\n const minElementsPerTile = 100;\r\n if (completeTile && 0 === header.numElementsExcluded && header.numElementsIncluded <= minElementsPerTile) {\r\n const containsCurves = 0 !== (header.flags & ImdlFlags.ContainsCurves);\r\n if (!containsCurves)\r\n isLeaf = true;\r\n else if (undefined === sizeMultiplier)\r\n sizeMultiplier = 1.0;\r\n } else if (undefined === sizeMultiplier && header.numElementsIncluded + header.numElementsExcluded <= minElementsPerTile) {\r\n sizeMultiplier = 1.0;\r\n }\r\n }\r\n }\r\n\r\n return {\r\n featureTableStartPos,\r\n contentRange: header.contentRange,\r\n isLeaf,\r\n sizeMultiplier,\r\n emptySubRangeMask: header.emptySubRanges,\r\n };\r\n}\r\n\r\nconst scratchRangeDiagonal = new Vector3d();\r\n\r\n/** Compute the chord tolerance for the specified tile of the given range with the specified size multiplier.\r\n * @internal\r\n */\r\nexport function computeTileChordTolerance(tile: TileMetadata, is3d: boolean, tileScreenSize: number): number {\r\n if (tile.range.isNull)\r\n return 0;\r\n\r\n const diagonal = tile.range.diagonal(scratchRangeDiagonal);\r\n const diagDist = is3d ? diagonal.magnitude() : diagonal.magnitudeXY();\r\n\r\n const mult = Math.max(tile.sizeMultiplier ?? 1, 1);\r\n return diagDist / (tileScreenSize * Constants.minToleranceRatioMultiplier * Math.max(1, mult));\r\n}\r\n\r\n/** Deserializes tile metadata.\r\n * @internal\r\n */\r\nexport class TileMetadataReader {\r\n private readonly _is2d: boolean;\r\n private readonly _isVolumeClassifier: boolean;\r\n private readonly _options: TileOptions;\r\n\r\n public constructor(type: BatchType, is2d: boolean, options: TileOptions) {\r\n this._is2d = is2d;\r\n this._isVolumeClassifier = BatchType.VolumeClassifier === type;\r\n this._options = options;\r\n }\r\n\r\n /** Produce metadata from the specified tile content.\r\n * @throws [[TileReadError]]\r\n */\r\n public read(stream: ByteStream, props: TileProps): TileMetadata {\r\n const content = readTileContentDescription(stream, props.sizeMultiplier, this._is2d, this._options, this._isVolumeClassifier);\r\n return {\r\n contentRange: content.contentRange,\r\n isLeaf: content.isLeaf,\r\n sizeMultiplier: content.sizeMultiplier,\r\n emptySubRangeMask: content.emptySubRangeMask,\r\n range: Range3d.fromJSON(props.range),\r\n contentId: props.contentId,\r\n };\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"TileMetadata.js","sourceRoot":"","sources":["../../../src/tile/TileMetadata.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAE6B;AAC7B,wDAAyD;AACzD,kDAA4C;AAE5C,iDAA+F;AAC/F,qCAAyD;AAEzD,mCAAmC;AAEnC,+DAA+D;AAC/D,IAAU,SAAS,CAElB;AAFD,WAAU,SAAS;IACJ,qCAA2B,GAAG,CAAC,CAAC;AAC/C,CAAC,EAFS,SAAS,KAAT,SAAS,QAElB;AA6CD,gBAAgB;AAChB,IAAiB,WAAW,CAyB3B;AAzBD,WAAiB,WAAW;IAC1B;;;;;OAKG;IACH,SAAgB,sBAAsB,CAAC,MAAc,EAAE,SAAiB;QACtE,MAAM,IAAI,GAAG,+BAA+B,CAAC,MAAM,CAAC,CAAC;QACrD,MAAM,YAAY,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;QAEnD,OAAO;YACL,6BAA6B,EAAE,IAAI,CAAC,OAAO;YAC3C,gBAAgB,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC,eAAe,CAAC;YACrE,qBAAqB,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC,eAAe,CAAC;YAC1E,kBAAkB,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC,kBAAkB,CAAC;YAC1E,sBAAsB,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC,gBAAgB,CAAC;YAC5E,iBAAiB,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,iBAAiB,CAA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,CAAC,WAAW,EAAE,CAAC;IAEtE,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAA,IAAI,CAAC,cAAc,mCAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACnD,OAAO,QAAQ,GAAG,CAAC,cAAc,GAAG,SAAS,CAAC,2BAA2B,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AACjG,CAAC;AATD,8DASC;AAED;;GAEG;AACH,MAAa,kBAAkB;IAK7B,YAAmB,IAAe,EAAE,IAAa,EAAE,OAAoB;QACrE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,mBAAmB,GAAG,wBAAS,CAAC,gBAAgB,KAAK,IAAI,CAAC;QAC/D,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,MAAkB,EAAE,KAAgB;QAC9C,MAAM,OAAO,GAAG,0BAA0B,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC9H,OAAO;YACL,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;YAC5C,KAAK,EAAE,uBAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;YACpC,SAAS,EAAE,KAAK,CAAC,SAAS;SAC3B,CAAC;IACJ,CAAC;CACF;AAzBD,gDAyBC","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/** @packageDocumentation\r\n * @module Tile\r\n */\r\n\r\nimport {\r\n assert, ByteStream, compareBooleansOrUndefined, compareNumbers, compareStringsOrUndefined, Id64, Id64String,\r\n} from \"@itwin/core-bentley\";\r\nimport { Range3d, Vector3d } from \"@itwin/core-geometry\";\r\nimport { BatchType } from \"../FeatureTable\";\r\nimport { TileProps } from \"../TileProps\";\r\nimport { CurrentImdlVersion, FeatureTableHeader, ImdlFlags, ImdlHeader } from \"./IModelTileIO\";\r\nimport { TileReadError, TileReadStatus } from \"./TileIO\";\r\n\r\n// cspell:ignore imdl mult bitfield\r\n\r\n// NB: These constants correspond to those defined in Tile.cpp.\r\nnamespace Constants {\r\n export const minToleranceRatioMultiplier = 2;\r\n}\r\n\r\n/** Describes an iModel tile tree.\r\n * @internal\r\n */\r\nexport interface TileTreeMetadata {\r\n readonly modelId: Id64String;\r\n readonly is2d: boolean;\r\n readonly contentRange?: Range3d;\r\n readonly tileScreenSize: number;\r\n}\r\n\r\n/** Describes the contents of an iModel tile.\r\n * @internal\r\n */\r\nexport interface TileContentMetadata {\r\n readonly contentRange: Range3d;\r\n readonly isLeaf: boolean;\r\n readonly sizeMultiplier?: number;\r\n readonly emptySubRangeMask: number;\r\n}\r\n\r\n/** Describes an iModel tile.\r\n * @internal\r\n */\r\nexport interface TileMetadata extends TileContentMetadata {\r\n readonly contentId: string;\r\n readonly range: Range3d;\r\n}\r\n\r\n/** @internal */\r\nexport interface TileOptions {\r\n readonly maximumMajorTileFormatVersion: number;\r\n readonly enableInstancing: boolean;\r\n readonly enableImprovedElision: boolean;\r\n readonly ignoreAreaPatterns: boolean;\r\n readonly enableExternalTextures: boolean;\r\n readonly useProjectExtents: boolean;\r\n readonly optimizeBRepProcessing: boolean;\r\n readonly useLargerTiles: boolean;\r\n readonly disableMagnification: boolean;\r\n readonly alwaysSubdivideIncompleteTiles: boolean;\r\n readonly enableIndexedEdges: boolean;\r\n}\r\n\r\n/** @internal */\r\nexport namespace TileOptions {\r\n /** Given the string representation of an [[IModelTileTreeId]] and the contentId of a [Tile]($frontend) belonging to that [TileTree]($frontend),\r\n * compute the [[TileOptions]] that were used to generate the Ids.\r\n * @throws Error if `treeId` or `contentId` are not valid Ids.\r\n * @note `treeId` and `contentId` are assumed to be valid Ids. They are not fully parsed and validated - only the information required by this function is extracted.\r\n * @note `treeId` and `contentId` are assumed to have been produced for version 4 or later of the iMdl tile format.\r\n */\r\n export function fromTreeIdAndContentId(treeId: string, contentId: string): TileOptions {\r\n const tree = treeFlagsAndFormatVersionFromId(treeId);\r\n const contentFlags = contentFlagsFromId(contentId);\r\n\r\n return {\r\n maximumMajorTileFormatVersion: tree.version,\r\n enableInstancing: 0 !== (contentFlags & ContentFlags.AllowInstancing),\r\n enableImprovedElision: 0 !== (contentFlags & ContentFlags.ImprovedElision),\r\n ignoreAreaPatterns: 0 !== (contentFlags & ContentFlags.IgnoreAreaPatterns),\r\n enableExternalTextures: 0 !== (contentFlags & ContentFlags.ExternalTextures),\r\n useProjectExtents: 0 !== (tree.flags & TreeFlags.UseProjectExtents),\r\n optimizeBRepProcessing: 0 !== (tree.flags & TreeFlags.OptimizeBRepProcessing),\r\n useLargerTiles: 0 !== (tree.flags & TreeFlags.UseLargerTiles),\r\n disableMagnification: false,\r\n alwaysSubdivideIncompleteTiles: false,\r\n enableIndexedEdges: true,\r\n };\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function parseTileTreeIdAndContentId(treeId: string, contentId: string): { modelId: Id64String, treeId: IModelTileTreeId, contentId: ContentIdSpec, options: TileOptions } {\r\n let idx = 0;\r\n let type: BatchType,\r\n expansion: number | undefined,\r\n animationId: string | undefined,\r\n edges: EdgeType | undefined,\r\n sectionCut: string | undefined;\r\n\r\n // Skip version and flags, they're handled by TileOptions.fromTreeIdAndContentId\r\n while (idx < treeId.length && treeId[idx] !== \"-\")\r\n idx++;\r\n idx++; // -\r\n if (idx >= treeId.length)\r\n throw new Error(\"Invalid tree Id\");\r\n\r\n if (treeId[idx] === \"C\") {\r\n // PlanarClassifier or VolumeClassifier\r\n ({ idx, type, expansion } = parseClassifier(idx, treeId, expansion));\r\n } else {\r\n type = BatchType.Primary;\r\n }\r\n\r\n // Animation\r\n // eslint-disable-next-line prefer-const\r\n ({ idx, animationId } = parseAnimation(idx, treeId, animationId));\r\n\r\n if (type === BatchType.Primary) {\r\n ({ idx, edges, sectionCut } = parsePrimary(idx, treeId, edges, sectionCut));\r\n }\r\n\r\n const modelId = treeId.substr(idx);\r\n if (!Id64.isId64(modelId))\r\n throw new Error(\"Invalid tree Id\");\r\n\r\n const { flags: treeFlags } = treeFlagsAndFormatVersionFromId(treeId);\r\n const parsedTreeId = getTreeId(type, edges, sectionCut, animationId, expansion, (treeFlags & TreeFlags.EnforceDisplayPriority) !== 0 ? true : undefined);\r\n const options = TileOptions.fromTreeIdAndContentId(treeId, contentId);\r\n\r\n let parsedContentId: ContentIdSpec;\r\n try {\r\n parsedContentId = ContentIdProvider.create(true, options).specFromId(contentId);\r\n } catch (e) {\r\n throw new Error(\"Invalid content Id\");\r\n }\r\n\r\n if (Object.keys(parsedContentId).some((key) => parsedContentId.hasOwnProperty(key) && typeof parsedContentId[key as keyof ContentIdSpec] === \"number\" && !Number.isFinite(parsedContentId[key as keyof ContentIdSpec])))\r\n throw new Error(\"Invalid content Id\");\r\n\r\n return {\r\n contentId: parsedContentId,\r\n modelId,\r\n options,\r\n treeId: parsedTreeId,\r\n };\r\n}\r\n\r\nfunction getTreeId(type: BatchType, edges?: EdgeType, sectionCut?: string, animationId?: string, expansion?: number, enforceDisplayPriority?: boolean): IModelTileTreeId {\r\n if (type === BatchType.Primary)\r\n return {\r\n type,\r\n edges,\r\n sectionCut,\r\n animationId,\r\n enforceDisplayPriority,\r\n } as PrimaryTileTreeId;\r\n else\r\n return {\r\n type,\r\n expansion,\r\n animationId,\r\n } as ClassifierTileTreeId;\r\n}\r\n\r\nfunction parsePrimary(idx: number, treeId: string, edges: EdgeType = EdgeType.None, sectionCut: string | undefined) {\r\n // Edges\r\n edges = EdgeType.NonIndexed;\r\n if (idx < treeId.length ) {\r\n const noEdgesStr = \"E:0_\";\r\n if (treeId.startsWith(noEdgesStr, idx))\r\n edges = EdgeType.None;\r\n else if (treeId.startsWith(\"E:2_\", idx))\r\n edges = EdgeType.Indexed;\r\n\r\n if (EdgeType.NonIndexed !== edges)\r\n idx += noEdgesStr.length;\r\n }\r\n\r\n // Section cut\r\n if (idx + 1 < treeId.length && treeId[idx] === \"S\") {\r\n idx++; // S\r\n sectionCut = \"\";\r\n while (idx < treeId.length && treeId[idx] !== \"s\") {\r\n sectionCut += treeId[idx++];\r\n }\r\n if (idx === treeId.length)\r\n throw new Error(\"Invalid tree Id\");\r\n idx++; // s\r\n }\r\n return { idx, edges, sectionCut };\r\n}\r\n\r\nfunction parseClassifier(idx: number, treeId: string, expansion: number | undefined) {\r\n let type: BatchType;\r\n idx++; // C\r\n if (idx + 1 < treeId.length && treeId[idx] === \"P\" && treeId[idx + 1] === \":\") {\r\n type = BatchType.PlanarClassifier;\r\n idx += 2; // P:\r\n } else if (idx < treeId.length && treeId[idx] === \":\") {\r\n type = BatchType.VolumeClassifier;\r\n idx++; // :\r\n } else {\r\n throw new Error(\"Invalid tree Id\");\r\n }\r\n\r\n // C: or CP: is always followed by {expansion}_\r\n let expansionStr = \"\";\r\n while (idx < treeId.length && (treeId[idx] >= \"0\" && treeId[idx] <= \"9\" || treeId[idx] === \".\")) {\r\n expansionStr += treeId[idx++];\r\n }\r\n\r\n if (idx === treeId.length || treeId[idx] !== \"_\")\r\n throw new Error(\"Invalid tree Id\");\r\n idx++; // _\r\n\r\n expansion = Number.parseFloat(expansionStr);\r\n return { idx, type, expansion };\r\n}\r\n\r\nfunction parseAnimation(idx: number, treeId: string, animationId: string | undefined) {\r\n if (idx < treeId.length && treeId[idx] === \"A\") {\r\n if (idx + 1 < treeId.length && treeId[idx + 1] !== \":\")\r\n throw new Error(\"Invalid tree Id\");\r\n idx += 2;\r\n\r\n // Parse animation id\r\n animationId = \"\";\r\n while (idx < treeId.length && treeId[idx] !== \"_\") {\r\n animationId += treeId[idx++];\r\n }\r\n\r\n if (!Id64.isId64(animationId) || idx === treeId.length)\r\n throw new Error(\"Invalid tree Id\");\r\n idx++; // _\r\n }\r\n\r\n return { idx, animationId };\r\n}\r\n\r\n/** @internal */\r\nexport const defaultTileOptions: TileOptions = Object.freeze({\r\n maximumMajorTileFormatVersion: CurrentImdlVersion.Major,\r\n enableInstancing: true,\r\n enableImprovedElision: true,\r\n ignoreAreaPatterns: false,\r\n enableExternalTextures: true,\r\n useProjectExtents: true,\r\n optimizeBRepProcessing: true,\r\n useLargerTiles: true,\r\n disableMagnification: false,\r\n alwaysSubdivideIncompleteTiles: false,\r\n enableIndexedEdges: true,\r\n});\r\n\r\nfunction contentFlagsFromId(id: string): ContentFlags {\r\n if (0 === id.length || \"-\" !== id[0])\r\n throw new Error(\"Invalid content Id\");\r\n\r\n // V4: -flags-d-i-j-k-m - version in tree Id\r\n const end = id.indexOf(\"-\", 1);\r\n if (-1 !== end) {\r\n const flags = Number.parseInt(id.substring(1, end), 16);\r\n if (!Number.isNaN(flags))\r\n return flags;\r\n }\r\n\r\n throw new Error(\"Invalid content Id\");\r\n}\r\n\r\nfunction treeFlagsAndFormatVersionFromId(id: string): { flags: TreeFlags, version: number } {\r\n if (0 === id.length)\r\n throw new Error(\"Invalid tree Id\");\r\n\r\n let parts = id.split(\"-\");\r\n if (parts.length > 0) {\r\n parts = parts[0].split(\"_\");\r\n if (parts.length === 2) {\r\n const version = Number.parseInt(parts[0], 16);\r\n const flags = Number.parseInt(parts[1], 16);\r\n if (!Number.isNaN(version) || !Number.isNaN(flags))\r\n return { version, flags };\r\n }\r\n }\r\n\r\n throw new Error(\"Invalid tree Id\");\r\n}\r\n\r\n/** @internal */\r\nexport function getMaximumMajorTileFormatVersion(maxMajorVersion: number, formatVersion?: number): number {\r\n // The `formatVersion` input is from the backend, telling us precisely the maximum major+minor version it can produce.\r\n // Ensure we do not request tiles of a newer major version than backend can supply or it can read; and also limit major version\r\n // to that optionally configured by the app.\r\n let majorVersion = maxMajorVersion;\r\n if (undefined !== formatVersion)\r\n majorVersion = Math.min((formatVersion >>> 0x10), majorVersion);\r\n\r\n // Version number less than 1 is invalid - ignore\r\n majorVersion = Math.max(majorVersion, 1);\r\n\r\n // Version number greater than current known version ignored\r\n majorVersion = Math.min(majorVersion, CurrentImdlVersion.Major);\r\n\r\n // Version numbers are integers - round down\r\n return Math.max(Math.floor(majorVersion), 1);\r\n}\r\n\r\n/** Flags controlling the structure of a tile tree. The flags are part of the tile tree's Id.\r\n * @alpha\r\n */\r\nexport enum TreeFlags {\r\n None = 0,\r\n UseProjectExtents = 1 << 0, // Use project extents as the basis of the tile tree's range.\r\n EnforceDisplayPriority = 1 << 1, // For 3d plan projection models, group graphics into layers based on subcategory.\r\n OptimizeBRepProcessing = 1 << 2, // Use an optimized pipeline for producing facets from BRep entities.\r\n UseLargerTiles = 1 << 3, // Produce tiles of larger size in screen pixels.\r\n}\r\n\r\n/** Describes the type of edges to include in the graphics for a tile tree.\r\n * @alpha\r\n */\r\nexport enum EdgeType {\r\n /** Omit all edges. */\r\n None = 0,\r\n /** Include non-indexed edges, which consume more memory and are less efficient to draw than [[Indexed]] edges, but are compatible with WebGL 1. */\r\n NonIndexed = 1,\r\n /** Include indexed edges, which use less memory and draw more efficiently than [[NonIndexed]] edges, but require WebGL 2. */\r\n Indexed = 2,\r\n}\r\n\r\n/** Describes a tile tree used to draw the contents of a model, possibly with embedded animation.\r\n * @internal\r\n */\r\nexport interface PrimaryTileTreeId {\r\n /** Describes the type of tile tree. */\r\n type: BatchType.Primary;\r\n /** The type of edges to include in tile content. */\r\n edges: EdgeType;\r\n /** Id of the [DisplayStyle]($backend) or [RenderTimeline]($backend) element holding the [[RenderSchedule]] script to be applied to the tiles. */\r\n animationId?: Id64String;\r\n /** If true, meshes within the tiles will be grouped into nodes based on the display priority associated with their subcategories,\r\n * for ensuring the graphics display with correct priority.\r\n */\r\n enforceDisplayPriority?: boolean;\r\n /** If defined, the compact string representation of a clip vector applied to the tiles to produce cut geometry at the intersections with the clip planes.\r\n * Any geometry *not* intersecting the clip planes is omitted from the tiles.\r\n * @see [ClipVector.toCompactString[($core-geometry).\r\n */\r\n sectionCut?: string;\r\n}\r\n\r\n/** Describes a tile tree that can classify the contents of other tile trees using the model's geometry.\r\n * @internal\r\n */\r\nexport interface ClassifierTileTreeId {\r\n type: BatchType.VolumeClassifier | BatchType.PlanarClassifier;\r\n expansion: number;\r\n animationId?: Id64String;\r\n}\r\n\r\nfunction animationIdToString(animationId: Id64String): string {\r\n return `A:${animationId}_`;\r\n}\r\n\r\n/** Describes the Id of an iModel tile tree.\r\n * @internal\r\n */\r\nexport type IModelTileTreeId = PrimaryTileTreeId | ClassifierTileTreeId;\r\n\r\n/** Convert a tile tree Id to its string representation.\r\n * @internal\r\n */\r\nexport function iModelTileTreeIdToString(modelId: Id64String, treeId: IModelTileTreeId, options: TileOptions): string {\r\n let idStr = \"\";\r\n let flags = options.useProjectExtents ? TreeFlags.UseProjectExtents : TreeFlags.None;\r\n if (options.optimizeBRepProcessing)\r\n flags |= TreeFlags.OptimizeBRepProcessing;\r\n\r\n if (options.useLargerTiles)\r\n flags |= TreeFlags.UseLargerTiles;\r\n\r\n if (BatchType.Primary === treeId.type) {\r\n if (undefined !== treeId.animationId)\r\n idStr = `${idStr}${animationIdToString(treeId.animationId)}`;\r\n else if (treeId.enforceDisplayPriority) // animation and priority are currently mutually exclusive\r\n flags |= TreeFlags.EnforceDisplayPriority;\r\n\r\n const edges = treeId.edges !== EdgeType.NonIndexed ? `E:${treeId.edges}_` : \"\";\r\n const sectionCut = treeId.sectionCut ? `S${treeId.sectionCut}s` : \"\";\r\n idStr = `${idStr}${edges}${sectionCut}`;\r\n } else {\r\n const typeStr = BatchType.PlanarClassifier === treeId.type ? \"CP\" : \"C\";\r\n idStr = `${idStr + typeStr}:${treeId.expansion.toFixed(6)}_`;\r\n\r\n if (BatchType.VolumeClassifier === treeId.type)\r\n flags |= TreeFlags.UseProjectExtents;\r\n\r\n if (undefined !== treeId.animationId)\r\n idStr = `${idStr}${animationIdToString(treeId.animationId)}`;\r\n }\r\n\r\n const version = getMaximumMajorTileFormatVersion(options.maximumMajorTileFormatVersion);\r\n if (version >= 4) {\r\n const prefix = `${version.toString(16)}_${flags.toString(16)}-`;\r\n idStr = prefix + idStr;\r\n }\r\n\r\n return idStr + modelId;\r\n}\r\n\r\n/** Ordinal comparison of two tile tree Ids, e.g., for use in sorted containers.\r\n * @internal\r\n */\r\nexport function compareIModelTileTreeIds(lhs: IModelTileTreeId, rhs: IModelTileTreeId): number {\r\n let cmp = compareNumbers(lhs.type, rhs.type);\r\n if (0 === cmp)\r\n cmp = compareStringsOrUndefined(lhs.animationId, rhs.animationId);\r\n\r\n if (0 !== cmp)\r\n return cmp;\r\n\r\n // NB: The redundant checks on BatchType below are to satisfy compiler.\r\n assert(lhs.type === rhs.type);\r\n if (BatchType.Primary === lhs.type && BatchType.Primary === rhs.type) {\r\n cmp = compareNumbers(lhs.edges, rhs.edges);\r\n if (0 === cmp) {\r\n cmp = compareBooleansOrUndefined(lhs.enforceDisplayPriority, rhs.enforceDisplayPriority);\r\n if (0 === cmp)\r\n cmp = compareStringsOrUndefined(lhs.sectionCut, rhs.sectionCut);\r\n }\r\n } else if (BatchType.Primary !== lhs.type && BatchType.Primary !== rhs.type) {\r\n cmp = compareNumbers(lhs.expansion, rhs.expansion);\r\n }\r\n\r\n return cmp;\r\n}\r\n\r\n/** Flags controlling how tile content is produced. The flags are part of the ContentId.\r\n * @alpha\r\n */\r\nexport enum ContentFlags {\r\n None = 0,\r\n AllowInstancing = 1 << 0,\r\n ImprovedElision = 1 << 1,\r\n IgnoreAreaPatterns = 1 << 2,\r\n ExternalTextures = 1 << 3,\r\n}\r\n\r\n/** Describes the components of a tile's content Id.\r\n *\r\n * The depth specifies how many subdivisions from the root tile are to be performed to reach the sub-volume of interest.\r\n *\r\n * The i, j, and k parameters specify how to subdivide the tile's volume. Each sub-division is performed along the longest axis of the\r\n * volume. The volume is first sub-divided based on `i`, then the result sub-divided based on `j`, and finally that result sub-divided\r\n * based on `k`.\r\n *\r\n * The multiplier is an integer - generally a power of two - multiplied by the screen size of a tile (512 pixels) used to\r\n * produce a higher-resolution tile for the same volume.\r\n * @internal\r\n */\r\ninterface ContentIdSpec {\r\n depth: number;\r\n i: number;\r\n j: number;\r\n k: number;\r\n multiplier: number;\r\n}\r\n\r\n/** Contains logic for working with tile content Ids according to a specific content Id scheme. Which scheme is used depends on\r\n * the major version of the tile format.\r\n * @internal\r\n */\r\nexport abstract class ContentIdProvider {\r\n public readonly majorFormatVersion: number;\r\n public readonly contentFlags: ContentFlags;\r\n\r\n protected constructor(formatVersion: number, contentFlags: ContentFlags) {\r\n this.majorFormatVersion = formatVersion;\r\n this.contentFlags = contentFlags;\r\n }\r\n\r\n public get rootContentId(): string {\r\n return this.computeId(0, 0, 0, 0, 1);\r\n }\r\n\r\n public idFromParentAndMultiplier(parentId: string, multiplier: number): string {\r\n const lastSepPos = parentId.lastIndexOf(this._separator);\r\n assert(-1 !== lastSepPos);\r\n return parentId.substring(0, lastSepPos + 1) + multiplier.toString(16);\r\n }\r\n\r\n public specFromId(id: string): ContentIdSpec {\r\n const parts = id.split(this._separator);\r\n const len = parts.length;\r\n assert(len >= 5);\r\n return {\r\n depth: parseInt(parts[len - 5], 16),\r\n i: parseInt(parts[len - 4], 16),\r\n j: parseInt(parts[len - 3], 16),\r\n k: parseInt(parts[len - 2], 16),\r\n multiplier: parseInt(parts[len - 1], 16),\r\n };\r\n }\r\n\r\n public idFromSpec(spec: ContentIdSpec): string {\r\n return this.computeId(spec.depth, spec.i, spec.j, spec.k, spec.multiplier);\r\n }\r\n\r\n protected join(depth: number, i: number, j: number, k: number, mult: number): string {\r\n const sep = this._separator;\r\n return depth.toString(16) + sep + i.toString(16) + sep + j.toString(16) + sep + k.toString(16) + sep + mult.toString(16);\r\n }\r\n\r\n protected abstract get _separator(): string;\r\n protected abstract computeId(depth: number, i: number, j: number, k: number, mult: number): string;\r\n\r\n /** formatVersion is the maximum major version supported by the back-end supplying the tile tree.\r\n * Must ensure front-end does not request tiles of a format the back-end cannot supply, and back-end does\r\n * not supply tiles of a format the front-end doesn't recognize.\r\n */\r\n public static create(allowInstancing: boolean, options: TileOptions, formatVersion?: number): ContentIdProvider {\r\n const majorVersion = getMaximumMajorTileFormatVersion(options.maximumMajorTileFormatVersion, formatVersion);\r\n assert(majorVersion > 0);\r\n assert(Math.floor(majorVersion) === majorVersion);\r\n switch (majorVersion) {\r\n case 0:\r\n case 1:\r\n return new ContentIdV1Provider(majorVersion);\r\n case 2:\r\n case 3:\r\n return new ContentIdV2Provider(majorVersion, allowInstancing, options);\r\n default:\r\n return new ContentIdV4Provider(allowInstancing, options, majorVersion);\r\n }\r\n }\r\n}\r\n\r\n/** The original (major version 1) tile format used a content Id scheme of the format\r\n * `depth/i/j/k/multiplier`.\r\n * @internal\r\n */\r\nclass ContentIdV1Provider extends ContentIdProvider {\r\n public constructor(majorVersion: number) {\r\n super(majorVersion, ContentFlags.None);\r\n }\r\n\r\n protected get _separator() { return \"/\"; }\r\n protected computeId(depth: number, i: number, j: number, k: number, mult: number): string {\r\n return this.join(depth, i, j, k, mult);\r\n }\r\n}\r\n\r\n/** Tile formats 2 and 3 use a content Id scheme encoding styling flags and the major format version\r\n * into the content Id, of the format `_majorVersion_flags_depth_i_j_k_multiplier`.\r\n * @internal\r\n */\r\nclass ContentIdV2Provider extends ContentIdProvider {\r\n private readonly _prefix: string;\r\n\r\n public constructor(majorVersion: number, allowInstancing: boolean, options: TileOptions) {\r\n const flags = (allowInstancing && options.enableInstancing) ? ContentFlags.AllowInstancing : ContentFlags.None;\r\n super(majorVersion, flags);\r\n this._prefix = this._separator + majorVersion.toString(16) + this._separator + flags.toString(16) + this._separator;\r\n }\r\n\r\n protected get _separator() { return \"_\"; }\r\n protected computeId(depth: number, i: number, j: number, k: number, mult: number): string {\r\n return this._prefix + this.join(depth, i, j, k, mult);\r\n }\r\n}\r\n\r\n/** Tile formats 4+ encode styling flags but not major format version. (The version is specified by the tile tree's Id).\r\n * Format: `-flags-depth-i-j-k-multiplier`.\r\n * @internal\r\n */\r\nclass ContentIdV4Provider extends ContentIdProvider {\r\n private readonly _prefix: string;\r\n\r\n public constructor(allowInstancing: boolean, options: TileOptions, majorVersion: number) {\r\n let flags = (allowInstancing && options.enableInstancing) ? ContentFlags.AllowInstancing : ContentFlags.None;\r\n if (options.enableImprovedElision)\r\n flags = flags | ContentFlags.ImprovedElision;\r\n\r\n if (options.ignoreAreaPatterns)\r\n flags = flags | ContentFlags.IgnoreAreaPatterns;\r\n\r\n if (options.enableExternalTextures)\r\n flags = flags | ContentFlags.ExternalTextures;\r\n\r\n super(majorVersion, flags);\r\n this._prefix = this._separator + flags.toString(16) + this._separator;\r\n }\r\n\r\n protected get _separator() { return \"-\"; }\r\n protected computeId(depth: number, i: number, j: number, k: number, mult: number): string {\r\n return this._prefix + this.join(depth, i, j, k, mult);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function bisectTileRange3d(range: Range3d, takeUpper: boolean): void {\r\n const diag = range.diagonal();\r\n const pt = takeUpper ? range.high : range.low;\r\n if (diag.x > diag.y && diag.x > diag.z)\r\n pt.x = (range.low.x + range.high.x) / 2.0;\r\n else if (diag.y > diag.z)\r\n pt.y = (range.low.y + range.high.y) / 2.0;\r\n else\r\n pt.z = (range.low.z + range.high.z) / 2.0;\r\n}\r\n\r\n/** @internal */\r\nexport function bisectTileRange2d(range: Range3d, takeUpper: boolean): void {\r\n const diag = range.diagonal();\r\n const pt = takeUpper ? range.high : range.low;\r\n if (diag.x > diag.y)\r\n pt.x = (range.low.x + range.high.x) / 2.0;\r\n else\r\n pt.y = (range.low.y + range.high.y) / 2.0;\r\n}\r\n\r\n/** Given a description of a tile, compute the ranges which would result from sub-dividing its range into 4 or 8 sub-volumes.\r\n * @internal\r\n */\r\nexport function computeChildTileRanges(tile: TileMetadata, root: TileTreeMetadata): Array<{ range: Range3d, isEmpty: boolean }> {\r\n const emptyMask = tile.emptySubRangeMask;\r\n const is2d = root.is2d;\r\n const bisectRange = is2d ? bisectTileRange2d : bisectTileRange3d;\r\n\r\n const ranges: Array<{ range: Range3d, isEmpty: boolean }> = [];\r\n for (let i = 0; i < 2; i++) {\r\n for (let j = 0; j < 2; j++) {\r\n for (let k = 0; k < (is2d ? 1 : 2); k++) {\r\n const emptyBit = 1 << (i + j * 2 + k * 4);\r\n const isEmpty = 0 !== (emptyMask & emptyBit);\r\n\r\n const range = tile.range.clone();\r\n bisectRange(range, 0 === i);\r\n bisectRange(range, 0 === j);\r\n if (!is2d)\r\n bisectRange(range, 0 === k);\r\n\r\n ranges.push({ range, isEmpty });\r\n }\r\n }\r\n }\r\n\r\n return ranges;\r\n}\r\n\r\n/** Given a description of the parent tile, obtain the properties of its child tiles, and the number of empty children.\r\n * @internal\r\n */\r\nexport function computeChildTileProps(parent: TileMetadata, idProvider: ContentIdProvider, root: TileTreeMetadata): { children: TileProps[], numEmpty: number } {\r\n let numEmpty = 0;\r\n const children: TileProps[] = [];\r\n\r\n // Leaf nodes have no children\r\n if (parent.isLeaf)\r\n return { children, numEmpty };\r\n\r\n // One child, same volume as parent, but higher-resolution.\r\n if (undefined !== parent.sizeMultiplier) {\r\n const sizeMultiplier = parent.sizeMultiplier * 2;\r\n const contentId = idProvider.idFromParentAndMultiplier(parent.contentId, sizeMultiplier);\r\n children.push({\r\n contentId,\r\n range: parent.range,\r\n contentRange: parent.contentRange,\r\n sizeMultiplier,\r\n isLeaf: false,\r\n maximumSize: root.tileScreenSize,\r\n });\r\n\r\n return { children, numEmpty };\r\n }\r\n\r\n // Sub-divide parent's range into 4 (for 2d trees) or 8 (for 3d trees) child tiles.\r\n const parentSpec = idProvider.specFromId(parent.contentId);\r\n const childSpec: ContentIdSpec = { ...parentSpec };\r\n childSpec.depth = parentSpec.depth + 1;\r\n\r\n // This mask is a bitfield in which an 'on' bit indicates sub-volume containing no geometry.\r\n // Don't bother creating children or requesting content for such empty volumes.\r\n const emptyMask = parent.emptySubRangeMask;\r\n\r\n // Spatial tree range == project extents; content range == model range.\r\n // Trivially reject children whose ranges are entirely outside model range.\r\n let treeContentRange = root.contentRange;\r\n if (undefined !== treeContentRange && treeContentRange.containsRange(parent.range)) {\r\n // Parent is wholly within model range - don't bother testing child ranges against it.\r\n treeContentRange = undefined;\r\n }\r\n\r\n const is2d = root.is2d;\r\n const bisectRange = is2d ? bisectTileRange2d : bisectTileRange3d;\r\n for (let i = 0; i < 2; i++) {\r\n for (let j = 0; j < 2; j++) {\r\n for (let k = 0; k < (is2d ? 1 : 2); k++) {\r\n const emptyBit = 1 << (i + j * 2 + k * 4);\r\n if (0 !== (emptyMask & emptyBit)) {\r\n // volume is known to contain no geometry.\r\n ++numEmpty;\r\n continue;\r\n }\r\n\r\n const range = parent.range.clone();\r\n bisectRange(range, 0 === i);\r\n bisectRange(range, 0 === j);\r\n if (!is2d)\r\n bisectRange(range, 0 === k);\r\n\r\n if (undefined !== treeContentRange && !range.intersectsRange(treeContentRange)) {\r\n // volume is within project extents but entirely outside model range\r\n ++numEmpty;\r\n continue;\r\n }\r\n\r\n childSpec.i = parentSpec.i * 2 + i;\r\n childSpec.j = parentSpec.j * 2 + j;\r\n childSpec.k = parentSpec.k * 2 + k;\r\n\r\n const childId = idProvider.idFromSpec(childSpec);\r\n children.push({ contentId: childId, range, maximumSize: root.tileScreenSize });\r\n }\r\n }\r\n }\r\n\r\n return { children, numEmpty };\r\n}\r\n\r\n/** @internal */\r\nexport interface TileContentDescription extends TileContentMetadata {\r\n readonly featureTableStartPos: number;\r\n}\r\n\r\n/** Deserializes tile content metadata.\r\n * @throws [[TileReadError]]\r\n * @internal\r\n */\r\nexport function readTileContentDescription(stream: ByteStream, sizeMultiplier: number | undefined, is2d: boolean, options: TileOptions, isVolumeClassifier: boolean): TileContentDescription {\r\n stream.reset();\r\n\r\n const header = new ImdlHeader(stream);\r\n if (!header.isValid)\r\n throw new TileReadError(TileReadStatus.InvalidHeader);\r\n else if (!header.isReadableVersion)\r\n throw new TileReadError(TileReadStatus.NewerMajorVersion);\r\n\r\n // Skip the feature table.\r\n const featureTableStartPos = stream.curPos;\r\n const ftHeader = FeatureTableHeader.readFrom(stream);\r\n if (undefined === ftHeader)\r\n throw new TileReadError(TileReadStatus.InvalidFeatureTable);\r\n\r\n stream.curPos = featureTableStartPos + ftHeader.length;\r\n\r\n // Determine subdivision based on header data.\r\n const completeTile = 0 === (header.flags & ImdlFlags.Incomplete);\r\n const emptyTile = completeTile && 0 === header.numElementsIncluded && 0 === header.numElementsExcluded;\r\n let isLeaf = (emptyTile || isVolumeClassifier); // Current classifier algorithm supports only a single tile.\r\n if (!isLeaf) {\r\n // Non-spatial (2d) models are of arbitrary scale and contain geometry like line work and especially text which\r\n // can be adversely affected by quantization issues when zooming in closely.\r\n const maxLeafTolerance = 1.0;\r\n\r\n // Must sub-divide if tile explicitly specifies...\r\n let canSkipSubdivision = 0 === (header.flags & ImdlFlags.DisallowMagnification);\r\n // ...or in 2d, or if app explicitly disabled magnification, or tolerance large enough to risk quantization error...\r\n canSkipSubdivision = canSkipSubdivision && !is2d && !options.disableMagnification && header.tolerance <= maxLeafTolerance;\r\n // ...or app specifies incomplete tiles must always be sub-divided.\r\n canSkipSubdivision = canSkipSubdivision && (completeTile || !options.alwaysSubdivideIncompleteTiles);\r\n if (canSkipSubdivision) {\r\n const minElementsPerTile = 100;\r\n if (completeTile && 0 === header.numElementsExcluded && header.numElementsIncluded <= minElementsPerTile) {\r\n const containsCurves = 0 !== (header.flags & ImdlFlags.ContainsCurves);\r\n if (!containsCurves)\r\n isLeaf = true;\r\n else if (undefined === sizeMultiplier)\r\n sizeMultiplier = 1.0;\r\n } else if (undefined === sizeMultiplier && header.numElementsIncluded + header.numElementsExcluded <= minElementsPerTile) {\r\n sizeMultiplier = 1.0;\r\n }\r\n }\r\n }\r\n\r\n return {\r\n featureTableStartPos,\r\n contentRange: header.contentRange,\r\n isLeaf,\r\n sizeMultiplier,\r\n emptySubRangeMask: header.emptySubRanges,\r\n };\r\n}\r\n\r\nconst scratchRangeDiagonal = new Vector3d();\r\n\r\n/** Compute the chord tolerance for the specified tile of the given range with the specified size multiplier.\r\n * @internal\r\n */\r\nexport function computeTileChordTolerance(tile: TileMetadata, is3d: boolean, tileScreenSize: number): number {\r\n if (tile.range.isNull)\r\n return 0;\r\n\r\n const diagonal = tile.range.diagonal(scratchRangeDiagonal);\r\n const diagDist = is3d ? diagonal.magnitude() : diagonal.magnitudeXY();\r\n\r\n const mult = Math.max(tile.sizeMultiplier ?? 1, 1);\r\n return diagDist / (tileScreenSize * Constants.minToleranceRatioMultiplier * Math.max(1, mult));\r\n}\r\n\r\n/** Deserializes tile metadata.\r\n * @internal\r\n */\r\nexport class TileMetadataReader {\r\n private readonly _is2d: boolean;\r\n private readonly _isVolumeClassifier: boolean;\r\n private readonly _options: TileOptions;\r\n\r\n public constructor(type: BatchType, is2d: boolean, options: TileOptions) {\r\n this._is2d = is2d;\r\n this._isVolumeClassifier = BatchType.VolumeClassifier === type;\r\n this._options = options;\r\n }\r\n\r\n /** Produce metadata from the specified tile content.\r\n * @throws [[TileReadError]]\r\n */\r\n public read(stream: ByteStream, props: TileProps): TileMetadata {\r\n const content = readTileContentDescription(stream, props.sizeMultiplier, this._is2d, this._options, this._isVolumeClassifier);\r\n return {\r\n contentRange: content.contentRange,\r\n isLeaf: content.isLeaf,\r\n sizeMultiplier: content.sizeMultiplier,\r\n emptySubRangeMask: content.emptySubRangeMask,\r\n range: Range3d.fromJSON(props.range),\r\n contentId: props.contentId,\r\n };\r\n }\r\n}\r\n"]}
|
|
@@ -6,7 +6,7 @@ import { TransformProps } from "@itwin/core-geometry";
|
|
|
6
6
|
import { Placement2dProps, Placement3dProps } from "../ElementProps";
|
|
7
7
|
import { ElementGeometryDataEntry } from "../geometry/ElementGeometry";
|
|
8
8
|
import { GeometryStreamProps } from "../geometry/GeometryStream";
|
|
9
|
-
import { ContentFlags, TreeFlags } from "../tile/TileMetadata";
|
|
9
|
+
import { ContentFlags, EdgeType, TreeFlags } from "../tile/TileMetadata";
|
|
10
10
|
/** Wire format describing properties common to [[PersistentGraphicsRequestProps]] and [[DynamicGraphicsRequestProps]].
|
|
11
11
|
* @see [[ElementGraphicsRequestProps]] for more details.
|
|
12
12
|
* @public
|
|
@@ -29,6 +29,10 @@ export interface GraphicsRequestProps {
|
|
|
29
29
|
readonly location?: TransformProps;
|
|
30
30
|
/** If true, surface edges will be omitted from the graphics. */
|
|
31
31
|
readonly omitEdges?: boolean;
|
|
32
|
+
/** If omitEdges is false, specifies the type of edges to produce. Generally determined by TileAdmin.requestElementGraphics.
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
readonly edgeType?: EdgeType;
|
|
32
36
|
/** If true, the element's graphics will be clipped against the iModel's project extents. */
|
|
33
37
|
readonly clipToProjectExtents?: boolean;
|
|
34
38
|
/** If defined, the compact string representation of a [ClipVector]($core-geometry) to be applied to the geometry to produce section-cut
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementGraphics.d.ts","sourceRoot":"","sources":["../../../src/tile/ElementGraphics.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ElementGraphics.d.ts","sourceRoot":"","sources":["../../../src/tile/ElementGraphics.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAA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AC1C,IAAI,EAAE,mBAAmB,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,kEAAkE;IAClE,MAAM,EAAE,YAAY,CAAC;IACrB,gDAAgD;IAChD,IAAI,EAAE,wBAAwB,EAAE,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,2BAA4B,SAAQ,oBAAoB;IACvE,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,GAAG,wBAAwB,CAAC;IACjE;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,uGAAuG;IACvG,QAAQ,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,6BAA8B,SAAQ,2BAA2B;IAChF,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;CACpD;AAED;;;GAGG;AACH,MAAM,WAAW,6BAA8B,SAAQ,2BAA2B;IAChF,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;CACpD;AAED;;;;;GAKG;AACH,oBAAY,2BAA2B,GAAG,8BAA8B,GAAG,6BAA6B,GAAG,6BAA6B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementGraphics.js","sourceRoot":"","sources":["../../../src/tile/ElementGraphics.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG","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/** @packageDocumentation\r\n * @module Tile\r\n */\r\n\r\nimport { Id64String } from \"@itwin/core-bentley\";\r\nimport { TransformProps } from \"@itwin/core-geometry\";\r\nimport { Placement2dProps, Placement3dProps } from \"../ElementProps\";\r\nimport { ElementGeometryDataEntry } from \"../geometry/ElementGeometry\";\r\nimport { GeometryStreamProps } from \"../geometry/GeometryStream\";\r\nimport { ContentFlags, TreeFlags } from \"../tile/TileMetadata\";\r\n\r\n/** Wire format describing properties common to [[PersistentGraphicsRequestProps]] and [[DynamicGraphicsRequestProps]].\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface GraphicsRequestProps {\r\n /** Uniquely identifies this request among all [[ElementGraphicsRequestProps]] for a given [[IModel]]. */\r\n readonly id: string;\r\n /** Log10 of the chord tolerance with which to stroke the element's geometry. e.g., for a chord tolerance of 0.01 (10^-2) meters, supply -2. */\r\n readonly toleranceLog10: number;\r\n /** The major version of the \"iMdl\" format to use when producing the iMdl representation of the element's geometry.\r\n * If omitted, the most recent version known to the backend will be used.\r\n * @alpha\r\n */\r\n readonly formatVersion?: number;\r\n /** Optional flags. [[TreeFlags.UseProjectExtents]] has no effect. [[TreeFlags.EnforceDisplayPriority]] is not yet implemented. @alpha */\r\n readonly treeFlags?: TreeFlags;\r\n /** Optional flags. [[ContentFlags.ImprovedElision]] has no effect. @alpha */\r\n readonly contentFlags?: ContentFlags;\r\n /** Transform from element graphics to world coordinates. Defaults to identity. */\r\n readonly location?: TransformProps;\r\n /** If true, surface edges will be omitted from the graphics. */\r\n readonly omitEdges?: boolean;\r\n /** If true, the element's graphics will be clipped against the iModel's project extents. */\r\n readonly clipToProjectExtents?: boolean;\r\n /** If defined, the compact string representation of a [ClipVector]($core-geometry) to be applied to the geometry to produce section-cut\r\n * geometry at the intersections with the clip planes. Any geometry *not* intersecting the clip planes is omitted from the tiles.\r\n * @see [ClipVector.toCompactString]($core-geometry) to produce the string representation.\r\n */\r\n readonly sectionCut?: string;\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a single element.\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface PersistentGraphicsRequestProps extends GraphicsRequestProps {\r\n /** The element whose geometry is to be used to generate the graphics. */\r\n readonly elementId: Id64String;\r\n}\r\n\r\n/** As part of a [[DynamicGraphicsRequestProps]], specifies the geometry from which to generate the graphics in JSON format.\r\n * @public\r\n */\r\nexport interface JsonGeometryStream {\r\n /** Discriminator for [[DynamicGraphicsRequestProps.geometry]]. */\r\n format: \"json\";\r\n /** The geometry stream in JSON format. */\r\n data: GeometryStreamProps;\r\n}\r\n\r\n/** As part of a [[DynamicGraphicsRequestProps]], specifies the geometry from which to generate the graphics in binary flatbuffer-encoded format.\r\n * @public\r\n */\r\nexport interface FlatBufferGeometryStream {\r\n /** Discriminator for [[DynamicGraphicsRequestProps.geometry]]. */\r\n format: \"flatbuffer\";\r\n /** The geometry stream in flatbuffer format. */\r\n data: ElementGeometryDataEntry[];\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a single geometry stream.\r\n * @see [[DynamicGraphicsRequest2dProps]] and [[DynamicGraphicsRequest3dProps]].\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface DynamicGraphicsRequestProps extends GraphicsRequestProps {\r\n /** The geometry from which to generate the graphics. */\r\n readonly geometry: JsonGeometryStream | FlatBufferGeometryStream;\r\n /** The category to which the geometry belongs. This is required to identify a persistent [SpatialCategory]($backend) for 3d geometry or\r\n * [DrawingCategory]($backend) for 2d geometry.\r\n */\r\n readonly categoryId: Id64String;\r\n /** If specified, tools will recognize the generated graphics as being associated with this element. */\r\n readonly elementId?: Id64String;\r\n /** If specified, tools will recognize the generated graphics as being associated with this model.\r\n * It should identify a 3d model for 3d geometry or a 2d model for 2d geometry.\r\n * It needn't identify a persistent model - it can be a transient Id.\r\n */\r\n readonly modelId?: Id64String;\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a 2d geometry stream.\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface DynamicGraphicsRequest2dProps extends DynamicGraphicsRequestProps {\r\n /** Specifies the geometry is 2d. */\r\n readonly type: \"2d\";\r\n /** The origin and rotation of the geometry. */\r\n readonly placement: Omit<Placement2dProps, \"bbox\">;\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a 3d geometry stream.\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface DynamicGraphicsRequest3dProps extends DynamicGraphicsRequestProps {\r\n /** Specifies the geometry is 3d. */\r\n readonly type: \"3d\";\r\n /** The origin and rotation of the geometry. */\r\n readonly placement: Omit<Placement3dProps, \"bbox\">;\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a single element or geometry stream.\r\n * @note Every request must have an `id` that is unique amongst all extant requests for a given [[IModel]].\r\n * @see [TileAdmin.requestElementGraphics]($frontend) and [IModelDb.generateElementGraphics]($backend) to fulfill such a request.\r\n * @see [readElementGraphics]($frontend) to convert the result of a request to a [RenderGraphic]($frontend) for display.\r\n * @public\r\n */\r\nexport type ElementGraphicsRequestProps = PersistentGraphicsRequestProps | DynamicGraphicsRequest2dProps | DynamicGraphicsRequest3dProps;\r\n"]}
|
|
1
|
+
{"version":3,"file":"ElementGraphics.js","sourceRoot":"","sources":["../../../src/tile/ElementGraphics.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG","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/** @packageDocumentation\r\n * @module Tile\r\n */\r\n\r\nimport { Id64String } from \"@itwin/core-bentley\";\r\nimport { TransformProps } from \"@itwin/core-geometry\";\r\nimport { Placement2dProps, Placement3dProps } from \"../ElementProps\";\r\nimport { ElementGeometryDataEntry } from \"../geometry/ElementGeometry\";\r\nimport { GeometryStreamProps } from \"../geometry/GeometryStream\";\r\nimport { ContentFlags, EdgeType, TreeFlags } from \"../tile/TileMetadata\";\r\n\r\n/** Wire format describing properties common to [[PersistentGraphicsRequestProps]] and [[DynamicGraphicsRequestProps]].\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface GraphicsRequestProps {\r\n /** Uniquely identifies this request among all [[ElementGraphicsRequestProps]] for a given [[IModel]]. */\r\n readonly id: string;\r\n /** Log10 of the chord tolerance with which to stroke the element's geometry. e.g., for a chord tolerance of 0.01 (10^-2) meters, supply -2. */\r\n readonly toleranceLog10: number;\r\n /** The major version of the \"iMdl\" format to use when producing the iMdl representation of the element's geometry.\r\n * If omitted, the most recent version known to the backend will be used.\r\n * @alpha\r\n */\r\n readonly formatVersion?: number;\r\n /** Optional flags. [[TreeFlags.UseProjectExtents]] has no effect. [[TreeFlags.EnforceDisplayPriority]] is not yet implemented. @alpha */\r\n readonly treeFlags?: TreeFlags;\r\n /** Optional flags. [[ContentFlags.ImprovedElision]] has no effect. @alpha */\r\n readonly contentFlags?: ContentFlags;\r\n /** Transform from element graphics to world coordinates. Defaults to identity. */\r\n readonly location?: TransformProps;\r\n /** If true, surface edges will be omitted from the graphics. */\r\n readonly omitEdges?: boolean;\r\n /** If omitEdges is false, specifies the type of edges to produce. Generally determined by TileAdmin.requestElementGraphics.\r\n * @internal\r\n */\r\n readonly edgeType?: EdgeType;\r\n /** If true, the element's graphics will be clipped against the iModel's project extents. */\r\n readonly clipToProjectExtents?: boolean;\r\n /** If defined, the compact string representation of a [ClipVector]($core-geometry) to be applied to the geometry to produce section-cut\r\n * geometry at the intersections with the clip planes. Any geometry *not* intersecting the clip planes is omitted from the tiles.\r\n * @see [ClipVector.toCompactString]($core-geometry) to produce the string representation.\r\n */\r\n readonly sectionCut?: string;\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a single element.\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface PersistentGraphicsRequestProps extends GraphicsRequestProps {\r\n /** The element whose geometry is to be used to generate the graphics. */\r\n readonly elementId: Id64String;\r\n}\r\n\r\n/** As part of a [[DynamicGraphicsRequestProps]], specifies the geometry from which to generate the graphics in JSON format.\r\n * @public\r\n */\r\nexport interface JsonGeometryStream {\r\n /** Discriminator for [[DynamicGraphicsRequestProps.geometry]]. */\r\n format: \"json\";\r\n /** The geometry stream in JSON format. */\r\n data: GeometryStreamProps;\r\n}\r\n\r\n/** As part of a [[DynamicGraphicsRequestProps]], specifies the geometry from which to generate the graphics in binary flatbuffer-encoded format.\r\n * @public\r\n */\r\nexport interface FlatBufferGeometryStream {\r\n /** Discriminator for [[DynamicGraphicsRequestProps.geometry]]. */\r\n format: \"flatbuffer\";\r\n /** The geometry stream in flatbuffer format. */\r\n data: ElementGeometryDataEntry[];\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a single geometry stream.\r\n * @see [[DynamicGraphicsRequest2dProps]] and [[DynamicGraphicsRequest3dProps]].\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface DynamicGraphicsRequestProps extends GraphicsRequestProps {\r\n /** The geometry from which to generate the graphics. */\r\n readonly geometry: JsonGeometryStream | FlatBufferGeometryStream;\r\n /** The category to which the geometry belongs. This is required to identify a persistent [SpatialCategory]($backend) for 3d geometry or\r\n * [DrawingCategory]($backend) for 2d geometry.\r\n */\r\n readonly categoryId: Id64String;\r\n /** If specified, tools will recognize the generated graphics as being associated with this element. */\r\n readonly elementId?: Id64String;\r\n /** If specified, tools will recognize the generated graphics as being associated with this model.\r\n * It should identify a 3d model for 3d geometry or a 2d model for 2d geometry.\r\n * It needn't identify a persistent model - it can be a transient Id.\r\n */\r\n readonly modelId?: Id64String;\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a 2d geometry stream.\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface DynamicGraphicsRequest2dProps extends DynamicGraphicsRequestProps {\r\n /** Specifies the geometry is 2d. */\r\n readonly type: \"2d\";\r\n /** The origin and rotation of the geometry. */\r\n readonly placement: Omit<Placement2dProps, \"bbox\">;\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a 3d geometry stream.\r\n * @see [[ElementGraphicsRequestProps]] for more details.\r\n * @public\r\n */\r\nexport interface DynamicGraphicsRequest3dProps extends DynamicGraphicsRequestProps {\r\n /** Specifies the geometry is 3d. */\r\n readonly type: \"3d\";\r\n /** The origin and rotation of the geometry. */\r\n readonly placement: Omit<Placement3dProps, \"bbox\">;\r\n}\r\n\r\n/** Wire format describing a request to produce graphics in \"iMdl\" format for a single element or geometry stream.\r\n * @note Every request must have an `id` that is unique amongst all extant requests for a given [[IModel]].\r\n * @see [TileAdmin.requestElementGraphics]($frontend) and [IModelDb.generateElementGraphics]($backend) to fulfill such a request.\r\n * @see [readElementGraphics]($frontend) to convert the result of a request to a [RenderGraphic]($frontend) for display.\r\n * @public\r\n */\r\nexport type ElementGraphicsRequestProps = PersistentGraphicsRequestProps | DynamicGraphicsRequest2dProps | DynamicGraphicsRequest3dProps;\r\n"]}
|
|
@@ -42,6 +42,7 @@ export interface TileOptions {
|
|
|
42
42
|
readonly useLargerTiles: boolean;
|
|
43
43
|
readonly disableMagnification: boolean;
|
|
44
44
|
readonly alwaysSubdivideIncompleteTiles: boolean;
|
|
45
|
+
readonly enableIndexedEdges: boolean;
|
|
45
46
|
}
|
|
46
47
|
/** @internal */
|
|
47
48
|
export declare namespace TileOptions {
|
|
@@ -74,14 +75,25 @@ export declare enum TreeFlags {
|
|
|
74
75
|
OptimizeBRepProcessing = 4,
|
|
75
76
|
UseLargerTiles = 8
|
|
76
77
|
}
|
|
78
|
+
/** Describes the type of edges to include in the graphics for a tile tree.
|
|
79
|
+
* @alpha
|
|
80
|
+
*/
|
|
81
|
+
export declare enum EdgeType {
|
|
82
|
+
/** Omit all edges. */
|
|
83
|
+
None = 0,
|
|
84
|
+
/** Include non-indexed edges, which consume more memory and are less efficient to draw than [[Indexed]] edges, but are compatible with WebGL 1. */
|
|
85
|
+
NonIndexed = 1,
|
|
86
|
+
/** Include indexed edges, which use less memory and draw more efficiently than [[NonIndexed]] edges, but require WebGL 2. */
|
|
87
|
+
Indexed = 2
|
|
88
|
+
}
|
|
77
89
|
/** Describes a tile tree used to draw the contents of a model, possibly with embedded animation.
|
|
78
90
|
* @internal
|
|
79
91
|
*/
|
|
80
92
|
export interface PrimaryTileTreeId {
|
|
81
93
|
/** Describes the type of tile tree. */
|
|
82
94
|
type: BatchType.Primary;
|
|
83
|
-
/**
|
|
84
|
-
|
|
95
|
+
/** The type of edges to include in tile content. */
|
|
96
|
+
edges: EdgeType;
|
|
85
97
|
/** Id of the [DisplayStyle]($backend) or [RenderTimeline]($backend) element holding the [[RenderSchedule]] script to be applied to the tiles. */
|
|
86
98
|
animationId?: Id64String;
|
|
87
99
|
/** If true, meshes within the tiles will be grouped into nodes based on the display priority associated with their subcategories,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileMetadata.d.ts","sourceRoot":"","sources":["../../../src/tile/TileMetadata.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACG,UAAU,
|
|
1
|
+
{"version":3,"file":"TileMetadata.d.ts","sourceRoot":"","sources":["../../../src/tile/TileMetadata.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACG,UAAU,EAA+E,UAAU,EAC5G,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAY,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc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Y,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAS3G;AAED;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;IAChC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAU;IAC9C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;gBAEpB,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW;IAMvE;;OAEG;IACI,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,GAAG,YAAY;CAWhE"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Tile
|
|
7
7
|
*/
|
|
8
|
-
import { assert,
|
|
8
|
+
import { assert, compareBooleansOrUndefined, compareNumbers, compareStringsOrUndefined, Id64, } from "@itwin/core-bentley";
|
|
9
9
|
import { Range3d, Vector3d } from "@itwin/core-geometry";
|
|
10
10
|
import { BatchType } from "../FeatureTable";
|
|
11
11
|
import { CurrentImdlVersion, FeatureTableHeader, ImdlFlags, ImdlHeader } from "./IModelTileIO";
|
|
@@ -39,6 +39,7 @@ export var TileOptions;
|
|
|
39
39
|
useLargerTiles: 0 !== (tree.flags & TreeFlags.UseLargerTiles),
|
|
40
40
|
disableMagnification: false,
|
|
41
41
|
alwaysSubdivideIncompleteTiles: false,
|
|
42
|
+
enableIndexedEdges: true,
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
TileOptions.fromTreeIdAndContentId = fromTreeIdAndContentId;
|
|
@@ -46,7 +47,7 @@ export var TileOptions;
|
|
|
46
47
|
/** @internal */
|
|
47
48
|
export function parseTileTreeIdAndContentId(treeId, contentId) {
|
|
48
49
|
let idx = 0;
|
|
49
|
-
let type, expansion, animationId,
|
|
50
|
+
let type, expansion, animationId, edges, sectionCut;
|
|
50
51
|
// Skip version and flags, they're handled by TileOptions.fromTreeIdAndContentId
|
|
51
52
|
while (idx < treeId.length && treeId[idx] !== "-")
|
|
52
53
|
idx++;
|
|
@@ -64,13 +65,13 @@ export function parseTileTreeIdAndContentId(treeId, contentId) {
|
|
|
64
65
|
// eslint-disable-next-line prefer-const
|
|
65
66
|
({ idx, animationId } = parseAnimation(idx, treeId, animationId));
|
|
66
67
|
if (type === BatchType.Primary) {
|
|
67
|
-
({ idx,
|
|
68
|
+
({ idx, edges, sectionCut } = parsePrimary(idx, treeId, edges, sectionCut));
|
|
68
69
|
}
|
|
69
70
|
const modelId = treeId.substr(idx);
|
|
70
71
|
if (!Id64.isId64(modelId))
|
|
71
72
|
throw new Error("Invalid tree Id");
|
|
72
73
|
const { flags: treeFlags } = treeFlagsAndFormatVersionFromId(treeId);
|
|
73
|
-
const parsedTreeId = getTreeId(type,
|
|
74
|
+
const parsedTreeId = getTreeId(type, edges, sectionCut, animationId, expansion, (treeFlags & TreeFlags.EnforceDisplayPriority) !== 0 ? true : undefined);
|
|
74
75
|
const options = TileOptions.fromTreeIdAndContentId(treeId, contentId);
|
|
75
76
|
let parsedContentId;
|
|
76
77
|
try {
|
|
@@ -88,11 +89,11 @@ export function parseTileTreeIdAndContentId(treeId, contentId) {
|
|
|
88
89
|
treeId: parsedTreeId,
|
|
89
90
|
};
|
|
90
91
|
}
|
|
91
|
-
function getTreeId(type,
|
|
92
|
+
function getTreeId(type, edges, sectionCut, animationId, expansion, enforceDisplayPriority) {
|
|
92
93
|
if (type === BatchType.Primary)
|
|
93
94
|
return {
|
|
94
95
|
type,
|
|
95
|
-
|
|
96
|
+
edges,
|
|
96
97
|
sectionCut,
|
|
97
98
|
animationId,
|
|
98
99
|
enforceDisplayPriority,
|
|
@@ -104,15 +105,17 @@ function getTreeId(type, edgesRequired, sectionCut, animationId, expansion, enfo
|
|
|
104
105
|
animationId,
|
|
105
106
|
};
|
|
106
107
|
}
|
|
107
|
-
function parsePrimary(idx, treeId,
|
|
108
|
+
function parsePrimary(idx, treeId, edges = EdgeType.None, sectionCut) {
|
|
108
109
|
// Edges
|
|
109
|
-
|
|
110
|
-
if (idx < treeId.length
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
110
|
+
edges = EdgeType.NonIndexed;
|
|
111
|
+
if (idx < treeId.length) {
|
|
112
|
+
const noEdgesStr = "E:0_";
|
|
113
|
+
if (treeId.startsWith(noEdgesStr, idx))
|
|
114
|
+
edges = EdgeType.None;
|
|
115
|
+
else if (treeId.startsWith("E:2_", idx))
|
|
116
|
+
edges = EdgeType.Indexed;
|
|
117
|
+
if (EdgeType.NonIndexed !== edges)
|
|
118
|
+
idx += noEdgesStr.length;
|
|
116
119
|
}
|
|
117
120
|
// Section cut
|
|
118
121
|
if (idx + 1 < treeId.length && treeId[idx] === "S") {
|
|
@@ -125,7 +128,7 @@ function parsePrimary(idx, treeId, edgesRequired, sectionCut) {
|
|
|
125
128
|
throw new Error("Invalid tree Id");
|
|
126
129
|
idx++; // s
|
|
127
130
|
}
|
|
128
|
-
return { idx,
|
|
131
|
+
return { idx, edges, sectionCut };
|
|
129
132
|
}
|
|
130
133
|
function parseClassifier(idx, treeId, expansion) {
|
|
131
134
|
let type;
|
|
@@ -180,6 +183,7 @@ export const defaultTileOptions = Object.freeze({
|
|
|
180
183
|
useLargerTiles: true,
|
|
181
184
|
disableMagnification: false,
|
|
182
185
|
alwaysSubdivideIncompleteTiles: false,
|
|
186
|
+
enableIndexedEdges: true,
|
|
183
187
|
});
|
|
184
188
|
function contentFlagsFromId(id) {
|
|
185
189
|
if (0 === id.length || "-" !== id[0])
|
|
@@ -234,6 +238,18 @@ export var TreeFlags;
|
|
|
234
238
|
TreeFlags[TreeFlags["OptimizeBRepProcessing"] = 4] = "OptimizeBRepProcessing";
|
|
235
239
|
TreeFlags[TreeFlags["UseLargerTiles"] = 8] = "UseLargerTiles";
|
|
236
240
|
})(TreeFlags || (TreeFlags = {}));
|
|
241
|
+
/** Describes the type of edges to include in the graphics for a tile tree.
|
|
242
|
+
* @alpha
|
|
243
|
+
*/
|
|
244
|
+
export var EdgeType;
|
|
245
|
+
(function (EdgeType) {
|
|
246
|
+
/** Omit all edges. */
|
|
247
|
+
EdgeType[EdgeType["None"] = 0] = "None";
|
|
248
|
+
/** Include non-indexed edges, which consume more memory and are less efficient to draw than [[Indexed]] edges, but are compatible with WebGL 1. */
|
|
249
|
+
EdgeType[EdgeType["NonIndexed"] = 1] = "NonIndexed";
|
|
250
|
+
/** Include indexed edges, which use less memory and draw more efficiently than [[NonIndexed]] edges, but require WebGL 2. */
|
|
251
|
+
EdgeType[EdgeType["Indexed"] = 2] = "Indexed";
|
|
252
|
+
})(EdgeType || (EdgeType = {}));
|
|
237
253
|
function animationIdToString(animationId) {
|
|
238
254
|
return `A:${animationId}_`;
|
|
239
255
|
}
|
|
@@ -252,7 +268,7 @@ export function iModelTileTreeIdToString(modelId, treeId, options) {
|
|
|
252
268
|
idStr = `${idStr}${animationIdToString(treeId.animationId)}`;
|
|
253
269
|
else if (treeId.enforceDisplayPriority) // animation and priority are currently mutually exclusive
|
|
254
270
|
flags |= TreeFlags.EnforceDisplayPriority;
|
|
255
|
-
const edges = treeId.
|
|
271
|
+
const edges = treeId.edges !== EdgeType.NonIndexed ? `E:${treeId.edges}_` : "";
|
|
256
272
|
const sectionCut = treeId.sectionCut ? `S${treeId.sectionCut}s` : "";
|
|
257
273
|
idStr = `${idStr}${edges}${sectionCut}`;
|
|
258
274
|
}
|
|
@@ -283,7 +299,7 @@ export function compareIModelTileTreeIds(lhs, rhs) {
|
|
|
283
299
|
// NB: The redundant checks on BatchType below are to satisfy compiler.
|
|
284
300
|
assert(lhs.type === rhs.type);
|
|
285
301
|
if (BatchType.Primary === lhs.type && BatchType.Primary === rhs.type) {
|
|
286
|
-
cmp =
|
|
302
|
+
cmp = compareNumbers(lhs.edges, rhs.edges);
|
|
287
303
|
if (0 === cmp) {
|
|
288
304
|
cmp = compareBooleansOrUndefined(lhs.enforceDisplayPriority, rhs.enforceDisplayPriority);
|
|
289
305
|
if (0 === cmp)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileMetadata.js","sourceRoot":"","sources":["../../../src/tile/TileMetadata.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EACL,MAAM,EAAc,eAAe,EAAE,0BAA0B,EAAE,cAAc,EAAE,yBAAyB,EAAE,IAAI,GACjH,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEzD,mCAAmC;AAEnC,+DAA+D;AAC/D,IAAU,SAAS,CAElB;AAFD,WAAU,SAAS;IACJ,qCAA2B,GAAG,CAAC,CAAC;AAC/C,CAAC,EAFS,SAAS,KAAT,SAAS,QAElB;AA4CD,gBAAgB;AAChB,MAAM,KAAW,WAAW,CAwB3B;AAxBD,WAAiB,WAAW;IAC1B;;;;;OAKG;IACH,SAAgB,sBAAsB,CAAC,MAAc,EAAE,SAAiB;QACtE,MAAM,IAAI,GAAG,+BAA+B,CAAC,MAAM,CAAC,CAAC;QACrD,MAAM,YAAY,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;QAEnD,OAAO;YACL,6BAA6B,EAAE,IAAI,CAAC,OAAO;YAC3C,gBAAgB,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC,eAAe,CAAC;YACrE,qBAAqB,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC,eAAe,CAAC;YAC1E,kBAAkB,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,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B,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,MAAkB,EAAE,KAAgB;QAC9C,MAAM,OAAO,GAAG,0BAA0B,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC9H,OAAO;YACL,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;YAC5C,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;YACpC,SAAS,EAAE,KAAK,CAAC,SAAS;SAC3B,CAAC;IACJ,CAAC;CACF","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/** @packageDocumentation\r\n * @module Tile\r\n */\r\n\r\nimport {\r\n assert, ByteStream, compareBooleans, compareBooleansOrUndefined, compareNumbers, compareStringsOrUndefined, Id64, Id64String,\r\n} from \"@itwin/core-bentley\";\r\nimport { Range3d, Vector3d } from \"@itwin/core-geometry\";\r\nimport { BatchType } from \"../FeatureTable\";\r\nimport { TileProps } from \"../TileProps\";\r\nimport { CurrentImdlVersion, FeatureTableHeader, ImdlFlags, ImdlHeader } from \"./IModelTileIO\";\r\nimport { TileReadError, TileReadStatus } from \"./TileIO\";\r\n\r\n// cspell:ignore imdl mult bitfield\r\n\r\n// NB: These constants correspond to those defined in Tile.cpp.\r\nnamespace Constants {\r\n export const minToleranceRatioMultiplier = 2;\r\n}\r\n\r\n/** Describes an iModel tile tree.\r\n * @internal\r\n */\r\nexport interface TileTreeMetadata {\r\n readonly modelId: Id64String;\r\n readonly is2d: boolean;\r\n readonly contentRange?: Range3d;\r\n readonly tileScreenSize: number;\r\n}\r\n\r\n/** Describes the contents of an iModel tile.\r\n * @internal\r\n */\r\nexport interface TileContentMetadata {\r\n readonly contentRange: Range3d;\r\n readonly isLeaf: boolean;\r\n readonly sizeMultiplier?: number;\r\n readonly emptySubRangeMask: number;\r\n}\r\n\r\n/** Describes an iModel tile.\r\n * @internal\r\n */\r\nexport interface TileMetadata extends TileContentMetadata {\r\n readonly contentId: string;\r\n readonly range: Range3d;\r\n}\r\n\r\n/** @internal */\r\nexport interface TileOptions {\r\n readonly maximumMajorTileFormatVersion: number;\r\n readonly enableInstancing: boolean;\r\n readonly enableImprovedElision: boolean;\r\n readonly ignoreAreaPatterns: boolean;\r\n readonly enableExternalTextures: boolean;\r\n readonly useProjectExtents: boolean;\r\n readonly optimizeBRepProcessing: boolean;\r\n readonly useLargerTiles: boolean;\r\n readonly disableMagnification: boolean;\r\n readonly alwaysSubdivideIncompleteTiles: boolean;\r\n}\r\n\r\n/** @internal */\r\nexport namespace TileOptions {\r\n /** Given the string representation of an [[IModelTileTreeId]] and the contentId of a [Tile]($frontend) belonging to that [TileTree]($frontend),\r\n * compute the [[TileOptions]] that were used to generate the Ids.\r\n * @throws Error if `treeId` or `contentId` are not valid Ids.\r\n * @note `treeId` and `contentId` are assumed to be valid Ids. They are not fully parsed and validated - only the information required by this function is extracted.\r\n * @note `treeId` and `contentId` are assumed to have been produced for version 4 or later of the iMdl tile format.\r\n */\r\n export function fromTreeIdAndContentId(treeId: string, contentId: string): TileOptions {\r\n const tree = treeFlagsAndFormatVersionFromId(treeId);\r\n const contentFlags = contentFlagsFromId(contentId);\r\n\r\n return {\r\n maximumMajorTileFormatVersion: tree.version,\r\n enableInstancing: 0 !== (contentFlags & ContentFlags.AllowInstancing),\r\n enableImprovedElision: 0 !== (contentFlags & ContentFlags.ImprovedElision),\r\n ignoreAreaPatterns: 0 !== (contentFlags & ContentFlags.IgnoreAreaPatterns),\r\n enableExternalTextures: 0 !== (contentFlags & ContentFlags.ExternalTextures),\r\n useProjectExtents: 0 !== (tree.flags & TreeFlags.UseProjectExtents),\r\n optimizeBRepProcessing: 0 !== (tree.flags & TreeFlags.OptimizeBRepProcessing),\r\n useLargerTiles: 0 !== (tree.flags & TreeFlags.UseLargerTiles),\r\n disableMagnification: false,\r\n alwaysSubdivideIncompleteTiles: false,\r\n };\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function parseTileTreeIdAndContentId(treeId: string, contentId: string): { modelId: Id64String, treeId: IModelTileTreeId, contentId: ContentIdSpec, options: TileOptions } {\r\n let idx = 0;\r\n let type: BatchType,\r\n expansion: number | undefined,\r\n animationId: string | undefined,\r\n edgesRequired: boolean | undefined,\r\n sectionCut: string | undefined;\r\n\r\n // Skip version and flags, they're handled by TileOptions.fromTreeIdAndContentId\r\n while (idx < treeId.length && treeId[idx] !== \"-\")\r\n idx++;\r\n idx++; // -\r\n if (idx >= treeId.length)\r\n throw new Error(\"Invalid tree Id\");\r\n\r\n if (treeId[idx] === \"C\") {\r\n // PlanarClassifier or VolumeClassifier\r\n ({ idx, type, expansion } = parseClassifier(idx, treeId, expansion));\r\n } else {\r\n type = BatchType.Primary;\r\n }\r\n\r\n // Animation\r\n // eslint-disable-next-line prefer-const\r\n ({ idx, animationId } = parseAnimation(idx, treeId, animationId));\r\n\r\n if (type === BatchType.Primary) {\r\n ({ idx, edgesRequired, sectionCut } = parsePrimary(idx, treeId, edgesRequired, sectionCut));\r\n }\r\n\r\n const modelId = treeId.substr(idx);\r\n if (!Id64.isId64(modelId))\r\n throw new Error(\"Invalid tree Id\");\r\n\r\n const { flags: treeFlags } = treeFlagsAndFormatVersionFromId(treeId);\r\n const parsedTreeId = getTreeId(type, edgesRequired, sectionCut, animationId, expansion, (treeFlags & TreeFlags.EnforceDisplayPriority) !== 0 ? true : undefined);\r\n const options = TileOptions.fromTreeIdAndContentId(treeId, contentId);\r\n\r\n let parsedContentId: ContentIdSpec;\r\n try {\r\n parsedContentId = ContentIdProvider.create(true, options).specFromId(contentId);\r\n } catch (e) {\r\n throw new Error(\"Invalid content Id\");\r\n }\r\n\r\n if (Object.keys(parsedContentId).some((key) => parsedContentId.hasOwnProperty(key) && typeof parsedContentId[key as keyof ContentIdSpec] === \"number\" && !Number.isFinite(parsedContentId[key as keyof ContentIdSpec])))\r\n throw new Error(\"Invalid content Id\");\r\n\r\n return {\r\n contentId: parsedContentId,\r\n modelId,\r\n options,\r\n treeId: parsedTreeId,\r\n };\r\n}\r\n\r\nfunction getTreeId(type: BatchType, edgesRequired?: boolean, sectionCut?: string, animationId?: string, expansion?: number, enforceDisplayPriority?: boolean): IModelTileTreeId {\r\n if (type === BatchType.Primary)\r\n return {\r\n type,\r\n edgesRequired,\r\n sectionCut,\r\n animationId,\r\n enforceDisplayPriority,\r\n } as PrimaryTileTreeId;\r\n else\r\n return {\r\n type,\r\n expansion,\r\n animationId,\r\n } as ClassifierTileTreeId;\r\n}\r\n\r\nfunction parsePrimary(idx: number, treeId: string, edgesRequired: boolean | undefined, sectionCut: string | undefined) {\r\n // Edges\r\n const edgesStr = \"E:0_\";\r\n if (idx < treeId.length && treeId.startsWith(edgesStr, idx)) {\r\n edgesRequired = false;\r\n idx += edgesStr.length;\r\n } else {\r\n edgesRequired = true;\r\n }\r\n\r\n // Section cut\r\n if (idx + 1 < treeId.length && treeId[idx] === \"S\") {\r\n idx++; // S\r\n sectionCut = \"\";\r\n while (idx < treeId.length && treeId[idx] !== \"s\") {\r\n sectionCut += treeId[idx++];\r\n }\r\n if (idx === treeId.length)\r\n throw new Error(\"Invalid tree Id\");\r\n idx++; // s\r\n }\r\n return { idx, edgesRequired, sectionCut };\r\n}\r\n\r\nfunction parseClassifier(idx: number, treeId: string, expansion: number | undefined) {\r\n let type: BatchType;\r\n idx++; // C\r\n if (idx + 1 < treeId.length && treeId[idx] === \"P\" && treeId[idx + 1] === \":\") {\r\n type = BatchType.PlanarClassifier;\r\n idx += 2; // P:\r\n } else if (idx < treeId.length && treeId[idx] === \":\") {\r\n type = BatchType.VolumeClassifier;\r\n idx++; // :\r\n } else {\r\n throw new Error(\"Invalid tree Id\");\r\n }\r\n\r\n // C: or CP: is always followed by {expansion}_\r\n let expansionStr = \"\";\r\n while (idx < treeId.length && (treeId[idx] >= \"0\" && treeId[idx] <= \"9\" || treeId[idx] === \".\")) {\r\n expansionStr += treeId[idx++];\r\n }\r\n\r\n if (idx === treeId.length || treeId[idx] !== \"_\")\r\n throw new Error(\"Invalid tree Id\");\r\n idx++; // _\r\n\r\n expansion = Number.parseFloat(expansionStr);\r\n return { idx, type, expansion };\r\n}\r\n\r\nfunction parseAnimation(idx: number, treeId: string, animationId: string | undefined) {\r\n if (idx < treeId.length && treeId[idx] === \"A\") {\r\n if (idx + 1 < treeId.length && treeId[idx + 1] !== \":\")\r\n throw new Error(\"Invalid tree Id\");\r\n idx += 2;\r\n\r\n // Parse animation id\r\n animationId = \"\";\r\n while (idx < treeId.length && treeId[idx] !== \"_\") {\r\n animationId += treeId[idx++];\r\n }\r\n\r\n if (!Id64.isId64(animationId) || idx === treeId.length)\r\n throw new Error(\"Invalid tree Id\");\r\n idx++; // _\r\n }\r\n\r\n return { idx, animationId };\r\n}\r\n\r\n/** @internal */\r\nexport const defaultTileOptions: TileOptions = Object.freeze({\r\n maximumMajorTileFormatVersion: CurrentImdlVersion.Major,\r\n enableInstancing: true,\r\n enableImprovedElision: true,\r\n ignoreAreaPatterns: false,\r\n enableExternalTextures: true,\r\n useProjectExtents: true,\r\n optimizeBRepProcessing: true,\r\n useLargerTiles: true,\r\n disableMagnification: false,\r\n alwaysSubdivideIncompleteTiles: false,\r\n});\r\n\r\nfunction contentFlagsFromId(id: string): ContentFlags {\r\n if (0 === id.length || \"-\" !== id[0])\r\n throw new Error(\"Invalid content Id\");\r\n\r\n // V4: -flags-d-i-j-k-m - version in tree Id\r\n const end = id.indexOf(\"-\", 1);\r\n if (-1 !== end) {\r\n const flags = Number.parseInt(id.substring(1, end), 16);\r\n if (!Number.isNaN(flags))\r\n return flags;\r\n }\r\n\r\n throw new Error(\"Invalid content Id\");\r\n}\r\n\r\nfunction treeFlagsAndFormatVersionFromId(id: string): { flags: TreeFlags, version: number } {\r\n if (0 === id.length)\r\n throw new Error(\"Invalid tree Id\");\r\n\r\n let parts = id.split(\"-\");\r\n if (parts.length > 0) {\r\n parts = parts[0].split(\"_\");\r\n if (parts.length === 2) {\r\n const version = Number.parseInt(parts[0], 16);\r\n const flags = Number.parseInt(parts[1], 16);\r\n if (!Number.isNaN(version) || !Number.isNaN(flags))\r\n return { version, flags };\r\n }\r\n }\r\n\r\n throw new Error(\"Invalid tree Id\");\r\n}\r\n\r\n/** @internal */\r\nexport function getMaximumMajorTileFormatVersion(maxMajorVersion: number, formatVersion?: number): number {\r\n // The `formatVersion` input is from the backend, telling us precisely the maximum major+minor version it can produce.\r\n // Ensure we do not request tiles of a newer major version than backend can supply or it can read; and also limit major version\r\n // to that optionally configured by the app.\r\n let majorVersion = maxMajorVersion;\r\n if (undefined !== formatVersion)\r\n majorVersion = Math.min((formatVersion >>> 0x10), majorVersion);\r\n\r\n // Version number less than 1 is invalid - ignore\r\n majorVersion = Math.max(majorVersion, 1);\r\n\r\n // Version number greater than current known version ignored\r\n majorVersion = Math.min(majorVersion, CurrentImdlVersion.Major);\r\n\r\n // Version numbers are integers - round down\r\n return Math.max(Math.floor(majorVersion), 1);\r\n}\r\n\r\n/** Flags controlling the structure of a tile tree. The flags are part of the tile tree's Id.\r\n * @alpha\r\n */\r\nexport enum TreeFlags {\r\n None = 0,\r\n UseProjectExtents = 1 << 0, // Use project extents as the basis of the tile tree's range.\r\n EnforceDisplayPriority = 1 << 1, // For 3d plan projection models, group graphics into layers based on subcategory.\r\n OptimizeBRepProcessing = 1 << 2, // Use an optimized pipeline for producing facets from BRep entities.\r\n UseLargerTiles = 1 << 3, // Produce tiles of larger size in screen pixels.\r\n}\r\n\r\n/** Describes a tile tree used to draw the contents of a model, possibly with embedded animation.\r\n * @internal\r\n */\r\nexport interface PrimaryTileTreeId {\r\n /** Describes the type of tile tree. */\r\n type: BatchType.Primary;\r\n /** Whether to include edges in tile content. */\r\n edgesRequired: boolean;\r\n /** Id of the [DisplayStyle]($backend) or [RenderTimeline]($backend) element holding the [[RenderSchedule]] script to be applied to the tiles. */\r\n animationId?: Id64String;\r\n /** If true, meshes within the tiles will be grouped into nodes based on the display priority associated with their subcategories,\r\n * for ensuring the graphics display with correct priority.\r\n */\r\n enforceDisplayPriority?: boolean;\r\n /** If defined, the compact string representation of a clip vector applied to the tiles to produce cut geometry at the intersections with the clip planes.\r\n * Any geometry *not* intersecting the clip planes is omitted from the tiles.\r\n * @see [ClipVector.toCompactString[($core-geometry).\r\n */\r\n sectionCut?: string;\r\n}\r\n\r\n/** Describes a tile tree that can classify the contents of other tile trees using the model's geometry.\r\n * @internal\r\n */\r\nexport interface ClassifierTileTreeId {\r\n type: BatchType.VolumeClassifier | BatchType.PlanarClassifier;\r\n expansion: number;\r\n animationId?: Id64String;\r\n}\r\n\r\nfunction animationIdToString(animationId: Id64String): string {\r\n return `A:${animationId}_`;\r\n}\r\n\r\n/** Describes the Id of an iModel tile tree.\r\n * @internal\r\n */\r\nexport type IModelTileTreeId = PrimaryTileTreeId | ClassifierTileTreeId;\r\n\r\n/** Convert a tile tree Id to its string representation.\r\n * @internal\r\n */\r\nexport function iModelTileTreeIdToString(modelId: Id64String, treeId: IModelTileTreeId, options: TileOptions): string {\r\n let idStr = \"\";\r\n let flags = options.useProjectExtents ? TreeFlags.UseProjectExtents : TreeFlags.None;\r\n if (options.optimizeBRepProcessing)\r\n flags |= TreeFlags.OptimizeBRepProcessing;\r\n\r\n if (options.useLargerTiles)\r\n flags |= TreeFlags.UseLargerTiles;\r\n\r\n if (BatchType.Primary === treeId.type) {\r\n if (undefined !== treeId.animationId)\r\n idStr = `${idStr}${animationIdToString(treeId.animationId)}`;\r\n else if (treeId.enforceDisplayPriority) // animation and priority are currently mutually exclusive\r\n flags |= TreeFlags.EnforceDisplayPriority;\r\n\r\n const edges = treeId.edgesRequired ? \"\" : \"E:0_\";\r\n const sectionCut = treeId.sectionCut ? `S${treeId.sectionCut}s` : \"\";\r\n idStr = `${idStr}${edges}${sectionCut}`;\r\n } else {\r\n const typeStr = BatchType.PlanarClassifier === treeId.type ? \"CP\" : \"C\";\r\n idStr = `${idStr + typeStr}:${treeId.expansion.toFixed(6)}_`;\r\n\r\n if (BatchType.VolumeClassifier === treeId.type)\r\n flags |= TreeFlags.UseProjectExtents;\r\n\r\n if (undefined !== treeId.animationId)\r\n idStr = `${idStr}${animationIdToString(treeId.animationId)}`;\r\n }\r\n\r\n const version = getMaximumMajorTileFormatVersion(options.maximumMajorTileFormatVersion);\r\n if (version >= 4) {\r\n const prefix = `${version.toString(16)}_${flags.toString(16)}-`;\r\n idStr = prefix + idStr;\r\n }\r\n\r\n return idStr + modelId;\r\n}\r\n\r\n/** Ordinal comparison of two tile tree Ids, e.g., for use in sorted containers.\r\n * @internal\r\n */\r\nexport function compareIModelTileTreeIds(lhs: IModelTileTreeId, rhs: IModelTileTreeId): number {\r\n let cmp = compareNumbers(lhs.type, rhs.type);\r\n if (0 === cmp)\r\n cmp = compareStringsOrUndefined(lhs.animationId, rhs.animationId);\r\n\r\n if (0 !== cmp)\r\n return cmp;\r\n\r\n // NB: The redundant checks on BatchType below are to satisfy compiler.\r\n assert(lhs.type === rhs.type);\r\n if (BatchType.Primary === lhs.type && BatchType.Primary === rhs.type) {\r\n cmp = compareBooleans(lhs.edgesRequired, rhs.edgesRequired);\r\n if (0 === cmp) {\r\n cmp = compareBooleansOrUndefined(lhs.enforceDisplayPriority, rhs.enforceDisplayPriority);\r\n if (0 === cmp)\r\n cmp = compareStringsOrUndefined(lhs.sectionCut, rhs.sectionCut);\r\n }\r\n } else if (BatchType.Primary !== lhs.type && BatchType.Primary !== rhs.type) {\r\n cmp = compareNumbers(lhs.expansion, rhs.expansion);\r\n }\r\n\r\n return cmp;\r\n}\r\n\r\n/** Flags controlling how tile content is produced. The flags are part of the ContentId.\r\n * @alpha\r\n */\r\nexport enum ContentFlags {\r\n None = 0,\r\n AllowInstancing = 1 << 0,\r\n ImprovedElision = 1 << 1,\r\n IgnoreAreaPatterns = 1 << 2,\r\n ExternalTextures = 1 << 3,\r\n}\r\n\r\n/** Describes the components of a tile's content Id.\r\n *\r\n * The depth specifies how many subdivisions from the root tile are to be performed to reach the sub-volume of interest.\r\n *\r\n * The i, j, and k parameters specify how to subdivide the tile's volume. Each sub-division is performed along the longest axis of the\r\n * volume. The volume is first sub-divided based on `i`, then the result sub-divided based on `j`, and finally that result sub-divided\r\n * based on `k`.\r\n *\r\n * The multiplier is an integer - generally a power of two - multiplied by the screen size of a tile (512 pixels) used to\r\n * produce a higher-resolution tile for the same volume.\r\n * @internal\r\n */\r\ninterface ContentIdSpec {\r\n depth: number;\r\n i: number;\r\n j: number;\r\n k: number;\r\n multiplier: number;\r\n}\r\n\r\n/** Contains logic for working with tile content Ids according to a specific content Id scheme. Which scheme is used depends on\r\n * the major version of the tile format.\r\n * @internal\r\n */\r\nexport abstract class ContentIdProvider {\r\n public readonly majorFormatVersion: number;\r\n public readonly contentFlags: ContentFlags;\r\n\r\n protected constructor(formatVersion: number, contentFlags: ContentFlags) {\r\n this.majorFormatVersion = formatVersion;\r\n this.contentFlags = contentFlags;\r\n }\r\n\r\n public get rootContentId(): string {\r\n return this.computeId(0, 0, 0, 0, 1);\r\n }\r\n\r\n public idFromParentAndMultiplier(parentId: string, multiplier: number): string {\r\n const lastSepPos = parentId.lastIndexOf(this._separator);\r\n assert(-1 !== lastSepPos);\r\n return parentId.substring(0, lastSepPos + 1) + multiplier.toString(16);\r\n }\r\n\r\n public specFromId(id: string): ContentIdSpec {\r\n const parts = id.split(this._separator);\r\n const len = parts.length;\r\n assert(len >= 5);\r\n return {\r\n depth: parseInt(parts[len - 5], 16),\r\n i: parseInt(parts[len - 4], 16),\r\n j: parseInt(parts[len - 3], 16),\r\n k: parseInt(parts[len - 2], 16),\r\n multiplier: parseInt(parts[len - 1], 16),\r\n };\r\n }\r\n\r\n public idFromSpec(spec: ContentIdSpec): string {\r\n return this.computeId(spec.depth, spec.i, spec.j, spec.k, spec.multiplier);\r\n }\r\n\r\n protected join(depth: number, i: number, j: number, k: number, mult: number): string {\r\n const sep = this._separator;\r\n return depth.toString(16) + sep + i.toString(16) + sep + j.toString(16) + sep + k.toString(16) + sep + mult.toString(16);\r\n }\r\n\r\n protected abstract get _separator(): string;\r\n protected abstract computeId(depth: number, i: number, j: number, k: number, mult: number): string;\r\n\r\n /** formatVersion is the maximum major version supported by the back-end supplying the tile tree.\r\n * Must ensure front-end does not request tiles of a format the back-end cannot supply, and back-end does\r\n * not supply tiles of a format the front-end doesn't recognize.\r\n */\r\n public static create(allowInstancing: boolean, options: TileOptions, formatVersion?: number): ContentIdProvider {\r\n const majorVersion = getMaximumMajorTileFormatVersion(options.maximumMajorTileFormatVersion, formatVersion);\r\n assert(majorVersion > 0);\r\n assert(Math.floor(majorVersion) === majorVersion);\r\n switch (majorVersion) {\r\n case 0:\r\n case 1:\r\n return new ContentIdV1Provider(majorVersion);\r\n case 2:\r\n case 3:\r\n return new ContentIdV2Provider(majorVersion, allowInstancing, options);\r\n default:\r\n return new ContentIdV4Provider(allowInstancing, options, majorVersion);\r\n }\r\n }\r\n}\r\n\r\n/** The original (major version 1) tile format used a content Id scheme of the format\r\n * `depth/i/j/k/multiplier`.\r\n * @internal\r\n */\r\nclass ContentIdV1Provider extends ContentIdProvider {\r\n public constructor(majorVersion: number) {\r\n super(majorVersion, ContentFlags.None);\r\n }\r\n\r\n protected get _separator() { return \"/\"; }\r\n protected computeId(depth: number, i: number, j: number, k: number, mult: number): string {\r\n return this.join(depth, i, j, k, mult);\r\n }\r\n}\r\n\r\n/** Tile formats 2 and 3 use a content Id scheme encoding styling flags and the major format version\r\n * into the content Id, of the format `_majorVersion_flags_depth_i_j_k_multiplier`.\r\n * @internal\r\n */\r\nclass ContentIdV2Provider extends ContentIdProvider {\r\n private readonly _prefix: string;\r\n\r\n public constructor(majorVersion: number, allowInstancing: boolean, options: TileOptions) {\r\n const flags = (allowInstancing && options.enableInstancing) ? ContentFlags.AllowInstancing : ContentFlags.None;\r\n super(majorVersion, flags);\r\n this._prefix = this._separator + majorVersion.toString(16) + this._separator + flags.toString(16) + this._separator;\r\n }\r\n\r\n protected get _separator() { return \"_\"; }\r\n protected computeId(depth: number, i: number, j: number, k: number, mult: number): string {\r\n return this._prefix + this.join(depth, i, j, k, mult);\r\n }\r\n}\r\n\r\n/** Tile formats 4+ encode styling flags but not major format version. (The version is specified by the tile tree's Id).\r\n * Format: `-flags-depth-i-j-k-multiplier`.\r\n * @internal\r\n */\r\nclass ContentIdV4Provider extends ContentIdProvider {\r\n private readonly _prefix: string;\r\n\r\n public constructor(allowInstancing: boolean, options: TileOptions, majorVersion: number) {\r\n let flags = (allowInstancing && options.enableInstancing) ? ContentFlags.AllowInstancing : ContentFlags.None;\r\n if (options.enableImprovedElision)\r\n flags = flags | ContentFlags.ImprovedElision;\r\n\r\n if (options.ignoreAreaPatterns)\r\n flags = flags | ContentFlags.IgnoreAreaPatterns;\r\n\r\n if (options.enableExternalTextures)\r\n flags = flags | ContentFlags.ExternalTextures;\r\n\r\n super(majorVersion, flags);\r\n this._prefix = this._separator + flags.toString(16) + this._separator;\r\n }\r\n\r\n protected get _separator() { return \"-\"; }\r\n protected computeId(depth: number, i: number, j: number, k: number, mult: number): string {\r\n return this._prefix + this.join(depth, i, j, k, mult);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function bisectTileRange3d(range: Range3d, takeUpper: boolean): void {\r\n const diag = range.diagonal();\r\n const pt = takeUpper ? range.high : range.low;\r\n if (diag.x > diag.y && diag.x > diag.z)\r\n pt.x = (range.low.x + range.high.x) / 2.0;\r\n else if (diag.y > diag.z)\r\n pt.y = (range.low.y + range.high.y) / 2.0;\r\n else\r\n pt.z = (range.low.z + range.high.z) / 2.0;\r\n}\r\n\r\n/** @internal */\r\nexport function bisectTileRange2d(range: Range3d, takeUpper: boolean): void {\r\n const diag = range.diagonal();\r\n const pt = takeUpper ? range.high : range.low;\r\n if (diag.x > diag.y)\r\n pt.x = (range.low.x + range.high.x) / 2.0;\r\n else\r\n pt.y = (range.low.y + range.high.y) / 2.0;\r\n}\r\n\r\n/** Given a description of a tile, compute the ranges which would result from sub-dividing its range into 4 or 8 sub-volumes.\r\n * @internal\r\n */\r\nexport function computeChildTileRanges(tile: TileMetadata, root: TileTreeMetadata): Array<{ range: Range3d, isEmpty: boolean }> {\r\n const emptyMask = tile.emptySubRangeMask;\r\n const is2d = root.is2d;\r\n const bisectRange = is2d ? bisectTileRange2d : bisectTileRange3d;\r\n\r\n const ranges: Array<{ range: Range3d, isEmpty: boolean }> = [];\r\n for (let i = 0; i < 2; i++) {\r\n for (let j = 0; j < 2; j++) {\r\n for (let k = 0; k < (is2d ? 1 : 2); k++) {\r\n const emptyBit = 1 << (i + j * 2 + k * 4);\r\n const isEmpty = 0 !== (emptyMask & emptyBit);\r\n\r\n const range = tile.range.clone();\r\n bisectRange(range, 0 === i);\r\n bisectRange(range, 0 === j);\r\n if (!is2d)\r\n bisectRange(range, 0 === k);\r\n\r\n ranges.push({ range, isEmpty });\r\n }\r\n }\r\n }\r\n\r\n return ranges;\r\n}\r\n\r\n/** Given a description of the parent tile, obtain the properties of its child tiles, and the number of empty children.\r\n * @internal\r\n */\r\nexport function computeChildTileProps(parent: TileMetadata, idProvider: ContentIdProvider, root: TileTreeMetadata): { children: TileProps[], numEmpty: number } {\r\n let numEmpty = 0;\r\n const children: TileProps[] = [];\r\n\r\n // Leaf nodes have no children\r\n if (parent.isLeaf)\r\n return { children, numEmpty };\r\n\r\n // One child, same volume as parent, but higher-resolution.\r\n if (undefined !== parent.sizeMultiplier) {\r\n const sizeMultiplier = parent.sizeMultiplier * 2;\r\n const contentId = idProvider.idFromParentAndMultiplier(parent.contentId, sizeMultiplier);\r\n children.push({\r\n contentId,\r\n range: parent.range,\r\n contentRange: parent.contentRange,\r\n sizeMultiplier,\r\n isLeaf: false,\r\n maximumSize: root.tileScreenSize,\r\n });\r\n\r\n return { children, numEmpty };\r\n }\r\n\r\n // Sub-divide parent's range into 4 (for 2d trees) or 8 (for 3d trees) child tiles.\r\n const parentSpec = idProvider.specFromId(parent.contentId);\r\n const childSpec: ContentIdSpec = { ...parentSpec };\r\n childSpec.depth = parentSpec.depth + 1;\r\n\r\n // This mask is a bitfield in which an 'on' bit indicates sub-volume containing no geometry.\r\n // Don't bother creating children or requesting content for such empty volumes.\r\n const emptyMask = parent.emptySubRangeMask;\r\n\r\n // Spatial tree range == project extents; content range == model range.\r\n // Trivially reject children whose ranges are entirely outside model range.\r\n let treeContentRange = root.contentRange;\r\n if (undefined !== treeContentRange && treeContentRange.containsRange(parent.range)) {\r\n // Parent is wholly within model range - don't bother testing child ranges against it.\r\n treeContentRange = undefined;\r\n }\r\n\r\n const is2d = root.is2d;\r\n const bisectRange = is2d ? bisectTileRange2d : bisectTileRange3d;\r\n for (let i = 0; i < 2; i++) {\r\n for (let j = 0; j < 2; j++) {\r\n for (let k = 0; k < (is2d ? 1 : 2); k++) {\r\n const emptyBit = 1 << (i + j * 2 + k * 4);\r\n if (0 !== (emptyMask & emptyBit)) {\r\n // volume is known to contain no geometry.\r\n ++numEmpty;\r\n continue;\r\n }\r\n\r\n const range = parent.range.clone();\r\n bisectRange(range, 0 === i);\r\n bisectRange(range, 0 === j);\r\n if (!is2d)\r\n bisectRange(range, 0 === k);\r\n\r\n if (undefined !== treeContentRange && !range.intersectsRange(treeContentRange)) {\r\n // volume is within project extents but entirely outside model range\r\n ++numEmpty;\r\n continue;\r\n }\r\n\r\n childSpec.i = parentSpec.i * 2 + i;\r\n childSpec.j = parentSpec.j * 2 + j;\r\n childSpec.k = parentSpec.k * 2 + k;\r\n\r\n const childId = idProvider.idFromSpec(childSpec);\r\n children.push({ contentId: childId, range, maximumSize: root.tileScreenSize });\r\n }\r\n }\r\n }\r\n\r\n return { children, numEmpty };\r\n}\r\n\r\n/** @internal */\r\nexport interface TileContentDescription extends TileContentMetadata {\r\n readonly featureTableStartPos: number;\r\n}\r\n\r\n/** Deserializes tile content metadata.\r\n * @throws [[TileReadError]]\r\n * @internal\r\n */\r\nexport function readTileContentDescription(stream: ByteStream, sizeMultiplier: number | undefined, is2d: boolean, options: TileOptions, isVolumeClassifier: boolean): TileContentDescription {\r\n stream.reset();\r\n\r\n const header = new ImdlHeader(stream);\r\n if (!header.isValid)\r\n throw new TileReadError(TileReadStatus.InvalidHeader);\r\n else if (!header.isReadableVersion)\r\n throw new TileReadError(TileReadStatus.NewerMajorVersion);\r\n\r\n // Skip the feature table.\r\n const featureTableStartPos = stream.curPos;\r\n const ftHeader = FeatureTableHeader.readFrom(stream);\r\n if (undefined === ftHeader)\r\n throw new TileReadError(TileReadStatus.InvalidFeatureTable);\r\n\r\n stream.curPos = featureTableStartPos + ftHeader.length;\r\n\r\n // Determine subdivision based on header data.\r\n const completeTile = 0 === (header.flags & ImdlFlags.Incomplete);\r\n const emptyTile = completeTile && 0 === header.numElementsIncluded && 0 === header.numElementsExcluded;\r\n let isLeaf = (emptyTile || isVolumeClassifier); // Current classifier algorithm supports only a single tile.\r\n if (!isLeaf) {\r\n // Non-spatial (2d) models are of arbitrary scale and contain geometry like line work and especially text which\r\n // can be adversely affected by quantization issues when zooming in closely.\r\n const maxLeafTolerance = 1.0;\r\n\r\n // Must sub-divide if tile explicitly specifies...\r\n let canSkipSubdivision = 0 === (header.flags & ImdlFlags.DisallowMagnification);\r\n // ...or in 2d, or if app explicitly disabled magnification, or tolerance large enough to risk quantization error...\r\n canSkipSubdivision = canSkipSubdivision && !is2d && !options.disableMagnification && header.tolerance <= maxLeafTolerance;\r\n // ...or app specifies incomplete tiles must always be sub-divided.\r\n canSkipSubdivision = canSkipSubdivision && (completeTile || !options.alwaysSubdivideIncompleteTiles);\r\n if (canSkipSubdivision) {\r\n const minElementsPerTile = 100;\r\n if (completeTile && 0 === header.numElementsExcluded && header.numElementsIncluded <= minElementsPerTile) {\r\n const containsCurves = 0 !== (header.flags & ImdlFlags.ContainsCurves);\r\n if (!containsCurves)\r\n isLeaf = true;\r\n else if (undefined === sizeMultiplier)\r\n sizeMultiplier = 1.0;\r\n } else if (undefined === sizeMultiplier && header.numElementsIncluded + header.numElementsExcluded <= minElementsPerTile) {\r\n sizeMultiplier = 1.0;\r\n }\r\n }\r\n }\r\n\r\n return {\r\n featureTableStartPos,\r\n contentRange: header.contentRange,\r\n isLeaf,\r\n sizeMultiplier,\r\n emptySubRangeMask: header.emptySubRanges,\r\n };\r\n}\r\n\r\nconst scratchRangeDiagonal = new Vector3d();\r\n\r\n/** Compute the chord tolerance for the specified tile of the given range with the specified size multiplier.\r\n * @internal\r\n */\r\nexport function computeTileChordTolerance(tile: TileMetadata, is3d: boolean, tileScreenSize: number): number {\r\n if (tile.range.isNull)\r\n return 0;\r\n\r\n const diagonal = tile.range.diagonal(scratchRangeDiagonal);\r\n const diagDist = is3d ? diagonal.magnitude() : diagonal.magnitudeXY();\r\n\r\n const mult = Math.max(tile.sizeMultiplier ?? 1, 1);\r\n return diagDist / (tileScreenSize * Constants.minToleranceRatioMultiplier * Math.max(1, mult));\r\n}\r\n\r\n/** Deserializes tile metadata.\r\n * @internal\r\n */\r\nexport class TileMetadataReader {\r\n private readonly _is2d: boolean;\r\n private readonly _isVolumeClassifier: boolean;\r\n private readonly _options: TileOptions;\r\n\r\n public constructor(type: BatchType, is2d: boolean, options: TileOptions) {\r\n this._is2d = is2d;\r\n this._isVolumeClassifier = BatchType.VolumeClassifier === type;\r\n this._options = options;\r\n }\r\n\r\n /** Produce metadata from the specified tile content.\r\n * @throws [[TileReadError]]\r\n */\r\n public read(stream: ByteStream, props: TileProps): TileMetadata {\r\n const content = readTileContentDescription(stream, props.sizeMultiplier, this._is2d, this._options, this._isVolumeClassifier);\r\n return {\r\n contentRange: content.contentRange,\r\n isLeaf: content.isLeaf,\r\n sizeMultiplier: content.sizeMultiplier,\r\n emptySubRangeMask: content.emptySubRangeMask,\r\n range: Range3d.fromJSON(props.range),\r\n contentId: props.contentId,\r\n };\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"TileMetadata.js","sourceRoot":"","sources":["../../../src/tile/TileMetadata.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EACL,MAAM,EAAc,0BAA0B,EAAE,cAAc,EAAE,yBAAyB,EAAE,IAAI,GAChG,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEzD,mCAAmC;AAEnC,+DAA+D;AAC/D,IAAU,SAAS,CAElB;AAFD,WAAU,SAAS;IACJ,qCAA2B,GAAG,CAAC,CAAC;AAC/C,CAAC,EAFS,SAAS,KAAT,SAAS,QAElB;AA6CD,gBAAgB;AAChB,MAAM,KAAW,WAAW,CAyB3B;AAzBD,WAAiB,WAAW;IAC1B;;;;;OAKG;IACH,SAAgB,sBAAsB,CAAC,MAAc,EAAE,SAAiB;QACtE,MAAM,IAAI,GAAG,+BAA+B,CAAC,MAAM,CAAC,CAAC;QACrD,MAAM,YAAY,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;QAEnD,OAAO;YACL,6BAA6B,EAAE,IAAI,CAAC,OAAO;YAC3C,gBAAgB,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC,eAAe,CAAC;YACrE,qBAAqB,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC,eAAe,CAAC;YAC1E,kBAAkB,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC,kBAA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MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAA,IAAI,CAAC,cAAc,mCAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACnD,OAAO,QAAQ,GAAG,CAAC,cAAc,GAAG,SAAS,CAAC,2BAA2B,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AACjG,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAK7B,YAAmB,IAAe,EAAE,IAAa,EAAE,OAAoB;QACrE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC,gBAAgB,KAAK,IAAI,CAAC;QAC/D,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,MAAkB,EAAE,KAAgB;QAC9C,MAAM,OAAO,GAAG,0BAA0B,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC9H,OAAO;YACL,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;YAC5C,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;YACpC,SAAS,EAAE,KAAK,CAAC,SAAS;SAC3B,CAAC;IACJ,CAAC;CACF","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/** @packageDocumentation\r\n * @module Tile\r\n */\r\n\r\nimport {\r\n assert, ByteStream, compareBooleansOrUndefined, compareNumbers, compareStringsOrUndefined, Id64, Id64String,\r\n} from \"@itwin/core-bentley\";\r\nimport { Range3d, Vector3d } from \"@itwin/core-geometry\";\r\nimport { BatchType } from \"../FeatureTable\";\r\nimport { TileProps } from \"../TileProps\";\r\nimport { CurrentImdlVersion, FeatureTableHeader, ImdlFlags, ImdlHeader } from \"./IModelTileIO\";\r\nimport { TileReadError, TileReadStatus } from \"./TileIO\";\r\n\r\n// cspell:ignore imdl mult bitfield\r\n\r\n// NB: These constants correspond to those defined in Tile.cpp.\r\nnamespace Constants {\r\n export const minToleranceRatioMultiplier = 2;\r\n}\r\n\r\n/** Describes an iModel tile tree.\r\n * @internal\r\n */\r\nexport interface TileTreeMetadata {\r\n readonly modelId: Id64String;\r\n readonly is2d: boolean;\r\n readonly contentRange?: Range3d;\r\n readonly tileScreenSize: number;\r\n}\r\n\r\n/** Describes the contents of an iModel tile.\r\n * @internal\r\n */\r\nexport interface TileContentMetadata {\r\n readonly contentRange: Range3d;\r\n readonly isLeaf: boolean;\r\n readonly sizeMultiplier?: number;\r\n readonly emptySubRangeMask: number;\r\n}\r\n\r\n/** Describes an iModel tile.\r\n * @internal\r\n */\r\nexport interface TileMetadata extends TileContentMetadata {\r\n readonly contentId: string;\r\n readonly range: Range3d;\r\n}\r\n\r\n/** @internal */\r\nexport interface TileOptions {\r\n readonly maximumMajorTileFormatVersion: number;\r\n readonly enableInstancing: boolean;\r\n readonly enableImprovedElision: boolean;\r\n readonly ignoreAreaPatterns: boolean;\r\n readonly enableExternalTextures: boolean;\r\n readonly useProjectExtents: boolean;\r\n readonly optimizeBRepProcessing: boolean;\r\n readonly useLargerTiles: boolean;\r\n readonly disableMagnification: boolean;\r\n readonly alwaysSubdivideIncompleteTiles: boolean;\r\n readonly enableIndexedEdges: boolean;\r\n}\r\n\r\n/** @internal */\r\nexport namespace TileOptions {\r\n /** Given the string representation of an [[IModelTileTreeId]] and the contentId of a [Tile]($frontend) belonging to that [TileTree]($frontend),\r\n * compute the [[TileOptions]] that were used to generate the Ids.\r\n * @throws Error if `treeId` or `contentId` are not valid Ids.\r\n * @note `treeId` and `contentId` are assumed to be valid Ids. They are not fully parsed and validated - only the information required by this function is extracted.\r\n * @note `treeId` and `contentId` are assumed to have been produced for version 4 or later of the iMdl tile format.\r\n */\r\n export function fromTreeIdAndContentId(treeId: string, contentId: string): TileOptions {\r\n const tree = treeFlagsAndFormatVersionFromId(treeId);\r\n const contentFlags = contentFlagsFromId(contentId);\r\n\r\n return {\r\n maximumMajorTileFormatVersion: tree.version,\r\n enableInstancing: 0 !== (contentFlags & ContentFlags.AllowInstancing),\r\n enableImprovedElision: 0 !== (contentFlags & ContentFlags.ImprovedElision),\r\n ignoreAreaPatterns: 0 !== (contentFlags & ContentFlags.IgnoreAreaPatterns),\r\n enableExternalTextures: 0 !== (contentFlags & ContentFlags.ExternalTextures),\r\n useProjectExtents: 0 !== (tree.flags & TreeFlags.UseProjectExtents),\r\n optimizeBRepProcessing: 0 !== (tree.flags & TreeFlags.OptimizeBRepProcessing),\r\n useLargerTiles: 0 !== (tree.flags & TreeFlags.UseLargerTiles),\r\n disableMagnification: false,\r\n alwaysSubdivideIncompleteTiles: false,\r\n enableIndexedEdges: true,\r\n };\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function parseTileTreeIdAndContentId(treeId: string, contentId: string): { modelId: Id64String, treeId: IModelTileTreeId, contentId: ContentIdSpec, options: TileOptions } {\r\n let idx = 0;\r\n let type: BatchType,\r\n expansion: number | undefined,\r\n animationId: string | undefined,\r\n edges: EdgeType | undefined,\r\n sectionCut: string | undefined;\r\n\r\n // Skip version and flags, they're handled by TileOptions.fromTreeIdAndContentId\r\n while (idx < treeId.length && treeId[idx] !== \"-\")\r\n idx++;\r\n idx++; // -\r\n if (idx >= treeId.length)\r\n throw new Error(\"Invalid tree Id\");\r\n\r\n if (treeId[idx] === \"C\") {\r\n // PlanarClassifier or VolumeClassifier\r\n ({ idx, type, expansion } = parseClassifier(idx, treeId, expansion));\r\n } else {\r\n type = BatchType.Primary;\r\n }\r\n\r\n // Animation\r\n // eslint-disable-next-line prefer-const\r\n ({ idx, animationId } = parseAnimation(idx, treeId, animationId));\r\n\r\n if (type === BatchType.Primary) {\r\n ({ idx, edges, sectionCut } = parsePrimary(idx, treeId, edges, sectionCut));\r\n }\r\n\r\n const modelId = treeId.substr(idx);\r\n if (!Id64.isId64(modelId))\r\n throw new Error(\"Invalid tree Id\");\r\n\r\n const { flags: treeFlags } = treeFlagsAndFormatVersionFromId(treeId);\r\n const parsedTreeId = getTreeId(type, edges, sectionCut, animationId, expansion, (treeFlags & TreeFlags.EnforceDisplayPriority) !== 0 ? true : undefined);\r\n const options = TileOptions.fromTreeIdAndContentId(treeId, contentId);\r\n\r\n let parsedContentId: ContentIdSpec;\r\n try {\r\n parsedContentId = ContentIdProvider.create(true, options).specFromId(contentId);\r\n } catch (e) {\r\n throw new Error(\"Invalid content Id\");\r\n }\r\n\r\n if (Object.keys(parsedContentId).some((key) => parsedContentId.hasOwnProperty(key) && typeof parsedContentId[key as keyof ContentIdSpec] === \"number\" && !Number.isFinite(parsedContentId[key as keyof ContentIdSpec])))\r\n throw new Error(\"Invalid content Id\");\r\n\r\n return {\r\n contentId: parsedContentId,\r\n modelId,\r\n options,\r\n treeId: parsedTreeId,\r\n };\r\n}\r\n\r\nfunction getTreeId(type: BatchType, edges?: EdgeType, sectionCut?: string, animationId?: string, expansion?: number, enforceDisplayPriority?: boolean): IModelTileTreeId {\r\n if (type === BatchType.Primary)\r\n return {\r\n type,\r\n edges,\r\n sectionCut,\r\n animationId,\r\n enforceDisplayPriority,\r\n } as PrimaryTileTreeId;\r\n else\r\n return {\r\n type,\r\n expansion,\r\n animationId,\r\n } as ClassifierTileTreeId;\r\n}\r\n\r\nfunction parsePrimary(idx: number, treeId: string, edges: EdgeType = EdgeType.None, sectionCut: string | undefined) {\r\n // Edges\r\n edges = EdgeType.NonIndexed;\r\n if (idx < treeId.length ) {\r\n const noEdgesStr = \"E:0_\";\r\n if (treeId.startsWith(noEdgesStr, idx))\r\n edges = EdgeType.None;\r\n else if (treeId.startsWith(\"E:2_\", idx))\r\n edges = EdgeType.Indexed;\r\n\r\n if (EdgeType.NonIndexed !== edges)\r\n idx += noEdgesStr.length;\r\n }\r\n\r\n // Section cut\r\n if (idx + 1 < treeId.length && treeId[idx] === \"S\") {\r\n idx++; // S\r\n sectionCut = \"\";\r\n while (idx < treeId.length && treeId[idx] !== \"s\") {\r\n sectionCut += treeId[idx++];\r\n }\r\n if (idx === treeId.length)\r\n throw new Error(\"Invalid tree Id\");\r\n idx++; // s\r\n }\r\n return { idx, edges, sectionCut };\r\n}\r\n\r\nfunction parseClassifier(idx: number, treeId: string, expansion: number | undefined) {\r\n let type: BatchType;\r\n idx++; // C\r\n if (idx + 1 < treeId.length && treeId[idx] === \"P\" && treeId[idx + 1] === \":\") {\r\n type = BatchType.PlanarClassifier;\r\n idx += 2; // P:\r\n } else if (idx < treeId.length && treeId[idx] === \":\") {\r\n type = BatchType.VolumeClassifier;\r\n idx++; // :\r\n } else {\r\n throw new Error(\"Invalid tree Id\");\r\n }\r\n\r\n // C: or CP: is always followed by {expansion}_\r\n let expansionStr = \"\";\r\n while (idx < treeId.length && (treeId[idx] >= \"0\" && treeId[idx] <= \"9\" || treeId[idx] === \".\")) {\r\n expansionStr += treeId[idx++];\r\n }\r\n\r\n if (idx === treeId.length || treeId[idx] !== \"_\")\r\n throw new Error(\"Invalid tree Id\");\r\n idx++; // _\r\n\r\n expansion = Number.parseFloat(expansionStr);\r\n return { idx, type, expansion };\r\n}\r\n\r\nfunction parseAnimation(idx: number, treeId: string, animationId: string | undefined) {\r\n if (idx < treeId.length && treeId[idx] === \"A\") {\r\n if (idx + 1 < treeId.length && treeId[idx + 1] !== \":\")\r\n throw new Error(\"Invalid tree Id\");\r\n idx += 2;\r\n\r\n // Parse animation id\r\n animationId = \"\";\r\n while (idx < treeId.length && treeId[idx] !== \"_\") {\r\n animationId += treeId[idx++];\r\n }\r\n\r\n if (!Id64.isId64(animationId) || idx === treeId.length)\r\n throw new Error(\"Invalid tree Id\");\r\n idx++; // _\r\n }\r\n\r\n return { idx, animationId };\r\n}\r\n\r\n/** @internal */\r\nexport const defaultTileOptions: TileOptions = Object.freeze({\r\n maximumMajorTileFormatVersion: CurrentImdlVersion.Major,\r\n enableInstancing: true,\r\n enableImprovedElision: true,\r\n ignoreAreaPatterns: false,\r\n enableExternalTextures: true,\r\n useProjectExtents: true,\r\n optimizeBRepProcessing: true,\r\n useLargerTiles: true,\r\n disableMagnification: false,\r\n alwaysSubdivideIncompleteTiles: false,\r\n enableIndexedEdges: true,\r\n});\r\n\r\nfunction contentFlagsFromId(id: string): ContentFlags {\r\n if (0 === id.length || \"-\" !== id[0])\r\n throw new Error(\"Invalid content Id\");\r\n\r\n // V4: -flags-d-i-j-k-m - version in tree Id\r\n const end = id.indexOf(\"-\", 1);\r\n if (-1 !== end) {\r\n const flags = Number.parseInt(id.substring(1, end), 16);\r\n if (!Number.isNaN(flags))\r\n return flags;\r\n }\r\n\r\n throw new Error(\"Invalid content Id\");\r\n}\r\n\r\nfunction treeFlagsAndFormatVersionFromId(id: string): { flags: TreeFlags, version: number } {\r\n if (0 === id.length)\r\n throw new Error(\"Invalid tree Id\");\r\n\r\n let parts = id.split(\"-\");\r\n if (parts.length > 0) {\r\n parts = parts[0].split(\"_\");\r\n if (parts.length === 2) {\r\n const version = Number.parseInt(parts[0], 16);\r\n const flags = Number.parseInt(parts[1], 16);\r\n if (!Number.isNaN(version) || !Number.isNaN(flags))\r\n return { version, flags };\r\n }\r\n }\r\n\r\n throw new Error(\"Invalid tree Id\");\r\n}\r\n\r\n/** @internal */\r\nexport function getMaximumMajorTileFormatVersion(maxMajorVersion: number, formatVersion?: number): number {\r\n // The `formatVersion` input is from the backend, telling us precisely the maximum major+minor version it can produce.\r\n // Ensure we do not request tiles of a newer major version than backend can supply or it can read; and also limit major version\r\n // to that optionally configured by the app.\r\n let majorVersion = maxMajorVersion;\r\n if (undefined !== formatVersion)\r\n majorVersion = Math.min((formatVersion >>> 0x10), majorVersion);\r\n\r\n // Version number less than 1 is invalid - ignore\r\n majorVersion = Math.max(majorVersion, 1);\r\n\r\n // Version number greater than current known version ignored\r\n majorVersion = Math.min(majorVersion, CurrentImdlVersion.Major);\r\n\r\n // Version numbers are integers - round down\r\n return Math.max(Math.floor(majorVersion), 1);\r\n}\r\n\r\n/** Flags controlling the structure of a tile tree. The flags are part of the tile tree's Id.\r\n * @alpha\r\n */\r\nexport enum TreeFlags {\r\n None = 0,\r\n UseProjectExtents = 1 << 0, // Use project extents as the basis of the tile tree's range.\r\n EnforceDisplayPriority = 1 << 1, // For 3d plan projection models, group graphics into layers based on subcategory.\r\n OptimizeBRepProcessing = 1 << 2, // Use an optimized pipeline for producing facets from BRep entities.\r\n UseLargerTiles = 1 << 3, // Produce tiles of larger size in screen pixels.\r\n}\r\n\r\n/** Describes the type of edges to include in the graphics for a tile tree.\r\n * @alpha\r\n */\r\nexport enum EdgeType {\r\n /** Omit all edges. */\r\n None = 0,\r\n /** Include non-indexed edges, which consume more memory and are less efficient to draw than [[Indexed]] edges, but are compatible with WebGL 1. */\r\n NonIndexed = 1,\r\n /** Include indexed edges, which use less memory and draw more efficiently than [[NonIndexed]] edges, but require WebGL 2. */\r\n Indexed = 2,\r\n}\r\n\r\n/** Describes a tile tree used to draw the contents of a model, possibly with embedded animation.\r\n * @internal\r\n */\r\nexport interface PrimaryTileTreeId {\r\n /** Describes the type of tile tree. */\r\n type: BatchType.Primary;\r\n /** The type of edges to include in tile content. */\r\n edges: EdgeType;\r\n /** Id of the [DisplayStyle]($backend) or [RenderTimeline]($backend) element holding the [[RenderSchedule]] script to be applied to the tiles. */\r\n animationId?: Id64String;\r\n /** If true, meshes within the tiles will be grouped into nodes based on the display priority associated with their subcategories,\r\n * for ensuring the graphics display with correct priority.\r\n */\r\n enforceDisplayPriority?: boolean;\r\n /** If defined, the compact string representation of a clip vector applied to the tiles to produce cut geometry at the intersections with the clip planes.\r\n * Any geometry *not* intersecting the clip planes is omitted from the tiles.\r\n * @see [ClipVector.toCompactString[($core-geometry).\r\n */\r\n sectionCut?: string;\r\n}\r\n\r\n/** Describes a tile tree that can classify the contents of other tile trees using the model's geometry.\r\n * @internal\r\n */\r\nexport interface ClassifierTileTreeId {\r\n type: BatchType.VolumeClassifier | BatchType.PlanarClassifier;\r\n expansion: number;\r\n animationId?: Id64String;\r\n}\r\n\r\nfunction animationIdToString(animationId: Id64String): string {\r\n return `A:${animationId}_`;\r\n}\r\n\r\n/** Describes the Id of an iModel tile tree.\r\n * @internal\r\n */\r\nexport type IModelTileTreeId = PrimaryTileTreeId | ClassifierTileTreeId;\r\n\r\n/** Convert a tile tree Id to its string representation.\r\n * @internal\r\n */\r\nexport function iModelTileTreeIdToString(modelId: Id64String, treeId: IModelTileTreeId, options: TileOptions): string {\r\n let idStr = \"\";\r\n let flags = options.useProjectExtents ? TreeFlags.UseProjectExtents : TreeFlags.None;\r\n if (options.optimizeBRepProcessing)\r\n flags |= TreeFlags.OptimizeBRepProcessing;\r\n\r\n if (options.useLargerTiles)\r\n flags |= TreeFlags.UseLargerTiles;\r\n\r\n if (BatchType.Primary === treeId.type) {\r\n if (undefined !== treeId.animationId)\r\n idStr = `${idStr}${animationIdToString(treeId.animationId)}`;\r\n else if (treeId.enforceDisplayPriority) // animation and priority are currently mutually exclusive\r\n flags |= TreeFlags.EnforceDisplayPriority;\r\n\r\n const edges = treeId.edges !== EdgeType.NonIndexed ? `E:${treeId.edges}_` : \"\";\r\n const sectionCut = treeId.sectionCut ? `S${treeId.sectionCut}s` : \"\";\r\n idStr = `${idStr}${edges}${sectionCut}`;\r\n } else {\r\n const typeStr = BatchType.PlanarClassifier === treeId.type ? \"CP\" : \"C\";\r\n idStr = `${idStr + typeStr}:${treeId.expansion.toFixed(6)}_`;\r\n\r\n if (BatchType.VolumeClassifier === treeId.type)\r\n flags |= TreeFlags.UseProjectExtents;\r\n\r\n if (undefined !== treeId.animationId)\r\n idStr = `${idStr}${animationIdToString(treeId.animationId)}`;\r\n }\r\n\r\n const version = getMaximumMajorTileFormatVersion(options.maximumMajorTileFormatVersion);\r\n if (version >= 4) {\r\n const prefix = `${version.toString(16)}_${flags.toString(16)}-`;\r\n idStr = prefix + idStr;\r\n }\r\n\r\n return idStr + modelId;\r\n}\r\n\r\n/** Ordinal comparison of two tile tree Ids, e.g., for use in sorted containers.\r\n * @internal\r\n */\r\nexport function compareIModelTileTreeIds(lhs: IModelTileTreeId, rhs: IModelTileTreeId): number {\r\n let cmp = compareNumbers(lhs.type, rhs.type);\r\n if (0 === cmp)\r\n cmp = compareStringsOrUndefined(lhs.animationId, rhs.animationId);\r\n\r\n if (0 !== cmp)\r\n return cmp;\r\n\r\n // NB: The redundant checks on BatchType below are to satisfy compiler.\r\n assert(lhs.type === rhs.type);\r\n if (BatchType.Primary === lhs.type && BatchType.Primary === rhs.type) {\r\n cmp = compareNumbers(lhs.edges, rhs.edges);\r\n if (0 === cmp) {\r\n cmp = compareBooleansOrUndefined(lhs.enforceDisplayPriority, rhs.enforceDisplayPriority);\r\n if (0 === cmp)\r\n cmp = compareStringsOrUndefined(lhs.sectionCut, rhs.sectionCut);\r\n }\r\n } else if (BatchType.Primary !== lhs.type && BatchType.Primary !== rhs.type) {\r\n cmp = compareNumbers(lhs.expansion, rhs.expansion);\r\n }\r\n\r\n return cmp;\r\n}\r\n\r\n/** Flags controlling how tile content is produced. The flags are part of the ContentId.\r\n * @alpha\r\n */\r\nexport enum ContentFlags {\r\n None = 0,\r\n AllowInstancing = 1 << 0,\r\n ImprovedElision = 1 << 1,\r\n IgnoreAreaPatterns = 1 << 2,\r\n ExternalTextures = 1 << 3,\r\n}\r\n\r\n/** Describes the components of a tile's content Id.\r\n *\r\n * The depth specifies how many subdivisions from the root tile are to be performed to reach the sub-volume of interest.\r\n *\r\n * The i, j, and k parameters specify how to subdivide the tile's volume. Each sub-division is performed along the longest axis of the\r\n * volume. The volume is first sub-divided based on `i`, then the result sub-divided based on `j`, and finally that result sub-divided\r\n * based on `k`.\r\n *\r\n * The multiplier is an integer - generally a power of two - multiplied by the screen size of a tile (512 pixels) used to\r\n * produce a higher-resolution tile for the same volume.\r\n * @internal\r\n */\r\ninterface ContentIdSpec {\r\n depth: number;\r\n i: number;\r\n j: number;\r\n k: number;\r\n multiplier: number;\r\n}\r\n\r\n/** Contains logic for working with tile content Ids according to a specific content Id scheme. Which scheme is used depends on\r\n * the major version of the tile format.\r\n * @internal\r\n */\r\nexport abstract class ContentIdProvider {\r\n public readonly majorFormatVersion: number;\r\n public readonly contentFlags: ContentFlags;\r\n\r\n protected constructor(formatVersion: number, contentFlags: ContentFlags) {\r\n this.majorFormatVersion = formatVersion;\r\n this.contentFlags = contentFlags;\r\n }\r\n\r\n public get rootContentId(): string {\r\n return this.computeId(0, 0, 0, 0, 1);\r\n }\r\n\r\n public idFromParentAndMultiplier(parentId: string, multiplier: number): string {\r\n const lastSepPos = parentId.lastIndexOf(this._separator);\r\n assert(-1 !== lastSepPos);\r\n return parentId.substring(0, lastSepPos + 1) + multiplier.toString(16);\r\n }\r\n\r\n public specFromId(id: string): ContentIdSpec {\r\n const parts = id.split(this._separator);\r\n const len = parts.length;\r\n assert(len >= 5);\r\n return {\r\n depth: parseInt(parts[len - 5], 16),\r\n i: parseInt(parts[len - 4], 16),\r\n j: parseInt(parts[len - 3], 16),\r\n k: parseInt(parts[len - 2], 16),\r\n multiplier: parseInt(parts[len - 1], 16),\r\n };\r\n }\r\n\r\n public idFromSpec(spec: ContentIdSpec): string {\r\n return this.computeId(spec.depth, spec.i, spec.j, spec.k, spec.multiplier);\r\n }\r\n\r\n protected join(depth: number, i: number, j: number, k: number, mult: number): string {\r\n const sep = this._separator;\r\n return depth.toString(16) + sep + i.toString(16) + sep + j.toString(16) + sep + k.toString(16) + sep + mult.toString(16);\r\n }\r\n\r\n protected abstract get _separator(): string;\r\n protected abstract computeId(depth: number, i: number, j: number, k: number, mult: number): string;\r\n\r\n /** formatVersion is the maximum major version supported by the back-end supplying the tile tree.\r\n * Must ensure front-end does not request tiles of a format the back-end cannot supply, and back-end does\r\n * not supply tiles of a format the front-end doesn't recognize.\r\n */\r\n public static create(allowInstancing: boolean, options: TileOptions, formatVersion?: number): ContentIdProvider {\r\n const majorVersion = getMaximumMajorTileFormatVersion(options.maximumMajorTileFormatVersion, formatVersion);\r\n assert(majorVersion > 0);\r\n assert(Math.floor(majorVersion) === majorVersion);\r\n switch (majorVersion) {\r\n case 0:\r\n case 1:\r\n return new ContentIdV1Provider(majorVersion);\r\n case 2:\r\n case 3:\r\n return new ContentIdV2Provider(majorVersion, allowInstancing, options);\r\n default:\r\n return new ContentIdV4Provider(allowInstancing, options, majorVersion);\r\n }\r\n }\r\n}\r\n\r\n/** The original (major version 1) tile format used a content Id scheme of the format\r\n * `depth/i/j/k/multiplier`.\r\n * @internal\r\n */\r\nclass ContentIdV1Provider extends ContentIdProvider {\r\n public constructor(majorVersion: number) {\r\n super(majorVersion, ContentFlags.None);\r\n }\r\n\r\n protected get _separator() { return \"/\"; }\r\n protected computeId(depth: number, i: number, j: number, k: number, mult: number): string {\r\n return this.join(depth, i, j, k, mult);\r\n }\r\n}\r\n\r\n/** Tile formats 2 and 3 use a content Id scheme encoding styling flags and the major format version\r\n * into the content Id, of the format `_majorVersion_flags_depth_i_j_k_multiplier`.\r\n * @internal\r\n */\r\nclass ContentIdV2Provider extends ContentIdProvider {\r\n private readonly _prefix: string;\r\n\r\n public constructor(majorVersion: number, allowInstancing: boolean, options: TileOptions) {\r\n const flags = (allowInstancing && options.enableInstancing) ? ContentFlags.AllowInstancing : ContentFlags.None;\r\n super(majorVersion, flags);\r\n this._prefix = this._separator + majorVersion.toString(16) + this._separator + flags.toString(16) + this._separator;\r\n }\r\n\r\n protected get _separator() { return \"_\"; }\r\n protected computeId(depth: number, i: number, j: number, k: number, mult: number): string {\r\n return this._prefix + this.join(depth, i, j, k, mult);\r\n }\r\n}\r\n\r\n/** Tile formats 4+ encode styling flags but not major format version. (The version is specified by the tile tree's Id).\r\n * Format: `-flags-depth-i-j-k-multiplier`.\r\n * @internal\r\n */\r\nclass ContentIdV4Provider extends ContentIdProvider {\r\n private readonly _prefix: string;\r\n\r\n public constructor(allowInstancing: boolean, options: TileOptions, majorVersion: number) {\r\n let flags = (allowInstancing && options.enableInstancing) ? ContentFlags.AllowInstancing : ContentFlags.None;\r\n if (options.enableImprovedElision)\r\n flags = flags | ContentFlags.ImprovedElision;\r\n\r\n if (options.ignoreAreaPatterns)\r\n flags = flags | ContentFlags.IgnoreAreaPatterns;\r\n\r\n if (options.enableExternalTextures)\r\n flags = flags | ContentFlags.ExternalTextures;\r\n\r\n super(majorVersion, flags);\r\n this._prefix = this._separator + flags.toString(16) + this._separator;\r\n }\r\n\r\n protected get _separator() { return \"-\"; }\r\n protected computeId(depth: number, i: number, j: number, k: number, mult: number): string {\r\n return this._prefix + this.join(depth, i, j, k, mult);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function bisectTileRange3d(range: Range3d, takeUpper: boolean): void {\r\n const diag = range.diagonal();\r\n const pt = takeUpper ? range.high : range.low;\r\n if (diag.x > diag.y && diag.x > diag.z)\r\n pt.x = (range.low.x + range.high.x) / 2.0;\r\n else if (diag.y > diag.z)\r\n pt.y = (range.low.y + range.high.y) / 2.0;\r\n else\r\n pt.z = (range.low.z + range.high.z) / 2.0;\r\n}\r\n\r\n/** @internal */\r\nexport function bisectTileRange2d(range: Range3d, takeUpper: boolean): void {\r\n const diag = range.diagonal();\r\n const pt = takeUpper ? range.high : range.low;\r\n if (diag.x > diag.y)\r\n pt.x = (range.low.x + range.high.x) / 2.0;\r\n else\r\n pt.y = (range.low.y + range.high.y) / 2.0;\r\n}\r\n\r\n/** Given a description of a tile, compute the ranges which would result from sub-dividing its range into 4 or 8 sub-volumes.\r\n * @internal\r\n */\r\nexport function computeChildTileRanges(tile: TileMetadata, root: TileTreeMetadata): Array<{ range: Range3d, isEmpty: boolean }> {\r\n const emptyMask = tile.emptySubRangeMask;\r\n const is2d = root.is2d;\r\n const bisectRange = is2d ? bisectTileRange2d : bisectTileRange3d;\r\n\r\n const ranges: Array<{ range: Range3d, isEmpty: boolean }> = [];\r\n for (let i = 0; i < 2; i++) {\r\n for (let j = 0; j < 2; j++) {\r\n for (let k = 0; k < (is2d ? 1 : 2); k++) {\r\n const emptyBit = 1 << (i + j * 2 + k * 4);\r\n const isEmpty = 0 !== (emptyMask & emptyBit);\r\n\r\n const range = tile.range.clone();\r\n bisectRange(range, 0 === i);\r\n bisectRange(range, 0 === j);\r\n if (!is2d)\r\n bisectRange(range, 0 === k);\r\n\r\n ranges.push({ range, isEmpty });\r\n }\r\n }\r\n }\r\n\r\n return ranges;\r\n}\r\n\r\n/** Given a description of the parent tile, obtain the properties of its child tiles, and the number of empty children.\r\n * @internal\r\n */\r\nexport function computeChildTileProps(parent: TileMetadata, idProvider: ContentIdProvider, root: TileTreeMetadata): { children: TileProps[], numEmpty: number } {\r\n let numEmpty = 0;\r\n const children: TileProps[] = [];\r\n\r\n // Leaf nodes have no children\r\n if (parent.isLeaf)\r\n return { children, numEmpty };\r\n\r\n // One child, same volume as parent, but higher-resolution.\r\n if (undefined !== parent.sizeMultiplier) {\r\n const sizeMultiplier = parent.sizeMultiplier * 2;\r\n const contentId = idProvider.idFromParentAndMultiplier(parent.contentId, sizeMultiplier);\r\n children.push({\r\n contentId,\r\n range: parent.range,\r\n contentRange: parent.contentRange,\r\n sizeMultiplier,\r\n isLeaf: false,\r\n maximumSize: root.tileScreenSize,\r\n });\r\n\r\n return { children, numEmpty };\r\n }\r\n\r\n // Sub-divide parent's range into 4 (for 2d trees) or 8 (for 3d trees) child tiles.\r\n const parentSpec = idProvider.specFromId(parent.contentId);\r\n const childSpec: ContentIdSpec = { ...parentSpec };\r\n childSpec.depth = parentSpec.depth + 1;\r\n\r\n // This mask is a bitfield in which an 'on' bit indicates sub-volume containing no geometry.\r\n // Don't bother creating children or requesting content for such empty volumes.\r\n const emptyMask = parent.emptySubRangeMask;\r\n\r\n // Spatial tree range == project extents; content range == model range.\r\n // Trivially reject children whose ranges are entirely outside model range.\r\n let treeContentRange = root.contentRange;\r\n if (undefined !== treeContentRange && treeContentRange.containsRange(parent.range)) {\r\n // Parent is wholly within model range - don't bother testing child ranges against it.\r\n treeContentRange = undefined;\r\n }\r\n\r\n const is2d = root.is2d;\r\n const bisectRange = is2d ? bisectTileRange2d : bisectTileRange3d;\r\n for (let i = 0; i < 2; i++) {\r\n for (let j = 0; j < 2; j++) {\r\n for (let k = 0; k < (is2d ? 1 : 2); k++) {\r\n const emptyBit = 1 << (i + j * 2 + k * 4);\r\n if (0 !== (emptyMask & emptyBit)) {\r\n // volume is known to contain no geometry.\r\n ++numEmpty;\r\n continue;\r\n }\r\n\r\n const range = parent.range.clone();\r\n bisectRange(range, 0 === i);\r\n bisectRange(range, 0 === j);\r\n if (!is2d)\r\n bisectRange(range, 0 === k);\r\n\r\n if (undefined !== treeContentRange && !range.intersectsRange(treeContentRange)) {\r\n // volume is within project extents but entirely outside model range\r\n ++numEmpty;\r\n continue;\r\n }\r\n\r\n childSpec.i = parentSpec.i * 2 + i;\r\n childSpec.j = parentSpec.j * 2 + j;\r\n childSpec.k = parentSpec.k * 2 + k;\r\n\r\n const childId = idProvider.idFromSpec(childSpec);\r\n children.push({ contentId: childId, range, maximumSize: root.tileScreenSize });\r\n }\r\n }\r\n }\r\n\r\n return { children, numEmpty };\r\n}\r\n\r\n/** @internal */\r\nexport interface TileContentDescription extends TileContentMetadata {\r\n readonly featureTableStartPos: number;\r\n}\r\n\r\n/** Deserializes tile content metadata.\r\n * @throws [[TileReadError]]\r\n * @internal\r\n */\r\nexport function readTileContentDescription(stream: ByteStream, sizeMultiplier: number | undefined, is2d: boolean, options: TileOptions, isVolumeClassifier: boolean): TileContentDescription {\r\n stream.reset();\r\n\r\n const header = new ImdlHeader(stream);\r\n if (!header.isValid)\r\n throw new TileReadError(TileReadStatus.InvalidHeader);\r\n else if (!header.isReadableVersion)\r\n throw new TileReadError(TileReadStatus.NewerMajorVersion);\r\n\r\n // Skip the feature table.\r\n const featureTableStartPos = stream.curPos;\r\n const ftHeader = FeatureTableHeader.readFrom(stream);\r\n if (undefined === ftHeader)\r\n throw new TileReadError(TileReadStatus.InvalidFeatureTable);\r\n\r\n stream.curPos = featureTableStartPos + ftHeader.length;\r\n\r\n // Determine subdivision based on header data.\r\n const completeTile = 0 === (header.flags & ImdlFlags.Incomplete);\r\n const emptyTile = completeTile && 0 === header.numElementsIncluded && 0 === header.numElementsExcluded;\r\n let isLeaf = (emptyTile || isVolumeClassifier); // Current classifier algorithm supports only a single tile.\r\n if (!isLeaf) {\r\n // Non-spatial (2d) models are of arbitrary scale and contain geometry like line work and especially text which\r\n // can be adversely affected by quantization issues when zooming in closely.\r\n const maxLeafTolerance = 1.0;\r\n\r\n // Must sub-divide if tile explicitly specifies...\r\n let canSkipSubdivision = 0 === (header.flags & ImdlFlags.DisallowMagnification);\r\n // ...or in 2d, or if app explicitly disabled magnification, or tolerance large enough to risk quantization error...\r\n canSkipSubdivision = canSkipSubdivision && !is2d && !options.disableMagnification && header.tolerance <= maxLeafTolerance;\r\n // ...or app specifies incomplete tiles must always be sub-divided.\r\n canSkipSubdivision = canSkipSubdivision && (completeTile || !options.alwaysSubdivideIncompleteTiles);\r\n if (canSkipSubdivision) {\r\n const minElementsPerTile = 100;\r\n if (completeTile && 0 === header.numElementsExcluded && header.numElementsIncluded <= minElementsPerTile) {\r\n const containsCurves = 0 !== (header.flags & ImdlFlags.ContainsCurves);\r\n if (!containsCurves)\r\n isLeaf = true;\r\n else if (undefined === sizeMultiplier)\r\n sizeMultiplier = 1.0;\r\n } else if (undefined === sizeMultiplier && header.numElementsIncluded + header.numElementsExcluded <= minElementsPerTile) {\r\n sizeMultiplier = 1.0;\r\n }\r\n }\r\n }\r\n\r\n return {\r\n featureTableStartPos,\r\n contentRange: header.contentRange,\r\n isLeaf,\r\n sizeMultiplier,\r\n emptySubRangeMask: header.emptySubRanges,\r\n };\r\n}\r\n\r\nconst scratchRangeDiagonal = new Vector3d();\r\n\r\n/** Compute the chord tolerance for the specified tile of the given range with the specified size multiplier.\r\n * @internal\r\n */\r\nexport function computeTileChordTolerance(tile: TileMetadata, is3d: boolean, tileScreenSize: number): number {\r\n if (tile.range.isNull)\r\n return 0;\r\n\r\n const diagonal = tile.range.diagonal(scratchRangeDiagonal);\r\n const diagDist = is3d ? diagonal.magnitude() : diagonal.magnitudeXY();\r\n\r\n const mult = Math.max(tile.sizeMultiplier ?? 1, 1);\r\n return diagDist / (tileScreenSize * Constants.minToleranceRatioMultiplier * Math.max(1, mult));\r\n}\r\n\r\n/** Deserializes tile metadata.\r\n * @internal\r\n */\r\nexport class TileMetadataReader {\r\n private readonly _is2d: boolean;\r\n private readonly _isVolumeClassifier: boolean;\r\n private readonly _options: TileOptions;\r\n\r\n public constructor(type: BatchType, is2d: boolean, options: TileOptions) {\r\n this._is2d = is2d;\r\n this._isVolumeClassifier = BatchType.VolumeClassifier === type;\r\n this._options = options;\r\n }\r\n\r\n /** Produce metadata from the specified tile content.\r\n * @throws [[TileReadError]]\r\n */\r\n public read(stream: ByteStream, props: TileProps): TileMetadata {\r\n const content = readTileContentDescription(stream, props.sizeMultiplier, this._is2d, this._options, this._isVolumeClassifier);\r\n return {\r\n contentRange: content.contentRange,\r\n isLeaf: content.isLeaf,\r\n sizeMultiplier: content.sizeMultiplier,\r\n emptySubRangeMask: content.emptySubRangeMask,\r\n range: Range3d.fromJSON(props.range),\r\n contentId: props.contentId,\r\n };\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-common",
|
|
3
|
-
"version": "3.0.0-dev.
|
|
3
|
+
"version": "3.0.0-dev.156",
|
|
4
4
|
"description": "iTwin.js components common to frontend and backend",
|
|
5
5
|
"main": "lib/cjs/core-common.js",
|
|
6
6
|
"module": "lib/esm/core-common.js",
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"js-base64": "^3.6.1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@itwin/core-bentley": "^3.0.0-dev.
|
|
33
|
-
"@itwin/core-geometry": "^3.0.0-dev.
|
|
32
|
+
"@itwin/core-bentley": "^3.0.0-dev.156",
|
|
33
|
+
"@itwin/core-geometry": "^3.0.0-dev.156"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@itwin/build-tools": "3.0.0-dev.
|
|
37
|
-
"@itwin/core-bentley": "3.0.0-dev.
|
|
38
|
-
"@itwin/core-geometry": "3.0.0-dev.
|
|
39
|
-
"@itwin/eslint-plugin": "3.0.0-dev.
|
|
36
|
+
"@itwin/build-tools": "3.0.0-dev.156",
|
|
37
|
+
"@itwin/core-bentley": "3.0.0-dev.156",
|
|
38
|
+
"@itwin/core-geometry": "3.0.0-dev.156",
|
|
39
|
+
"@itwin/eslint-plugin": "3.0.0-dev.156",
|
|
40
40
|
"@types/chai": "^4.1.4",
|
|
41
41
|
"@types/flatbuffers": "~1.10.0",
|
|
42
42
|
"@types/mocha": "^8.2.2",
|