@itwin/core-common
Version:
iTwin.js components common to frontend and backend
248 lines • 10.7 kB
TypeScript
/** @packageDocumentation
* @module Tile
*/
import { ByteStream, Id64String } from "@itwin/core-bentley";
import { Range3d } from "@itwin/core-geometry";
import { BatchType } from "../FeatureTable";
import { TileProps } from "../TileProps";
/** Describes an iModel tile tree.
* @internal
*/
export interface TileTreeMetadata {
readonly modelId: Id64String;
readonly is2d: boolean;
readonly contentRange?: Range3d;
readonly tileScreenSize: number;
}
/** Describes the contents of an iModel tile.
* @internal
*/
export interface TileContentMetadata {
readonly contentRange: Range3d;
readonly isLeaf: boolean;
readonly sizeMultiplier?: number;
readonly emptySubRangeMask: number;
}
/** Describes an iModel tile.
* @internal
*/
export interface TileMetadata extends TileContentMetadata {
readonly contentId: string;
readonly range: Range3d;
}
/** The type of edges to be produced for iMdl tiles.
* @see [[EdgeOptions]].
* @internal
*/
export type TileEdgeType = "compact" | "indexed" | "non-indexed";
/** Describes how edges should be produced for tiles in a tile tree.
* @internal
*/
export interface EdgeOptions {
type: TileEdgeType;
/** For polyfaces that lack edge visibility information, generate edges for all faces; otherwise, infer edges from mesh topology. */
smooth: boolean;
}
/** @internal */
export interface TileOptions {
readonly maximumMajorTileFormatVersion: number;
readonly enableInstancing: boolean;
readonly enableImprovedElision: boolean;
readonly ignoreAreaPatterns: boolean;
readonly enableExternalTextures: boolean;
readonly useProjectExtents: boolean;
readonly expandProjectExtents: boolean;
readonly optimizeBRepProcessing: boolean;
readonly useLargerTiles: boolean;
readonly disableMagnification: boolean;
readonly alwaysSubdivideIncompleteTiles: boolean;
readonly edgeOptions: EdgeOptions;
readonly disablePolyfaceDecimation: boolean;
}
/** @internal */
export declare namespace TileOptions {
/** Given the string representation of an [[IModelTileTreeId]] and the contentId of a [Tile]($frontend) belonging to that [TileTree]($frontend),
* compute the [[TileOptions]] that were used to generate the Ids.
* @throws Error if `treeId` or `contentId` are not valid Ids.
* @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.
* @note `treeId` and `contentId` are assumed to have been produced for version 4 or later of the iMdl tile format.
*/
function fromTreeIdAndContentId(treeId: string, contentId: string): TileOptions;
}
/** The result of [[parseTileTreeIdAndContentId]].
* @internal
*/
export interface ParsedTileTreeIdAndContentId {
modelId: Id64String;
treeId: IModelTileTreeId;
contentId: ContentIdSpec;
options: TileOptions;
}
/** @internal */
export declare function parseTileTreeIdAndContentId(treeId: string, contentId: string): ParsedTileTreeIdAndContentId;
/** @internal */
export declare const defaultTileOptions: TileOptions;
/** @internal */
export declare function getMaximumMajorTileFormatVersion(maxMajorVersion: number, formatVersion?: number): number;
/** Flags controlling the structure of a tile tree. The flags are part of the tile tree's Id.
* @alpha
*/
export declare enum TreeFlags {
None = 0,
UseProjectExtents = 1,// Use project extents as the basis of the tile tree's range.
EnforceDisplayPriority = 2,// For 3d plan projection models, group graphics into layers based on subcategory.
OptimizeBRepProcessing = 4,// Use an optimized pipeline for producing facets from BRep entities.
UseLargerTiles = 8,// Produce tiles of larger size in screen pixels.
ExpandProjectExtents = 16,// If UseProjectExtents, round them up/down to nearest powers of ten.
DisablePolyfaceDecimation = 32
}
/** Describes a tile tree used to draw the contents of a model, possibly with embedded animation.
* @internal
*/
export interface PrimaryTileTreeId {
/** Describes the type of tile tree. */
type: BatchType.Primary;
/** The type of edges to include in tile content. */
edges: EdgeOptions | false;
/** Id of the [DisplayStyle]($backend) or [RenderTimeline]($backend) element holding the [[RenderSchedule]] script to be applied to the tiles. */
animationId?: Id64String;
/** If true, meshes within the tiles will be grouped into nodes based on the display priority associated with their subcategories,
* for ensuring the graphics display with correct priority.
*/
enforceDisplayPriority?: boolean;
/** 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.
* Any geometry *not* intersecting the clip planes is omitted from the tiles.
* @see [ClipVector.toCompactString[($core-geometry).
*/
sectionCut?: string;
disablePolyfaceDecimation?: boolean;
}
/** Describes a tile tree that can classify the contents of other tile trees using the model's geometry.
* @internal
*/
export interface ClassifierTileTreeId {
type: BatchType.VolumeClassifier | BatchType.PlanarClassifier;
expansion: number;
animationId?: Id64String;
disablePolyfaceDecimation?: boolean;
}
/** Describes the Id of an iModel tile tree.
* @internal
*/
export type IModelTileTreeId = PrimaryTileTreeId | ClassifierTileTreeId;
/** Convert a tile tree Id to its string representation.
* @internal
*/
export declare function iModelTileTreeIdToString(modelId: Id64String, treeId: IModelTileTreeId, options: TileOptions): string;
/** Ordinal comparison of two tile tree Ids, e.g., for use in sorted containers.
* @internal
*/
export declare function compareIModelTileTreeIds(lhs: IModelTileTreeId, rhs: IModelTileTreeId): number;
/** Flags controlling how tile content is produced. The flags are part of the ContentId.
* @alpha
*/
export declare enum ContentFlags {
None = 0,
AllowInstancing = 1,
ImprovedElision = 2,
IgnoreAreaPatterns = 4,
ExternalTextures = 8
}
/** Describes the components of a tile's content Id.
*
* The depth specifies how many subdivisions from the root tile are to be performed to reach the sub-volume of interest.
*
* 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
* volume. The volume is first sub-divided based on `i`, then the result sub-divided based on `j`, and finally that result sub-divided
* based on `k`.
*
* The multiplier is an integer - generally a power of two - multiplied by the screen size of a tile (512 pixels) used to
* produce a higher-resolution tile for the same volume.
* @internal
*/
interface ContentIdSpec {
depth: number;
i: number;
j: number;
k: number;
multiplier: number;
}
/** Contains logic for working with tile content Ids according to a specific content Id scheme. Which scheme is used depends on
* the major version of the tile format.
* @internal
*/
export declare abstract class ContentIdProvider {
readonly majorFormatVersion: number;
readonly contentFlags: ContentFlags;
protected constructor(formatVersion: number, contentFlags: ContentFlags);
get rootContentId(): string;
idFromParentAndMultiplier(parentId: string, multiplier: number): string;
specFromId(id: string): ContentIdSpec;
idFromSpec(spec: ContentIdSpec): string;
protected join(depth: number, i: number, j: number, k: number, mult: number): string;
protected abstract get _separator(): string;
protected abstract computeId(depth: number, i: number, j: number, k: number, mult: number): string;
/** formatVersion is the maximum major version supported by the back-end supplying the tile tree.
* Must ensure front-end does not request tiles of a format the back-end cannot supply, and back-end does
* not supply tiles of a format the front-end doesn't recognize.
*/
static create(allowInstancing: boolean, options: TileOptions, formatVersion?: number): ContentIdProvider;
}
/** @internal */
export declare function bisectTileRange3d(range: Range3d, takeUpper: boolean): void;
/** @internal */
export declare function bisectTileRange2d(range: Range3d, takeUpper: boolean): void;
/** Given a description of a tile, compute the ranges which would result from sub-dividing its range into 4 or 8 sub-volumes.
* @internal
*/
export declare function computeChildTileRanges(tile: TileMetadata, root: TileTreeMetadata): Array<{
range: Range3d;
isEmpty: boolean;
}>;
/** Given a description of the parent tile, obtain the properties of its child tiles, and the number of empty children.
* @internal
*/
export declare function computeChildTileProps(parent: TileMetadata, idProvider: ContentIdProvider, root: TileTreeMetadata): {
children: TileProps[];
numEmpty: number;
};
/** @internal */
export interface TileContentDescription extends TileContentMetadata {
readonly featureTableStartPos: number;
}
/** Deserializes tile content metadata.
* @throws [[TileReadError]]
* @internal
* @deprecated in 4.0 - will not be removed until after 2026-06-13. Use decodeTileContentDescription. I think tile agents (or their tests) are using this function.
*/
export declare function readTileContentDescription(stream: ByteStream, sizeMultiplier: number | undefined, is2d: boolean, options: TileOptions, isVolumeClassifier: boolean): TileContentDescription;
/** @internal */
export interface DecodeTileContentDescriptionArgs {
stream: ByteStream;
options: TileOptions;
isVolumeClassifier?: boolean;
is2d?: boolean;
sizeMultiplier?: number;
isLeaf?: boolean;
}
/** @internal */
export declare function decodeTileContentDescription(args: DecodeTileContentDescriptionArgs): TileContentDescription;
/** Compute the chord tolerance for the specified tile of the given range with the specified size multiplier.
* @internal
*/
export declare function computeTileChordTolerance(tile: TileMetadata, is3d: boolean, tileScreenSize: number): number;
/** Deserializes tile metadata.
* @internal
*/
export declare class TileMetadataReader {
private readonly _is2d;
private readonly _isVolumeClassifier;
private readonly _options;
constructor(type: BatchType, is2d: boolean, options: TileOptions);
/** Produce metadata from the specified tile content.
* @throws [[TileReadError]]
*/
read(stream: ByteStream, props: TileProps): TileMetadata;
}
export {};
//# sourceMappingURL=TileMetadata.d.ts.map