@itwin/core-common
Version:
iTwin.js components common to frontend and backend
209 lines • 11.7 kB
TypeScript
/** @packageDocumentation
* @module DisplayStyles
*/
import { Id64String } from "@itwin/core-bentley";
import { ModelMapLayerSettings } from "./MapLayerSettings";
/** Describes how a [[SpatialClassifier]] affects the display of classified geometry - that is, geometry intersecting
* the classifier.
* @public
* @extensions
*/
export declare enum SpatialClassifierInsideDisplay {
/** The geometry is not displayed. */
Off = 0,
/** The geometry is displayed without alteration. */
On = 1,
/** The geometry is darkened. */
Dimmed = 2,
/** The geometry is tinted by the [Viewport.hilite]($frontend) color. */
Hilite = 3,
/** The geometry is tinted with the colors of the classifier elements. */
ElementColor = 4
}
/** Describes how a [[SpatialClassifier]] affects the display of unclassified geometry - that is, geometry not intersecting
* the classifier.
* @public
* @extensions
*/
export declare enum SpatialClassifierOutsideDisplay {
/** The geometry is not displayed. */
Off = 0,
/** The geometry is displayed without alteration. */
On = 1,
/** The geometry is darkened. */
Dimmed = 2
}
/** JSON representation of a [[SpatialClassifierFlags]].
* @public
* @extensions
*/
export interface SpatialClassifierFlagsProps {
/** See [[SpatialClassifierFlags.inside]]. */
inside: SpatialClassifierInsideDisplay;
/** See [[SpatialClassifierFlags.outside]]. */
outside: SpatialClassifierOutsideDisplay;
/** See [[SpatialClassifierFlags.isVolumeClassifier]]. */
isVolumeClassifier?: boolean;
}
/** Flags affecting how a [[SpatialClassifier]] is applied.
* @public
*/
export declare class SpatialClassifierFlags {
/** How geometry intersecting the classifier should be displayed. */
readonly inside: SpatialClassifierInsideDisplay;
/** How geometry not intersecting the classifier should be displayed. */
readonly outside: SpatialClassifierOutsideDisplay;
/** True for volume classification; false for planar classification. */
readonly isVolumeClassifier: boolean;
/** Construct new flags. */
constructor(inside?: SpatialClassifierInsideDisplay, outside?: SpatialClassifierOutsideDisplay, isVolumeClassifier?: boolean);
/** Construct from JSON representation. */
static fromJSON(props: SpatialClassifierFlagsProps): SpatialClassifierFlags;
/** Convert to JSON representation. */
toJSON(): SpatialClassifierFlagsProps;
/** Create flags indentical to these ones except for any properties explicitly specified by `changedProps`. */
clone(changedProps?: Partial<SpatialClassifierFlagsProps>): SpatialClassifierFlags;
/** Return true if these flags are equivalent to `other`. */
equals(other: SpatialClassifierFlags): boolean;
/** Return true if these flags are equivalent to `props`. */
equalsProps(props: SpatialClassifierFlagsProps): boolean;
}
/** JSON representation of a [[SpatialClassifier]].
* @public
* @extensions
*/
export interface SpatialClassifierProps {
/** See [[SpatialClassifier.modelId]]. */
modelId: Id64String;
/** See [[SpatialClassifier.expand]]. */
expand: number;
/** See [[SpatialClassifier.flags]]. */
flags: SpatialClassifierFlagsProps;
/** See [[SpatialClassifier.name]]. */
name: string;
/** Records whether this is the active classifier.
* See [[SpatialClassifier.active]].
*/
isActive?: boolean;
}
/** Describes how to use the geometry of one [GeometricModel]($backend) to classify the contents of other models - most typically, reality models.
* Applying a classifier divides the geometry of the classified model into two groups:
* - Classified (intersecting the classifier); and
* - Unclassified (not intersecting the classifier).
* For example, a model containing the building footprints for a city block could be used to classify a reality mesh captured from photographs of the
* real-world block. Then, buildings within the reality mesh can be selected individually, and present the properties of the classifier geometry (e.g.,
* the address of the building). The appearance of the geometry can also be customized based using [[SpatialClassifierInsideDisplay]] and [[SpatialClassifierOutsideDisplay]].
* Two types of classification are supported:
* - Planar classification, in which the geometry of the classifier model is projected onto a plane to classify geometry within a region extruded perpendicular
* the plane (e.g., the building footprints example); and
* - Volume classification, in which closed, non-intersecting volumes within the classifier classify geometry that intersects (i.e. is contained within) those same volumes (e.g., imagine using boxes instead
* of footprints to classify buildings, or floors of buildings).
* @see this (interactive example)[https://www.itwinjs.org/sample-showcase/?group=Viewer+Features&sample=classifier-sample].
* @see [[SpatialClassifiers]] to define a set of classifiers.
* @see [[ContextRealityModel.classifiers]] to classify a context reality model.
* @see [SpatialModelState.classifiers]($frontend) to classify a persistent reality model.
* @public
*/
export declare class SpatialClassifier {
/** The Id of the [GeometricModel]($backend) whose geometry is used to produce the classifier. */
readonly modelId: Id64String;
/** A distance in meters by which to expand the classifier geometry. For example, if line strings are used to represent streets,
* you might expand them to the average width of a street.
*/
readonly expand: number;
/** Flags controlling how to apply the classifier. */
readonly flags: SpatialClassifierFlags;
/** A user-friendly name, useful for identifying individual classifiers within a [[SpatialClassifiers]]. */
readonly name: string;
/** Construct a new classifier. */
constructor(modelId: Id64String, name: string, flags?: SpatialClassifierFlags, expand?: number);
/** Construct from JSON representation. */
static fromJSON(props: SpatialClassifierProps): SpatialClassifier;
/** Convert to JSON representation.
* @note This method always sets the [[SpatialClassifierProps.isActive]] property to `false`.
*/
toJSON(): SpatialClassifierProps;
/** Construct from Model Map Layer.
* @beta
*/
static fromModelMapLayer(mapLayer: ModelMapLayerSettings): SpatialClassifier;
/** Create a classifier identical to this one except for any properties explicitly specified by `changedProps`. */
clone(changedProps?: Partial<SpatialClassifierProps>): SpatialClassifier;
/** Return true if this classifier is equivalent to `other`. */
equals(other: SpatialClassifier): boolean;
/** Return true if this classifier is equivalent to `props`. */
equalsProps(props: SpatialClassifierProps): boolean;
}
/** An object that can store the JSON representation of a list of [[SpatialClassifier]]s.
* @see [[SpatialClassifiers]].
* @public
* @extensions
*/
export interface SpatialClassifiersContainer {
/** The list of classifiers. */
classifiers?: SpatialClassifierProps[];
}
/** A set of [[SpatialClassifier]]s for a given reality model. At most one of the classifiers can be actively classifying the model at any given time.
* The set of classifiers can be presented to the user, listed by name, so that the active classifier can be changed.
* The set of classifiers is populated from its JSON representation and that representation is kept in sync as the set of classifiers is modified.
* @see this (interactive example)[https://www.itwinjs.org/sample-showcase/?group=Viewer+Features&sample=classifier-sample].
* @see [[SpatialClassifier]] for details on how spatial classification works.
* @see [[ContextRealityModel.classifiers]] to define classifiers for a context reality model.
* @see [SpatialModelState.classifiers]($frontend) to define classifiers for a persistent reality model.
* @public
*/
export declare class SpatialClassifiers implements Iterable<SpatialClassifier> {
private readonly _json;
private readonly _classifiers;
private _active?;
/** Construct a new set of classifiers from the JSON representation. The set will be initialized from `container.classifiers` and that JSON representation
* will be kept in sync with changes made to the set. The caller should not directly modify `container.classifiers` or its contents as that will cause the set to become out
* of sync with the JSON representation.
* The [[active]] classifier will be determined by the first [[SpatialClassifierProps]] whose `isActive` property is set to `true`, if any.
*/
constructor(container: SpatialClassifiersContainer);
/** The classifier currently classifying the target reality model. The classifier passed to the setter must be one obtained from this set, or one equivalent to
* one contained in this set; in the latter case, the equivalent classifier contained in this set becomes active.
*/
/** The classifier currently classifying the target reality model, if any.
* @see [[setActive]] to change the active classifier.
*/
get active(): SpatialClassifier | undefined;
/** Change the [[active]] classifier. The input must be a classifier belonging to this set, or equivalent to one in the set.
* If no equivalent classifier exists in the set, the active classifier remains unchanged.
* @param The classifier to set as active, or `undefined` to clear the active classifier.
* @returns the active classifier.
*/
setActive(active: SpatialClassifier | undefined): SpatialClassifier | undefined;
/** Obtain an iterator over the classifiers contained in this set. */
[Symbol.iterator](): Iterator<SpatialClassifier>;
/** The number of classifiers in this set. */
get size(): number;
/** Returns the first classifier that satisfies `criterion`, or `undefined` if no classifier satisfies it. */
find(criterion: (classifier: SpatialClassifier) => boolean): SpatialClassifier | undefined;
/** Find the first classifier that is equivalent to the supplied classifier, or `undefined` if no equivalent classifier exists in this set. */
findEquivalent(classifier: SpatialClassifier): SpatialClassifier | undefined;
/** Return true if the specified classifier or one equivalent to it exists in this set. */
has(classifier: SpatialClassifier): boolean;
/** Add a classifier to this set. If an equivalent classifier already exists, the supplied classifier is not added.
* @param classifier The classifier to add.
* @returns The equivalent pre-existing classifier, if one existed; or the supplied classifier, if it was added to the set.
*/
add(classifier: SpatialClassifier): SpatialClassifier;
/** Replace an existing classifier with a different one.
* @param toReplace The classifier to be replaced.
* @param replacement The classifier to replace `toReplace`.
* @returns true if a classifier equivalent to `toReplace` existed in the set and was replaced by `replacement`.
* @note If `toReplace` was the [[active]] classifier, `replacement` will become active.
*/
replace(toReplace: SpatialClassifier, replacement: SpatialClassifier): boolean;
/** Remove the first classifier equivalent to `classifier` from this set.
* @param classifier The classifier to remove.
* @returns The classifier that was actually removed, or `undefined` if none was removed.
*/
delete(classifier: SpatialClassifier): SpatialClassifier | undefined;
/** Remove all classifiers from this set. */
clear(): void;
private get _array();
}
//# sourceMappingURL=SpatialClassification.d.ts.map