Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
900 lines (812 sloc) 39.1 KB
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2019 Bentley Systems, Incorporated. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license terms.
*--------------------------------------------------------------------------------------------*/
/** @module Elements */
import { Id64String, Id64, GuidString, DbOpcode, JsonUtils, IModelStatus } from "@bentley/bentleyjs-core";
import { Transform, Range3d } from "@bentley/geometry-core";
import { DrawingModel } from "./Model";
import { Entity } from "./Entity";
import { IModelDb } from "./IModelDb";
import { SubjectOwnsSubjects } from "./NavigationRelationship";
import {
BisCodeSpec, Code, CodeScopeProps, CodeSpec, Placement3d, Placement2d, AxisAlignedBox3d, GeometryStreamProps, ElementAlignedBox3d,
ElementProps, RelatedElement, GeometricElementProps, TypeDefinition, GeometricElement3dProps, GeometricElement2dProps,
SubjectProps, SheetBorderTemplateProps, SheetTemplateProps, SheetProps, TypeDefinitionElementProps,
InformationPartitionElementProps, DefinitionElementProps, LineStyleProps, GeometryPartProps, EntityMetaData, IModel,
} from "@bentley/imodeljs-common";
/** Elements are the smallest individually identifiable building blocks for modeling the real world in an iModel.
* Each element represents an entity in the real world. Sets of Elements (contained in [[Model]]s) are used to model
* other Elements that represent larger scale real world entities. Using this recursive modeling strategy,
* Elements can represent entities at any scale. Elements can represent physical things or abstract concepts
* or simply be information records.
*
* Every Element has a 64-bit id (inherited from Entity) that uniquely identifies it within an iModel. Every Element also
* has a "code" that identifies its meaning in the real world. Additionally, Elements may have a "federationGuid"
* to hold a GUID, if the element was assigned that GUID by some other federated database. The iModel database enforces
* uniqueness of id, code, and federationGuid.
*
* See:
* * [Element Fundamentals]($docs/bis/intro/element-fundamentals.md)
* * [Working with schemas and elements in TypeScript]($docs/learning/backend/SchemasAndElementsInTypeScript.md)
* * [Creating elements]($docs/learning/backend/CreateElements.md)
* @public
*/
export class Element extends Entity implements ElementProps {
/** @internal */
public static get className(): string { return "Element"; }
/** The ModelId of the [Model]($docs/bis/intro/model-fundamentals.md) containing this element */
public readonly model: Id64String;
/** The [Code]($docs/bis/intro/codes.md) for this element */
public readonly code: Code;
/** The parent element, if present, of this element. */
public parent?: RelatedElement;
/** A [FederationGuid]($docs/bis/intro/element-fundamentals.md#federationguid) assigned to this element by some other federated database */
public federationGuid?: GuidString;
/** A [user-assigned label]($docs/bis/intro/element-fundamentals.md#userlabel) for this element. */
public userLabel?: string;
/** Optional [json properties]($docs/bis/intro/element-fundamentals.md#jsonproperties) of this element. */
public readonly jsonProperties: { [key: string]: any };
/** constructor for Element.
* @internal
*/
constructor(props: ElementProps, iModel: IModelDb) {
super(props, iModel);
this.code = Code.fromJSON(props.code);
this.model = RelatedElement.idFromJson(props.model);
this.parent = RelatedElement.fromJSON(props.parent);
this.federationGuid = props.federationGuid;
this.userLabel = props.userLabel;
this.jsonProperties = Object.assign({}, props.jsonProperties); // make sure we have our own copy
}
public static onInsert(_props: ElementProps, _iModel: IModelDb): IModelStatus { return IModelStatus.Success; }
public static onUpdate(_props: ElementProps, _iModel: IModelDb): IModelStatus { return IModelStatus.Success; }
public static onDelete(_props: ElementProps, _iModel: IModelDb): IModelStatus { return IModelStatus.Success; }
public static onInserted(_props: ElementProps, _iModel: IModelDb): void { }
public static onUpdated(_props: ElementProps, _iModel: IModelDb): void { }
public static onDeleted(_props: ElementProps, _iModel: IModelDb): void { }
public static onBeforeOutputsHandled(_id: Id64String, _iModel: IModelDb): void { }
public static onAllInputsHandled(_id: Id64String, _iModel: IModelDb): void { }
/** Save this Element's properties to an object for serializing to JSON.
* @internal
*/
public toJSON(): ElementProps {
const val = super.toJSON() as ElementProps;
if (Id64.isValid(this.code.spec))
val.code = this.code;
val.model = this.model;
if (this.parent) val.parent = this.parent;
if (this.federationGuid) val.federationGuid = this.federationGuid;
if (this.userLabel) val.userLabel = this.userLabel;
if (Object.keys(this.jsonProperties).length > 0)
val.jsonProperties = this.jsonProperties;
return val;
}
/** Get the class metadata for this element. */
public getClassMetaData(): EntityMetaData | undefined { return this.iModel.classMetaDataRegistry.find(this.classFullName); }
private getAllUserProperties(): any { if (!this.jsonProperties.UserProps) this.jsonProperties.UserProps = new Object(); return this.jsonProperties.UserProps; }
/** Get a set of JSON user properties by namespace */
public getUserProperties(namespace: string) { return this.getAllUserProperties()[namespace]; }
/** Change a set of user JSON properties of this Element by namespace. */
public setUserProperties(nameSpace: string, value: any) { this.getAllUserProperties()[nameSpace] = value; }
/** Remove a set of JSON user properties, specified by namespace, from this Element */
public removeUserProperties(nameSpace: string) { delete this.getAllUserProperties()[nameSpace]; }
/** Get a JSON property of this element, by namespace */
public getJsonProperty(nameSpace: string): any { return this.jsonProperties[nameSpace]; }
public setJsonProperty(nameSpace: string, value: any) { this.jsonProperties[nameSpace] = value; }
/** Get a display label for this Element. By default returns userLabel if present, otherwise code value. */
public getDisplayLabel(): string { return this.userLabel ? this.userLabel : this.code.getValue(); }
/**
* Get a list of HTML strings that describe this Element for the tooltip. Strings will be listed on separate lines in the tooltip.
* Any instances of the pattern `%{tag}` will be replaced by the localized value of tag.
*/
public getToolTipMessage(): string[] {
const addKey = (key: string) => "<b>%{iModelJs:Element." + key + "}:</b> "; // %{iModelJs:Element.xxx} is replaced with localized value of xxx in frontend.
const msg: string[] = [];
const display = this.getDisplayLabel();
msg.push(display ? display : addKey("Id") + this.id + ", " + addKey("Type") + this.className);
if (this.category)
msg.push(addKey("Category") + this.iModel.elements.getElement(this.category).getDisplayLabel());
msg.push(addKey("Model") + this.iModel.elements.getElement(this.model).getDisplayLabel());
return msg;
}
/** Insert this Element into the iModel. */
public insert() { return this.iModel.elements.insertElement(this); }
/** Update this Element in the iModel. */
public update() { this.iModel.elements.updateElement(this); }
/** Delete this Element from the iModel. */
public delete() { this.iModel.elements.deleteElement(this.id); }
/**
* Add a request for locks, code reservations, and anything else that would be needed to carry out the specified operation.
* @param opcode The operation that will be performed on the element.
*/
public buildConcurrencyControlRequest(opcode: DbOpcode) { this.iModel.concurrencyControl.buildRequestForElement(this, opcode); }
}
/** An abstract base class to model real world entities that intrinsically have geometry.
* @public
*/
export abstract class GeometricElement extends Element implements GeometricElementProps {
/** @internal */
public static get className(): string { return "GeometricElement"; }
/** The Id of the [[Category]] for this GeometricElement. */
public category: Id64String;
/** The GeometryStream for this GeometricElement. */
public geom?: GeometryStreamProps;
/** @internal */
public constructor(props: GeometricElementProps, iModel: IModelDb) {
super(props, iModel);
this.category = Id64.fromJSON(props.category);
this.geom = props.geom;
}
/** Type guard for instanceof [[GeometricElement3d]] */
public is3d(): this is GeometricElement3d { return this instanceof GeometricElement3d; }
/** Type guard for instanceof [[GeometricElement2d]] */
public is2d(): this is GeometricElement2d { return this instanceof GeometricElement2d; }
/** Get the [Transform]($geometry) from the Placement of this GeometricElement */
public getPlacementTransform(): Transform { return this.placement.getTransform(); }
public calculateRange3d(): AxisAlignedBox3d { return this.placement.calculateRange(); }
/** @internal */
public toJSON(): GeometricElementProps {
const val = super.toJSON() as GeometricElementProps;
val.category = this.category;
if (this.geom)
val.geom = this.geom;
return val;
}
}
/** An abstract base class to model real world entities that intrinsically have 3d geometry.
* See [how to create a GeometricElement3d]($docs/learning/backend/CreateElements.md#GeometricElement3d).
* @public
*/
export abstract class GeometricElement3d extends GeometricElement implements GeometricElement3dProps {
/** @internal */
public static get className(): string { return "GeometricElement3d"; }
public placement: Placement3d;
public typeDefinition?: TypeDefinition;
/** @internal */
public constructor(props: GeometricElement3dProps, iModel: IModelDb) {
super(props, iModel);
this.placement = Placement3d.fromJSON(props.placement);
if (props.typeDefinition)
this.typeDefinition = TypeDefinition.fromJSON(props.typeDefinition);
}
/** @internal */
public toJSON(): GeometricElement3dProps {
const val = super.toJSON() as GeometricElement3dProps;
val.placement = this.placement;
if (this.typeDefinition)
val.typeDefinition = this.typeDefinition;
return val;
}
}
/** A 3D Graphical Element
* @public
*/
export abstract class GraphicalElement3d extends GeometricElement3d {
/** @internal */
public static get className(): string { return "GraphicalElement3d"; }
/** @internal */
public constructor(props: GeometricElement3dProps, iModel: IModelDb) { super(props, iModel); }
}
/** An abstract base class to model information entities that intrinsically have 2d geometry.
* @public
*/
export abstract class GeometricElement2d extends GeometricElement implements GeometricElement2dProps {
/** @internal */
public static get className(): string { return "GeometricElement2d"; }
public placement: Placement2d;
public typeDefinition?: TypeDefinition;
/** @internal */
public constructor(props: GeometricElement2dProps, iModel: IModelDb) {
super(props, iModel);
this.placement = Placement2d.fromJSON(props.placement);
if (props.typeDefinition)
this.typeDefinition = TypeDefinition.fromJSON(props.typeDefinition);
}
/** @internal */
public toJSON(): GeometricElement2dProps {
const val = super.toJSON() as GeometricElement2dProps;
val.placement = this.placement;
if (this.typeDefinition)
val.typeDefinition = this.typeDefinition;
return val;
}
}
/**An abstract base class for 2d Geometric Elements that are used to convey information within graphical presentations (like drawings).
* @public
*/
export abstract class GraphicalElement2d extends GeometricElement2d {
/** @internal */
public static get className(): string { return "GraphicalElement2d"; }
/** @internal */
public constructor(props: GeometricElement2dProps, iModel: IModelDb) { super(props, iModel); }
}
/** 2d element used to annotate drawings and sheets.
* @public
*/
export class AnnotationElement2d extends GraphicalElement2d {
/** @internal */
public static get className(): string { return "AnnotationElement2d"; }
/** @internal */
public constructor(props: GeometricElement2dProps, iModel: IModelDb) { super(props, iModel); }
}
/** 2d element used to persist graphics for use in drawings.
* @public
*/
export class DrawingGraphic extends GraphicalElement2d {
/** @internal */
public static get className(): string { return "DrawingGraphic"; }
/** @internal */
public constructor(props: GeometricElement2dProps, iModel: IModelDb) { super(props, iModel); }
}
/** 2D Text Annotation
* @public
*/
export class TextAnnotation2d extends AnnotationElement2d {
/** @internal */
public static get className(): string { return "TextAnnotation2d"; }
/** @internal */
public constructor(props: GeometricElement2dProps, iModel: IModelDb) { super(props, iModel); }
}
/** 3D Text Annotation
* @public
*/
export class TextAnnotation3d extends GraphicalElement3d {
/** @internal */
public static get className(): string { return "TextAnnotation3d"; }
/** @internal */
public constructor(props: GeometricElement3dProps, iModel: IModelDb) { super(props, iModel); }
}
/** An Element that occupies real world space. Its coordinates are in the project space of its iModel.
* @public
*/
export abstract class SpatialElement extends GeometricElement3d {
/** @internal */
public static get className(): string { return "SpatialElement"; }
/** @internal */
public constructor(props: GeometricElement3dProps, iModel: IModelDb) { super(props, iModel); }
}
/** An Element that is spatially located, has mass, and can be 'touched'.
* @public
*/
export abstract class PhysicalElement extends SpatialElement {
/** @internal */
public static get className(): string { return "PhysicalElement"; }
/** @internal */
public constructor(props: GeometricElement3dProps, iModel: IModelDb) { super(props, iModel); }
}
/** Identifies a *tracked* real world location but has no mass and cannot be *touched*.
* @public
*/
export abstract class SpatialLocationElement extends SpatialElement {
/** @internal */
public static get className(): string { return "SpatialLocationElement"; }
/** @internal */
public constructor(props: GeometricElement3dProps, iModel: IModelDb) { super(props, iModel); }
}
/** A Volume Element is a Spatial Location Element that is restricted to defining a volume.
* @public
*/
export class VolumeElement extends SpatialLocationElement {
/** @internal */
public static get className(): string { return "VolumeElement"; }
/** @internal */
public constructor(props: GeometricElement3dProps, iModel: IModelDb) { super(props, iModel); }
}
/** Information Content Element is an abstract base class for modeling pure information entities. Only the
* core framework should directly subclass from Information Content Element. Domain and application developers
* should start with the most appropriate subclass of Information Content Element.
* @public
*/
export abstract class InformationContentElement extends Element {
/** @internal */
public static get className(): string { return "InformationContentElement"; }
/** @internal */
constructor(props: ElementProps, iModel: IModelDb) { super(props, iModel); }
}
/** Element used in conjunction with bis:ElementDrivesElement relationships to bundle multiple inputs before
* driving the output element.
* @beta
*/
export abstract class DriverBundleElement extends InformationContentElement {
/** @internal */
public static get className(): string { return "DriverBundleElement"; }
/** @internal */
constructor(props: ElementProps, iModel: IModelDb) { super(props, iModel); }
}
/** Information Reference is an abstract base class for modeling entities whose main purpose is to reference something else.
* @public
*/
export abstract class InformationReferenceElement extends InformationContentElement {
/** @internal */
public static get className(): string { return "InformationReferenceElement"; }
/** @internal */
public constructor(props: ElementProps, iModel: IModelDb) { super(props, iModel); }
}
/** A Subject is an information element that describes what this repository (or part thereof) is about.
* See [how to create a Subject element]$(docs/learning/backend/CreateElements.md#Subject).
* @public
*/
export class Subject extends InformationReferenceElement implements SubjectProps {
/** @internal */
public static get className(): string { return "Subject"; }
public description?: string;
/** @internal */
public constructor(props: SubjectProps, iModel: IModelDb) { super(props, iModel); }
/** Create a Code for a Subject given a name that is meant to be unique within the scope of its parent Subject.
* @param iModelDb The IModelDb
* @param parentSubjectId The Id of the DocumentListModel that contains the Drawing and provides the scope for its name.
* @param codeValue The Drawing name
*/
public static createCode(iModelDb: IModelDb, parentSubjectId: CodeScopeProps, codeValue: string): Code {
const codeSpec: CodeSpec = iModelDb.codeSpecs.getByName(BisCodeSpec.subject);
return new Code({ spec: codeSpec.id, scope: parentSubjectId, value: codeValue });
}
/** Create a Subject
* @param iModelDb The IModelDb
* @param parentSubjectId The new Subject will be a child of this Subject
* @param name The name (codeValue) of the Subject
* @param description The optional description of the Subject
* @returns The newly constructed Subject
* @throws [[IModelError]] if there is a problem creating the Subject
*/
public static create(iModelDb: IModelDb, parentSubjectId: Id64String, name: string, description?: string): Subject {
const subjectProps: SubjectProps = {
classFullName: this.classFullName,
model: IModel.repositoryModelId,
parent: new SubjectOwnsSubjects(parentSubjectId),
code: this.createCode(iModelDb, parentSubjectId, name),
description,
};
return new Subject(subjectProps, iModelDb);
}
/** Insert a Subject
* @param iModelDb Insert into this IModelDb
* @param parentSubjectId The new Subject will be inserted as a child of this Subject
* @param name The name (codeValue) of the Subject
* @param description The optional description of the Subject
* @returns The Id of the newly inserted Subject
* @throws [[IModelError]] if there is a problem inserting the Subject
*/
public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string, description?: string): Id64String {
const subject = this.create(iModelDb, parentSubjectId, name, description);
return iModelDb.elements.insertElement(subject);
}
}
/** An InformationContentElement that identifies the content of a document.
* The realized form of a document is called a DocumentCarrier (different class than Document).
* For example, a will is a legal document. The will published into a PDF file is an ElectronicDocumentCopy.
* The will printed onto paper is a PrintedDocumentCopy.
* In this example, the Document only identifies, names, and tracks the content of the will.
* @public
*/
export abstract class Document extends InformationContentElement {
/** @internal */
public static get className(): string { return "Document"; }
/** @internal */
constructor(props: ElementProps, iModel: IModelDb) { super(props, iModel); }
}
/** A document that represents a drawing, that is, 2-D graphical representation of engineering data. A Drawing element is modelled by a [[DrawingModel]].
* @public
*/
export class Drawing extends Document {
/** @internal */
public static get className(): string { return "Drawing"; }
/** @internal */
constructor(props: ElementProps, iModel: IModelDb) { super(props, iModel); }
/** Create a Code for a Drawing given a name that is meant to be unique within the scope of the specified DocumentListModel.
* @param iModel The IModelDb
* @param scopeModelId The Id of the DocumentListModel that contains the Drawing and provides the scope for its name.
* @param codeValue The Drawing name
*/
public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {
const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.drawing);
return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });
}
/** Insert a Drawing element and a DrawingModel that breaks it down.
* @param iModelDb Insert into this iModel
* @param documentListModelId Insert the new Drawing into this DocumentListModel
* @param name The name of the Drawing.
* @returns The Id of the newly inserted Drawing element and the DrawingModel that breaks it down (same value).
* @throws [[IModelError]] if unable to insert the element.
*/
public static insert(iModelDb: IModelDb, documentListModelId: Id64String, name: string): Id64String {
const drawingProps: ElementProps = {
classFullName: this.classFullName,
model: documentListModelId,
code: this.createCode(iModelDb, documentListModelId, name),
};
const drawingId: Id64String = iModelDb.elements.insertElement(drawingProps);
const model: DrawingModel = iModelDb.models.createModel({
classFullName: DrawingModel.classFullName,
modeledElement: { id: drawingId },
}) as DrawingModel;
return iModelDb.models.insertModel(model);
}
}
/** A document that represents a section drawing, that is, 2-D graphical documentation derived from a planar
* section of some other spatial model. A SectionDrawing element is modelled by a [[SectionDrawingModel]].
* @public
*/
export class SectionDrawing extends Drawing {
/** @internal */
public static get className(): string { return "SectionDrawing"; }
/** @internal */
constructor(props: ElementProps, iModel: IModelDb) { super(props, iModel); }
}
/** The template for a SheetBorder
* @public
*/
export class SheetBorderTemplate extends Document implements SheetBorderTemplateProps {
/** @internal */
public static get className(): string { return "SheetBorderTemplate"; }
public height?: number;
public width?: number;
/** @internal */
public constructor(props: SheetBorderTemplateProps, iModel: IModelDb) { super(props, iModel); }
}
/** The template for a [[Sheet]]
* @public
*/
export class SheetTemplate extends Document implements SheetTemplateProps {
/** @internal */
public static get className(): string { return "SheetTemplate"; }
public height?: number;
public width?: number;
public border?: Id64String;
/** @internal */
constructor(props: SheetTemplateProps, iModel: IModelDb) { super(props, iModel); }
}
/** A digital representation of a *sheet of paper*. Modeled by a [[SheetModel]].
* @public
*/
export class Sheet extends Document implements SheetProps {
/** @internal */
public static get className(): string { return "Sheet"; }
public height: number;
public width: number;
public scale?: number;
public sheetTemplate?: Id64String;
/** @internal */
constructor(props: SheetProps, iModel: IModelDb) {
super(props, iModel);
this.height = JsonUtils.asDouble(props.height);
this.width = JsonUtils.asDouble(props.width);
this.scale = props.scale;
this.sheetTemplate = props.sheetTemplate ? Id64.fromJSON(props.sheetTemplate) : undefined;
}
/** Create a Code for a Sheet given a name that is meant to be unique within the scope of the specified DocumentListModel.
* @param iModel The IModelDb
* @param scopeModelId The Id of the DocumentListModel that contains the Sheet and provides the scope for its name.
* @param codeValue The Sheet name
*/
public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {
const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.sheet);
return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });
}
}
/** An Information Carrier carries information, but is not the information itself. For example, the arrangement
* of ink on paper or the sequence of electronic bits are information carriers.
* @deprecated BisCore will focus on the information itself and not how it is carried.
* @internal
*/
export abstract class InformationCarrierElement extends Element {
/** @internal */
public static get className(): string { return "InformationCarrierElement"; }
/** @internal */
constructor(props: ElementProps, iModel: IModelDb) { super(props, iModel); }
}
/** An Information Carrier that carries a Document. An electronic file is a good example.
* @deprecated BisCore will focus on the information itself and not how it is carried.
* @internal
*/
export abstract class DocumentCarrier extends InformationCarrierElement {
/** @internal */
public static get className(): string { return "DocumentCarrier"; }
/** @internal */
constructor(props: ElementProps, iModel: IModelDb) { super(props, iModel); }
}
/** Information Record Element is an abstract base class for modeling information records. Information Record
* Element is the default choice if no other subclass of Information Content Element makes sense.
* @public
*/
export abstract class InformationRecordElement extends InformationContentElement {
/** @internal */
public static get className(): string { return "InformationRecordElement"; }
/** @internal */
constructor(props: ElementProps, iModel: IModelDb) { super(props, iModel); }
}
/** A Definition Element holds configuration-related information that is meant to be referenced / shared.
* @public
*/
export abstract class DefinitionElement extends InformationContentElement implements DefinitionElementProps {
/** @internal */
public static get className(): string { return "DefinitionElement"; }
/** If true, don't show this DefinitionElement in user interface lists. */
public isPrivate: boolean;
/** @internal */
constructor(props: ElementProps, iModel: IModelDb) { super(props, iModel); this.isPrivate = props.isPrivate; }
/** @internal */
public toJSON(): DefinitionElementProps {
const val = super.toJSON() as DefinitionElementProps;
val.isPrivate = this.isPrivate;
return val;
}
}
/** Defines a set of properties (the *type*) that may be associated with an element.
* @public
*/
export abstract class TypeDefinitionElement extends DefinitionElement implements TypeDefinitionElementProps {
/** @internal */
public static get className(): string { return "TypeDefinitionElement"; }
public recipe?: RelatedElement;
/** @internal */
constructor(props: TypeDefinitionElementProps, iModel: IModelDb) { super(props, iModel); }
}
/** Defines a recipe for generating a *type*.
* @internal
*/
export abstract class RecipeDefinitionElement extends DefinitionElement {
/** @internal */
public static get className(): string { return "RecipeDefinitionElement"; }
/** @internal */
constructor(props: ElementProps, iModel: IModelDb) { super(props, iModel); }
}
/** Defines a set of properties (the *type*) that can be associated with a Physical Element. A Physical
* Type has a strong correlation with something that can be ordered from a catalog since all instances
* share a common set of properties.
* @public
*/
export abstract class PhysicalType extends TypeDefinitionElement {
/** @internal */
public static get className(): string { return "PhysicalType"; }
/** @internal */
constructor(props: TypeDefinitionElementProps, iModel: IModelDb) { super(props, iModel); }
/** Create a Code for a PhysicalType element given a name that is meant to be unique within the scope of the specified DefinitionModel.
* @param iModel The IModelDb
* @param scopeModelId The Id of the DefinitionModel that contains the PhysicalType element and provides the scope for its name.
* @param codeValue The PhysicalType name
*/
public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {
const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.physicalType);
return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });
}
}
/** Defines a set of properties (the *type*) that can be associated with a spatial location.
* @public
*/
export abstract class SpatialLocationType extends TypeDefinitionElement {
/** @internal */
public static get className(): string { return "SpatialLocationType"; }
/** @internal */
constructor(props: TypeDefinitionElementProps, iModel: IModelDb) { super(props, iModel); }
/** Create a Code for a SpatialLocationType element given a name that is meant to be unique within the scope of the specified DefinitionModel.
* @param iModel The IModelDb
* @param scopeModelId The Id of the DefinitionModel that contains the SpatialLocationType element and provides the scope for its name.
* @param codeValue The SpatialLocationType name
*/
public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {
const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.spatialLocationType);
return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });
}
}
/** A recipe that uses a 3d template for creating new instances.
* @internal
*/
export class TemplateRecipe3d extends RecipeDefinitionElement {
/** @internal */
public static get className(): string { return "TemplateRecipe3d"; }
/** @internal */
public constructor(props: ElementProps, iModel: IModelDb) { super(props, iModel); }
}
/** Defines a set of properties (the *type*) that can be associated with a 2D Graphical Element.
* @public
*/
export abstract class GraphicalType2d extends TypeDefinitionElement {
/** @internal */
public static get className(): string { return "GraphicalType2d"; }
/** @internal */
public constructor(props: ElementProps, iModel: IModelDb) { super(props, iModel); }
/** Create a Code for a GraphicalType2d element given a name that is meant to be unique within the scope of the specified DefinitionModel.
* @param iModel The IModelDb
* @param scopeModelId The Id of the DefinitionModel that contains the GraphicalType2d element and provides the scope for its name.
* @param codeValue The GraphicalType2d name
*/
public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {
const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.graphicalType2d);
return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });
}
}
/** A recipe that uses a 2D template for creating new instances.
* @internal
*/
export class TemplateRecipe2d extends RecipeDefinitionElement {
/** @internal */
public static get className(): string { return "TemplateRecipe2d"; }
/** @internal */
public constructor(props: ElementProps, iModel: IModelDb) { super(props, iModel); }
}
/** An abstract base class for elements that introduce a new modeling
* perspective within the overall iModel information hierarchy. An Information Partition is always parented
* to a `Subject` and broken down by a `Model`.
* @public
*/
export abstract class InformationPartitionElement extends InformationContentElement implements InformationPartitionElementProps {
/** @internal */
public static get className(): string { return "InformationPartitionElement"; }
public description?: string;
/** @internal */
public constructor(props: InformationPartitionElementProps, iModel: IModelDb) { super(props, iModel); }
/** Create a code that can be used for any kind of InformationPartitionElement. */
public static createCode(iModel: IModelDb, scopeElementId: CodeScopeProps, codeValue: string): Code {
const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.informationPartitionElement);
return new Code({ spec: codeSpec.id, scope: scopeElementId, value: codeValue });
}
}
/** An Element that indicates that there is a definition-related modeling perspective within
* the overall iModel information hierarchy. A Definition Partition is always parented to a Subject and
* broken down by a Definition Model.
* @public
*/
export class DefinitionPartition extends InformationPartitionElement {
/** @internal */
public static get className(): string { return "DefinitionPartition"; }
}
/** A Document Partition element indicates that there is a document-related modeling perspective within
* the overall iModel information hierarchy. A Document Partition is always parented to a Subject and broken down by a Document List Model.
* @public
*/
export class DocumentPartition extends InformationPartitionElement {
/** @internal */
public static get className(): string { return "DocumentPartition"; }
}
/** A Group Information Partition element indicates that there is a group-information-related modeling perspective
* within the overall iModel information hierarchy. A Group Information Partition is always parented to
* a Subject and broken down by a Group Information Model.
* @public
*/
export class GroupInformationPartition extends InformationPartitionElement {
/** @internal */
public static get className(): string { return "GroupInformationPartition"; }
}
/** A Information Record Partition element indicates that there is an information-record-related modeling
* perspective within the overall iModel information hierarchy. An Information Record Partition is always
* parented to a Subject and broken down by an Information Record Model.
* @public
*/
export class InformationRecordPartition extends InformationPartitionElement {
/** @internal */
public static get className(): string { return "InformationRecordPartition"; }
}
/** A Link Partition element indicates that there is a link-related modeling perspective within the overall
* iModel information hierarchy. A Link Partition is always parented to a Subject and broken down by a LinkModel.
* @public
*/
export class LinkPartition extends InformationPartitionElement {
/** @internal */
public static get className(): string { return "LinkPartition"; }
}
/** A Physical Partition element indicates that there is a physical modeling perspective within the overall
* iModel information hierarchy. A Physical Partition is always parented to a Subject and broken down by a Physical Model.
* @public
*/
export class PhysicalPartition extends InformationPartitionElement {
/** @internal */
public static get className(): string { return "PhysicalPartition"; }
}
/** A Spatial Location Partition element indicates that there is a spatial-location-related modeling perspective
* within the overall iModel information hierarchy. A Spatial Location Partition is always parented to a
* Subject and broken down by a Spatial Location Model.
* @public
*/
export class SpatialLocationPartition extends InformationPartitionElement {
/** @internal */
public static get className(): string { return "SpatialLocationPartition"; }
}
/** Group Information is an abstract base class for modeling entities whose main purpose is to reference
* a group of related elements.
* @public
*/
export abstract class GroupInformationElement extends InformationReferenceElement {
/** @internal */
public static get className(): string { return "GroupInformationElement"; }
}
/** An information element that specifies a link.
* @public
*/
export abstract class LinkElement extends InformationReferenceElement {
/** @internal */
public static get className(): string { return "LinkElement"; }
/** Create a Code for a LinkElement given a name that is meant to be unique within the scope of the specified Model.
* @param iModel The IModelDb
* @param scopeModelId The Id of the Model that contains the LinkElement and provides the scope for its name.
* @param codeValue The LinkElement name
*/
public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {
const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.linkElement);
return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });
}
}
/** An information element that specifies a URL link.
* @public
*/
export class UrlLink extends LinkElement {
/** @internal */
public static get className(): string { return "UrlLink"; }
}
/** An information element that links to an embedded file.
* @public
*/
export class EmbeddedFileLink extends LinkElement {
/** @internal */
public static get className(): string { return "EmbeddedFileLink"; }
}
/** An information element that links to a repository.
* @public
*/
export class RepositoryLink extends UrlLink {
/** @internal */
public static get className(): string { return "RepositoryLink"; }
}
/** A real world entity is modeled as a Role Element when a set of external circumstances define an important
* role (one that is worth tracking) that is not intrinsic to the entity playing the role. For example,
* a person can play the role of a teacher or a rock can play the role of a boundary marker.
* @public
*/
export abstract class RoleElement extends Element {
/** @internal */
public static get className(): string { return "RoleElement"; }
}
/** A Definition Element that specifies a collection of geometry that is meant to be reused across Geometric
* Element instances. Leveraging Geometry Parts can help reduce file size and improve display performance.
* @public
*/
export class GeometryPart extends DefinitionElement implements GeometryPartProps {
/** @internal */
public static get className(): string { return "GeometryPart"; }
public geom?: GeometryStreamProps;
public bbox: ElementAlignedBox3d;
/** @internal */
public constructor(props: GeometryPartProps, iModel: IModelDb) {
super(props, iModel);
this.geom = props.geom;
this.bbox = Range3d.fromJSON(props.bbox);
}
/** @internal */
public toJSON(): GeometryPartProps {
const val = super.toJSON() as GeometryPartProps;
val.geom = this.geom;
val.bbox = this.bbox;
return val;
}
/** Create a Code for a GeometryPart element given a name that is meant to be unique within the scope of the specified DefinitionModel.
* @param iModel The IModelDb
* @param scopeModelId The Id of the DefinitionModel that contains the GeometryPart element and provides the scope for its name.
* @param codeValue The GeometryPart name
* @note GeometryPart elements are not required to be named (have a non-empty Code).
*/
public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {
const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.geometryPart);
return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });
}
}
/** The definition element for a line style
* @public
*/
export class LineStyle extends DefinitionElement implements LineStyleProps {
/** @internal */
public static get className(): string { return "LineStyle"; }
public description?: string;
public data!: string;
/** @internal */
constructor(props: LineStyleProps, iModel: IModelDb) { super(props, iModel); }
/** Create a Code for a LineStyle definition given a name that is meant to be unique within the scope of the specified model.
* @param iModel The IModel
* @param scopeModelId The Id of the DefinitionModel that contains the LineStyle and provides the scope for its name.
* @param codeValue The name of the LineStyle
* @returns A LineStyle Code
*/
public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {
return new Code({ spec: iModel.codeSpecs.getByName(BisCodeSpec.lineStyle).id, scope: scopeModelId, value: codeValue });
}
}
You can’t perform that action at this time.