diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index 16ae5502573..fa5be5c8d8c 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -1,3 +1,9 @@ +## From 37.x to 38 + +- **TypeScript declarations**: expanded coverage and corrected types may expose build errors. Remove conflicting local declaration shims and fix code rejected by the new types. +- **TypeScript libraries**: typed-array factories now declare BigInt support. Add `ES2020.BigInt` if your `lib` list does not include `ES2020` or later. Your `target` can stay unchanged. +- **Accessor types**: `setXFrom` methods and setters that return no value now declare `void`. Getter types include `null` or `undefined` where applicable. + ## From 36.x to 37 - **vtkCamera**: `setModelTransformMatrix` now expects matrices in gl-matrix column-major order, consistent with `vtkTransform`, `vtkMatrixBuilder`, and `userMatrix` on `vtkProp3D`. Remove any transpose previously applied to column-major rotation or translation matrices to compensate for the old behavior. Transpose row-major matrices before passing them. ([#3586](https://github.com/Kitware/vtk-js/pull/3586)) diff --git a/Sources/Common/Core/AnimationMixer/index.d.ts b/Sources/Common/Core/AnimationMixer/index.d.ts index 01a2afff43d..b54262d9346 100644 --- a/Sources/Common/Core/AnimationMixer/index.d.ts +++ b/Sources/Common/Core/AnimationMixer/index.d.ts @@ -1,5 +1,5 @@ import { Nullable } from '../../../types'; -import { vtkObject } from '../../../interfaces'; +import { vtkObject, vtkSubscription } from '../../../interfaces'; import vtkAnimationClip from '../../DataModel/AnimationClip'; import vtkAnimationScene from '../AnimationScene'; import vtkArmature from '../../DataModel/Armature'; @@ -12,18 +12,33 @@ export interface SkinningData { jointCount: number; } -export interface AnimationBindingContext { - animation: object; +export type AnimationBindingContext = { deltaTime: number; mixer: vtkAnimationMixer; time: number; -} +} & ( + | { animation: object; animations?: never } + | { animation?: never; animations: object[] } +); export interface AnimationSource { name: string; - evaluate(time: number): unknown; + duration?: number; + weight?: number; + evaluate(time: number, loop?: boolean): unknown; } +export type AnimationBindingOptions = { + enabled?: boolean; + time?: number; + loop?: boolean; + timeScale?: number; +}; + +export type AnimationEndEvent = + | { name: string; clip: vtkAnimationClip } + | { name: string; binding: object }; + export interface AnimationSceneData { actors?: Map; actorNodeIds?: Map; @@ -125,6 +140,16 @@ export interface vtkAnimationMixer extends vtkObject { */ stop(): void; + /** Alias of stop(). */ + stopAll(): void; + + /** Subscribe to a clip or animation binding reaching its end. */ + onAnimationEnd( + callback: (event: AnimationEndEvent) => void, + priority?: number + ): vtkSubscription; + invokeAnimationEnd(event: AnimationEndEvent): void; + /** * Get the name of the currently playing clip. */ @@ -133,7 +158,7 @@ export interface vtkAnimationMixer extends vtkObject { /** * Check if the mixer is currently playing. */ - isPlaying(): boolean; + isPlaying(): Nullable; /** * Set the skeleton to animate. @@ -197,7 +222,7 @@ export interface vtkAnimationMixer extends vtkObject { name: string, apply: (updates: unknown, context: AnimationBindingContext) => void, animations?: object[], - options?: { enabled?: boolean; time?: number } + options?: AnimationBindingOptions ): boolean; /** @@ -239,13 +264,19 @@ export interface vtkAnimationMixer extends vtkObject { getAnimationNames(): string[]; /** Play every imported animation channel with the given name. */ - playAnimation(name: string): boolean; + playAnimation(name: string, options?: AnimationBindingOptions): boolean; /** Play a node animation by name, or the first one when omitted. */ - playNodeAnimation(name?: string): void; + playNodeAnimation( + name?: Nullable, + options?: AnimationBindingOptions + ): void; /** Play a pointer animation by name, or the first one when omitted. */ - playPointerAnimation(name?: string): void; + playPointerAnimation( + name?: Nullable, + options?: AnimationBindingOptions + ): void; /** Return true when the mixer contains any animation. */ hasAnimations(): boolean; diff --git a/Sources/Common/Core/CellArray/index.d.ts b/Sources/Common/Core/CellArray/index.d.ts index 54e286686b2..bdfd5b14ac6 100755 --- a/Sources/Common/Core/CellArray/index.d.ts +++ b/Sources/Common/Core/CellArray/index.d.ts @@ -23,7 +23,7 @@ export interface vtkCellArray extends vtkDataArray { * Get the sizes of the cells in this array. * @param {Boolean} [recompute] Recompute the cell sizes. */ - getCellSizes(recompute?: boolean): any; + getCellSizes(recompute?: boolean): number[]; /** * Set the data of this array. @@ -35,7 +35,7 @@ export interface vtkCellArray extends vtkDataArray { * Returns the point indices at the given location as a subarray. * @param loc */ - getCell(loc: any): void; + getCell(loc: number): TypedArray; /** * Insert a cell to this array in the next available slot. @@ -82,13 +82,18 @@ export function newInstance( * @param cellArray * @returns {number[]} An array of cell sizes. */ -export function extractCellSizes(cellArray: any): number[]; +declare function extractCellSizes(cellArray: any): number[]; /** * @static * @param cellArray */ -export function getNumberOfCells(cellArray: any): any; +declare function getNumberOfCells(cellArray: any): any; + +export declare const STATIC: Readonly<{ + extractCellSizes: typeof extractCellSizes; + getNumberOfCells: typeof getNumberOfCells; +}>; /** * vtkCellArray stores dataset topologies as an explicit connectivity table diff --git a/Sources/Common/Core/ClassHierarchy/index.d.ts b/Sources/Common/Core/ClassHierarchy/index.d.ts new file mode 100644 index 00000000000..c4ba3657029 --- /dev/null +++ b/Sources/Common/Core/ClassHierarchy/index.d.ts @@ -0,0 +1,15 @@ +/** + * An array of class names that ignores duplicates: pushing a name already in + * the hierarchy leaves the array unchanged and still reports its length. + */ +export interface ClassHierarchy extends Array { + push(...names: string[]): number; +} + +/** + * The subclass carries no static members of its own; it inherits Array's. + */ +declare const ClassHierarchy: { + new (...items: string[]): ClassHierarchy; +}; +export default ClassHierarchy; diff --git a/Sources/Common/Core/DataArray/Constants.d.ts b/Sources/Common/Core/DataArray/Constants.d.ts new file mode 100644 index 00000000000..8c07649b2d0 --- /dev/null +++ b/Sources/Common/Core/DataArray/Constants.d.ts @@ -0,0 +1,42 @@ +export declare const DataTypeByteSize: { + Int8Array: number; + Uint8Array: number; + Uint8ClampedArray: number; + Int16Array: number; + Uint16Array: number; + Int32Array: number; + Uint32Array: number; + Float32Array: number; + Float64Array: number; +}; + +/** + * Constants capturing the various VTK data types. + */ +export declare const VtkDataTypes: { + readonly VOID: ''; + readonly CHAR: 'Int8Array'; + readonly SIGNED_CHAR: 'Int8Array'; + readonly UNSIGNED_CHAR: 'Uint8Array'; + /** + * Should be used for VTK.js internal purpose only + */ + readonly UNSIGNED_CHAR_CLAMPED: 'Uint8ClampedArray'; + readonly SHORT: 'Int16Array'; + readonly UNSIGNED_SHORT: 'Uint16Array'; + readonly INT: 'Int32Array'; + readonly UNSIGNED_INT: 'Uint32Array'; + readonly FLOAT: 'Float32Array'; + readonly DOUBLE: 'Float64Array'; +}; + +export type VtkDataTypes = (typeof VtkDataTypes)[keyof typeof VtkDataTypes]; + +export declare const DefaultDataType: VtkDataTypes; + +declare const _default: { + DefaultDataType: typeof DefaultDataType; + DataTypeByteSize: typeof DataTypeByteSize; + VtkDataTypes: typeof VtkDataTypes; +}; +export default _default; diff --git a/Sources/Common/Core/DataArray/index.d.ts b/Sources/Common/Core/DataArray/index.d.ts index d3bc68b5d59..00f5cf485b5 100644 --- a/Sources/Common/Core/DataArray/index.d.ts +++ b/Sources/Common/Core/DataArray/index.d.ts @@ -1,3 +1,4 @@ +import { DataTypeByteSize, VtkDataTypes } from './Constants'; import { vtkObject, vtkRange, GetStateOptions } from '../../../interfaces'; import { Float, @@ -83,10 +84,16 @@ export interface vtkDataArray extends vtkObject { */ setValue(valueIdx: NonNegativeInteger, value: number): void; + /** Get a value by its flat component index. */ + getValue(valueIdx: number): number; + + /** Set a value by its flat component index. */ + setValue(valueIdx: number, value: number): void; + /** * */ - getData(): number[] | TypedArray; + getData(): TypedArray; /** * Call this method when the underlying data has changed @@ -324,7 +331,7 @@ export interface vtkDataArray extends vtkObject { * without converting and copying to a plain Array. * @returns {object} */ - getState(options?: GetStateOptions): object; + getState(options?: GetStateOptions): object | null; /** * Deep copy of another vtkDataArray into this one. @@ -391,7 +398,7 @@ export interface vtkDataArray extends vtkObject { * @see insertNextTuple * @see insertNextTuples */ - initialize(): void; + initialize(): vtkDataArray; // --- via macro -- @@ -427,7 +434,7 @@ export interface vtkDataArray extends vtkObject { * @param {Number} [component] (default: 0) indice to use inside tuple size * @param {Number} [numberOfComponents] (default: 1) size of the tuple */ -export function computeRange( +declare function computeRange( values: ArrayLike, component?: number, numberOfComponents?: number @@ -440,7 +447,7 @@ export function computeRange( * @param {Number} offset offset index to select the desired component in the tuple * @param {Number} numberOfComponents size of tuple in a multi-channel array */ -export function fastComputeRange( +declare function fastComputeRange( values: ArrayLike, offset: number, numberOfComponents: number @@ -451,7 +458,7 @@ export function fastComputeRange( * Create helper object that can be used to gather min, max, count, sum of * a set of values. */ -export function createRangeHelper(): vtkRangeHelper; +declare function createRangeHelper(): vtkRangeHelper; /** * Return the name of a typed array @@ -463,14 +470,22 @@ export function createRangeHelper(): vtkRangeHelper; * * @param typedArray to extract its type from */ -export function getDataType(typedArray: TypedArray): string; +declare function getDataType(typedArray: TypedArray): string; /** * Return the max norm of a given vtkDataArray * * @param dataArray to process */ -export function getMaxNorm(dataArray: vtkDataArray): number; +declare function getMaxNorm(dataArray: vtkDataArray): number; + +export declare const STATIC: Readonly<{ + computeRange: typeof computeRange; + createRangeHelper: typeof createRangeHelper; + fastComputeRange: typeof fastComputeRange; + getDataType: typeof getDataType; + getMaxNorm: typeof getMaxNorm; +}>; /** * Method use to decorate a given object (publicAPI+model) with vtkDataArray characteristics. @@ -497,37 +512,6 @@ export function extend( */ export function newInstance(initialValues?: object): vtkDataArray; -/** - * Constants capturing the number of bytes per element based on its data type. - */ -export enum DataTypeByteSize { - Int8Array, - Uint8Array, - Uint8ClampedArray, - Int16Array, - Uint16Array, - Int32Array, - Uint32Array, - Float32Array, - Float64Array, -} - -/** - * Constants capturing the various VTK data types. - */ -export enum VtkDataTypes { - VOID, - CHAR, - SIGNED_CHAR, - UNSIGNED_CHAR, - SHORT, - UNSIGNED_SHORT, - INT, - UNSIGNED_INT, - FLOAT, - DOUBLE, -} - /** * vtkDataArray is an abstract superclass for data array objects containing * numeric data. diff --git a/Sources/Common/Core/Endian/index.d.ts b/Sources/Common/Core/Endian/index.d.ts index fa2f960e21b..72d91b8c8d4 100755 --- a/Sources/Common/Core/Endian/index.d.ts +++ b/Sources/Common/Core/Endian/index.d.ts @@ -5,7 +5,7 @@ import { Nullable } from '../../../types'; */ export function getEndianness(): Nullable; -export const ENDIANNESS: string; +export const ENDIANNESS: Nullable; /** * @@ -13,3 +13,10 @@ export const ENDIANNESS: string; * @param {Number} wordSize */ export function swapBytes(buffer: ArrayBuffer, wordSize: number): void; + +declare const _default: { + ENDIANNESS: Nullable; + getEndianness: typeof getEndianness; + swapBytes: typeof swapBytes; +}; +export default _default; diff --git a/Sources/Common/Core/HalfFloat/index.d.ts b/Sources/Common/Core/HalfFloat/index.d.ts index 2f943fbe3be..b4f497eb030 100644 --- a/Sources/Common/Core/HalfFloat/index.d.ts +++ b/Sources/Common/Core/HalfFloat/index.d.ts @@ -7,16 +7,16 @@ * @param {number} input * @return encoded half float number (16 bits) */ -export function toHalf(input: number): number; +declare function toHalf(input: number): number; /** * Convert a half float representation to a number * @param {number} input * @return decoded half float number */ -export function fromHalf(input: number): number; +declare function fromHalf(input: number): number; -export declare const HalfFloat: { +declare const HalfFloat: { toHalf: typeof toHalf; fromHalf: typeof fromHalf; }; diff --git a/Sources/Common/Core/ImageHelper/index.d.ts b/Sources/Common/Core/ImageHelper/index.d.ts index 86970bf0c12..2464f7cfc4d 100755 --- a/Sources/Common/Core/ImageHelper/index.d.ts +++ b/Sources/Common/Core/ImageHelper/index.d.ts @@ -14,7 +14,7 @@ interface ITransform { * @param {HTMLCanvasElement} canvas The HTML canvas to convert. * @param {Number[]} [boundingBox] A bounding box array. */ -export function canvasToImageData( +declare function canvasToImageData( canvas: HTMLCanvasElement, boundingBox?: number[] ): vtkImageData; @@ -24,7 +24,13 @@ export function canvasToImageData( * @param {HTMLImageElement} image The HTML image to convert. * @param {ITransform} [transform] The transform object to apply to the image. */ -export function imageToImageData( +declare function imageToImageData( image: HTMLImageElement, transform?: ITransform ): vtkImageData; + +declare const _default: { + canvasToImageData: typeof canvasToImageData; + imageToImageData: typeof imageToImageData; +}; +export default _default; diff --git a/Sources/Common/Core/LookupTable/index.d.ts b/Sources/Common/Core/LookupTable/index.d.ts index 732ba4ad885..be8f3d6dd40 100644 --- a/Sources/Common/Core/LookupTable/index.d.ts +++ b/Sources/Common/Core/LookupTable/index.d.ts @@ -1,12 +1,42 @@ +import { vtkObject } from '../../../interfaces'; import { Range, RGBAColor } from '../../../types'; +import vtkDataArray from '../DataArray'; +import { ScalarMappingTarget } from '../ScalarsToColors/Constants'; import vtkScalarsToColors from '../ScalarsToColors'; /** * */ -export interface ILookupTableInitialValues {} +export interface ILookupTableInitialValues { + aboveRangeColor?: RGBAColor; + alphaRange?: Range; + belowRangeColor?: RGBAColor; + hueRange?: Range; + nanColor?: RGBAColor; + numberOfColors?: number; + saturationRange?: Range; + useAboveRangeColor?: boolean; + useBelowRangeColor?: boolean; + valueRange?: Range; +} export interface vtkLookupTable extends vtkScalarsToColors { + /** Return whether all colors in the table are opaque. */ + isOpaque(): boolean; + + /** Lookup tables do not use logarithmic scaling. */ + usingLogScale(): boolean; + + /** Build the table if it is stale or empty. */ + build(): void; + + /** Map scalar values through the lookup table into the supplied output. */ + mapScalarsThroughTable( + input: vtkDataArray, + output: vtkDataArray, + outFormat: ScalarMappingTarget, + inputOffset: number + ): void; /** * */ @@ -37,6 +67,11 @@ export interface vtkLookupTable extends vtkScalarsToColors { */ getAlphaRangeByReference(): Range; + /** + * The timestamp of the last color table build. + */ + getBuildTime(): vtkObject; + /** * */ @@ -145,7 +180,7 @@ export interface vtkLookupTable extends vtkScalarsToColors { * @param range * @param p */ - lookupShiftAndScale(range: Range, p: object): boolean; + lookupShiftAndScale(range: Range, p: object): void; /** * @@ -157,7 +192,7 @@ export interface vtkLookupTable extends vtkScalarsToColors { * * @param aboveRangeColor */ - setAboveRangeColorFrom(aboveRangeColor: RGBAColor): boolean; + setAboveRangeColorFrom(aboveRangeColor: RGBAColor): void; /** * @@ -169,7 +204,7 @@ export interface vtkLookupTable extends vtkScalarsToColors { * * @param alphaRange */ - setAlphaRangeFrom(alphaRange: Range): boolean; + setAlphaRangeFrom(alphaRange: Range): void; /** * @@ -181,7 +216,7 @@ export interface vtkLookupTable extends vtkScalarsToColors { * * @param belowRangeColor */ - setBelowRangeColorFrom(belowRangeColor: RGBAColor): boolean; + setBelowRangeColorFrom(belowRangeColor: RGBAColor): void; /** * @@ -193,7 +228,7 @@ export interface vtkLookupTable extends vtkScalarsToColors { * * @param hueRange */ - setHueRangeFrom(hueRange: Range): boolean; + setHueRangeFrom(hueRange: Range): void; /** * @@ -205,7 +240,7 @@ export interface vtkLookupTable extends vtkScalarsToColors { * * @param nanColor */ - setNanColorFrom(nanColor: RGBAColor): boolean; + setNanColorFrom(nanColor: RGBAColor): void; /** * @@ -223,7 +258,7 @@ export interface vtkLookupTable extends vtkScalarsToColors { * * @param saturationRange */ - setSaturationRangeFrom(saturationRange: Range): boolean; + setSaturationRangeFrom(saturationRange: Range): void; /** * @@ -253,7 +288,7 @@ export interface vtkLookupTable extends vtkScalarsToColors { * * @param valueRange */ - setValueRangeFrom(valueRange: Range): boolean; + setValueRangeFrom(valueRange: Range): void; } /** diff --git a/Sources/Common/Core/Math/Constants.d.ts b/Sources/Common/Core/Math/Constants.d.ts new file mode 100644 index 00000000000..5a0c1ddddcb --- /dev/null +++ b/Sources/Common/Core/Math/Constants.d.ts @@ -0,0 +1,13 @@ +export declare const IDENTITY: number[]; +export declare const IDENTITY_3X3: number[]; + +export declare const EPSILON: number; +export declare const VTK_SMALL_NUMBER: number; + +declare const _default: { + IDENTITY: typeof IDENTITY; + IDENTITY_3X3: typeof IDENTITY_3X3; + EPSILON: typeof EPSILON; + VTK_SMALL_NUMBER: typeof VTK_SMALL_NUMBER; +}; +export default _default; diff --git a/Sources/Common/Core/Math/index.d.ts b/Sources/Common/Core/Math/index.d.ts index 3107fab3ded..09f71389ed2 100755 --- a/Sources/Common/Core/Math/index.d.ts +++ b/Sources/Common/Core/Math/index.d.ts @@ -18,34 +18,6 @@ import { */ export function createArray(size?: number): number[]; -/** - * Given two rows indices, swap the two rows of a nxn matrix - * @param {Number[]} matrix The n by n matrix in wich we want to swap the vectors. - * @param {Number} n size of the matrix. - * @param {Number} row1 index of first row to swap with the other. - * @param {Number} row2 index of second row to swap with the other. - */ -export function swapRowsMatrix_nxn( - matrix: number[], - n: number, - row1: number, - row2: number -): void; - -/** - * Given two columns indices, swap the two columns of a nxn matrix - * @param {Number[]} matrix The n by n matrix in wich we want to swap the vectors. - * @param {Number} n size of the matrix. - * @param {Number} column1 index of first col to swap with the other. - * @param {Number} column2 index of second col to swap with the other. - */ -export function swapColumnsMatrix_nxn( - matrix: number[], - n: number, - column1: number, - column2: number -): void; - /** * Get the number π. */ @@ -612,7 +584,7 @@ export function invert3x3(in_3x3: Matrix3x3, outI_3x3: Matrix3x3): void; * @see isIdentity() * @see identity3x3() */ -export function identity(n: number, mat: number[]): void; +export function identity(n: number, mat: number[]): number[]; /** * Set mat_3x3 to the identity matrix. @@ -624,12 +596,12 @@ export function identity3x3(mat_3x3: Matrix3x3): void; /** * Returns true if provided matrix is the identity matrix. - * @param {Number[]} mat The 3x3 matrix to check + * @param {Number[]} mat The 4x4 matrix to check * @param {Number} [eps] The tolerance value. * @see isIdentity() * @see identity() */ -export function isIdentity(mat: Matrix3x3, eps?: number): boolean; +export function isIdentity(mat: Matrix, eps?: number): boolean; /** * Returns true if provided 3x3 matrix is the identity matrix. @@ -664,6 +636,14 @@ export function quaternionToMatrix3x3( */ export function areEquals(a: number[], b: number[], eps?: number): boolean; +/** + * Returns true if elements of both arrays are equals. + * @param {Number[]} a An array of numbers (vector, point, matrix...) + * @param {Number[]} b An array of numbers (vector, point, matrix...) + * @param {Number} [eps] The tolerance value. + */ +export const areMatricesEqual: typeof areEquals; + /** * * @param {Number} num @@ -1137,6 +1117,16 @@ export function isNaN(value: number): boolean; */ export function isFinite(value: any): boolean; +/** + * Value used to represent positive infinity. + */ +export const inf: number; + +/** + * Value used to represent negative infinity. + */ +export const negInf: number; + /** * vtkMath provides methods to perform common math operations. These include * providing constants such as Pi; conversion from degrees to radians; vector @@ -1145,11 +1135,9 @@ export function isFinite(value: any): boolean; * number generation (for backward compatibility only). * **Contrary to the rest of vtk.js, vtkMath is in row-major format (similar to VTK C++).** */ -export declare const vtkMath: { - createArray: typeof createArray; - swapRowsMatrix_nxn: typeof swapRowsMatrix_nxn; - swapColumnsMatrix_nxn: typeof swapColumnsMatrix_nxn; +declare const vtkMath: { Pi: typeof Pi; + ldexp: typeof ldexp; radiansFromDegrees: typeof radiansFromDegrees; degreesFromRadians: typeof degreesFromRadians; round: typeof round; @@ -1194,10 +1182,6 @@ export declare const vtkMath: { norm2D: typeof norm2D; normalize2D: typeof normalize2D; determinant2x2: typeof determinant2x2; - rowsToMat4: typeof rowsToMat4; - columnsToMat4: typeof columnsToMat4; - rowsToMat3: typeof rowsToMat3; - columnsToMat3: typeof columnsToMat3; LUFactor3x3: typeof LUFactor3x3; LUSolve3x3: typeof LUSolve3x3; linearSolve3x3: typeof linearSolve3x3; @@ -1207,6 +1191,9 @@ export declare const vtkMath: { transpose3x3: typeof transpose3x3; invert3x3: typeof invert3x3; identity3x3: typeof identity3x3; + identity: typeof identity; + isIdentity: typeof isIdentity; + isIdentity3x3: typeof isIdentity3x3; determinant3x3: typeof determinant3x3; quaternionToMatrix3x3: typeof quaternionToMatrix3x3; areEquals: typeof areEquals; diff --git a/Sources/Common/Core/MatrixBuilder/index.d.ts b/Sources/Common/Core/MatrixBuilder/index.d.ts index 255d11bf627..789fa0864cb 100755 --- a/Sources/Common/Core/MatrixBuilder/index.d.ts +++ b/Sources/Common/Core/MatrixBuilder/index.d.ts @@ -2,12 +2,6 @@ import { mat3, mat4 } from 'gl-matrix'; import { TypedArray, Vector3 } from '../../../types'; declare interface Transform { - /** - * - * @param {Boolean} [useDegree] - */ - new (useDegree?: boolean); - /** * Multiplies the current matrix with a transformation matrix created by * normalizing both direction vectors and rotating around the axis of the @@ -145,7 +139,7 @@ declare function buildFromRadian(): Transform; * initialized with the Identity Matrix. * */ -export declare const vtkMatrixBuilder: { +declare const vtkMatrixBuilder: { buildFromDegree: typeof buildFromDegree; buildFromRadian: typeof buildFromRadian; }; diff --git a/Sources/Common/Core/Points/index.d.ts b/Sources/Common/Core/Points/index.d.ts index 15d5c96f28f..3981a5a0810 100755 --- a/Sources/Common/Core/Points/index.d.ts +++ b/Sources/Common/Core/Points/index.d.ts @@ -14,7 +14,7 @@ export interface vtkPoints extends vtkDataArray { /** * Trigger the computation of bounds */ - computeBounds(): Bounds; + computeBounds(): void; /** * Get a copy of the bounds of the array. diff --git a/Sources/Common/Core/ProgressHandler/index.d.ts b/Sources/Common/Core/ProgressHandler/index.d.ts index 11202782d00..898b06204f5 100755 --- a/Sources/Common/Core/ProgressHandler/index.d.ts +++ b/Sources/Common/Core/ProgressHandler/index.d.ts @@ -1,4 +1,4 @@ -import { vtkObject } from '../../../interfaces'; +import { vtkObject, vtkSubscription } from '../../../interfaces'; /** * @@ -28,6 +28,19 @@ export interface vtkProgressHandler extends vtkObject { */ isWorking(): boolean; + /** + * + * @param cb + * @param priority + */ + onChange(cb: (working: boolean) => void, priority?: number): vtkSubscription; + + /** + * + * @param working + */ + invokeChange(working: boolean): void; + /** * * @param promise diff --git a/Sources/Common/Core/ScalarsToColors/Constants.d.ts b/Sources/Common/Core/ScalarsToColors/Constants.d.ts index e62cd1bcf8a..dab489fbbc0 100644 --- a/Sources/Common/Core/ScalarsToColors/Constants.d.ts +++ b/Sources/Common/Core/ScalarsToColors/Constants.d.ts @@ -1,18 +1,31 @@ -export declare enum VectorMode { - MAGNITUDE = 0, - COMPONENT = 1, - RGBCOLORS = 2, -} +export declare const VectorMode: { + readonly MAGNITUDE: 0; + readonly COMPONENT: 1; + readonly RGBCOLORS: 2; +}; + +export type VectorMode = (typeof VectorMode)[keyof typeof VectorMode]; + +export declare const ScalarMappingTarget: { + readonly LUMINANCE: 1; + readonly LUMINANCE_ALPHA: 2; + readonly RGB: 3; + readonly RGBA: 4; +}; + +export type ScalarMappingTarget = + (typeof ScalarMappingTarget)[keyof typeof ScalarMappingTarget]; + +export declare const Scale: { + readonly LINEAR: 0; + readonly LOG10: 1; +}; -export declare enum ScalarMappingTarget { - LUMINANCE = 1, - LUMINANCE_ALPHA = 2, - RGB = 3, - RGBA = 4, -} +export type Scale = (typeof Scale)[keyof typeof Scale]; declare const _default: { VectorMode: typeof VectorMode; ScalarMappingTarget: typeof ScalarMappingTarget; + Scale: typeof Scale; }; export default _default; diff --git a/Sources/Common/Core/ScalarsToColors/index.d.ts b/Sources/Common/Core/ScalarsToColors/index.d.ts index a02ce227be7..2087e7f085d 100755 --- a/Sources/Common/Core/ScalarsToColors/index.d.ts +++ b/Sources/Common/Core/ScalarsToColors/index.d.ts @@ -2,12 +2,13 @@ import { vtkObject } from '../../../interfaces'; import { ColorMode } from '../../../Rendering/Core/Mapper/Constants'; import { Range } from '../../../types'; import vtkDataArray from '../DataArray'; -import { ScalarMappingTarget, VectorMode } from './Constants'; +import { ScalarMappingTarget, Scale, VectorMode } from './Constants'; /** * */ export interface IScalarsToColorsInitialValues { + vectorMode?: VectorMode; alpha?: number; vectorComponent?: number; vectorSize?: number; @@ -32,7 +33,11 @@ export interface vtkScalarsToColors extends vtkObject { * @param numComp * @param numTuples */ - convertToRGBA(colors: any, numComp: number, numTuples: number): void; + convertToRGBA( + colors: any, + numComp: number, + numTuples: number + ): vtkDataArray | null; /** * Specify an additional opacity (alpha) value to blend with. @@ -43,7 +48,7 @@ export interface vtkScalarsToColors extends vtkObject { * * @param {Number} idx */ - getAnnotatedValue(idx: number): void; + getAnnotatedValue(idx: number): any; /** * @@ -62,7 +67,7 @@ export interface vtkScalarsToColors extends vtkObject { * * @param {Number} idx */ - getAnnotation(idx: number): string; + getAnnotation(idx: number): string | null; /** * @@ -192,7 +197,11 @@ export interface vtkScalarsToColors extends vtkObject { * @param {ColorMode} colorMode * @param {Number} componentIn */ - mapScalars(scalars: any, colorMode: ColorMode, componentIn: number): void; + mapScalars( + scalars: any, + colorMode: ColorMode, + componentIn: number + ): vtkDataArray | null; /** * Map a set of vector values through the table @@ -290,7 +299,7 @@ export interface vtkScalarsToColors extends vtkObject { * * @param {Range} mappingRange */ - setMappingRangeFrom(mappingRange: Range): boolean; + setMappingRangeFrom(mappingRange: Range): void; /** * @@ -343,7 +352,7 @@ export interface vtkScalarsToColors extends vtkObject { /** * Update the map from annotated values to indices in the array of annotations. */ - updateAnnotatedValueMap(): boolean; + updateAnnotatedValueMap(): void; /** * @@ -396,7 +405,8 @@ export function newInstance( export declare const vtkScalarsToColors: { newInstance: typeof newInstance; extend: typeof extend; + Scale: typeof Scale; VectorMode: typeof VectorMode; - ScalarMappingTarget: typeof VectorMode; + ScalarMappingTarget: typeof ScalarMappingTarget; }; export default vtkScalarsToColors; diff --git a/Sources/Common/Core/StringArray/index.d.ts b/Sources/Common/Core/StringArray/index.d.ts index bd03967d032..440abe1081c 100755 --- a/Sources/Common/Core/StringArray/index.d.ts +++ b/Sources/Common/Core/StringArray/index.d.ts @@ -7,7 +7,7 @@ import { NonNegativeInteger } from '../../../types'; export interface IStringArrayInitialValues { name?: string; numberOfComponents?: number; - size: number; + size?: number; dataType?: string; } @@ -73,7 +73,7 @@ export interface vtkStringArray extends vtkObject { /** * */ - newClone(): void; + newClone(): vtkStringArray; /** * Set the data component at the location specified by tupleIdx and compIdx @@ -99,9 +99,9 @@ export interface vtkStringArray extends vtkObject { /** * * @param {String[]} array - * @param {Number} numberOfComponents + * @param {Number} [numberOfComponents] */ - setData(array: string[], numberOfComponents: number): void; + setData(array: string[], numberOfComponents?: number): void; /** * diff --git a/Sources/Common/Core/URLExtract/index.d.ts b/Sources/Common/Core/URLExtract/index.d.ts index 715f19175f8..3327a754c10 100755 --- a/Sources/Common/Core/URLExtract/index.d.ts +++ b/Sources/Common/Core/URLExtract/index.d.ts @@ -3,7 +3,7 @@ * @param {Boolean} [castToNativeType] * @param {String} [query] */ -export function extractURLParameters( +declare function extractURLParameters( castToNativeType?: boolean, query?: string ): object; @@ -12,7 +12,9 @@ export function extractURLParameters( * * @param {String} str The type value as string. */ -export function toNativeType(str: string): void; +declare function toNativeType( + str: string +): string | number | boolean | null | undefined | unknown[]; declare const _default: { toNativeType: typeof toNativeType; diff --git a/Sources/Common/Core/VariantArray/index.d.ts b/Sources/Common/Core/VariantArray/index.d.ts index 586ebf08909..8fff827510d 100755 --- a/Sources/Common/Core/VariantArray/index.d.ts +++ b/Sources/Common/Core/VariantArray/index.d.ts @@ -7,7 +7,7 @@ import { NonNegativeInteger } from '../../../types'; export interface IVariantArrayInitialValues { name?: string; numberOfComponents?: number; - size: number; + size?: number; dataType?: string; } @@ -70,7 +70,7 @@ export interface vtkVariantArray extends vtkObject { /** * */ - newClone(): void; + newClone(): vtkVariantArray; /** * Set the data component at the location specified by tupleIdx and compIdx @@ -96,9 +96,9 @@ export interface vtkVariantArray extends vtkObject { /** * * @param {Array} array - * @param {Number} numberOfComponents + * @param {Number} [numberOfComponents] */ - setData(array: Array, numberOfComponents: number): void; + setData(array: Array, numberOfComponents?: number): void; /** * diff --git a/Sources/Common/DataModel/AbstractPointLocator/index.d.ts b/Sources/Common/DataModel/AbstractPointLocator/index.d.ts index 35099a825c5..8b642e3a38d 100644 --- a/Sources/Common/DataModel/AbstractPointLocator/index.d.ts +++ b/Sources/Common/DataModel/AbstractPointLocator/index.d.ts @@ -1,5 +1,5 @@ import { vtkObject } from '../../../interfaces'; -import { Bounds } from '../../../types'; +import { Bounds, Nullable } from '../../../types'; import vtkLocator, { ILocatorInitialValues } from '../Locator'; /** @@ -7,7 +7,7 @@ import vtkLocator, { ILocatorInitialValues } from '../Locator'; */ export interface IAbstractPointLocatorInitialValues extends ILocatorInitialValues { bounds?: Bounds; - numberOfBuckets: number; + numberOfBuckets?: number; } export interface vtkAbstractPointLocator extends vtkLocator { @@ -15,13 +15,33 @@ export interface vtkAbstractPointLocator extends vtkLocator { * Set the bounds of this object. * @param {Bounds} input */ - setBounds(input: Bounds): void; + setBounds(input: Bounds): boolean; + + /** + * Set the bounds of this object by reference. + * @param {Bounds} bounds + */ + setBoundsFrom(bounds: Bounds): void; /** * Get the bounds of this object. * @returns {Bounds} */ - getBounds(): Bounds; + getBounds(): Nullable; + + /** + * Get the bounds of this object by reference. + * @returns {Bounds} + */ + getBoundsByReference(): Nullable; + + /** + * Get the number of buckets (divisions) currently used by the search + * structure. + * + * @returns {Number} The number of buckets. + */ + getNumberOfBuckets(): number; } // ---------------------------------------------------------------------------- diff --git a/Sources/Common/DataModel/BoundingBox/index.d.ts b/Sources/Common/DataModel/BoundingBox/index.d.ts index 1e85a09ae13..c31ed8df583 100644 --- a/Sources/Common/DataModel/BoundingBox/index.d.ts +++ b/Sources/Common/DataModel/BoundingBox/index.d.ts @@ -3,6 +3,8 @@ import { Bounds, TypedArray, Vector2, Vector3 } from '../../../types'; import vtkPoints from '../../Core/Points'; import { Nullable } from '../../../types'; +declare const INIT_BOUNDS: Bounds; + /** * Tests whether two bounds equal. * @param {Bounds} a @@ -103,7 +105,7 @@ export function setMaxPoint( * @param {Bounds} bounds * @param {number} delta */ -export function inflate(bounds: Bounds, delta: number): Bounds; +declare function inflate(bounds: Bounds, delta: number): Bounds; /** * Scales a bounding box. @@ -267,8 +269,8 @@ export function intersectBox( origin: Vector3, dir: Vector3, coord: Vector3, - tolerance: number -): boolean; + tolerance: number[] +): number; /** * Plane intersection with box @@ -283,7 +285,7 @@ export function intersectPlane( bounds: Bounds, origin: Vector3, normal: Vector3 -): boolean; +): number; /** * Do two bounding boxes intersect. @@ -363,58 +365,58 @@ export function computeDivisions( */ export function distance2ToBounds(x: Vector3, bounds: Bounds): number; +/** + * A bounding box instance owns its `bounds` array; every method operates on it + * rather than taking the bounds as an argument. Use the module's free + * functions for the same operations on a plain bounds array. + */ declare class BoundingBox { + bounds: Bounds; + getBounds(): Bounds; + /** - * Tests whether two bounds equal. - * @param {Bounds} a - * @param {Bounds} b + * Tests whether the given bounds equal this one. + * @param {Bounds} otherBounds */ - equals(a: Bounds, b: Bounds): boolean; + equals(otherBounds: Bounds): boolean; /** - * Tests whether a given bounds is valid. - * @param {Bounds} bounds + * Tests whether this bounding box is valid. */ - isValid(bounds: Bounds): boolean; + isValid(): boolean; /** - * Sets a bounding box from another bounding box. - * @param {Bounds} bounds - * @param {Bounds} other + * Sets this bounding box from another bounding box. + * @param {Bounds} otherBounds */ - setBounds(bounds: Bounds, other: Bounds): Bounds; + setBounds(otherBounds: Bounds): Bounds; /** - * Resets a bounds to infinity. - * @param {Bounds} bounds + * Resets this bounds to infinity. */ - reset(bounds: Bounds): Bounds; + reset(): Bounds; /** - * Adds points to a bounding box. - * @param {Bounds} bounds + * Adds a point to this bounding box. * @param {number|Number[]|TypedArray} xOrPoint * @param {number} y * @param {number} z */ addPoint( - bounds: Bounds, xOrPoint: number | number[] | TypedArray, y?: number, z?: number ): Bounds; /** - * Adds points to a bounding box. - * @param {Bounds} bounds + * Adds points to this bounding box. * @param {number[]} points A flattened array of 3D coordinates. */ - addPoints(bounds: Bounds, points: number[]): Bounds; + addPoints(points: number[]): Bounds; /** - * Adds two bounding boxes together. - * @param {Bounds} bounds + * Adds another bounding box to this one. * @param {number} xMin * @param {number} xMax * @param {number} yMin @@ -423,7 +425,6 @@ declare class BoundingBox { * @param {number} zMax */ addBounds( - bounds: Bounds, xMin: number, xMax: number, yMin: number, @@ -433,163 +434,124 @@ declare class BoundingBox { ): Bounds; /** - * Sets the min point of a bounding box. - * @param {Bounds} bounds + * Sets the min point of this bounding box. * @param {number} x * @param {number} y * @param {number} z */ - setMinPoint(bounds: Bounds, x: number, y: number, z: number): boolean; + setMinPoint(x: number, y: number, z: number): boolean; /** - * Sets the max point of a bounding box. - * @param {Bounds} bounds + * Sets the max point of this bounding box. * @param {number} x * @param {number} y * @param {number} z */ - setMaxPoint(bounds: Bounds, x: number, y: number, z: number): boolean; + setMaxPoint(x: number, y: number, z: number): boolean; /** - * Inflates a bounding box. + * Inflates this bounding box. * @param {number} [delta] The amount to inflate the bounding box by. */ inflate(delta?: number): Bounds; /** - * Scales a bounding box. - * @param {Bounds} bounds + * Scales this bounding box. * @param {number} sx * @param {number} sy * @param {number} sz */ - scale(bounds: Bounds, sx: number, sy: number, sz: number): boolean; - - /** - * Gets the center of a bounding box. - * @param {Bounds} bounds - */ - getCenter(bounds: Bounds): Vector3; + scale(sx: number, sy: number, sz: number): boolean; /** - * Scales a bounding box around its center. - * @param {Bounds} bounds - * @param {number} sx - * @param {number} sy - * @param {number} sz + * Gets the center of this bounding box. */ - scaleAboutCenter(bounds: Bounds, sx: number, sy: number, sz: number): boolean; + getCenter(): Vector3; /** - * Gets the bounding box side length. - * @param {Bounds} bounds + * Gets a side length of this bounding box. * @param {number} index */ - getLength(bounds: Bounds, index: number): number; + getLength(index: number): number; /** * Gets the lengths of all sides. - * @param {Bounds} bounds */ - getLengths(bounds: Bounds): Vector3; + getLengths(): Vector3; /** - * Gets the x range of a bounding box. - * @param {Bounds} bounds + * Gets the x range of this bounding box. */ - getXRange(bounds: Bounds): Vector2; + getXRange(): Vector2; /** - * Gets the y range of a bounding box. - * @param {Bounds} bounds + * Gets the y range of this bounding box. */ - getYRange(bounds: Bounds): Vector2; + getYRange(): Vector2; /** - * Gets the z range of a bounding box. - * @param {Bounds} bounds + * Gets the z range of this bounding box. */ - getZRange(bounds: Bounds): Vector2; + getZRange(): Vector2; /** - * Gets the maximum side length of the bounding box. - * @param {Bounds} bounds + * Gets the maximum side length of this bounding box. */ - getMaxLength(bounds: Bounds): number; + getMaxLength(): number; /** - * Gets the diagonal length of the bounding box. - * @param {Bounds} bounds + * Gets the diagonal length of this bounding box. */ - getDiagonalLength(bounds: Bounds): Nullable; + getDiagonalLength(): Nullable; /** - * Gets the squared diagonal length of the bounding box. - * @param {Bounds} bounds + * Gets the squared diagonal length of this bounding box. */ - getDiagonalLength2(bounds: Bounds): Nullable; + getDiagonalLength2(): Nullable; /** * Gets the min point. - * @param {Bounds} bounds */ - - getMinPoint(bounds: Bounds): Vector3; + getMinPoint(): Vector3; /** * Gets the max point. - * @param {Bounds} bounds */ - getMaxPoint(bounds: Bounds): Vector3; + getMaxPoint(): Vector3; /** - * Gets the corners of a bounding box. - * @param {Bounds} bounds + * Gets the corners of this bounding box. * @param {Vector3[]} corners */ - getCorners(bounds: Bounds, corners: Vector3[]): Vector3[]; + getCorners(corners: Vector3[]): Vector3[]; /** * Computes the two corner points with min and max coords. - * @param {Bounds} bounds * @param {Vector3} point1 * @param {Vector3} point2 */ - computeCornerPoints( - bounds: Bounds, - point1: Vector3, - point2: Vector3 - ): Vector3; + computeCornerPoints(point1: Vector3, point2: Vector3): Vector3; /** - * Transforms a bounding box. - * @param {Bounds} bounds + * Transforms this bounding box. * @param {mat4} transform - * @param {Bounds} out + * @param {Bounds} [out] */ - transformBounds( - bounds: Bounds, - transform: mat4, - out: Bounds - ): ReturnType; + transformBounds(transform: mat4, out?: Bounds): ReturnType; - computeScale3(bounds: Bounds, scale3: Vector3): Vector3; + /** + * Computes the half lengths of this bounding box. + * @param {Vector3} [scale3] + */ + computeScale3(scale3?: Vector3): Vector3; /** - * Compute local bounds. - * Not as fast as vtkPoints.getBounds() if u, v, w form a natural basis. - * @param {vtkPoints} points + * Compute local bounds along the given basis. * @param {array} u first vector * @param {array} v second vector * @param {array} w third vector */ - - computeLocalBounds( - points: vtkPoints, - u: Vector3, - v: Vector3, - w: Vector3 - ): Bounds; + computeLocalBounds(u: Vector3, v: Vector3, w: Vector3): Bounds; /** * The method returns a non-zero value if the bounding box is hit. @@ -597,76 +559,82 @@ declare class BoundingBox { * directions, coord[3] is the location of hit, and t is the parametric * coordinate along line. (Notes: the intersection ray dir[3] is NOT * normalized. Valid intersections will only occur between 0<=t<=1.) - * @param {Bounds} bounds * @param {Vector3} origin * @param {Vector3} dir * @param {Vector3} coord - * @param {number} tolerance + * @param {number[]} tolerance */ intersectBox( - bounds: Bounds, origin: Vector3, dir: Vector3, coord: Vector3, - tolerance: number - ): boolean; + tolerance: number[] + ): number; /** * Plane intersection with box * The plane is infinite in extent and defined by an origin and normal.The function indicates * whether the plane intersects, not the particulars of intersection points and such * The function returns non-zero if the plane and box intersect; zero otherwise. - * @param {Bounds} bounds * @param {Vector3} origin * @param {Vector3} normal */ - intersectPlane(bounds: Bounds, origin: Vector3, normal: Vector3): boolean; + intersectPlane(origin: Vector3, normal: Vector3): number; /** - * Do two bounding boxes intersect. - * @param {Bounds} bounds - * @param bBounds + * Intersect this bounding box with another one, storing the result in this + * one. + * @param {Bounds} otherBounds */ - intersect(bounds: Bounds, bBounds: Bounds): boolean; + intersect(otherBounds: Bounds): boolean; /** - * Do two bounding boxes intersect. - * @param {Bounds} bounds - * @param {Bounds} bBounds + * Does another bounding box intersect this one. + * @param {Bounds} otherBounds */ - intersects(bounds: Bounds, bBounds: Bounds): boolean; + intersects(otherBounds: Bounds): boolean; /** - * Does the bbox contain a given point. - * @param {Bounds} bounds + * Does this bounding box contain a given point. * @param {number} x * @param {number} y * @param {number} z */ - containsPoint(bounds: Bounds, x: number, y: number, z: number): boolean; + containsPoint(x: number, y: number, z: number): boolean; /** - * Is a bbox contained in another bbox. - * @param {Bounds} bounds - * @param {Bounds} other + * Is another bounding box contained in this one. + * @param {Bounds} otherBounds */ - contains(bounds: Bounds, other: Bounds): boolean; + contains(otherBounds: Bounds): boolean; /** - * Does a plane intersect a boox. - * @param {Bounds} bounds + * Does a plane cut this bounding box. * @param {Vector3} origin * @param {Vector3} normal */ - cutWithPlane(bounds: Bounds, origin: Vector3, normal: Vector3): boolean; + cutWithPlane(origin: Vector3, normal: Vector3): boolean; + + /** + * Compute the number of divisions given this bounding box and a target + * number of buckets/bins. Handles degenerate bounding boxes properly. + * @param {Number} totalBins - Target number of bins + * @param {Number[]} divs - Output array to store divisions [divX, divY, divZ] + * @param {Bounds} [adjustedBounds] - Output array to store adjusted bounds if needed + * @returns {Number} The actual total number of bins + */ + computeDivisions( + totalBins: number, + divs: number[], + adjustedBounds?: Bounds + ): number; /** - * Calculate the squared distance from point x to the specified bounds. + * Calculate the squared distance from point x to this bounding box. * @param {Vector3} x The point coordinates - * @param {Bounds} bounds The bounding box coordinates * @returns {Number} The squared distance to the bounds */ - distance2ToBounds(x: Vector3, bounds: Bounds): number; + distance2ToBounds(x: Vector3): number; } export interface IBoundingBoxInitialValues { @@ -710,8 +678,52 @@ declare const vtkBoundingBox: { intersects: typeof intersects; containsPoint: typeof containsPoint; contains: typeof contains; + computeDivisions: typeof computeDivisions; + clampDivisions: typeof clampDivisions; distance2ToBounds: typeof distance2ToBounds; INIT_BOUNDS: Bounds; }; +export declare const STATIC: Readonly<{ + equals: typeof equals; + isValid: typeof isValid; + setBounds: typeof setBounds; + reset: typeof reset; + addPoint: typeof addPoint; + addPoints: typeof addPoints; + addBounds: typeof addBounds; + setMinPoint: typeof setMinPoint; + setMaxPoint: typeof setMaxPoint; + inflate: typeof inflate; + scale: typeof scale; + scaleAboutCenter: typeof scaleAboutCenter; + getCenter: typeof getCenter; + getLength: typeof getLength; + getLengths: typeof getLengths; + getMaxLength: typeof getMaxLength; + getDiagonalLength: typeof getDiagonalLength; + getDiagonalLength2: typeof getDiagonalLength2; + getMinPoint: typeof getMinPoint; + getMaxPoint: typeof getMaxPoint; + getXRange: typeof getXRange; + getYRange: typeof getYRange; + getZRange: typeof getZRange; + getCorners: typeof getCorners; + computeCornerPoints: typeof computeCornerPoints; + computeLocalBounds: typeof computeLocalBounds; + transformBounds: typeof transformBounds; + computeScale3: typeof computeScale3; + cutWithPlane: typeof cutWithPlane; + intersectBox: typeof intersectBox; + intersectPlane: typeof intersectPlane; + intersect: typeof intersect; + intersects: typeof intersects; + containsPoint: typeof containsPoint; + contains: typeof contains; + computeDivisions: typeof computeDivisions; + clampDivisions: typeof clampDivisions; + distance2ToBounds: typeof distance2ToBounds; + INIT_BOUNDS: typeof INIT_BOUNDS; +}>; + export default vtkBoundingBox; diff --git a/Sources/Common/DataModel/Box/index.d.ts b/Sources/Common/DataModel/Box/index.d.ts index 9ba641cd5ba..0dffa3836f0 100644 --- a/Sources/Common/DataModel/Box/index.d.ts +++ b/Sources/Common/DataModel/Box/index.d.ts @@ -7,9 +7,9 @@ export interface IBoxInitialValues { } export interface IBoxIntersections { - t1; + t1: number; t2: number; - x1; + x1: Vector3; x2: Vector3; } @@ -86,9 +86,9 @@ export function newInstance(initialValues?: IBoxInitialValues): vtkBox; // bounding planes one at a time and compute the parametric coordinate // of each intersection and return the parametric values and the calculated points export function intersectWithLine( - bounds, - p1, - p2 + bounds: Bounds, + p1: Vector3, + p2: Vector3 ): IBoxIntersections | undefined; /** @@ -101,4 +101,5 @@ export declare const vtkBox: { extend: typeof extend; intersectWithLine: typeof intersectWithLine; }; +export declare const STATIC: Readonly>; export default vtkBox; diff --git a/Sources/Common/DataModel/CardinalSpline1D/index.d.ts b/Sources/Common/DataModel/CardinalSpline1D/index.d.ts index 786cad4cb16..6cd4c3586ce 100755 --- a/Sources/Common/DataModel/CardinalSpline1D/index.d.ts +++ b/Sources/Common/DataModel/CardinalSpline1D/index.d.ts @@ -1,8 +1,6 @@ import { Vector3 } from '../../../types'; -import vtkSpline1D, { - ISpline1DInitialValues, - BoundaryCondition, -} from '../Spline1D'; +import vtkSpline1D, { ISpline1DInitialValues } from '../Spline1D'; +import { BoundaryCondition } from '../Spline1D/Constants'; export interface ICardinalSpline1DInitialValues extends ISpline1DInitialValues {} @@ -38,7 +36,7 @@ export interface vtkCardinalSpline1D extends vtkSpline1D { work: Float32Array, x: Vector3, y: Vector3, - options: { + options?: { leftConstraint: BoundaryCondition; leftValue: number; rightConstraint: BoundaryCondition; diff --git a/Sources/Common/DataModel/Cell/index.d.ts b/Sources/Common/DataModel/Cell/index.d.ts index 5e185e74d8c..25ad1c96224 100755 --- a/Sources/Common/DataModel/Cell/index.d.ts +++ b/Sources/Common/DataModel/Cell/index.d.ts @@ -73,9 +73,14 @@ export interface vtkCell extends vtkObject { */ getNumberOfPoints(): number; - // getCellDimension(): void; - // intersectWithLine(p1: any, p2: any, tol: any, t: any, x: any, pcoords: any, subId: any): void; - // evaluatePosition(x: Vector3, closestPoint: Vector3, subId: number, pcoords: Vector3, dist2: number, weights: any): void; + /** Get the topological dimension of the cell. Virtual in vtkCell itself. */ + getCellDimension(): number | undefined; + + /** Virtual line-intersection hook implemented by concrete cell types. */ + intersectWithLine(...args: any[]): any; + + /** Virtual point-evaluation hook implemented by concrete cell types. */ + evaluatePosition(...args: any[]): any; } /** diff --git a/Sources/Common/DataModel/CellLinks/index.d.ts b/Sources/Common/DataModel/CellLinks/index.d.ts index 86706c30191..af53192b037 100644 --- a/Sources/Common/DataModel/CellLinks/index.d.ts +++ b/Sources/Common/DataModel/CellLinks/index.d.ts @@ -17,6 +17,11 @@ export interface ICellLink { cells: Nullable; } +/** + * Default (empty) link record used to initialize a point's link entry. + */ +export const InitLink: ICellLink; + export interface vtkCellLinks extends vtkObject { /** * Build the link list array from the input dataset. diff --git a/Sources/Common/DataModel/CellTypes/Constants.d.ts b/Sources/Common/DataModel/CellTypes/Constants.d.ts new file mode 100644 index 00000000000..297aa70aa59 --- /dev/null +++ b/Sources/Common/DataModel/CellTypes/Constants.d.ts @@ -0,0 +1,85 @@ +export declare const CellType: { + // Linear cells + readonly VTK_EMPTY_CELL: 0; + readonly VTK_VERTEX: 1; + readonly VTK_POLY_VERTEX: 2; + readonly VTK_LINE: 3; + readonly VTK_POLY_LINE: 4; + readonly VTK_TRIANGLE: 5; + readonly VTK_TRIANGLE_STRIP: 6; + readonly VTK_POLYGON: 7; + readonly VTK_PIXEL: 8; + readonly VTK_QUAD: 9; + readonly VTK_TETRA: 10; + readonly VTK_VOXEL: 11; + readonly VTK_HEXAHEDRON: 12; + readonly VTK_WEDGE: 13; + readonly VTK_PYRAMID: 14; + readonly VTK_PENTAGONAL_PRISM: 15; + readonly VTK_HEXAGONAL_PRISM: 16; + + // Quadratic, isoparametric cells + readonly VTK_QUADRATIC_EDGE: 21; + readonly VTK_QUADRATIC_TRIANGLE: 22; + readonly VTK_QUADRATIC_QUAD: 23; + readonly VTK_QUADRATIC_POLYGON: 36; + readonly VTK_QUADRATIC_TETRA: 24; + readonly VTK_QUADRATIC_HEXAHEDRON: 25; + readonly VTK_QUADRATIC_WEDGE: 26; + readonly VTK_QUADRATIC_PYRAMID: 27; + readonly VTK_BIQUADRATIC_QUAD: 28; + readonly VTK_TRIQUADRATIC_HEXAHEDRON: 29; + readonly VTK_QUADRATIC_LINEAR_QUAD: 30; + readonly VTK_QUADRATIC_LINEAR_WEDGE: 31; + readonly VTK_BIQUADRATIC_QUADRATIC_WEDGE: 32; + readonly VTK_BIQUADRATIC_QUADRATIC_HEXAHEDRON: 33; + readonly VTK_BIQUADRATIC_TRIANGLE: 34; + + // Cubic, isoparametric cell + readonly VTK_CUBIC_LINE: 35; + + // Special class of cells formed by convex group of points + readonly VTK_CONVEX_POINT_SET: 41; + + // Polyhedron cell (consisting of polygonal faces) + readonly VTK_POLYHEDRON: 42; + + // Higher order cells in parametric form + readonly VTK_PARAMETRIC_CURVE: 51; + readonly VTK_PARAMETRIC_SURFACE: 52; + readonly VTK_PARAMETRIC_TRI_SURFACE: 53; + readonly VTK_PARAMETRIC_QUAD_SURFACE: 54; + readonly VTK_PARAMETRIC_TETRA_REGION: 55; + readonly VTK_PARAMETRIC_HEX_REGION: 56; + + // Higher order cells + readonly VTK_HIGHER_ORDER_EDGE: 60; + readonly VTK_HIGHER_ORDER_TRIANGLE: 61; + readonly VTK_HIGHER_ORDER_QUAD: 62; + readonly VTK_HIGHER_ORDER_POLYGON: 63; + readonly VTK_HIGHER_ORDER_TETRAHEDRON: 64; + readonly VTK_HIGHER_ORDER_WEDGE: 65; + readonly VTK_HIGHER_ORDER_PYRAMID: 66; + readonly VTK_HIGHER_ORDER_HEXAHEDRON: 67; + + // Arbitrary order Lagrange elements (formulated separated from generic higher order cells) + readonly VTK_LAGRANGE_CURVE: 68; + readonly VTK_LAGRANGE_TRIANGLE: 69; + readonly VTK_LAGRANGE_QUADRILATERAL: 70; + readonly VTK_LAGRANGE_TETRAHEDRON: 71; + readonly VTK_LAGRANGE_HEXAHEDRON: 72; + readonly VTK_LAGRANGE_WEDGE: 73; + readonly VTK_LAGRANGE_PYRAMID: 74; + + readonly VTK_NUMBER_OF_CELL_TYPES: 75; +}; + +export type CellType = (typeof CellType)[keyof typeof CellType]; + +export declare const CellTypesStrings: string[]; + +declare const _default: { + CellType: typeof CellType; + CellTypesStrings: typeof CellTypesStrings; +}; +export default _default; diff --git a/Sources/Common/DataModel/CellTypes/index.d.ts b/Sources/Common/DataModel/CellTypes/index.d.ts new file mode 100644 index 00000000000..af10d7a1d03 --- /dev/null +++ b/Sources/Common/DataModel/CellTypes/index.d.ts @@ -0,0 +1,205 @@ +import { vtkObject } from '../../../interfaces'; + +/** + * + */ +export interface ICellTypesInitialValues { + size?: number; + maxId?: number; + extend?: number; + typeArray?: Uint8Array; + locationArray?: Uint32Array; +} + +export interface vtkCellTypes extends vtkObject { + /** + * Allocate memory for this array. Delete old storage only if necessary. + * @param {Number} [sz] (default: 512) + * @param {Number} [ext] (default: 1000) + */ + allocate(sz?: number, ext?: number): void; + + /** + * Standard DeepCopy method. Since this object contains no reference + * to other objects, there is no ShallowCopy. + * @param {vtkCellTypes} src + */ + deepCopy(src: vtkCellTypes): void; + + /** + * Delete cell by setting it to the empty cell type. + * @param {Number} cellId + */ + deleteCell(cellId: number): void; + + /** + * Return the location of the cell in the associated vtkCellArray. + * @param {Number} cellId + */ + getCellLocation(cellId: number): number; + + /** + * Return the type of cell. + * @param {Number} cellId + */ + getCellType(cellId: number): number; + + /** + * Get the growth increment of the arrays. + */ + getExtend(): number; + + /** + * Get the array of cell locations. + */ + getLocationArray(): number[]; + + /** + * Get the array of cell locations without copying it. + */ + getLocationArrayByReference(): Uint32Array; + + /** + * Get the maximum index inserted so far. + */ + getMaxId(): number; + + /** + * Return the number of types in the list. + */ + getNumberOfTypes(): number; + + /** + * Get the allocated size of the data. + */ + getSize(): number; + + /** + * Get the array of cell types. + */ + getTypeArray(): number[]; + + /** + * Get the array of cell types without copying it. + */ + getTypeArrayByReference(): Uint8Array; + + /** + * Add a cell at the specified id. + * @param {Number} cellId + * @param {Number} type + * @param {Number} loc + */ + insertCell(cellId: number, type: number, loc: number): void; + + /** + * Add a cell to the object in the next available slot. + * Returns the id of the inserted cell. + * @param {Number} type + * @param {Number} loc + */ + insertNextCell(type: number, loc: number): number; + + /** + * Add the type specified to the end of the list, with a location of -1. + * Returns the id of the inserted cell. + * @param {Number} type + */ + insertNextType(type: number): number; + + /** + * Return true if the type specified is contained in the list. + * @param {Number} type + */ + isType(type: number): boolean; + + /** + * Initialize the object without releasing memory. + */ + reset(): void; + + /** + * Specify a group of cell types. + * @param {Number} ncells + * @param {Uint8Array} cellTypes + * @param {Uint32Array} cellLocations + */ + setCellTypes( + ncells: number, + cellTypes: Uint8Array, + cellLocations: Uint32Array + ): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkCellTypes characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ICellTypesInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ICellTypesInitialValues +): void; + +/** + * Method used to create a new instance of vtkCellTypes. + * @param {ICellTypesInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: ICellTypesInitialValues +): vtkCellTypes; + +/** + * Given an int (as defined in vtkCellType.h) identifier for a class + * return its classname. + * @static + * @param {Number} typeId + */ +declare function getClassNameFromTypeId(typeId: number): string; + +/** + * Given a data object classname, return its int identifier (as + * defined in vtkCellType.h) + * @static + * @param {String} cellTypeString + */ +declare function getTypeIdFromClassName(cellTypeString: string): number; + +/** + * Fast check to determine if a cell type represents a linear or nonlinear cell. + * @static + * @param {Number} type + */ +declare function isLinear(type: number): boolean; + +/** + * Returns true for cell types that are made of several sub cells + * (triangle strips, poly lines and poly vertices). + * @static + * @param {Number} cellType + */ +declare function hasSubCells(cellType: number): boolean; + +export declare const STATIC: { + getClassNameFromTypeId: typeof getClassNameFromTypeId; + getTypeIdFromClassName: typeof getTypeIdFromClassName; + isLinear: typeof isLinear; + hasSubCells: typeof hasSubCells; +}; + +/** + * vtkCellTypes provides a mapping from cell ids to cell types and to the + * location of the cell definition in the associated vtkCellArray. + */ +export declare const vtkCellTypes: { + newInstance: typeof newInstance; + extend: typeof extend; + getClassNameFromTypeId: typeof getClassNameFromTypeId; + getTypeIdFromClassName: typeof getTypeIdFromClassName; + isLinear: typeof isLinear; + hasSubCells: typeof hasSubCells; +}; +export default vtkCellTypes; diff --git a/Sources/Common/DataModel/Collection/index.d.ts b/Sources/Common/DataModel/Collection/index.d.ts index 3753edcb78a..998123263f4 100644 --- a/Sources/Common/DataModel/Collection/index.d.ts +++ b/Sources/Common/DataModel/Collection/index.d.ts @@ -1,5 +1,4 @@ import { vtkObject } from '../../../interfaces'; -import { Nullable } from '../../../types'; /** * @@ -58,9 +57,9 @@ export interface vtkCollection extends vtkObject { empty(): boolean; /** - * get the current item and provided index, returns null if index is out of bounds + * get the current item and provided index, returns undefined if index is out of bounds */ - getItem(idx: number): Nullable; + getItem(idx: number): vtkObject | undefined; /** * Execute a passed function on every item in the collection @@ -89,9 +88,9 @@ export interface vtkCollection extends vtkObject { * Similar to forEach, but returns an array of resulting values. * @param callbackfn callback function to execute on each item in the collection, that returns a value. */ - map( - callbackfn: (value: T, index: number, array: readonly T[]) => void - ): void; + map( + callbackfn: (value: T, index: number, array: readonly T[]) => U + ): U[]; /** * Check each element for modified time and update the collection's diff --git a/Sources/Common/DataModel/Cone/index.d.ts b/Sources/Common/DataModel/Cone/index.d.ts index 176f23291ce..7de46d5e65f 100755 --- a/Sources/Common/DataModel/Cone/index.d.ts +++ b/Sources/Common/DataModel/Cone/index.d.ts @@ -1,5 +1,5 @@ -import { vtkObject } from '../../../interfaces'; import { Vector3 } from '../../../types'; +import vtkImplicitFunction from '../ImplicitFunction'; /** * @@ -8,7 +8,7 @@ export interface IConeInitialValues { angle?: number; } -export interface vtkCone extends vtkObject { +export interface vtkCone extends vtkImplicitFunction { /** * Given the point x evaluate the cone equation. * @param {Vector3} x The point coordinate. diff --git a/Sources/Common/DataModel/Cylinder/index.d.ts b/Sources/Common/DataModel/Cylinder/index.d.ts index fd325a428ba..3a0c25de32e 100755 --- a/Sources/Common/DataModel/Cylinder/index.d.ts +++ b/Sources/Common/DataModel/Cylinder/index.d.ts @@ -26,11 +26,6 @@ export interface vtkCylinder extends vtkImplicitFunction { */ evaluateGradient(xyz: Vector3): number[]; - /** - * Get the angle of the cone. - */ - getAngle(): number; - /** * Get the axis of the cylinder. */ @@ -56,12 +51,6 @@ export interface vtkCylinder extends vtkImplicitFunction { */ getRadius(): number; - /** - * Set the value representing the angle of the cone. - * @param {Number} angle The angle of the cone. - */ - setAngle(angle: number): boolean; - /** * Set the axis of the cylinder. * @param {Number[]} axis The axis coordinate. @@ -80,7 +69,7 @@ export interface vtkCylinder extends vtkImplicitFunction { * Set the axis of the cylinder. * @param {Number[]} axis The axis coordinate. */ - setAxisFrom(axis: number[]): boolean; + setAxisFrom(axis: number[]): void; /** * Set the center of the cylinder. @@ -100,7 +89,7 @@ export interface vtkCylinder extends vtkImplicitFunction { * Set the center of the cylinder. * @param {Number[]} center The center coordinate. */ - setCenterFrom(center: number[]): boolean; + setCenterFrom(center: number[]): void; /** * Set the radius of the cylinder. @@ -138,7 +127,7 @@ export function newInstance( * @param {Number[]} axis * @param {Number[]} x */ -export function evaluate( +declare function evaluate( radius: number, center: number[], axis: number[], @@ -154,4 +143,7 @@ export declare const vtkCylinder: { extend: typeof extend; evaluate: typeof evaluate; }; +export declare const STATIC: Readonly<{ + evaluate: typeof evaluate; +}>; export default vtkCylinder; diff --git a/Sources/Common/DataModel/DataSet/Constants.d.ts b/Sources/Common/DataModel/DataSet/Constants.d.ts index 16921ce7345..63ac94fb9e3 100644 --- a/Sources/Common/DataModel/DataSet/Constants.d.ts +++ b/Sources/Common/DataModel/DataSet/Constants.d.ts @@ -1,27 +1,39 @@ -export declare enum FieldAssociations { - FIELD_ASSOCIATION_POINTS = 0, - FIELD_ASSOCIATION_CELLS = 1, - FIELD_ASSOCIATION_NONE = 2, - FIELD_ASSOCIATION_POINTS_THEN_CELLS = 3, - FIELD_ASSOCIATION_VERTICES = 4, - FIELD_ASSOCIATION_EDGES = 5, - FIELD_ASSOCIATION_ROWS = 6, - NUMBER_OF_ASSOCIATIONS = 7, -} +export declare const FieldAssociations: { + readonly FIELD_ASSOCIATION_POINTS: 0; + readonly FIELD_ASSOCIATION_CELLS: 1; + readonly FIELD_ASSOCIATION_NONE: 2; + readonly FIELD_ASSOCIATION_POINTS_THEN_CELLS: 3; + readonly FIELD_ASSOCIATION_VERTICES: 4; + readonly FIELD_ASSOCIATION_EDGES: 5; + readonly FIELD_ASSOCIATION_ROWS: 6; + readonly NUMBER_OF_ASSOCIATIONS: 7; +}; -export declare enum FieldDataTypes { - UNIFORM = 0, - DATA_OBJECT_FIELD = 0, - COORDINATE = 1, - POINT_DATA = 1, - POINT = 2, - POINT_FIELD_DATA = 2, - CELL = 3, - CELL_FIELD_DATA = 3, - VERTEX = 4, - VERTEX_FIELD_DATA = 4, - EDGE = 5, - EDGE_FIELD_DATA = 5, - ROW = 6, - ROW_DATA = 6, -} +export type FieldAssociations = + (typeof FieldAssociations)[keyof typeof FieldAssociations]; + +export declare const FieldDataTypes: { + readonly UNIFORM: 0; + readonly DATA_OBJECT_FIELD: 0; + readonly COORDINATE: 1; + readonly POINT_DATA: 1; + readonly POINT: 2; + readonly POINT_FIELD_DATA: 2; + readonly CELL: 3; + readonly CELL_FIELD_DATA: 3; + readonly VERTEX: 4; + readonly VERTEX_FIELD_DATA: 4; + readonly EDGE: 5; + readonly EDGE_FIELD_DATA: 5; + readonly ROW: 6; + readonly ROW_DATA: 6; +}; + +export type FieldDataTypes = + (typeof FieldDataTypes)[keyof typeof FieldDataTypes]; + +declare const _default: { + FieldDataTypes: typeof FieldDataTypes; + FieldAssociations: typeof FieldAssociations; +}; +export default _default; diff --git a/Sources/Common/DataModel/DataSet/index.d.ts b/Sources/Common/DataModel/DataSet/index.d.ts index ed32d9c71fc..f69797a7a47 100755 --- a/Sources/Common/DataModel/DataSet/index.d.ts +++ b/Sources/Common/DataModel/DataSet/index.d.ts @@ -1,5 +1,6 @@ import vtkDataSetAttributes from '../DataSetAttributes'; import { vtkObject } from '../../../interfaces'; +import { Bounds, Vector3 } from '../../../types'; import { FieldAssociations, FieldDataTypes } from './Constants'; /** @@ -13,7 +14,44 @@ export interface vtkDataSet extends vtkObject { * @see vtkDataSetAttributes::initialize() * @see vtkFieldData::initialize() */ - initialize(): void; + initialize(): vtkDataSet; + + /** + * Compute the (X, Y, Z) bounds of the data. + */ + computeBounds(): void; + + /** + * Returns the squared length of the diagonal of the bounding box. + */ + getLength2(): number; + + /** + * Returns the length of the diagonal of the bounding box. + */ + getLength(): number; + + /** + * Returns the center of the bounding box as [x, y, z]. + */ + getCenter(): Vector3; + + /** + * Get the bounding box of a cell with the given cellId. + * @param {Number} cellId - The id of the cell + */ + getCellBounds(cellId: number): Bounds; + + /** + * Get the bounds for this dataset as [xmin, xmax, ymin, ymax, zmin, zmax]. + * @return {Bounds} The bounds for the dataset. + */ + getBounds(): Bounds; + + /** + * Get the bounds for this dataset by reference. + */ + getBoundsByReference(): Bounds; /** * Get dataset's cell data @@ -87,7 +125,7 @@ export function newInstance(initialValues?: IDataSetInitialValues): vtkDataSet; export declare const vtkDataSet: { newInstance: typeof newInstance; extend: typeof extend; - FieldAssociation: typeof FieldAssociations; + FieldAssociations: typeof FieldAssociations; FieldDataTypes: typeof FieldDataTypes; }; export default vtkDataSet; diff --git a/Sources/Common/DataModel/DataSetAttributes/Constants.d.ts b/Sources/Common/DataModel/DataSetAttributes/Constants.d.ts new file mode 100644 index 00000000000..b417d4e4570 --- /dev/null +++ b/Sources/Common/DataModel/DataSetAttributes/Constants.d.ts @@ -0,0 +1,113 @@ +export declare const AttributeTypes: { + readonly SCALARS: 0; + readonly VECTORS: 1; + readonly NORMALS: 2; + readonly TCOORDS: 3; + readonly TENSORS: 4; + readonly GLOBALIDS: 5; + readonly PEDIGREEIDS: 6; + readonly EDGEFLAG: 7; + readonly NUM_ATTRIBUTES: 8; +}; + +export type AttributeTypes = + (typeof AttributeTypes)[keyof typeof AttributeTypes]; + +export declare const AttributeLimitTypes: { + readonly MAX: 0; + readonly EXACT: 1; + readonly NOLIMIT: 2; +}; + +export type AttributeLimitTypes = + (typeof AttributeLimitTypes)[keyof typeof AttributeLimitTypes]; + +export declare const CellGhostTypes: { + /** + * The cell is present on multiple processors + */ + readonly DUPLICATECELL: 1; + /** + * The cell has more neighbors than in a regular mesh + */ + readonly HIGHCONNECTIVITYCELL: 2; + /** + * The cell has less neighbors than in a regular mesh + */ + readonly LOWCONNECTIVITYCELL: 4; + /** + * Other cells are present that refines it + */ + readonly REFINEDCELL: 8; + /** + * The cell is on the exterior of the data set + */ + readonly EXTERIORCELL: 16; + /** + * The cell is needed to maintain connectivity, but the data values should be + * ignored + */ + readonly HIDDENCELL: 32; +}; + +export type CellGhostTypes = + (typeof CellGhostTypes)[keyof typeof CellGhostTypes]; + +export declare const PointGhostTypes: { + /** + * The point is present on multiple processors + */ + readonly DUPLICATEPOINT: 1; + /** + * The point is needed to maintain connectivity, but the data values should be + * ignored + */ + readonly HIDDENPOINT: 2; +}; + +export type PointGhostTypes = + (typeof PointGhostTypes)[keyof typeof PointGhostTypes]; + +export declare const AttributeCopyOperations: { + readonly COPYTUPLE: 0; + readonly INTERPOLATE: 1; + readonly PASSDATA: 2; + /** + * All of the above + */ + readonly ALLCOPY: 3; +}; + +export type AttributeCopyOperations = + (typeof AttributeCopyOperations)[keyof typeof AttributeCopyOperations]; + +export declare const ghostArrayName: string; + +export declare const DesiredOutputPrecision: { + /** + * Use the point type that does not truncate any data + */ + readonly DEFAULT: 0; + /** + * Use Float32Array + */ + readonly SINGLE: 1; + /** + * Use Float64Array + */ + readonly DOUBLE: 2; +}; + +export type DesiredOutputPrecision = + (typeof DesiredOutputPrecision)[keyof typeof DesiredOutputPrecision]; + +declare const _default: { + AttributeCopyOperations: typeof AttributeCopyOperations; + AttributeLimitTypes: typeof AttributeLimitTypes; + AttributeTypes: typeof AttributeTypes; + CellGhostTypes: typeof CellGhostTypes; + DesiredOutputPrecision: typeof DesiredOutputPrecision; + PointGhostTypes: typeof PointGhostTypes; + ghostArrayName: typeof ghostArrayName; +}; +export default _default; diff --git a/Sources/Common/DataModel/DataSetAttributes/FieldData.d.ts b/Sources/Common/DataModel/DataSetAttributes/FieldData.d.ts index c197848f056..ba46392deb9 100755 --- a/Sources/Common/DataModel/DataSetAttributes/FieldData.d.ts +++ b/Sources/Common/DataModel/DataSetAttributes/FieldData.d.ts @@ -221,7 +221,7 @@ export interface vtkFieldData extends vtkObject { /** * */ - getState(): object; + getState(options?: object): object | null; } /** diff --git a/Sources/Common/DataModel/DataSetAttributes/index.d.ts b/Sources/Common/DataModel/DataSetAttributes/index.d.ts index 2d1981a23fb..9cf23d5e0a4 100755 --- a/Sources/Common/DataModel/DataSetAttributes/index.d.ts +++ b/Sources/Common/DataModel/DataSetAttributes/index.d.ts @@ -1,89 +1,16 @@ import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; import { IFieldDataInitialValues, vtkFieldData } from './FieldData'; import vtkDataArray from '../../Core/DataArray'; - -export enum AttributeTypes { - SCALARS, - VECTORS, - NORMALS, - TCOORDS, - TENSORS, - GLOBALIDS, - PEDIGREEIDS, - EDGEFLAG, - NUM_ATTRIBUTES, -} - -export enum AttributeLimitTypes { - MAX, - EXACT, - NOLIMIT, -} - -export enum CellGhostTypes { - /** - * The cell is present on multiple processors - */ - DUPLICATECELL, - /** - * The cell has more neighbors than in a regular mesh - */ - HIGHCONNECTIVITYCELL, - /** - * The cell has less neighbors than in a regular mesh - */ - LOWCONNECTIVITYCELL, - /** - * Tther cells are present that refines it. - */ - REFINEDCELL, - /** - * The cell is on the exterior of the data set - */ - EXTERIORCELL, - /** - * The cell is needed to maintain connectivity, but the data values should be ignored. - */ - HIDDENCELL, -} - -export enum PointGhostTypes { - /** - * The cell is present on multiple processors - */ - DUPLICATEPOINT, - /** - * The point is needed to maintain connectivity, but the data values should be ignored. - */ - HIDDENPOINT, -} - -export enum AttributeCopyOperations { - COPYTUPLE, - INTERPOLATE, - PASSDATA, - /** - * All of the above - */ - ALLCOPY, -} - -export const ghostArrayName: string; - -export enum DesiredOutputPrecision { - /** - * Use the point type that does not truncate any data - */ - DEFAULT, - /** - * Use Float32Array - */ - SINGLE, - /** - * Use Float64Array - */ - DOUBLE, -} +import { + AttributeCopyOperations, + AttributeLimitTypes, + AttributeTypes, + CellGhostTypes, + DesiredOutputPrecision, + PointGhostTypes, + ghostArrayName, +} from './Constants'; /** * @@ -109,7 +36,7 @@ export interface vtkDataSetAttributes extends vtkFieldData { * * @param {string} attType */ - getActiveAttribute(attType: string): any; + getActiveAttribute(attType: string): Nullable; /** * Get a list of attribute names that the given array @@ -225,7 +152,7 @@ export interface vtkDataSetAttributes extends vtkFieldData { * Override to allow proper handling of active attributes * @param {Number} arrayIdx The index of the array. */ - removeArrayByIndex(arrayIdx: number): void; + removeArrayByIndex(arrayIdx: number): boolean; /** * Called when initialize() is called. @@ -233,48 +160,6 @@ export interface vtkDataSetAttributes extends vtkFieldData { */ initializeAttributeCopyFlags(): void; - /** - * - * @param {Number} activeScalars - */ - setActiveScalars(activeScalars: number): boolean; - - /** - * - * @param {Number} activeVectors - */ - setActiveVectors(activeVectors: number): boolean; - - /** - * - * @param {Number} activeTensors - */ - setActiveTensors(activeTensors: number): boolean; - - /** - * - * @param {Number} activeNormals - */ - setActiveNormals(activeNormals: number): boolean; - - /** - * - * @param {Number} activeTCoords - */ - setActiveTCoords(activeTCoords: number): boolean; - - /** - * - * @param {Number} activeGlobalIds - */ - setActiveGlobalIds(activeGlobalIds: number): boolean; - - /** - * - * @param {Number} activePedigreeIds - */ - setActivePedigreeIds(activePedigreeIds: number): boolean; - /** * Try to copy the state of the other to ourselves by just using references. * @@ -330,43 +215,43 @@ export interface vtkDataSetAttributes extends vtkFieldData { * Set the scalar data. * @param {vtkDataArray} scalars The scalar data. */ - setScalars(scalars: vtkDataArray): boolean; + setScalars(scalars: vtkDataArray): number; /** * Set the vector data. * @param {vtkDataArray} vectors The vector data. */ - setVectors(vectors: vtkDataArray): boolean; + setVectors(vectors: vtkDataArray): number; /** * Set the normal data. * @param {vtkDataArray} normals The normal data. */ - setNormals(normals: vtkDataArray): boolean; + setNormals(normals: vtkDataArray): number; /** * Set the texture coordinate data. * @param {vtkDataArray} tcoords The texture coordinate data. */ - setTCoords(tcoords: vtkDataArray): boolean; + setTCoords(tcoords: vtkDataArray): number; /** * Set the tensor data. * @param {vtkDataArray} tensors The tensor data. */ - setTensors(tensors: vtkDataArray): boolean; + setTensors(tensors: vtkDataArray): number; /** * Set the global id data. * @param {vtkDataArray} globalIds The global id data. */ - setGlobalIds(globalIds: vtkDataArray): boolean; + setGlobalIds(globalIds: vtkDataArray): number; /** * Set the pedigree id data. * @param {vtkDataArray} pedigreeids The pedigree id data. */ - setPedigreeIds(pedigreeIds: vtkDataArray): boolean; + setPedigreeIds(pedigreeIds: vtkDataArray): number; /** * @@ -488,5 +373,13 @@ export function newInstance( export declare const vtkDataSetAttributes: { newInstance: typeof newInstance; extend: typeof extend; + // constants + AttributeCopyOperations: typeof AttributeCopyOperations; + AttributeLimitTypes: typeof AttributeLimitTypes; + AttributeTypes: typeof AttributeTypes; + CellGhostTypes: typeof CellGhostTypes; + DesiredOutputPrecision: typeof DesiredOutputPrecision; + PointGhostTypes: typeof PointGhostTypes; + ghostArrayName: typeof ghostArrayName; }; export default vtkDataSetAttributes; diff --git a/Sources/Common/DataModel/EdgeLocator/index.d.ts b/Sources/Common/DataModel/EdgeLocator/index.d.ts index 71d87b83891..2f5ddfd8e69 100644 --- a/Sources/Common/DataModel/EdgeLocator/index.d.ts +++ b/Sources/Common/DataModel/EdgeLocator/index.d.ts @@ -1,5 +1,3 @@ -import { Nullable } from '../../../types'; - /** * */ @@ -14,21 +12,39 @@ export interface IEdge { } export interface vtkEdgeLocator { + /** + * Whether the edge orientation is taken into account when generating keys. + */ + oriented: boolean; + + /** + * Map storing the inserted edges, indexed by their key. + */ + edgeMap: Map; + /** * Remove all the edges previously added. */ initialize(): void; /** - * Returns the inserted edge or null if no edge was inserted. + * Compute the unique key associated with the given edge point ids. * @param {Number} pointId0 Edge first point id * @param {Number} pointId1 Edge last point id - * @return {IEdge|null} an edge object ({ key, edgeId, value }) or null + * @return {Number} the edge key + */ + computeEdgeKey(pointId0: number, pointId1: number): number; + + /** + * Returns the inserted edge or undefined if no edge was inserted. + * @param {Number} pointId0 Edge first point id + * @param {Number} pointId1 Edge last point id + * @return {IEdge|undefined} an edge object ({ key, edgeId, value }) or undefined */ isInsertedEdge( pointId0: number, pointId1: number - ): Nullable>; + ): IEdge | undefined; /** * Insert edge if it does not already exist. @@ -68,7 +84,7 @@ export interface vtkEdgeLocator { * Method use to create a new instance of vtkEdgeLocator * @param {IEdgeLocatorInitialValues} [initialValues] for pre-setting some of its content */ -export function newInstance( +declare function newInstance( initialValues?: IEdgeLocatorInitialValues ): vtkEdgeLocator; diff --git a/Sources/Common/DataModel/ITKHelper/index.d.ts b/Sources/Common/DataModel/ITKHelper/index.d.ts index 2a3ea6d93f3..3efff233a97 100644 --- a/Sources/Common/DataModel/ITKHelper/index.d.ts +++ b/Sources/Common/DataModel/ITKHelper/index.d.ts @@ -16,7 +16,7 @@ export interface IOptions { export function convertItkToVtkImage( itkImage: any, options?: IOptions -): vtkImageData; +): vtkImageData | null; /** * Converts a vtk.js vtkImageData to an itk-wasm Image. @@ -38,7 +38,7 @@ export function convertVtkToItkImage( export function convertItkToVtkPolyData( itkPolyData: any, options?: IOptions -): vtkPolyData; +): vtkPolyData | null; /** * Converts a vtk.js vtkPolyData to an itk-wasm PolyData. @@ -56,7 +56,7 @@ export function convertVtkToItkPolyData( * vtkITKHelper is a helper which provides a set of functions to work with * itk-wasm module. */ -export declare const vtkITKHelper: { +declare const vtkITKHelper: { convertItkToVtkImage: typeof convertItkToVtkImage; convertVtkToItkImage: typeof convertVtkToItkImage; convertItkToVtkPolyData: typeof convertItkToVtkPolyData; diff --git a/Sources/Common/DataModel/ImageData/index.d.ts b/Sources/Common/DataModel/ImageData/index.d.ts index f9d9139dc56..eec3d96a0f1 100755 --- a/Sources/Common/DataModel/ImageData/index.d.ts +++ b/Sources/Common/DataModel/ImageData/index.d.ts @@ -26,7 +26,7 @@ export interface vtkImageData extends vtkDataSet { * and the data set. * @see vtkDataSet::initialize() */ - initialize(): void; + initialize(): vtkImageData; /** * Returns an object with `{ minimum, maximum, average, variance, sigma, count }` @@ -133,6 +133,13 @@ export interface vtkImageData extends vtkDataSet { */ getDirection(): mat3; + /** + * Direction is a `mat3` matrix corresponding to the axes directions in + * world coordinates for the I, J, K axes of the image. Direction must form + * an orthonormal basis. + */ + getDirectionByReference(): mat3; + /** * The maximal extent of the projection. * @default [0, -1, 0, -1, 0, -1] @@ -167,7 +174,7 @@ export interface vtkImageData extends vtkDataSet { * 1D data array. * @param {Number} index */ - getPoint(index: number): Vector3; + getPoint(index: number): Vector3 | null; /** * Get the origin of the dataset. The origin is the position in world @@ -298,6 +305,16 @@ export interface vtkImageData extends vtkDataSet { e22: number ): boolean; + /** + * The direction matrix is a 3x3 basis for the I, J, K axes + * of the image. The rows of the matrix correspond to the + * axes directions in world coordinates. Direction must + * form an orthonormal basis, results are undefined if + * it is not. + * @param {mat3} direction + */ + setDirectionFrom(direction: mat3): void; + /** * Set the extent. * @param {Extent} extent @@ -320,7 +337,7 @@ export interface vtkImageData extends vtkDataSet { y2: number, z1: number, z2: number - ): void; + ): boolean; /** * Set the origin of the image. @@ -332,7 +349,7 @@ export interface vtkImageData extends vtkDataSet { * Set the origin of the image. * @param {Vector3} origin The coordinate of the origin point. */ - setOriginFrom(origin: Vector3): boolean; + setOriginFrom(origin: Vector3): void; /** * @@ -344,7 +361,7 @@ export interface vtkImageData extends vtkDataSet { * * @param spacing */ - setSpacingFrom(spacing: number[]): boolean; + setSpacingFrom(spacing: number[]): void; /** * this is the fast version, requires vec3 arguments diff --git a/Sources/Common/DataModel/ImplicitBoolean/Constants.d.ts b/Sources/Common/DataModel/ImplicitBoolean/Constants.d.ts new file mode 100644 index 00000000000..0e874d48dde --- /dev/null +++ b/Sources/Common/DataModel/ImplicitBoolean/Constants.d.ts @@ -0,0 +1,12 @@ +export declare const Operation: { + readonly UNION: 0; + readonly INTERSECTION: 1; + readonly DIFFERENCE: 2; +}; + +export type Operation = (typeof Operation)[keyof typeof Operation]; + +declare const _default: { + Operation: typeof Operation; +}; +export default _default; diff --git a/Sources/Common/DataModel/ImplicitBoolean/index.d.ts b/Sources/Common/DataModel/ImplicitBoolean/index.d.ts new file mode 100644 index 00000000000..c7c7eea84d8 --- /dev/null +++ b/Sources/Common/DataModel/ImplicitBoolean/index.d.ts @@ -0,0 +1,126 @@ +import { Vector3 } from '../../../types'; +import vtkImplicitFunction, { + IImplicitFunctionInitialValues, +} from '../ImplicitFunction'; +import { Operation } from './Constants'; + +/** + * + */ +export interface IImplicitBooleanInitialValues extends IImplicitFunctionInitialValues { + operation?: Operation; + functions?: vtkImplicitFunction[]; +} + +export interface vtkImplicitBoolean extends vtkImplicitFunction { + /** + * Add an implicit function to the list of functions to combine. + * The function is ignored if it is already in the list. + * @param {vtkImplicitFunction} f + */ + addFunction(f: vtkImplicitFunction): void; + + /** + * Evaluate the combination of all the implicit functions, following the + * current operation. + * @param {Vector3} xyz The point coordinate. + */ + evaluateFunction(xyz: Vector3): number; + + /** + * @param {Vector3} xyz The point coordinate. + */ + evaluateGradient(xyz: Vector3): number[]; + + /** + * Get the list of implicit functions being combined. + */ + getFunctions(): vtkImplicitFunction[]; + + /** + * The modified time is the maximum of this object's and of all the + * combined functions'. + */ + getMTime(): number; + + /** + * Get the operation used to combine the functions. + */ + getOperation(): Operation; + + /** + * Get the name of the current operation. + */ + getOperationAsString(): string; + + /** + * Whether the given function is part of the combination. + * @param {vtkImplicitFunction} f + */ + hasFunction(f: vtkImplicitFunction): boolean; + + /** + * Remove every function from the combination. + */ + removeAllFunctions(): void; + + /** + * Remove the given function from the combination. + * @param {vtkImplicitFunction} f + */ + removeFunction(f: vtkImplicitFunction): void; + + /** + * Set the operation used to combine the functions. + * @param {Operation} operation + */ + setOperation(operation: Operation): boolean; + + /** + * Set the operation to Operation.DIFFERENCE. + */ + setOperationToDifference(): boolean; + + /** + * Set the operation to Operation.INTERSECTION. + */ + setOperationToIntersection(): boolean; + + /** + * Set the operation to Operation.UNION. + */ + setOperationToUnion(): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkImplicitBoolean characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IImplicitBooleanInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IImplicitBooleanInitialValues +): void; + +/** + * Method used to create a new instance of vtkImplicitBoolean. + * @param {IImplicitBooleanInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IImplicitBooleanInitialValues +): vtkImplicitBoolean; + +/** + * vtkImplicitBoolean combines a list of implicit functions with a boolean + * operation: union, intersection or difference. + */ +export declare const vtkImplicitBoolean: { + newInstance: typeof newInstance; + extend: typeof extend; + // constants + Operation: typeof Operation; +}; +export default vtkImplicitBoolean; diff --git a/Sources/Common/DataModel/ImplicitFunction/index.d.ts b/Sources/Common/DataModel/ImplicitFunction/index.d.ts index 300bbb32dc1..1cbe432d8ff 100644 --- a/Sources/Common/DataModel/ImplicitFunction/index.d.ts +++ b/Sources/Common/DataModel/ImplicitFunction/index.d.ts @@ -28,7 +28,7 @@ export interface vtkImplicitFunction extends vtkObject { /** * Get the transform. undefined by default */ - getTransform(): vtkTransform; + getTransform(): vtkTransform | undefined; /** * Set the transform to apply on all points. diff --git a/Sources/Common/DataModel/IncrementalOctreeNode/index.d.ts b/Sources/Common/DataModel/IncrementalOctreeNode/index.d.ts index ff626149eb6..fbe093b6b3c 100644 --- a/Sources/Common/DataModel/IncrementalOctreeNode/index.d.ts +++ b/Sources/Common/DataModel/IncrementalOctreeNode/index.d.ts @@ -1,16 +1,17 @@ import { vtkObject } from '../../../interfaces'; -import { Bounds, Vector3 } from '../../../types'; +import { Bounds, Nullable, Vector3 } from '../../../types'; import vtkPoints from '../../Core/Points'; /** * */ export interface IIncrementalOctreeNodeInitialValues { pointIdSet?: number[]; - minBounds?: Bounds; - maxBounds?: Bounds; - minDataBounds?: Bounds; - maxDataBounds?: Bounds; - parent?: vtkIncrementalOctreeNode; + numberOfPoints?: number; + minBounds?: Vector3; + maxBounds?: Vector3; + minDataBounds?: Vector3; + maxDataBounds?: Vector3; + parent?: Nullable; children?: vtkIncrementalOctreeNode[]; } @@ -18,7 +19,7 @@ export interface vtkIncrementalOctreeNode extends vtkObject { /** * Create a list object for storing point indices. */ - createPointIdSet(): void; + createPointIdSet(initSize: number, growSize: number): void; /** * Set the spatial bounding box of the node. This function sets a default @@ -48,6 +49,128 @@ export interface vtkIncrementalOctreeNode extends vtkObject { */ getBounds(bounds: Bounds): void; + /** + * Get the minimum coordinates of the spatial bounding box of the node. + */ + getMinBounds(): Nullable; + + /** + * Get the minimum coordinates of the spatial bounding box of the node by + * reference. + */ + getMinBoundsByReference(): Nullable; + + /** + * Set the minimum coordinates of the spatial bounding box of the node. + * + * The array accessors are generated with a size of six, so the setter only + * accepts six values even though the node itself keeps three of them. + * + * @param {Bounds} minBounds + */ + setMinBounds(minBounds: Bounds): boolean; + + /** + * Set the minimum coordinates of the spatial bounding box of the node. + * + * @param {Bounds} minBounds + */ + setMinBoundsFrom(minBounds: Vector3): void; + + /** + * Get the maximum coordinates of the spatial bounding box of the node. + */ + getMaxBounds(): Nullable; + + /** + * Get the maximum coordinates of the spatial bounding box of the node by + * reference. + */ + getMaxBoundsByReference(): Nullable; + + /** + * Set the maximum coordinates of the spatial bounding box of the node. + * + * @param {Bounds} maxBounds + */ + setMaxBounds(maxBounds: Bounds): boolean; + + /** + * Set the maximum coordinates of the spatial bounding box of the node. + * + * @param {Bounds} maxBounds + */ + setMaxBoundsFrom(maxBounds: Vector3): void; + + /** + * Get the minimum coordinates of the data bounding box of the node. + */ + getMinDataBounds(): Nullable; + + /** + * Get the minimum coordinates of the data bounding box of the node by + * reference. + */ + getMinDataBoundsByReference(): Nullable; + + /** + * Set the minimum coordinates of the data bounding box of the node. + * + * @param {Bounds} minDataBounds + */ + setMinDataBounds(minDataBounds: Bounds): boolean; + + /** + * Set the minimum coordinates of the data bounding box of the node. + * + * @param {Bounds} minDataBounds + */ + setMinDataBoundsFrom(minDataBounds: Vector3): void; + + /** + * Get the maximum coordinates of the data bounding box of the node. + */ + getMaxDataBounds(): Nullable; + + /** + * Get the maximum coordinates of the data bounding box of the node by + * reference. + */ + getMaxDataBoundsByReference(): Nullable; + + /** + * Set the maximum coordinates of the data bounding box of the node. + * + * @param {Bounds} maxDataBounds + */ + setMaxDataBounds(maxDataBounds: Bounds): boolean; + + /** + * Set the maximum coordinates of the data bounding box of the node. + * + * @param {Bounds} maxDataBounds + */ + setMaxDataBoundsFrom(maxDataBounds: Vector3): void; + + /** + * Get the list of point indices maintained by the node, or null while the + * node holds none. + */ + getPointIdSet(): Nullable; + + /** + * Get the number of points maintained by the node. The node does not seed + * the counter, so it is undefined unless one was passed as an initial value. + */ + getNumberOfPoints(): number | undefined; + + /** + * Set the parent node. + * + * @param {vtkIncrementalOctreeNode} parent + */ + setParent(parent: vtkIncrementalOctreeNode): boolean; + /** * @param {Vector3} point */ @@ -154,7 +277,7 @@ export interface vtkIncrementalOctreeNode extends vtkObject { pntIdx: number, maxPts: number, ptMode: number - ): void; + ): number; /** * Divide this LEAF node into eight child nodes as the number of points @@ -268,12 +391,12 @@ export interface vtkIncrementalOctreeNode extends vtkObject { * * @param publicAPI object on which methods will be bounds (public) * @param model object on which data structure will be bounds (protected) - * @param {object} [initialValues] (default: {}) + * @param {IIncrementalOctreeNodeInitialValues} [initialValues] (default: {}) */ export function extend( publicAPI: object, model: object, - initialValues?: object + initialValues?: IIncrementalOctreeNodeInitialValues ): void; // ---------------------------------------------------------------------------- diff --git a/Sources/Common/DataModel/IncrementalOctreePointLocator/index.d.ts b/Sources/Common/DataModel/IncrementalOctreePointLocator/index.d.ts index fb0fb3c51d3..39d8c3fe7aa 100644 --- a/Sources/Common/DataModel/IncrementalOctreePointLocator/index.d.ts +++ b/Sources/Common/DataModel/IncrementalOctreePointLocator/index.d.ts @@ -1,25 +1,318 @@ -import { vtkObject } from '../../../interfaces'; +import { Bounds, Nullable, Vector3 } from '../../../types'; import vtkPoints from '../../Core/Points'; import vtkIncrementalOctreeNode from '../IncrementalOctreeNode'; -import { IAbstractPointLocatorInitialValues } from '../AbstractPointLocator'; +import vtkAbstractPointLocator, { + IAbstractPointLocatorInitialValues, +} from '../AbstractPointLocator'; /** * */ export interface IIncrementalOctreePointLocatorInitialValues extends IAbstractPointLocatorInitialValues { - fudgeFactor: number; - octreeMaxDimSize: number; - buildCubicOctree: boolean; - maxPointsPerLeaf: number; - insertTolerance2: number; - locatorPoints: vtkPoints; - octreeRootNode: vtkIncrementalOctreeNode; - numberOfNodes: number; + fudgeFactor?: number; + octreeMaxDimSize?: number; + buildCubicOctree?: boolean; + maxPointsPerLeaf?: number; + insertTolerance2?: number; + locatorPoints?: vtkPoints; + octreeRootNode?: vtkIncrementalOctreeNode; + numberOfNodes?: number; } -type vtkIncrementalOctreePointLocatorBase = vtkObject; +/** + * A point index paired with the squared distance to the query point. The index + * is -1 when no point was found. + */ +export type PointIdAndDistance2 = [number, number]; + +/** + * The index of an already inserted point (-1 when the point is new) together + * with the leaf node that does or would contain it. + */ +export interface IInsertedPointResult { + pointIdx: number; + leafContainer: vtkIncrementalOctreeNode; +} + +export interface IInsertUniquePointResult { + success: boolean; + idx: number; +} + +type vtkIncrementalOctreePointLocatorBase = vtkAbstractPointLocator; + +export interface vtkIncrementalOctreePointLocator extends vtkIncrementalOctreePointLocatorBase { + /** + * Delete the octree search structure and release the points being located. + */ + freeSearchStructure(): void; + + /** + * Given a leaf node, find the closest point it stores to the given point. + * + * @param {vtkIncrementalOctreeNode} leafNode + * @param {Vector3} point + * @returns {PointIdAndDistance2} + */ + findClosestPointInLeafNode( + leafNode: vtkIncrementalOctreeNode, + point: Vector3 + ): PointIdAndDistance2; + + /** + * Find the closest point within a squared radius of the given point, skipping + * maskNode. refDist2 bounds the sub-trees that are worth descending into. + * + * @param {Vector3} point + * @param {Number} radius2 the squared search radius + * @param {vtkIncrementalOctreeNode} maskNode a node to exclude from the search + * @param {Number} minDist2 the initial upper bound on the squared distance; + * the search stops descending once it cannot improve on it + * @param {Number} refDist2 + * @returns {PointIdAndDistance2} + */ + findClosestPointInSphere( + point: Vector3, + radius2: number, + maskNode: vtkIncrementalOctreeNode, + minDist2: number, + refDist2: number + ): PointIdAndDistance2; + + /** + * Same as findClosestPointInSphere, using the octree extent as the reference + * distance. + * + * @param {Vector3} point + * @param {Number} radius2 the squared search radius + * @param {vtkIncrementalOctreeNode} maskNode a node to exclude from the search + * @returns {PointIdAndDistance2} + */ + findClosestPointInSphereWithTolerance( + point: Vector3, + radius2: number, + maskNode: vtkIncrementalOctreeNode + ): PointIdAndDistance2; + + /** + * Find, in a leaf node, a point with exactly the same coordinates as the + * given one, reading the locator points as 32-bit floats. + * + * @param {vtkIncrementalOctreeNode} leafNode + * @param {Vector3} point + * @returns {Number} the point index, or -1 when there is no duplicate + */ + findDuplicateFloatTypePointInVisitedLeafNode( + leafNode: vtkIncrementalOctreeNode, + point: Vector3 + ): number; + + /** + * Find, in a leaf node, a point with exactly the same coordinates as the + * given one, reading the locator points as 64-bit floats. + * + * @param {vtkIncrementalOctreeNode} leafNode + * @param {Vector3} point + * @returns {Number} the point index, or -1 when there is no duplicate + */ + findDuplicateDoubleTypePointInVisitedLeafNode( + leafNode: vtkIncrementalOctreeNode, + point: Vector3 + ): number; + + /** + * Find, in a leaf node, a point with exactly the same coordinates as the + * given one, dispatching on the data type of the locator points. + * + * @param {vtkIncrementalOctreeNode} leafNode + * @param {Vector3} point + * @returns {Number} the point index, or -1 when there is no duplicate + */ + findDuplicatePointInLeafNode( + leafNode: vtkIncrementalOctreeNode, + point: Vector3 + ): number; + + /** + * Initialize the octree with an empty root node covering the given bounds and + * take ownership of the points object used for insertion. + * + * @param {vtkPoints} points + * @param {Bounds} bounds + * @param {Number} [estNumPts] (default: 0) + * @returns {Boolean} false when no valid points object was given + */ + initPointInsertion( + points: vtkPoints, + bounds: Bounds, + estNumPts?: number + ): boolean; + + /** + * Insert a point at the given index, without checking for duplicates. + * initPointInsertion must have been called first. + * + * @param {Number} ptId + * @param {Vector3} x + */ + insertPoint(ptId: number, x: Vector3): void; + + /** + * Append a point, without checking for duplicates. initPointInsertion must + * have been called first. + * + * @param {Vector3} x + * @returns {Number} the index of the inserted point + */ + insertNextPoint(x: Vector3): number; + + /** + * Insert a point only if no point already lies within the insertion + * tolerance of it. + * + * @param {Vector3} point + * @returns {IInsertUniquePointResult} success is false when a point was + * already there, in which case idx is that existing point's index + */ + insertUniquePoint(point: Vector3): IInsertUniquePointResult; -export interface vtkIncrementalOctreePointLocator extends vtkIncrementalOctreePointLocatorBase {} + /** + * Determine whether a point is already present, dispatching on whether the + * insertion tolerance is zero. + * + * @param {Vector3} x + * @returns {IInsertedPointResult} + */ + isInsertedPoint( + x: Vector3, + leafContainer?: vtkIncrementalOctreeNode + ): IInsertedPointResult; + + /** + * Determine whether a point with exactly these coordinates is already + * present in the leaf node that contains it. + * + * @param {Vector3} x + * @returns {IInsertedPointResult} + */ + isInsertedPointForZeroTolerance(x: Vector3): IInsertedPointResult; + + /** + * Determine whether a point lies within the insertion tolerance of an + * already inserted point. + * + * @param {Vector3} x + * @returns {IInsertedPointResult} + */ + isInsertedPointForNonZeroTolerance(x: Vector3): IInsertedPointResult; + + /** + * Get whether the octree root is inflated to a cube so that every octant is + * a cube too. + * @default false + */ + getBuildCubicOctree(): boolean; + + /** + * Get the padding applied to the lower bounds of the octree root. + * @default 0 + */ + getFudgeFactor(): number; + + /** + * Get the squared insertion tolerance, i.e. the square of the tolerance. + * @default 0.000001 + */ + getInsertTolerance2(): number; + + /** + * Get the points into which insertion writes. + */ + getLocatorPoints(): Nullable; + + /** + * Get the maximum number of points a leaf node may hold before it is + * sub-divided. + * @default 128 + */ + getMaxPointsPerLeaf(): number; + + /** + * Get the number of nodes currently in the octree. + * @default 0 + */ + getNumberOfNodes(): number; + + /** + * Get the largest side length of the octree root node. + * @default 0 + */ + getOctreeMaxDimSize(): number; + + /** + * Get the root node of the octree. + */ + getOctreeRootNode(): Nullable; + + /** + * Set whether the octree root is inflated to a cube so that every octant is + * a cube too. Must be set before initPointInsertion. + * + * @param {Boolean} buildCubicOctree + */ + setBuildCubicOctree(buildCubicOctree: boolean): boolean; + + /** + * Set the padding applied to the lower bounds of the octree root. + * + * @param {Number} fudgeFactor + */ + setFudgeFactor(fudgeFactor: number): boolean; + + /** + * Set the squared insertion tolerance. initPointInsertion recomputes it from + * the locator tolerance. + * + * @param {Number} insertTolerance2 + */ + setInsertTolerance2(insertTolerance2: number): boolean; + + /** + * Set the points into which insertion writes. + * + * @param {vtkPoints} locatorPoints + */ + setLocatorPoints(locatorPoints: vtkPoints): boolean; + + /** + * Set the maximum number of points a leaf node may hold before it is + * sub-divided. + * + * @param {Number} maxPointsPerLeaf + */ + setMaxPointsPerLeaf(maxPointsPerLeaf: number): boolean; + + /** + * Set the number of nodes in the octree. + * + * @param {Number} numberOfNodes + */ + setNumberOfNodes(numberOfNodes: number): boolean; + + /** + * Set the largest side length of the octree root node. + * + * @param {Number} octreeMaxDimSize + */ + setOctreeMaxDimSize(octreeMaxDimSize: number): boolean; + + /** + * Set the root node of the octree. + * + * @param {vtkIncrementalOctreeNode} octreeRootNode + */ + setOctreeRootNode(octreeRootNode: vtkIncrementalOctreeNode): boolean; +} // ---------------------------------------------------------------------------- // Static API diff --git a/Sources/Common/DataModel/KochanekSpline1D/index.d.ts b/Sources/Common/DataModel/KochanekSpline1D/index.d.ts index a94c60725ff..9d788cb8bfa 100755 --- a/Sources/Common/DataModel/KochanekSpline1D/index.d.ts +++ b/Sources/Common/DataModel/KochanekSpline1D/index.d.ts @@ -1,7 +1,5 @@ -import vtkSpline1D, { - ISpline1DInitialValues, - BoundaryCondition, -} from '../Spline1D'; +import vtkSpline1D, { ISpline1DInitialValues } from '../Spline1D'; +import { BoundaryCondition } from '../Spline1D/Constants'; export interface IKochanekSpline1DInitialValues extends ISpline1DInitialValues { tension?: number; @@ -41,7 +39,7 @@ export interface vtkKochanekSpline1D extends vtkSpline1D { work: Float32Array, x: number[], y: number[], - options: { + options?: { leftConstraint: BoundaryCondition; leftValue: number; rightConstraint: BoundaryCondition; diff --git a/Sources/Common/DataModel/Line/Constants.d.ts b/Sources/Common/DataModel/Line/Constants.d.ts new file mode 100644 index 00000000000..0bd384977f7 --- /dev/null +++ b/Sources/Common/DataModel/Line/Constants.d.ts @@ -0,0 +1,13 @@ +export declare const IntersectionState: { + readonly NO_INTERSECTION: 0; + readonly YES_INTERSECTION: 1; + readonly ON_LINE: 2; +}; + +export type IntersectionState = + (typeof IntersectionState)[keyof typeof IntersectionState]; + +declare const _default: { + IntersectionState: typeof IntersectionState; +}; +export default _default; diff --git a/Sources/Common/DataModel/Line/index.d.ts b/Sources/Common/DataModel/Line/index.d.ts index 0b151f410f1..8b68410b2fd 100755 --- a/Sources/Common/DataModel/Line/index.d.ts +++ b/Sources/Common/DataModel/Line/index.d.ts @@ -1,15 +1,12 @@ import { quat } from 'gl-matrix'; import { Vector3, Vector2, Nullable } from '../../../types'; import vtkCell from '../Cell'; +import { IntersectionState } from './Constants'; -export enum IntersectionState { - NO_INTERSECTION, - YES_INTERSECTION, - ON_LINE, -} +export type { IntersectionState }; export interface ILineInitialValues { - orientations: Nullable; + orientations?: Nullable; } export interface IIntersectWithLine { @@ -120,7 +117,7 @@ export function newInstance(initialValues?: ILineInitialValues): vtkLine; * @param {Vector3} p2 * @param {Vector3} [closestPoint] */ -export function distanceToLine( +declare function distanceToLine( x: Vector3, p1: Vector3, p2: Vector3, @@ -151,7 +148,7 @@ export function distanceToLine( * @param {Vector3} u * @param {Vector3} v */ -export function intersection( +declare function intersection( a1: Vector3, a2: Vector3, b1: Vector3, @@ -171,5 +168,10 @@ export declare const vtkLine: { extend: typeof extend; distanceToLine: typeof distanceToLine; intersection: typeof intersection; + IntersectionState: typeof IntersectionState; }; +export declare const STATIC: Readonly<{ + distanceToLine: typeof distanceToLine; + intersection: typeof intersection; +}>; export default vtkLine; diff --git a/Sources/Common/DataModel/Locator/index.d.ts b/Sources/Common/DataModel/Locator/index.d.ts index 32a5cd780a0..35e12235d4d 100644 --- a/Sources/Common/DataModel/Locator/index.d.ts +++ b/Sources/Common/DataModel/Locator/index.d.ts @@ -1,4 +1,5 @@ import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; import vtkDataSet from '../DataSet'; /** @@ -25,7 +26,7 @@ export interface vtkLocator extends vtkObject { * * @returns {vtkDataSet} The dataset associated with this locator. */ - getDataSet(): vtkDataSet; + getDataSet(): Nullable; /** * Get the current level of the locator. @@ -72,14 +73,6 @@ export interface vtkLocator extends vtkObject { */ setDataSet(dataSet: vtkDataSet): boolean; - /** - * Set the current level of the locator. - * - * @param {Number} level - The level to set. - * @returns {Boolean} Whether the operation was successful. - */ - setLevel(level: number): boolean; - /** * Set the maximum level of the locator. * diff --git a/Sources/Common/DataModel/Molecule/index.d.ts b/Sources/Common/DataModel/Molecule/index.d.ts new file mode 100644 index 00000000000..61db4a6bae3 --- /dev/null +++ b/Sources/Common/DataModel/Molecule/index.d.ts @@ -0,0 +1,138 @@ +import { vtkObject } from '../../../interfaces'; + +/** + * Chemical JSON description of the atoms of the molecule, e.g. + * `{ elements: { number: [...] }, coords: { '3d': [...] } }`. + */ +export type MoleculeAtoms = Record; + +/** + * Chemical JSON description of the bonds of the molecule. + */ +export type MoleculeBonds = Record; + +/** + * + */ +export interface IMoleculeInitialValues { + /** + * Version of the chemical JSON format the molecule follows. + */ + 'chemical json'?: number; + name?: string; + inchi?: string; + formula?: string; + atoms?: MoleculeAtoms; + bonds?: MoleculeBonds; + properties?: Record; +} + +export interface vtkMolecule extends vtkObject { + /** + * The field name is `chemical json`, so the generated accessor name + * contains a space. + */ + 'getChemical json'(): number; + + /** + * @see getChemical json + */ + 'setChemical json'(chemicalJson: number): boolean; + + /** + * + */ + getAtoms(): MoleculeAtoms; + + /** + * + */ + getBonds(): MoleculeBonds; + + /** + * + */ + getFormula(): string; + + /** + * + */ + getInchi(): string; + + /** + * + */ + getName(): string; + + /** + * + */ + getProperties(): Record; + + /** + * + * @param {MoleculeAtoms} atoms + */ + setAtoms(atoms: MoleculeAtoms): boolean; + + /** + * + * @param {MoleculeBonds} bonds + */ + setBonds(bonds: MoleculeBonds): boolean; + + /** + * + * @param {String} formula + */ + setFormula(formula: string): boolean; + + /** + * + * @param {String} inchi + */ + setInchi(inchi: string): boolean; + + /** + * + * @param {String} name + */ + setName(name: string): boolean; + + /** + * + * @param properties + */ + setProperties(properties: Record): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkMolecule characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IMoleculeInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IMoleculeInitialValues +): void; + +/** + * Method used to create a new instance of vtkMolecule. + * @param {IMoleculeInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IMoleculeInitialValues +): vtkMolecule; + +/** + * vtkMolecule holds the chemical JSON description of a molecule: its atoms, + * bonds and associated properties. + */ +export declare const vtkMolecule: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkMolecule; diff --git a/Sources/Common/DataModel/PiecewiseFunction/index.d.ts b/Sources/Common/DataModel/PiecewiseFunction/index.d.ts index f6e6d3615fb..92f33f10c91 100644 --- a/Sources/Common/DataModel/PiecewiseFunction/index.d.ts +++ b/Sources/Common/DataModel/PiecewiseFunction/index.d.ts @@ -1,5 +1,5 @@ import { vtkObject } from '../../../interfaces'; -import { Range } from '../../../types'; +import { Nullable, Range } from '../../../types'; export interface IPiecewiseFunctionInitialValues { range?: Range; @@ -13,7 +13,7 @@ export interface vtkPiecewiseFunction extends vtkObject { * @param {Number} x The x coordinate. * @param {Number} y The y coordinate. */ - addPoint(x: number, y: number): void; + addPoint(x: number, y: number): number; /** * Add points to the function. @@ -49,7 +49,7 @@ export interface vtkPiecewiseFunction extends vtkObject { * Estimates the minimum size of a table such that it would correctly sample * this function. */ - estimateMinNumberOfSamples(): number; + estimateMinNumberOfSamples(x1: number, x2: number): number; /** * Traverses the nodes to find the minimum distance. @@ -76,7 +76,7 @@ export interface vtkPiecewiseFunction extends vtkObject { /** * Returns a pointer to the data stored in the table. */ - getDataPointer(): any[]; + getDataPointer(): Nullable; /** * Returns the first point location which precedes a non-zero segment of the @@ -151,8 +151,9 @@ export interface vtkPiecewiseFunction extends vtkObject { /** * Returns the value of the function at the specified location using the * specified interpolation. + * @param x The position to evaluate. */ - getValue(): any; + getValue(x: number): number; /** * Removes all points from the function. @@ -216,7 +217,7 @@ export interface vtkPiecewiseFunction extends vtkObject { * * @param {Range} range */ - setRangeFrom(range: Range): boolean; + setRangeFrom(range: Range): void; /** * Internal method to sort the vector and update the Range whenever a node diff --git a/Sources/Common/DataModel/Plane/index.d.ts b/Sources/Common/DataModel/Plane/index.d.ts index bfc76c7fa01..524ce1695d1 100755 --- a/Sources/Common/DataModel/Plane/index.d.ts +++ b/Sources/Common/DataModel/Plane/index.d.ts @@ -1,5 +1,5 @@ import { vtkObject } from '../../../interfaces'; -import { Vector3 } from '../../../types'; +import { Nullable, Vector3 } from '../../../types'; import vtkImplicitFunction from '../ImplicitFunction'; /** @@ -14,7 +14,18 @@ interface IIntersectWithLine { intersection: boolean; betweenPoints: boolean; t: number; - x: Vector3; + /** + * The intersection point, or an empty array when the line is parallel to the + * plane and no intersection was computed. + */ + x: Vector3 | []; +} + +interface IIntersectWithPlane { + intersection: boolean; + l0: Vector3; + l1: Vector3; + error: Nullable; } export interface vtkPlane extends vtkImplicitFunction { @@ -156,7 +167,7 @@ export interface vtkPlane extends vtkImplicitFunction { intersectWithPlane( planeOrigin: Vector3, planeNormal: Vector3 - ): IIntersectWithLine; + ): IIntersectWithPlane; /** * Set the normal of the plane. @@ -176,7 +187,7 @@ export interface vtkPlane extends vtkImplicitFunction { * Set the normal object. * @param {Vector3} normal The normal coordinate. */ - setNormalFrom(normal: Vector3): boolean; + setNormalFrom(normal: Vector3): void; /** * Set the origin of the plane. @@ -196,7 +207,7 @@ export interface vtkPlane extends vtkImplicitFunction { * Set the origin of the plane. * @param {Vector3} origin The coordinate of the origin point. */ - setOriginFrom(origin: Vector3): boolean; + setOriginFrom(origin: Vector3): void; } /** @@ -225,7 +236,7 @@ export function newInstance(initialValues?: IPlaneInitialValues): vtkPlane; * @param {Vector3} origin The coordinate of the origin point. * @param {Vector3} x */ -export function evaluate(normal: Vector3, origin: Vector3, x: Vector3): number; +declare function evaluate(normal: Vector3, origin: Vector3, x: Vector3): number; /** * Return the distance of a point x to a plane defined by n (x-p0) = 0. @@ -235,7 +246,7 @@ export function evaluate(normal: Vector3, origin: Vector3, x: Vector3): number; * @param {Vector3} origin The coordinate of the origin point. * @param {Vector3} normal */ -export function distanceToPlane( +declare function distanceToPlane( x: Vector3, origin: Vector3, normal: Vector3 @@ -252,7 +263,7 @@ export function distanceToPlane( * @param {Vector3} normal * @param {Vector3} xproj */ -export function projectPoint( +declare function projectPoint( x: any, origin: Vector3, normal: Vector3, @@ -267,7 +278,7 @@ export function projectPoint( * @param {Vector3} normal * @param {Vector3} vproj The projection vector's coordinate.. */ -export function projectVector( +declare function projectVector( v: Vector3, normal: Vector3, vproj: Vector3 @@ -285,7 +296,7 @@ export function projectVector( * @param {Vector3} normal * @param {Vector3} xproj */ -export function generalizedProjectPoint( +declare function generalizedProjectPoint( x: any, origin: Vector3, normal: Vector3, @@ -314,7 +325,7 @@ export function generalizedProjectPoint( * @param {Vector3} origin The coordinate of the origin point. * @param {Vector3} normal */ -export function intersectWithLine( +declare function intersectWithLine( p1: Vector3, p2: Vector3, origin: Vector3, @@ -343,22 +354,22 @@ export function intersectWithLine( * @param {Vector3} plane2Origin * @param {Vector3} plane2Normal */ -export function intersectWithPlane( +declare function intersectWithPlane( plane1Origin: Vector3, plane1Normal: Vector3, plane2Origin: Vector3, plane2Normal: Vector3 -): IIntersectWithLine; +): IIntersectWithPlane; /** * Constants for the `intersectWithPlane` function. */ -export declare const COINCIDE: string; +declare const COINCIDE: string; /** * Constants for the `intersectWithPlane` function. */ -export declare const DISJOINT: string; +declare const DISJOINT: string; /** * vtkPlane provides methods for various plane computations. These include @@ -375,5 +386,19 @@ export declare const vtkPlane: { generalizedProjectPoint: typeof generalizedProjectPoint; intersectWithLine: typeof intersectWithLine; intersectWithPlane: typeof intersectWithPlane; + // constants + COINCIDE: typeof COINCIDE; + DISJOINT: typeof DISJOINT; }; +export declare const STATIC: Readonly<{ + evaluate: typeof evaluate; + distanceToPlane: typeof distanceToPlane; + projectPoint: typeof projectPoint; + projectVector: typeof projectVector; + generalizedProjectPoint: typeof generalizedProjectPoint; + intersectWithLine: typeof intersectWithLine; + intersectWithPlane: typeof intersectWithPlane; + DISJOINT: typeof DISJOINT; + COINCIDE: typeof COINCIDE; +}>; export default vtkPlane; diff --git a/Sources/Common/DataModel/Planes/index.d.ts b/Sources/Common/DataModel/Planes/index.d.ts index 550947da918..cc5b62cb599 100644 --- a/Sources/Common/DataModel/Planes/index.d.ts +++ b/Sources/Common/DataModel/Planes/index.d.ts @@ -1,4 +1,4 @@ -import { Bounds, Vector3 } from '../../../types'; +import { Bounds, Nullable, Vector3 } from '../../../types'; import vtkDataArray from '../../Core/DataArray'; import vtkImplicitFunction, { IImplicitFunctionInitialValues, @@ -46,13 +46,13 @@ export interface vtkPlanes extends vtkImplicitFunction { * Get the normals of the plane. * @returns {vtkDataArray} The normals of the plane. */ - getNormals(): vtkDataArray; + getNormals(): Nullable; /** * Get the points of the plane. * @returns {vtkPoints} The points of the plane. */ - getPoints(): vtkPoints; + getPoints(): Nullable; /** * Get the i-th plane @@ -63,6 +63,15 @@ export interface vtkPlanes extends vtkImplicitFunction { */ getPlane(i: number, plane?: vtkPlane): vtkPlane; + /** + * Get the raw frustum plane coefficients (4 per plane). + * + * Defaults to a 24 element Float64Array, but becomes a plain array once + * setFrustumPlanes() has been called. + * @see setFrustumPlanes + */ + getPlanes(): Float64Array | number[]; + /** * Set the bounds of the planes. * @param {Bounds} bounds The bounds to set. diff --git a/Sources/Common/DataModel/PointLocator/index.d.ts b/Sources/Common/DataModel/PointLocator/index.d.ts index 6a0f224e19c..49a85f463cf 100644 --- a/Sources/Common/DataModel/PointLocator/index.d.ts +++ b/Sources/Common/DataModel/PointLocator/index.d.ts @@ -24,6 +24,17 @@ interface IFindClosestPointResult { } export interface vtkPointLocator extends vtkIncrementalPointLocator { + /** + * Build the locator from the input dataset. + */ + buildLocator(): void; + + /** + * Compute the performance factors (bucket widths, offsets and divisions) + * derived from the current bounds and divisions. + */ + computePerformanceFactors(): void; + /** * Find the closest inserted point to the given coordinates. * @@ -65,7 +76,23 @@ export interface vtkPointLocator extends vtkIncrementalPointLocator { * @param {vtkPolyData} polydata The polydata to generate representation for * @returns */ - generateRepresentation(polydata: vtkPolyData): boolean; + generateRepresentation(polydata: vtkPolyData): void; + + /** + * Get the flat bucket index for a given point. + * + * @param {Vector3} point The point coordinates + * @returns {Number} The bucket index + */ + getBucketIndex(point: Vector3): number; + + /** + * Get the (i, j, k) bucket indices for a given point. + * + * @param {Vector3} point The point coordinates + * @returns {Vector3} The bucket indices, clamped to the locator divisions + */ + getBucketIndices(point: Vector3): Vector3; /** * Get the number of points per bucket. @@ -88,6 +115,11 @@ export interface vtkPointLocator extends vtkIncrementalPointLocator { */ getPoints(): Nullable; + /** + * Release the points and free the search structure. + */ + initialize(): void; + /** * Initialize point insertion. * @@ -140,6 +172,18 @@ export interface vtkPointLocator extends vtkIncrementalPointLocator { */ isInsertedPoint(x: Vector3): number; + /** + * Get the divisions of the point locator. + * @default [50, 50, 50] + */ + getDivisions(): Vector3; + + /** + * Get the divisions of the point locator. + * @default [50, 50, 50] + */ + getDivisionsByReference(): Vector3; + /** * Set the divisions of the point locator. * @param {Vector3} divisions The number of divisions in each dimension. @@ -156,6 +200,12 @@ export interface vtkPointLocator extends vtkIncrementalPointLocator { */ setDivisions(x: number, y: number, z: number): boolean; + /** + * Set the divisions of the point locator. + * @param {Vector3} divisions The number of divisions in each dimension. + */ + setDivisionsFrom(divisions: Vector3): void; + /** * Set the number of points per bucket. * diff --git a/Sources/Common/DataModel/PointSet/index.d.ts b/Sources/Common/DataModel/PointSet/index.d.ts index ea61eb5e399..05d7b2a8b26 100755 --- a/Sources/Common/DataModel/PointSet/index.d.ts +++ b/Sources/Common/DataModel/PointSet/index.d.ts @@ -12,7 +12,7 @@ export interface vtkPointSet extends vtkDataSet { * Empty the points and initialize the data set and . * @see vtkDataSet::initialize() */ - initialize(): void; + initialize(): vtkPointSet; /** * Compute the (X, Y, Z) bounds of the data. diff --git a/Sources/Common/DataModel/PolyData/index.d.ts b/Sources/Common/DataModel/PolyData/index.d.ts index 23c80b66e7e..ece58a7bf56 100755 --- a/Sources/Common/DataModel/PolyData/index.d.ts +++ b/Sources/Common/DataModel/PolyData/index.d.ts @@ -1,5 +1,8 @@ -import { CellType } from '../../../types'; +import { CellType, Nullable } from '../../../types'; import vtkCellArray from '../../Core/CellArray'; +import vtkCell from '../Cell'; +import vtkCellLinks from '../CellLinks'; +import vtkCellTypes from '../CellTypes'; import vtkPointSet, { IPointSetInitialValues } from '../PointSet'; /** @@ -12,7 +15,7 @@ export interface vtkPolyData extends vtkPointSet { * Empty the cells and initialize the point set. * @see vtkPointSet::initialize() */ - initialize(): void; + initialize(): vtkPolyData; /** * Create data structure that allows random access of cells. @@ -31,7 +34,7 @@ export interface vtkPolyData extends vtkPointSet { * @param {Number} cellId * @param cellHint */ - getCell(cellId: number, cellHint: any): void; + getCell(cellId: number, cellHint?: any): vtkCell; /** * Get the neighbors at an edge. @@ -63,7 +66,7 @@ export interface vtkPolyData extends vtkPointSet { /** * Get the cell array defining cells. */ - getCells(): vtkCellArray; + getCells(): Nullable; /** * Get the cell array defining lines. @@ -73,7 +76,7 @@ export interface vtkPolyData extends vtkPointSet { /** * Get the links between points and cells. */ - getLinks(): any; // vtkCellLinks + getLinks(): Nullable; /** * Get the maximum cell size. @@ -115,7 +118,7 @@ export interface vtkPolyData extends vtkPointSet { * Topological inquiry to get cells using point. * @param ptId */ - getPointCells(ptId: number): void; + getPointCells(ptId: number): number[]; /** * Get the cell array defining polys. @@ -159,6 +162,11 @@ export interface vtkPolyData extends vtkPointSet { setVerts(verts: vtkCellArray): boolean; } +/** + * Maps CellType enum values to the vtkCell subclass used to represent that cell type. + */ +export const CELL_FACTORY: Record; + /** * Method used to decorate a given object (publicAPI+model) with vtkPolyData characteristics. * diff --git a/Sources/Common/DataModel/PolyLine/index.d.ts b/Sources/Common/DataModel/PolyLine/index.d.ts index e1d5b08d6bc..b7e71fcc8ce 100644 --- a/Sources/Common/DataModel/PolyLine/index.d.ts +++ b/Sources/Common/DataModel/PolyLine/index.d.ts @@ -3,7 +3,10 @@ import { Nullable, Vector2, Vector3 } from '../../../types'; import vtkCell, { ICellInitialValues } from '../Cell'; import { IIntersectWithLine } from '../Line'; -export interface IPolyLineInitialValues extends ICellInitialValues {} +export interface IPolyLineInitialValues extends ICellInitialValues { + orientations?: quat[]; + distanceFunction?: (a: vec3, b: vec3) => number; +} export interface vtkPolyLine extends vtkCell { /** diff --git a/Sources/Common/DataModel/Polygon/Constants.d.ts b/Sources/Common/DataModel/Polygon/Constants.d.ts new file mode 100644 index 00000000000..7155f5f7e04 --- /dev/null +++ b/Sources/Common/DataModel/Polygon/Constants.d.ts @@ -0,0 +1,17 @@ +export declare const EPSILON: number; +export declare const FLOAT_EPSILON: number; +export declare const TOLERANCE: number; + +/** + * Different states which pointInPolygon could return. + */ +export declare const PolygonWithPointIntersectionState: { + readonly FAILURE: -1; + readonly OUTSIDE: 0; + readonly INSIDE: 1; + readonly INTERSECTION: 2; + readonly ON_LINE: 3; +}; + +export type PolygonWithPointIntersectionState = + (typeof PolygonWithPointIntersectionState)[keyof typeof PolygonWithPointIntersectionState]; diff --git a/Sources/Common/DataModel/Polygon/index.d.ts b/Sources/Common/DataModel/Polygon/index.d.ts index 9cc230eb419..3549980798f 100644 --- a/Sources/Common/DataModel/Polygon/index.d.ts +++ b/Sources/Common/DataModel/Polygon/index.d.ts @@ -1,5 +1,7 @@ import { vtkObject } from '../../../interfaces'; import { Bounds, TypedArray, Vector3 } from '../../../types'; +import vtkPoints from '../../Core/Points'; +import { PolygonWithPointIntersectionState } from './Constants'; export interface IPolygonInitialValues { firstPoint?: Vector3; @@ -9,14 +11,11 @@ export interface IPolygonInitialValues { /** * Different states which pointInPolygon could return. + * + * @deprecated Use {@link PolygonWithPointIntersectionState}, the name the + * constant actually has at runtime. */ -export enum PolygonIntersectionState { - FAILURE, - OUTSIDE, - INSIDE, - INTERSECTION, - ON_LINE, -} +export type PolygonIntersectionState = PolygonWithPointIntersectionState; export interface vtkPolygon extends vtkObject { /** @@ -36,7 +35,7 @@ export interface vtkPolygon extends vtkObject { * The output data contains points by group of three: each three-group * defines one triangle. */ - triangulate(): void; + triangulate(): boolean | null; } /** @@ -53,13 +52,42 @@ export interface vtkPolygon extends vtkObject { * @param {Vector3} normal Normal vector of the polygon * @returns {PolygonIntersectionState} Integer indicating the type of intersection */ -export function pointInPolygon( +declare function pointInPolygon( point: Vector3, vertices: Array | TypedArray, bounds: Bounds, normal: Vector3 ): PolygonIntersectionState; +/** + * Simple utility method for computing polygon bounds. + * Requires a poly with at least one point. + * + * @param {Array|TypedArray} poly Array of point indices for the polygon + * @param {vtkPoints} points vtkPoints instance + * @param {Bounds} bounds Output bounds, filled in place + * @returns {Number} The sum of the squares of the bounding box dimensions + */ +export function getBounds( + poly: Array | TypedArray, + points: vtkPoints, + bounds: Bounds +): number; + +/** + * Compute the normal of a polygon and return its norm. + * + * @param {Array|TypedArray} poly Array of point indices for the polygon + * @param {vtkPoints} points vtkPoints instance + * @param {Vector3} normal Output normal, filled in place + * @returns {Number} The norm of the computed normal + */ +export function getNormal( + poly: Array | TypedArray, + points: vtkPoints, + normal: Vector3 +): number; + /** * Compute the centroid of a polygon. * @param {Array} poly - Array of point indices for the polygon @@ -69,7 +97,7 @@ export function pointInPolygon( */ export function computeCentroid( poly: Array, - points: TypedArray, + points: vtkPoints, centroid?: Vector3 ): Vector3; @@ -103,5 +131,11 @@ export declare const vtkPolygon: { newInstance: typeof newInstance; extend: typeof extend; // static + pointInPolygon: typeof pointInPolygon; + getBounds: typeof getBounds; + getNormal: typeof getNormal; + computeCentroid: typeof computeCentroid; + // constants + PolygonWithPointIntersectionState: typeof PolygonWithPointIntersectionState; }; export default vtkPolygon; diff --git a/Sources/Common/DataModel/Quad/Constants.d.ts b/Sources/Common/DataModel/Quad/Constants.d.ts new file mode 100644 index 00000000000..86c5c2a0baf --- /dev/null +++ b/Sources/Common/DataModel/Quad/Constants.d.ts @@ -0,0 +1,12 @@ +export declare const QuadWithLineIntersectionState: { + readonly NO_INTERSECTION: 0; + readonly YES_INTERSECTION: 1; +}; + +export type QuadWithLineIntersectionState = + (typeof QuadWithLineIntersectionState)[keyof typeof QuadWithLineIntersectionState]; + +declare const _default: { + QuadWithLineIntersectionState: typeof QuadWithLineIntersectionState; +}; +export default _default; diff --git a/Sources/Common/DataModel/Quad/index.d.ts b/Sources/Common/DataModel/Quad/index.d.ts index da989009b88..5d3e79a3725 100644 --- a/Sources/Common/DataModel/Quad/index.d.ts +++ b/Sources/Common/DataModel/Quad/index.d.ts @@ -56,7 +56,7 @@ export interface vtkQuad extends vtkCell { * @param {Vector3} pcoords The parametric coordinates. * @param {Vector4} sf out weights. */ - interpolationFunctions(pcoords: Vector3, sf: Vector4); + interpolationFunctions(pcoords: Vector3, sf: Vector4): void; } /** diff --git a/Sources/Common/DataModel/SelectionNode/Constants.d.ts b/Sources/Common/DataModel/SelectionNode/Constants.d.ts index e00a8db2c6c..eb86338d951 100644 --- a/Sources/Common/DataModel/SelectionNode/Constants.d.ts +++ b/Sources/Common/DataModel/SelectionNode/Constants.d.ts @@ -1,23 +1,29 @@ -export declare enum SelectionContent { - GLOBALIDS = 0, - PEDIGREEIDS = 1, - VALUES = 2, - INDICES = 3, - FRUSTUM = 4, - LOCATIONS = 5, - THRESHOLDS = 6, - BLOCKS = 7, - QUERY = 8, -} +export declare const SelectionContent: { + readonly GLOBALIDS: 0; + readonly PEDIGREEIDS: 1; + readonly VALUES: 2; + readonly INDICES: 3; + readonly FRUSTUM: 4; + readonly LOCATIONS: 5; + readonly THRESHOLDS: 6; + readonly BLOCKS: 7; + readonly QUERY: 8; +}; + +export type SelectionContent = + (typeof SelectionContent)[keyof typeof SelectionContent]; + +export declare const SelectionField: { + readonly CELL: 0; + readonly POINT: 1; + readonly FIELD: 2; + readonly VERTEX: 3; + readonly EDGE: 4; + readonly ROW: 5; +}; -export declare enum SelectionField { - CELL = 0, - POINT = 1, - FIELD = 2, - VERTEX = 3, - EDGE = 4, - ROW = 5, -} +export type SelectionField = + (typeof SelectionField)[keyof typeof SelectionField]; declare const _default: { SelectionContent: typeof SelectionContent; diff --git a/Sources/Common/DataModel/SelectionNode/index.d.ts b/Sources/Common/DataModel/SelectionNode/index.d.ts index fa006c85331..e9ce97007d5 100644 --- a/Sources/Common/DataModel/SelectionNode/index.d.ts +++ b/Sources/Common/DataModel/SelectionNode/index.d.ts @@ -34,7 +34,7 @@ export interface vtkSelectionNode extends vtkObject { /** * This functions is called internally by VTK.js and is not intended for public use. */ - setContentType(contentType: SelectionContent): void; + setContentType(contentType: SelectionContent): boolean; /** * Returns -1 if not initialized. @@ -44,7 +44,7 @@ export interface vtkSelectionNode extends vtkObject { /** * This functions is called internally by VTK.js and is not intended for public use. */ - setFieldType(fieldType: SelectionField): void; + setFieldType(fieldType: SelectionField): boolean; /** * Get the selection properties. @@ -64,7 +64,7 @@ export interface vtkSelectionNode extends vtkObject { /** * This functions is called internally by VTK.js and is not intended for public use. */ - setSelectionList(selectionAttributeIDs: ISelectionNodeProperties): boolean; + setSelectionList(selectionAttributeIDs: number[]): boolean; } /** diff --git a/Sources/Common/DataModel/Sphere/index.d.ts b/Sources/Common/DataModel/Sphere/index.d.ts index 6c62c40ac09..4ec17bd2154 100755 --- a/Sources/Common/DataModel/Sphere/index.d.ts +++ b/Sources/Common/DataModel/Sphere/index.d.ts @@ -54,7 +54,7 @@ export interface vtkSphere extends vtkImplicitFunction { * Set the center of the sphere. * @param {Vector3} center The center coordinate. */ - setCenterFrom(center: Vector3): boolean; + setCenterFrom(center: Vector3): void; /** * Set the radius of the sphere. Radius must be > 0. @@ -84,11 +84,15 @@ export function extend( export function newInstance(initialValues?: ISphereInitialValues): vtkSphere; /** - * @param {Number} radius + * @param {Number|Vector3} radius * @param {Vector3} center * @param {Vector3} x */ -declare function evaluate(radius: number, center: Vector3, x: Vector3): number; +declare function evaluate( + radius: number | Vector3, + center: Vector3, + x: Vector3 +): number; /** * Approximate bounding sphere for a point set represented as a flat xyz array. @@ -130,4 +134,9 @@ export declare const vtkSphere: { computeBoundingSphere: typeof computeBoundingSphere; computeBoundingSphereFromSpheres: typeof computeBoundingSphereFromSpheres; }; +export declare const STATIC: Readonly<{ + evaluate: typeof evaluate; + computeBoundingSphere: typeof computeBoundingSphere; + computeBoundingSphereFromSpheres: typeof computeBoundingSphereFromSpheres; +}>; export default vtkSphere; diff --git a/Sources/Common/DataModel/Spline1D/Constants.d.ts b/Sources/Common/DataModel/Spline1D/Constants.d.ts new file mode 100644 index 00000000000..ea6e5274d55 --- /dev/null +++ b/Sources/Common/DataModel/Spline1D/Constants.d.ts @@ -0,0 +1,31 @@ +/** + * Boundary conditions available to compute open splines. + */ +export declare const BoundaryCondition: { + /** + * Desired slope at boundary point is derivative from two points (boundary and + * second interior) + */ + readonly DEFAULT: 0; + /** + * Desired slope at boundary point is the boundary value given + */ + readonly DERIVATIVE: 1; + /** + * Second derivative at boundary point is the boundary value given + */ + readonly SECOND_DERIVATIVE: 2; + /** + * Desired second derivative at boundary point is the boundary value given + * times second derivative at first interior point + */ + readonly SECOND_DERIVATIVE_INTERIOR_POINT: 3; +}; + +export type BoundaryCondition = + (typeof BoundaryCondition)[keyof typeof BoundaryCondition]; + +declare const _default: { + BoundaryCondition: typeof BoundaryCondition; +}; +export default _default; diff --git a/Sources/Common/DataModel/Spline1D/index.d.ts b/Sources/Common/DataModel/Spline1D/index.d.ts index 197514b2cd0..b9f067c9df7 100755 --- a/Sources/Common/DataModel/Spline1D/index.d.ts +++ b/Sources/Common/DataModel/Spline1D/index.d.ts @@ -1,20 +1,8 @@ import { vtkObject } from '../../../interfaces'; +import { BoundaryCondition } from './Constants'; export interface ISpline1DInitialValues {} -// Boundary conditions available to compute open splines -// DEFAULT : desired slope at boundary point is derivative from two points (boundary and second interior) -// DERIVATIVE : desired slope at boundary point is the boundary value given. -// SECOND_DERIVATIVE : second derivative at boundary point is the boundary value given. -// SECOND_DERIVATIVE_INTERIOR_POINT : desired second derivative at boundary point is the boundary value given times second derivative -// at first interior point. -export enum BoundaryCondition { - DEFAULT, - DERIVATIVE, - SECOND_DERIVATIVE, - SECOND_DERIVATIVE_INTERIOR_POINT, -} - export interface vtkSpline1D extends vtkObject { /** * @@ -47,7 +35,7 @@ export interface vtkSpline1D extends vtkObject { work: Float32Array, x: number[], y: number[], - options: { + options?: { leftConstraint: BoundaryCondition; leftValue: number; rightConstraint: BoundaryCondition; diff --git a/Sources/Common/DataModel/Spline3D/Constants.d.ts b/Sources/Common/DataModel/Spline3D/Constants.d.ts index d4f23cd3b18..21e34d59f35 100644 --- a/Sources/Common/DataModel/Spline3D/Constants.d.ts +++ b/Sources/Common/DataModel/Spline3D/Constants.d.ts @@ -1,7 +1,9 @@ -export declare enum splineKind { - CARDINAL_SPLINE = 'CARDINAL_SPLINE', - KOCHANEK_SPLINE = 'KOCHANEK_SPLINE', -} +export declare const splineKind: { + readonly CARDINAL_SPLINE: 'CARDINAL_SPLINE'; + readonly KOCHANEK_SPLINE: 'KOCHANEK_SPLINE'; +}; + +export type splineKind = (typeof splineKind)[keyof typeof splineKind]; declare const _default: { splineKind: typeof splineKind; diff --git a/Sources/Common/DataModel/Spline3D/index.d.ts b/Sources/Common/DataModel/Spline3D/index.d.ts index 4ac3babcb22..3c0bd224c1e 100755 --- a/Sources/Common/DataModel/Spline3D/index.d.ts +++ b/Sources/Common/DataModel/Spline3D/index.d.ts @@ -17,12 +17,38 @@ export interface vtkSpline3D extends vtkObject { */ computeCoefficients(points: number[]): void; + /** + * Get whether the spline is closed (the last point is joined to the first). + * @default false + */ + getClose(): boolean; + + /** + * Get the parametric values delimiting each spline interval. When empty, the + * intervals default to the point indices. + * @default [] + */ + getIntervals(): number[] | Float32Array; + /** * * @param {Number} intervalIndex * @param {Number} t */ getPoint(intervalIndex: number, t: number): number[]; + + /** + * Set whether the spline is closed (the last point is joined to the first). + * @param {Boolean} close + */ + setClose(close: boolean): boolean; + + /** + * Set the parametric values delimiting each spline interval. Pass an empty + * array to fall back to the point indices. + * @param {Number[]} intervals + */ + setIntervals(intervals: number[] | Float32Array): boolean; } /** diff --git a/Sources/Common/DataModel/StructuredData/Constants.d.ts b/Sources/Common/DataModel/StructuredData/Constants.d.ts new file mode 100644 index 00000000000..8a3cab28f0c --- /dev/null +++ b/Sources/Common/DataModel/StructuredData/Constants.d.ts @@ -0,0 +1,20 @@ +export declare const StructuredType: { + readonly UNCHANGED: 0; + readonly SINGLE_POINT: 1; + readonly X_LINE: 2; + readonly Y_LINE: 3; + readonly Z_LINE: 4; + readonly XY_PLANE: 5; + readonly YZ_PLANE: 6; + readonly XZ_PLANE: 7; + readonly XYZ_GRID: 8; + readonly EMPTY: 9; +}; + +export type StructuredType = + (typeof StructuredType)[keyof typeof StructuredType]; + +declare const _default: { + StructuredType: typeof StructuredType; +}; +export default _default; diff --git a/Sources/Common/DataModel/StructuredData/index.d.ts b/Sources/Common/DataModel/StructuredData/index.d.ts new file mode 100644 index 00000000000..bfa914eef07 --- /dev/null +++ b/Sources/Common/DataModel/StructuredData/index.d.ts @@ -0,0 +1,20 @@ +import { Extent } from '../../../types'; +import { StructuredType } from './Constants'; + +/** + * Return the data description (see StructuredType) of the given extent, i.e. + * whether it describes an empty dataset, a single point, a line, a plane or a + * volume. + * @param {Extent} inExt + */ +export function getDataDescriptionFromExtent(inExt: Extent): StructuredType; + +/** + * vtkStructuredData provides helpers to describe structured datasets from + * their extent. + */ +declare const vtkStructuredData: { + getDataDescriptionFromExtent: typeof getDataDescriptionFromExtent; + StructuredType: typeof StructuredType; +}; +export default vtkStructuredData; diff --git a/Sources/Common/DataModel/Triangle/index.d.ts b/Sources/Common/DataModel/Triangle/index.d.ts index bcadaf6ef15..bab3f3c91ca 100755 --- a/Sources/Common/DataModel/Triangle/index.d.ts +++ b/Sources/Common/DataModel/Triangle/index.d.ts @@ -1,5 +1,9 @@ import { Vector2, Vector3 } from '../../../types'; +import vtkCellArray from '../../Core/CellArray'; +import vtkDataArray from '../../Core/DataArray'; import vtkCell, { ICellInitialValues } from '../Cell'; +import vtkDataSetAttributes from '../DataSetAttributes'; +import vtkPointLocator from '../PointLocator'; export interface ITriangleInitialValues extends ICellInitialValues {} @@ -16,10 +20,44 @@ export interface IIntersectWithTriangle { coplanar: boolean; pt1: Vector3; pt2: Vector3; - surfaceId: number; + surfaceId: number[]; +} + +export interface IEvaluatePositionResult { + subId: number; + dist2: number; + evaluation: number; } export interface vtkTriangle extends vtkCell { + /** + * Clip the triangle against the given scalar value, appending the resulting + * triangles to tris and their interpolated attributes to outPd/outCd. + * + * @param {Number} value The clipping value + * @param {vtkDataArray} cellScalars The scalar value at each triangle corner + * @param {vtkPointLocator} locator Merges the generated points + * @param {vtkCellArray} tris Receives the generated triangles + * @param {vtkDataSetAttributes} inPd Input point data + * @param {vtkDataSetAttributes} outPd Output point data + * @param {vtkDataSetAttributes} inCd Input cell data + * @param {Number} cellId The id of this cell in the input + * @param {vtkDataSetAttributes} outCd Output cell data + * @param {Boolean} insideOut Keep the region below the value instead of above + */ + clip( + value: number, + cellScalars: vtkDataArray, + locator: vtkPointLocator, + tris: vtkCellArray, + inPd: vtkDataSetAttributes, + outPd: vtkDataSetAttributes, + inCd: vtkDataSetAttributes, + cellId: number, + outCd: vtkDataSetAttributes, + insideOut: boolean + ): void; + /** * Get the topological dimensional of the cell (0, 1, 2 or 3). */ @@ -97,7 +135,7 @@ export interface vtkTriangle extends vtkCell { closestPoint: Vector3, pcoords: Vector3, weights: number[] - ): IIntersectWithLine; + ): IEvaluatePositionResult; /** * Determine global coordinates (x) from the given subId and parametric @@ -144,7 +182,7 @@ export function newInstance( * @param {Vector3} v3 The third point coordinate. * @param {Vector3} n The normal coordinate. */ -export function computeNormalDirection( +declare function computeNormalDirection( v1: Vector3, v2: Vector3, v3: Vector3, @@ -159,7 +197,7 @@ export function computeNormalDirection( * @param {Vector3} v3 The third point coordinate. * @param {Vector3} n The normal coordinate. */ -export function computeNormal( +declare function computeNormal( v1: Vector3, v2: Vector3, v3: Vector3, @@ -170,7 +208,7 @@ export function computeNormal( * Compute the interpolation functions/derivatives * @param {Number[]} derivs - The derivatives. */ -export function interpolationDerivs(derivs: number[]): void; +declare function interpolationDerivs(derivs: number[]): void; /** * Compute the intersection between two triangles. @@ -181,7 +219,7 @@ export function interpolationDerivs(derivs: number[]): void; * @param {Vector3} q2 The second point coordinate of the second triangle. * @param {Vector3} r2 The third point coordinate of the second triangle. */ -export function intersectWithTriangle( +declare function intersectWithTriangle( p1: Vector3, q1: Vector3, r1: Vector3, @@ -205,4 +243,10 @@ export declare const vtkTriangle: { interpolationDerivs: typeof interpolationDerivs; intersectWithTriangle: typeof intersectWithTriangle; }; +export declare const STATIC: Readonly<{ + computeNormalDirection: typeof computeNormalDirection; + computeNormal: typeof computeNormal; + interpolationDerivs: typeof interpolationDerivs; + intersectWithTriangle: typeof intersectWithTriangle; +}>; export default vtkTriangle; diff --git a/Sources/Common/DataModel/TriangleStrip/index.d.ts b/Sources/Common/DataModel/TriangleStrip/index.d.ts index f31dc71d8a8..8ae38a0bbdb 100644 --- a/Sources/Common/DataModel/TriangleStrip/index.d.ts +++ b/Sources/Common/DataModel/TriangleStrip/index.d.ts @@ -1,7 +1,10 @@ import { CellType, Vector3 } from '../../../types'; import vtkCellArray from '../../Core/CellArray'; +import vtkDataArray from '../../Core/DataArray'; import vtkPoints from '../../Core/Points'; import vtkCell, { ICellInitialValues } from '../Cell'; +import vtkDataSetAttributes from '../DataSetAttributes'; +import vtkPointLocator from '../PointLocator'; import vtkLine from '../Line'; import vtkTriangle from '../Triangle'; @@ -19,6 +22,51 @@ export interface vtkTriangleStrip extends vtkCell { */ cellBoundary(subId: number, pcoords: Vector3, pts: Vector3[]): boolean; + /** + * Clip the strip against the given scalar value by clipping each of its + * triangles in turn, appending the results to tris. + * + * @param {Number} value The clipping value + * @param {vtkDataArray} cellScalars The scalar value at each strip point + * @param {vtkPointLocator} locator Merges the generated points + * @param {vtkCellArray} tris Receives the generated triangles + * @param {vtkDataSetAttributes} inPd Input point data + * @param {vtkDataSetAttributes} outPd Output point data + * @param {vtkDataSetAttributes} inCd Input cell data + * @param {Number} cellId The id of this cell in the input + * @param {vtkDataSetAttributes} outCd Output cell data + * @param {Boolean} insideOut Keep the region below the value instead of above + */ + clip( + value: number, + cellScalars: vtkDataArray, + locator: vtkPointLocator, + tris: vtkCellArray, + inPd: vtkDataSetAttributes, + outPd: vtkDataSetAttributes, + inCd: vtkDataSetAttributes, + cellId: number, + outCd: vtkDataSetAttributes, + insideOut: boolean + ): void; + + /** + * Not implemented: always throws. + */ + contour( + value: number, + cellScalars: vtkDataArray, + locator: vtkPointLocator, + verts: vtkCellArray, + lines: vtkCellArray, + polys: vtkCellArray, + inPd: vtkDataSetAttributes, + outPd: vtkDataSetAttributes, + inCd: vtkDataSetAttributes, + cellId: number, + outCd: vtkDataSetAttributes + ): void; + /** * Derivatives of the triangle strip. * @param {Number} subId - The sub-id of the triangle. @@ -37,15 +85,17 @@ export interface vtkTriangleStrip extends vtkCell { /** * Evaluate the location of a point in the triangle strip. + * @param {Number} subId The triangle within the strip to evaluate against. * @param {Vector3} pcoords The parametric coordinates of the point. - * @param {Vector3} closestPoint The closest point on the triangle strip. - * @param {Number[]} weights The interpolation weights. + * @param {Vector3} x The interpolated position, written in place. + * @param {Number[]} weights The interpolation weights, written in place. */ evaluateLocation( + subId: number, pcoords: Vector3, - closestPoint: Vector3, + x: Vector3, weights: number[] - ): number; + ): void; /** * Evaluate the position of a point in the triangle strip. @@ -160,7 +210,7 @@ export function newInstance( * @param {vtkPoints} pts Points of the triangle strip * @param {vtkCellArray} polys Cell array to store the resulting triangles */ -export function decomposeStrip(pts: vtkPoints, polys: vtkCellArray): void; +declare function decomposeStrip(pts: vtkPoints, polys: vtkCellArray): void; /** * vtkTriangleStrip is a concrete implementation of vtkCell to represent a 2D @@ -177,4 +227,7 @@ export declare const vtkTriangleStrip: { extend: typeof extend; decomposeStrip: typeof decomposeStrip; }; +export declare const STATIC: Readonly<{ + decomposeStrip: typeof decomposeStrip; +}>; export default vtkTriangleStrip; diff --git a/Sources/Common/Transform/LandmarkTransform/Constants.d.ts b/Sources/Common/Transform/LandmarkTransform/Constants.d.ts new file mode 100644 index 00000000000..e72320a3fc6 --- /dev/null +++ b/Sources/Common/Transform/LandmarkTransform/Constants.d.ts @@ -0,0 +1,12 @@ +export declare const Mode: { + readonly RIGID_BODY: 0; + readonly SIMILARITY: 1; + readonly AFFINE: 2; +}; + +export type Mode = (typeof Mode)[keyof typeof Mode]; + +declare const _default: { + Mode: typeof Mode; +}; +export default _default; diff --git a/Sources/Common/Transform/LandmarkTransform/index.d.ts b/Sources/Common/Transform/LandmarkTransform/index.d.ts index 265fed71d02..045b4bd3c16 100644 --- a/Sources/Common/Transform/LandmarkTransform/index.d.ts +++ b/Sources/Common/Transform/LandmarkTransform/index.d.ts @@ -1,12 +1,9 @@ import { mat4 } from 'gl-matrix'; import { vtkObject } from '../../../interfaces'; import vtkPoints from '../../Core/Points'; +import { Mode } from './Constants'; -export enum Mode { - RIGID_BODY, - SIMILARITY, - AFFINE, -} +export type { Mode }; export interface ILandmarkTransformInitialValues { mode?: Mode; @@ -27,12 +24,12 @@ export interface vtkLandmarkTransform extends vtkObject { /** * Get list of 3D points which defines the source points. */ - getSourceLandmark(): vtkPoints; + getSourceLandmark(): vtkPoints | undefined; /** * Get list of 3D points which defines the target points. */ - getTargetLandmark(): vtkPoints; + getTargetLandmark(): vtkPoints | undefined; /** * Set the number of degrees of freedom to constrain the solution to: @@ -105,5 +102,6 @@ export function newInstance( export declare const vtkLandmarkTransform: { newInstance: typeof newInstance; extend: typeof extend; + Mode: typeof Mode; }; export default vtkLandmarkTransform; diff --git a/Sources/Common/Transform/Transform/index.d.ts b/Sources/Common/Transform/Transform/index.d.ts index ac933eb55ee..8c466454dfc 100644 --- a/Sources/Common/Transform/Transform/index.d.ts +++ b/Sources/Common/Transform/Transform/index.d.ts @@ -18,6 +18,11 @@ export interface vtkTransform extends vtkObject { */ getMatrix(): mat4; + /** + * @see getMatrix + */ + getMatrixByReference(): mat4; + /** * @see getMatrix * @param {mat4} matrix @@ -63,6 +68,12 @@ export interface vtkTransform extends vtkObject { e33: number ): boolean; + /** + * @see getMatrix + * @param {mat4} matrix + */ + setMatrixFrom(matrix: mat4): void; + /** * The value of preMultiplyFlag indicates how matrix multiplications should occur. * diff --git a/Sources/Filters/Core/CleanPolyData/index.d.ts b/Sources/Filters/Core/CleanPolyData/index.d.ts index ec40d3c3691..718acdec221 100644 --- a/Sources/Filters/Core/CleanPolyData/index.d.ts +++ b/Sources/Filters/Core/CleanPolyData/index.d.ts @@ -1,4 +1,4 @@ -import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes'; +import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes/Constants'; import { vtkAlgorithm, vtkObject } from '../../../interfaces'; import { Bounds, Vector3 } from '../../../types'; @@ -53,7 +53,7 @@ export interface vtkCleanPolyData extends vtkCleanPolyDataBase { /** * Create default locator. */ - createDefaultLocator(): void; + createDefaultLocator(input?: any): void; /** * Get the absolute tolerance value. @@ -106,9 +106,10 @@ export interface vtkCleanPolyData extends vtkCleanPolyDataBase { /** * Operate on a point by applying a transformation. * - * @param {Vector3} point The point to operate on. + * @param {Vector3} inPoint The point to operate on. + * @param {Vector3} outPoint The point to write the result into. */ - operateOnPoint(point: Vector3): void; + operateOnPoint(inPoint: Vector3, outPoint: Vector3): void; /** * diff --git a/Sources/Filters/Core/ClipPolyData/index.d.ts b/Sources/Filters/Core/ClipPolyData/index.d.ts index 6b56fc89b23..6f1a56edde5 100644 --- a/Sources/Filters/Core/ClipPolyData/index.d.ts +++ b/Sources/Filters/Core/ClipPolyData/index.d.ts @@ -1,8 +1,9 @@ -import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes'; +import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes/Constants'; import vtkImplicitFunction from '../../../Common/DataModel/ImplicitFunction'; import vtkIncrementalPointLocator from '../../../Common/DataModel/IncrementalPointLocator'; import vtkPolyData from '../../../Common/DataModel/PolyData'; import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; export interface IClipPolyDataInitialValues { clipFunction?: vtkImplicitFunction; @@ -26,7 +27,7 @@ export interface vtkClipPolyData extends vtkClipPolyDataBase { /** * Get the implicit function used to perform the clipping. */ - getClipFunction(): vtkImplicitFunction; + getClipFunction(): Nullable; /** * Get the output of the filter that contains the clipped pieces. (The output of the filter is the part that is not clipped.) @@ -66,7 +67,7 @@ export interface vtkClipPolyData extends vtkClipPolyDataBase { * To use a different locator, set it with the SetLocator() method. * To turn off merging of coincident points, set the locator to null. */ - getLocator(): vtkIncrementalPointLocator; + getLocator(): Nullable; /** * Get the output points precision. diff --git a/Sources/Filters/Core/Cutter/index.d.ts b/Sources/Filters/Core/Cutter/index.d.ts new file mode 100644 index 00000000000..5a5a32d21f2 --- /dev/null +++ b/Sources/Filters/Core/Cutter/index.d.ts @@ -0,0 +1,99 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; + +export interface ICutterFunction { + getMTime(): number; + evaluateFunction(x: number, y: number, z: number): number; +} + +/** + * + */ +export interface ICutterInitialValues { + /** + * The implicit function used to cut the input data, e.g. a vtkPlane. Any + * object exposing `evaluateFunction(x, y, z)` and `getMTime()` will do. + */ + cutFunction?: Nullable; + + /** + * The iso-value of the cut function at which the input is cut. + * @default 0.0 + */ + cutValue?: number; +} + +type vtkCutterBase = vtkObject & vtkAlgorithm; + +export interface vtkCutter extends vtkCutterBase { + /** + * Get the implicit function used to cut the input data. + */ + getCutFunction(): Nullable; + + /** + * Set the implicit function used to cut the input data. + * + * @param {ICutterFunction} cutFunction The cut function + */ + setCutFunction(cutFunction: Nullable): boolean; + + /** + * Get the iso-value at which the input is cut. + * @default 0.0 + */ + getCutValue(): number; + + /** + * Set the iso-value at which the input is cut. + * + * @param {Number} cutValue The iso-value + */ + setCutValue(cutValue: number): boolean; + + /** + * The modified time of the cutter, which also accounts for the modified time + * of its cut function. + */ + getMTime(): number; + + /** + * + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkCutter characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ICutterInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ICutterInitialValues +): void; + +/** + * Method used to create a new instance of vtkCutter + * @param {ICutterInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance(initialValues?: ICutterInitialValues): vtkCutter; + +/** + * vtkCutter is a filter that any dataset with an implicit function, such as a + * vtkPlane, producing a vtkPolyData of the resulting lines and polygons. + * + * The cut function is evaluated at every input point; cells whose points do not + * all lie on the same side of the iso-value are intersected, and the + * intersection points are linearly interpolated along the crossed edges. + */ +declare const vtkCutter: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkCutter; diff --git a/Sources/Filters/Core/ImageAppend/index.d.ts b/Sources/Filters/Core/ImageAppend/index.d.ts index 6531a2d68f0..61ff1dc8a72 100644 --- a/Sources/Filters/Core/ImageAppend/index.d.ts +++ b/Sources/Filters/Core/ImageAppend/index.d.ts @@ -72,7 +72,7 @@ export interface vtkImageAppend extends vtkImageAppendBase { * @param model object on which data structure will be bounds (protected) * @param {IImageAppendInitialValues} [initialValues] (default: {}) */ -export function extend( +declare function extend( publicAPI: object, model: object, initialValues?: IImageAppendInitialValues diff --git a/Sources/Filters/Core/PolyDataNormals/index.d.ts b/Sources/Filters/Core/PolyDataNormals/index.d.ts new file mode 100644 index 00000000000..3641188dfd8 --- /dev/null +++ b/Sources/Filters/Core/PolyDataNormals/index.d.ts @@ -0,0 +1,109 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable, TypedArray } from '../../../types'; + +/** + * + */ +export interface IPolyDataNormalsInitialValues { + /** + * Whether a normal is computed for every cell of the input. + * @default false + */ + computeCellNormals?: boolean; + + /** + * Whether a normal is computed for every point of the input. + * @default true + */ + computePointNormals?: boolean; +} + +type vtkPolyDataNormalsBase = vtkObject & vtkAlgorithm; + +export interface vtkPolyDataNormals extends vtkPolyDataNormalsBase { + /** + * Get whether a normal is computed for every cell of the input. + * @default false + */ + getComputeCellNormals(): boolean; + + /** + * Get whether a normal is computed for every point of the input. + * @default true + */ + getComputePointNormals(): boolean; + + /** + * Controls whether a normal is computed for every cell of the input. + * + * @param {Boolean} computeCellNormals + */ + setComputeCellNormals(computeCellNormals: boolean): boolean; + + /** + * Controls whether a normal is computed for every point of the input. + * + * @param {Boolean} computePointNormals + */ + setComputePointNormals(computePointNormals: boolean): boolean; + + /** + * Compute the cell normals and the point normals of a set of polygons, and + * return them as a `[cellNormals, pointNormals]` pair. + * + * A point normal is the normalized sum of the normals of the cells the point + * belongs to. It is only accumulated when `computePointNormals` is on; + * otherwise the returned point normals are left zeroed. Returns `null` when + * `pointsData` is not given. + * + * @param {Number} numberOfPolys The number of polygons described by `polysData`. + * @param {Number[]|TypedArray} polysData The polygon connectivity, as + * successive runs of a point count followed by that many point ids. Runs of + * fewer than three points are skipped. + * @param {Number[]|TypedArray} pointsData The flat (x, y, z) point coordinates. + */ + vtkPolyDataNormalsExecute( + numberOfPolys: number, + polysData: number[] | TypedArray, + pointsData: Nullable + ): Nullable<[Float32Array, Float32Array]>; + + /** + * + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkPolyDataNormals characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IPolyDataNormalsInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IPolyDataNormalsInitialValues +): void; + +/** + * Method used to create a new instance of vtkPolyDataNormals. + * @param {IPolyDataNormalsInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IPolyDataNormalsInitialValues +): vtkPolyDataNormals; + +/** + * vtkPolyDataNormals is a filter that computes point and/or cell normals for a + * vtkPolyData. The input points, cells and data arrays are passed through + * unchanged; only the `Normals` arrays are added to the output. + */ +declare const vtkPolyDataNormals: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkPolyDataNormals; diff --git a/Sources/Filters/Core/ThresholdPoints/index.d.ts b/Sources/Filters/Core/ThresholdPoints/index.d.ts index 5eaeb484ed0..59b89ff5724 100644 --- a/Sources/Filters/Core/ThresholdPoints/index.d.ts +++ b/Sources/Filters/Core/ThresholdPoints/index.d.ts @@ -1,5 +1,15 @@ import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +declare enum OperationType { + Below = 'Below', + Above = 'Above', +} + +/** + * The type is public; the value is reached through the module default export. + */ +export type { OperationType }; + export interface ThresholdCriteria { arrayName: string; fieldAssociation: string; @@ -22,12 +32,23 @@ export interface vtkThresholdPoints extends vtkThresholdPointsBase { */ getCriterias(): ThresholdCriteria[]; + /** + * Get the desired precision for the output types. + */ + getCriteriasByReference(): ThresholdCriteria[]; + /** * Set the desired precision for the output types. * @param outputPointsPrecision */ setCriterias(criterias: ThresholdCriteria[]): boolean; + /** + * Set the desired precision for the output types. + * @param outputPointsPrecision + */ + setCriteriasFrom(criterias: ThresholdCriteria[]): void; + /** * * @param inData @@ -68,5 +89,6 @@ export function newInstance( export declare const vtkThresholdPoints: { newInstance: typeof newInstance; extend: typeof extend; + OperationType: typeof OperationType; }; export default vtkThresholdPoints; diff --git a/Sources/Filters/Cornerstone/ImageDataToCornerstoneImage/index.d.ts b/Sources/Filters/Cornerstone/ImageDataToCornerstoneImage/index.d.ts new file mode 100644 index 00000000000..ce61ec28b54 --- /dev/null +++ b/Sources/Filters/Cornerstone/ImageDataToCornerstoneImage/index.d.ts @@ -0,0 +1,98 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { TypedArray } from '../../../types'; + +/** + * + */ +export interface IImageDataToCornerstoneImageInitialValues { + imageId?: string; + sliceIndex?: number; +} + +/** + * The image object handed to cornerstone, as produced by this filter. + */ +export interface ICornerstoneImage { + imageId: string; + color: boolean; + columnPixelSpacing: number; + columns: number; + width: number; + rowPixelSpacing: number; + rows: number; + height: number; + intercept: number; + invert: boolean; + minPixelValue: number; + maxPixelValue: number; + sizeInBytes: number; + slope: number; + windowCenter: number; + windowWidth: number; + decodeTimeInMS: number; + getPixelData(): TypedArray; +} + +type vtkImageDataToCornerstoneImageBase = vtkObject & vtkAlgorithm; + +export interface vtkImageDataToCornerstoneImage extends vtkImageDataToCornerstoneImageBase { + /** + * Get the image id set on the produced cornerstone image. + */ + getImageId(): string; + + /** + * Get the index of the slice to extract from the input image data. + */ + getSliceIndex(): number; + + /** + * Convert the input vtkImageData slice into a cornerstone image. + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; + + /** + * Set the image id of the produced cornerstone image. + * @param {String} imageId + */ + setImageId(imageId: string): boolean; + + /** + * Set the index of the slice to extract from the input image data. + * @param {Number} sliceIndex + */ + setSliceIndex(sliceIndex: number): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkImageDataToCornerstoneImage characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IImageDataToCornerstoneImageInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IImageDataToCornerstoneImageInitialValues +): void; + +/** + * Method used to create a new instance of vtkImageDataToCornerstoneImage. + * @param {IImageDataToCornerstoneImageInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IImageDataToCornerstoneImageInitialValues +): vtkImageDataToCornerstoneImage; + +/** + * vtkImageDataToCornerstoneImage converts a slice of a vtkImageData into an + * image object that can be displayed by cornerstone. + */ +export declare const vtkImageDataToCornerstoneImage: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkImageDataToCornerstoneImage; diff --git a/Sources/Filters/General/AppendPolyData/index.d.ts b/Sources/Filters/General/AppendPolyData/index.d.ts index 39fc227ca3d..32700fae51a 100755 --- a/Sources/Filters/General/AppendPolyData/index.d.ts +++ b/Sources/Filters/General/AppendPolyData/index.d.ts @@ -1,21 +1,5 @@ import { vtkAlgorithm, vtkObject } from '../../../interfaces'; - -export enum DesiredOutputPrecision { - /** - * Output precision should match the input precision - */ - DEFAULT, - - /** - * Output single-precision floating-point (i.e. float32) - */ - SINGLE, - - /** - * Output double-precision floating point (i.e. float64) - */ - DOUBLE, -} +import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes/Constants'; /** * diff --git a/Sources/Filters/General/BFSConnectivityFilter/Constants.d.ts b/Sources/Filters/General/BFSConnectivityFilter/Constants.d.ts new file mode 100644 index 00000000000..5aee675edfb --- /dev/null +++ b/Sources/Filters/General/BFSConnectivityFilter/Constants.d.ts @@ -0,0 +1,14 @@ +export declare const ExtractionMode: { + readonly ExtractionMode_ALL: 0; + readonly ExtractionMode_LARGEST: 1; + readonly ExtractionMode_SMALLEST: 2; + readonly ExtractionMode_CUSTOM: 3; +}; + +export type ExtractionMode = + (typeof ExtractionMode)[keyof typeof ExtractionMode]; + +declare const _default: { + ExtractionMode: typeof ExtractionMode; +}; +export default _default; diff --git a/Sources/Filters/General/BFSConnectivityFilter/index.d.ts b/Sources/Filters/General/BFSConnectivityFilter/index.d.ts index f994cb6d520..ef807ccb431 100755 --- a/Sources/Filters/General/BFSConnectivityFilter/index.d.ts +++ b/Sources/Filters/General/BFSConnectivityFilter/index.d.ts @@ -1,11 +1,10 @@ import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { ExtractionMode } from './Constants'; -export enum ExtractionMode { - ExtractionMode_ALL, - ExtractionMode_LARGEST, - ExtractionMode_SMALLEST, - ExtractionMode_CUSTOM, -} +/** + * The type is public; the value is reached through the Constants module. + */ +export type { ExtractionMode }; /** * @@ -45,18 +44,38 @@ export interface vtkBFSConnectivityFilter extends vtkBFSConnectivityFilterBase { * Set the extractionMode to extract the required connected regions * @param {ExtractionMode} extractionMode */ - setExtractionMode(extractionMode: ExtractionMode): void; + setExtractionMode(extractionMode: ExtractionMode): boolean; + + /** + * Set the ExtractionMode to ExtractionMode_ALL. + */ + setExtractionModeToAll(): void; + + /** + * Set the ExtractionMode to ExtractionMode_LARGEST. + */ + setExtractionModeToLargest(): void; + + /** + * Set the ExtractionMode to ExtractionMode_SMALLEST. + */ + setExtractionModeToSmallest(): void; + + /** + * Set the ExtractionMode to ExtractionMode_CUSTOM. + */ + setExtractionModeToCustom(): void; /** * Set the index to extract regions. should be 0 ~ regionsCount-1. * @param {Number} extractionIndex */ - setExtractionIndex(extractionIndex: number): void; + setExtractionIndex(extractionIndex: number): boolean; /** - * @param {Number} regionsCount + * No-op. RegionsCount is computed internally and cannot be set. */ - setRegionsCount(regionsCount: number): void; + setRegionsCount(): void; } /** diff --git a/Sources/Filters/General/Calculator/index.d.ts b/Sources/Filters/General/Calculator/index.d.ts new file mode 100644 index 00000000000..eef7eea66f6 --- /dev/null +++ b/Sources/Filters/General/Calculator/index.d.ts @@ -0,0 +1,174 @@ +import vtkDataArray from '../../../Common/Core/DataArray'; +import { AttributeTypes } from '../../../Common/DataModel/DataSetAttributes/Constants'; +import { FieldDataTypes } from '../../../Common/DataModel/DataSet/Constants'; +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; + +/** + * Describes where an array lives and how it is identified. + * + * Exactly one of `name`, `index` or `attribute` is used to look an input array + * up; output arrays are created from the remaining fields, which are forwarded + * to `vtkDataArray.newInstance`. + */ +export interface IArraySpec { + location: FieldDataTypes; + name?: string; + index?: number; + attribute?: AttributeTypes; + numberOfComponents?: number; + dataType?: string; + /** + * Number of tuples of an output array living in `FieldDataTypes.UNIFORM`, + * where no other object provides the size. + */ + tuples?: number; +} + +export interface IArraySpecs { + input: IArraySpec[]; + output: IArraySpec[]; +} + +export interface IFormula { + getArrays(inData: any[]): IArraySpecs; + evaluate( + arraysIn: Array>, + arraysOut: Array> + ): void; +} + +export interface ISimpleFormulaOptions { + outputAttributeType?: AttributeTypes; + numberOfOutputComponents?: number; +} + +export interface IPreparedArrays { + arraysIn: Array>; + arraysOut: Array>; +} + +/** + * + */ +export interface ICalculatorInitialValues { + formula?: IFormula; +} + +type vtkCalculatorBase = vtkObject & vtkAlgorithm; + +export interface vtkCalculator extends vtkCalculatorBase { + /** + * Add the array specifiers that are implicitly available at the given + * location, on top of the ones the caller asked for. Point coordinates are + * appended when the field data is associated with points or graph vertices. + * @param {FieldDataTypes} locn + * @param {IArraySpec[]} arraysIn + */ + augmentInputArrays( + locn: FieldDataTypes, + arraysIn: IArraySpec[] + ): IArraySpec[]; + + /** + * Build a formula object that applies `singleValueFormula` tuple by tuple. + * + * The formula is called with one argument per input array followed by the + * tuple index and a scratch output tuple. It must return a number when the + * output has a single component and a tuple otherwise. + * @param {FieldDataTypes} locn + * @param {String[]} arrNames names of the input arrays + * @param {String} resultName name of the array to create + * @param singleValueFormula + * @param {ISimpleFormulaOptions} [options] (default: {}) + */ + createSimpleFormulaObject( + locn: FieldDataTypes, + arrNames: string[], + resultName: string, + singleValueFormula: (...args: any[]) => number | number[], + options?: ISimpleFormulaOptions + ): IFormula; + + /** + * Get the formula currently applied by the filter. + */ + getFormula(): IFormula; + + /** + * Fetch the input arrays and allocate the output arrays described by + * `arraySpec`. Entries are null where a specifier could not be resolved. + * @param {IArraySpecs} arraySpec + * @param inData + * @param outData + */ + prepareArrays( + arraySpec: IArraySpecs, + inData: any, + outData: any + ): IPreparedArrays; + + /** + * + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): number; + + /** + * Set the formula to apply. + * @param {IFormula} formula + */ + setFormula(formula: IFormula): boolean; + + /** + * Shorthand for `setFormula(createSimpleFormulaObject(...))`. + * @param {FieldDataTypes} locn + * @param {String[]} arrNames names of the input arrays + * @param {String} resultName name of the array to create + * @param formula + * @param {ISimpleFormulaOptions} [options] (default: {}) + */ + setFormulaSimple( + locn: FieldDataTypes, + arrNames: string[], + resultName: string, + formula: (...args: any[]) => number | number[], + options?: ISimpleFormulaOptions + ): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkCalculator characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ICalculatorInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ICalculatorInitialValues +): void; + +/** + * Method used to create a new instance of vtkCalculator + * @param {ICalculatorInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: ICalculatorInitialValues +): vtkCalculator; + +/** + * vtkCalculator - a filter that computes derived quantities from input arrays + * + * vtkCalculator evaluates a formula over the arrays of its input dataset and + * stores the result in a new array of the shallow-copied output. The formula is + * an object whose `getArrays()` method declares the input and output arrays. + * Its `evaluate()` method fills the output arrays. + */ +export declare const vtkCalculator: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkCalculator; diff --git a/Sources/Filters/General/ClipClosedSurface/Constants.d.ts b/Sources/Filters/General/ClipClosedSurface/Constants.d.ts new file mode 100644 index 00000000000..b3dae7005a5 --- /dev/null +++ b/Sources/Filters/General/ClipClosedSurface/Constants.d.ts @@ -0,0 +1,12 @@ +export declare const ScalarMode: { + readonly NONE: 0; + readonly COLORS: 1; + readonly LABELS: 2; +}; + +export type ScalarMode = (typeof ScalarMode)[keyof typeof ScalarMode]; + +declare const _default: { + ScalarMode: typeof ScalarMode; +}; +export default _default; diff --git a/Sources/Filters/General/ClipClosedSurface/index.d.ts b/Sources/Filters/General/ClipClosedSurface/index.d.ts index fda21ffe07c..0f940ce0ff9 100644 --- a/Sources/Filters/General/ClipClosedSurface/index.d.ts +++ b/Sources/Filters/General/ClipClosedSurface/index.d.ts @@ -1,15 +1,12 @@ import { vtkAlgorithm, vtkObject } from '../../../interfaces'; -import { Vector3 } from '../../../types'; +import { Nullable, Vector3 } from '../../../types'; import vtkPlane from '../../../Common/DataModel/Plane'; +import { ScalarMode } from './Constants'; /** - * + * The type is public; the value is reached through the module default export. */ -export enum ScalarMode { - NONE, - COLORS, - LABELS, -} +export type { ScalarMode }; /** * @@ -32,6 +29,81 @@ export interface IClipClosedSurfaceInitialValues { type vtkClipClosedSurfaceBase = vtkObject & vtkAlgorithm; export interface vtkClipClosedSurface extends vtkClipClosedSurfaceBase { + /** + * Get the planes used to clip the input data. + */ + getClippingPlanes(): Nullable; + + /** + * Get the tolerance used to determine when a point is on the clipping plane. + */ + getTolerance(): number; + + /** + * Get whether point data is passed through to the output. + */ + getPassPointData(): boolean; + + /** + * Get whether generated triangles are further triangulated. + */ + getTriangulatePolys(): boolean; + + /** + * Get the scalar mode used to color the output. + */ + getScalarMode(): ScalarMode; + + /** + * Get whether an outline is generated at the cut edges. + */ + getGenerateOutline(): boolean; + + /** + * Get whether faces are generated to close the clipped surface. + */ + getGenerateFaces(): boolean; + + /** + * Get the id of the active clipping plane. + */ + getActivePlaneId(): number; + + /** + * Get whether an error is displayed when triangulation fails. + */ + getTriangulationErrorDisplay(): boolean; + + /** + * Get the color used for the faces generated to close the surface. + */ + getBaseColor(): Vector3; + + /** + * Get the color used for the faces generated to close the surface. + */ + getBaseColorByReference(): Vector3; + + /** + * Get the color used for the region of a cut face that is on the active plane. + */ + getClipColor(): Vector3; + + /** + * Get the color used for the region of a cut face that is on the active plane. + */ + getClipColorByReference(): Vector3; + + /** + * Get the color used for the active plane's cut face when it differs from the other cut faces. + */ + getActivePlaneColor(): Vector3; + + /** + * Get the color used for the active plane's cut face when it differs from the other cut faces. + */ + getActivePlaneColorByReference(): Vector3; + /** * * @param {any} inData @@ -39,20 +111,116 @@ export interface vtkClipClosedSurface extends vtkClipClosedSurfaceBase { */ requestData(inData: any, outData: any): void; + /** + * Set the planes used to clip the input data. + * @param clippingPlanes + */ + setClippingPlanes(clippingPlanes: vtkPlane[]): boolean; + + /** + * Set the tolerance used to determine when a point is on the clipping plane. + * @param tolerance + */ + setTolerance(tolerance: number): boolean; + + /** + * Set whether point data is passed through to the output. + * @param passPointData + */ + setPassPointData(passPointData: boolean): boolean; + + /** + * Set whether generated triangles are further triangulated. + * @param triangulatePolys + */ + setTriangulatePolys(triangulatePolys: boolean): boolean; + + /** + * Set the scalar mode used to color the output. + * @param scalarMode + */ + setScalarMode(scalarMode: ScalarMode): boolean; + /** * Set scalarMode to NONE. */ setScalarModeToNone(): void; /** - * Set scalarMode to COLOR. + * Set scalarMode to COLORS. + */ + setScalarModeToColors(): void; + + /** + * Set scalarMode to LABELS. + */ + setScalarModeToLabels(): void; + + /** + * Set whether an outline is generated at the cut edges. + * @param generateOutline + */ + setGenerateOutline(generateOutline: boolean): boolean; + + /** + * Set whether faces are generated to close the clipped surface. + * @param generateFaces + */ + setGenerateFaces(generateFaces: boolean): boolean; + + /** + * Set the id of the active clipping plane. + * @param activePlaneId + */ + setActivePlaneId(activePlaneId: number): boolean; + + /** + * Set whether an error is displayed when triangulation fails. + * @param triangulationErrorDisplay + */ + setTriangulationErrorDisplay(triangulationErrorDisplay: boolean): boolean; + + /** + * Set the color used for the faces generated to close the surface. + * @param x + * @param y + * @param z + */ + setBaseColor(x: number, y: number, z: number): boolean; + + /** + * Set the color used for the faces generated to close the surface. + * @param baseColor + */ + setBaseColorFrom(baseColor: Vector3): void; + + /** + * Set the color used for the region of a cut face that is on the active plane. + * @param x + * @param y + * @param z + */ + setClipColor(x: number, y: number, z: number): boolean; + + /** + * Set the color used for the region of a cut face that is on the active plane. + * @param clipColor + */ + setClipColorFrom(clipColor: Vector3): void; + + /** + * Set the color used for the active plane's cut face when it differs from the other cut faces. + * @param x + * @param y + * @param z */ - setScalarModeToColor(): void; + setActivePlaneColor(x: number, y: number, z: number): boolean; /** - * Set scalarMode to LABEL. + * Set the color used for the active plane's cut face when it differs from the other cut faces. + * @param activePlaneColor */ - setScalarModeToLabel(): void; + setActivePlaneColorFrom(activePlaneColor: Vector3): void; } // ---------------------------------------------------------------------------- diff --git a/Sources/Filters/General/ClosedPolyLineToSurfaceFilter/index.d.ts b/Sources/Filters/General/ClosedPolyLineToSurfaceFilter/index.d.ts new file mode 100644 index 00000000000..07b7810d5e1 --- /dev/null +++ b/Sources/Filters/General/ClosedPolyLineToSurfaceFilter/index.d.ts @@ -0,0 +1,51 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; + +/** + * + */ +export interface IClosedPolyLineToSurfaceFilterInitialValues {} + +type vtkClosedPolyLineToSurfaceFilterBase = vtkObject & vtkAlgorithm; + +export interface vtkClosedPolyLineToSurfaceFilter extends vtkClosedPolyLineToSurfaceFilterBase { + /** + * + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkClosedPolyLineToSurfaceFilter characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IClosedPolyLineToSurfaceFilterInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IClosedPolyLineToSurfaceFilterInitialValues +): void; + +/** + * Method used to create a new instance of vtkClosedPolyLineToSurfaceFilter + * @param {IClosedPolyLineToSurfaceFilterInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IClosedPolyLineToSurfaceFilterInitialValues +): vtkClosedPolyLineToSurfaceFilter; + +/** + * vtkClosedPolyLineToSurfaceFilter - converts closed polylines into polygons + * + * vtkClosedPolyLineToSurfaceFilter aggregates the line segments of its input + * into closed loops and emits one polygon per loop. The output is a shallow + * copy of the input with its polys replaced by the reconstructed faces. + */ +export declare const vtkClosedPolyLineToSurfaceFilter: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkClosedPolyLineToSurfaceFilter; diff --git a/Sources/Filters/General/ContourTriangulator/Constants.d.ts b/Sources/Filters/General/ContourTriangulator/Constants.d.ts new file mode 100644 index 00000000000..38a87555198 --- /dev/null +++ b/Sources/Filters/General/ContourTriangulator/Constants.d.ts @@ -0,0 +1,6 @@ +export declare const CCS_POLYGON_TOLERANCE: number; + +declare const _default: { + CCS_POLYGON_TOLERANCE: typeof CCS_POLYGON_TOLERANCE; +}; +export default _default; diff --git a/Sources/Filters/General/ContourTriangulator/index.d.ts b/Sources/Filters/General/ContourTriangulator/index.d.ts index 1ca3a83f475..85204639b6a 100644 --- a/Sources/Filters/General/ContourTriangulator/index.d.ts +++ b/Sources/Filters/General/ContourTriangulator/index.d.ts @@ -19,7 +19,7 @@ export interface vtkContourTriangulator extends vtkContourTriangulatorBase { * @param {any} inData * @param {any} outData */ - requestData(inData: any, outData: any): void; + requestData(inData: any, outData: any): boolean; /** * Sets the behavior of the filter regarding polys. @@ -65,20 +65,16 @@ export interface vtkContourTriangulator extends vtkContourTriangulatorBase { * @param {Boolean} [triangulatePolys] (default: true) If set to true * the resulting polygons will be triangulated, otherwise the polygons * themselves will be added to the output. - * @param {Boolean} [diagnoseOnTriangulationError] (default: false) - * If this option is set to true and there was a triangulation error - * this will add the polys as outlines to the output. * @returns {Boolean} Returns true if triangulation was successful, * false otherwise. */ -export function triangulateContours( +declare function triangulateContours( polyData: vtkPolyData, firstLine: number, numLines: number, polys: vtkCellArray, normal: Nullable, - triangulatePolys?: boolean, - diagnoseOnTriangulationError?: boolean + triangulatePolys?: boolean ): boolean; /** @@ -93,7 +89,7 @@ export function triangulateContours( * @returns {Boolean} Returns true if triangulation was successful, * false otherwise. */ -export function triangulatePolygon( +declare function triangulatePolygon( polygon: Array | TypedArray, points: vtkPoints, triangles: vtkCellArray @@ -133,4 +129,9 @@ export declare const vtkContourTriangulator: { triangulatePolygon: typeof triangulatePolygon; }; +export declare const STATIC: Readonly<{ + triangulateContours: typeof triangulateContours; + triangulatePolygon: typeof triangulatePolygon; +}>; + export default vtkContourTriangulator; diff --git a/Sources/Filters/General/ImageCropFilter/index.d.ts b/Sources/Filters/General/ImageCropFilter/index.d.ts index d47b7d5043e..1e489bf0bde 100755 --- a/Sources/Filters/General/ImageCropFilter/index.d.ts +++ b/Sources/Filters/General/ImageCropFilter/index.d.ts @@ -14,15 +14,13 @@ type vtkImageCropFilterBase = vtkObject & vtkAlgorithm; export interface vtkImageCropFilter extends vtkImageCropFilterBase { /** * Get The cropping planes, in IJK space. - * @default [0, 0, 0, 0, 0, 0]. */ - getCroppingPlanes(): CroppingPlanes; + getCroppingPlanes(): CroppingPlanes | undefined; /** * Get The cropping planes, in IJK space. - * @default [0, 0, 0, 0, 0, 0]. */ - getCroppingPlanesByReference(): CroppingPlanes; + getCroppingPlanesByReference(): CroppingPlanes | undefined; /** * @@ -51,7 +49,7 @@ export interface vtkImageCropFilter extends vtkImageCropFilterBase { * * @param croppingPlanes */ - setCroppingPlanesFrom(croppingPlanes: CroppingPlanes): boolean; + setCroppingPlanesFrom(croppingPlanes: CroppingPlanes): void; } /** diff --git a/Sources/Filters/General/ImageDataOutlineFilter/index.d.ts b/Sources/Filters/General/ImageDataOutlineFilter/index.d.ts index c5aed4ece97..81d0a94039d 100644 --- a/Sources/Filters/General/ImageDataOutlineFilter/index.d.ts +++ b/Sources/Filters/General/ImageDataOutlineFilter/index.d.ts @@ -2,8 +2,6 @@ import { vtkAlgorithm, vtkObject } from '../../../interfaces'; import vtkImageData from '../../../Common/DataModel/ImageData'; import vtkPolyData from '../../../Common/DataModel/PolyData'; -export const LINE_ARRAY: number[]; - export interface IImageDataOutlineFilterInitialValues {} type vtkImageDataOutlineFilterBase = vtkObject & vtkAlgorithm; @@ -14,7 +12,7 @@ export interface vtkImageDataOutlineFilter extends vtkImageDataOutlineFilterBase * @param inData * @param outData */ - requestData(inData: vtkImageData, outData: vtkPolyData): void; + requestData(inData: vtkImageData[], outData: vtkPolyData[]): void; /** * Flag that indicates whether the output will generate faces of the outline. diff --git a/Sources/Filters/General/ImageMarchingCubes/index.d.ts b/Sources/Filters/General/ImageMarchingCubes/index.d.ts new file mode 100644 index 00000000000..81dacb058d9 --- /dev/null +++ b/Sources/Filters/General/ImageMarchingCubes/index.d.ts @@ -0,0 +1,205 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Extent, TypedArray, Vector3 } from '../../../types'; + +/** + * + */ +export interface IImageMarchingCubesInitialValues { + contourValue?: number; + computeNormals?: boolean; + mergePoints?: boolean; +} + +type vtkImageMarchingCubesBase = vtkObject & vtkAlgorithm; + +export interface vtkImageMarchingCubes extends vtkImageMarchingCubesBase { + /** + * Get whether point normals are interpolated from the scalar gradient. + */ + getComputeNormals(): boolean; + + /** + * Get the iso-value at which the surface is extracted. + */ + getContourValue(): number; + + /** + * Get whether points shared by neighboring voxels are merged. + */ + getMergePoints(): boolean; + + /** + * Compute the scalar gradient at the i-j-k point and store it in `g`. + * @param {Number} i + * @param {Number} j + * @param {Number} k + * @param {Vector3} dims + * @param {Number} slice number of points in one i-j slice + * @param {Vector3} spacing + * @param {TypedArray|Number[]} s scalar values + * @param {Number[]} g gradient output + */ + getPointGradient( + i: number, + j: number, + k: number, + dims: Vector3, + slice: number, + spacing: Vector3, + s: TypedArray | number[], + g: number[] + ): void; + + /** + * Compute the gradients of the eight corners of the voxel whose origin is + * i-j-k and cache them for the next call to produceTriangles. + * @param {Number} i + * @param {Number} j + * @param {Number} k + * @param {Vector3} dims + * @param {Number} slice number of points in one i-j slice + * @param {Vector3} spacing + * @param {TypedArray|Number[]} scalars + */ + getVoxelGradients( + i: number, + j: number, + k: number, + dims: Vector3, + slice: number, + spacing: Vector3, + scalars: TypedArray | number[] + ): void; + + /** + * Compute the world coordinates of the eight corners of the voxel whose + * origin is i-j-k and cache them for the next call to produceTriangles. + * @param {Number} i + * @param {Number} j + * @param {Number} k + * @param {Vector3} origin + * @param {Vector3} spacing + */ + getVoxelPoints( + i: number, + j: number, + k: number, + origin: Vector3, + spacing: Vector3 + ): void; + + /** + * Cache the point ids and the scalar values of the eight corners of the voxel + * whose origin is i-j-k. + * @param {Number} i + * @param {Number} j + * @param {Number} k + * @param {Number} slice number of points in one i-j slice + * @param {Vector3} dims + * @param {Vector3} origin + * @param {Vector3} spacing + * @param {TypedArray|Number[]} s scalar values + */ + getVoxelScalars( + i: number, + j: number, + k: number, + slice: number, + dims: Vector3, + origin: Vector3, + spacing: Vector3, + s: TypedArray | number[] + ): void; + + /** + * Append the triangles contributed by one voxel to `points`, `tris` and, + * when computeNormals is on, `normals`. + * @param {Number} cVal contour value + * @param {Number} i + * @param {Number} j + * @param {Number} k + * @param {Extent} extent + * @param {Number} slice number of points in one i-j slice + * @param {Vector3} dims + * @param {Vector3} origin + * @param {Vector3} spacing + * @param {TypedArray|Number[]} scalars + * @param {Number[]} points + * @param {Number[]} tris + * @param {Number[]} normals + */ + produceTriangles( + cVal: number, + i: number, + j: number, + k: number, + extent: Extent, + slice: number, + dims: Vector3, + origin: Vector3, + spacing: Vector3, + scalars: TypedArray | number[], + points: number[], + tris: number[], + normals: number[] + ): void; + + /** + * + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; + + /** + * Set whether point normals are interpolated from the scalar gradient. + * @param {Boolean} computeNormals + */ + setComputeNormals(computeNormals: boolean): boolean; + + /** + * Set the iso-value at which the surface is extracted. + * @param {Number} contourValue + */ + setContourValue(contourValue: number): boolean; + + /** + * Set whether points shared by neighboring voxels are merged. + * @param {Boolean} mergePoints + */ + setMergePoints(mergePoints: boolean): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkImageMarchingCubes characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IImageMarchingCubesInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IImageMarchingCubesInitialValues +): void; + +/** + * Method used to create a new instance of vtkImageMarchingCubes + * @param {IImageMarchingCubesInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IImageMarchingCubesInitialValues +): vtkImageMarchingCubes; + +/** + * vtkImageMarchingCubes - generate an isosurface from a vtkImageData + * + * vtkImageMarchingCubes is a filter that takes a vtkImageData as input and + * generates, using the marching cubes case table, a vtkPolyData containing the + * triangles of the isosurface at the requested contour value. + */ +export declare const vtkImageMarchingCubes: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkImageMarchingCubes; diff --git a/Sources/Filters/General/ImageMarchingSquares/index.d.ts b/Sources/Filters/General/ImageMarchingSquares/index.d.ts new file mode 100644 index 00000000000..6376b8c3fef --- /dev/null +++ b/Sources/Filters/General/ImageMarchingSquares/index.d.ts @@ -0,0 +1,167 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { TypedArray, Vector3 } from '../../../types'; + +/** + * Converts an i-j-k index into world coordinates, writing them into `out`. + */ +export type IndexToWorld = (ijk: number[], out: number[]) => number[]; + +/** + * + */ +export interface IImageMarchingSquaresInitialValues { + contourValues?: number[]; + slicingMode?: number; + slice?: number; + mergePoints?: boolean; +} + +type vtkImageMarchingSquaresBase = vtkObject & vtkAlgorithm; + +export interface vtkImageMarchingSquares extends vtkImageMarchingSquaresBase { + /** + * Get the list of contour values. + */ + getContourValues(): number[]; + + /** + * Get whether points shared by neighboring pixels are merged. + */ + getMergePoints(): boolean; + + /** + * Cache the world coordinates of the four corners of the pixel whose origin + * is `ijk`. + * @param {Vector3} ijk origin of the pixel + * @param {Number} kernelX index of the X element + * @param {Number} kernelY index of the Y element + * @param {IndexToWorld} indexToWorld + */ + getPixelPoints( + ijk: Vector3, + kernelX: number, + kernelY: number, + indexToWorld: IndexToWorld + ): void; + + /** + * Cache the point ids and the scalar values of the four corners of the pixel + * whose origin is `ijk`. + * @param {Vector3} ijk origin of the pixel + * @param {Vector3} dims dimensions of the image + * @param {TypedArray|Number[]} scalars + * @param {Vector3} increments IJK slice increments + * @param {Number} kernelX index of the X element + * @param {Number} kernelY index of the Y element + */ + getPixelScalars( + ijk: Vector3, + dims: Vector3, + scalars: TypedArray | number[], + increments: Vector3, + kernelX: number, + kernelY: number + ): void; + + /** + * Get the index of the axis along which the image is sliced. + */ + getSlicingMode(): number; + + /** + * Get the index of the slice the contours are extracted from. + */ + getSlice(): number; + + /** + * Append the line segments contributed by one pixel to `points` and `lines`. + * @param {Number} cVal contour value + * @param {Vector3} ijk origin of the pixel + * @param {Vector3} dims dimensions of the image + * @param {TypedArray|Number[]} scalars + * @param {Number[]} points + * @param {Number[]} lines + * @param {Vector3} increments IJK slice increments + * @param {Number} kernelX index of the X element + * @param {Number} kernelY index of the Y element + * @param {IndexToWorld} indexToWorld + */ + produceLines( + cVal: number, + ijk: Vector3, + dims: Vector3, + scalars: TypedArray | number[], + points: number[], + lines: number[], + increments: Vector3, + kernelX: number, + kernelY: number, + indexToWorld: IndexToWorld + ): void; + + /** + * + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; + + /** + * Set the list of contour values. + * @param {Number[]} cValues + */ + setContourValues(cValues: number[]): void; + + /** + * Set whether points shared by neighboring pixels are merged. + * @param {Boolean} mergePoints + */ + setMergePoints(mergePoints: boolean): boolean; + + /** + * Set the index of the slice the contours are extracted from. + * @param {Number} slice + */ + setSlice(slice: number): boolean; + + /** + * Set the index of the axis along which the image is sliced (0: I, 1: J, + * 2: K). + * @param {Number} slicingMode + */ + setSlicingMode(slicingMode: number): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkImageMarchingSquares characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IImageMarchingSquaresInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IImageMarchingSquaresInitialValues +): void; + +/** + * Method used to create a new instance of vtkImageMarchingSquares + * @param {IImageMarchingSquaresInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IImageMarchingSquaresInitialValues +): vtkImageMarchingSquares; + +/** + * vtkImageMarchingSquares - generate isolines from one slice of a vtkImageData + * + * vtkImageMarchingSquares is a filter that takes a vtkImageData as input and + * generates, using the marching squares case table, a vtkPolyData containing + * one polyline per contour value on the selected slice. + */ +export declare const vtkImageMarchingSquares: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkImageMarchingSquares; diff --git a/Sources/Filters/General/MoleculeToRepresentation/index.d.ts b/Sources/Filters/General/MoleculeToRepresentation/index.d.ts new file mode 100644 index 00000000000..5f273686888 --- /dev/null +++ b/Sources/Filters/General/MoleculeToRepresentation/index.d.ts @@ -0,0 +1,146 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; + +/** + * Name of the per-element radius entry of `Utilities/XMLConverter/chemistry/elements.json` + * used to size the atom spheres. + */ +export type RadiusType = 'radiusVDW' | 'radiusCovalent'; + +/** + * + */ +export interface IMoleculeToRepresentationInitialValues { + sphereScaleArrayName?: string; + tolerance?: number; + atomicRadiusScaleFactor?: number; + bondRadius?: number; + deltaBondFactor?: number; + radiusType?: RadiusType; + hideElements?: string | string[]; +} + +type vtkMoleculeToRepresentationBase = vtkObject & vtkAlgorithm; + +export interface vtkMoleculeToRepresentation extends vtkMoleculeToRepresentationBase { + /** + * Get the factor applied to the tabulated atomic radius. + */ + getAtomicRadiusScaleFactor(): number; + + /** + * Get the radius of the sticks representing the bonds. + */ + getBondRadius(): number; + + /** + * Get the extra spacing inserted between the sticks of a multiple bond. + */ + getDeltaBondFactor(): number; + + /** + * Get the elements, identified by their id, that are not represented. + */ + getHideElements(): string | string[]; + + /** + * Get which tabulated radius is used to size the atom spheres. + */ + getRadiusType(): RadiusType; + + /** + * Get the name given to the sphere scale array of the first output. + */ + getSphereScaleArrayName(): string; + + /** + * Get the extra distance allowed when deducing bonds from atom positions. + */ + getTolerance(): number; + + /** + * Produce the sphere polydata on output 0 and the stick polydata on output 1. + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): number; + + /** + * Set the factor applied to the tabulated atomic radius. + * @param {Number} atomicRadiusScaleFactor + */ + setAtomicRadiusScaleFactor(atomicRadiusScaleFactor: number): boolean; + + /** + * Set the radius of the sticks representing the bonds. + * @param {Number} bondRadius + */ + setBondRadius(bondRadius: number): boolean; + + /** + * Set the extra spacing inserted between the sticks of a multiple bond. + * @param {Number} deltaBondFactor + */ + setDeltaBondFactor(deltaBondFactor: number): boolean; + + /** + * Set the elements, identified by their id, that must not be represented. + * @param {String|String[]} hideElements + */ + setHideElements(hideElements: string | string[]): boolean; + + /** + * Set which tabulated radius is used to size the atom spheres. + * @param {RadiusType} radiusType + */ + setRadiusType(radiusType: RadiusType): boolean; + + /** + * Set the name given to the sphere scale array of the first output. + * @param {String} sphereScaleArrayName + */ + setSphereScaleArrayName(sphereScaleArrayName: string): boolean; + + /** + * Set the extra distance allowed when deducing bonds from atom positions. + * Two atoms are bonded when their distance is below the sum of their + * covalent radii plus this tolerance. + * @param {Number} tolerance + */ + setTolerance(tolerance: number): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkMoleculeToRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IMoleculeToRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IMoleculeToRepresentationInitialValues +): void; + +/** + * Method used to create a new instance of vtkMoleculeToRepresentation + * @param {IMoleculeToRepresentationInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IMoleculeToRepresentationInitialValues +): vtkMoleculeToRepresentation; + +/** + * vtkMoleculeToRepresentation - convert a molecule into renderable polydata + * + * vtkMoleculeToRepresentation takes a molecule as input and produces two + * outputs: a polydata whose points are the atoms, carrying a scale and a color + * array, and a polydata whose points are the bonds, carrying a scale, an + * orientation and a color array. Bonds absent from the input are deduced from + * the distance between the atoms and their covalent radii. + */ +export declare const vtkMoleculeToRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkMoleculeToRepresentation; diff --git a/Sources/Filters/General/OBBTree/OBBNode.d.ts b/Sources/Filters/General/OBBTree/OBBNode.d.ts new file mode 100644 index 00000000000..6079c1820f9 --- /dev/null +++ b/Sources/Filters/General/OBBTree/OBBNode.d.ts @@ -0,0 +1,147 @@ +import { vtkObject } from '../../../interfaces'; +import { Nullable, Vector3 } from '../../../types'; + +/** + * The three axes of an oriented bounding box, ordered from longest to shortest. + */ +export type OBBAxes = [Vector3, Vector3, Vector3]; + +/** + * + */ +export interface IOBBNodeInitialValues { + corner?: Vector3; + axes?: OBBAxes; + cells?: number[]; +} + +export interface vtkOBBNode extends vtkObject { + /** + * Recursively copy `nodeSource`, and its children, into this node. + * @param {vtkOBBNode} nodeSource + */ + deepCopy(nodeSource: vtkOBBNode): void; + + /** + * Get the three axes of the box. + */ + getAxes(): OBBAxes; + + /** + * Get the three axes of the box. + */ + getAxesByReference(): OBBAxes; + + /** + * Get one of the three axes of the box. + * @param {Number} axis 0 for the longest axis, 2 for the shortest + */ + getAxis(axis: number): Vector3; + + /** + * Get the ids of the cells contained in this node. + */ + getCells(): number[]; + + /** + * Get the corner of the box the axes originate from. + */ + getCorner(): Vector3; + + /** + * Get the corner of the box the axes originate from. + */ + getCornerByReference(): Vector3; + + /** + * Get the two children of this node, or null when it is a leaf. + */ + getKids(): Nullable<[vtkOBBNode, vtkOBBNode]>; + + /** + * Get the parent of this node, or null when it is the root. + */ + getParent(): Nullable; + + /** + * Set the three axes of the box. + * @param {OBBAxes} axes + */ + setAxes(axes: OBBAxes): boolean; + + /** + * Set the three axes of the box. + * @param {OBBAxes} axes + */ + setAxesFrom(axes: OBBAxes): void; + + /** + * Set the ids of the cells contained in this node. + * @param {Number[]} cells + */ + setCells(cells: number[]): boolean; + + /** + * Set the corner of the box the axes originate from. + * @param {Vector3} corner + */ + setCorner(corner: Vector3): boolean; + + /** + * Set the corner of the box the axes originate from. + * @param {Number} x + * @param {Number} y + * @param {Number} z + */ + setCorner(x: number, y: number, z: number): boolean; + + /** + * Set the corner of the box the axes originate from. + * @param {Vector3} corner + */ + setCornerFrom(corner: Vector3): void; + + /** + * Set the two children of this node. + * @param {[vtkOBBNode, vtkOBBNode]} kids + */ + setKids(kids: Nullable<[vtkOBBNode, vtkOBBNode]>): boolean; + + /** + * Set the parent of this node. + * @param {vtkOBBNode} parent + */ + setParent(parent: Nullable): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOBBNode characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOBBNodeInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOBBNodeInitialValues +): void; + +/** + * Method used to create a new instance of vtkOBBNode + * @param {IOBBNodeInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance(initialValues?: IOBBNodeInitialValues): vtkOBBNode; + +/** + * vtkOBBNode - a node of an oriented bounding box tree + * + * vtkOBBNode holds one oriented bounding box of a vtkOBBTree: the corner the + * box originates from, its three axes ordered from longest to shortest, the + * cells it contains, and the two children it was split into. + */ +export declare const vtkOBBNode: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOBBNode; diff --git a/Sources/Filters/General/OBBTree/index.d.ts b/Sources/Filters/General/OBBTree/index.d.ts new file mode 100644 index 00000000000..6802e0a15bc --- /dev/null +++ b/Sources/Filters/General/OBBTree/index.d.ts @@ -0,0 +1,278 @@ +import { mat4 } from 'gl-matrix'; +import vtkMatrixBuilder from '../../../Common/Core/MatrixBuilder'; +import vtkPolyData from '../../../Common/DataModel/PolyData'; +import { vtkObject } from '../../../interfaces'; +import { Nullable, Vector3 } from '../../../types'; +import vtkOBBNode from './OBBNode'; + +type Transform = ReturnType; + +/** + * Called for every pair of intersecting leaf nodes found by intersectWithOBBTree. + * Returning a negative number stops the traversal. + */ +export type OnIntersectCallback = ( + nodeA: vtkOBBNode, + nodeB: vtkOBBNode, + XformBtoA: Nullable +) => number; + +/** + * Accumulator handed to findTriangleIntersections. + */ +export interface ITriangleIntersectionInfo { + /** + * The tree the triangles of the second node belong to. + */ + obbTree1: vtkOBBTree; + /** + * Polydata the intersection points and lines are appended to. + */ + intersectionLines: vtkPolyData; +} + +/** + * + */ +export interface IOBBTreeInitialValues { + tolerance?: number; + automatic?: boolean; + numberOfCellsPerNode?: number; + dataset?: vtkPolyData; + tree?: vtkOBBNode; + level?: number; + maxLevel?: number; + retainCellLists?: number; +} + +export interface vtkOBBTree extends vtkObject { + /** + * Build the OBB tree of the current dataset. The tree is discarded and + * rebuilt on every call. + */ + buildLocator(): void; + + /** + * Compute the oriented bounding box of a dataset without building a tree. + * The results are written into the arrays passed in. + * @param {vtkPolyData} input + * @param {Vector3} corner corner the axes originate from + * @param {Vector3} max longest axis + * @param {Vector3} mid middle axis + * @param {Vector3} min shortest axis + * @param {Vector3} size extent of the box along each axis + */ + computeOBBFromDataset( + input: vtkPolyData, + corner: Vector3, + max: Vector3, + mid: Vector3, + min: Vector3, + size: Vector3 + ): void; + + /** + * Copy the settings and the tree of another OBB tree into this one. + * @param {vtkOBBTree} tree + */ + deepCopy(tree: vtkOBBTree): void; + + /** + * Test whether two nodes are disjoint, `nodeB` being optionally transformed + * into the space of `nodeA` by `XformBtoA`. Returns 0 when the boxes overlap + * and the number of the separating axis test that succeeded otherwise. + * @param {vtkOBBNode} nodeA + * @param {vtkOBBNode} nodeB + * @param {mat4} [XformBtoA] assumed to be orthogonal + */ + disjointOBBNodes( + nodeA: Nullable, + nodeB: Nullable, + XformBtoA?: Nullable + ): number; + + /** + * Intersect the triangles of two leaf nodes and append the resulting + * segments to `info.intersectionLines`. Returns the number of intersection + * lines found. + * @param {ITriangleIntersectionInfo} info + * @param {vtkOBBNode} node0 leaf of this tree + * @param {vtkOBBNode} node1 leaf of `info.obbTree1` + * @param {mat4} [transform] + */ + findTriangleIntersections( + info: ITriangleIntersectionInfo, + node0: vtkOBBNode, + node1: vtkOBBNode, + transform?: Nullable + ): number; + + /** + * Create a polygonal representation of the boxes at the given level. When + * `level` is negative the leaf nodes are gathered instead. Returns null when + * the tree has not been built. + * @param {Number} level + */ + generateRepresentation(level: number): Nullable; + + /** + * Get whether the number of cells per node is computed from the dataset. + */ + getAutomatic(): boolean; + + /** + * Get the dataset the tree is built from. + */ + getDataset(): Nullable; + + /** + * Get the depth reached by the last call to buildLocator. + */ + getLevel(): number; + + /** + * Get the maximum depth of the tree. + */ + getMaxLevel(): number; + + /** + * Get the number of cells below which a node is not split any further. + */ + getNumberOfCellsPerNode(): number; + + /** + * Get whether the cell lists of the non-leaf nodes are kept. + */ + getRetainCellLists(): number; + + /** + * Get the tolerance used by the separating axis tests. + */ + getTolerance(): number; + + /** + * Get the root node of the tree. + */ + getTree(): Nullable; + + /** + * Traverse this tree against `obbTreeB` and call `onIntersect` for every pair + * of intersecting leaf nodes. `obbTreeB` is optionally transformed into the + * space of this tree by `XformBtoA`. Returns the accumulated absolute value + * of the callback results. + * @param {vtkOBBTree} obbTreeB + * @param {mat4} [XformBtoA] + * @param {OnIntersectCallback} [onIntersect] (default: () => -1) + */ + intersectWithOBBTree( + obbTreeB: vtkOBBTree, + XformBtoA?: Nullable, + onIntersect?: OnIntersectCallback + ): number; + + /** + * Set whether the number of cells per node is computed from the dataset. + * @param {Boolean} automatic + */ + setAutomatic(automatic: boolean): boolean; + + /** + * Set the dataset the tree is built from. + * @param {vtkPolyData} dataset + */ + setDataset(dataset: vtkPolyData): boolean; + + /** + * Set the depth of the tree. + * @param {Number} level + */ + setLevel(level: number): boolean; + + /** + * Set the maximum depth of the tree. + * @param {Number} maxLevel + */ + setMaxLevel(maxLevel: number): boolean; + + /** + * Set the number of cells below which a node is not split any further. + * @param {Number} numberOfCellsPerNode + */ + setNumberOfCellsPerNode(numberOfCellsPerNode: number): boolean; + + /** + * Set whether the cell lists of the non-leaf nodes are kept. + * @param {Number} retainCellLists + */ + setRetainCellLists(retainCellLists: number): boolean; + + /** + * Set the tolerance used by the separating axis tests. + * @param {Number} tolerance + */ + setTolerance(tolerance: number): boolean; + + /** + * Set the root node of the tree. + * @param {vtkOBBNode} tree + */ + setTree(tree: Nullable): boolean; + + /** + * Test whether a triangle intersects a node, the triangle being optionally + * transformed into the space of the node by `XformBtoA`. Returns 1 when they + * overlap and 0 otherwise. + * @param {vtkOBBNode} nodeA + * @param {Vector3} p0 + * @param {Vector3} p1 + * @param {Vector3} p2 + * @param {mat4} [XformBtoA] assumed to be orthogonal + */ + triangleIntersectsNode( + nodeA: vtkOBBNode, + p0: Vector3, + p1: Vector3, + p2: Vector3, + XformBtoA?: Nullable + ): number; + + /** + * Apply a transform to every node of the tree in place. + * @param {Transform} transform a vtkMatrixBuilder transform + */ + transform(transform: Transform): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOBBTree characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOBBTreeInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOBBTreeInitialValues +): void; + +/** + * Method used to create a new instance of vtkOBBTree + * @param {IOBBTreeInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance(initialValues?: IOBBTreeInitialValues): vtkOBBTree; + +/** + * vtkOBBTree - generate an oriented bounding box hierarchy for a dataset + * + * vtkOBBTree builds a tree of oriented bounding boxes over the cells of a + * vtkPolyData. Each node holds the box of a subset of the cells, split in two + * along its longest axis until the leaves hold no more than + * numberOfCellsPerNode cells or the maximum level is reached. The tree can then + * be tested against another OBB tree to find intersecting cells. + */ +export declare const vtkOBBTree: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOBBTree; diff --git a/Sources/Filters/General/OutlineFilter/index.d.ts b/Sources/Filters/General/OutlineFilter/index.d.ts index 0ea4c61acb6..9aca0172926 100755 --- a/Sources/Filters/General/OutlineFilter/index.d.ts +++ b/Sources/Filters/General/OutlineFilter/index.d.ts @@ -50,5 +50,7 @@ export function newInstance( export declare const vtkOutlineFilter: { newInstance: typeof newInstance; extend: typeof extend; + BOUNDS_MAP: typeof BOUNDS_MAP; + LINE_ARRAY: typeof LINE_ARRAY; }; export default vtkOutlineFilter; diff --git a/Sources/Filters/General/PaintFilter/index.d.ts b/Sources/Filters/General/PaintFilter/index.d.ts new file mode 100644 index 00000000000..dbdb745d0cd --- /dev/null +++ b/Sources/Filters/General/PaintFilter/index.d.ts @@ -0,0 +1,239 @@ +import { mat4 } from 'gl-matrix'; +import vtkImageData from '../../../Common/DataModel/ImageData'; +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable, Vector3 } from '../../../types'; + +/** + * Decides, for one voxel of the background image, whether the label is applied. + * + * @param voxel the tuple of the background image at `index` + * @param index flat point index + * @param label the label about to be written + */ +export type VoxelFunc = ( + voxel: number[], + index: number, + label: number +) => boolean; + +/** + * + */ +export interface IPaintFilterInitialValues { + backgroundImage?: vtkImageData; + labelMap?: vtkImageData; + maskWorldToIndex?: mat4; + voxelFunc?: VoxelFunc; + radius?: number; + label?: number; + slicingMode?: number; +} + +type vtkPaintFilterBase = vtkObject & + Omit< + vtkAlgorithm, + | 'setInputData' + | 'setInputConnection' + | 'addInputData' + | 'addInputConnection' + | 'getInputData' + | 'getInputConnection' + >; + +export interface vtkPaintFilter extends vtkPaintFilterBase { + /** + * Add a point to the current stroke. + * @param {Vector3} point world coordinates + */ + addPoint(point: Vector3): void; + + /** + * Write the current label into the label map wherever `maskBuffer` is set, + * pushing the overwritten values onto the undo history. + * @param maskBuffer binary mask, one byte per point of the label map + */ + applyBinaryMask(maskBuffer: ArrayBuffer): void; + + /** + * Replace the label map, recording the difference with the current one as a + * single undoable step. + * @param {vtkImageData} labelMap + */ + applyLabelMap(labelMap: vtkImageData): void; + + /** + * Whether there is a step available to redo. + */ + canRedo(): boolean; + + /** + * Whether there is a step available to undo. + */ + canUndo(): boolean; + + /** + * Terminate the current stroke and apply it to the label map. Returns + * undefined when no stroke is in progress. + */ + endStroke(): Promise | undefined; + + /** + * Get the image the voxel function is evaluated against. + */ + getBackgroundImage(): Nullable; + + /** + * Get the value written into the label map by the current stroke. + */ + getLabel(): number; + + /** + * Get the label map being painted into. + */ + getLabelMap(): Nullable; + + /** + * Get the transform used to convert the painted world coordinates into + * label map indices. + */ + getMaskWorldToIndex(): Nullable; + + /** + * Get the brush radius, in world units. + */ + getRadius(): number; + + /** + * Get the slicing mode restricting the paint operations to a single slice. + */ + getSlicingMode(): Nullable; + + /** + * Get the predicate deciding, per voxel, whether the label is written. + */ + getVoxelFunc(): Nullable; + + /** + * Paint the axis-aligned ellipse of the current stroke. + * @param {Vector3} center world coordinates of the center + * @param {Vector3} scale3 world coordinates of the semi-axes + */ + paintEllipse(center: Vector3, scale3: Vector3): void; + + /** + * Paint the triangulated polygon defined by a flat list of world coordinates. + * @param {Number[]} pointList flattened xyz triplets + */ + paintPolygon(pointList: number[]): void; + + /** + * Paint the axis-aligned box spanned by two world points. + * @param {Vector3} point1 + * @param {Vector3} point2 + */ + paintRectangle(point1: Vector3, point2: Vector3): void; + + /** + * Re-apply the last undone step. + */ + redo(): void; + + /** + * Allocate the label map from the background image if needed and publish it + * on the output port. + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; + + /** + * Set the image the voxel function is evaluated against. + * @param {vtkImageData} backgroundImage + */ + setBackgroundImage(backgroundImage: vtkImageData): boolean; + + /** + * Set the value written into the label map by the following strokes. + * @param {Number} label + */ + setLabel(label: number): boolean; + + /** + * Set the label map being painted into. Setting it resets the undo history. + * @param {vtkImageData} labelMap + */ + setLabelMap(labelMap: vtkImageData): boolean; + + /** + * Set the transform used to convert the painted world coordinates into + * label map indices. + * @param {mat4} maskWorldToIndex + */ + setMaskWorldToIndex(maskWorldToIndex: mat4): boolean; + + /** + * Set the brush radius, in world units. + * @param {Number} radius + */ + setRadius(radius: number): boolean; + + /** + * Restrict the paint operations to a single slice along the given axis, or + * pass null to paint in 3D. + * @param {Number} slicingMode + */ + setSlicingMode(slicingMode: Nullable): boolean; + + /** + * Set a predicate deciding, per voxel, whether the label is written. + * @param {VoxelFunc} voxelFunc + */ + setVoxelFunc(voxelFunc: Nullable): boolean; + + /** + * Start a new stroke. Paint operations are accumulated by a worker until + * endStroke is called. + */ + startStroke(): void; + + /** + * Revert the last applied stroke. + */ + undo(): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkPaintFilter characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IPaintFilterInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IPaintFilterInitialValues +): void; + +/** + * Method used to create a new instance of vtkPaintFilter + * @param {IPaintFilterInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IPaintFilterInitialValues +): vtkPaintFilter; + +/** + * vtkPaintFilter - painting into a label map + * + * vtkPaintFilter is a source producing a label map, of the same geometry as the + * background image, that is painted into with a brush. A stroke is opened with + * startStroke, fed with addPoint, paintRectangle, paintEllipse or paintPolygon, + * and committed with endStroke. Committed strokes can be reverted with undo and + * reapplied with redo. + */ +export declare const vtkPaintFilter: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkPaintFilter; diff --git a/Sources/Filters/General/ScalarToRGBA/index.d.ts b/Sources/Filters/General/ScalarToRGBA/index.d.ts new file mode 100644 index 00000000000..e4c03b0a55a --- /dev/null +++ b/Sources/Filters/General/ScalarToRGBA/index.d.ts @@ -0,0 +1,80 @@ +import vtkPiecewiseFunction from '../../../Common/DataModel/PiecewiseFunction'; +import vtkScalarsToColors from '../../../Common/Core/ScalarsToColors'; +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; + +/** + * + */ +export interface IScalarToRGBAInitialValues { + lookupTable?: vtkScalarsToColors; + piecewiseFunction?: vtkPiecewiseFunction; +} + +type vtkScalarToRGBABase = vtkObject & vtkAlgorithm; + +export interface vtkScalarToRGBA extends vtkScalarToRGBABase { + /** + * Get the lookup table mapping the input scalars to RGB. + */ + getLookupTable(): Nullable; + + /** + * Get the transfer function mapping the input scalars to opacity. + */ + getPiecewiseFunction(): Nullable; + + /** + * + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; + + /** + * Set the lookup table mapping the input scalars to RGB. + * @param {vtkScalarsToColors} lookupTable + */ + setLookupTable(lookupTable: vtkScalarsToColors): boolean; + + /** + * Set the transfer function mapping the input scalars to opacity. + * @param {vtkPiecewiseFunction} piecewiseFunction + */ + setPiecewiseFunction(piecewiseFunction: vtkPiecewiseFunction): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkScalarToRGBA characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IScalarToRGBAInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IScalarToRGBAInitialValues +): void; + +/** + * Method used to create a new instance of vtkScalarToRGBA + * @param {IScalarToRGBAInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IScalarToRGBAInitialValues +): vtkScalarToRGBA; + +/** + * vtkScalarToRGBA - map the scalars of an image to an RGBA image + * + * vtkScalarToRGBA converts the point scalars of the input vtkImageData into a + * four-component unsigned char array, using the lookup table for the color and + * the piecewise function for the alpha channel. The output vtkImageData keeps + * the extent, spacing, origin and direction of the input. + */ +export declare const vtkScalarToRGBA: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkScalarToRGBA; diff --git a/Sources/Filters/General/ShrinkPolyData/index.d.ts b/Sources/Filters/General/ShrinkPolyData/index.d.ts index 9f239154885..9a1eb54bf49 100644 --- a/Sources/Filters/General/ShrinkPolyData/index.d.ts +++ b/Sources/Filters/General/ShrinkPolyData/index.d.ts @@ -1,6 +1,5 @@ -import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes'; +import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes/Constants'; import { vtkAlgorithm, vtkObject } from '../../../interfaces'; -import { Vector3 } from '../../../types'; /** * @@ -28,22 +27,7 @@ export interface vtkShrinkPolyData extends vtkShrinkPolyDataBase { * Set the shrink factor. * @param {Number} shrinkFactor */ - setShrinkFactor(shrinkFactor: number): boolean; - - /** - * Shrink two points towards their midpoint by a shrink factor. - * @param {Vector3} p1 - The [x, y, z] coordinates of the first point - * @param {Vector3} p2 - The [x, y, z] coordinates of the second point - * @param {number} shrinkFactor - The shrink factor (0.0 to 1.0) - * @param {Number[]} [shrunkPoints] - Optional array to store the shrunk points - * @returns {Number[]} Array containing the two new points - */ - shrinkLine( - p1: Vector3, - p2: Vector3, - shrinkFactor: number, - shrunkPoints?: number[] - ): number[]; + setShrinkFactor(shrinkFactor: number): void; } /** diff --git a/Sources/Filters/General/TransformPolyDataFilter/index.d.ts b/Sources/Filters/General/TransformPolyDataFilter/index.d.ts index 40d85c0a0b4..7d145beccb4 100644 --- a/Sources/Filters/General/TransformPolyDataFilter/index.d.ts +++ b/Sources/Filters/General/TransformPolyDataFilter/index.d.ts @@ -1,6 +1,7 @@ -import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes'; +import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes/Constants'; import vtkTransform from '../../../Common/Transform/Transform'; import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; export interface ITransformPolyDataFilterInitialValues { transform?: vtkTransform; @@ -13,7 +14,7 @@ export interface vtkTransformPolyDataFilter extends vtkTransformPolyDataFilterBa /** * Get the transform used by this filter. */ - getTransform(): vtkTransform; + getTransform(): Nullable; /** * Get the output points precision. diff --git a/Sources/Filters/General/TubeFilter/Constants.d.ts b/Sources/Filters/General/TubeFilter/Constants.d.ts new file mode 100644 index 00000000000..7393a6b539e --- /dev/null +++ b/Sources/Filters/General/TubeFilter/Constants.d.ts @@ -0,0 +1,24 @@ +export declare const VaryRadius: { + readonly VARY_RADIUS_OFF: 0; + readonly VARY_RADIUS_BY_SCALAR: 1; + readonly VARY_RADIUS_BY_VECTOR: 2; + readonly VARY_RADIUS_BY_ABSOLUTE_SCALAR: 3; +}; + +export type VaryRadius = (typeof VaryRadius)[keyof typeof VaryRadius]; + +export declare const GenerateTCoords: { + readonly TCOORDS_OFF: 0; + readonly TCOORDS_FROM_NORMALIZED_LENGTH: 1; + readonly TCOORDS_FROM_LENGTH: 2; + readonly TCOORDS_FROM_SCALARS: 3; +}; + +export type GenerateTCoords = + (typeof GenerateTCoords)[keyof typeof GenerateTCoords]; + +declare const _default: { + VaryRadius: typeof VaryRadius; + GenerateTCoords: typeof GenerateTCoords; +}; +export default _default; diff --git a/Sources/Filters/General/TubeFilter/index.d.ts b/Sources/Filters/General/TubeFilter/index.d.ts index f29a951fe55..e0caa9edbe8 100755 --- a/Sources/Filters/General/TubeFilter/index.d.ts +++ b/Sources/Filters/General/TubeFilter/index.d.ts @@ -1,19 +1,11 @@ import { vtkAlgorithm, vtkObject } from '../../../interfaces'; -import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes'; +import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes/Constants'; +import { VaryRadius, GenerateTCoords } from './Constants'; -export enum VaryRadius { - VARY_RADIUS_OFF, - VARY_RADIUS_BY_SCALAR, - VARY_RADIUS_BY_VECTOR, - VARY_RADIUS_BY_ABSOLUTE_SCALAR, -} - -export enum GenerateTCoords { - TCOORDS_OFF, - TCOORDS_FROM_NORMALIZED_LENGTH, - TCOORDS_FROM_LENGTH, - TCOORDS_FROM_SCALARS, -} +/** + * The type is public; the value is reached through the Constants module. + */ +export type { VaryRadius, GenerateTCoords }; /** * diff --git a/Sources/Filters/General/WarpScalar/index.d.ts b/Sources/Filters/General/WarpScalar/index.d.ts new file mode 100644 index 00000000000..a7a9a04bb85 --- /dev/null +++ b/Sources/Filters/General/WarpScalar/index.d.ts @@ -0,0 +1,123 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Vector3 } from '../../../types'; + +/** + * + */ +export interface IWarpScalarInitialValues { + scaleFactor?: number; + useNormal?: boolean; + normal?: Vector3; + xyPlane?: boolean; +} + +type vtkWarpScalarBase = vtkObject & vtkAlgorithm; + +export interface vtkWarpScalar extends vtkWarpScalarBase { + /** + * Get the normal used when the input has no normals, or when useNormal is on. + */ + getNormal(): Vector3; + + /** + * Get the normal used when the input has no normals, or when useNormal is on. + */ + getNormalByReference(): Vector3; + + /** + * Get the amount by which the points are displaced along the normal. + */ + getScaleFactor(): number; + + /** + * Get whether the instance normal is used in place of the input normals. + */ + getUseNormal(): boolean; + + /** + * Get whether the z coordinate is used as the scalar to warp by. + */ + getXyPlane(): boolean; + + /** + * + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): number; + + /** + * Set the normal used when the input has no normals, or when useNormal is on. + * @param {Vector3} normal + */ + setNormal(normal: Vector3): boolean; + + /** + * Set the normal used when the input has no normals, or when useNormal is on. + * @param {Number} x + * @param {Number} y + * @param {Number} z + */ + setNormal(x: number, y: number, z: number): boolean; + + /** + * Set the normal used when the input has no normals, or when useNormal is on. + * @param {Vector3} normal + */ + setNormalFrom(normal: Vector3): void; + + /** + * Set the amount by which the points are displaced along the normal. + * @param {Number} scaleFactor + */ + setScaleFactor(scaleFactor: number): boolean; + + /** + * Set whether the instance normal is used in place of the input normals. + * @param {Boolean} useNormal + */ + setUseNormal(useNormal: boolean): boolean; + + /** + * Set whether the z coordinate is used as the scalar to warp by, in which + * case the points are displaced along the z axis. + * @param {Boolean} xyPlane + */ + setXyPlane(xyPlane: boolean): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWarpScalar characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWarpScalarInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWarpScalarInitialValues +): void; + +/** + * Method used to create a new instance of vtkWarpScalar + * @param {IWarpScalarInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWarpScalarInitialValues +): vtkWarpScalar; + +/** + * vtkWarpScalar - deform a dataset along its normals by its scalars + * + * vtkWarpScalar displaces every point of its input along a normal by a distance + * equal to the point scalar times the scale factor. The normal is taken from + * the input point normals, from the instance normal, or from the z axis when + * xyPlane is on. The scalars are read from the array selected with + * setInputArrayToProcess. + */ +export declare const vtkWarpScalar: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWarpScalar; diff --git a/Sources/Filters/General/WindowedSincPolyDataFilter/index.d.ts b/Sources/Filters/General/WindowedSincPolyDataFilter/index.d.ts new file mode 100644 index 00000000000..610b01a486d --- /dev/null +++ b/Sources/Filters/General/WindowedSincPolyDataFilter/index.d.ts @@ -0,0 +1,205 @@ +import vtkPoints from '../../../Common/Core/Points'; +import vtkPolyData from '../../../Common/DataModel/PolyData'; +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; + +/** + * + */ +export interface IWindowedSincPolyDataFilterInitialValues { + numberOfIterations?: number; + passBand?: number; + featureAngle?: number; + edgeAngle?: number; + featureEdgeSmoothing?: number; + boundarySmoothing?: number; + nonManifoldSmoothing?: number; + generateErrorScalars?: number; + generateErrorVectors?: number; + normalizeCoordinates?: number; +} + +type vtkWindowedSincPolyDataFilterBase = vtkObject & vtkAlgorithm; + +export interface vtkWindowedSincPolyDataFilter extends vtkWindowedSincPolyDataFilterBase { + /** + * Get whether points on the boundary of the mesh are smoothed. + */ + getBoundarySmoothing(): number; + + /** + * Get the angle, in degrees, above which an edge between two adjacent + * boundary or feature edges is considered sharp and its vertex is fixed. + */ + getEdgeAngle(): number; + + /** + * Get the angle, in degrees, above which the edge between two adjacent + * polygons is a feature edge. + */ + getFeatureAngle(): number; + + /** + * Get whether feature edges are smoothed. + */ + getFeatureEdgeSmoothing(): number; + + /** + * Get whether a scalar array holding the distance each point moved is added + * to the output. + */ + getGenerateErrorScalars(): number; + + /** + * Get whether a vector array holding the displacement of each point is added + * to the output. + */ + getGenerateErrorVectors(): number; + + /** + * Get whether the coordinates are normalized to the unit cube before + * smoothing and restored afterwards. + */ + getNormalizeCoordinates(): number; + + /** + * Get whether non-manifold vertices are smoothed. + */ + getNonManifoldSmoothing(): number; + + /** + * Get the degree of the Chebyshev polynomial approximating the filter. + */ + getNumberOfIterations(): number; + + /** + * Get the pass band of the windowed sinc filter, in [0, 2]. + */ + getPassBand(): number; + + /** + * + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; + + /** + * Set whether points on the boundary of the mesh are smoothed. + * @param {Number} boundarySmoothing + */ + setBoundarySmoothing(boundarySmoothing: number): boolean; + + /** + * Set the angle, in degrees, above which an edge between two adjacent + * boundary or feature edges is considered sharp and its vertex is fixed. + * @param {Number} edgeAngle + */ + setEdgeAngle(edgeAngle: number): boolean; + + /** + * Set the angle, in degrees, above which the edge between two adjacent + * polygons is a feature edge. + * @param {Number} featureAngle + */ + setFeatureAngle(featureAngle: number): boolean; + + /** + * Set whether feature edges are smoothed. + * @param {Number} featureEdgeSmoothing + */ + setFeatureEdgeSmoothing(featureEdgeSmoothing: number): boolean; + + /** + * Set whether a scalar array holding the distance each point moved is added + * to the output. + * @param {Number} generateErrorScalars + */ + setGenerateErrorScalars(generateErrorScalars: number): boolean; + + /** + * Set whether a vector array holding the displacement of each point is added + * to the output. + * @param {Number} generateErrorVectors + */ + setGenerateErrorVectors(generateErrorVectors: number): boolean; + + /** + * Set whether the coordinates are normalized to the unit cube before + * smoothing and restored afterwards. + * @param {Number} normalizeCoordinates + */ + setNormalizeCoordinates(normalizeCoordinates: number): boolean; + + /** + * Set whether non-manifold vertices are smoothed. + * @param {Number} nonManifoldSmoothing + */ + setNonManifoldSmoothing(nonManifoldSmoothing: number): boolean; + + /** + * Set the degree of the Chebyshev polynomial approximating the filter. + * @param {Number} numberOfIterations + */ + setNumberOfIterations(numberOfIterations: number): boolean; + + /** + * Set the pass band of the windowed sinc filter, in [0, 2]. + * @param {Number} passBand + */ + setPassBand(passBand: number): boolean; + + /** + * Smooth `inPts` using the topology of `inputPolyData` and return the new + * point set. The error scalars and vectors, when requested, are added to + * `output`. Returns `inPts` unchanged when there is nothing to smooth. + * @param {vtkPoints} inPts + * @param {vtkPolyData} inputPolyData + * @param {vtkPolyData} output + */ + vtkWindowedSincPolyDataFilterExecute( + inPts: Nullable, + inputPolyData: vtkPolyData, + output: vtkPolyData + ): Nullable; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWindowedSincPolyDataFilter characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWindowedSincPolyDataFilterInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWindowedSincPolyDataFilterInitialValues +): void; + +/** + * Method used to create a new instance of vtkWindowedSincPolyDataFilter + * @param {IWindowedSincPolyDataFilterInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWindowedSincPolyDataFilterInitialValues +): vtkWindowedSincPolyDataFilter; + +/** + * vtkWindowedSincPolyDataFilter - adjust point positions using a windowed sinc + * function interpolation kernel + * + * vtkWindowedSincPolyDataFilter adjusts point coordinates using a windowed sinc + * function interpolation kernel. The effect is to "relax" the mesh, making the + * cells better shaped and the vertices more evenly distributed. Note that this + * filter operates on the lines, polygons, and triangle strips composing an + * instance of vtkPolyData. Vertex or poly-vertex cells are never modified. + * + * The algorithm is described in "Optimal Surface Smoothing as Filter Design", + * G. Taubin, T. Zhang and G. Golub, IBM tech report RC-20404. + */ +export declare const vtkWindowedSincPolyDataFilter: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWindowedSincPolyDataFilter; diff --git a/Sources/Filters/Imaging/ImageAppendComponents/index.d.ts b/Sources/Filters/Imaging/ImageAppendComponents/index.d.ts index fda1ca5d3af..23ed881b0a6 100644 --- a/Sources/Filters/Imaging/ImageAppendComponents/index.d.ts +++ b/Sources/Filters/Imaging/ImageAppendComponents/index.d.ts @@ -23,7 +23,7 @@ export interface vtkImageAppendComponents extends vtkImageAppendComponentsBase { * @param model object on which data structure will be bounds (protected) * @param {IImageAppendComponentsInitialValues} [initialValues] (default: {}) */ -export function extend( +declare function extend( publicAPI: object, model: object, initialValues?: IImageAppendComponentsInitialValues diff --git a/Sources/Filters/Modeling/RibbonFilter/index.d.ts b/Sources/Filters/Modeling/RibbonFilter/index.d.ts index c3f51095402..314de221027 100644 --- a/Sources/Filters/Modeling/RibbonFilter/index.d.ts +++ b/Sources/Filters/Modeling/RibbonFilter/index.d.ts @@ -1,6 +1,18 @@ import { vtkAlgorithm, vtkObject } from '../../../interfaces'; import { Vector3 } from '../../../types'; +declare enum GenerateTCoords { + TCOORDS_OFF, + TCOORDS_FROM_SCALARS, + TCOORDS_FROM_LENGTH, + TCOORDS_FROM_NORMALIZED_LENGTH, +} + +/** + * The type is public; the value is reached through the module default export. + */ +export type { GenerateTCoords }; + export type IGenerateTCoords = | 'TCOORDS_OFF' | 'TCOORDS_FROM_SCALARS' @@ -107,9 +119,8 @@ export interface vtkRibbonFilter extends vtkRibbonFilterBase { * Set the default normal used to orient the ribbon when no normals are provided in the input. * The default normal is a vector defined by three components (x,y,z). The * default is (0,0,1). - * @returns true if the default normal is set successfully. */ - setDefaultNormalFrom(defaultNormal: Vector3): boolean; + setDefaultNormalFrom(defaultNormal: Vector3): void; /** * Set the method used to generate texture coordinates. By default, texture @@ -192,5 +203,6 @@ export function newInstance( export declare const vtkRibbonFilter: { newInstance: typeof newInstance; extend: typeof extend; + GenerateTCoords: typeof GenerateTCoords; }; export default vtkRibbonFilter; diff --git a/Sources/Filters/Sources/ArcSource/index.d.ts b/Sources/Filters/Sources/ArcSource/index.d.ts index d57c905acd4..8c67cab8d77 100644 --- a/Sources/Filters/Sources/ArcSource/index.d.ts +++ b/Sources/Filters/Sources/ArcSource/index.d.ts @@ -1,4 +1,4 @@ -import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes'; +import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes/Constants'; import { vtkAlgorithm, vtkObject } from '../../../interfaces'; import { Vector3 } from '../../../types'; @@ -122,7 +122,7 @@ export interface vtkArcSource extends vtkArcSourceBase { * Set the first point of the arc by reference. * @param {Vector3} point1 The first point's coordinates. */ - setPoint1From(point1: Vector3): boolean; + setPoint1From(point1: Vector3): void; /** * Set the second point of the arc. @@ -134,7 +134,7 @@ export interface vtkArcSource extends vtkArcSourceBase { * Set the second point of the arc by reference. * @param {Vector3} point2 The second point's coordinates. */ - setPoint2From(point2: Vector3): boolean; + setPoint2From(point2: Vector3): void; /** * Set the center of the arc. @@ -146,7 +146,7 @@ export interface vtkArcSource extends vtkArcSourceBase { * Set the center of the arc by reference. * @param {Vector3} center The center point's coordinates. */ - setCenterFrom(center: Vector3): boolean; + setCenterFrom(center: Vector3): void; /** * Set the normal vector of the arc. @@ -158,7 +158,7 @@ export interface vtkArcSource extends vtkArcSourceBase { * Set the normal vector of the arc by reference. * @param {Vector3} normal The normal vector's coordinates. */ - setNormalFrom(normal: Vector3): boolean; + setNormalFrom(normal: Vector3): void; /** * Set the polar vector of the arc. @@ -170,7 +170,7 @@ export interface vtkArcSource extends vtkArcSourceBase { * Set the polar vector of the arc by reference. * @param {Vector3} polarVector The polar vector's coordinates. */ - setPolarVectorFrom(polarVector: Vector3): boolean; + setPolarVectorFrom(polarVector: Vector3): void; /** * Set the angle of the arc. diff --git a/Sources/Filters/Sources/ArmatureSource/index.d.ts b/Sources/Filters/Sources/ArmatureSource/index.d.ts index 44a97c2e72a..89350e9a33b 100644 --- a/Sources/Filters/Sources/ArmatureSource/index.d.ts +++ b/Sources/Filters/Sources/ArmatureSource/index.d.ts @@ -79,6 +79,11 @@ export interface vtkArmatureSource extends vtkArmatureSourceBase { * Get the intended joint radius. Default 0.15. */ getJointRadius(): number; + + /** + * Generate the joint points and bone links from the skeleton's world matrices. + */ + requestData(inData: any, outData: any): void; } export interface IvtkArmatureSourceInitialValues extends IArmatureSourceInitialValues {} diff --git a/Sources/Filters/Sources/Arrow2DSource/Constants.d.ts b/Sources/Filters/Sources/Arrow2DSource/Constants.d.ts new file mode 100644 index 00000000000..483043b6952 --- /dev/null +++ b/Sources/Filters/Sources/Arrow2DSource/Constants.d.ts @@ -0,0 +1,13 @@ +export declare const ShapeType: { + readonly TRIANGLE: 'triangle'; + readonly STAR: 'star'; + readonly ARROW_4: 'arrow4points'; + readonly ARROW_6: 'arrow6points'; +}; + +export type ShapeType = (typeof ShapeType)[keyof typeof ShapeType]; + +declare const _default: { + ShapeType: typeof ShapeType; +}; +export default _default; diff --git a/Sources/Filters/Sources/Arrow2DSource/index.d.ts b/Sources/Filters/Sources/Arrow2DSource/index.d.ts index a2203d9d4c0..7b0092d9a78 100755 --- a/Sources/Filters/Sources/Arrow2DSource/index.d.ts +++ b/Sources/Filters/Sources/Arrow2DSource/index.d.ts @@ -1,12 +1,11 @@ import { vtkAlgorithm, vtkObject } from '../../../interfaces'; import { Vector3 } from '../../../types'; +import { ShapeType } from './Constants'; -export enum ShapeType { - TRIANGLE, - STAR, - ARROW_4, - ARROW_6, -} +/** + * The type is public; the value is reached through the Constants module. + */ +export type { ShapeType }; /** * @@ -18,7 +17,7 @@ export interface IArrow2DSourceInitialValues { thickness?: number; center?: Vector3; pointType?: string; - origin?: Vector3; + shape?: ShapeType; direction?: Vector3; } @@ -113,7 +112,17 @@ export interface vtkArrow2DSource extends vtkArrow2DSourceBase { * @param {Vector3} center The center of the cone coordinates. * @default [0, 0, 0] */ - setCenterFrom(center: Vector3): boolean; + setCenter(center: Vector3): boolean; + + /** + * Set the center of the cone. + * It is located at the middle of the axis of the cone. + * !!! warning + * This is not the center of the base of the cone! + * @param {Vector3} center The center of the cone coordinates. + * @default [0, 0, 0] + */ + setCenterFrom(center: Vector3): void; /** * Set the direction for the arrow. @@ -133,7 +142,7 @@ export interface vtkArrow2DSource extends vtkArrow2DSourceBase { * Set the direction for the arrow 2D. * @param {Vector3} direction The direction coordinates. */ - setDirectionFrom(direction: Vector3): boolean; + setDirectionFrom(direction: Vector3): void; /** * Set the height of the cone. diff --git a/Sources/Filters/Sources/ArrowSource/index.d.ts b/Sources/Filters/Sources/ArrowSource/index.d.ts index bf3c8774f7c..6d2ee08bba1 100755 --- a/Sources/Filters/Sources/ArrowSource/index.d.ts +++ b/Sources/Filters/Sources/ArrowSource/index.d.ts @@ -1,13 +1,6 @@ import { vtkAlgorithm, vtkObject } from '../../../interfaces'; import { Vector3 } from '../../../types'; -export enum ShapeType { - TRIANGLE, - STAR, - ARROW_4, - ARROW_6, -} - /** * */ @@ -106,7 +99,7 @@ export interface vtkArrowSource extends vtkArrowSourceBase { * Set the direction for the arrow. * @param {Vector3} direction The direction coordinates. */ - setDirectionFrom(direction: Vector3): boolean; + setDirectionFrom(direction: Vector3): void; /** * Inverts the arrow direction. diff --git a/Sources/Filters/Sources/CircleSource/index.d.ts b/Sources/Filters/Sources/CircleSource/index.d.ts index f711bf43f76..fab8fb07970 100755 --- a/Sources/Filters/Sources/CircleSource/index.d.ts +++ b/Sources/Filters/Sources/CircleSource/index.d.ts @@ -96,7 +96,7 @@ export interface vtkCircleSource extends vtkCircleSourceBase { * Set the direction for the circle. * @param {Vector3} direction The direction coordinates. */ - setDirectionFrom(direction: Vector3): boolean; + setDirectionFrom(direction: Vector3): void; /** * Set the center of the circle. @@ -112,7 +112,7 @@ export interface vtkCircleSource extends vtkCircleSourceBase { * @param {Vector3} center * @default [0, 0, 0] */ - setCenterFrom(center: Vector3): boolean; + setCenterFrom(center: Vector3): void; /** * diff --git a/Sources/Filters/Sources/ConcentricCylinderSource/index.d.ts b/Sources/Filters/Sources/ConcentricCylinderSource/index.d.ts new file mode 100644 index 00000000000..0e4142f3eb1 --- /dev/null +++ b/Sources/Filters/Sources/ConcentricCylinderSource/index.d.ts @@ -0,0 +1,281 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable, Vector3 } from '../../../types'; + +/** + * + */ +export interface IConcentricCylinderSourceInitialValues { + height?: number; + radius?: number[]; + cellFields?: number[]; + resolution?: number; + startTheta?: number; + endTheta?: number; + center?: Vector3; + direction?: Vector3; + skipInnerFaces?: boolean; + mask?: Nullable; + pointType?: string; +} + +type vtkConcentricCylinderSourceBase = vtkObject & + Omit< + vtkAlgorithm, + | 'getInputData' + | 'setInputData' + | 'setInputConnection' + | 'getInputConnection' + | 'addInputConnection' + | 'addInputData' + >; + +export interface vtkConcentricCylinderSource extends vtkConcentricCylinderSourceBase { + /** + * Add a new layer with the given radius. + * When no cell field is provided, the index of the new layer is used. + * @param {Number} radius + * @param {Number} [cellField] + */ + addRadius(radius: number, cellField?: number): void; + + /** + * Remove every layer along with their cell fields. + */ + clearRadius(): void; + + /** + * Get the cell field value of each layer. + * @default [1] + */ + getCellFields(): number[]; + + /** + * Get the cell field value of each layer. + */ + getCellFieldsByReference(): number[]; + + /** + * Get the center of the cylinder. + * @default [0, 0, 0] + */ + getCenter(): Vector3; + + /** + * Get the center of the cylinder. + */ + getCenterByReference(): Vector3; + + /** + * Get the orientation vector of the cylinder. + * @default [0, 0, 1] + */ + getDirection(): Vector3; + + /** + * Get the orientation vector of the cylinder. + */ + getDirectionByReference(): Vector3; + + /** + * Get the angular sector ending angle in degrees. + * @default 360 + */ + getEndTheta(): number; + + /** + * Get the height of the cylinder. + * @default 1.0 + */ + getHeight(): number; + + /** + * Get the full hidden-layer mask, or null when no mask is set. + * @default null + */ + getMaskLayer(): Nullable; + + /** + * Get whether the given layer is hidden. + * @param {Number} index + */ + getMaskLayer(index: number): boolean; + + /** + * Get the number of layers. + */ + getNumberOfRadius(): number; + + /** + * Get the radius of the given layer. + * @param {Number} [index] (default: 0) + */ + getRadius(index?: number): number; + + /** + * Get the number of facets used to represent each cylinder. + * @default 6 + */ + getResolution(): number; + + /** + * Get whether the faces shared by two visible layers are skipped. + * @default true + */ + getSkipInnerFaces(): boolean; + + /** + * Get the angular sector starting angle in degrees. + * @default 0 + */ + getStartTheta(): number; + + /** + * Clear the hidden-layer mask so that every layer is visible. + */ + removeMask(): void; + + /** + * Expose methods + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; + + /** + * Set the cell field value of the given layer. + * @param {Number} index + * @param {Number} field + */ + setCellField(index: number, field: number): void; + + /** + * Set the center of the cylinder. + * @param {Number} x The x coordinate. + * @param {Number} y The y coordinate. + * @param {Number} z The z coordinate. + */ + setCenter(x: number, y: number, z: number): boolean; + + /** + * Set the center of the cylinder. + * @param {Vector3} center + */ + setCenter(center: Vector3): boolean; + + /** + * Set the center of the cylinder. + * @param {Vector3} center + */ + setCenterFrom(center: Vector3): void; + + /** + * Set the direction for the cylinder. + * @param {Number} x The x coordinate. + * @param {Number} y The y coordinate. + * @param {Number} z The z coordinate. + */ + setDirection(x: number, y: number, z: number): boolean; + + /** + * Set the direction for the cylinder. + * @param {Vector3} direction + */ + setDirection(direction: Vector3): boolean; + + /** + * Set the direction for the cylinder. + * @param {Vector3} direction + */ + setDirectionFrom(direction: Vector3): void; + + /** + * Set the angular sector ending angle in degrees. + * @param {Number} endTheta + */ + setEndTheta(endTheta: number): boolean; + + /** + * Set the height of the cylinder. + * @param {Number} height + */ + setHeight(height: number): boolean; + + /** + * Hide or show the given layer. + * @param {Number} index + * @param {Boolean} hidden + */ + setMaskLayer(index: number, hidden: boolean): void; + + /** + * Set the radius of an already existing layer. + * @param {Number} index + * @param {Number} radius + */ + setRadius(index: number, radius: number): void; + + /** + * Set the number of facets used to represent each cylinder. + * @param {Number} resolution + */ + setResolution(resolution: number): boolean; + + /** + * Turn on/off the generation of the faces that are shared by two + * consecutive visible layers. + * @param {Boolean} skipInnerFaces + */ + setSkipInnerFaces(skipInnerFaces: boolean): boolean; + + /** + * Set the angular sector starting angle in degrees. + * @param {Number} startTheta + */ + setStartTheta(startTheta: number): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkConcentricCylinderSource characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IConcentricCylinderSourceInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IConcentricCylinderSourceInitialValues +): void; + +/** + * Method used to create a new instance of vtkConcentricCylinderSource. + * @param {IConcentricCylinderSourceInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IConcentricCylinderSourceInitialValues +): vtkConcentricCylinderSource; + +/** + * vtkConcentricCylinderSource creates a set of concentric cylinders sharing the + * same axis. Each layer is defined by its radius and can carry its own cell + * field value, which is stored in the `layer` cell array of the output + * polydata. Layers can individually be hidden with a mask, and the faces shared + * by two visible layers can be skipped. + * + * @example + * ```js + * import vtkConcentricCylinderSource from '@kitware/vtk.js/Filters/Sources/ConcentricCylinderSource'; + * + * const cylinder = vtkConcentricCylinderSource.newInstance({ + * height: 2, + * radius: [0.5, 1, 2], + * cellFields: [0, 1, 2], + * }); + * const polydata = cylinder.getOutputData(); + * ``` + */ +export declare const vtkConcentricCylinderSource: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkConcentricCylinderSource; diff --git a/Sources/Filters/Sources/ConeSource/index.d.ts b/Sources/Filters/Sources/ConeSource/index.d.ts index 758db1a00cd..9621658e287 100755 --- a/Sources/Filters/Sources/ConeSource/index.d.ts +++ b/Sources/Filters/Sources/ConeSource/index.d.ts @@ -115,7 +115,7 @@ export interface vtkConeSource extends vtkConeSourceBase { * @param {Vector3} center * @default [0, 0, 0] */ - setCenterFrom(center: Vector3): boolean; + setCenterFrom(center: Vector3): void; /** * Set the direction for the cone. @@ -144,7 +144,7 @@ export interface vtkConeSource extends vtkConeSourceBase { * @param {Vector3} direction * @default [1, 0, 0] */ - setDirectionFrom(direction: Vector3): boolean; + setDirectionFrom(direction: Vector3): void; /** * Set the height of the cone. diff --git a/Sources/Filters/Sources/CubeSource/index.d.ts b/Sources/Filters/Sources/CubeSource/index.d.ts index 4eb1dd6a2ad..4057a91e4a0 100755 --- a/Sources/Filters/Sources/CubeSource/index.d.ts +++ b/Sources/Filters/Sources/CubeSource/index.d.ts @@ -5,7 +5,7 @@ import { Bounds, Vector3 } from '../../../types'; /** * */ -export interface ICircleSourceInitialValues { +export interface ICubeSourceInitialValues { xLength?: number; yLength?: number; zLength?: number; @@ -13,6 +13,8 @@ export interface ICircleSourceInitialValues { rotations?: Vector3; pointType?: string; generate3DTextureCoordinates?: boolean; + generateFaces?: boolean; + generateLines?: boolean; } type vtkCubeSourceBase = vtkObject & @@ -29,14 +31,13 @@ type vtkCubeSourceBase = vtkObject & export interface vtkCubeSource extends vtkCubeSourceBase { /** * Get the center of the cube. - * @default [0.0, 0.0, 0.0] */ - getCenter(): Vector3; + getCenter(): Vector3 | undefined; /** * Get the center of the cube. */ - getCenterByReference(): Vector3; + getCenterByReference(): Vector3 | undefined; /** * @@ -60,19 +61,22 @@ export interface vtkCubeSource extends vtkCubeSourceBase { * Get the 4x4 transformation set to apply as a final trasformation to the output. * @param matrix */ - getMatrix(): mat4; + getMatrix(): mat4 | undefined; + + /** + * Get the 4x4 transformation set to apply as a final trasformation to the output. + */ + getMatrixByReference(): mat4 | undefined; /** * - * @default [0.0, 0.0, 0.0] */ - getRotations(): Vector3; + getRotations(): Vector3 | undefined; /** * - * @default [0.0, 0.0, 0.0] */ - getRotationsByReference(): Vector3; + getRotationsByReference(): Vector3 | undefined; /** * Get the length of the cube in the x-direction. @@ -115,13 +119,13 @@ export interface vtkCubeSource extends vtkCubeSourceBase { yMax: number, zMin: number, zMax: number - ): boolean; + ): void; /** * Convenience methods allows creation of cube by specifying bounding box. * @param {Bounds} bounds The bounds for the cube. */ - setBounds(bounds: Bounds): boolean; + setBounds(bounds: Bounds): void; /** * Set the center of the cube. @@ -137,7 +141,7 @@ export interface vtkCubeSource extends vtkCubeSourceBase { * @param center * @default [0, 0, 0] */ - setCenterFrom(center: Vector3): boolean; + setCenterFrom(center: Vector3): void; /** * @@ -165,6 +169,12 @@ export interface vtkCubeSource extends vtkCubeSourceBase { */ setMatrix(matrix: mat4): boolean; + /** + * Set a 4x4 transformation that will be applied as a final trasformation to the output. + * @param matrix + */ + setMatrixFrom(matrix: mat4): void; + /** * Float array of size 3 representing the angles, in degrees, of rotation for the cube. * @param xAngle @@ -177,7 +187,7 @@ export interface vtkCubeSource extends vtkCubeSourceBase { * * @param {Vector3} rotations */ - setRotationsFrom(rotations: Vector3): boolean; + setRotationsFrom(rotations: Vector3): void; /** * Set the length of the cube in the x-direction. @@ -203,20 +213,20 @@ export interface vtkCubeSource extends vtkCubeSourceBase { * * @param publicAPI object on which methods will be bounds (public) * @param model object on which data structure will be bounds (protected) - * @param {ICircleSourceInitialValues} [initialValues] (default: {}) + * @param {ICubeSourceInitialValues} [initialValues] (default: {}) */ export function extend( publicAPI: object, model: object, - initialValues?: ICircleSourceInitialValues + initialValues?: ICubeSourceInitialValues ): void; /** * Method used to create a new instance of vtkCubeSource. - * @param {ICircleSourceInitialValues} [initialValues] for pre-setting some of its content + * @param {ICubeSourceInitialValues} [initialValues] for pre-setting some of its content */ export function newInstance( - initialValues?: ICircleSourceInitialValues + initialValues?: ICubeSourceInitialValues ): vtkCubeSource; /** diff --git a/Sources/Filters/Sources/Cursor3D/index.d.ts b/Sources/Filters/Sources/Cursor3D/index.d.ts index 5c5c9d8e810..3289aed236a 100755 --- a/Sources/Filters/Sources/Cursor3D/index.d.ts +++ b/Sources/Filters/Sources/Cursor3D/index.d.ts @@ -135,13 +135,19 @@ export interface vtkCursor3D extends vtkCursor3DBase { * point.) * @param {Vector3} points */ - setFocalPoint(points: Vector3): boolean; + setFocalPoint(points: Vector3): void; /** * Set the boundary of the 3D cursor. * @param {Bounds} bounds The bounds of the 3D cursor. */ - setModelBounds(bounds: Bounds): boolean; + setModelBounds(bounds: Bounds): void; + + /** + * Turn on/off the wireframe bounding box. + * @param {Boolean} outline + */ + setOutline(outline: boolean): boolean; /** * Enable/disable the translation mode. @@ -156,29 +162,29 @@ export interface vtkCursor3D extends vtkCursor3DBase { * If the cursor focus moves outside the specified bounds, * the cursor will either be restrained against the nearest "wall" (Wrap=off), * or it will wrap around (Wrap=on). - * @param {Number} wrap + * @param {Boolean} wrap */ - setWrap(wrap: number): boolean; + setWrap(wrap: boolean): boolean; /** * Turn on/off the wireframe x-shadows. - * @param {Number} xLength + * @param {Boolean} xShadows */ - setXShadows(xLength: number): boolean; + setXShadows(xShadows: boolean): boolean; /** * Turn on/off the wireframe y-shadows. - * @param {Number} yLength + * @param {Boolean} yShadows */ - setYShadows(yLength: number): boolean; + setYShadows(yShadows: boolean): boolean; /** * Turn on/off the wireframe z-shadows. - * @param {Number} zLength + * @param {Boolean} zShadows */ - setZShadows(zLength: number): boolean; + setZShadows(zShadows: boolean): boolean; } /** diff --git a/Sources/Filters/Sources/CylinderSource/index.d.ts b/Sources/Filters/Sources/CylinderSource/index.d.ts index 05b5cc9e774..99eccdccdb4 100755 --- a/Sources/Filters/Sources/CylinderSource/index.d.ts +++ b/Sources/Filters/Sources/CylinderSource/index.d.ts @@ -72,10 +72,10 @@ export interface vtkCylinderSource extends vtkCylinderSourceBase { /** * Get the radius on Z axis. If not null and different from radius, * the cylinder base becomes an ellipse instead of a circle. - * @default null + * @default undefined * @see getRadius() */ - getOtherRadius(): number; + getOtherRadius(): number | undefined; /** * Get the base radius of the cylinder. @@ -117,7 +117,7 @@ export interface vtkCylinderSource extends vtkCylinderSourceBase { * @param {Vector3} center The center point's coordinates. * @default [0, 0, 0] */ - setCenterFrom(center: Vector3): boolean; + setCenterFrom(center: Vector3): void; /** * Set the direction for the cylinder. @@ -137,7 +137,7 @@ export interface vtkCylinderSource extends vtkCylinderSourceBase { * Set the direction for the cylinder. * @param {Vector3} direction The direction coordinates. */ - setDirectionFrom(direction: Vector3): boolean; + setDirectionFrom(direction: Vector3): void; /** * Set the height of the cylinder. diff --git a/Sources/Filters/Sources/DiskSource/index.d.ts b/Sources/Filters/Sources/DiskSource/index.d.ts index 1ccd0e3d551..2093ebd01e6 100644 --- a/Sources/Filters/Sources/DiskSource/index.d.ts +++ b/Sources/Filters/Sources/DiskSource/index.d.ts @@ -31,6 +31,11 @@ export interface vtkDiskSource extends vtkDiskSourceBase { */ getCenter(): Vector3; + /** + * Get the center of the disk. + */ + getCenterByReference(): Vector3; + /** * Get the circumferential resolution of the disk. */ @@ -46,6 +51,11 @@ export interface vtkDiskSource extends vtkDiskSourceBase { */ getNormal(): Vector3; + /** + * Get the normal of the disk. + */ + getNormalByReference(): Vector3; + /** * Get the outer radius of the disk. */ @@ -74,6 +84,12 @@ export interface vtkDiskSource extends vtkDiskSourceBase { */ setCenter(center: Vector3): boolean; + /** + * Set the center of the disk. + * @param {Vector3} center + */ + setCenterFrom(center: Vector3): void; + /** * Set the circumferential resolution of the disk. * @param {number} resolution @@ -92,6 +108,12 @@ export interface vtkDiskSource extends vtkDiskSourceBase { */ setNormal(normal: Vector3): boolean; + /** + * Set the normal of the disk. + * @param {Vector3} normal + */ + setNormalFrom(normal: Vector3): void; + /** * Set the outer radius of the disk. * @param {number} radius diff --git a/Sources/Filters/Sources/EllipseArcSource/index.d.ts b/Sources/Filters/Sources/EllipseArcSource/index.d.ts index ade53e1a22a..479cab15d99 100644 --- a/Sources/Filters/Sources/EllipseArcSource/index.d.ts +++ b/Sources/Filters/Sources/EllipseArcSource/index.d.ts @@ -1,4 +1,4 @@ -import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes'; +import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes/Constants'; import { vtkAlgorithm, vtkObject } from '../../../interfaces'; import { Vector3 } from '../../../types'; @@ -112,7 +112,7 @@ export interface vtkEllipseArcSource extends vtkEllipseArcSourceBase { * Set the center of the arc by reference. * @param {Vector3} center The center's coordinates. */ - setCenterFrom(center: Vector3): boolean; + setCenterFrom(center: Vector3): void; /** * Set the major radius vector of the arc. @@ -124,7 +124,7 @@ export interface vtkEllipseArcSource extends vtkEllipseArcSourceBase { * Set the major radius vector of the arc by reference. * @param {Vector3} majorRadiusVector The major radius vector's coordinates. */ - setMajorRadiusVectorFrom(majorRadiusVector: Vector3): boolean; + setMajorRadiusVectorFrom(majorRadiusVector: Vector3): void; /** * Set the normal vector of the arc. @@ -136,7 +136,7 @@ export interface vtkEllipseArcSource extends vtkEllipseArcSourceBase { * Set the normal vector of the arc by reference. * @param {Vector3} normal The normal vector's coordinates. */ - setNormalFrom(normal: Vector3): boolean; + setNormalFrom(normal: Vector3): void; /** * Set the output points precision. diff --git a/Sources/Filters/Sources/FrustumSource/index.d.ts b/Sources/Filters/Sources/FrustumSource/index.d.ts index 06e1e3066f6..69bdd91f5c3 100644 --- a/Sources/Filters/Sources/FrustumSource/index.d.ts +++ b/Sources/Filters/Sources/FrustumSource/index.d.ts @@ -1,5 +1,6 @@ -import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes'; +import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes/Constants'; import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; import vtkPlanes from '../../../Common/DataModel/Planes'; /** @@ -31,7 +32,7 @@ export interface vtkFrustumSource extends vtkFrustumSourceBase { /** * Get the planes defining the frustum. */ - getPlanes(): vtkPlanes; + getPlanes(): Nullable; /** * Get whether to show lines. diff --git a/Sources/Filters/Sources/ImageGridSource/index.d.ts b/Sources/Filters/Sources/ImageGridSource/index.d.ts new file mode 100644 index 00000000000..264140ac9d8 --- /dev/null +++ b/Sources/Filters/Sources/ImageGridSource/index.d.ts @@ -0,0 +1,316 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Extent, Matrix3x3, Vector3 } from '../../../types'; + +/** + * + */ +export interface IImageGridSourceInitialValues { + lineValue?: number; + fillValue?: number; + gridSpacing?: Vector3; + gridOrigin?: Vector3; + dataSpacing?: Vector3; + dataOrigin?: Vector3; + dataExtent?: Extent; + dataDirection?: Matrix3x3; +} + +type vtkImageGridSourceBase = vtkObject & + Omit< + vtkAlgorithm, + | 'getInputData' + | 'setInputData' + | 'setInputConnection' + | 'getInputConnection' + | 'addInputConnection' + | 'addInputData' + >; + +export interface vtkImageGridSource extends vtkImageGridSourceBase { + /** + * Get the direction matrix of the output image. + * @default [1, 0, 0, 0, 1, 0, 0, 0, 1] + */ + getDataDirection(): Matrix3x3; + + /** + * Get the direction matrix of the output image. + */ + getDataDirectionByReference(): Matrix3x3; + + /** + * Get the extent of the output image. + * @default [0, 255, 0, 255, 0, 0] + */ + getDataExtent(): Extent; + + /** + * Get the extent of the output image. + */ + getDataExtentByReference(): Extent; + + /** + * Get the origin of the output image. + * @default [0, 0, 0] + */ + getDataOrigin(): Vector3; + + /** + * Get the origin of the output image. + */ + getDataOriginByReference(): Vector3; + + /** + * Get the spacing of the output image. + * @default [1, 1, 1] + */ + getDataSpacing(): Vector3; + + /** + * Get the spacing of the output image. + */ + getDataSpacingByReference(): Vector3; + + /** + * Get the value used for the voxels that are not on a grid line. + * @default 255 + */ + getFillValue(): number; + + /** + * Get the grid origin, expressed in voxel index. + * @default [0, 0, 0] + */ + getGridOrigin(): Vector3; + + /** + * Get the grid origin, expressed in voxel index. + */ + getGridOriginByReference(): Vector3; + + /** + * Get the grid line period along each axis, expressed in voxels. + * A period of 0 disables the grid lines for that axis. + * @default [10, 10, 0] + */ + getGridSpacing(): Vector3; + + /** + * Get the grid line period along each axis, expressed in voxels. + */ + getGridSpacingByReference(): Vector3; + + /** + * Get the value used for the voxels that are on a grid line. + * @default 0 + */ + getLineValue(): number; + + /** + * Expose methods + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; + + /** + * Set the direction matrix of the output image. + * @param {Matrix3x3} dataDirection + */ + setDataDirection(dataDirection: Matrix3x3): boolean; + + /** + * Set the direction matrix of the output image. + * @param {Number} e00 + * @param {Number} e01 + * @param {Number} e02 + * @param {Number} e10 + * @param {Number} e11 + * @param {Number} e12 + * @param {Number} e20 + * @param {Number} e21 + * @param {Number} e22 + */ + setDataDirection( + e00: number, + e01: number, + e02: number, + e10: number, + e11: number, + e12: number, + e20: number, + e21: number, + e22: number + ): boolean; + + /** + * Set the direction matrix of the output image. + * @param {Matrix3x3} dataDirection + */ + setDataDirectionFrom(dataDirection: Matrix3x3): void; + + /** + * Set the extent of the output image. + * @param {Extent} dataExtent + */ + setDataExtent(dataExtent: Extent): boolean; + + /** + * Set the extent of the output image. + * @param {Number} x1 + * @param {Number} x2 + * @param {Number} y1 + * @param {Number} y2 + * @param {Number} z1 + * @param {Number} z2 + */ + setDataExtent( + x1: number, + x2: number, + y1: number, + y2: number, + z1: number, + z2: number + ): boolean; + + /** + * Set the extent of the output image. + * @param {Extent} dataExtent + */ + setDataExtentFrom(dataExtent: Extent): void; + + /** + * Set the origin of the output image. + * @param {Number} x The x coordinate. + * @param {Number} y The y coordinate. + * @param {Number} z The z coordinate. + */ + setDataOrigin(x: number, y: number, z: number): boolean; + + /** + * Set the origin of the output image. + * @param {Vector3} dataOrigin + */ + setDataOrigin(dataOrigin: Vector3): boolean; + + /** + * Set the origin of the output image. + * @param {Vector3} dataOrigin + */ + setDataOriginFrom(dataOrigin: Vector3): void; + + /** + * Set the spacing of the output image. + * @param {Number} x The x spacing. + * @param {Number} y The y spacing. + * @param {Number} z The z spacing. + */ + setDataSpacing(x: number, y: number, z: number): boolean; + + /** + * Set the spacing of the output image. + * @param {Vector3} dataSpacing + */ + setDataSpacing(dataSpacing: Vector3): boolean; + + /** + * Set the spacing of the output image. + * @param {Vector3} dataSpacing + */ + setDataSpacingFrom(dataSpacing: Vector3): void; + + /** + * Set the value used for the voxels that are not on a grid line. + * @param {Number} fillValue + */ + setFillValue(fillValue: number): boolean; + + /** + * Set the grid origin, expressed in voxel index. + * @param {Number} x The x coordinate. + * @param {Number} y The y coordinate. + * @param {Number} z The z coordinate. + */ + setGridOrigin(x: number, y: number, z: number): boolean; + + /** + * Set the grid origin, expressed in voxel index. + * @param {Vector3} gridOrigin + */ + setGridOrigin(gridOrigin: Vector3): boolean; + + /** + * Set the grid origin, expressed in voxel index. + * @param {Vector3} gridOrigin + */ + setGridOriginFrom(gridOrigin: Vector3): void; + + /** + * Set the grid line period along each axis, expressed in voxels. + * A period of 0 disables the grid lines for that axis. + * @param {Number} x The x period. + * @param {Number} y The y period. + * @param {Number} z The z period. + */ + setGridSpacing(x: number, y: number, z: number): boolean; + + /** + * Set the grid line period along each axis, expressed in voxels. + * @param {Vector3} gridSpacing + */ + setGridSpacing(gridSpacing: Vector3): boolean; + + /** + * Set the grid line period along each axis, expressed in voxels. + * @param {Vector3} gridSpacing + */ + setGridSpacingFrom(gridSpacing: Vector3): void; + + /** + * Set the value used for the voxels that are on a grid line. + * @param {Number} lineValue + */ + setLineValue(lineValue: number): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkImageGridSource characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IImageGridSourceInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IImageGridSourceInitialValues +): void; + +/** + * Method used to create a new instance of vtkImageGridSource. + * @param {IImageGridSourceInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IImageGridSourceInitialValues +): vtkImageGridSource; + +/** + * vtkImageGridSource produces an image of a grid. The voxels that fall on a + * grid line get the line value, all the others get the fill value. The grid + * line period and offset are expressed in voxels through the grid spacing and + * the grid origin, while the geometry of the produced image is controlled by + * the data extent, origin, spacing and direction. + * + * @example + * ```js + * import vtkImageGridSource from '@kitware/vtk.js/Filters/Sources/ImageGridSource'; + * + * const grid = vtkImageGridSource.newInstance({ gridSpacing: [20, 20, 0] }); + * const imageData = grid.getOutputData(); + * ``` + */ +export declare const vtkImageGridSource: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkImageGridSource; diff --git a/Sources/Filters/Sources/LineSource/index.d.ts b/Sources/Filters/Sources/LineSource/index.d.ts index ea9d34c4bf7..7c0a626c305 100755 --- a/Sources/Filters/Sources/LineSource/index.d.ts +++ b/Sources/Filters/Sources/LineSource/index.d.ts @@ -76,7 +76,7 @@ export interface vtkLineSource extends vtkLineSourceBase { * Set the starting point of the line. * @param {Vector3} point1 The starting point's coordinates. */ - setPoint1From(point1: Vector3): boolean; + setPoint1From(point1: Vector3): void; /** * Set the ending point of the line. @@ -90,7 +90,7 @@ export interface vtkLineSource extends vtkLineSourceBase { * Set the ending point of the line. * @param {Vector3} point2 The ending point's coordinates. */ - setPoint2From(point2: Vector3): boolean; + setPoint2From(point2: Vector3): void; /** * Set the number of segments used to represent the line. diff --git a/Sources/Filters/Sources/PlaneSource/index.d.ts b/Sources/Filters/Sources/PlaneSource/index.d.ts index b8cb23a05bc..0aa7912fb10 100755 --- a/Sources/Filters/Sources/PlaneSource/index.d.ts +++ b/Sources/Filters/Sources/PlaneSource/index.d.ts @@ -125,7 +125,7 @@ export interface vtkPlaneSource extends vtkPlaneSourceBase { * Set the normal of the plane. * @param {Vector3} normal The normal coordinate. */ - setNormal(normal: Vector3): boolean; + setNormal(normal: Vector3): void; /** * Set the normal of the plane. @@ -133,13 +133,7 @@ export interface vtkPlaneSource extends vtkPlaneSourceBase { * @param {Number} y The y coordinate. * @param {Number} z The z coordinate. */ - setNormal(x: number, y: number, z: number): boolean; - - /** - * Set the normal of the plane. - * @param {Vector3} normal The normal coordinate. - */ - setNormalFrom(normal: Vector3): boolean; + setNormal(x: number, y: number, z: number): void; /** * Set the origin of the plane. @@ -159,7 +153,7 @@ export interface vtkPlaneSource extends vtkPlaneSourceBase { * Set the origin of the plane. * @param {Vector3} origin The coordinate of the origin point. */ - setOriginFrom(origin: Vector3): boolean; + setOriginFrom(origin: Vector3): void; /** * Specify a point defining the first axis of the plane. @@ -167,13 +161,13 @@ export interface vtkPlaneSource extends vtkPlaneSourceBase { * @param {Number} y The y coordinate. * @param {Number} z The z coordinate. */ - setPoint1(x: number, y: number, z: number): boolean; + setPoint1(x: number, y: number, z: number): void; /** * Specify a point defining the first axis of the plane. * @param {Vector3} point1 */ - setPoint1(point1: Vector3): boolean; + setPoint1(point1: Vector3): void; /** * Specify a point defining the second axis of the plane. @@ -181,13 +175,13 @@ export interface vtkPlaneSource extends vtkPlaneSourceBase { * @param {Number} y The y coordinate. * @param {Number} z The z coordinate. */ - setPoint2(x: number, y: number, z: number): boolean; + setPoint2(x: number, y: number, z: number): void; /** * Specify a point defining the second axis of the plane. * @param {Vector3} point2 */ - setPoint2(point2: Vector3): boolean; + setPoint2(point2: Vector3): void; /** * Set the number of facets used to represent the cone. diff --git a/Sources/Filters/Sources/PlatonicSolidSource/Constants.d.ts b/Sources/Filters/Sources/PlatonicSolidSource/Constants.d.ts index 9b69e18a3d9..31204b4e16b 100644 --- a/Sources/Filters/Sources/PlatonicSolidSource/Constants.d.ts +++ b/Sources/Filters/Sources/PlatonicSolidSource/Constants.d.ts @@ -1,10 +1,12 @@ -export declare enum SolidType { - VTK_SOLID_TETRAHEDRON = 0, - VTK_SOLID_CUBE = 1, - VTK_SOLID_OCTAHEDRON = 2, - VTK_SOLID_ICOSAHEDRON = 3, - VTK_SOLID_DODECAHEDRON = 4, -} +export declare const SolidType: { + readonly VTK_SOLID_TETRAHEDRON: 0; + readonly VTK_SOLID_CUBE: 1; + readonly VTK_SOLID_OCTAHEDRON: 2; + readonly VTK_SOLID_ICOSAHEDRON: 3; + readonly VTK_SOLID_DODECAHEDRON: 4; +}; + +export type SolidType = (typeof SolidType)[keyof typeof SolidType]; declare const _default: { SolidType: typeof SolidType; diff --git a/Sources/Filters/Sources/PlatonicSolidSource/index.d.ts b/Sources/Filters/Sources/PlatonicSolidSource/index.d.ts index 393ae38e379..b965828fde7 100644 --- a/Sources/Filters/Sources/PlatonicSolidSource/index.d.ts +++ b/Sources/Filters/Sources/PlatonicSolidSource/index.d.ts @@ -1,5 +1,5 @@ import { vtkAlgorithm, vtkObject } from '../../../interfaces'; -import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes'; +import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes/Constants'; import { SolidType } from './Constants'; /** @@ -105,5 +105,6 @@ export function newInstance( export declare const vtkPlatonicSolidSource: { newInstance: typeof newInstance; extend: typeof extend; + SolidType: typeof SolidType; }; export default vtkPlatonicSolidSource; diff --git a/Sources/Filters/Sources/PointSource/index.d.ts b/Sources/Filters/Sources/PointSource/index.d.ts index c897a6008b0..876b5aea875 100755 --- a/Sources/Filters/Sources/PointSource/index.d.ts +++ b/Sources/Filters/Sources/PointSource/index.d.ts @@ -71,7 +71,7 @@ export interface vtkPointSource extends vtkPointSourceBase { * Set the center of the point cloud. * @param {Vector3} center The center point's coordinates. */ - setCenterFrom(center: Vector3): boolean; + setCenterFrom(center: Vector3): void; /** * Set the number of points to generate. diff --git a/Sources/Filters/Sources/RTAnalyticSource/index.d.ts b/Sources/Filters/Sources/RTAnalyticSource/index.d.ts new file mode 100644 index 00000000000..1fcbd3957a0 --- /dev/null +++ b/Sources/Filters/Sources/RTAnalyticSource/index.d.ts @@ -0,0 +1,296 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Extent, Matrix3x3, Vector3 } from '../../../types'; + +/** + * + */ +export interface IRTAnalyticSourceInitialValues { + offset?: number; + maximum?: number; + center?: Vector3; + frequency?: Vector3; + magnitude?: Vector3; + standardDeviation?: number; + wholeExtent?: Extent; + dataDirection?: Matrix3x3; +} + +type vtkRTAnalyticSourceBase = vtkObject & + Omit< + vtkAlgorithm, + | 'getInputData' + | 'setInputData' + | 'setInputConnection' + | 'getInputConnection' + | 'addInputConnection' + | 'addInputData' + >; + +export interface vtkRTAnalyticSource extends vtkRTAnalyticSourceBase { + /** + * Get the center of the gaussian, expressed in voxel index. + * @default [0, 0, 0] + */ + getCenter(): Vector3; + + /** + * Get the center of the gaussian, expressed in voxel index. + */ + getCenterByReference(): Vector3; + + /** + * Get the direction matrix of the output image. + * @default [1, 0, 0, 0, 1, 0, 0, 0, 1] + */ + getDataDirection(): Matrix3x3; + + /** + * Get the direction matrix of the output image. + */ + getDataDirectionByReference(): Matrix3x3; + + /** + * Get the natural frequency of the sinusoid along each axis. + * @default [60, 30, 40] + */ + getFrequency(): Vector3; + + /** + * Get the natural frequency of the sinusoid along each axis. + */ + getFrequencyByReference(): Vector3; + + /** + * Get the amplitude of the sinusoid along each axis. + * @default [10, 18, 5] + */ + getMagnitude(): Vector3; + + /** + * Get the amplitude of the sinusoid along each axis. + */ + getMagnitudeByReference(): Vector3; + + /** + * Get the maximum value of the gaussian. + * @default 120 + */ + getMaximum(): number; + + /** + * Get the constant value added to every voxel. + * @default 40 + */ + getOffset(): number; + + /** + * Get the standard deviation of the gaussian. + * @default 0.5 + */ + getStandardDeviation(): number; + + /** + * Get the extent of the output image. + * @default [-10, 10, -10, 10, -10, 10] + */ + getWholeExtent(): Extent; + + /** + * Get the extent of the output image. + */ + getWholeExtentByReference(): Extent; + + /** + * Expose methods + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; + + /** + * Set the center of the gaussian, expressed in voxel index. + * @param {Number} x The x coordinate. + * @param {Number} y The y coordinate. + * @param {Number} z The z coordinate. + */ + setCenter(x: number, y: number, z: number): boolean; + + /** + * Set the center of the gaussian, expressed in voxel index. + * @param {Vector3} center + */ + setCenter(center: Vector3): boolean; + + /** + * Set the center of the gaussian, expressed in voxel index. + * @param {Vector3} center + */ + setCenterFrom(center: Vector3): void; + + /** + * Set the direction matrix of the output image. + * @param {Matrix3x3} dataDirection + */ + setDataDirection(dataDirection: Matrix3x3): boolean; + + /** + * Set the direction matrix of the output image. + * @param {Number} e00 + * @param {Number} e01 + * @param {Number} e02 + * @param {Number} e10 + * @param {Number} e11 + * @param {Number} e12 + * @param {Number} e20 + * @param {Number} e21 + * @param {Number} e22 + */ + setDataDirection( + e00: number, + e01: number, + e02: number, + e10: number, + e11: number, + e12: number, + e20: number, + e21: number, + e22: number + ): boolean; + + /** + * Set the direction matrix of the output image. + * @param {Matrix3x3} dataDirection + */ + setDataDirectionFrom(dataDirection: Matrix3x3): void; + + /** + * Set the natural frequency of the sinusoid along each axis. + * @param {Number} x The x frequency. + * @param {Number} y The y frequency. + * @param {Number} z The z frequency. + */ + setFrequency(x: number, y: number, z: number): boolean; + + /** + * Set the natural frequency of the sinusoid along each axis. + * @param {Vector3} frequency + */ + setFrequency(frequency: Vector3): boolean; + + /** + * Set the natural frequency of the sinusoid along each axis. + * @param {Vector3} frequency + */ + setFrequencyFrom(frequency: Vector3): void; + + /** + * Set the amplitude of the sinusoid along each axis. + * @param {Number} x The x magnitude. + * @param {Number} y The y magnitude. + * @param {Number} z The z magnitude. + */ + setMagnitude(x: number, y: number, z: number): boolean; + + /** + * Set the amplitude of the sinusoid along each axis. + * @param {Vector3} magnitude + */ + setMagnitude(magnitude: Vector3): boolean; + + /** + * Set the amplitude of the sinusoid along each axis. + * @param {Vector3} magnitude + */ + setMagnitudeFrom(magnitude: Vector3): void; + + /** + * Set the maximum value of the gaussian. + * @param {Number} maximum + */ + setMaximum(maximum: number): boolean; + + /** + * Set the constant value added to every voxel. + * @param {Number} offset + */ + setOffset(offset: number): boolean; + + /** + * Set the standard deviation of the gaussian. + * @param {Number} standardDeviation + */ + setStandardDeviation(standardDeviation: number): boolean; + + /** + * Set the extent of the output image. + * @param {Extent} wholeExtent + */ + setWholeExtent(wholeExtent: Extent): boolean; + + /** + * Set the extent of the output image. + * @param {Number} x1 + * @param {Number} x2 + * @param {Number} y1 + * @param {Number} y2 + * @param {Number} z1 + * @param {Number} z2 + */ + setWholeExtent( + x1: number, + x2: number, + y1: number, + y2: number, + z1: number, + z2: number + ): boolean; + + /** + * Set the extent of the output image. + * @param {Extent} wholeExtent + */ + setWholeExtentFrom(wholeExtent: Extent): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkRTAnalyticSource characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IRTAnalyticSourceInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IRTAnalyticSourceInitialValues +): void; + +/** + * Method used to create a new instance of vtkRTAnalyticSource. + * @param {IRTAnalyticSourceInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IRTAnalyticSourceInitialValues +): vtkRTAnalyticSource; + +/** + * vtkRTAnalyticSource creates an image for regression testing. The image is + * filled with the sum of a gaussian centered on `center` and of a sinusoid + * whose amplitude and natural frequency are given per axis, plus a constant + * offset. + * + * @example + * ```js + * import vtkRTAnalyticSource from '@kitware/vtk.js/Filters/Sources/RTAnalyticSource'; + * + * const source = vtkRTAnalyticSource.newInstance({ + * wholeExtent: [0, 63, 0, 63, 0, 63], + * }); + * const imageData = source.getOutputData(); + * ``` + */ +export declare const vtkRTAnalyticSource: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkRTAnalyticSource; diff --git a/Sources/Filters/Sources/RegularPolygonSource/index.d.ts b/Sources/Filters/Sources/RegularPolygonSource/index.d.ts index 7970fe0e8e2..358a7b8b749 100644 --- a/Sources/Filters/Sources/RegularPolygonSource/index.d.ts +++ b/Sources/Filters/Sources/RegularPolygonSource/index.d.ts @@ -1,11 +1,11 @@ import { vtkAlgorithm, vtkObject } from '../../../interfaces'; import { Vector3 } from '../../../types'; -import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes'; +import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes/Constants'; /** * */ -export interface IPlaneSourceInitialValues { +export interface IRegularPolygonSourceInitialValues { numberOfSides?: number; center?: Vector3; normal?: Vector3; @@ -95,6 +95,12 @@ export interface vtkRegularPolygonSource extends vtkRegularPolygonSourceBase { */ setCenter(center: Vector3): boolean; + /** + * Set the center of the regular polygon. + * @param {Vector3} center + */ + setCenterFrom(center: Vector3): void; + /** * Set whether to generate polygon points. * @param generatePolygon @@ -116,6 +122,12 @@ export interface vtkRegularPolygonSource extends vtkRegularPolygonSourceBase { */ setNormal(normal: Vector3): boolean; + /** + * Set the normal of the regular polygon. + * @param {Vector3} normal + */ + setNormalFrom(normal: Vector3): void; + /** * Set the number of sides for the regular polygon. * @param numberOfSides @@ -145,20 +157,20 @@ export interface vtkRegularPolygonSource extends vtkRegularPolygonSourceBase { * * @param publicAPI object on which methods will be bounds (public) * @param model object on which data structure will be bounds (protected) - * @param {IPlaneSourceInitialValues} [initialValues] (default: {}) + * @param {IRegularPolygonSourceInitialValues} [initialValues] (default: {}) */ export function extend( publicAPI: object, model: object, - initialValues?: IPlaneSourceInitialValues + initialValues?: IRegularPolygonSourceInitialValues ): void; /** * Method used to create a new instance of vtkRegularPolygonSource. - * @param {IPlaneSourceInitialValues} [initialValues] for pre-setting some of its content + * @param {IRegularPolygonSourceInitialValues} [initialValues] for pre-setting some of its content */ export function newInstance( - initialValues?: IPlaneSourceInitialValues + initialValues?: IRegularPolygonSourceInitialValues ): vtkRegularPolygonSource; /** diff --git a/Sources/Filters/Sources/SLICSource/index.d.ts b/Sources/Filters/Sources/SLICSource/index.d.ts new file mode 100644 index 00000000000..cf58dd26cd3 --- /dev/null +++ b/Sources/Filters/Sources/SLICSource/index.d.ts @@ -0,0 +1,257 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Vector3 } from '../../../types'; + +/** + * + */ +export interface ISLICSourceInitialValues { + clusters?: Float64Array[]; + spacing?: Vector3; + origin?: Vector3; + dimensions?: Vector3; + clusterArrayName?: string; + scalarArrayName?: string; +} + +type vtkSLICSourceBase = vtkObject & + Omit< + vtkAlgorithm, + | 'getInputData' + | 'setInputData' + | 'setInputConnection' + | 'getInputConnection' + | 'addInputConnection' + | 'addInputData' + >; + +export interface vtkSLICSource extends vtkSLICSourceBase { + /** + * Add a cluster centered on the given world position, whose field is the + * affine function `fnConst + fnDfDx * dx + fnDfDy * dy + fnDfDz * dz` where + * `d*` is the offset from the cluster center. + * @param {Number} centerX + * @param {Number} centerY + * @param {Number} centerZ + * @param {Number} fnConst + * @param {Number} fnDfDx + * @param {Number} fnDfDy + * @param {Number} fnDfDz + * @returns the id of the newly created cluster + */ + addCluster( + centerX: number, + centerY: number, + centerZ: number, + fnConst: number, + fnDfDx: number, + fnDfDy: number, + fnDfDz: number + ): number; + + /** + * Get the name of the output array holding the cluster index of each voxel. + * @default 'cluster' + */ + getClusterArrayName(): string; + + /** + * Get the dimensions of the output image. + * @default [10, 10, 10] + */ + getDimensions(): Vector3; + + /** + * Get the dimensions of the output image. + */ + getDimensionsByReference(): Vector3; + + /** + * Get the number of clusters. + */ + getNumberOfClusters(): number; + + /** + * Get the origin of the output image. + * @default [0, 0, 0] + */ + getOrigin(): Vector3; + + /** + * Get the origin of the output image. + */ + getOriginByReference(): Vector3; + + /** + * Get the name of the output array holding the field value of each voxel. + * @default 'field' + */ + getScalarArrayName(): string; + + /** + * Get the spacing of the output image. + * @default [1, 1, 1] + */ + getSpacing(): Vector3; + + /** + * Get the spacing of the output image. + */ + getSpacingByReference(): Vector3; + + /** + * Remove every cluster. + */ + removeAllClusters(): void; + + /** + * Remove the cluster with the given id. + * Removing a cluster shifts the ids of the following ones. + * @param {Number} id + */ + removeCluster(id: number): void; + + /** + * Expose methods + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; + + /** + * Set the name of the output array holding the cluster index of each voxel. + * @param {String} clusterArrayName + */ + setClusterArrayName(clusterArrayName: string): boolean; + + /** + * Set the dimensions of the output image. + * @param {Number} x The x dimension. + * @param {Number} y The y dimension. + * @param {Number} z The z dimension. + */ + setDimensions(x: number, y: number, z: number): boolean; + + /** + * Set the dimensions of the output image. + * @param {Vector3} dimensions + */ + setDimensions(dimensions: Vector3): boolean; + + /** + * Set the dimensions of the output image. + * @param {Vector3} dimensions + */ + setDimensionsFrom(dimensions: Vector3): void; + + /** + * Set the origin of the output image. + * @param {Number} x The x coordinate. + * @param {Number} y The y coordinate. + * @param {Number} z The z coordinate. + */ + setOrigin(x: number, y: number, z: number): boolean; + + /** + * Set the origin of the output image. + * @param {Vector3} origin + */ + setOrigin(origin: Vector3): boolean; + + /** + * Set the origin of the output image. + * @param {Vector3} origin + */ + setOriginFrom(origin: Vector3): void; + + /** + * Set the name of the output array holding the field value of each voxel. + * @param {String} scalarArrayName + */ + setScalarArrayName(scalarArrayName: string): boolean; + + /** + * Set the spacing of the output image. + * @param {Number} x The x spacing. + * @param {Number} y The y spacing. + * @param {Number} z The z spacing. + */ + setSpacing(x: number, y: number, z: number): boolean; + + /** + * Set the spacing of the output image. + * @param {Vector3} spacing + */ + setSpacing(spacing: Vector3): boolean; + + /** + * Set the spacing of the output image. + * @param {Vector3} spacing + */ + setSpacingFrom(spacing: Vector3): void; + + /** + * Replace the definition of the cluster with the given id, creating it when + * it does not exist yet. + * @param {Number} id + * @param {Number} centerX + * @param {Number} centerY + * @param {Number} centerZ + * @param {Number} fnConst + * @param {Number} fnDfDx + * @param {Number} fnDfDy + * @param {Number} fnDfDz + */ + updateCluster( + id: number, + centerX: number, + centerY: number, + centerZ: number, + fnConst: number, + fnDfDx: number, + fnDfDy: number, + fnDfDz: number + ): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkSLICSource characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ISLICSourceInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ISLICSourceInitialValues +): void; + +/** + * Method used to create a new instance of vtkSLICSource. + * @param {ISLICSourceInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: ISLICSourceInitialValues +): vtkSLICSource; + +/** + * vtkSLICSource generates a synthetic image made of Voronoi cells (clusters). + * Each voxel is assigned to its closest cluster center, and its scalar value is + * given by the affine function attached to that cluster. The output image holds + * two point arrays: the cluster index and the field value. + * + * @example + * ```js + * import vtkSLICSource from '@kitware/vtk.js/Filters/Sources/SLICSource'; + * + * const source = vtkSLICSource.newInstance({ dimensions: [20, 20, 20] }); + * source.addCluster(5, 5, 5, 1, 0, 0, 0); + * source.addCluster(15, 15, 15, 2, 0, 0, 0); + * const imageData = source.getOutputData(); + * ``` + */ +export declare const vtkSLICSource: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkSLICSource; diff --git a/Sources/Filters/Sources/SphereSource/index.d.ts b/Sources/Filters/Sources/SphereSource/index.d.ts index 1cc83d604a5..03462246d87 100755 --- a/Sources/Filters/Sources/SphereSource/index.d.ts +++ b/Sources/Filters/Sources/SphereSource/index.d.ts @@ -113,7 +113,7 @@ export interface vtkSphereSource extends vtkSphereSourceBase { * Set the center of the sphere. * @param {Vector3} center The center point's coordinates. */ - setCenterFrom(center: Vector3): boolean; + setCenterFrom(center: Vector3): void; /** * Set the ending latitude angle. diff --git a/Sources/Filters/Sources/TorusSource/index.d.ts b/Sources/Filters/Sources/TorusSource/index.d.ts new file mode 100644 index 00000000000..534efc90873 --- /dev/null +++ b/Sources/Filters/Sources/TorusSource/index.d.ts @@ -0,0 +1,199 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Vector3 } from '../../../types'; + +/** + * + */ +export interface ITorusSourceInitialValues { + radius?: number; + tubeRadius?: number; + resolution?: number; + tubeResolution?: number; + arcLength?: number; + center?: Vector3; + direction?: Vector3; + pointType?: string; +} + +type vtkTorusSourceBase = vtkObject & + Omit< + vtkAlgorithm, + | 'getInputData' + | 'setInputData' + | 'setInputConnection' + | 'getInputConnection' + | 'addInputConnection' + | 'addInputData' + >; + +export interface vtkTorusSource extends vtkTorusSourceBase { + /** + * Get the angle in radians swept by the torus around its axis. + * @default 2 * Math.PI + */ + getArcLength(): number; + + /** + * Get the center of the torus. + * @default [0, 0, 0] + */ + getCenter(): Vector3; + + /** + * Get the center of the torus. + */ + getCenterByReference(): Vector3; + + /** + * Get the orientation vector of the torus. + * @default [1.0, 0.0, 0.0] + */ + getDirection(): Vector3; + + /** + * Get the orientation vector of the torus. + */ + getDirectionByReference(): Vector3; + + /** + * Get the radius from the center of the torus to the center of the tube. + * @default 0.5 + */ + getRadius(): number; + + /** + * Get the number of subdivisions along the arc of the torus. + * @default 64 + */ + getResolution(): number; + + /** + * Get the radius of the tube. + * @default 0.01 + */ + getTubeRadius(): number; + + /** + * Get the number of subdivisions around the tube section. + * @default 64 + */ + getTubeResolution(): number; + + /** + * Expose methods + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; + + /** + * Set the angle in radians swept by the torus around its axis. + * @param {Number} arcLength + */ + setArcLength(arcLength: number): boolean; + + /** + * Set the center of the torus. + * @param {Number} x The x coordinate. + * @param {Number} y The y coordinate. + * @param {Number} z The z coordinate. + */ + setCenter(x: number, y: number, z: number): boolean; + + /** + * Set the center of the torus. + * @param {Vector3} center + */ + setCenter(center: Vector3): boolean; + + /** + * Set the center of the torus. + * @param {Vector3} center + */ + setCenterFrom(center: Vector3): void; + + /** + * Set the direction for the torus. + * @param {Number} x The x coordinate. + * @param {Number} y The y coordinate. + * @param {Number} z The z coordinate. + */ + setDirection(x: number, y: number, z: number): boolean; + + /** + * Set the direction for the torus. + * @param {Vector3} direction + */ + setDirection(direction: Vector3): boolean; + + /** + * Set the direction for the torus. + * @param {Vector3} direction + */ + setDirectionFrom(direction: Vector3): void; + + /** + * Set the radius from the center of the torus to the center of the tube. + * @param {Number} radius + */ + setRadius(radius: number): boolean; + + /** + * Set the number of subdivisions along the arc of the torus. + * @param {Number} resolution + */ + setResolution(resolution: number): boolean; + + /** + * Set the radius of the tube. + * @param {Number} tubeRadius + */ + setTubeRadius(tubeRadius: number): boolean; + + /** + * Set the number of subdivisions around the tube section. + * @param {Number} tubeResolution + */ + setTubeResolution(tubeResolution: number): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkTorusSource characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ITorusSourceInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ITorusSourceInitialValues +): void; + +/** + * Method used to create a new instance of vtkTorusSource. + * @param {ITorusSourceInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: ITorusSourceInitialValues +): vtkTorusSource; + +/** + * vtkTorusSource creates a torus centered at a specified point and whose axis + * points in a specified direction. The torus is defined by the radius from its + * center to the center of the tube, the radius of the tube itself, and the arc + * length swept around the axis, which allows partial tori to be created. + * + * @example + * ```js + * import vtkTorusSource from '@kitware/vtk.js/Filters/Sources/TorusSource'; + * + * const torus = vtkTorusSource.newInstance({ radius: 1, tubeRadius: 0.1 }); + * const polydata = torus.getOutputData(); + * ``` + */ +export declare const vtkTorusSource: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkTorusSource; diff --git a/Sources/Filters/Sources/ViewFinderSource/index.d.ts b/Sources/Filters/Sources/ViewFinderSource/index.d.ts new file mode 100644 index 00000000000..3b617e0ce00 --- /dev/null +++ b/Sources/Filters/Sources/ViewFinderSource/index.d.ts @@ -0,0 +1,174 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Vector3 } from '../../../types'; + +/** + * + */ +export interface IViewFinderSourceInitialValues { + radius?: number; + spacing?: number; + width?: number; + center?: Vector3; + orientation?: Vector3; + pointType?: string; +} + +type vtkViewFinderSourceBase = vtkObject & + Omit< + vtkAlgorithm, + | 'getInputData' + | 'setInputData' + | 'setInputConnection' + | 'getInputConnection' + | 'addInputConnection' + | 'addInputData' + >; + +export interface vtkViewFinderSource extends vtkViewFinderSourceBase { + /** + * Get the center of the view finder. + * @default [0, 0, 0] + */ + getCenter(): Vector3; + + /** + * Get the center of the view finder. + */ + getCenterByReference(): Vector3; + + /** + * Get the orientation vector of the view finder. + * @default [1, 0, 0] + */ + getOrientation(): Vector3; + + /** + * Get the orientation vector of the view finder. + */ + getOrientationByReference(): Vector3; + + /** + * Get the distance from the center at which each bar starts. + * @default 1 + */ + getRadius(): number; + + /** + * Get the length of each bar. + * @default 2 + */ + getSpacing(): number; + + /** + * Get the ratio between the radius and the half-thickness of each bar. + * A larger value produces thinner bars. + * @default 4 + */ + getWidth(): number; + + /** + * Expose methods + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; + + /** + * Set the center of the view finder. + * @param {Number} x The x coordinate. + * @param {Number} y The y coordinate. + * @param {Number} z The z coordinate. + */ + setCenter(x: number, y: number, z: number): boolean; + + /** + * Set the center of the view finder. + * @param {Vector3} center + */ + setCenter(center: Vector3): boolean; + + /** + * Set the center of the view finder. + * @param {Vector3} center + */ + setCenterFrom(center: Vector3): void; + + /** + * Set the orientation for the view finder. + * @param {Number} x The x coordinate. + * @param {Number} y The y coordinate. + * @param {Number} z The z coordinate. + */ + setOrientation(x: number, y: number, z: number): boolean; + + /** + * Set the orientation for the view finder. + * @param {Vector3} orientation + */ + setOrientation(orientation: Vector3): boolean; + + /** + * Set the orientation for the view finder. + * @param {Vector3} orientation + */ + setOrientationFrom(orientation: Vector3): void; + + /** + * Set the distance from the center at which each bar starts. + * @param {Number} radius + */ + setRadius(radius: number): boolean; + + /** + * Set the length of each bar. + * @param {Number} spacing + */ + setSpacing(spacing: number): boolean; + + /** + * Set the ratio between the radius and the half-thickness of each bar. + * @param {Number} width + */ + setWidth(width: number): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkViewFinderSource characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IViewFinderSourceInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IViewFinderSourceInitialValues +): void; + +/** + * Method used to create a new instance of vtkViewFinderSource. + * @param {IViewFinderSourceInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IViewFinderSourceInitialValues +): vtkViewFinderSource; + +/** + * vtkViewFinderSource creates a view finder: four pairs of bars laid out along + * the axes of a plane, leaving the center free so that the crosshair marks a + * position without hiding it. The bars start at `radius` from the center, are + * `spacing` long, and their thickness is derived from `radius / width`. + * + * @example + * ```js + * import vtkViewFinderSource from '@kitware/vtk.js/Filters/Sources/ViewFinderSource'; + * + * const viewFinder = vtkViewFinderSource.newInstance({ radius: 1, spacing: 2 }); + * const polydata = viewFinder.getOutputData(); + * ``` + */ +export declare const vtkViewFinderSource: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkViewFinderSource; diff --git a/Sources/Filters/Texture/TextureMapToPlane/index.d.ts b/Sources/Filters/Texture/TextureMapToPlane/index.d.ts index bcbe8587ae1..8c7da784f7c 100755 --- a/Sources/Filters/Texture/TextureMapToPlane/index.d.ts +++ b/Sources/Filters/Texture/TextureMapToPlane/index.d.ts @@ -112,7 +112,7 @@ export interface vtkTextureMapToPlane extends vtkTextureMapToPlaneBase { * Set the normal object. * @param {Number[]} normal The normal object coordinates. */ - setNormalFrom(normal: number[]): boolean; + setNormalFrom(normal: number[]): void; /** * Set the origin of the plane. @@ -132,7 +132,7 @@ export interface vtkTextureMapToPlane extends vtkTextureMapToPlaneBase { * Set the origin of the plane. * @param {Number[]} origin The origin of the plane. */ - setOriginFrom(origin: number[]): boolean; + setOriginFrom(origin: number[]): void; /** * Set the point which defines the first axis of the plane. @@ -152,7 +152,7 @@ export interface vtkTextureMapToPlane extends vtkTextureMapToPlaneBase { * Set the point which defines the first axis of the plane. * @param {Number[]} point1 The coordinate of the point. */ - setPoint1From(point1: number[]): boolean; + setPoint1From(point1: number[]): void; /** * Set the point which defines the second axis of the plane @@ -172,7 +172,7 @@ export interface vtkTextureMapToPlane extends vtkTextureMapToPlaneBase { * Set the point which defines the second axis of the plane * @param {Number[]} point2 The coordinate of the point. */ - setPoint2From(point2: number[]): boolean; + setPoint2From(point2: number[]): void; /** * Set the s-coordinate range for texture s-t coordinate pair. @@ -191,7 +191,7 @@ export interface vtkTextureMapToPlane extends vtkTextureMapToPlaneBase { * Set the s-coordinate range for texture s-t coordinate pair. * @param {Number[]} sRange The s-coordinate range. */ - setSRangeFrom(sRange: number[]): boolean; + setSRangeFrom(sRange: number[]): void; /** * Set the t-coordinate range for texture s-t coordinate pair. @@ -210,7 +210,7 @@ export interface vtkTextureMapToPlane extends vtkTextureMapToPlaneBase { * Set the t-coordinate range for texture s-t coordinate pair. * @param {Number[]} tRange The t-coordinate range. */ - setTRangeFrom(tRange: number[]): boolean; + setTRangeFrom(tRange: number[]): void; } /** diff --git a/Sources/Filters/Texture/TextureMapToSphere/index.d.ts b/Sources/Filters/Texture/TextureMapToSphere/index.d.ts index e3aa55227e3..34ca3bf9279 100755 --- a/Sources/Filters/Texture/TextureMapToSphere/index.d.ts +++ b/Sources/Filters/Texture/TextureMapToSphere/index.d.ts @@ -74,7 +74,7 @@ export interface vtkTextureMapToSphere extends vtkTextureMapToSphereBase { * Set the point defining the center of the sphere. * @param {Number[]} center The center point coordinates. */ - setCenterFrom(center: number[]): boolean; + setCenterFrom(center: number[]): void; } /** diff --git a/Sources/IO/Core/DataAccessHelper/HtmlDataAccessHelper.d.ts b/Sources/IO/Core/DataAccessHelper/HtmlDataAccessHelper.d.ts index 0b0fcb5dd99..6f0d60fee49 100644 --- a/Sources/IO/Core/DataAccessHelper/HtmlDataAccessHelper.d.ts +++ b/Sources/IO/Core/DataAccessHelper/HtmlDataAccessHelper.d.ts @@ -2,16 +2,11 @@ export interface HtmlDataAccessHelper { fetchArray( instance: any, baseURL: string, - array: object[], + array: object, options?: object - ): Promise; + ): Promise; fetchJSON(instance: any, url: string, options?: object): Promise; fetchText(instance: any, url: string, options?: object): Promise; - fetchBinary( - instance: any, - url: string, - options?: object - ): Promise; fetchImage( instance: any, url: string, diff --git a/Sources/IO/Core/DataAccessHelper/HttpDataAccessHelper.d.ts b/Sources/IO/Core/DataAccessHelper/HttpDataAccessHelper.d.ts index 4131b74b3b1..faa164c09a2 100644 --- a/Sources/IO/Core/DataAccessHelper/HttpDataAccessHelper.d.ts +++ b/Sources/IO/Core/DataAccessHelper/HttpDataAccessHelper.d.ts @@ -2,16 +2,12 @@ export interface HttpDataAccessHelper { fetchArray( instance: any, baseURL: string, - array: object[], + array: object, options?: object - ): Promise; + ): Promise; fetchJSON(instance: any, url: string, options?: object): Promise; fetchText(instance: any, url: string, options?: object): Promise; - fetchBinary( - instance: any, - url: string, - options?: object - ): Promise; + fetchBinary(url: string, options?: object): Promise; fetchImage( instance: any, url: string, diff --git a/Sources/IO/Core/DataAccessHelper/JSZipDataAccessHelper.d.ts b/Sources/IO/Core/DataAccessHelper/JSZipDataAccessHelper.d.ts index 440a0d1ea15..6e93ea9ea3b 100644 --- a/Sources/IO/Core/DataAccessHelper/JSZipDataAccessHelper.d.ts +++ b/Sources/IO/Core/DataAccessHelper/JSZipDataAccessHelper.d.ts @@ -2,9 +2,9 @@ interface IJSZipDataAccessHelper { fetchArray( instance: any, baseURL: string, - array: object[], + array: object, options?: object - ): Promise; + ): Promise; fetchJSON(instance: any, url: string, options?: object): Promise; fetchText(instance: any, url: string, options?: object): Promise; fetchBinary( diff --git a/Sources/IO/Core/DataAccessHelper/LiteHttpDataAccessHelper.d.ts b/Sources/IO/Core/DataAccessHelper/LiteHttpDataAccessHelper.d.ts index 9063c87e373..18e2aa7c3f4 100644 --- a/Sources/IO/Core/DataAccessHelper/LiteHttpDataAccessHelper.d.ts +++ b/Sources/IO/Core/DataAccessHelper/LiteHttpDataAccessHelper.d.ts @@ -2,16 +2,12 @@ export interface LiteHttpDataAccessHelper { fetchArray( instance: any, baseURL: string, - array: object[], + array: object, options?: object - ): Promise; + ): Promise; fetchJSON(instance: any, url: string, options?: object): Promise; fetchText(instance: any, url: string, options?: object): Promise; - fetchBinary( - instance: any, - url: string, - options?: object - ): Promise; + fetchBinary(url: string, options?: object): Promise; fetchImage( instance: any, url: string, diff --git a/Sources/IO/Core/HttpDataSetReader/index.d.ts b/Sources/IO/Core/HttpDataSetReader/index.d.ts index 0f65a07a2c0..1e1b39ef1d1 100644 --- a/Sources/IO/Core/HttpDataSetReader/index.d.ts +++ b/Sources/IO/Core/HttpDataSetReader/index.d.ts @@ -3,11 +3,13 @@ import { HtmlDataAccessHelper } from '../DataAccessHelper/HtmlDataAccessHelper'; import { HttpDataAccessHelper } from '../DataAccessHelper/HttpDataAccessHelper'; import { JSZipDataAccessHelper } from '../DataAccessHelper/JSZipDataAccessHelper'; import { LiteHttpDataAccessHelper } from '../DataAccessHelper/LiteHttpDataAccessHelper'; +import { Nullable } from '../../../types'; /** * */ export interface IHttpDataSetReaderInitialValues { + maxCacheSize?: number; enableArray?: boolean; fetchGzip?: boolean; arrays?: any[]; @@ -138,7 +140,7 @@ export interface vtkHttpDataSetReader extends vtkHttpDataSetReaderBase { * } * ``` */ - getBaseURL(): string; + getBaseURL(): Nullable; /** * @@ -162,7 +164,7 @@ export interface vtkHttpDataSetReader extends vtkHttpDataSetReaderBase { /** * Get the url of the object to load. */ - getUrl(): string; + getUrl(): Nullable; /** * Gets an array of all cached array ids. @@ -218,7 +220,7 @@ export interface vtkHttpDataSetReader extends vtkHttpDataSetReaderBase { /** * */ - loadData(): string; + loadData(): Promise; /** * Attach listener to monitor when the reader is downloading data or not. diff --git a/Sources/IO/Core/HttpDataSetSeriesReader/index.d.ts b/Sources/IO/Core/HttpDataSetSeriesReader/index.d.ts new file mode 100644 index 00000000000..add6d778850 --- /dev/null +++ b/Sources/IO/Core/HttpDataSetSeriesReader/index.d.ts @@ -0,0 +1,169 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable, Range } from '../../../types'; +import { HtmlDataAccessHelper } from '../DataAccessHelper/HtmlDataAccessHelper'; +import { HttpDataAccessHelper } from '../DataAccessHelper/HttpDataAccessHelper'; +import { JSZipDataAccessHelper } from '../DataAccessHelper/JSZipDataAccessHelper'; +import { LiteHttpDataAccessHelper } from '../DataAccessHelper/LiteHttpDataAccessHelper'; + +export interface IHttpDataSetSeriesReaderOptions { + fullpath?: boolean; + compression?: string; + loadData?: boolean; +} + +/** + * + */ +export interface IHttpDataSetSeriesReaderInitialValues { + fetchGzip?: boolean; + url?: string; + baseURL?: string; + dataAccessHelper?: + | HtmlDataAccessHelper + | HttpDataAccessHelper + | JSZipDataAccessHelper + | LiteHttpDataAccessHelper; +} + +type vtkHttpDataSetSeriesReaderBase = vtkObject & + Omit< + vtkAlgorithm, + | 'getInputData' + | 'setInputData' + | 'setInputConnection' + | 'getInputConnection' + | 'addInputConnection' + | 'addInputData' + >; + +export interface vtkHttpDataSetSeriesReader extends vtkHttpDataSetSeriesReaderBase { + /** + * Get the base url used to download the individual time steps. + */ + getBaseURL(): Nullable; + + /** + * Get the url of the series index to load. + */ + getUrl(): Nullable; + + /** + * Fetch the series index and create one vtkHttpDataSetReader per time step. + * Resolves with this reader once every time step has been fetched. + * @param {Boolean} [loadData] Also download the arrays (default false). + */ + updateMetaData(loadData?: boolean): Promise; + + /** + * Set the url of the series to load. The url must point at an `index.json` + * file, or at a folder containing one. + * @param {String} url the url of the series to load. + * @param {IHttpDataSetSeriesReaderOptions} [options] + */ + setUrl( + url: string, + options?: IHttpDataSetSeriesReaderOptions + ): Promise; + + /** + * Get the sorted list of time steps defined in the series. + */ + getTimeSteps(): number[]; + + /** + * Get the first and last time steps of the series, or an empty array when + * the series is empty. + */ + getTimeRange(): Range | []; + + /** + * Make the reader of the latest time step at or before the given time the + * current one, and expose its dataset as this reader's output. + * @param {Number} timeStep + */ + setUpdateTimeStep(timeStep: number): void; + + /** + * Enable or disable a given array on the current time step reader. + * @param {String} location + * @param {String} name + * @param {Boolean} [enable] (default true) + */ + enableArray(location: string, name: string, enable?: boolean): void; + + /** + * Download the enabled arrays of the current time step reader. + */ + loadData(): void; + + /** + * + * @param dataAccessHelper + */ + setDataAccessHelper( + dataAccessHelper: + | HtmlDataAccessHelper + | HttpDataAccessHelper + | JSZipDataAccessHelper + | LiteHttpDataAccessHelper + ): boolean; + + /** + * + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkHttpDataSetSeriesReader characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IHttpDataSetSeriesReaderInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IHttpDataSetSeriesReaderInitialValues +): void; + +/** + * Method used to create a new instance of vtkHttpDataSetSeriesReader + * @param {IHttpDataSetSeriesReaderInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IHttpDataSetSeriesReaderInitialValues +): vtkHttpDataSetSeriesReader; + +/** + * The vtkHttpDataSetSeriesReader is a reader which can load datasets that vary + * over time. It is a wrapper over multiple vtkHttpDataSetReader, one per time + * step, described by an `index.json` file of the following shape: + * + * ```json + * { + * "series": [ + * { "url": "0", "timeStep": 0.0 }, + * { "url": "1", "timeStep": 0.333333 } + * ] + * } + * ``` + * + * @example + * ```js + * import vtkHttpDataSetSeriesReader from '@kitware/vtk.js/IO/Core/HttpDataSetSeriesReader'; + * + * const reader = vtkHttpDataSetSeriesReader.newInstance(); + * reader.setUrl('https://kitware.github.io/vtk-js-datasets/data/temporal').then(() => { + * const [begin, end] = reader.getTimeRange(); + * reader.setUpdateTimeStep((begin + end) / 2); + * }); + * ``` + */ +export declare const vtkHttpDataSetSeriesReader: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkHttpDataSetSeriesReader; diff --git a/Sources/IO/Core/HttpSceneLoader/index.d.ts b/Sources/IO/Core/HttpSceneLoader/index.d.ts index ac3cdb1f276..b8229809d5d 100644 --- a/Sources/IO/Core/HttpSceneLoader/index.d.ts +++ b/Sources/IO/Core/HttpSceneLoader/index.d.ts @@ -1,8 +1,10 @@ -import { vtkObject } from '../../../interfaces'; +import { vtkObject, vtkSubscription } from '../../../interfaces'; +import { Nullable } from '../../../types'; import vtkAnnotatedCubeActor from '../../../Rendering/Core/AnnotatedCubeActor'; import vtkAxesActor from '../../../Rendering/Core/AxesActor'; import vtkRenderer from '../../../Rendering/Core/Renderer'; import vtkRenderWindowInteractor from '../../../Rendering/Core/RenderWindowInteractor'; +import vtkTimeStepBasedAnimationHandler from '../../../Interaction/Animations/TimeStepBasedAnimationHandler'; /** * @@ -19,18 +21,17 @@ export interface vtkHttpSceneLoader extends vtkObject { /** * */ - getAnimationHandler(): any; // vtkTimeStepBasedAnimationHandler + getAnimationHandler(): Nullable; /** * */ - getBaseURL(): string; + getBaseURL(): Nullable; /** * - * @param {Boolean} fetchGzip */ - getFetchGzip(fetchGzip: boolean): boolean; + getFetchGzip(): boolean; /** * @@ -40,7 +41,7 @@ export interface vtkHttpSceneLoader extends vtkObject { /** * */ - getRenderer(): vtkRenderer; + getRenderer(): vtkRenderer | undefined; /** * @@ -50,7 +51,7 @@ export interface vtkHttpSceneLoader extends vtkObject { /** * */ - getUrl(): string; + getUrl(): Nullable; /** * @@ -60,7 +61,7 @@ export interface vtkHttpSceneLoader extends vtkObject { /** * */ - onReady(): void; + onReady(callback: () => void, priority?: number): vtkSubscription; /** * @@ -111,14 +112,14 @@ export function newInstance( * @param sceneItem * @param settings */ -export function applySettings(sceneItem: object, settings: object): void; +declare function applySettings(sceneItem: object, settings: object): void; /** * * @param typeName * @param handler */ -export function updateDatasetTypeMapping(typeName: string, handler: any): void; +declare function updateDatasetTypeMapping(typeName: string, handler: any): void; /** * vtkHttpSceneLoader diff --git a/Sources/IO/Core/ImageStream/ViewStream.d.ts b/Sources/IO/Core/ImageStream/ViewStream.d.ts index 17e65d9de94..5b8341b8717 100644 --- a/Sources/IO/Core/ImageStream/ViewStream.d.ts +++ b/Sources/IO/Core/ImageStream/ViewStream.d.ts @@ -1,5 +1,5 @@ -import { vtkObject } from '../../../interfaces'; -import { Size } from '../../../types'; +import { vtkObject, vtkSubscription } from '../../../interfaces'; +import { Nullable, Size } from '../../../types'; import vtkCamera from '../../../Rendering/Core/Camera'; import DefaultProtocol from './DefaultProtocol'; /** @@ -36,16 +36,25 @@ interface IEvent { } export interface vtkViewStream extends vtkObject { + /** + * + * @param event + */ + invokeImageReady(event: IEvent): void; + /** * * @param callback */ - onImageReady(callback: () => void): any; + onImageReady( + callback: (event: IEvent) => void, + priority?: number + ): vtkSubscription; /** * */ - getViewId(): string; + getViewId(): Nullable; /** * @@ -60,12 +69,12 @@ export interface vtkViewStream extends vtkObject { /** * */ - getLastImageEvent(): IEvent; + getLastImageEvent(): Nullable; /** * */ - getCamera(): vtkCamera; + getCamera(): vtkCamera | undefined; /** * diff --git a/Sources/IO/Core/ImageStream/index.d.ts b/Sources/IO/Core/ImageStream/index.d.ts index 55cca8b088f..5d3e5e1063b 100644 --- a/Sources/IO/Core/ImageStream/index.d.ts +++ b/Sources/IO/Core/ImageStream/index.d.ts @@ -1,6 +1,7 @@ import { vtkObject } from '../../../interfaces'; import { Size } from '../../../types'; import vtkViewStream from './ViewStream'; +import createDefaultProtocol from './DefaultProtocol'; /** * @@ -17,7 +18,10 @@ export interface vtkImageStream extends vtkObject { /** * */ - connect(session: WebsocketSession): void; + connect( + session: WebsocketSession, + protocol?: typeof createDefaultProtocol + ): void; /** * @@ -39,7 +43,7 @@ export interface vtkImageStream extends vtkObject { /** * */ - getProtocol(): any; + getProtocol(): ReturnType; /** * @@ -49,7 +53,7 @@ export interface vtkImageStream extends vtkObject { /** * */ - registerViewStream(): void; + registerViewStream(view: vtkViewStream): void; /** * @@ -60,7 +64,7 @@ export interface vtkImageStream extends vtkObject { /** * */ - unregisterViewStream(): void; + unregisterViewStream(view: vtkViewStream): void; } /** diff --git a/Sources/IO/Core/WSLinkClient/index.d.ts b/Sources/IO/Core/WSLinkClient/index.d.ts index 708ed0c1bd6..d08f1f682d0 100644 --- a/Sources/IO/Core/WSLinkClient/index.d.ts +++ b/Sources/IO/Core/WSLinkClient/index.d.ts @@ -14,7 +14,12 @@ import vtkImageStream from '../ImageStream'; * * @param smartConnectClass */ -export function setSmartConnectClass(smartConnectClass: object): void; +declare function setSmartConnectClass(smartConnectClass: object): void; + +export interface IWSLinkClientInitialValues { + notBusyList?: string[]; + createImageStream?: boolean; +} export interface vtkWSLinkClient extends vtkObject { /** @@ -47,7 +52,7 @@ export interface vtkWSLinkClient extends vtkObject { * @param {Function} [configDecorator] (default: null) */ connect( - config: object, + config?: object, configDecorator?: (config: object) => object ): Promise; @@ -55,7 +60,7 @@ export interface vtkWSLinkClient extends vtkObject { * Disconnect from server * @param {Number} timeout amount of second to wait before the server exit as well. If we want to avoid the server from quitting, `-1` should be provided. (default=60) */ - disconnect(timeout: number): void; + disconnect(timeout?: number): void; /** * Register dynamically a protocol after being connected @@ -83,18 +88,18 @@ export interface vtkWSLinkClient extends vtkObject { /** * Get protocols that were either provided in `newInstance` or via its set */ - getProtocols(): Record; + getProtocols(): Record | undefined; /** * Update the list of methods that should be ignore from the busy state monitoring * @returns {Boolean} true if the set method modified the object */ - setNotBusyList(methodList: [string]): boolean; + setNotBusyList(methodList: string[]): boolean; /** - * @returns {object} the current set of methods to ignore from busy state + * @returns {String[]} the current set of methods to ignore from busy state */ - getNotBusyList(): object; + getNotBusyList(): string[]; /** * Should the client auto listen to image stream topic by creating its imageStream object @@ -117,7 +122,7 @@ export interface vtkWSLinkClient extends vtkObject { /** * @returns {Function} configDecorator function if any was provided */ - getConfigDecorator(): (config: object) => object; + getConfigDecorator(): ((config: object) => object) | undefined; /** * @@ -127,17 +132,17 @@ export interface vtkWSLinkClient extends vtkObject { /** * */ - getConfig(): object; + getConfig(): object | undefined; /** * */ - getRemote(): Record; + getRemote(): Record | undefined; /** * */ - getImageStream(): vtkImageStream; + getImageStream(): vtkImageStream | undefined; /** * @@ -152,13 +157,13 @@ export interface vtkWSLinkClient extends vtkObject { invokeBusyChange(): void; onConnectionReady(callback: (httpReq: any) => void): vtkSubscription; - // invokeConnectionReady(): void + invokeConnectionReady(client: vtkWSLinkClient): void; onConnectionError(callback: (httpReq: any) => void): vtkSubscription; - // invokeConnectionError(): void + invokeConnectionError(error: any): void; onConnectionClose(callback: (httpReq: any) => void): vtkSubscription; - // invokeConnectionClose(): void + invokeConnectionClose(close: any): void; } /** @@ -166,21 +171,23 @@ export interface vtkWSLinkClient extends vtkObject { * * @param publicAPI object on which methods will be bounds (public) * @param model object on which data structure will be bounds (protected) - * @param {object} [initialValues] (default: {}) + * @param {IWSLinkClientInitialValues} [initialValues] (default: {}) */ export function extend( publicAPI: object, model: object, - initialValues?: object + initialValues?: IWSLinkClientInitialValues ): void; // ---------------------------------------------------------------------------- /** * Method use to create a new instance of vtkWSLinkClient - * @param {object} [initialValues] for pre-setting some of its content + * @param {IWSLinkClientInitialValues} [initialValues] for pre-setting some of its content */ -export function newInstance(initialValues?: object): vtkWSLinkClient; +export function newInstance( + initialValues?: IWSLinkClientInitialValues +): vtkWSLinkClient; /** * vtkWSLinkClient is a WSLink client for talking to a server over WebSocket diff --git a/Sources/IO/Core/ZipMultiDataSetReader/index.d.ts b/Sources/IO/Core/ZipMultiDataSetReader/index.d.ts new file mode 100644 index 00000000000..0bbe7930bf1 --- /dev/null +++ b/Sources/IO/Core/ZipMultiDataSetReader/index.d.ts @@ -0,0 +1,129 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; +import { HtmlDataAccessHelper } from '../DataAccessHelper/HtmlDataAccessHelper'; +import { HttpDataAccessHelper } from '../DataAccessHelper/HttpDataAccessHelper'; +import { JSZipDataAccessHelper } from '../DataAccessHelper/JSZipDataAccessHelper'; +import { LiteHttpDataAccessHelper } from '../DataAccessHelper/LiteHttpDataAccessHelper'; + +export interface IZipMultiDataSetReaderOptions { + compression?: string; + progressCallback?: any; +} + +/** + * + */ +export interface IZipMultiDataSetReaderInitialValues { + url?: string; + baseURL?: string; + dataAccessHelper?: + | HtmlDataAccessHelper + | HttpDataAccessHelper + | JSZipDataAccessHelper + | LiteHttpDataAccessHelper; +} + +type vtkZipMultiDataSetReaderBase = vtkObject & + Omit< + vtkAlgorithm, + | 'getInputData' + | 'setInputData' + | 'setInputConnection' + | 'getInputConnection' + | 'addInputConnection' + | 'addInputData' + | 'getOutputData' + | 'getOutputPort' + >; + +export interface vtkZipMultiDataSetReader extends vtkZipMultiDataSetReaderBase { + /** + * + */ + getBaseURL(): Nullable; + + /** + * Get the url of the zip to load. + */ + getUrl(): Nullable; + + /** + * + */ + getDataAccessHelper(): + | HtmlDataAccessHelper + | HttpDataAccessHelper + | JSZipDataAccessHelper + | LiteHttpDataAccessHelper; + + /** + * + * @param dataAccessHelper + */ + setDataAccessHelper( + dataAccessHelper: + | HtmlDataAccessHelper + | HttpDataAccessHelper + | JSZipDataAccessHelper + | LiteHttpDataAccessHelper + ): boolean; + + /** + * Set the url of the zip to load and fetch it. + * @param {String} url the url of the zip to load. + * @param {IZipMultiDataSetReaderOptions} [option] + */ + setUrl(url: string, option?: IZipMultiDataSetReaderOptions): Promise; + + /** + * Fetch and parse the zip at the currently set url. + * @param {IZipMultiDataSetReaderOptions} [option] + */ + loadData(option?: IZipMultiDataSetReaderOptions): Promise; + + /** + * Unzip the given buffer, reading `datasets.json` and every `array_*` entry + * it contains. + * @param {ArrayBuffer} arrayBuffer The content to parse. + */ + parseAsArrayBuffer(arrayBuffer: ArrayBuffer): Promise; + + /** + * + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkZipMultiDataSetReader characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IZipMultiDataSetReaderInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IZipMultiDataSetReaderInitialValues +): void; + +/** + * Method used to create a new instance of vtkZipMultiDataSetReader + * @param {IZipMultiDataSetReaderInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IZipMultiDataSetReaderInitialValues +): vtkZipMultiDataSetReader; + +/** + * vtkZipMultiDataSetReader reads a zip archive produced by + * vtkZipMultiDataSetWriter: a `datasets.json` metadata file alongside one + * binary file per data array. + */ +export declare const vtkZipMultiDataSetReader: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkZipMultiDataSetReader; diff --git a/Sources/IO/Core/ZipMultiDataSetWriter/index.d.ts b/Sources/IO/Core/ZipMultiDataSetWriter/index.d.ts new file mode 100644 index 00000000000..276d110781f --- /dev/null +++ b/Sources/IO/Core/ZipMultiDataSetWriter/index.d.ts @@ -0,0 +1,76 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; + +/** + * + */ +export interface IZipMultiDataSetWriterInitialValues { + compressionLevel?: number; + blob?: Blob; +} + +type vtkZipMultiDataSetWriterBase = vtkObject & + Omit; + +export interface vtkZipMultiDataSetWriter extends vtkZipMultiDataSetWriterBase { + /** + * Get the zip produced by the last call to `write()`. + */ + getBlob(): Nullable; + + /** + * + */ + getCompressionLevel(): number; + + /** + * + * @param {Number} compressionLevel + */ + setCompressionLevel(compressionLevel: number): boolean; + + /** + * Serialize every input dataset then zip the result into a Blob reachable + * through `getBlob()`. + */ + write(): void; + + /** + * + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkZipMultiDataSetWriter characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IZipMultiDataSetWriterInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IZipMultiDataSetWriterInitialValues +): void; + +/** + * Method used to create a new instance of vtkZipMultiDataSetWriter + * @param {IZipMultiDataSetWriterInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IZipMultiDataSetWriterInitialValues +): vtkZipMultiDataSetWriter; + +/** + * vtkZipMultiDataSetWriter writes all of its inputs into a single zip archive + * holding a `datasets.json` metadata file alongside one binary file per data + * array. The archive is readable by vtkZipMultiDataSetReader. + */ +export declare const vtkZipMultiDataSetWriter: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkZipMultiDataSetWriter; diff --git a/Sources/IO/Geometry/DracoReader/index.d.ts b/Sources/IO/Geometry/DracoReader/index.d.ts index 14582be7e60..50884adaf47 100755 --- a/Sources/IO/Geometry/DracoReader/index.d.ts +++ b/Sources/IO/Geometry/DracoReader/index.d.ts @@ -30,7 +30,7 @@ export interface vtkDracoReader extends vtkDracoReaderBase { /** * */ - getBaseURL(): string; + getBaseURL(): string | undefined; /** * @@ -44,7 +44,7 @@ export interface vtkDracoReader extends vtkDracoReaderBase { /** * Get the url of the object to load. */ - getUrl(): string; + getUrl(): string | undefined; /** * Load the object data. @@ -54,9 +54,9 @@ export interface vtkDracoReader extends vtkDracoReaderBase { /** * Parse data. - * @param {String | ArrayBuffer} content The content to parse. + * @param {ArrayBuffer} content The content to parse. */ - parse(content: string | ArrayBuffer): void; + parse(content: ArrayBuffer): void; /** * Parse data as ArrayBuffer. @@ -65,16 +65,10 @@ export interface vtkDracoReader extends vtkDracoReaderBase { parseAsArrayBuffer(content: ArrayBuffer): void; /** - * Parse data as text. - * @param {String} content The content to parse. - */ - parseAsText(content: string): void; - /** - * - * @param inData - * @param outData + * Parse the data set through `setUrl` or `parseAsArrayBuffer` and publish it + * on the output port. */ - requestData(inData: any, outData: any): void; + requestData(): void; /** * @@ -120,20 +114,20 @@ export function newInstance( /** * Get the draco decoder */ -export function getDracoDecoder(): any; +declare function getDracoDecoder(): any; /** * Set the draco decoder * @param dracoDecoder */ -export function setDracoDecoder(dracoDecoder: any): Promise; +declare function setDracoDecoder(dracoDecoder: any): Promise; /** * Load the WASM decoder from url and set the decoderModule * @param url * @param binaryName */ -export function setWasmBinary( +declare function setWasmBinary( url: string, binaryName: string ): Promise; diff --git a/Sources/IO/Geometry/GLTFImporter/Constants.d.ts b/Sources/IO/Geometry/GLTFImporter/Constants.d.ts new file mode 100644 index 00000000000..8a6e1fd2d3e --- /dev/null +++ b/Sources/IO/Geometry/GLTFImporter/Constants.d.ts @@ -0,0 +1,99 @@ +export declare const BINARY_HEADER_MAGIC: 'glTF'; +export declare const BINARY_HEADER_LENGTH: 12; + +export declare const BINARY_CHUNK_TYPES: { + readonly JSON: 0x4e4f534a; + readonly BIN: 0x004e4942; +}; + +export type BINARY_CHUNK_TYPES = + (typeof BINARY_CHUNK_TYPES)[keyof typeof BINARY_CHUNK_TYPES]; + +export declare const BINARY_HEADER_INTS: 3; +export declare const BINARY_CHUNK_HEADER_INTS: 2; + +export declare const MIN_LIGHT_ATTENUATION: number; + +export declare const COMPONENTS: { + readonly SCALAR: 1; + readonly VEC2: 2; + readonly VEC3: 3; + readonly VEC4: 4; + readonly MAT2: 4; + readonly MAT3: 9; + readonly MAT4: 16; +}; + +export declare const BYTES: { + readonly 5120: 1; + readonly 5121: 1; + readonly 5122: 2; + readonly 5123: 2; + readonly 5125: 4; + readonly 5126: 4; +}; + +export declare const MODES: { + readonly GL_POINTS: 0; + readonly GL_LINES: 1; + readonly GL_LINE_LOOP: 2; + readonly GL_LINE_STRIP: 3; + readonly GL_TRIANGLES: 4; + readonly GL_TRIANGLE_STRIP: 5; + readonly GL_TRIANGLE_FAN: 6; +}; + +export type MODES = (typeof MODES)[keyof typeof MODES]; + +export declare const ARRAY_TYPES: { + readonly 5120: typeof Int8Array; + readonly 5121: typeof Uint8Array; + readonly 5122: typeof Int16Array; + readonly 5123: typeof Uint16Array; + readonly 5125: typeof Uint32Array; + readonly 5126: typeof Float32Array; +}; + +export declare const GL_SAMPLER: { + readonly NEAREST: 9728; + readonly LINEAR: 9729; + readonly NEAREST_MIPMAP_NEAREST: 9984; + readonly LINEAR_MIPMAP_NEAREST: 9985; + readonly NEAREST_MIPMAP_LINEAR: 9986; + readonly LINEAR_MIPMAP_LINEAR: 9987; + readonly REPEAT: 10497; + readonly CLAMP_TO_EDGE: 33071; + readonly MIRRORED_REPEAT: 33648; + readonly TEXTURE_MAG_FILTER: 10240; + readonly TEXTURE_MIN_FILTER: 10241; + readonly TEXTURE_WRAP_S: 10242; + readonly TEXTURE_WRAP_T: 10243; +}; + +export type GL_SAMPLER = (typeof GL_SAMPLER)[keyof typeof GL_SAMPLER]; + +export declare const DEFAULT_SAMPLER: { + readonly magFilter: typeof GL_SAMPLER.NEAREST; + readonly minFilter: typeof GL_SAMPLER.LINEAR_MIPMAP_LINEAR; + readonly wrapS: typeof GL_SAMPLER.REPEAT; + readonly wrapT: typeof GL_SAMPLER.REPEAT; +}; + +export declare const SEMANTIC_ATTRIBUTE_MAP: { + readonly NORMAL: 'normal'; + readonly POSITION: 'position'; + readonly TEXCOORD_0: 'texcoord0'; + readonly TEXCOORD_1: 'texcoord1'; + readonly WEIGHTS_0: 'weight'; + readonly JOINTS_0: 'joint'; + readonly COLOR_0: 'color'; + readonly TANGENT: 'tangent'; +}; + +export declare const ALPHA_MODE: { + readonly OPAQUE: 'OPAQUE'; + readonly MASK: 'MASK'; + readonly BLEND: 'BLEND'; +}; + +export type ALPHA_MODE = (typeof ALPHA_MODE)[keyof typeof ALPHA_MODE]; diff --git a/Sources/IO/Geometry/GLTFImporter/index.d.ts b/Sources/IO/Geometry/GLTFImporter/index.d.ts index f9ae739e9ef..54e2f767874 100644 --- a/Sources/IO/Geometry/GLTFImporter/index.d.ts +++ b/Sources/IO/Geometry/GLTFImporter/index.d.ts @@ -1,4 +1,4 @@ -import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { vtkObject, vtkSubscription } from '../../../interfaces'; import { HtmlDataAccessHelper } from '../../Core/DataAccessHelper/HtmlDataAccessHelper'; import { HttpDataAccessHelper } from '../../Core/DataAccessHelper/HttpDataAccessHelper'; import { JSZipDataAccessHelper } from '../../Core/DataAccessHelper/JSZipDataAccessHelper'; @@ -10,6 +10,10 @@ import { vtkCamera } from '../../../Rendering/Core/Camera'; import { vtkArmature } from '../../../Common/DataModel/Armature'; import { vtkAnimationClip } from '../../../Common/DataModel/AnimationClip'; import { vtkAnimationMixer } from '../../../Common/Core/AnimationMixer'; +import type { AnimationSource } from '../../../Common/Core/AnimationMixer'; +import type { vtkLight } from '../../../Rendering/Core/Light'; +import type { vtkProperty } from '../../../Rendering/Core/Property'; +import type { Bounds } from '../../../types'; interface IGLTFImporterOptions { binary?: boolean; @@ -25,18 +29,19 @@ export interface IGLTFMaterialVariant { /** * */ -export interface IGLTFImporterInitialValues {} - -type vtkGLTFImporterBase = vtkObject & - Omit< - vtkAlgorithm, - | 'getInputData' - | 'setInputData' - | 'setInputConnection' - | 'getInputConnection' - | 'addInputConnection' - | 'addInputData' - >; +export interface IGLTFImporterInitialValues { + /** + * The importer reads the model through this helper, and falls back to the + * http one. It has no accessor: pass it here or leave it unset. + */ + dataAccessHelper?: + | HtmlDataAccessHelper + | HttpDataAccessHelper + | JSZipDataAccessHelper + | LiteHttpDataAccessHelper; +} + +type vtkGLTFImporterBase = vtkObject; export interface vtkGLTFImporter extends vtkGLTFImporterBase { /** @@ -48,41 +53,55 @@ export interface vtkGLTFImporter extends vtkGLTFImporterBase { /** * Get the actors. */ - getActors(): Map; + getActors(): Map | undefined; /** * Get the base url. */ - getBaseURL(): string; + getBaseURL(): string | undefined; /** * Get the cameras. */ - getCameras(): Map; + getCameras(): Map | undefined; /** - * + * Get the node transforms and hierarchy parsed from the scene. */ - getDataAccessHelper(): - | HtmlDataAccessHelper - | HttpDataAccessHelper - | JSZipDataAccessHelper - | LiteHttpDataAccessHelper; + getNodeTransforms(): Map | undefined; + getNodeChildren(): Map | undefined; + + /** + * Get data used to animate morph targets, materials, and lights. + */ + getMorphTargets(): Map | undefined; + getMaterialProperties(): Map | undefined; + getNodeLights(): Map | undefined; + + /** + * Get the scenes. + */ + getScenes(): any[] | undefined; + + /** + * Get the bounds of a scene, or null when no bounds are available. + */ + getSceneBounds(sceneIndex?: number): Bounds | null; /** * Get the url of the object to load. */ - getUrl(): string; + getUrl(): string | undefined; /** * Get the variant array. */ - getVariants(): string[]; + getVariants(): string[] | undefined; /** * Get the variant mappings. */ - getVariantMappings(): Map; + getVariantMappings(): Map | undefined; /** * Import the actors. @@ -119,7 +138,7 @@ export interface vtkGLTFImporter extends vtkGLTFImporterBase { * * @param callback */ - onReady(callback: () => void): void; + onReady(callback: () => void, priority?: number): vtkSubscription; /** * Parse data. @@ -131,7 +150,7 @@ export interface vtkGLTFImporter extends vtkGLTFImporterBase { * Parse data as ArrayBuffer. * @param {ArrayBuffer} content The content to parse. */ - parseAsArrayBuffer(content: ArrayBuffer): void; + parseAsBinary(content: ArrayBuffer): Promise; /** * Parse data as text. @@ -146,18 +165,6 @@ export interface vtkGLTFImporter extends vtkGLTFImporterBase { */ requestData(inData: any, outData: any): void; - /** - * - * @param dataAccessHelper - */ - setDataAccessHelper( - dataAccessHelper: - | HtmlDataAccessHelper - | HttpDataAccessHelper - | JSZipDataAccessHelper - | LiteHttpDataAccessHelper - ): boolean; - /** * Set the url of the object to load. * @param {String} url the url of the object to load. @@ -175,7 +182,7 @@ export interface vtkGLTFImporter extends vtkGLTFImporterBase { * Set the Draco decoder. * @param dracoDecoder */ - setDracoDecoder(dracoDecoder: any): void; + setDracoDecoder(dracoDecoder: any): Promise; /** * Set the vtk Renderer. @@ -187,7 +194,7 @@ export interface vtkGLTFImporter extends vtkGLTFImporterBase { * Switch to a variant. * @param variantIndex The index of the variant to switch to. */ - switchToVariant(variantIndex: number): void; + switchToVariant(variantIndex: number): Promise; /** * Get all parsed skeletons from glTF skins @@ -228,6 +235,17 @@ export interface vtkGLTFImporter extends vtkGLTFImporterBase { */ getAnimationClipNames(): string[]; + /** + * Get animations targeting node transforms or material properties. + */ + getNodeAnimations(): AnimationSource[]; + getPointerAnimations(): AnimationSource[]; + + /** + * Release the imported scene and its graphics resources. + */ + releaseGraphicsResources(): void; + /** * Invoke the skeletonLoaded event * @param event Event data with { skeleton, gltfSkinIndex } @@ -281,16 +299,6 @@ export function newInstance( initialValues?: IGLTFImporterInitialValues ): vtkGLTFImporter; -/** - * Load the WASM decoder from url and set the decoderModule - * @param url - * @param binaryName - */ -export function setWasmBinary( - url: string, - binaryName: string -): Promise; - /** * vtkGLTFImporter can import glTF 2.0 files. * diff --git a/Sources/IO/Geometry/IFCImporter/index.d.ts b/Sources/IO/Geometry/IFCImporter/index.d.ts index f4b497d87d9..babeea5f223 100644 --- a/Sources/IO/Geometry/IFCImporter/index.d.ts +++ b/Sources/IO/Geometry/IFCImporter/index.d.ts @@ -1,4 +1,4 @@ -import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { vtkAlgorithm, vtkObject, vtkSubscription } from '../../../interfaces'; import { vtkRenderer } from '../../../Rendering/Core/Renderer'; import { HtmlDataAccessHelper } from '../../Core/DataAccessHelper/HtmlDataAccessHelper'; import { HttpDataAccessHelper } from '../../Core/DataAccessHelper/HttpDataAccessHelper'; @@ -32,7 +32,7 @@ export interface vtkIFCImporter extends vtkIFCImporterBase { /** * */ - getBaseURL(): string; + getBaseURL(): string | undefined; /** * @@ -43,10 +43,15 @@ export interface vtkIFCImporter extends vtkIFCImporterBase { | JSZipDataAccessHelper | LiteHttpDataAccessHelper; + /** + * Get whether the geometries are merged into a single actor when imported. + */ + getMergeGeometries(): boolean; + /** * Get the url of the object to load. */ - getUrl(): string; + getUrl(): string | undefined; /** * Import actors into the renderer. @@ -72,13 +77,6 @@ export interface vtkIFCImporter extends vtkIFCImporterBase { */ parseAsArrayBuffer(content: ArrayBuffer): void; - /** - * - * @param inData - * @param outData - */ - requestData(inData: any, outData: any): void; - /** * * @param dataAccessHelper @@ -91,19 +89,37 @@ export interface vtkIFCImporter extends vtkIFCImporterBase { | LiteHttpDataAccessHelper ): boolean; + /** + * Set whether the geometries are merged into a single actor when imported. + * @param {Boolean} mergeGeometries + */ + setMergeGeometries(mergeGeometries: boolean): boolean; + /** * Set the url of the object to load. * @param {String} url the url of the object to load. * @param {IIFCImporterOptions} [option] The PLY reader options. */ setUrl(url: string, option?: IIFCImporterOptions): Promise; + + /** + * + * @param {Function} cb The callback to be called. + * @param {Number} [priority] The priority of the event. + */ + onReady(cb: () => void, priority?: number): Readonly; + + /** + * + */ + invokeReady(): void; } /** * Set WebIFC api to be used by vtkIFCImporter * @param {object} ifcApi */ -export function setIFCAPI(ifcApi: any): void; +declare function setIFCAPI(ifcApi: any): void; /** * Method used to decorate a given object (publicAPI+model) with vtkIFCImporter characteristics. diff --git a/Sources/IO/Geometry/PLYReader/index.d.ts b/Sources/IO/Geometry/PLYReader/index.d.ts index 67a822d2ab3..5a8057ff915 100755 --- a/Sources/IO/Geometry/PLYReader/index.d.ts +++ b/Sources/IO/Geometry/PLYReader/index.d.ts @@ -42,7 +42,7 @@ export interface vtkPLYReader extends vtkPLYReaderBase { /** * */ - getBaseURL(): string; + getBaseURL(): string | undefined; /** * @@ -66,7 +66,7 @@ export interface vtkPLYReader extends vtkPLYReaderBase { /** * Get the url of the object to load. */ - getUrl(): string; + getUrl(): string | undefined; /** * Load the object data. diff --git a/Sources/IO/Geometry/PLYWriter/Constants.d.ts b/Sources/IO/Geometry/PLYWriter/Constants.d.ts new file mode 100644 index 00000000000..217e08ba6c7 --- /dev/null +++ b/Sources/IO/Geometry/PLYWriter/Constants.d.ts @@ -0,0 +1,24 @@ +export declare const FormatTypes: { + readonly ASCII: 'ascii'; + readonly BINARY: 'binary'; +}; + +export type FormatTypes = (typeof FormatTypes)[keyof typeof FormatTypes]; + +/** + * Choose the name used for the texture coordinates. + * (u, v) or (texture_u, texture_v) + */ +export declare const TextureCoordinatesName: { + readonly UV: [string, string]; + readonly TEXTURE_UV: [string, string]; +}; + +export type TextureCoordinatesName = + (typeof TextureCoordinatesName)[keyof typeof TextureCoordinatesName]; + +declare const _default: { + FormatTypes: typeof FormatTypes; + TextureCoordinatesName: typeof TextureCoordinatesName; +}; +export default _default; diff --git a/Sources/IO/Geometry/PLYWriter/index.d.ts b/Sources/IO/Geometry/PLYWriter/index.d.ts index d62f29add62..b5fdd461f01 100644 --- a/Sources/IO/Geometry/PLYWriter/index.d.ts +++ b/Sources/IO/Geometry/PLYWriter/index.d.ts @@ -1,21 +1,20 @@ import { mat4 } from 'gl-matrix'; import vtkPolyData from '../../../Common/DataModel/PolyData'; import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; +import { FormatTypes, TextureCoordinatesName } from './Constants'; -export enum FormatTypes { - ASCII, - BINARY, -} - -export enum TextureCoordinatesName { - UV, - TEXTURE_UV, -} +/** + * The type is public; the value is reached through the Constants module. + */ +export type { FormatTypes, TextureCoordinatesName }; /** * */ export interface IPLYWriterInitialValues { + headerComments?: string[]; + withIndices?: boolean; format?: FormatTypes; dataByteOrder?: number; comments?: string[]; @@ -54,12 +53,12 @@ export interface vtkPLYWriter extends vtkPLYWriterBase { /** * Get texture filename. */ - getTextureFileName(): string; + getTextureFileName(): Nullable; /** * Get transformation matrix. */ - getTransform(): mat4; + getTransform(): Nullable; /** * Get whether colors values are included. @@ -186,7 +185,7 @@ export function newInstance( * @param {Boolean} [withColors] Include colors. * @param {Boolean} [withIndice] Include indice. */ -export function writePLY( +declare function writePLY( polyData: vtkPolyData, format?: FormatTypes, dataByteOrder?: number, @@ -198,7 +197,7 @@ export function writePLY( withUVs?: boolean, withColors?: boolean, withIndice?: boolean -): vtkPolyData; +): DataView | string; /** * vtkPLYWriter writes polygonal data in Stanford University PLY format (see @@ -215,4 +214,7 @@ export declare const vtkPLYWriter: { extend: typeof extend; writePLY: typeof writePLY; }; +export declare const STATIC: Readonly<{ + writePLY: typeof writePLY; +}>; export default vtkPLYWriter; diff --git a/Sources/IO/Geometry/STLReader/index.d.ts b/Sources/IO/Geometry/STLReader/index.d.ts index 70217e35f2e..6c906532016 100755 --- a/Sources/IO/Geometry/STLReader/index.d.ts +++ b/Sources/IO/Geometry/STLReader/index.d.ts @@ -1,4 +1,6 @@ import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; +import vtkPointLocator from '../../../Common/DataModel/PointLocator'; import { HtmlDataAccessHelper } from '../../Core/DataAccessHelper/HtmlDataAccessHelper'; import { HttpDataAccessHelper } from '../../Core/DataAccessHelper/HttpDataAccessHelper'; import { JSZipDataAccessHelper } from '../../Core/DataAccessHelper/JSZipDataAccessHelper'; @@ -57,7 +59,7 @@ export interface vtkSTLReader extends vtkSTLReaderBase { /** * */ - getBaseURL(): string; + getBaseURL(): string | undefined; /** * @@ -71,7 +73,7 @@ export interface vtkSTLReader extends vtkSTLReaderBase { /** * Get the point locator used for vertex merging. */ - getLocator(): any; + getLocator(): Nullable; /** * Get whether point merging is enabled. @@ -81,7 +83,7 @@ export interface vtkSTLReader extends vtkSTLReaderBase { /** * Get the url of the object to load. */ - getUrl(): string; + getUrl(): string | undefined; /** * Get tolerance when removeDuplicateVertices is set @@ -134,7 +136,7 @@ export interface vtkSTLReader extends vtkSTLReaderBase { /** * Set a point locator used for vertex merging. */ - setLocator(locator: any): boolean; + setLocator(locator: Nullable): boolean; /** * Enable/disable point merging. diff --git a/Sources/IO/Geometry/STLWriter/Constants.d.ts b/Sources/IO/Geometry/STLWriter/Constants.d.ts new file mode 100644 index 00000000000..339136796a0 --- /dev/null +++ b/Sources/IO/Geometry/STLWriter/Constants.d.ts @@ -0,0 +1,11 @@ +export declare const FormatTypes: { + readonly ASCII: 'ascii'; + readonly BINARY: 'binary'; +}; + +export type FormatTypes = (typeof FormatTypes)[keyof typeof FormatTypes]; + +declare const _default: { + FormatTypes: typeof FormatTypes; +}; +export default _default; diff --git a/Sources/IO/Geometry/STLWriter/index.d.ts b/Sources/IO/Geometry/STLWriter/index.d.ts index fbd2dfebf95..93eeef2e4d3 100755 --- a/Sources/IO/Geometry/STLWriter/index.d.ts +++ b/Sources/IO/Geometry/STLWriter/index.d.ts @@ -1,16 +1,21 @@ import { mat4 } from 'gl-matrix'; import vtkPolyData from '../../../Common/DataModel/PolyData'; import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; +import { FormatTypes } from './Constants'; -export enum FormatTypes { - ASCII, - BINARY, -} +/** + * The type is public; the value is reached through the Constants module. + */ +export type { FormatTypes }; /** * */ -export interface ISTLWriterInitialValues {} +export interface ISTLWriterInitialValues { + format?: FormatTypes; + transform?: mat4; +} type vtkSTLWriterBase = vtkObject & vtkAlgorithm; @@ -23,7 +28,7 @@ export interface vtkSTLWriter extends vtkSTLWriterBase { /** * */ - getTransform(): mat4; + getTransform(): Nullable; /** * @@ -72,11 +77,11 @@ export function newInstance( * @param {FormatTypes} [format] * @param {mat4} [transform] */ -export function writeSTL( +declare function writeSTL( polyData: vtkPolyData, format?: FormatTypes, transform?: mat4 -): vtkPolyData; +): DataView | string; /** * vtkSTLWriter writes stereo lithography (.stl) files in either ASCII or binary @@ -90,4 +95,7 @@ export declare const vtkSTLWriter: { extend: typeof extend; writeSTL: typeof writeSTL; }; +export declare const STATIC: Readonly<{ + writeSTL: typeof writeSTL; +}>; export default vtkSTLWriter; diff --git a/Sources/IO/Image/HDRReader/index.d.ts b/Sources/IO/Image/HDRReader/index.d.ts index fb422d2a2e4..c03358f009a 100644 --- a/Sources/IO/Image/HDRReader/index.d.ts +++ b/Sources/IO/Image/HDRReader/index.d.ts @@ -29,7 +29,7 @@ export interface vtkHDRReader extends vtkHDRReaderBase { /** * Get the base url. */ - getBaseURL(): string; + getBaseURL(): string | undefined; /** * Get the dataAccess helper. @@ -40,10 +40,25 @@ export interface vtkHDRReader extends vtkHDRReaderBase { | JSZipDataAccessHelper | LiteHttpDataAccessHelper; + /** + * Get the exposure value parsed from the file header. + */ + getExposure(): number; + + /** + * Get the gamma value parsed from the file header. + */ + getGamma(): number; + + /** + * Get the pixel aspect ratio parsed from the file header. + */ + getPixelAspect(): number; + /** * Get the url of the object to load. */ - getUrl(): string; + getUrl(): string | undefined; /** * Load the object data. diff --git a/Sources/IO/Image/TGAReader/Constants.d.ts b/Sources/IO/Image/TGAReader/Constants.d.ts new file mode 100644 index 00000000000..65316883c0f --- /dev/null +++ b/Sources/IO/Image/TGAReader/Constants.d.ts @@ -0,0 +1,15 @@ +declare const _default: { + readonly TYPE_INDEXED: 1; + readonly TYPE_RGB: 2; + readonly TYPE_GREY: 3; + readonly TYPE_RLE_INDEXED: 9; + readonly TYPE_RLE_RGB: 10; + readonly TYPE_RLE_GREY: 11; + readonly ORIGIN_MASK: 0x30; + readonly ORIGIN_SHIFT: 0x04; + readonly ORIGIN_BL: 0x00; + readonly ORIGIN_BR: 0x01; + readonly ORIGIN_UL: 0x02; + readonly ORIGIN_UR: 0x03; +}; +export default _default; diff --git a/Sources/IO/Image/TGAReader/index.d.ts b/Sources/IO/Image/TGAReader/index.d.ts index 1ce9c0882c7..b2b1af6b00b 100644 --- a/Sources/IO/Image/TGAReader/index.d.ts +++ b/Sources/IO/Image/TGAReader/index.d.ts @@ -29,7 +29,7 @@ export interface vtkTGAReader extends vtkTGAReaderBase { /** * Get the base url. */ - getBaseURL(): string; + getBaseURL(): string | undefined; /** * Get the dataAccess helper. @@ -43,7 +43,7 @@ export interface vtkTGAReader extends vtkTGAReaderBase { /** * Get the url of the object to load. */ - getUrl(): string; + getUrl(): string | undefined; /** * Load the object data. diff --git a/Sources/IO/Image/TIFFReader/index.d.ts b/Sources/IO/Image/TIFFReader/index.d.ts index 0e731d933d1..556f9232d23 100644 --- a/Sources/IO/Image/TIFFReader/index.d.ts +++ b/Sources/IO/Image/TIFFReader/index.d.ts @@ -13,7 +13,9 @@ interface ITIFFReaderOptions { /** * */ -export interface ITIFFReaderInitialValues {} +export interface ITIFFReaderInitialValues { + flipY?: boolean; +} type vtkTIFFReaderBase = vtkObject & Omit< @@ -30,7 +32,7 @@ export interface vtkTIFFReader extends vtkTIFFReaderBase { /** * Get the base url. */ - getBaseURL(): string; + getBaseURL(): string | undefined; /** * Get if the image is flipped vertically. @@ -49,7 +51,7 @@ export interface vtkTIFFReader extends vtkTIFFReaderBase { /** * Get the url of the object to load. */ - getUrl(): string; + getUrl(): string | undefined; /** * Load the object data. diff --git a/Sources/IO/Legacy/LegacyAsciiParser/index.d.ts b/Sources/IO/Legacy/LegacyAsciiParser/index.d.ts new file mode 100644 index 00000000000..438eca6eab3 --- /dev/null +++ b/Sources/IO/Legacy/LegacyAsciiParser/index.d.ts @@ -0,0 +1,47 @@ +import vtkPolyData from '../../../Common/DataModel/PolyData'; + +/** + * Mutable state threaded through the line parsers. `parseLegacyASCII` fills it + * in and returns it; `dataset` holds the parsed geometry. + */ +export interface ILegacyAsciiDataModel { + dataset?: vtkPolyData; + + /** + * Line consumer installed by the section currently being parsed. Returns + * false once the section is complete. + */ + arrayHandler?: (line: string) => boolean; + + activeFieldLocation?: 'POINT_DATA' | 'CELL_DATA'; + + /** + * Number of points declared by the POINT_DATA section. + */ + POINT_DATA?: number; + + /** + * Number of cells declared by the CELL_DATA section. + */ + CELL_DATA?: number; +} + +/** + * Parse the content of a legacy VTK ASCII file. Only the POLYDATA dataset type + * is supported. + * + * @param {String} content The file content. + * @param {ILegacyAsciiDataModel} [dataModel] Object to fill in (default {}). + */ +declare function parseLegacyASCII( + content: string, + dataModel?: ILegacyAsciiDataModel +): ILegacyAsciiDataModel; + +/** + * vtkLegacyAsciiParser turns the text of a legacy VTK file into a vtkPolyData. + */ +declare const vtkLegacyAsciiParser: { + parseLegacyASCII: typeof parseLegacyASCII; +}; +export default vtkLegacyAsciiParser; diff --git a/Sources/IO/Legacy/PolyDataReader/index.d.ts b/Sources/IO/Legacy/PolyDataReader/index.d.ts new file mode 100644 index 00000000000..a4c6c5d7d4b --- /dev/null +++ b/Sources/IO/Legacy/PolyDataReader/index.d.ts @@ -0,0 +1,128 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; +import { HtmlDataAccessHelper } from '../../Core/DataAccessHelper/HtmlDataAccessHelper'; +import { HttpDataAccessHelper } from '../../Core/DataAccessHelper/HttpDataAccessHelper'; +import { JSZipDataAccessHelper } from '../../Core/DataAccessHelper/JSZipDataAccessHelper'; +import { LiteHttpDataAccessHelper } from '../../Core/DataAccessHelper/LiteHttpDataAccessHelper'; + +export interface IPolyDataReaderOptions { + compression?: string; + progressCallback?: any; +} + +/** + * + */ +export interface IPolyDataReaderInitialValues { + url?: string; + baseURL?: string; + compression?: string; + progressCallback?: any; + dataAccessHelper?: + | HtmlDataAccessHelper + | HttpDataAccessHelper + | JSZipDataAccessHelper + | LiteHttpDataAccessHelper; +} + +type vtkPolyDataReaderBase = vtkObject & + Omit< + vtkAlgorithm, + | 'getInputData' + | 'setInputData' + | 'setInputConnection' + | 'getInputConnection' + | 'addInputConnection' + | 'addInputData' + >; + +export interface vtkPolyDataReader extends vtkPolyDataReaderBase { + /** + * + */ + getBaseURL(): Nullable; + + /** + * Get the url of the object to load. + */ + getUrl(): Nullable; + + /** + * + */ + getDataAccessHelper(): + | HtmlDataAccessHelper + | HttpDataAccessHelper + | JSZipDataAccessHelper + | LiteHttpDataAccessHelper; + + /** + * + * @param dataAccessHelper + */ + setDataAccessHelper( + dataAccessHelper: + | HtmlDataAccessHelper + | HttpDataAccessHelper + | JSZipDataAccessHelper + | LiteHttpDataAccessHelper + ): boolean; + + /** + * Set the url of the object to load. + * @param {String} url the url of the object to load. + * @param {IPolyDataReaderOptions} [option] The PolyData reader options. + */ + setUrl(url: string, option?: IPolyDataReaderOptions): Promise; + + /** + * Load the object data. + * @param {IPolyDataReaderOptions} [option] + */ + loadData(option?: IPolyDataReaderOptions): Promise; + + /** + * Parse data as text. + * @param {String} content The content to parse. + */ + parseAsText(content: string): void; + + /** + * + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkPolyDataReader characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IPolyDataReaderInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IPolyDataReaderInitialValues +): void; + +/** + * Method used to create a new instance of vtkPolyDataReader + * @param {IPolyDataReaderInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IPolyDataReaderInitialValues +): vtkPolyDataReader; + +/** + * The vtkPolyDataReader reads legacy VTK ASCII files. The current + * implementation is limited to the geometry: no point, cell or field data is + * read. + */ +export declare const vtkPolyDataReader: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkPolyDataReader; diff --git a/Sources/IO/Misc/ElevationReader/index.d.ts b/Sources/IO/Misc/ElevationReader/index.d.ts index 0d975dbb66c..47e1152375c 100755 --- a/Sources/IO/Misc/ElevationReader/index.d.ts +++ b/Sources/IO/Misc/ElevationReader/index.d.ts @@ -47,7 +47,7 @@ export interface vtkElevationReader extends vtkElevationReaderBase { /** * Get the url of the object to load. */ - getUrl(): string; + getUrl(): string | undefined; /** * @@ -83,7 +83,7 @@ export interface vtkElevationReader extends vtkElevationReaderBase { /** * */ - isBusy(): number; + isBusy(): boolean; /** * Load the object data. diff --git a/Sources/IO/Misc/GCodeReader/index.d.ts b/Sources/IO/Misc/GCodeReader/index.d.ts index 3c56e3a7c5f..e94ef726957 100644 --- a/Sources/IO/Misc/GCodeReader/index.d.ts +++ b/Sources/IO/Misc/GCodeReader/index.d.ts @@ -1,4 +1,4 @@ -import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { vtkAlgorithm, vtkObject, vtkSubscription } from '../../../interfaces'; import { HtmlDataAccessHelper } from '../../Core/DataAccessHelper/HtmlDataAccessHelper'; import { HttpDataAccessHelper } from '../../Core/DataAccessHelper/HttpDataAccessHelper'; import { JSZipDataAccessHelper } from '../../Core/DataAccessHelper/JSZipDataAccessHelper'; @@ -30,7 +30,7 @@ export interface vtkGCodeReader extends vtkGCodeReaderBase { /** * */ - getBaseURL(): string; + getBaseURL(): string | undefined; /** * @@ -44,7 +44,12 @@ export interface vtkGCodeReader extends vtkGCodeReaderBase { /** * Get the url of the object to load. */ - getUrl(): string; + getUrl(): string | undefined; + + /** + * + */ + invokeReady(): void; /** * Load the object data. @@ -52,6 +57,11 @@ export interface vtkGCodeReader extends vtkGCodeReaderBase { */ loadData(options?: IGCodeReaderOptions): Promise; + /** + * + */ + onReady(callback: () => void, priority?: number): vtkSubscription; + /** * Parse data. * @param {String | ArrayBuffer} content The content to parse. diff --git a/Sources/IO/Misc/HttpDataSetLODsLoader/index.d.ts b/Sources/IO/Misc/HttpDataSetLODsLoader/index.d.ts new file mode 100644 index 00000000000..777e41ce6eb --- /dev/null +++ b/Sources/IO/Misc/HttpDataSetLODsLoader/index.d.ts @@ -0,0 +1,148 @@ +import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; +import vtkHttpDataSetReader from '../../Core/HttpDataSetReader'; +import vtkMapper from '../../../Rendering/Core/Mapper'; + +/** + * + */ +export interface IHttpDataSetLODsLoaderInitialValues { + baseUrl?: string; + files?: string[]; + mapper?: vtkMapper; + sceneItem?: any; + stepFinishedCallback?: () => void; + /** + * Delay in milliseconds before the first level of detail is downloaded. + */ + waitTimeToStart?: number; + /** + * Delay in milliseconds between two level of detail downloads. + */ + waitTimeBetweenDownloads?: number; +} + +export interface vtkHttpDataSetLODsLoader extends vtkObject { + /** + * Download every file of `files` in order, connecting each newly loaded + * source to `mapper` as it arrives, so the rendered level of detail + * improves over time. + */ + startDownloads(): void; + + /** + * Reader of the most recently created source. + */ + getCurrentSource(): Nullable; + + /** + * + */ + getBaseUrl(): string; + + /** + * Url prefix prepended to every entry of `files`. + * @param {String} baseUrl + */ + setBaseUrl(baseUrl: string): boolean; + + /** + * File names of the levels of detail, from coarsest to finest. + */ + getFiles(): string[]; + + /** + * + * @param {String[]} files + */ + setFiles(files: string[]): boolean; + + /** + * + */ + getMapper(): Nullable; + + /** + * Mapper the loaded sources are connected to. + * @param {vtkMapper} mapper + */ + setMapper(mapper: vtkMapper): boolean; + + /** + * Optional scene item whose default settings are applied to every newly + * loaded source, and whose `source` is updated as levels of detail arrive. + */ + getSceneItem(): any; + + /** + * + * @param sceneItem + */ + setSceneItem(sceneItem: any): boolean; + + /** + * + */ + getStepFinishedCallback(): Nullable<() => void>; + + /** + * Called after each level of detail has been connected to the mapper. + * @param stepFinishedCallback + */ + setStepFinishedCallback(stepFinishedCallback: () => void): boolean; + + /** + * + */ + getWaitTimeToStart(): number; + + /** + * Delay in milliseconds before the first level of detail is downloaded. + * @param {Number} waitTimeToStart + */ + setWaitTimeToStart(waitTimeToStart: number): boolean; + + /** + * + */ + getWaitTimeBetweenDownloads(): number; + + /** + * Delay in milliseconds between two level of detail downloads. + * @param {Number} waitTimeBetweenDownloads + */ + setWaitTimeBetweenDownloads(waitTimeBetweenDownloads: number): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkHttpDataSetLODsLoader characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IHttpDataSetLODsLoaderInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IHttpDataSetLODsLoaderInitialValues +): void; + +/** + * Method used to create a new instance of vtkHttpDataSetLODsLoader + * @param {IHttpDataSetLODsLoaderInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IHttpDataSetLODsLoaderInitialValues +): vtkHttpDataSetLODsLoader; + +/** + * vtkHttpDataSetLODsLoader progressively downloads a list of increasingly + * detailed versions of the same dataset and swaps each one into a mapper as it + * becomes available, so a coarse representation is displayed while the finer + * ones are still being fetched. + */ +export declare const vtkHttpDataSetLODsLoader: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkHttpDataSetLODsLoader; diff --git a/Sources/IO/Misc/ITKImageReader/index.d.ts b/Sources/IO/Misc/ITKImageReader/index.d.ts index 7fbf774ac5f..48435da0459 100755 --- a/Sources/IO/Misc/ITKImageReader/index.d.ts +++ b/Sources/IO/Misc/ITKImageReader/index.d.ts @@ -1,4 +1,5 @@ import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; /** * @@ -23,7 +24,7 @@ export interface vtkITKImageReader extends vtkITKImageReaderBase { /** * Get the array name. */ - getArrayName(): string; + getArrayName(): Nullable; /** * Get the filename. @@ -34,7 +35,7 @@ export interface vtkITKImageReader extends vtkITKImageReaderBase { * Parse data as array buffer. * @param {ArrayBuffer} arrayBuffer The array buffer to parse. */ - parseAsArrayBuffer(arrayBuffer: ArrayBuffer): void; + parseAsArrayBuffer(arrayBuffer: ArrayBuffer): Promise; /** * @@ -81,7 +82,7 @@ export function newInstance( * * @param {*} fn */ -export function setReadImageArrayBufferFromITK(fn: any): Promise; +declare function setReadImageArrayBufferFromITK(fn: any): Promise; /** * The vtkITKImageReader aims to read a ITK file format. diff --git a/Sources/IO/Misc/ITKPolyDataReader/index.d.ts b/Sources/IO/Misc/ITKPolyDataReader/index.d.ts index 2d47e8afb65..bbee535ee1b 100755 --- a/Sources/IO/Misc/ITKPolyDataReader/index.d.ts +++ b/Sources/IO/Misc/ITKPolyDataReader/index.d.ts @@ -1,4 +1,5 @@ import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; /** * @@ -23,7 +24,7 @@ export interface vtkITKPolyDataReader extends vtkITKPolyDataReaderBase { /** * Get the array name. */ - getArrayName(): string; + getArrayName(): Nullable; /** * Get the filename. @@ -34,7 +35,7 @@ export interface vtkITKPolyDataReader extends vtkITKPolyDataReaderBase { * Parse data as array buffer. * @param {ArrayBuffer} arrayBuffer The array buffer to parse. */ - parseAsArrayBuffer(arrayBuffer: ArrayBuffer): void; + parseAsArrayBuffer(arrayBuffer: ArrayBuffer): Promise; /** * @@ -81,7 +82,7 @@ export function newInstance( * * @param {*} fn */ -export function setReadPolyDataArrayBufferFromITK(fn: any): Promise; +declare function setReadPolyDataArrayBufferFromITK(fn: any): void; /** * The vtkITKPolyDataReader aims to read a ITK file format. diff --git a/Sources/IO/Misc/JSONNucleoReader/index.d.ts b/Sources/IO/Misc/JSONNucleoReader/index.d.ts index 6ed8e31560d..f22d4ffbb52 100755 --- a/Sources/IO/Misc/JSONNucleoReader/index.d.ts +++ b/Sources/IO/Misc/JSONNucleoReader/index.d.ts @@ -27,11 +27,6 @@ type vtkJSONNucleoReaderBase = vtkObject & >; export interface vtkJSONNucleoReader extends vtkJSONNucleoReaderBase { - /** - * - */ - getBaseURL(): string; - /** * */ @@ -44,7 +39,7 @@ export interface vtkJSONNucleoReader extends vtkJSONNucleoReaderBase { /** * Get the url of the object to load. */ - getUrl(): string; + getUrl(): string | undefined; /** * Load the object data. @@ -81,7 +76,7 @@ export interface vtkJSONNucleoReader extends vtkJSONNucleoReaderBase { * @param {String} url the url of the object to load. * @param {IJSONNucleoReaderOptions} [option] The JSONNucleo reader options. */ - setUrl(url: string, option: IJSONNucleoReaderOptions): Promise; + setUrl(url: string, option: IJSONNucleoReaderOptions): Promise; } /** diff --git a/Sources/IO/Misc/JSONReader/index.d.ts b/Sources/IO/Misc/JSONReader/index.d.ts index 0dd9b8079ca..0d37701fecc 100755 --- a/Sources/IO/Misc/JSONReader/index.d.ts +++ b/Sources/IO/Misc/JSONReader/index.d.ts @@ -31,7 +31,7 @@ export interface vtkJSONReader extends vtkJSONReaderBase { /** * Get the url of the object to load. */ - getUrl(): string; + getUrl(): string | undefined; /** * @@ -42,7 +42,7 @@ export interface vtkJSONReader extends vtkJSONReaderBase { /** * */ - isBusy(): number; + isBusy(): boolean; /** * Load the object data. @@ -60,7 +60,7 @@ export interface vtkJSONReader extends vtkJSONReaderBase { * Parse data as text. * @param {String} content The content to parse. */ - parseAsText(content: string): void; + parseAsText(content: string): boolean; /** * * @param inData @@ -73,7 +73,7 @@ export interface vtkJSONReader extends vtkJSONReaderBase { * @param {String} url the url of the object to load. * @param {IJSONReaderOptions} [option] The JSON reader options. */ - setUrl(url: string, option?: IJSONReaderOptions): Promise; + setUrl(url: string, option?: IJSONReaderOptions): Promise; } /** diff --git a/Sources/IO/Misc/MTLReader/index.d.ts b/Sources/IO/Misc/MTLReader/index.d.ts index 411e747bdc4..922b6084053 100755 --- a/Sources/IO/Misc/MTLReader/index.d.ts +++ b/Sources/IO/Misc/MTLReader/index.d.ts @@ -33,7 +33,7 @@ export interface vtkMTLReader extends vtkObject { /** * */ - getBaseURL(): string; + getBaseURL(): string | undefined; /** * @@ -53,22 +53,22 @@ export interface vtkMTLReader extends vtkObject { * * @param {String} name The name of the material. */ - getMaterial(name: string): object; + getMaterial(name: string): object | undefined; /** * */ - getMaterialNames(): object; + getMaterialNames(): string[]; /** * */ - getSplitGroup(): boolean; + getSplitGroup(): boolean | undefined; /** * Get the url of the object to load. */ - getUrl(): string; + getUrl(): string | undefined; /** * @@ -79,7 +79,7 @@ export interface vtkMTLReader extends vtkObject { /** * */ - isBusy(): number; + isBusy(): boolean; /** * @@ -103,12 +103,6 @@ export interface vtkMTLReader extends vtkObject { * @param {String} content The content to parse. */ parseAsText(content: string): void; - /** - * - * @param inData - * @param outData - */ - requestData(inData: any, outData: any): void; /** * @@ -146,7 +140,7 @@ export interface vtkMTLReader extends vtkObject { * @param {String} url the url of the object to load. * @param {IMTLReaderOptions} [option] The MTL reader options. */ - setUrl(url: string, option?: IMTLReaderOptions): Promise; + setUrl(url: string, option?: IMTLReaderOptions): Promise; } /** diff --git a/Sources/IO/Misc/OBJReader/index.d.ts b/Sources/IO/Misc/OBJReader/index.d.ts index d55b97cbc15..84b9a2635f7 100755 --- a/Sources/IO/Misc/OBJReader/index.d.ts +++ b/Sources/IO/Misc/OBJReader/index.d.ts @@ -14,6 +14,7 @@ interface IOBJReaderOptions { * */ export interface IOBJReaderInitialValues { + trackDuplicates?: boolean; numberOfOutputs?: number; requestCount?: number; splitMode?: string; @@ -46,7 +47,7 @@ type vtkOBJReaderBase = vtkObject & * @param polydata A polydata generated by the OBJReader * @param pointId A point Id (duplicated or not) */ -export function getPointDuplicateIds( +declare function getPointDuplicateIds( polydata: any, pointId: number ): Array; @@ -55,7 +56,7 @@ export interface vtkOBJReader extends vtkOBJReaderBase { /** * */ - getBaseURL(): string; + getBaseURL(): string | undefined; /** * @@ -69,12 +70,12 @@ export interface vtkOBJReader extends vtkOBJReaderBase { /** * Get the url of the object to load. */ - getUrl(): string; + getUrl(): string | undefined; /** * */ - getSplitMode(): number; + getSplitMode(): string | null; /** * True if duplicates are tracked in output polydata. @@ -90,7 +91,7 @@ export interface vtkOBJReader extends vtkOBJReaderBase { /** * */ - isBusy(): number; + isBusy(): boolean; /** * Load the object data. @@ -108,7 +109,7 @@ export interface vtkOBJReader extends vtkOBJReaderBase { * Parse data as text. * @param {String} content The content to parse. */ - parseAsText(content: string): void; + parseAsText(content: string): boolean; /** * @@ -148,7 +149,7 @@ export interface vtkOBJReader extends vtkOBJReaderBase { * @param {String} url the url of the object to load. * @param {IOBJReaderOptions} [option] The OBJ reader options. */ - setUrl(url: string, option?: IOBJReaderOptions): Promise; + setUrl(url: string, option?: IOBJReaderOptions): Promise; } /** @@ -204,5 +205,9 @@ export function newInstance( export declare const vtkOBJReader: { newInstance: typeof newInstance; extend: typeof extend; + getPointDuplicateIds: typeof getPointDuplicateIds; }; +export declare const STATIC: Readonly<{ + getPointDuplicateIds: typeof getPointDuplicateIds; +}>; export default vtkOBJReader; diff --git a/Sources/IO/Misc/OBJWriter/index.d.ts b/Sources/IO/Misc/OBJWriter/index.d.ts index 77851a76d72..a8e278a8183 100644 --- a/Sources/IO/Misc/OBJWriter/index.d.ts +++ b/Sources/IO/Misc/OBJWriter/index.d.ts @@ -23,7 +23,7 @@ export interface vtkOBJWriter extends vtkOBJWriterBase { /** * Get the MTL file as a string. */ - getMtl(): string; + getMtl(): string | undefined; /** * @@ -84,8 +84,14 @@ export function newInstance( /** * * @param {vktPolyData} polyData + * @param {string} [materialFilename] + * @param {string} [materialName] */ -export function writeOBJ(polyData: vtkPolyData): vtkPolyData; +declare function writeOBJ( + polyData: vtkPolyData, + materialFilename?: string, + materialName?: string +): string; /** * vtkOBJWriter writes wavefront obj (.obj) files in ASCII form. OBJ files @@ -100,4 +106,7 @@ export declare const vtkOBJWriter: { extend: typeof extend; writeOBJ: typeof writeOBJ; }; +export declare const STATIC: Readonly<{ + writeOBJ: typeof writeOBJ; +}>; export default vtkOBJWriter; diff --git a/Sources/IO/Misc/PDBReader/index.d.ts b/Sources/IO/Misc/PDBReader/index.d.ts index c5b24de91c0..4e66801bfca 100755 --- a/Sources/IO/Misc/PDBReader/index.d.ts +++ b/Sources/IO/Misc/PDBReader/index.d.ts @@ -33,7 +33,7 @@ export interface vtkPDBReader extends vtkPDBReaderBase { /** * */ - getBaseURL(): string; + getBaseURL(): string | undefined; /** * @@ -47,7 +47,7 @@ export interface vtkPDBReader extends vtkPDBReaderBase { /** * Get the url of the object to load. */ - getUrl(): string; + getUrl(): string | undefined; /** * @@ -68,7 +68,7 @@ export interface vtkPDBReader extends vtkPDBReaderBase { /** * */ - isBusy(): number; + isBusy(): boolean; /** * Load the object data. @@ -86,7 +86,7 @@ export interface vtkPDBReader extends vtkPDBReaderBase { * Parse data as text. * @param {String} content The content to parse. */ - parseAsText(content: string): void; + parseAsText(content: string): boolean; /** * * @param inData @@ -111,7 +111,7 @@ export interface vtkPDBReader extends vtkPDBReaderBase { * @param {String} url the url of the object to load. * @param {IPDBReaderOptions} [option] The PDB reader options. */ - setUrl(url: string, option?: IPDBReaderOptions): Promise; + setUrl(url: string, option?: IPDBReaderOptions): Promise; } /** diff --git a/Sources/IO/Misc/SkyboxReader/index.d.ts b/Sources/IO/Misc/SkyboxReader/index.d.ts new file mode 100644 index 00000000000..14a6a37b063 --- /dev/null +++ b/Sources/IO/Misc/SkyboxReader/index.d.ts @@ -0,0 +1,186 @@ +import { vtkAlgorithm, vtkObject, vtkSubscription } from '../../../interfaces'; +import { Nullable } from '../../../types'; +import { HtmlDataAccessHelper } from '../../Core/DataAccessHelper/HtmlDataAccessHelper'; +import { HttpDataAccessHelper } from '../../Core/DataAccessHelper/HttpDataAccessHelper'; +import { JSZipDataAccessHelper } from '../../Core/DataAccessHelper/JSZipDataAccessHelper'; +import { LiteHttpDataAccessHelper } from '../../Core/DataAccessHelper/LiteHttpDataAccessHelper'; + +export interface ISkyboxReaderOptions { + compression?: string; + progressCallback?: any; +} + +export interface ISkyboxFaceTransform { + flipX?: boolean; + flipY?: boolean; + rotate?: number; +} + +/** + * Mapping of a skybox face index to the image it should be filled with. + * The order is right, left, up, down, back, front. + */ +export interface ISkyboxFaceMapping { + fileName: string; + transform?: ISkyboxFaceTransform; +} + +/** + * + */ +export interface ISkyboxReaderInitialValues { + url?: string; + busy?: boolean; + faceMapping?: ISkyboxFaceMapping[]; + + /** + * Data access helper used to fetch the zip. It has no accessor, so it can + * only be provided through the initial values. + */ + dataAccessHelper?: + | HtmlDataAccessHelper + | HttpDataAccessHelper + | JSZipDataAccessHelper + | LiteHttpDataAccessHelper; +} + +type vtkSkyboxReaderBase = vtkObject & + Omit< + vtkAlgorithm, + | 'getInputData' + | 'setInputData' + | 'setInputConnection' + | 'getInputConnection' + | 'addInputConnection' + | 'addInputData' + >; + +export interface vtkSkyboxReader extends vtkSkyboxReaderBase { + /** + * Get the url of the zip to load. + */ + getUrl(): Nullable; + + /** + * Camera positions found in the loaded zip. + */ + getPositions(): string[]; + + /** + * Camera position currently exposed as the output texture. + */ + getPosition(): string; + + /** + * Select the camera position to expose as the output texture. Ignored when + * the name is not one of `getPositions()`. + * @param {String} name + */ + setPosition(name: string): void; + + /** + * + */ + getFaceMapping(): ISkyboxFaceMapping[]; + + /** + * Set which image of a position folder goes on which cube face, and how it + * must be transformed. Overridden by the `index.json` of the zip when it + * declares a face mapping. + * @param {ISkyboxFaceMapping[]} faceMapping + */ + setFaceMapping(faceMapping: ISkyboxFaceMapping[]): boolean; + + /** + * Set the url of the zip to load and fetch it. + * @param {String} url the url of the zip to load. + * @param {ISkyboxReaderOptions} [option] The Skybox reader options. + */ + setUrl(url: string, option?: ISkyboxReaderOptions): Promise; + + /** + * Load the object data. + * @param {ISkyboxReaderOptions} [option] + */ + loadData(option?: ISkyboxReaderOptions): Promise; + + /** + * Unzip the given buffer and build one vtkTexture per camera position it + * contains. Returns false when no content is given. + * @param {ArrayBuffer} content The content to parse. + */ + parseAsArrayBuffer(content: ArrayBuffer): Promise | false; + + /** + * Promise resolving with this reader once the images are all decoded. + */ + getReadyPromise(): Promise; + + /** + * Get the current status of the reader. True means busy and False means + * idle. + */ + isBusy(): boolean; + + /** + * + * @param {Boolean} busy + */ + invokeBusy(busy: boolean): void; + + /** + * + * @param callback + */ + onBusy(callback: (busy: boolean) => any): vtkSubscription; + + /** + * + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkSkyboxReader characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ISkyboxReaderInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ISkyboxReaderInitialValues +): void; + +/** + * Method used to create a new instance of vtkSkyboxReader + * @param {ISkyboxReaderInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: ISkyboxReaderInitialValues +): vtkSkyboxReader; + +/** + * vtkSkyboxReader reads a zip file containing one or more camera positions, + * each holding the six jpg images composing a skybox texture. The mapping of + * the images onto the cube faces comes either from `setFaceMapping()` or from + * an `index.json` embedded in the zip: + * + * ```json + * { + * "skybox": { + * "faceMapping": [ + * { "fileName": "right.jpg", "transform": { "flipY": true } } + * ] + * } + * } + * ``` + */ +export declare const vtkSkyboxReader: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkSkyboxReader; diff --git a/Sources/IO/XML/XMLImageDataWriter/index.d.ts b/Sources/IO/XML/XMLImageDataWriter/index.d.ts new file mode 100644 index 00000000000..6c1f23469c6 --- /dev/null +++ b/Sources/IO/XML/XMLImageDataWriter/index.d.ts @@ -0,0 +1,38 @@ +import { IXMLWriterInitialValues, vtkXMLWriter } from '../XMLWriter'; + +/** + * + */ +export interface IXMLImageDataWriterInitialValues extends IXMLWriterInitialValues {} + +export interface vtkXMLImageDataWriter extends vtkXMLWriter {} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkXMLImageDataWriter characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IXMLImageDataWriterInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IXMLImageDataWriterInitialValues +): void; + +/** + * Method used to create a new instance of vtkXMLImageDataWriter + * @param {IXMLImageDataWriterInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IXMLImageDataWriterInitialValues +): vtkXMLImageDataWriter; + +/** + * vtkXMLImageDataWriter writes a vtkImageData out as a VTK XML `.vti` document. + */ +declare const vtkXMLImageDataWriter: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkXMLImageDataWriter; diff --git a/Sources/IO/XML/XMLPolyDataWriter/index.d.ts b/Sources/IO/XML/XMLPolyDataWriter/index.d.ts new file mode 100644 index 00000000000..51835d287bb --- /dev/null +++ b/Sources/IO/XML/XMLPolyDataWriter/index.d.ts @@ -0,0 +1,38 @@ +import { IXMLWriterInitialValues, vtkXMLWriter } from '../XMLWriter'; + +/** + * + */ +export interface IXMLPolyDataWriterInitialValues extends IXMLWriterInitialValues {} + +export interface vtkXMLPolyDataWriter extends vtkXMLWriter {} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkXMLPolyDataWriter characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IXMLPolyDataWriterInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IXMLPolyDataWriterInitialValues +): void; + +/** + * Method used to create a new instance of vtkXMLPolyDataWriter + * @param {IXMLPolyDataWriterInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IXMLPolyDataWriterInitialValues +): vtkXMLPolyDataWriter; + +/** + * vtkXMLPolyDataWriter writes a vtkPolyData out as a VTK XML `.vtp` document. + */ +declare const vtkXMLPolyDataWriter: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkXMLPolyDataWriter; diff --git a/Sources/IO/XML/XMLReader/index.d.ts b/Sources/IO/XML/XMLReader/index.d.ts index ca6a5dad573..3b949154e4e 100755 --- a/Sources/IO/XML/XMLReader/index.d.ts +++ b/Sources/IO/XML/XMLReader/index.d.ts @@ -36,7 +36,7 @@ export interface vtkXMLReader extends vtkXMLReaderBase { /** * */ - getBaseURL(): string; + getBaseURL(): string | undefined; /** * @@ -50,7 +50,7 @@ export interface vtkXMLReader extends vtkXMLReaderBase { /** * Get the url of the object to load. */ - getUrl(): string; + getUrl(): string | undefined; /** * Load the object data. @@ -58,23 +58,12 @@ export interface vtkXMLReader extends vtkXMLReaderBase { */ loadData(options?: IXMLReaderOptions): Promise; - /** - * Parse data. - * @param {String | ArrayBuffer} content The content to parse. - */ - parse(content: string | ArrayBuffer): void; - /** * Parse data as ArrayBuffer. * @param {ArrayBuffer} content The content to parse. */ - parseAsArrayBuffer(content: ArrayBuffer): void; + parseAsArrayBuffer(content: ArrayBuffer): boolean; - /** - * Parse data as text. - * @param {String} content The content to parse. - */ - parseAsText(content: string): void; /** * * @param inData @@ -102,6 +91,29 @@ export interface vtkXMLReader extends vtkXMLReaderBase { setUrl(url: string, option?: IXMLReaderOptions): Promise; } +/** + * Collect every descendant element carrying the given tag name. + * + * @param {Element | Document} node The node to search under + * @param {String} tagName The tag name to match + */ +export function findAllTags( + node: Element | Document, + tagName: string +): Element[]; + +/** + * Collect the first descendant element carrying the given tag name, or + * undefined when the node has none. + * + * @param {Element | Document} node The node to search under + * @param {String} tagName The tag name to match + */ +export function findFirstTag( + node: Element | Document, + tagName: string +): Element | undefined; + /** * Method used to decorate a given object (publicAPI+model) with vtkXMLReader characteristics. * @@ -123,7 +135,7 @@ export function extend( * @param {String} headerType * @param {ArrayBuffer} binaryBuffer */ -export function processDataArray( +declare function processDataArray( size: number, dataArrayElem: HTMLElement, compressor: string, @@ -140,7 +152,7 @@ export function processDataArray( * @param {String} headerType * @param {ArrayBuffer} binaryBuffer */ -export function processCells( +declare function processCells( size: number, containerElem: HTMLElement, compressor: string, @@ -158,7 +170,7 @@ export function processCells( * @param {String} headerType * @param {ArrayBuffer} binaryBuffer */ -export function processFieldData( +declare function processFieldData( size: number, fieldElem: HTMLElement, fieldContainer: HTMLElement, diff --git a/Sources/IO/XML/XMLWriter/Constants.d.ts b/Sources/IO/XML/XMLWriter/Constants.d.ts new file mode 100644 index 00000000000..a836b7d7739 --- /dev/null +++ b/Sources/IO/XML/XMLWriter/Constants.d.ts @@ -0,0 +1,18 @@ +export declare const FormatTypes: { + readonly ASCII: 'ascii'; + readonly BINARY: 'binary'; + readonly APPENDED: 'appended'; +}; + +export type FormatTypes = (typeof FormatTypes)[keyof typeof FormatTypes]; + +/** + * Mapping from a JavaScript typed array constructor name to the corresponding + * VTK XML data array type name. + */ +export declare const TYPED_ARRAY: Record; + +declare const _default: { + FormatTypes: typeof FormatTypes; +}; +export default _default; diff --git a/Sources/IO/XML/XMLWriter/index.d.ts b/Sources/IO/XML/XMLWriter/index.d.ts new file mode 100644 index 00000000000..3de5cf076bb --- /dev/null +++ b/Sources/IO/XML/XMLWriter/index.d.ts @@ -0,0 +1,134 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import vtkDataArray from '../../../Common/Core/DataArray'; +import vtkDataSetAttributes from '../../../Common/DataModel/DataSetAttributes'; +import { FormatTypes } from './Constants'; + +/** + * + */ +export interface IXMLWriterInitialValues { + /** + * Size, in bytes, of the blocks the binary payload is split into before being + * compressed. + * @default 1024 + */ + blockSize?: number; + + /** + * How the data arrays are encoded in the produced XML. + * @default FormatTypes.BINARY + */ + format?: FormatTypes; +} + +type vtkXMLWriterBase = vtkObject & + Omit; + +export interface vtkXMLWriter extends vtkXMLWriterBase { + /** + * Get the block size used when compressing binary payloads. + * @default 1024 + */ + getBlockSize(): number; + + /** + * Set the block size used when compressing binary payloads. + */ + setBlockSize(blockSize: number): boolean; + + /** + * Get the encoding used for the data arrays. + */ + getFormat(): FormatTypes; + + /** + * Set the encoding used for the data arrays. + */ + setFormat(format: FormatTypes): boolean; + + /** + * Get the string produced by the last `requestData` call. Undefined before + * the first one, since `file` has no default. + */ + getFile(): string | undefined; + + /** + * Build the XML document for the given data object and return its root + * element. + * + * @param dataObject The data object to serialize + */ + create(dataObject: any): any; + + /** + * Serialize the given data object to an XML string. + * + * @param object The data object to serialize + */ + write(object: any): string; + + /** + * Append the arrays of a `vtkDataSetAttributes` under the given element. + * + * @param parentEle The parent XML element + * @param dataSetAttributesName Either `'PointData'` or `'CellData'` + * @param {vtkDataSetAttributes} dataSetAttributes The attributes to append + * @returns The created XML element + */ + processDataSetAttributes( + parentEle: any, + dataSetAttributesName: string, + dataSetAttributes: vtkDataSetAttributes + ): any; + + /** + * Append a single data array under the given element. + * + * @param parentEle The parent XML element + * @param {vtkDataArray} scalars The array to append + */ + processDataArray(parentEle: any, scalars: vtkDataArray): any; + + /** + * + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkXMLWriter characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IXMLWriterInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IXMLWriterInitialValues +): void; + +/** + * vtkXMLWriter is the base class of the VTK XML writers. It is not meant to be + * instantiated directly: use vtkXMLImageDataWriter or vtkXMLPolyDataWriter. + */ +declare const vtkXMLWriter: { + extend: typeof extend; + /** + * Deflate a block of bytes with zlib. + */ + compressBlock(uncompressed: Uint8Array): Uint8Array; + /** + * Encode a data array's values per the given format. + */ + processDataArray( + dataArray: vtkDataArray, + format: FormatTypes, + blockSize: number, + compressor?: string + ): string; + FormatTypes: typeof FormatTypes; +}; +export default vtkXMLWriter; diff --git a/Sources/Imaging/Core/AbstractImageInterpolator/Constants.d.ts b/Sources/Imaging/Core/AbstractImageInterpolator/Constants.d.ts index 75548b8f9a6..925c7f9a61d 100644 --- a/Sources/Imaging/Core/AbstractImageInterpolator/Constants.d.ts +++ b/Sources/Imaging/Core/AbstractImageInterpolator/Constants.d.ts @@ -1,14 +1,20 @@ -export declare enum ImageBorderMode { - CLAMP = 0, - REPEAT = 1, - MIRROR = 2, -} +export declare const ImageBorderMode: { + readonly CLAMP: 0; + readonly REPEAT: 1; + readonly MIRROR: 2; +}; + +export type ImageBorderMode = + (typeof ImageBorderMode)[keyof typeof ImageBorderMode]; + +export declare const InterpolationMode: { + readonly NEAREST: 0; + readonly LINEAR: 1; + readonly CUBIC: 2; +}; -export declare enum InterpolationMode { - NEAREST = 0, - LINEAR = 1, - CUBIC = 2, -} +export type InterpolationMode = + (typeof InterpolationMode)[keyof typeof InterpolationMode]; declare const _default: { ImageBorderMode: typeof ImageBorderMode; diff --git a/Sources/Imaging/Core/AbstractImageInterpolator/index.d.ts b/Sources/Imaging/Core/AbstractImageInterpolator/index.d.ts new file mode 100644 index 00000000000..7fa1903460c --- /dev/null +++ b/Sources/Imaging/Core/AbstractImageInterpolator/index.d.ts @@ -0,0 +1,270 @@ +import { vtkObject } from '../../../interfaces'; +import { Extent, Nullable, TypedArray, Vector3 } from '../../../types'; +import vtkImageData from '../../../Common/DataModel/ImageData'; +import { ImageBorderMode, InterpolationMode } from './Constants'; + +/** + * Description of the scalars being interpolated, shared with the + * interpolation kernels. + */ +export interface IInterpolationInfo { + pointer: Nullable; + extent: Extent; + increments: Vector3; + scalarType: Nullable; + dataTypeSize: number; + numberOfComponents: number; + borderMode: ImageBorderMode; + interpolationMode: InterpolationMode; + extraInfo: any; +} + +/** + * Precomputed per-axis interpolation weights for a whole extent. + */ +export interface IInterpolationWeights extends IInterpolationInfo { + positions: any[]; + weights: Nullable; + weightExtent: Extent; + kernelSize: Vector3; + workspace: Nullable; + lastY: Nullable; + lastZ: Nullable; +} + +/** + * + */ +export interface IAbstractImageInterpolatorInitialValues { + outValue?: number; + tolerance?: number; + componentOffset?: number; + componentCount?: number; + borderMode?: ImageBorderMode; + slidingWindow?: boolean; +} + +export interface vtkAbstractImageInterpolator extends vtkObject { + /** + * Setup the interpolator for the given image: caches its scalars, spacing, + * origin and extent then calls `update()`. + * @param {vtkImageData} data The image to interpolate. + */ + initialize(data: vtkImageData): void; + + /** + * Drop the reference to the scalars that were set by `initialize()`. + */ + releaseData(): void; + + /** + * Recompute the structured bounds and the interpolation info from the + * current scalars. Must be called after any option is changed. + */ + update(): void; + + /** + * Hook called at the end of `update()` for subclasses to update their own + * state. Does nothing on the abstract class. + */ + internalUpdate(): void; + + /** + * Interpolate a single component at the given world position. Returns + * `outValue` when the position is outside of the structured bounds. + */ + interpolateXYZ(x: number, y: number, z: number, component: number): number; + + /** + * Interpolate all components at the given world position into `value`. + * Returns false and fills `value` with `outValue` when the position is + * outside of the structured bounds. + * @param {Vector3} point The world coordinate. + * @param value Output array, filled with the interpolated components. + */ + interpolate(point: Vector3, value: number[] | TypedArray): boolean; + + /** + * Number of components that will be interpolated given an input component + * count, taking `componentOffset` and `componentCount` into account. + */ + computeNumberOfComponents(inputCount: number): number; + + /** + * + */ + getNumberOfComponents(): number; + + /** + * Interpolate at the given structured (index space) coordinate. + * @param {Vector3} point The structured coordinate. + * @param value Output array, filled with the interpolated components. + */ + interpolateIJK(point: Vector3, value: number[] | TypedArray): void; + + /** + * Check whether a structured coordinate lies within the structured bounds. + * @param {Vector3} point The structured coordinate. + */ + checkBoundsIJK(point: Vector3): boolean; + + /** + * Size of the interpolation kernel along each axis. `null` on the abstract + * class, subclasses provide the implementation. + */ + computeSupportSize: Nullable<(matrix: Nullable) => Vector3>; + + /** + * Whether the interpolation kernel is separable. `null` on the abstract + * class, subclasses provide the implementation. + */ + isSeparable: Nullable<() => boolean>; + + /** + * + */ + precomputeWeightsForExtent( + matrix: number[], + inExtent: Extent, + checkExtent: Extent + ): void; + + /** + * + */ + FreePrecomputedWeights(weights: IInterpolationWeights): void; + + /** + * Interpolation kernel. Does nothing on the abstract class. + */ + interpolatePoint( + interpolationInfo: IInterpolationInfo, + point: Vector3, + value: number[] | TypedArray + ): void; + + /** + * Row interpolation kernel. Does nothing on the abstract class. + */ + interpolateRow( + weights: IInterpolationWeights, + xIdx: number, + yIdx: number, + zIdx: number, + value: number[] | TypedArray, + n: number + ): void; + + /** + * Origin of the image passed to `initialize()`. + */ + getOrigin(): Nullable; + + /** + * Spacing of the image passed to `initialize()`. + */ + getSpacing(): Nullable; + + /** + * + */ + getOutValue(): number; + + /** + * Value returned for positions that lie outside of the image. + * @param {Number} outValue + */ + setOutValue(outValue: number): boolean; + + /** + * + */ + getTolerance(): number; + + /** + * Tolerance, in structured coordinates, by which the image bounds are + * enlarged when checking whether a position can be interpolated. + * @param {Number} tolerance + */ + setTolerance(tolerance: number): boolean; + + /** + * + */ + getComponentOffset(): number; + + /** + * Index of the first scalar component to interpolate. + * @param {Number} componentOffset + */ + setComponentOffset(componentOffset: number): boolean; + + /** + * + */ + getComponentCount(): number; + + /** + * Number of scalar components to interpolate, starting at + * `componentOffset`. A value of -1 means all remaining components. + * @param {Number} componentCount + */ + setComponentCount(componentCount: number): boolean; + + /** + * + */ + getBorderMode(): ImageBorderMode; + + /** + * How out-of-extent indices are mapped back into the extent. + * @param {ImageBorderMode} borderMode + */ + setBorderMode(borderMode: ImageBorderMode): boolean; + + /** + * + */ + getSlidingWindow(): boolean; + + /** + * + * @param {Boolean} slidingWindow + */ + setSlidingWindow(slidingWindow: boolean): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkAbstractImageInterpolator characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IAbstractImageInterpolatorInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IAbstractImageInterpolatorInitialValues +): void; + +/** + * Method used to create a new instance of vtkAbstractImageInterpolator + * @param {IAbstractImageInterpolatorInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IAbstractImageInterpolatorInitialValues +): vtkAbstractImageInterpolator; + +/** + * vtkAbstractImageInterpolator provides an abstract interface for interpolating + * image data. The `initialize()` method takes a vtkImageData as input and + * caches everything the interpolation kernels need; subclasses supply the + * kernels themselves through `interpolatePoint()` and `interpolateRow()`. + */ +export declare const vtkAbstractImageInterpolator: { + newInstance: typeof newInstance; + extend: typeof extend; + ImageBorderMode: typeof ImageBorderMode; + InterpolationMode: typeof InterpolationMode; +}; +export default vtkAbstractImageInterpolator; diff --git a/Sources/Imaging/Core/ImageInterpolator/index.d.ts b/Sources/Imaging/Core/ImageInterpolator/index.d.ts new file mode 100644 index 00000000000..33664ab8d29 --- /dev/null +++ b/Sources/Imaging/Core/ImageInterpolator/index.d.ts @@ -0,0 +1,142 @@ +import { Extent, Nullable, TypedArray, Vector3, Vector4 } from '../../../types'; +import { + IAbstractImageInterpolatorInitialValues, + IInterpolationInfo, + IInterpolationWeights, + vtkAbstractImageInterpolator, +} from '../AbstractImageInterpolator'; +import { InterpolationMode } from '../AbstractImageInterpolator/Constants'; + +/** + * + */ +export interface IImageInterpolatorInitialValues extends IAbstractImageInterpolatorInitialValues { + interpolationMode?: InterpolationMode; +} + +export interface vtkImageInterpolator extends vtkAbstractImageInterpolator { + /** + * Size of the interpolation kernel along each axis: 1 for nearest, 2 for + * linear and 4 for cubic. When `matrix` describes an integer mapping along + * an axis, that axis needs no interpolation and gets a size of 1. + * @param matrix Optional 4x4 row-major matrix, or null. + */ + computeSupportSize(matrix: Nullable): Vector3; + + /** + * + */ + isSeparable(): boolean; + + /** + * Nearest-neighbor interpolation kernel. + */ + interpolateNearest( + interpolationInfo: IInterpolationInfo, + point: Vector3, + value: number[] | TypedArray + ): void; + + /** + * Trilinear interpolation kernel. + */ + interpolateLinear( + interpolationInfo: IInterpolationInfo, + point: Vector3, + value: number[] | TypedArray + ): void; + + /** + * Tricubic interpolation kernel. + */ + interpolateCubic( + interpolationInfo: IInterpolationInfo, + point: Vector3, + value: number[] | TypedArray + ): void; + + /** + * Nearest-neighbor row kernel. + */ + interpolateRowNearest( + weights: IInterpolationWeights, + idX: number, + idY: number, + idZ: number, + outPtr: number[] | TypedArray, + n: number + ): void; + + /** + * Trilinear row kernel. + */ + interpolateRowLinear( + weights: IInterpolationWeights, + idX: number, + idY: number, + idZ: number, + outPtr: number[] | TypedArray, + n: number + ): void; + + /** + * Cubic interpolation weights for a fractional position. + */ + vtkTricubicInterpWeights(f: number): Vector4; + + /** + * Precompute the per-axis positions and weights needed to resample the + * given output extent, and report the portion of it that lies inside the + * input data in `clipExt`. + * @param matrix 4x4 row-major matrix mapping output to input indices. + * @param {Extent} outExt The output extent. + * @param {Extent} clipExt Filled with the clipped output extent. + */ + precomputeWeightsForExtent( + matrix: number[], + outExt: Extent, + clipExt: Extent + ): void; + + /** + * + */ + getInterpolationMode(): InterpolationMode; + + /** + * + * @param {InterpolationMode} interpolationMode + */ + setInterpolationMode(interpolationMode: InterpolationMode): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkImageInterpolator characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IImageInterpolatorInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IImageInterpolatorInitialValues +): void; + +/** + * Method used to create a new instance of vtkImageInterpolator + * @param {IImageInterpolatorInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IImageInterpolatorInitialValues +): vtkImageInterpolator; + +/** + * vtkImageInterpolator provides nearest-neighbor, trilinear and tricubic + * interpolation of vtkImageData. + */ +export declare const vtkImageInterpolator: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkImageInterpolator; diff --git a/Sources/Imaging/Core/ImagePointDataIterator/index.d.ts b/Sources/Imaging/Core/ImagePointDataIterator/index.d.ts new file mode 100644 index 00000000000..d42f64f9217 --- /dev/null +++ b/Sources/Imaging/Core/ImagePointDataIterator/index.d.ts @@ -0,0 +1,117 @@ +import { vtkObject } from '../../../interfaces'; +import { Extent, Nullable, TypedArray, Vector3 } from '../../../types'; +import vtkDataArray from '../../../Common/Core/DataArray'; +import vtkImageData from '../../../Common/DataModel/ImageData'; + +/** + * + */ +export interface IImagePointDataIteratorInitialValues { + extent?: Extent; +} + +export interface vtkImagePointDataIterator extends vtkObject { + /** + * Prepare the iterator to walk the given image over `inExtent`. + * @param {vtkImageData} image The image to iterate over. + * @param {Extent} [inExtent] The extent to walk, clamped to the image + * extent. Defaults to the whole image extent when null. + * @param stencil Optional stencil restricting the iteration. + * @param algorithm Optional algorithm used for progress reporting. + */ + initialize( + image: vtkImageData, + inExtent: Nullable, + stencil?: any, + algorithm?: any + ): void; + + /** + * Move the iterator to the span containing the given x index of the current + * row, and update the in-stencil state accordingly. + * @param {Number} idX + */ + setSpanState(idX: number): void; + + /** + * Advance to the next span, row or slice. + */ + nextSpan(): void; + + /** + * + */ + isAtEnd(): boolean; + + /** + * Whether the current span lies inside the stencil. Always true when no + * stencil was given to `initialize()`. + */ + isInStencil(): boolean; + + /** + * Point id just past the end of the current span. + */ + spanEndId(): number; + + /** + * Progress reporting hook. Does nothing by default. + */ + reportProgress(): void; + + /** + * Get the raw values of the given array, offset to tuple `i`. + * @param {vtkDataArray} array + * @param {Number} i The tuple index to start at. + */ + getArray(array: vtkDataArray, i: number): TypedArray; + + /** + * Get the raw scalars of the given image, offset to tuple `i`. + * @param {vtkImageData} image + * @param {Number} [i] The tuple index to start at (default 0). + */ + getScalars(image: vtkImageData, i?: number): TypedArray; + + /** + * Point id the iterator is currently at. + */ + getId(): number; + + /** + * Current x, y, z index. + */ + getIndex(): Vector3; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkImagePointDataIterator characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IImagePointDataIteratorInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IImagePointDataIteratorInitialValues +): void; + +/** + * Method used to create a new instance of vtkImagePointDataIterator + * @param {IImagePointDataIteratorInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IImagePointDataIteratorInitialValues +): vtkImagePointDataIterator; + +/** + * vtkImagePointDataIterator iterates over the point data of a vtkImageData, + * one span at a time. A span is a contiguous run of points along the x axis + * that is entirely inside or entirely outside of an optional stencil. + */ +export declare const vtkImagePointDataIterator: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkImagePointDataIterator; diff --git a/Sources/Imaging/Core/ImageReslice/Constants.d.ts b/Sources/Imaging/Core/ImageReslice/Constants.d.ts index f8821e20135..9c68cc4b518 100644 --- a/Sources/Imaging/Core/ImageReslice/Constants.d.ts +++ b/Sources/Imaging/Core/ImageReslice/Constants.d.ts @@ -1,9 +1,11 @@ -export declare enum SlabMode { - MIN = 0, - MAX = 1, - MEAN = 2, - SUM = 3, -} +export declare const SlabMode: { + readonly MIN: 0; + readonly MAX: 1; + readonly MEAN: 2; + readonly SUM: 3; +}; + +export type SlabMode = (typeof SlabMode)[keyof typeof SlabMode]; declare const _default: { SlabMode: typeof SlabMode; diff --git a/Sources/Imaging/Core/ImageReslice/index.d.ts b/Sources/Imaging/Core/ImageReslice/index.d.ts index 4ad0ec4a136..96866543080 100644 --- a/Sources/Imaging/Core/ImageReslice/index.d.ts +++ b/Sources/Imaging/Core/ImageReslice/index.d.ts @@ -17,30 +17,30 @@ import { mat3, mat4, vec3, vec4 } from 'gl-matrix'; * */ export interface IImageResliceInitialValues { - transformInputSampling: boolean; - autoCropOutput: boolean; - outputDimensionality: number; - outputSpacing: Nullable; // automatically computed if null - outputOrigin: Nullable; // automatically computed if null - outputDirection: Nullable; // identity if null - outputExtent: Nullable; // automatically computed if null - outputScalarType: Nullable; - wrap: boolean; // don't wrap - mirror: boolean; // don't mirror - border: boolean; // apply a border - interpolationMode: InterpolationMode; // only NEAREST supported so far - slabMode: SlabMode; - slabTrapezoidIntegration: boolean; - slabNumberOfSlices: number; - slabSliceSpacingFraction: number; - optimization: boolean; // not supported yet - scalarShift: number; // for rescaling the data - scalarScale: number; - backgroundColor: RGBAColor; - resliceAxes: Nullable; + transformInputSampling?: boolean; + autoCropOutput?: boolean; + outputDimensionality?: number; + outputSpacing?: Nullable; // automatically computed if null + outputOrigin?: Nullable; // automatically computed if null + outputDirection?: Nullable; // identity if null + outputExtent?: Nullable; // automatically computed if null + outputScalarType?: Nullable; + wrap?: boolean; // don't wrap + mirror?: boolean; // don't mirror + border?: boolean; // apply a border + interpolationMode?: InterpolationMode; // only NEAREST supported so far + slabMode?: SlabMode; + slabTrapezoidIntegration?: boolean; + slabNumberOfSlices?: number; + slabSliceSpacingFraction?: number; + optimization?: boolean; // not supported yet + scalarShift?: number; // for rescaling the data + scalarScale?: number; + backgroundColor?: RGBAColor; + resliceAxes?: Nullable; resliceTransform?: vtkTransform; - interpolator: any; // A vtkImageInterpolator (missing typescript header) - usePermuteExecute: boolean; // no supported yet + interpolator?: any; // A vtkImageInterpolator (missing typescript header) + usePermuteExecute?: boolean; // no supported yet } type vtkImageResliceBase = Omit & vtkAlgorithm; @@ -358,6 +358,18 @@ export interface vtkImageReslice extends vtkImageResliceBase { */ getOutputSpacing: () => vec3 | null; + /** + * @see getOutputSpacing + * @returns + */ + getOutputSpacingByReference: () => vec3 | null; + + /** + * @see setOutputSpacing + * @param outputSpacing + */ + setOutputSpacingFrom: (outputSpacing: vec3) => void; + /** * Set the origin for the output data. * The default output origin is the input origin permuted through the @@ -374,6 +386,18 @@ export interface vtkImageReslice extends vtkImageResliceBase { */ getOutputOrigin: () => vec3 | null; + /** + * @see getOutputOrigin + * @returns + */ + getOutputOriginByReference: () => vec3 | null; + + /** + * @see setOutputOrigin + * @param outputOrigin + */ + setOutputOriginFrom: (outputOrigin: vec3) => void; + /** * Set the extent for the output data. * The default output extent is the input extent permuted through the @@ -390,6 +414,18 @@ export interface vtkImageReslice extends vtkImageResliceBase { */ getOutputExtent: () => Extent | null; + /** + * @see getOutputExtent + * @returns + */ + getOutputExtentByReference: () => Extent | null; + + /** + * @see setOutputExtent + * @param outputExtent + */ + setOutputExtentFrom: (outputExtent: Extent) => void; + /** * Set the direction for the output data. * By default, the direction of the input data is passed to the output. @@ -410,6 +446,18 @@ export interface vtkImageReslice extends vtkImageResliceBase { */ getOutputDirection: () => mat3 | null; + /** + * @see getOutputDirection + * @returns + */ + getOutputDirectionByReference: () => mat3 | null; + + /** + * @see setOutputDirection + * @param outputDirection + */ + setOutputDirectionFrom: (outputDirection: mat3) => void; + /** * Set the background color (for multi-component images). * Defaults to full opaque black. @@ -424,6 +472,18 @@ export interface vtkImageReslice extends vtkImageResliceBase { */ getBackgroundColor: () => RGBAColor; + /** + * @see getBackgroundColor + * @returns + */ + getBackgroundColorByReference: () => RGBAColor; + + /** + * @see setBackgroundColor + * @param backgroundColor + */ + setBackgroundColorFrom: (backgroundColor: RGBAColor) => void; + /** * This method is used to set up the axes for the output voxels. * The output Spacing, Origin, and Extent specify the locations @@ -444,7 +504,7 @@ export interface vtkImageReslice extends vtkImageResliceBase { * @see setResliceAxes * @returns */ - getResliceAxes: () => mat4; + getResliceAxes: () => Nullable; /** * Set the scalar type of the output to be different from the input. @@ -671,5 +731,6 @@ export function newInstance( export declare const vtkImageReslice: { newInstance: typeof newInstance; extend: typeof extend; + SlabMode: typeof SlabMode; }; export default vtkImageReslice; diff --git a/Sources/Imaging/Hybrid/SampleFunction/index.d.ts b/Sources/Imaging/Hybrid/SampleFunction/index.d.ts new file mode 100644 index 00000000000..7e27e7d9d1b --- /dev/null +++ b/Sources/Imaging/Hybrid/SampleFunction/index.d.ts @@ -0,0 +1,138 @@ +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Bounds, Vector3 } from '../../../types'; +import vtkImplicitFunction from '../../../Common/DataModel/ImplicitFunction'; + +/** + * + */ +export interface ISampleFunctionInitialValues { + /** + * The implicit function to sample. Has no accessor: it can only be given + * through the initial values. + */ + implicitFunction?: vtkImplicitFunction; + + sampleDimensions?: Vector3; + + modelBounds?: Bounds; + + /** + * Typed array name used for the generated scalars. Has no accessor: it can + * only be given through the initial values. + */ + pointType?: string; +} + +type vtkSampleFunctionBase = vtkObject & vtkAlgorithm; + +export interface vtkSampleFunction extends vtkSampleFunctionBase { + /** + * Get the dimensions of the volume in the x-y-z directions. + */ + getSampleDimensions(): Vector3; + + /** + * + */ + getSampleDimensionsByReference(): Vector3; + + /** + * Set the dimensions of the volume in the x-y-z directions. + * @param {Vector3} sampleDimensions + */ + setSampleDimensions(sampleDimensions: Vector3): boolean; + + /** + * Set the dimensions of the volume in the x-y-z directions. + * @param {Number} x + * @param {Number} y + * @param {Number} z + */ + setSampleDimensions(x: number, y: number, z: number): boolean; + + /** + * + * @param {Vector3} sampleDimensions + */ + setSampleDimensionsFrom(sampleDimensions: Vector3): void; + + /** + * Get the bounds of the volume in 3D space. + */ + getModelBounds(): Bounds; + + /** + * + */ + getModelBoundsByReference(): Bounds; + + /** + * Set the bounds of the volume in 3D space. + * @param {Bounds} modelBounds + */ + setModelBounds(modelBounds: Bounds): boolean; + + /** + * Set the bounds of the volume in 3D space. + */ + setModelBounds( + xMin: number, + xMax: number, + yMin: number, + yMax: number, + zMin: number, + zMax: number + ): boolean; + + /** + * + * @param {Bounds} modelBounds + */ + setModelBoundsFrom(modelBounds: Bounds): void; + + /** + * The modified time is the maximum of this object's own modified time and + * that of the implicit function being sampled. + */ + getMTime(): number; + + /** + * + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkSampleFunction characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ISampleFunctionInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ISampleFunctionInitialValues +): void; + +/** + * Method used to create a new instance of vtkSampleFunction + * @param {ISampleFunctionInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: ISampleFunctionInitialValues +): vtkSampleFunction; + +/** + * vtkSampleFunction samples an implicit function over a volume. For example, a + * vtkPlane or vtkSphere can be defined, along with a volume extent (dimensions + * and geometric bounds), and the filter will then sample the implicit function + * over all voxels, producing a vtkImageData. + */ +export declare const vtkSampleFunction: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkSampleFunction; diff --git a/Sources/Interaction/Animations/TimeStepBasedAnimationHandler/index.d.ts b/Sources/Interaction/Animations/TimeStepBasedAnimationHandler/index.d.ts new file mode 100644 index 00000000000..e0e9c207e9a --- /dev/null +++ b/Sources/Interaction/Animations/TimeStepBasedAnimationHandler/index.d.ts @@ -0,0 +1,134 @@ +import vtkRenderer from '../../../Rendering/Core/Renderer'; +import { vtkObject } from '../../../interfaces'; +import { Nullable, RGBColor, Range } from '../../../types'; + +/** + * One entry of the animation data: the settings to apply at a given time. + * Besides `time`, `camera` and `background`, a scene item's settings are keyed + * by that item's id. + */ +export interface ITimeStepScene { + time: number; + camera?: object; + background?: RGBColor; + [id: string]: unknown; +} + +export interface ITimeStepBasedAnimationData { + timeSteps: ITimeStepScene[]; +} + +export interface IAnimationSceneItem { + id: string; + source: { + getTimeSteps?(): number[]; + setUpdateTimeStep?(time: number): void; + }; + defaultSettings?: object; +} + +export type ApplySettings = ( + sceneItem: IAnimationSceneItem, + settings: object +) => void; + +export interface vtkTimeStepBasedAnimationHandler extends vtkObject { + /** + * Snaps to the last time step lower than or equal to `time` and applies it. + * Does nothing when no time step is known. + * @param time the requested time + */ + setCurrentTimeStep(time: number): void; + + /** + * Sets the animation data and refreshes the time steps, time range and + * current time step from it. + * @param data the animation data + */ + setData(data: ITimeStepBasedAnimationData): void; + + /** + * Sets what the handler animates. + * @param scene the scene items + * @param originalMetadata metadata holding the base camera parameters + * @param applySettings callback applying settings to a scene item + * @param renderer the renderer + */ + setScene( + scene: IAnimationSceneItem[], + originalMetadata: object, + applySettings: ApplySettings, + renderer: vtkRenderer + ): void; + + /** + * Applies camera parameters to every registered renderer's active camera. + * @param params the camera parameters + */ + setCameraParameters(params: object): void; + + /** + * Sets the background of every registered renderer. + * @param color the background color + */ + setBackground(color: RGBColor): void; + + /** + * Applies the scene settings of the current time step. + */ + update(): void; + + /** + * Registers a renderer, if not already registered. + * @param renderer the renderer + */ + addRenderer(renderer: vtkRenderer): void; + + getCurrentTimeStep(): number; + getTimeSteps(): number[]; + getTimeRange(): Range; + getData(): Nullable; + getScene(): Nullable; + getApplySettings(): Nullable; + + /** + * Gets the metadata passed at construction. + */ + getOriginalMetada(): object | undefined; + + getRenderers(): vtkRenderer[]; + setRenderers(renderers: vtkRenderer[]): boolean; +} + +export interface ITimeStepBasedAnimationHandlerInitialValues { + timeSteps?: number[]; + timeRange?: Range; + currentTimeStep?: number; + scene?: Nullable; + data?: Nullable; + renderers?: vtkRenderer[]; + applySettings?: Nullable; + originalMetadata?: object; +} + +export function newInstance( + initialValues?: ITimeStepBasedAnimationHandlerInitialValues +): vtkTimeStepBasedAnimationHandler; + +export function extend( + publicAPI: object, + model: object, + initialValues?: ITimeStepBasedAnimationHandlerInitialValues +): void; + +/** + * Drives a scene through a discrete list of time steps: each time step carries + * camera, background and per-scene-item settings that are applied when that + * step becomes current. + */ +export declare const vtkTimeStepBasedAnimationHandler: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkTimeStepBasedAnimationHandler; diff --git a/Sources/Interaction/Manipulators/3DControllerModelSelectorManipulator/index.d.ts b/Sources/Interaction/Manipulators/3DControllerModelSelectorManipulator/index.d.ts index 0721a19014f..75f1be49d11 100644 --- a/Sources/Interaction/Manipulators/3DControllerModelSelectorManipulator/index.d.ts +++ b/Sources/Interaction/Manipulators/3DControllerModelSelectorManipulator/index.d.ts @@ -1,6 +1,12 @@ import vtkCompositeVRManipulator from '../CompositeVRManipulator'; +import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; -export interface vtk3DControllerModelSelectorManipulator extends vtkCompositeVRManipulator {} +export interface vtk3DControllerModelSelectorManipulator + extends vtkObject, vtkCompositeVRManipulator { + getLastWorldPosition(): Nullable | undefined; + getLastOrientation(): Nullable | undefined; +} export interface I3DControllerModelSelectorManipulatorInitialValues extends vtkCompositeVRManipulator {} @@ -10,7 +16,12 @@ export function extend( initialValues?: I3DControllerModelSelectorManipulatorInitialValues ): void; +export function newInstance( + initialValues?: I3DControllerModelSelectorManipulatorInitialValues +): vtk3DControllerModelSelectorManipulator; + export const vtk3DControllerModelSelectorManipulator: { + newInstance: typeof newInstance; extend: typeof extend; }; diff --git a/Sources/Interaction/Manipulators/CompositeCameraManipulator/index.d.ts b/Sources/Interaction/Manipulators/CompositeCameraManipulator/index.d.ts index ef370332414..9ab588b90a2 100644 --- a/Sources/Interaction/Manipulators/CompositeCameraManipulator/index.d.ts +++ b/Sources/Interaction/Manipulators/CompositeCameraManipulator/index.d.ts @@ -36,6 +36,17 @@ export interface vtkCompositeCameraManipulator { */ getDisplayCenter(): Vector2; + /** + * Gets the display center array by reference. + */ + getDisplayCenterByReference(): Vector2; + + /** + * Sets the display center from another array, without a copy. + * @param center + */ + setDisplayCenterFrom(center: Vector2): void; + /** * Sets the center. * @param center @@ -47,6 +58,17 @@ export interface vtkCompositeCameraManipulator { * Gets the center. */ getCenter(): Vector3; + + /** + * Gets the center array by reference. + */ + getCenterByReference(): Vector3; + + /** + * Sets the center from another array, without a copy. + * @param center + */ + setCenterFrom(center: Vector3): void; } export interface ICompositeCameraManipulatorInitialValues { diff --git a/Sources/Interaction/Manipulators/CompositeGestureManipulator/index.d.ts b/Sources/Interaction/Manipulators/CompositeGestureManipulator/index.d.ts index 1785cc81a37..872d7767e7c 100644 --- a/Sources/Interaction/Manipulators/CompositeGestureManipulator/index.d.ts +++ b/Sources/Interaction/Manipulators/CompositeGestureManipulator/index.d.ts @@ -1,7 +1,6 @@ import vtkInteractorStyle from '../../../Rendering/Core/InteractorStyle'; import vtkRenderer from '../../..//Rendering/Core/Renderer'; import vtkRenderWindowInteractor from '../../../Rendering/Core/RenderWindowInteractor'; -import { Nullable } from '../../../types'; export interface vtkCompositeGestureManipulator { /** @@ -100,11 +99,6 @@ export interface vtkCompositeGestureManipulator { */ setPinchEnabled(pinch: boolean): boolean; - /** - * Gets flag if pinch is enabled. - */ - getPinchEnabled(): boolean; - /** * Is pan enabled. */ @@ -116,11 +110,6 @@ export interface vtkCompositeGestureManipulator { */ setPanEnabled(pan: boolean): boolean; - /** - * Gets flag if pan is enabled. - */ - getPanEnabled(): boolean; - /** * Is rotate enabled. */ @@ -132,21 +121,16 @@ export interface vtkCompositeGestureManipulator { */ setRotateEnabled(rotate: boolean): boolean; - /** - * Gets flag if rotate is enabled. - */ - getRotateEnabled(): boolean; - /** * Sets the interactor style. * @param style vtkInteractorStyle */ - setInteractorStyle(style: Nullable): boolean; + setInteractorStyle(style: vtkInteractorStyle): boolean; /** * Gets the interactor style. */ - getInteractorStyle(): Nullable; + getInteractorStyle(): vtkInteractorStyle | undefined; } export interface ICompositeGestureManipulatorInitialValues { diff --git a/Sources/Interaction/Manipulators/CompositeMouseManipulator/index.d.ts b/Sources/Interaction/Manipulators/CompositeMouseManipulator/index.d.ts index dd492b035d9..a9bb5f1c9e8 100644 --- a/Sources/Interaction/Manipulators/CompositeMouseManipulator/index.d.ts +++ b/Sources/Interaction/Manipulators/CompositeMouseManipulator/index.d.ts @@ -1,5 +1,6 @@ import vtkRenderer from '../../../Rendering/Core/Renderer'; import vtkRenderWindowInteractor from '../../../Rendering/Core/RenderWindowInteractor'; +import { Nullable } from '../../../types'; export interface vtkCompositeMouseManipulator { /** @@ -60,6 +61,20 @@ export interface vtkCompositeMouseManipulator { */ onEndScroll(interactor: vtkRenderWindowInteractor): void; + /** + * Handles a scroll event. + * @param interactor the interactor + * @param renderer the renderer + * @param delta the scroll delta + * @param position the display position, when the interactor style caches one + */ + onScroll( + interactor: vtkRenderWindowInteractor, + renderer: vtkRenderer, + delta: number, + position?: Nullable<{ x: number; y: number }> + ): void; + /** * Is drag enabled. */ diff --git a/Sources/Interaction/Manipulators/CompositeVRManipulator/index.d.ts b/Sources/Interaction/Manipulators/CompositeVRManipulator/index.d.ts index 01c84322ea5..01a56bde2a3 100644 --- a/Sources/Interaction/Manipulators/CompositeVRManipulator/index.d.ts +++ b/Sources/Interaction/Manipulators/CompositeVRManipulator/index.d.ts @@ -24,6 +24,12 @@ export interface vtkCompositeVRManipulator { state: States, eventData: I3DEvent ): void; + + getDevice(): Device | undefined; + setDevice(device: Device): boolean; + + getInput(): Input | undefined; + setInput(input: Input): boolean; } export interface ICompositeVRManipulatorInitialValues { @@ -39,6 +45,8 @@ export function extend( export const vtkCompositeVRManipulator: { extend: typeof extend; + Device: typeof Device; + Input: typeof Input; }; export default vtkCompositeVRManipulator; diff --git a/Sources/Interaction/Manipulators/GestureCameraManipulator/index.d.ts b/Sources/Interaction/Manipulators/GestureCameraManipulator/index.d.ts index a9110cc45ff..7c0ace6ffc9 100644 --- a/Sources/Interaction/Manipulators/GestureCameraManipulator/index.d.ts +++ b/Sources/Interaction/Manipulators/GestureCameraManipulator/index.d.ts @@ -14,9 +14,7 @@ export interface vtkGestureCameraManipulator export interface IGestureCameraManipulatorInitialValues extends ICompositeCameraManipulatorInitialValues, - ICompositeGestureManipulatorInitialValues { - flipDirection?: boolean; -} + ICompositeGestureManipulatorInitialValues {} export function newInstance( initialValues?: IGestureCameraManipulatorInitialValues diff --git a/Sources/Interaction/Manipulators/KeyboardCameraManipulator/index.d.ts b/Sources/Interaction/Manipulators/KeyboardCameraManipulator/index.d.ts index f67920f3bd3..ad5dcc2ef07 100644 --- a/Sources/Interaction/Manipulators/KeyboardCameraManipulator/index.d.ts +++ b/Sources/Interaction/Manipulators/KeyboardCameraManipulator/index.d.ts @@ -1,4 +1,4 @@ -import { Vector3 } from '../../../types'; +import { Vector3, Nullable } from '../../../types'; import { vtkObject } from '../../../interfaces'; import vtkCompositeKeyboardManipulator from '../CompositeKeyboardManipulator'; import vtkRenderWindowInteractor from '../../../Rendering/Core/RenderWindowInteractor'; @@ -7,6 +7,105 @@ import vtkRenderer from '../../../Rendering/Core/Renderer'; export interface vtkKeyboardCameraManipulator extends vtkObject, vtkCompositeKeyboardManipulator { + /** + * Get the movement speed. + */ + getMovementSpeed(): Nullable; + + /** + * Set the movement speed. + * @param speed + */ + setMovementSpeed(speed: number): boolean; + + /** + * Get the keys that trigger a forward movement. + */ + getMoveForwardKeys(): KeyboardEvent['key'][]; + + /** + * Set the keys that trigger a forward movement. + * @param keys + */ + setMoveForwardKeys(keys: KeyboardEvent['key'][]): boolean; + + /** + * Get the keys that trigger a leftward movement. + */ + getMoveLeftKeys(): KeyboardEvent['key'][]; + + /** + * Set the keys that trigger a leftward movement. + * @param keys + */ + setMoveLeftKeys(keys: KeyboardEvent['key'][]): boolean; + + /** + * Get the keys that trigger a backward movement. + */ + getMoveBackwardKeys(): KeyboardEvent['key'][]; + + /** + * Set the keys that trigger a backward movement. + * @param keys + */ + setMoveBackwardKeys(keys: KeyboardEvent['key'][]): boolean; + + /** + * Get the keys that trigger a rightward movement. + */ + getMoveRightKeys(): KeyboardEvent['key'][]; + + /** + * Set the keys that trigger a rightward movement. + * @param keys + */ + setMoveRightKeys(keys: KeyboardEvent['key'][]): boolean; + + /** + * Get the keys that trigger an upward movement. + */ + getMoveUpKeys(): KeyboardEvent['key'][]; + + /** + * Set the keys that trigger an upward movement. + * @param keys + */ + setMoveUpKeys(keys: KeyboardEvent['key'][]): boolean; + + /** + * Get the keys that trigger a downward movement. + */ + getMoveDownKeys(): KeyboardEvent['key'][]; + + /** + * Set the keys that trigger a downward movement. + * @param keys + */ + setMoveDownKeys(keys: KeyboardEvent['key'][]): boolean; + + /** + * Get the interactor associated with the current movement. + */ + getInteractor(): Nullable; + + /** + * Set the interactor associated with the current movement. + * @param interactor + */ + setInteractor(interactor: vtkRenderWindowInteractor): boolean; + + /** + * Get the renderer associated with the current movement. + */ + getRenderer(): Nullable; + + /** + * Set the renderer associated with the current movement. + * @param renderer + */ + setRenderer(renderer: vtkRenderer): boolean; + /** * Returns whether a movement is ongoing. */ @@ -37,7 +136,10 @@ export interface vtkKeyboardCameraManipulator * @param key the movedkey * @param camera the camera */ - getDirectionFromKey(key: KeyboardEvent['key'], camera: vtkCamera): Vector3; + getDirectionFromKey( + key: KeyboardEvent['key'], + camera: vtkCamera + ): Vector3 | undefined; /** * Moves the given camera, in the given direction, at the given speed. @@ -85,6 +187,8 @@ export interface vtkKeyboardCameraManipulator } export interface IKeyboardCameraManipulatorInitialValues { + interactor?: vtkRenderWindowInteractor; + renderer?: vtkRenderer; movementSpeed?: number; moveForwardKeys?: KeyboardEvent['key'][]; moveLeftKeys?: KeyboardEvent['key'][]; diff --git a/Sources/Interaction/Manipulators/MouseBoxSelectorManipulator/index.d.ts b/Sources/Interaction/Manipulators/MouseBoxSelectorManipulator/index.d.ts index 5359ebdb2e9..ccf663d5aa6 100644 --- a/Sources/Interaction/Manipulators/MouseBoxSelectorManipulator/index.d.ts +++ b/Sources/Interaction/Manipulators/MouseBoxSelectorManipulator/index.d.ts @@ -2,7 +2,6 @@ import vtkCompositeMouseManipulator, { ICompositeMouseManipulatorInitialValues, } from '../CompositeMouseManipulator'; import { EventHandler, vtkObject, vtkSubscription } from '../../../interfaces'; -import { Nullable } from '../../../types'; export interface vtkMouseBoxSelectorManipulator extends vtkObject, vtkCompositeMouseManipulator { @@ -59,11 +58,23 @@ export interface vtkMouseBoxSelectorManipulator /** * Gets the box container. */ - getContainer(): Nullable; + getContainer(): Element | undefined; + + /** + * Sets whether the box changes on click. + * @param boxChangeOnClick + */ + setBoxChangeOnClick(boxChangeOnClick: boolean): boolean; + + /** + * Gets whether the box changes on click. + */ + getBoxChangeOnClick(): boolean; } export interface IMouseBoxSelectorManipulatorInitialValues extends ICompositeMouseManipulatorInitialValues { renderSelection?: boolean; + boxChangeOnClick?: boolean; selectionStyle?: Record; container?: Element; } diff --git a/Sources/Interaction/Manipulators/MouseCameraAxisRotateManipulator/index.d.ts b/Sources/Interaction/Manipulators/MouseCameraAxisRotateManipulator/index.d.ts new file mode 100644 index 00000000000..2255c55f561 --- /dev/null +++ b/Sources/Interaction/Manipulators/MouseCameraAxisRotateManipulator/index.d.ts @@ -0,0 +1,68 @@ +import vtkCompositeCameraManipulator, { + ICompositeCameraManipulatorInitialValues, +} from '../CompositeCameraManipulator'; +import vtkCompositeMouseManipulator, { + ICompositeMouseManipulatorInitialValues, +} from '../CompositeMouseManipulator'; +import { vtkObject } from '../../../interfaces'; +import { Vector3 } from '../../../types'; + +export interface vtkMouseCameraAxisRotateManipulator + extends + vtkObject, + vtkCompositeCameraManipulator, + vtkCompositeMouseManipulator { + /** + * Gets the axis the camera is rotated around. + */ + getRotationAxis(): Vector3; + + /** + * Sets the axis the camera is rotated around. + * @param rotationAxis + */ + setRotationAxis(rotationAxis: Vector3): boolean; + + /** + * Gets whether the elevation is constrained to the positive half of the + * rotation axis. + */ + getUseHalfAxis(): boolean; + + /** + * Sets whether the elevation is constrained to the positive half of the + * rotation axis. + * @param useHalfAxis + */ + setUseHalfAxis(useHalfAxis: boolean): boolean; +} + +export interface IMouseCameraAxisRotateManipulatorInitialValues + extends + ICompositeCameraManipulatorInitialValues, + ICompositeMouseManipulatorInitialValues { + rotationAxis?: Vector3; + useHalfAxis?: boolean; +} + +export function newInstance( + initialValues?: IMouseCameraAxisRotateManipulatorInitialValues +): vtkMouseCameraAxisRotateManipulator; + +export function extend( + publicAPI: object, + model: object, + initialValues?: IMouseCameraAxisRotateManipulatorInitialValues +): void; + +/** + * Rotates the camera around a fixed axis passing through the manipulator + * center: horizontal drags azimuth around that axis, vertical drags elevate + * towards it. + */ +export declare const vtkMouseCameraAxisRotateManipulator: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkMouseCameraAxisRotateManipulator; diff --git a/Sources/Interaction/Manipulators/MouseCameraSliceManipulator/index.d.ts b/Sources/Interaction/Manipulators/MouseCameraSliceManipulator/index.d.ts new file mode 100644 index 00000000000..d04cfb60ff2 --- /dev/null +++ b/Sources/Interaction/Manipulators/MouseCameraSliceManipulator/index.d.ts @@ -0,0 +1,39 @@ +import vtkCompositeCameraManipulator, { + ICompositeCameraManipulatorInitialValues, +} from '../CompositeCameraManipulator'; +import vtkCompositeMouseManipulator, { + ICompositeMouseManipulatorInitialValues, +} from '../CompositeMouseManipulator'; +import { vtkObject } from '../../../interfaces'; + +export interface vtkMouseCameraSliceManipulator + extends + vtkObject, + vtkCompositeCameraManipulator, + vtkCompositeMouseManipulator {} + +export interface IMouseCameraSliceManipulatorInitialValues + extends + ICompositeCameraManipulatorInitialValues, + ICompositeMouseManipulatorInitialValues {} + +export function newInstance( + initialValues?: IMouseCameraSliceManipulatorInitialValues +): vtkMouseCameraSliceManipulator; + +export function extend( + publicAPI: object, + model: object, + initialValues?: IMouseCameraSliceManipulatorInitialValues +): void; + +/** + * Slices through a volume by moving the camera along its view direction, + * clamped to the active camera clipping range. + */ +export declare const vtkMouseCameraSliceManipulator: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkMouseCameraSliceManipulator; diff --git a/Sources/Interaction/Manipulators/MouseCameraTrackballFirstPersonManipulator/index.d.ts b/Sources/Interaction/Manipulators/MouseCameraTrackballFirstPersonManipulator/index.d.ts new file mode 100644 index 00000000000..7dfdb5f8bf4 --- /dev/null +++ b/Sources/Interaction/Manipulators/MouseCameraTrackballFirstPersonManipulator/index.d.ts @@ -0,0 +1,84 @@ +import vtkCompositeCameraManipulator, { + ICompositeCameraManipulatorInitialValues, +} from '../CompositeCameraManipulator'; +import vtkCompositeMouseManipulator, { + ICompositeMouseManipulatorInitialValues, +} from '../CompositeMouseManipulator'; +import { vtkObject } from '../../../interfaces'; + +export interface vtkMouseCameraTrackballFirstPersonManipulator + extends + vtkObject, + vtkCompositeCameraManipulator, + vtkCompositeMouseManipulator { + /** + * Yaws and pitches the camera, spread over `numAnimationSteps` animation + * frames. + * @param yaw yaw in degrees + * @param pitch pitch in degrees + */ + moveCamera(yaw: number, pitch: number): void; + + /** + * Gets the number of animation steps a camera move is spread over. + */ + getNumAnimationSteps(): number; + + /** + * Sets the number of animation steps a camera move is spread over. + * @param numAnimationSteps + */ + setNumAnimationSteps(numAnimationSteps: number): boolean; + + /** + * Gets the factor applied to the mouse movement. + */ + getSensitivity(): number; + + /** + * Sets the factor applied to the mouse movement. + * @param sensitivity + */ + setSensitivity(sensitivity: number): boolean; + + /** + * Gets whether the pointer is locked on button down. + */ + getUsePointerLock(): boolean; + + /** + * Sets whether the pointer is locked on button down. + * @param usePointerLock + */ + setUsePointerLock(usePointerLock: boolean): boolean; +} + +export interface IMouseCameraTrackballFirstPersonManipulatorInitialValues + extends + ICompositeCameraManipulatorInitialValues, + ICompositeMouseManipulatorInitialValues { + numAnimationSteps?: number; + sensitivity?: number; + usePointerLock?: boolean; +} + +export function newInstance( + initialValues?: IMouseCameraTrackballFirstPersonManipulatorInitialValues +): vtkMouseCameraTrackballFirstPersonManipulator; + +export function extend( + publicAPI: object, + model: object, + initialValues?: IMouseCameraTrackballFirstPersonManipulatorInitialValues +): void; + +/** + * First-person style camera control: mouse movement yaws and pitches the + * camera in place, optionally using pointer lock. + */ +export declare const vtkMouseCameraTrackballFirstPersonManipulator: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkMouseCameraTrackballFirstPersonManipulator; diff --git a/Sources/Interaction/Manipulators/MouseCameraTrackballPanManipulatorAutoCenter/index.d.ts b/Sources/Interaction/Manipulators/MouseCameraTrackballPanManipulatorAutoCenter/index.d.ts new file mode 100644 index 00000000000..47f36f909fc --- /dev/null +++ b/Sources/Interaction/Manipulators/MouseCameraTrackballPanManipulatorAutoCenter/index.d.ts @@ -0,0 +1,30 @@ +import vtkMouseCameraTrackballPanManipulator, { + IMouseCameraTrackballPanManipulatorInitialValues, +} from '../MouseCameraTrackballPanManipulator'; + +export interface vtkMouseCameraTrackballPanManipulatorAutoCenter extends vtkMouseCameraTrackballPanManipulator {} + +export interface IMouseCameraTrackballPanManipulatorAutoCenterInitialValues extends IMouseCameraTrackballPanManipulatorInitialValues {} + +export function newInstance( + initialValues?: IMouseCameraTrackballPanManipulatorAutoCenterInitialValues +): vtkMouseCameraTrackballPanManipulatorAutoCenter; + +export function extend( + publicAPI: object, + model: object, + initialValues?: IMouseCameraTrackballPanManipulatorAutoCenterInitialValues +): void; + +/** + * Pan manipulator that moves the center of rotation along with the camera, so + * that a subsequent rotation keeps orbiting the point the pan ended on. The + * new center is pushed both to the manipulator and, when it exposes + * `setCenterOfRotation`, to the interactor style. + */ +export declare const vtkMouseCameraTrackballPanManipulatorAutoCenter: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkMouseCameraTrackballPanManipulatorAutoCenter; diff --git a/Sources/Interaction/Manipulators/MouseCameraTrackballRotateManipulator/index.d.ts b/Sources/Interaction/Manipulators/MouseCameraTrackballRotateManipulator/index.d.ts index 9c60600756f..f072c441a00 100644 --- a/Sources/Interaction/Manipulators/MouseCameraTrackballRotateManipulator/index.d.ts +++ b/Sources/Interaction/Manipulators/MouseCameraTrackballRotateManipulator/index.d.ts @@ -12,6 +12,11 @@ export interface vtkMouseCameraTrackballRotateManipulator vtkObject, vtkCompositeCameraManipulator, vtkCompositeMouseManipulator { + /** + * Get whether to use a given world-up vector. + */ + getUseWorldUpVec(): boolean; + /** * Sets whether to use a given world-up vector. * @param use boolean @@ -25,11 +30,22 @@ export interface vtkMouseCameraTrackballRotateManipulator setWorldUpVec(vec: Vector3): boolean; setWorldUpVec(x: number, y: number, z: number): boolean; + /** + * Sets the world-up vector from an array. + * @param worldUpVec the world-up vector + */ + setWorldUpVecFrom(worldUpVec: Vector3): void; + /** * Gets the world-up vector. */ getWorldUpVec(): Vector3; + /** + * Gets the world-up vector by reference. + */ + getWorldUpVecByReference(): Vector3; + /** * Gets whether to use the focal point as the center of rotation. */ diff --git a/Sources/Interaction/Manipulators/MouseCameraUnicamManipulator/index.d.ts b/Sources/Interaction/Manipulators/MouseCameraUnicamManipulator/index.d.ts new file mode 100644 index 00000000000..ac31012d2b0 --- /dev/null +++ b/Sources/Interaction/Manipulators/MouseCameraUnicamManipulator/index.d.ts @@ -0,0 +1,102 @@ +import vtkCompositeCameraManipulator, { + ICompositeCameraManipulatorInitialValues, +} from '../CompositeCameraManipulator'; +import vtkCompositeMouseManipulator, { + ICompositeMouseManipulatorInitialValues, +} from '../CompositeMouseManipulator'; +import { vtkObject } from '../../../interfaces'; +import { Vector3 } from '../../../types'; + +export interface vtkMouseCameraUnicamManipulator + extends + vtkObject, + vtkCompositeCameraManipulator, + vtkCompositeMouseManipulator { + /** + * Gets whether the delegate rotate manipulator keeps the camera view up + * aligned with the world up vector. + */ + getUseWorldUpVec(): boolean; + + /** + * Sets whether the delegate rotate manipulator keeps the camera view up + * aligned with the world up vector. + * @param useWorldUpVec + */ + setUseWorldUpVec(useWorldUpVec: boolean): void; + + /** + * Gets the world up vector of the delegate rotate manipulator. + */ + getWorldUpVec(): Vector3; + + /** + * Sets the world up vector of the delegate rotate manipulator. + * @param x + * @param y + * @param z + */ + setWorldUpVec(x: number, y: number, z: number): void; + + /** + * Gets whether the delegate rotate manipulator uses the hardware selector. + */ + getUseHardwareSelector(): boolean; + + /** + * Sets whether the delegate rotate manipulator uses the hardware selector. + * @param useHardwareSelector + */ + setUseHardwareSelector(useHardwareSelector: boolean): void; + + /** + * Reads the focus sphere color of the delegate rotate manipulator. + */ + getFocusSphereColor(): void; + + /** + * Sets the focus sphere color of the delegate rotate manipulator. + * @param r + * @param g + * @param b + */ + setFocusSphereColor(r: number, g: number, b: number): void; + + /** + * Gets the focus sphere radius factor of the delegate rotate manipulator. + */ + getFocusSphereRadiusFactor(): number; + + /** + * Sets the focus sphere radius factor of the delegate rotate manipulator. + * @param focusSphereRadiusFactor + */ + setFocusSphereRadiusFactor(focusSphereRadiusFactor: number): void; +} + +export interface IMouseCameraUnicamManipulatorInitialValues + extends + ICompositeCameraManipulatorInitialValues, + ICompositeMouseManipulatorInitialValues {} + +export function newInstance( + initialValues?: IMouseCameraUnicamManipulatorInitialValues +): vtkMouseCameraUnicamManipulator; + +export function extend( + publicAPI: object, + model: object, + initialValues?: IMouseCameraUnicamManipulatorInitialValues +): void; + +/** + * Unicam camera control on a single mouse button: the initial drag direction + * chooses between rotate (delegated to vtkMouseCameraUnicamRotateManipulator), + * pan and dolly, all correlated with the point picked under the cursor. + */ +export declare const vtkMouseCameraUnicamManipulator: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkMouseCameraUnicamManipulator; diff --git a/Sources/Interaction/Manipulators/MouseCameraUnicamRotateManipulator/index.d.ts b/Sources/Interaction/Manipulators/MouseCameraUnicamRotateManipulator/index.d.ts new file mode 100644 index 00000000000..d7a0a60d253 --- /dev/null +++ b/Sources/Interaction/Manipulators/MouseCameraUnicamRotateManipulator/index.d.ts @@ -0,0 +1,149 @@ +import vtkCompositeCameraManipulator, { + ICompositeCameraManipulatorInitialValues, +} from '../CompositeCameraManipulator'; +import vtkCompositeMouseManipulator, { + ICompositeMouseManipulatorInitialValues, +} from '../CompositeMouseManipulator'; +import { States } from '../../../Rendering/Core/InteractorStyle/Constants'; +import { vtkObject } from '../../../interfaces'; +import { Vector3 } from '../../../types'; + +/** + * `macro.get(publicAPI, model, ['state'])` replaces the vtkObject `getState()` + * serializer with an accessor on the interaction state. + */ +export interface vtkMouseCameraUnicamRotateManipulator + extends + Omit, + vtkCompositeCameraManipulator, + vtkCompositeMouseManipulator { + /** + * Gets the current interaction state. + */ + getState(): States; + + /** + * Gets the world position picked on the last button down. + */ + getDownPoint(): Vector3; + + /** + * Gets the picked world position array by reference. + */ + getDownPointByReference(): Vector3; + + /** + * Gets the world up vector. + */ + getWorldUpVec(): Vector3; + + /** + * Gets the world up vector array by reference. + */ + getWorldUpVecByReference(): Vector3; + + /** + * Sets the world up vector. + * @param worldUpVec + */ + setWorldUpVec(worldUpVec: Vector3): boolean; + setWorldUpVec(x: number, y: number, z: number): boolean; + + /** + * Sets the world up vector from another array, without a copy. + * @param worldUpVec + */ + setWorldUpVecFrom(worldUpVec: Vector3): void; + + /** + * Gets whether the camera view up is kept aligned with the world up vector. + */ + getUseWorldUpVec(): boolean; + + /** + * Sets whether the camera view up is kept aligned with the world up vector. + * @param useWorldUpVec + */ + setUseWorldUpVec(useWorldUpVec: boolean): boolean; + + /** + * Gets whether the hardware selector is used to pick the down point. + */ + getUseHardwareSelector(): boolean; + + /** + * Sets whether the hardware selector is used to pick the down point. + * @param useHardwareSelector + */ + setUseHardwareSelector(useHardwareSelector: boolean): boolean; + + /** + * Gets whether the focus sphere is displayed on button down. + */ + getDisplayFocusSphereOnButtonDown(): boolean; + + /** + * Sets whether the focus sphere is displayed on button down. + * @param displayFocusSphereOnButtonDown + */ + setDisplayFocusSphereOnButtonDown( + displayFocusSphereOnButtonDown: boolean + ): boolean; + + /** + * Gets the factor scaling the apparent size of the focus sphere. + */ + getFocusSphereRadiusFactor(): number; + + /** + * Sets the factor scaling the apparent size of the focus sphere. + * @param focusSphereRadiusFactor + */ + setFocusSphereRadiusFactor(focusSphereRadiusFactor: number): boolean; + + /** + * Reads the focus sphere color from its property. + */ + getFocusSphereColor(): void; + + /** + * Sets the focus sphere color. + * @param r + * @param g + * @param b + */ + setFocusSphereColor(r: number, g: number, b: number): void; +} + +export interface IMouseCameraUnicamRotateManipulatorInitialValues + extends + ICompositeCameraManipulatorInitialValues, + ICompositeMouseManipulatorInitialValues { + focusSphereRadiusFactor?: number; + displayFocusSphereOnButtonDown?: boolean; + useHardwareSelector?: boolean; + useWorldUpVec?: boolean; + worldUpVec?: Vector3; +} + +export function newInstance( + initialValues?: IMouseCameraUnicamRotateManipulatorInitialValues +): vtkMouseCameraUnicamRotateManipulator; + +export function extend( + publicAPI: object, + model: object, + initialValues?: IMouseCameraUnicamRotateManipulatorInitialValues +): void; + +/** + * Unicam rotation: the point picked under the cursor becomes the center of a + * virtual sphere the camera is rotated on, materialized by a focus sphere + * actor added to the renderer while rotating. + */ +export declare const vtkMouseCameraUnicamRotateManipulator: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkMouseCameraUnicamRotateManipulator; diff --git a/Sources/Interaction/Manipulators/MouseRangeManipulator/index.d.ts b/Sources/Interaction/Manipulators/MouseRangeManipulator/index.d.ts index f9464665d7b..b3955b376ef 100644 --- a/Sources/Interaction/Manipulators/MouseRangeManipulator/index.d.ts +++ b/Sources/Interaction/Manipulators/MouseRangeManipulator/index.d.ts @@ -1,9 +1,13 @@ import vtkCompositeMouseManipulator, { ICompositeMouseManipulatorInitialValues, } from '../../../Interaction/Manipulators/CompositeMouseManipulator'; +import vtkRenderer from '../../../Rendering/Core/Renderer'; +import vtkRenderWindowInteractor from '../../../Rendering/Core/RenderWindowInteractor'; import { vtkObject } from '../../../interfaces'; -export interface IMouseRangeManipulatorInitialValues extends ICompositeMouseManipulatorInitialValues {} +export interface IMouseRangeManipulatorInitialValues extends ICompositeMouseManipulatorInitialValues { + usePointerLock?: boolean; +} export interface vtkMouseRangeManipulator extends vtkCompositeMouseManipulator, vtkObject { @@ -11,30 +15,65 @@ export interface vtkMouseRangeManipulator min: number, max: number, step: number, - getValue: () => number, + getValue: number | (() => number), setValue: (v: number) => void, - scale?: number - ); + scale?: number, + exponentialScroll?: boolean + ): void; setVerticalListener( min: number, max: number, step: number, - getValue: () => number, + getValue: number | (() => number), setValue: (v: number) => void, - scale?: number - ); + scale?: number, + exponentialScroll?: boolean + ): void; setScrollListener( min: number, max: number, step: number, - getValue: () => number, + getValue: number | (() => number), setValue: (v: number) => void, - scale?: number - ); - removeHorizontalListener(); - removeVerticalListener(); - removeScrollListener(); - removeAllListeners(); + scale?: number, + exponentialScroll?: boolean + ): void; + removeHorizontalListener(): void; + removeVerticalListener(): void; + removeScrollListener(): void; + removeAllListeners(): void; + + /** + * Starts listening to mouse move events while the pointer is locked. + * @param interactor the interactor + * @param renderer the renderer + */ + startPointerLockEvent( + interactor: vtkRenderWindowInteractor, + renderer: vtkRenderer + ): void; + + /** + * Handles a mouse move event while the pointer is locked. + * @param interactor the interactor + * @param renderer the renderer + * @param event the mouse event + */ + onPointerLockMove( + interactor: vtkRenderWindowInteractor, + renderer: vtkRenderer, + event: MouseEvent + ): void; + + /** + * + */ + getUsePointerLock(): boolean | undefined; + + /** + * + */ + setUsePointerLock(usePointerLock: boolean): boolean; } export function extend( diff --git a/Sources/Interaction/Manipulators/VRButtonPanManipulator/index.d.ts b/Sources/Interaction/Manipulators/VRButtonPanManipulator/index.d.ts new file mode 100644 index 00000000000..03bf8e2d177 --- /dev/null +++ b/Sources/Interaction/Manipulators/VRButtonPanManipulator/index.d.ts @@ -0,0 +1,31 @@ +import vtkCompositeVRManipulator, { + ICompositeVRManipulatorInitialValues, +} from '../CompositeVRManipulator'; +import { vtkObject } from '../../../interfaces'; + +export interface vtkVRButtonPanManipulator + extends vtkObject, vtkCompositeVRManipulator {} + +export interface IVRButtonPanManipulatorInitialValues extends ICompositeVRManipulatorInitialValues {} + +export function newInstance( + initialValues?: IVRButtonPanManipulatorInitialValues +): vtkVRButtonPanManipulator; + +export function extend( + publicAPI: object, + model: object, + initialValues?: IVRButtonPanManipulatorInitialValues +): void; + +/** + * Moves the world along the direction the VR controller points at, at a speed + * driven by the controller's second gamepad axis, while the camera pose + * interaction is active. + */ +export declare const vtkVRButtonPanManipulator: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkVRButtonPanManipulator; diff --git a/Sources/Interaction/Style/InteractorStyleImage/index.d.ts b/Sources/Interaction/Style/InteractorStyleImage/index.d.ts index 2fb428b3148..deca94070dd 100644 --- a/Sources/Interaction/Style/InteractorStyleImage/index.d.ts +++ b/Sources/Interaction/Style/InteractorStyleImage/index.d.ts @@ -22,6 +22,23 @@ export interface vtkInteractorStyleImage extends vtkInteractorStyleTrackballCame */ handleLeftButtonRelease(callData: unknown): void; + /** + * The inherited `handleMouseMove`, captured before it is overridden. + * @param callData event data + */ + superHandleMouseMove(callData: unknown): void; + + /** + * The inherited `handleLeftButtonPress`, captured before it is overridden. + * @param callData event data + */ + superHandleLeftButtonPress(callData: unknown): void; + + /** + * The inherited `handleLeftButtonRelease`, captured before it is overridden. + */ + superHandleLeftButtonRelease(): void; + /** * Handles the start of a wheel event. * @param callData event data @@ -64,29 +81,45 @@ export interface vtkInteractorStyleImage extends vtkInteractorStyleTrackballCame * -2 will return the second-to-last image, etc. * @param i image number */ - setCurrentImageNumber(i: number): boolean; + setCurrentImageNumber(i: number): void; + + /** + * Gets the current image property. + */ + getCurrentImageProperty(): vtkImageProperty | undefined; /** * Sets the current image property. * @param imageProperty image property */ - setCurrentImageProperty(imageProperty: vtkImageProperty): boolean; + setCurrentImageProperty(imageProperty: vtkImageProperty): void; + + /** + * Gets the interaction mode. + */ + getInteractionMode(): 'IMAGE2D' | 'IMAGE3D' | 'IMAGE_SLICING'; + + /** + * Sets the interaction mode. + * @param mode interaction mode + */ + setInteractionMode(mode: 'IMAGE2D' | 'IMAGE3D' | 'IMAGE_SLICING'): boolean; } export interface IInteractorStyleImageInitialValues { - windowLevelStartPosition: Vector2; - windowLevelCurrentPosition: Vector2; - lastSlicePosition: number; - windowLevelInitial: Vector2; + windowLevelStartPosition?: Vector2; + windowLevelCurrentPosition?: Vector2; + lastSlicePosition?: number; + windowLevelInitial?: Vector2; // currentImageProperty: null; - currentImageNumber: number; - interactionMode: 'IMAGE2D' | 'IMAGE3D' | 'IMAGE_SLICING'; - xViewRightVector: Vector3; - xViewUpVector: Vector3; - yViewRightVector: Vector3; - yViewUpVector: Vector3; - zViewRightVector: Vector3; - zViewUpVector: Vector3; + currentImageNumber?: number; + interactionMode?: 'IMAGE2D' | 'IMAGE3D' | 'IMAGE_SLICING'; + xViewRightVector?: Vector3; + xViewUpVector?: Vector3; + yViewRightVector?: Vector3; + yViewUpVector?: Vector3; + zViewRightVector?: Vector3; + zViewUpVector?: Vector3; } export function newInstance( diff --git a/Sources/Interaction/Style/InteractorStyleMPRSlice/index.d.ts b/Sources/Interaction/Style/InteractorStyleMPRSlice/index.d.ts new file mode 100644 index 00000000000..91c1721d812 --- /dev/null +++ b/Sources/Interaction/Style/InteractorStyleMPRSlice/index.d.ts @@ -0,0 +1,72 @@ +import vtkInteractorStyleManipulator, { + IInteractorStyleManipulatorInitialValues, +} from '../InteractorStyleManipulator'; +import vtkVolumeMapper from '../../../Rendering/Core/VolumeMapper'; +import { Nullable, Range, Vector3 } from '../../../types'; + +export interface vtkInteractorStyleMPRSlice extends vtkInteractorStyleManipulator { + /** + * Gets the mapper whose bounds define the slice range. + */ + getVolumeMapper(): Nullable | undefined; + + /** + * Sets the mapper whose bounds define the slice range, and reorients the + * camera along the current slice normal. + */ + setVolumeMapper(volumeMapper: Nullable): void; + + /** + * Gets the current slice position, measured along the slice normal. + */ + getSlice(): number; + + /** + * Moves the camera to the given slice position, clamped to the slice range. + * @param slice the slice position + */ + setSlice(slice: number): boolean; + + /** + * Gets the [min, max] slice positions spanned by the volume mapper. + */ + getSliceRange(): Range; + + /** + * Gets the slice normal, which is the camera direction of projection. + */ + getSliceNormal(): Vector3; + + /** + * Points the camera along the given world-space normal and frames the volume + * mapper bounds. + * @param normal the slice normal components + */ + setSliceNormal(...normal: number[]): void; +} + +export interface IInteractorStyleMPRSliceInitialValues extends IInteractorStyleManipulatorInitialValues { + volumeMapper?: vtkVolumeMapper; +} + +export function newInstance( + initialValues?: IInteractorStyleMPRSliceInitialValues +): vtkInteractorStyleMPRSlice; + +export function extend( + publicAPI: object, + model: object, + initialValues?: IInteractorStyleMPRSliceInitialValues +): void; + +/** + * Manipulator style for multi-planar reformat: rotate, pan and zoom + * manipulators plus a scroll manipulator bound to the slice position along the + * camera direction of projection. + */ +export declare const vtkInteractorStyleMPRSlice: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkInteractorStyleMPRSlice; diff --git a/Sources/Interaction/Style/InteractorStyleManipulator/Presets.d.ts b/Sources/Interaction/Style/InteractorStyleManipulator/Presets.d.ts new file mode 100644 index 00000000000..6502799f0ae --- /dev/null +++ b/Sources/Interaction/Style/InteractorStyleManipulator/Presets.d.ts @@ -0,0 +1,64 @@ +// Imported as '../InteractorStyleManipulator' rather than './index' so that the +// path stays valid once the ESM package flattens `/index.d.ts` to +// `.d.ts`. +import { vtkInteractorStyleManipulator } from '../InteractorStyleManipulator'; + +/** + * A single manipulator entry of a preset: the registered manipulator type name + * plus the initial values handed to its `newInstance`. + */ +export interface IManipulatorDefinition { + type: string; + options?: object; +} + +declare const vtkInteractorStyleManipulatorPresets: { + /** + * Remove every manipulator currently bound to the given style, then + * instantiate and add the manipulators described by `definitions`. Each + * instance is dispatched to `addVRManipulator`, `addGestureManipulator`, + * `addKeyboardManipulator` or `addMouseManipulator` depending on its type. + * + * @param {IManipulatorDefinition[]} definitions The manipulators to create + * @param {vtkInteractorStyleManipulator} manipulatorStyle The style to configure + */ + applyDefinitions( + definitions: IManipulatorDefinition[], + manipulatorStyle: vtkInteractorStyleManipulator + ): boolean; + + /** + * Apply a registered preset onto an interactor style. + * + * The presets shipped with vtk.js are `'3D'`, `'2D'`, `'FirstPerson'`, + * `'Unicam'`, `'zRotateTop'` and `'zRotateAll'`. + * + * @param {string} name The name of the preset + * @param {vtkInteractorStyleManipulator} manipulatorStyle The style to configure + */ + applyPreset( + name: string, + manipulatorStyle: vtkInteractorStyleManipulator + ): boolean; + + /** + * Register a manipulator class under a type name usable in definitions. + * + * @param {string} type The type name + * @param {object} classDef The manipulator class (must expose `newInstance`) + */ + registerManipulatorType(type: string, classDef: object): void; + + /** + * Register a new style preset, or override an existing one. + * + * @param {string} name The name of the preset + * @param {IManipulatorDefinition[]} definitions The manipulators of the preset + */ + registerStylePreset( + name: string, + definitions: IManipulatorDefinition[] + ): void; +}; + +export default vtkInteractorStyleManipulatorPresets; diff --git a/Sources/Interaction/Style/InteractorStyleManipulator/index.d.ts b/Sources/Interaction/Style/InteractorStyleManipulator/index.d.ts index 9d6c089fd32..1dc133a0220 100644 --- a/Sources/Interaction/Style/InteractorStyleManipulator/index.d.ts +++ b/Sources/Interaction/Style/InteractorStyleManipulator/index.d.ts @@ -3,6 +3,8 @@ import vtkCompositeKeyboardManipulator from '../../Manipulators/CompositeKeyboar import vtkCompositeMouseManipulator from '../../Manipulators/CompositeMouseManipulator'; import vtkCompositeVRManipulator from '../../Manipulators/CompositeVRManipulator'; import vtkInteractorStyle from '../../../Rendering/Core/InteractorStyle'; +import vtkRenderer from '../../../Rendering/Core/Renderer'; +import vtkRenderWindowInteractor from '../../../Rendering/Core/RenderWindowInteractor'; import { Device, Input, @@ -117,13 +119,13 @@ export interface vtkInteractorStyleManipulator extends vtkInteractorStyle { * Finds a mouse manipulator with a given control set. * @param button which button * @param shift shift enabled - * @param scroll scroll enabled + * @param control control enabled * @param alt alt enabled */ findMouseManipulator( button: MouseButton, shift: boolean, - scroll: boolean, + control: boolean, alt: boolean ): Nullable; @@ -173,6 +175,11 @@ export interface vtkInteractorStyleManipulator extends vtkInteractorStyle { */ handleRightButtonRelease(callData: unknown): void; + /** + * Handles the end of a pointer lock event. + */ + handleEndPointerLock(): void; + /** * Handles the start of a wheel event. * @param callData event data @@ -306,9 +313,9 @@ export interface vtkInteractorStyleManipulator extends vtkInteractorStyle { getRotationFactor(): number; getMouseManipulators(): vtkCompositeMouseManipulator[]; - getMouseManipulators(): vtkCompositeMouseManipulator[]; - getMouseManipulators(): vtkCompositeMouseManipulator[]; - getMouseManipulators(): vtkCompositeMouseManipulator[]; + getKeyboardManipulators(): vtkCompositeKeyboardManipulator[]; + getVrManipulators(): vtkCompositeVRManipulator[]; + getGestureManipulators(): vtkCompositeGestureManipulator[]; /** * Sets the center of rotation @@ -319,11 +326,23 @@ export interface vtkInteractorStyleManipulator extends vtkInteractorStyle { setCenterOfRotation(x: number, y: number, z: number): boolean; setCenterOfRotation(xyz: Vector3): boolean; + /** + * Sets the center of rotation from an array. + * @param {Vector3} xyz + */ + setCenterOfRotationFrom(centerOfRotation: Vector3): void; + /** * Gets the center of rotation. * @returns {Vector3} */ getCenterOfRotation(): Vector3; + + /** + * Gets the center of rotation by reference. + * @returns {Vector3} + */ + getCenterOfRotationByReference(): Vector3; } export interface IInteractorStyleManipulatorInitialValues { @@ -331,6 +350,28 @@ export interface IInteractorStyleManipulatorInitialValues { rotationFactor?: number; } +declare function translateCamera( + renderer: vtkRenderer, + rwi: vtkRenderWindowInteractor, + toX: number, + toY: number, + fromX: number, + fromY: number +): void; + +declare function dollyToPosition( + fact: number, + position: { x: number; y: number }, + renderer: vtkRenderer, + rwi: vtkRenderWindowInteractor +): void; + +declare function dollyByFactor( + interactor: vtkRenderWindowInteractor, + renderer: vtkRenderer, + factor: number +): void; + export function newInstance( initialValues?: IInteractorStyleManipulatorInitialValues ): vtkInteractorStyleManipulator; @@ -341,9 +382,18 @@ export function extend( initialValues?: IInteractorStyleManipulatorInitialValues ): void; +export declare const STATIC: Readonly<{ + dollyToPosition: typeof dollyToPosition; + translateCamera: typeof translateCamera; + dollyByFactor: typeof dollyByFactor; +}>; + export const vtkInteractorStyleManipulator: { newInstance: typeof newInstance; extend: typeof extend; + dollyToPosition: typeof dollyToPosition; + translateCamera: typeof translateCamera; + dollyByFactor: typeof dollyByFactor; }; export default vtkInteractorStyleManipulator; diff --git a/Sources/Interaction/Style/InteractorStyleRemoteMouse/index.d.ts b/Sources/Interaction/Style/InteractorStyleRemoteMouse/index.d.ts new file mode 100644 index 00000000000..2f72b54ea48 --- /dev/null +++ b/Sources/Interaction/Style/InteractorStyleRemoteMouse/index.d.ts @@ -0,0 +1,238 @@ +import vtkInteractorStyle, { + IInteractorStyleInitialValues, +} from '../../../Rendering/Core/InteractorStyle'; +import { vtkSubscription } from '../../../interfaces'; + +/** + * Mouse state forwarded to the remote peer. Positions are normalized against + * the view size. The button and modifier flags are 0 or 1. Any extra field of + * `remoteEventAddOn` is merged in. + */ +export interface IRemoteMouseEvent { + action: 'down' | 'up'; + x: number; + y: number; + buttonLeft: number; + buttonMiddle: number; + buttonRight: number; + shiftKey: number; + altKey: number; + ctrlKey: number; + metaKey: number; + [key: string]: unknown; +} + +export interface IRemoteWheelEvent extends Partial { + type: 'StartMouseWheel' | 'MouseWheel' | 'EndMouseWheel'; + spinY?: number; +} + +export interface IRemoteGestureEvent { + type: + | 'StartPinch' + | 'Pinch' + | 'EndPinch' + | 'StartRotate' + | 'Rotate' + | 'EndRotate' + | 'StartPan' + | 'Pan' + | 'EndPan'; + scale?: number; + rotation?: number; + translation?: { x: number; y: number }; + [key: string]: unknown; +} + +export interface vtkInteractorStyleRemoteMouse extends vtkInteractorStyle { + /** + * @param callData event data + */ + handleLeftButtonPress(callData: unknown): void; + + /** + * @param callData event data + */ + handleMiddleButtonPress(callData: unknown): void; + + /** + * @param callData event data + */ + handleRightButtonPress(callData: unknown): void; + + /** + * @param callData event data + */ + handleLeftButtonRelease(callData: unknown): void; + + /** + * @param callData event data + */ + handleMiddleButtonRelease(callData: unknown): void; + + /** + * @param callData event data + */ + handleRightButtonRelease(callData: unknown): void; + + /** + * @param callData event data + */ + handleMouseMove(callData: unknown): void; + + /** + * @param callData event data + */ + handleStartMouseWheel(callData: unknown): void; + + /** + * @param callData event data + */ + handleMouseWheel(callData: unknown): void; + + /** + * @param callData event data + */ + handleStartPinch(callData: unknown): void; + + /** + * @param callData event data + */ + handlePinch(callData: unknown): void; + + /** + * @param callData event data + */ + handleStartRotate(callData: unknown): void; + + /** + * @param callData event data + */ + handleRotate(callData: unknown): void; + + /** + * @param callData event data + */ + handleStartPan(callData: unknown): void; + + /** + * @param callData event data + */ + handlePan(callData: unknown): void; + + handleEndMouseWheel(): void; + + handleEndPinch(): void; + + handleEndRotate(): void; + + handleEndPan(): void; + /** + * Handles a button down event. + * @param button which button + * @param callData event data + */ + onButtonDown(button: number, callData: unknown): void; + + /** + * Handles a button up event. + * @param button which button + * @param callData event data + */ + onButtonUp(button: number, callData: unknown): void; + + invokeRemoteMouseEvent(event: IRemoteMouseEvent): void; + onRemoteMouseEvent( + cb: (event: IRemoteMouseEvent) => void, + priority?: number + ): vtkSubscription; + + invokeRemoteWheelEvent(event: IRemoteWheelEvent): void; + onRemoteWheelEvent( + cb: (event: IRemoteWheelEvent) => void, + priority?: number + ): vtkSubscription; + + invokeRemoteGestureEvent(event: IRemoteGestureEvent): void; + onRemoteGestureEvent( + cb: (event: IRemoteGestureEvent) => void, + priority?: number + ): vtkSubscription; + + /** + * Gets whether mouse moves are forwarded even when no button is pressed. + */ + getSendMouseMove(): boolean; + + /** + * Sets whether mouse moves are forwarded even when no button is pressed. + * @param sendMouseMove + */ + setSendMouseMove(sendMouseMove: boolean): boolean; + + /** + * Gets the extra fields merged into every forwarded event. + */ + getRemoteEventAddOn(): object | undefined; + + /** + * Sets the extra fields merged into every forwarded event. + * @param remoteEventAddOn + */ + setRemoteEventAddOn(remoteEventAddOn: object): boolean; + + /** + * Gets the minimum delay, in milliseconds, between two forwarded mouse + * moves. + */ + getThrottleDelay(): number; + + /** + * Sets the minimum delay, in milliseconds, between two forwarded mouse + * moves. + * @param throttleDelay + */ + setThrottleDelay(throttleDelay: number): boolean; + + /** + * Gets the minimum delay, in milliseconds, between two forwarded wheel + * events. Zero disables throttling. + */ + getWheelThrottleDelay(): number; + + /** + * Sets the minimum delay, in milliseconds, between two forwarded wheel + * events. Zero disables throttling. + * @param wheelThrottleDelay + */ + setWheelThrottleDelay(wheelThrottleDelay: number): boolean; +} + +export interface IInteractorStyleRemoteMouseInitialValues extends IInteractorStyleInitialValues { + sendMouseMove?: boolean; + remoteEventAddOn?: object; + throttleDelay?: number; + wheelThrottleDelay?: number; +} + +export function newInstance( + initialValues?: IInteractorStyleRemoteMouseInitialValues +): vtkInteractorStyleRemoteMouse; + +export function extend( + publicAPI: object, + model: object, + initialValues?: IInteractorStyleRemoteMouseInitialValues +): void; + +/** + * Interactor style that does not act on the local camera but re-emits mouse, + * wheel and gesture interactions as events meant to be forwarded to a remote + * renderer. + */ +export declare const vtkInteractorStyleRemoteMouse: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkInteractorStyleRemoteMouse; diff --git a/Sources/Interaction/Style/InteractorStyleTrackballCamera/index.d.ts b/Sources/Interaction/Style/InteractorStyleTrackballCamera/index.d.ts index 0ab371364c1..0b51abdde92 100644 --- a/Sources/Interaction/Style/InteractorStyleTrackballCamera/index.d.ts +++ b/Sources/Interaction/Style/InteractorStyleTrackballCamera/index.d.ts @@ -156,11 +156,33 @@ export interface vtkInteractorStyleTrackballCamera extends vtkInteractorStyle { * @param factor factor */ dollyByFactor(renderer: vtkRenderer, factor: number): void; + + /** + * Gets the motion factor. + */ + getMotionFactor(): number; + + /** + * Sets the motion factor. + * @param factor motion factor + */ + setMotionFactor(factor: number): boolean; + + /** + * Gets the zoom factor. + */ + getZoomFactor(): number; + + /** + * Sets the zoom factor. + * @param factor zoom factor + */ + setZoomFactor(factor: number): boolean; } export interface IInteractorStyleTrackballCameraInitialValues { - motionFactor: number; - zoomFactor: number; + motionFactor?: number; + zoomFactor?: number; } export function newInstance( diff --git a/Sources/Interaction/Style/InteractorStyleUnicam/index.d.ts b/Sources/Interaction/Style/InteractorStyleUnicam/index.d.ts new file mode 100644 index 00000000000..49a9f14e19e --- /dev/null +++ b/Sources/Interaction/Style/InteractorStyleUnicam/index.d.ts @@ -0,0 +1,90 @@ +import vtkInteractorStyleManipulator, { + IInteractorStyleManipulatorInitialValues, +} from '../InteractorStyleManipulator'; +import { Vector3 } from '../../../types'; + +export interface vtkInteractorStyleUnicam extends vtkInteractorStyleManipulator { + /** + * Gets whether the unicam manipulator keeps the camera view up aligned with + * the world up vector. + */ + getUseWorldUpVec(): boolean; + + /** + * Sets whether the unicam manipulator keeps the camera view up aligned with + * the world up vector. + * @param useWorldUpVec + */ + setUseWorldUpVec(useWorldUpVec: boolean): void; + + /** + * Gets the world up vector of the unicam manipulator. + */ + getWorldUpVec(): Vector3; + + /** + * Sets the world up vector of the unicam manipulator. + * @param x + * @param y + * @param z + */ + setWorldUpVec(x: number, y: number, z: number): void; + + /** + * Gets whether the unicam manipulator uses the hardware selector. + */ + getUseHardwareSelector(): boolean; + + /** + * Sets whether the unicam manipulator uses the hardware selector. + * @param useHardwareSelector + */ + setUseHardwareSelector(useHardwareSelector: boolean): void; + + /** + * Reads the focus sphere color of the unicam manipulator. + */ + getFocusSphereColor(): void; + + /** + * Sets the focus sphere color of the unicam manipulator. + * @param r + * @param g + * @param b + */ + setFocusSphereColor(r: number, g: number, b: number): void; + + /** + * Gets the focus sphere radius factor of the unicam manipulator. + */ + getFocusSphereRadiusFactor(): number; + + /** + * Sets the focus sphere radius factor of the unicam manipulator. + * @param focusSphereRadiusFactor + */ + setFocusSphereRadiusFactor(focusSphereRadiusFactor: number): void; +} + +export interface IInteractorStyleUnicamInitialValues extends IInteractorStyleManipulatorInitialValues {} + +export function newInstance( + initialValues?: IInteractorStyleUnicamInitialValues +): vtkInteractorStyleUnicam; + +export function extend( + publicAPI: object, + model: object, + initialValues?: IInteractorStyleUnicamInitialValues +): void; + +/** + * Manipulator style preconfigured with a single vtkMouseCameraUnicamManipulator + * on the left button, and forwarding that manipulator's settings. + */ +export declare const vtkInteractorStyleUnicam: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkInteractorStyleUnicam; diff --git a/Sources/Interaction/UI/CornerAnnotation/index.d.ts b/Sources/Interaction/UI/CornerAnnotation/index.d.ts new file mode 100644 index 00000000000..d3bb40346ff --- /dev/null +++ b/Sources/Interaction/UI/CornerAnnotation/index.d.ts @@ -0,0 +1,127 @@ +import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; + +/** + * Keys accepted by the template map, one per corner / side of the container. + */ +export type CornerAnnotationCorner = + | 'nw' + | 'n' + | 'ne' + | 'w' + | 'e' + | 'sw' + | 's' + | 'se'; + +export type CornerAnnotationMetadata = Record; + +export type CornerAnnotationTemplate = ( + metadata: CornerAnnotationMetadata +) => string; + +export type ICornerAnnotationTemplates = Partial< + Record +>; + +export interface ICornerAnnotationInitialValues { + templates?: Nullable; + metadata?: Nullable; +} + +export interface vtkCornerAnnotation extends vtkObject { + /** + * Root element holding the nine annotation slots. + */ + getAnnotationContainer(): HTMLElement; + + getNorthWestContainer(): HTMLElement; + + getNorthContainer(): HTMLElement; + + getNorthEastContainer(): HTMLElement; + + getWestContainer(): HTMLElement; + + getEastContainer(): HTMLElement; + + getSouthWestContainer(): HTMLElement; + + getSouthContainer(): HTMLElement; + + getSouthEastContainer(): HTMLElement; + + getMetadata(): CornerAnnotationMetadata; + + /** + * Attach the annotation container to the given DOM element, detaching it + * from any previously set one. + * @param el + */ + setContainer(el: Nullable): void; + + /** + * No-op kept for API symmetry with the other UI widgets. + */ + resize(): void; + + /** + * Merge the given templates into the current ones and re-render. + * @param {ICornerAnnotationTemplates} templates + */ + updateTemplates(templates: ICornerAnnotationTemplates): void; + + /** + * Merge the given metadata into the current one and re-render. + * @param {CornerAnnotationMetadata} metadata + */ + updateMetadata(metadata: CornerAnnotationMetadata): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with + * vtkCornerAnnotation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ICornerAnnotationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ICornerAnnotationInitialValues +): void; + +/** + * Method used to create a new instance of vtkCornerAnnotation. + * @param {ICornerAnnotationInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: ICornerAnnotationInitialValues +): vtkCornerAnnotation; + +/** + * Replace every `${path}` occurrence of the template by the value found at + * that dotted path inside `map`. + * + * @param template the string containing `${...}` placeholders + * @param map the object to resolve the placeholder paths against + * @param {String} [fallback] value used when a path cannot be resolved + */ +declare function applyTemplate( + template: string, + map: Record, + fallback?: string +): string; + +/** + * vtkCornerAnnotation is a DOM overlay that displays text in the four corners + * and the four sides of a container. Each slot is filled by a template + * function evaluated against the annotation metadata. + */ +export declare const vtkCornerAnnotation: { + newInstance: typeof newInstance; + extend: typeof extend; + applyTemplate: typeof applyTemplate; +}; +export default vtkCornerAnnotation; diff --git a/Sources/Interaction/UI/FPSMonitor/index.d.ts b/Sources/Interaction/UI/FPSMonitor/index.d.ts new file mode 100644 index 00000000000..0fbf7050227 --- /dev/null +++ b/Sources/Interaction/UI/FPSMonitor/index.d.ts @@ -0,0 +1,133 @@ +import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; +import vtkRenderWindow from '../../../Rendering/Core/RenderWindow'; + +export interface IFPSMonitorInitialValues { + bufferSize?: number; + graphHeight?: number; + buffer?: number[]; + fpsSum?: number; + /** + * CSS class applied to the monitor container to lay it out horizontally or + * vertically. + */ + orientationClass?: string; + canvasVisibility?: boolean; + titleVisibility?: boolean; + infoVisibility?: boolean; +} + +export interface vtkFPSMonitor extends vtkObject { + /** + * Root element of the monitor. + */ + getFpsMonitorContainer(): HTMLElement; + + getRenderWindow(): Nullable; + + /** + * Extra key/value pairs merged into the render window statistics listing. + */ + getAddOnStats(): Nullable>; + + getBufferSize(): number; + + setBufferSize(bufferSize: number): boolean; + + getCanvasVisibility(): boolean; + + setCanvasVisibility(canvasVisibility: boolean): boolean; + + getInfoVisibility(): boolean; + + setInfoVisibility(infoVisibility: boolean): boolean; + + getTitleVisibility(): boolean; + + setTitleVisibility(titleVisibility: boolean): boolean; + + /** + * Redraw the title, the statistics listing and the graph. + */ + render(): void; + + /** + * Alias of render(). + */ + update(): void; + + /** + * Listen to the animation events of the render window interactor to sample + * the frame rate. Passing null unsubscribes. + * @param rw + */ + setRenderWindow(rw: Nullable): void; + + /** + * Attach the monitor to the given DOM element, detaching it from any + * previously set one. + * @param el + */ + setContainer(el: Nullable): void; + + /** + * No-op kept for API symmetry with the other UI widgets. + */ + resize(): void; + + setOrientationToHorizontal(): void; + + setOrientationToVertical(): void; + + /** + * Any mode other than 'horizontal' selects the vertical layout. + * @param {String} [mode] (default: 'horizontal') + */ + setOrientation(mode?: 'horizontal' | 'vertical'): void; + + /** + * Merge extra statistics into the ones reported by the render window. + * @param addOn + */ + setAddOnStats(addOn: Record): void; + + /** + * @param {Boolean} [title] (default: true) + * @param {Boolean} [graph] (default: true) + * @param {Boolean} [info] (default: true) + */ + setMonitorVisibility(title?: boolean, graph?: boolean, info?: boolean): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkFPSMonitor + * characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IFPSMonitorInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IFPSMonitorInitialValues +): void; + +/** + * Method used to create a new instance of vtkFPSMonitor. + * @param {IFPSMonitorInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IFPSMonitorInitialValues +): vtkFPSMonitor; + +/** + * vtkFPSMonitor is a DOM overlay reporting the mean and current frame rate of + * a render window, a rolling graph of the last frames and the render window + * statistics. + */ +export declare const vtkFPSMonitor: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkFPSMonitor; diff --git a/Sources/Interaction/UI/Slider/Constants.d.ts b/Sources/Interaction/UI/Slider/Constants.d.ts new file mode 100644 index 00000000000..873ecec2fcc --- /dev/null +++ b/Sources/Interaction/UI/Slider/Constants.d.ts @@ -0,0 +1,12 @@ +export declare const SliderOrientation: { + readonly VERTICAL: 0; + readonly HORIZONTAL: 1; +}; + +export type SliderOrientation = + (typeof SliderOrientation)[keyof typeof SliderOrientation]; + +declare const _default: { + SliderOrientation: typeof SliderOrientation; +}; +export default _default; diff --git a/Sources/Interaction/UI/Slider/index.d.ts b/Sources/Interaction/UI/Slider/index.d.ts new file mode 100644 index 00000000000..92ffdc9446c --- /dev/null +++ b/Sources/Interaction/UI/Slider/index.d.ts @@ -0,0 +1,108 @@ +import { vtkObject, vtkSubscription } from '../../../interfaces'; +import { Nullable, Vector2 } from '../../../types'; +import { SliderOrientation } from './Constants'; + +export interface ISliderInitialValues { + orientation?: SliderOrientation; + value?: number; + values?: number[]; + /** + * Distance between the first and the last of `values`. + */ + range?: number; + /** + * [cursor size, track size] in pixels, recomputed on resize(). + */ + containerSizes?: Vector2; + cursorStyle?: Partial; +} + +export interface vtkSlider extends vtkObject { + getOrientation(): SliderOrientation; + + setOrientation(orientation: SliderOrientation): boolean; + + getValue(): number; + + getValues(): number[]; + + /** + * Attach the slider cursor to the given DOM element and bind the mouse + * listeners on it. Passing null detaches and unbinds. + * @param el + */ + setContainer(el: Nullable): void; + + /** + * Recompute the orientation and the cursor size from the container size. + */ + resize(): void; + + /** + * Move the cursor to the given value. The value is ignored when it falls + * outside of the current values range. + * @param {Number} v + * @return true when the value changed + */ + setValue(v: number): boolean; + + /** + * Replace the set of values the cursor can snap to. + * @param {Number[]} values + */ + setValues(values: number[]): void; + + /** + * Build `nbSteps` evenly spaced values between min and max and use them as + * the slider values. + * @param {Number} min + * @param {Number} max + * @param {Number} nbSteps + */ + generateValues(min: number, max: number, nbSteps: number): void; + + /** + * Merge the given CSS properties into the cursor style and apply them. + * @param {Partial} [cursorStyle] + */ + updateCursorStyle(cursorStyle?: Partial): void; + + invokeValueChange(value: number): void; + + onValueChange( + cb: (value: number) => void, + priority?: number + ): vtkSubscription; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkSlider + * characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ISliderInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ISliderInitialValues +): void; + +/** + * Method used to create a new instance of vtkSlider. + * @param {ISliderInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance(initialValues?: ISliderInitialValues): vtkSlider; + +/** + * vtkSlider is a DOM widget that draws a draggable cursor inside a container. + * The cursor snaps to the closest of a discrete set of values and its + * orientation follows the longest dimension of the container. + */ +export declare const vtkSlider: { + newInstance: typeof newInstance; + extend: typeof extend; + SliderOrientation: typeof SliderOrientation; +}; +export default vtkSlider; diff --git a/Sources/Interaction/UI/VolumeController/index.d.ts b/Sources/Interaction/UI/VolumeController/index.d.ts new file mode 100644 index 00000000000..2ddf1625640 --- /dev/null +++ b/Sources/Interaction/UI/VolumeController/index.d.ts @@ -0,0 +1,117 @@ +import { vtkObject, vtkSubscription } from '../../../interfaces'; +import { Nullable, Size } from '../../../types'; +import { vtkPiecewiseGaussianWidget } from '../../Widgets/PiecewiseGaussianWidget'; +import vtkRenderWindow from '../../../Rendering/Core/RenderWindow'; +import vtkVolume from '../../../Rendering/Core/Volume'; + +export interface IVolumeControllerInitialValues { + /** + * Size in pixels of the embedded piecewise function editor. + */ + size?: Size; + expanded?: boolean; + rescaleColorMap?: boolean; +} + +export interface vtkVolumeController extends vtkObject { + getActor(): Nullable; + + setActor(actor: vtkVolume): boolean; + + getRenderWindow(): Nullable; + + setRenderWindow(renderWindow: vtkRenderWindow): boolean; + + getRescaleColorMap(): boolean; + + /** + * When true, the color transfer function mapping range follows the opacity + * range selected in the piecewise function editor. + * @param {Boolean} value + */ + setRescaleColorMap(value: boolean): boolean; + + /** + * The embedded piecewise gaussian widget used to edit the scalar opacity. + */ + getWidget(): vtkPiecewiseGaussianWidget; + + /** + * Build the controller DOM content and wire it to the given volume actor. + * @param {vtkRenderWindow} renderWindow + * @param {vtkVolume} actor + * @param {Boolean} isBackgroundDark selects the light or dark widget styling + * @param {String|Number} [useShadow] (default: '1') + * @param {String} [presetName] (default: 'erdc_rainbow_bright') + */ + setupContent( + renderWindow: vtkRenderWindow, + actor: vtkVolume, + isBackgroundDark: boolean, + useShadow?: string | number, + presetName?: string + ): void; + + /** + * Attach the controller to the given DOM element, detaching it from any + * previously set one. + * @param el + */ + setContainer(el: Nullable): void; + + /** + * Show or hide everything but the toggle button. + */ + toggleVisibility(): void; + + getExpanded(): boolean; + + setExpanded(expanded: boolean): void; + + /** + * Resize the embedded piecewise function editor. + * @param {Number} width + * @param {Number} height + */ + setSize(width: number, height: number): void; + + /** + * Render the embedded piecewise function editor. + */ + render(): void; + + onAnimation(cb: (animating: boolean) => void): vtkSubscription; +} + +/** + * Method used to decorate a given object (publicAPI+model) with + * vtkVolumeController characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IVolumeControllerInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IVolumeControllerInitialValues +): void; + +/** + * Method used to create a new instance of vtkVolumeController. + * @param {IVolumeControllerInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IVolumeControllerInitialValues +): vtkVolumeController; + +/** + * vtkVolumeController is a DOM overlay providing interactive control over a + * volume actor: color map preset, shading, sample distance, edge gradient + * opacity and a piecewise gaussian editor for the scalar opacity. + */ +export declare const vtkVolumeController: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkVolumeController; diff --git a/Sources/Interaction/Widgets/OrientationMarkerWidget/Constants.d.ts b/Sources/Interaction/Widgets/OrientationMarkerWidget/Constants.d.ts index 84843fea39f..eb508113f69 100644 --- a/Sources/Interaction/Widgets/OrientationMarkerWidget/Constants.d.ts +++ b/Sources/Interaction/Widgets/OrientationMarkerWidget/Constants.d.ts @@ -1,9 +1,11 @@ -export declare enum Corners { - TOP_LEFT = 'TOP_LEFT', - TOP_RIGHT = 'TOP_RIGHT', - BOTTOM_LEFT = 'BOTTOM_LEFT', - BOTTOM_RIGHT = 'BOTTOM_RIGHT', -} +export declare const Corners: { + readonly TOP_LEFT: 'TOP_LEFT'; + readonly TOP_RIGHT: 'TOP_RIGHT'; + readonly BOTTOM_LEFT: 'BOTTOM_LEFT'; + readonly BOTTOM_RIGHT: 'BOTTOM_RIGHT'; +}; + +export type Corners = (typeof Corners)[keyof typeof Corners]; declare const _default: { Corners: typeof Corners; diff --git a/Sources/Interaction/Widgets/OrientationMarkerWidget/index.d.ts b/Sources/Interaction/Widgets/OrientationMarkerWidget/index.d.ts index 1961562a9eb..eff81044f41 100644 --- a/Sources/Interaction/Widgets/OrientationMarkerWidget/index.d.ts +++ b/Sources/Interaction/Widgets/OrientationMarkerWidget/index.d.ts @@ -23,7 +23,7 @@ export interface vtkOrientationMarkerWidget extends vtkObject { * Get the computed viewport size. * The format is `[left, bottom, right, top]`. */ - computeViewport(): [number, number, number, number]; + computeViewport(): Nullable<[number, number, number, number]>; /** * Dereference any internal object and remove any subscription. @@ -36,7 +36,7 @@ export interface vtkOrientationMarkerWidget extends vtkObject { /** * */ - getActor(): vtkActor; + getActor(): vtkActor | undefined; /** * Gets the parent renderer, if any. @@ -51,7 +51,7 @@ export interface vtkOrientationMarkerWidget extends vtkObject { /** * Get the render window interactor associated with the widget. */ - getInteractor(): vtkRenderWindowInteractor; + getInteractor(): vtkRenderWindowInteractor | undefined; /** * Get the maximum side length, in pixels, for the orientation marker widget @@ -125,7 +125,7 @@ export interface vtkOrientationMarkerWidget extends vtkObject { * @param {Corners} viewportCorner * @default BOTTOM_LEFT */ - setViewportCorner(viewportCorner: Corners): boolean; + setViewportCorner(viewportCorner: Corners): void; /** * Set the viewport size. @@ -178,6 +178,15 @@ export function newInstance( /** * vtkOrientationMarkerWidget is a 2D widget for manipulating a marker prop */ +export declare const DEFAULT_VALUES: Readonly<{ + viewportCorner: Corners; + viewportSize: number; + minPixelSize: number; + maxPixelSize: number; + parentRenderer: null; + interactiveRenderer: boolean; +}>; + export declare const vtkOrientationMarkerWidget: { newInstance: typeof newInstance; extend: typeof extend; diff --git a/Sources/Interaction/Widgets/PiecewiseGaussianWidget/index.d.ts b/Sources/Interaction/Widgets/PiecewiseGaussianWidget/index.d.ts new file mode 100644 index 00000000000..f0e0c2de2da --- /dev/null +++ b/Sources/Interaction/Widgets/PiecewiseGaussianWidget/index.d.ts @@ -0,0 +1,379 @@ +import vtkPiecewiseFunction from '../../../Common/DataModel/PiecewiseFunction'; +import vtkColorTransferFunction from '../../../Rendering/Core/ColorTransferFunction'; +import { vtkObject, vtkSubscription } from '../../../interfaces'; +import { TypedArray, Vector2 } from '../../../types'; + +/** + * A single gaussian of the transfer function. + */ +export interface IGaussian { + /** + * Center of the gaussian, normalized in [0, 1] over the data range. + */ + position: number; + + /** + * Peak opacity of the gaussian, in [0, 1]. + */ + height: number; + + /** + * Width of the gaussian, normalized over the data range. + */ + width: number; + + /** + * Horizontal bias applied to the gaussian. + */ + xBias: number; + + /** + * Vertical bias applied to the gaussian. + */ + yBias: number; +} + +/** + * A node of the piecewise function produced from the gaussians. + */ +export interface IOpacityNode { + x: number; + y: number; + midpoint: number; + sharpness: number; +} + +export interface IPiecewiseGaussianWidgetStyle { + backgroundColor?: string; + histogramColor?: string; + strokeColor?: string; + activeColor?: string; + buttonDisableFillColor?: string; + buttonDisableStrokeColor?: string; + buttonStrokeColor?: string; + buttonFillColor?: string; + handleColor?: string; + strokeWidth?: number; + activeStrokeWidth?: number; + buttonStrokeWidth?: number; + handleWidth?: number; + iconSize?: number; + padding?: number; + zoomControlHeight?: number; + zoomControlColor?: string; +} + +/** + * Options describing how to extract a histogram out of a data array. + */ +export interface ISetDataArrayOptions { + numberOfBinToConsiders?: number; + numberOfBinsToSkip?: number; + numberOfComponents?: number; + component?: number; +} + +/** + * + */ +export interface IPiecewiseGaussianWidgetInitialValues { + gaussians?: IGaussian[]; + size?: Vector2; + numberOfBins?: number; + piecewiseSize?: number; + gaussianMinimumHeight?: number; + colorTransferFunction?: vtkColorTransferFunction; + backgroundImage?: HTMLImageElement; + enableRangeZoom?: boolean; + rangeZoom?: Vector2; + style?: IPiecewiseGaussianWidgetStyle; +} + +export interface vtkPiecewiseGaussianWidget extends vtkObject { + /** + * Attach the widget canvas to the given DOM element. Pass `null` to detach. + */ + setContainer(el: HTMLElement | null): void; + + /** + * Get the canvas the widget draws onto. + */ + getCanvas(): HTMLCanvasElement; + + /** + * Get the widget size, as `[width, height]` in pixels. + */ + getSize(): Vector2; + + /** + * Resize the widget. + */ + setSize(width: number, height: number): void; + + /** + * Get the gaussians currently defined. + */ + getGaussians(): IGaussian[]; + + /** + * Replace the gaussians. + */ + setGaussians(gaussians: IGaussian[]): void; + + /** + * Append a gaussian. + * + * @returns The index of the newly added gaussian. + */ + addGaussian( + position: number, + height: number, + width: number, + xBias: number, + yBias: number + ): number; + + /** + * Remove the gaussian at the given index. + */ + removeGaussian(index: number): void; + + /** + * Merge the given style into the widget style. + */ + updateStyle(style: IPiecewiseGaussianWidgetStyle): void; + + /** + * Compute the histogram displayed behind the gaussians from a data array. + * + * The histogram is computed on web workers, so it is not available when this + * call returns. Observe completion through `onModified`. + * + * @param array The values to build the histogram from + * @param {ISetDataArrayOptions} [options] How to interpret the array + */ + setDataArray(array: TypedArray, options?: ISetDataArrayOptions): void; + + /** + * Get the number of bins of the histogram. + * @default 256 + */ + getNumberOfBins(): number; + setNumberOfBins(numberOfBins: number): boolean; + + /** + * Get the number of samples the gaussians are discretized into when building + * the piecewise function. + * @default 256 + */ + getPiecewiseSize(): number; + setPiecewiseSize(piecewiseSize: number): boolean; + + /** + * Get the minimum height a gaussian may be dragged down to. + * @default 0.05 + */ + getGaussianMinimumHeight(): number; + setGaussianMinimumHeight(height: number): boolean; + + /** + * The color transfer function drawn under the chart. Has no default, so it + * is undefined until set. + */ + getColorTransferFunction(): vtkColorTransferFunction | undefined; + setColorTransferFunction(lut: vtkColorTransferFunction): boolean; + + /** + * An image drawn as the chart background. Has no default, so it is undefined + * until set. + */ + getBackgroundImage(): HTMLImageElement | undefined; + setBackgroundImage(image: HTMLImageElement): boolean; + + /** + * Whether the zoom control is shown and usable. + * @default true + */ + getEnableRangeZoom(): boolean; + setEnableRangeZoom(enable: boolean): boolean; + + /** + * The zoomed sub-range, normalized in [0, 1]. + * @default [0, 1] + */ + getRangeZoom(): Vector2; + getRangeZoomByReference(): Vector2; + setRangeZoom(range: Vector2): boolean; + setRangeZoom(min: number, max: number): boolean; + setRangeZoomFrom(rangeZoom: Vector2): void; + + /** + * Build the piecewise function nodes matching the current gaussians. + * + * @param {Vector2} [dataRange] Defaults to the range of the histogram array + */ + getOpacityNodes(dataRange?: Vector2): IOpacityNode[]; + + /** + * Push the current gaussians onto a piecewise function. + * + * @param {vtkPiecewiseFunction} piecewiseFunction The function to update + * @param {Vector2} [dataRange] Defaults to the range of the histogram array + */ + applyOpacity( + piecewiseFunction: vtkPiecewiseFunction, + dataRange?: Vector2 + ): void; + + /** + * Get the sub-range over which the opacity is non-zero. + * + * @param {Vector2} [dataRange] Defaults to the range of the histogram array + */ + getOpacityRange(dataRange?: Vector2): Vector2; + + /** + * Mouse handlers, in canvas coordinates. They are wired to the canvas by + * `bindMouseListeners`, but are also callable directly. + */ + onClick(x: number, y: number): boolean; + onHover(x: number, y: number): boolean; + onDown(x: number, y: number): boolean; + onDrag(x: number, y: number): boolean; + onUp(x: number, y: number): boolean; + onLeave(x: number, y: number): boolean; + onAddGaussian(x: number, y: number): boolean; + onRemoveGaussian(x: number, y: number): boolean; + + /** + * Redraw the widget. + */ + render(): void; + + /** + * Attach the mouse listeners to the canvas. Called automatically by + * `setContainer`. + */ + bindMouseListeners(): void; + + /** + * Detach the mouse listeners from the canvas. + */ + unbindMouseListeners(): void; + + /** + * Register a callback invoked whenever the opacity changes. + */ + onOpacityChange( + cb: (widget: vtkPiecewiseGaussianWidget, createdGaussian?: boolean) => void + ): vtkSubscription; + invokeOpacityChange( + widget: vtkPiecewiseGaussianWidget, + createdGaussian?: boolean + ): void; + + /** + * Register a callback invoked while a gaussian is being dragged. + */ + onAnimation(cb: (animating: boolean) => void): vtkSubscription; + invokeAnimation(animating: boolean): void; + + /** + * Register a callback invoked whenever the zoomed range changes. + */ + onZoomChange(cb: (rangeZoom: Vector2) => void): vtkSubscription; + invokeZoomChange(rangeZoom: Vector2): void; +} + +/** + * Sample the given gaussians and push the resulting nodes onto a piecewise + * function. + * + * @param {IGaussian[]} gaussians The gaussians to sample + * @param {Number} sampling The number of samples + * @param {Vector2} rangeToUse The data range the samples are spread over + * @param {vtkPiecewiseFunction} piecewiseFunction The function to update + */ +declare function applyGaussianToPiecewiseFunction( + gaussians: IGaussian[], + sampling: number, + rangeToUse: Vector2, + piecewiseFunction: vtkPiecewiseFunction +): void; + +/** + * Sample the given gaussians into an array of opacities. + */ +declare function computeOpacities( + gaussians: IGaussian[], + sampling?: number +): number[]; + +/** + * Index of the gaussian whose position is closest to `x`. + */ +declare function findGaussian(x: number, gaussians: IGaussian[]): number; + +export declare const STATIC: { + applyGaussianToPiecewiseFunction: typeof applyGaussianToPiecewiseFunction; + computeOpacities: typeof computeOpacities; + createListener: ( + callback: (x: number, y: number) => void, + preventDefault?: boolean + ) => (e: MouseEvent) => void; + drawChart: ( + ctx: CanvasRenderingContext2D, + area: number[], + values: number[], + style?: { + lineWidth?: number; + strokeStyle?: string; + fillStyle?: string; + clip?: boolean; + } + ) => void; + findGaussian: typeof findGaussian; + listenerSelector: ( + condition: () => boolean, + ok: (e: Event) => void, + ko: (e: Event) => void + ) => (e: Event) => void; + normalizeCoordinates: ( + x: number, + y: number, + subRectangeArea: number[], + zoomRange?: Vector2 + ) => Vector2; +}; + +/** + * Method used to decorate a given object (publicAPI+model) with vtkPiecewiseGaussianWidget characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IPiecewiseGaussianWidgetInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IPiecewiseGaussianWidgetInitialValues +): void; + +/** + * Method used to create a new instance of vtkPiecewiseGaussianWidget + * @param {IPiecewiseGaussianWidgetInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IPiecewiseGaussianWidgetInitialValues +): vtkPiecewiseGaussianWidget; + +/** + * vtkPiecewiseGaussianWidget is a canvas-based editor that lets the user shape + * a piecewise opacity function as a sum of gaussians, drawn on top of the + * histogram of the data being rendered. + */ +declare const vtkPiecewiseGaussianWidget: typeof STATIC & { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkPiecewiseGaussianWidget; diff --git a/Sources/Proxy/Animation/AbstractAnimationProxy/index.d.ts b/Sources/Proxy/Animation/AbstractAnimationProxy/index.d.ts new file mode 100644 index 00000000000..5d1aaa903ee --- /dev/null +++ b/Sources/Proxy/Animation/AbstractAnimationProxy/index.d.ts @@ -0,0 +1,27 @@ +import { VtkProxy } from '../../../macros'; + +export interface vtkAbstractAnimationProxy extends VtkProxy { + /** + * Move the animation to the given time. The base class does nothing; + * concrete animation proxies forward the time to their handler. + */ + setTime(time: number): void; + + /** + * List the times at which this animation has a frame. The base class + * always returns an empty list. + */ + getFrames(): number[]; +} + +export function newInstance(initialValues?: object): vtkAbstractAnimationProxy; + +/** + * Base class for animation proxies: an object that can report the times it + * can be rendered at and that can be moved to one of those times. + */ +declare const vtkAbstractAnimationProxy: { + newInstance: typeof newInstance; + extend: (publicAPI: object, model: object, initialValues?: object) => void; +}; +export default vtkAbstractAnimationProxy; diff --git a/Sources/Proxy/Animation/AnimationProxyManager/index.d.ts b/Sources/Proxy/Animation/AnimationProxyManager/index.d.ts new file mode 100644 index 00000000000..766abc17e48 --- /dev/null +++ b/Sources/Proxy/Animation/AnimationProxyManager/index.d.ts @@ -0,0 +1,66 @@ +import { EventHandler, vtkSubscription } from '../../../interfaces'; +import { VtkProxy } from '../../../macros'; +import { vtkAbstractAnimationProxy } from '../AbstractAnimationProxy'; + +export interface vtkAnimationProxyManager extends VtkProxy { + /** + * Register an animation and recompute the merged frame list. Registering + * the same animation twice only adds a single entry. + */ + addAnimation(animation: vtkAbstractAnimationProxy): void; + + /** + * Play from the current frame, waiting between frames for the wall-clock + * time separating them. Invokes `DonePlaying` once the last frame is shown. + */ + play(): void; + pause(): void; + + nextFrame(): void; + previousFrame(): void; + firstFrame(): void; + lastFrame(): void; + + /** + * Move every registered animation to the given frame and invoke + * `CurrentFrameChanged`. + */ + setFrameIndex(frameId: number): void; + + /** + * Recompute the sorted, deduplicated list of frames from every registered + * animation, then reset to the first frame. + */ + updateFrames(): void; + + getCurrentFrame(): number; + getFrames(): number[]; + getCurrentFrameIndex(): number; + + onCurrentFrameChanged( + cb: EventHandler, + priority?: number + ): Readonly; + invokeCurrentFrameChanged(...args: unknown[]): void; + + onFramesChanged( + cb: EventHandler, + priority?: number + ): Readonly; + invokeFramesChanged(...args: unknown[]): void; + + onDonePlaying(cb: EventHandler, priority?: number): Readonly; + invokeDonePlaying(...args: unknown[]): void; +} + +export function newInstance(initialValues?: object): vtkAnimationProxyManager; + +/** + * Aggregates animation proxies into a single timeline and plays through the + * union of their frames. + */ +declare const vtkAnimationProxyManager: { + newInstance: typeof newInstance; + extend: (publicAPI: object, model: object, initialValues?: object) => void; +}; +export default vtkAnimationProxyManager; diff --git a/Sources/Proxy/Animation/TimeStepBasedAnimationHandlerProxy/index.d.ts b/Sources/Proxy/Animation/TimeStepBasedAnimationHandlerProxy/index.d.ts new file mode 100644 index 00000000000..4e069f41b60 --- /dev/null +++ b/Sources/Proxy/Animation/TimeStepBasedAnimationHandlerProxy/index.d.ts @@ -0,0 +1,47 @@ +import { VtkProxy } from '../../../macros'; + +/** + * Minimal contract the proxy expects from the animation handler it drives, + * as implemented by vtkTimeStepBasedAnimationHandler. + */ +export interface ITimeStepBasedAnimationHandler { + setCurrentTimeStep(time: number): void; + getTimeSteps(): number[]; +} + +export interface vtkTimeStepBasedAnimationHandlerProxy extends VtkProxy { + setTime(time: number): void; + + /** + * The time steps of the attached handler, or an empty list when no handler + * is set. + */ + getFrames(): number[]; + + setInputAnimationHandler(handler: ITimeStepBasedAnimationHandler): void; + + getHandler(): ITimeStepBasedAnimationHandler | null; + setHandler(handler: ITimeStepBasedAnimationHandler | null): boolean; +} + +export interface ITimeStepBasedAnimationHandlerProxyInitialValues { + handler?: ITimeStepBasedAnimationHandler | null; +} + +export function newInstance( + initialValues?: ITimeStepBasedAnimationHandlerProxyInitialValues +): vtkTimeStepBasedAnimationHandlerProxy; + +/** + * Animation proxy driving a time-step based animation handler: its frames are + * the handler's time steps. + */ +declare const vtkTimeStepBasedAnimationHandlerProxy: { + newInstance: typeof newInstance; + extend: ( + publicAPI: object, + model: object, + initialValues?: ITimeStepBasedAnimationHandlerProxyInitialValues + ) => void; +}; +export default vtkTimeStepBasedAnimationHandlerProxy; diff --git a/Sources/Proxy/Core/AbstractRepresentationProxy/index.d.ts b/Sources/Proxy/Core/AbstractRepresentationProxy/index.d.ts index e1ace734d4f..9b96a52013b 100644 --- a/Sources/Proxy/Core/AbstractRepresentationProxy/index.d.ts +++ b/Sources/Proxy/Core/AbstractRepresentationProxy/index.d.ts @@ -1,25 +1,76 @@ import { vtkObject } from '../../../interfaces'; import { VtkProxy } from '../../../macros'; +import vtkDataArray from '../../../Common/Core/DataArray'; +import { Bounds, Range } from '../../../types'; import { vtkSourceProxy } from '../SourceProxy'; import { vtkAbstractMapper } from '../../../Rendering/Core/AbstractMapper'; import { vtkActor } from '../../../Rendering/Core/Actor'; import { vtkVolume } from '../../../Rendering/Core/Volume'; +import { vtkLookupTableProxy } from '../LookupTableProxy'; +import { vtkPiecewiseFunctionProxy } from '../PiecewiseFunctionProxy'; +import { vtkProp } from '../../../Rendering/Core/Prop'; -export interface vtkAbstractRepresentationProxy extends VtkProxy { +export interface IRepresentationDataArrayInfo { + name: string; + location: string; + numberOfComponents: number; + dataRange: Range; +} + +/** + * Representation proxies are also props: `setVisibility` is overridden to + * forward the flag to every actor and volume, and reports nothing back. + */ +export interface vtkAbstractRepresentationProxy + extends VtkProxy, Omit { setInput(source: vtkSourceProxy): void; getInputDataSet(): vtkObject | null; + getDataArray(arrayName?: string, arrayLocation?: string): vtkDataArray | null; + getLookupTableProxy(arrayName?: string): vtkLookupTableProxy | null; + setLookupTableProxy(...args: unknown[]): void; + getPiecewiseFunctionProxy( + arrayName?: string + ): vtkPiecewiseFunctionProxy | null; + setPiecewiseFunctionProxy(...args: unknown[]): void; + rescaleTransferFunctionToDataRange( + arrayName: string, + arrayLocation: string, + componentIndex?: number + ): void; setColorBy( arrayName: string | null, arrayLocation: string, componentIndex?: number - ); + ): void; + /** + * Get the array name, array location and component index currently driving + * the coloring. Trailing entries are omitted when the matching state is not + * set, so the tuple may come back empty. + */ + getColorBy(): [string?, string?, number?]; setRescaleOnColorBy(rescale: boolean): boolean; getRescaleOnColorBy(): boolean; - getInput(): VtkProxy; - getMapper(): vtkAbstractMapper; + getInput(): VtkProxy | undefined; + getMapper(): vtkAbstractMapper | undefined; getActors(): vtkActor[]; getVolumes(): vtkVolume[]; + getNestedProps(): Array; + getBounds(): Bounds; + isVisible(): boolean; + setVisibility(visible: boolean): void; + listDataArrays(): IRepresentationDataArrayInfo[]; + updateColorByDomain(): void; +} + +export interface IAbstractRepresentationProxyInitialValues { + rescaleOnColorBy?: boolean; } -declare const vtkAbstractRepresentationProxy: vtkAbstractRepresentationProxy; +declare const vtkAbstractRepresentationProxy: { + extend: ( + publicAPI: object, + model: object, + initialValues?: IAbstractRepresentationProxyInitialValues + ) => void; +}; export default vtkAbstractRepresentationProxy; diff --git a/Sources/Proxy/Core/LookupTableProxy/Constants.d.ts b/Sources/Proxy/Core/LookupTableProxy/Constants.d.ts new file mode 100644 index 00000000000..a9df17e57f3 --- /dev/null +++ b/Sources/Proxy/Core/LookupTableProxy/Constants.d.ts @@ -0,0 +1,29 @@ +// [x, r/h, g/s, b/v, m=0.5, s=0.0] +type RGBHSVPoint = [number, number, number, number, number?, number?]; + +/** + * The module exposes these only through its default object; there are no named + * runtime exports to declare. + */ +declare const _default: { + Mode: { + readonly Preset: 0; + readonly RGBPoints: 1; + readonly HSVPoints: 2; + readonly Nodes: 3; + }; + Defaults: { + Preset: string; + RGBPoints: RGBHSVPoint[]; + HSVPoints: RGBHSVPoint[]; + Nodes: { + x: number; + r: number; + g: number; + b: number; + midpoint: number; + sharpness: number; + }[]; + }; +}; +export default _default; diff --git a/Sources/Proxy/Core/LookupTableProxy/index.d.ts b/Sources/Proxy/Core/LookupTableProxy/index.d.ts index 592458f984c..13299c7b915 100644 --- a/Sources/Proxy/Core/LookupTableProxy/index.d.ts +++ b/Sources/Proxy/Core/LookupTableProxy/index.d.ts @@ -11,16 +11,32 @@ export enum Mode { Nodes = 3, } +export interface ILookupTableProxyDefaults { + Preset: string; + RGBPoints: RGBHSVPoint[]; + HSVPoints: RGBHSVPoint[]; + Nodes: { + x: number; + r: number; + g: number; + b: number; + midpoint: number; + sharpness: number; + }[]; +} + export interface vtkLookupTableProxy extends VtkProxy { setPresetName(name: string): void; getPresetName(): string; setRGBPoints(points: RGBHSVPoint[]): void; - getRGBPoints(): RGBHSVPoint[]; + getRgbPoints(): RGBHSVPoint[]; setHSVPoints(points: RGBHSVPoint[]): void; - getHSVPoints(): RGBHSVPoint[]; + getHsvPoints(): RGBHSVPoint[]; + setArrayName(arrayName: string): boolean; + getArrayName(): string; // Node: { x, y, midpoint, sharpness } setNodes(nodes: number[][]): void; - getNodes(nodes): number[][]; + getNodes(): number[][]; setMode(mode: number): void; getMode(): number; applyMode(): void; @@ -30,16 +46,29 @@ export interface vtkLookupTableProxy extends VtkProxy { } export interface ILookupTableProxyInitialValues { + arrayName?: string; + dataRange?: [number, number]; + mode?: number; + nodes?: number[][]; + presetName?: string; lookupTable?: vtkColorTransferFunction; } +declare function extend( + publicAPI: object, + model: object, + initialValues?: ILookupTableProxyInitialValues +): void; + export function newInstance( initialValues?: ILookupTableProxyInitialValues ): vtkLookupTableProxy; export declare const vtkLookupTableProxy: { newInstance: typeof newInstance; - Mode: Mode; + extend: typeof extend; + Mode: typeof Mode; + Defaults: ILookupTableProxyDefaults; }; export default vtkLookupTableProxy; diff --git a/Sources/Proxy/Core/PiecewiseFunctionProxy/Constants.d.ts b/Sources/Proxy/Core/PiecewiseFunctionProxy/Constants.d.ts new file mode 100644 index 00000000000..5f26e9f2b17 --- /dev/null +++ b/Sources/Proxy/Core/PiecewiseFunctionProxy/Constants.d.ts @@ -0,0 +1,23 @@ +/** + * The module exposes these only through its default object; there are no named + * runtime exports to declare. + */ +declare const _default: { + Defaults: { + Gaussians: { + position: number; + height: number; + width: number; + xBias: number; + yBias: number; + }[]; + Points: number[][]; + Nodes: { x: number; y: number; midpoint: number; sharpness: number }[]; + }; + Mode: { + readonly Gaussians: 0; + readonly Points: 1; + readonly Nodes: 2; + }; +}; +export default _default; diff --git a/Sources/Proxy/Core/PiecewiseFunctionProxy/index.d.ts b/Sources/Proxy/Core/PiecewiseFunctionProxy/index.d.ts index 8c67bcb59b7..440946e39a2 100644 --- a/Sources/Proxy/Core/PiecewiseFunctionProxy/index.d.ts +++ b/Sources/Proxy/Core/PiecewiseFunctionProxy/index.d.ts @@ -18,12 +18,17 @@ export interface PiecewiseNode { sharpness: number; } -export enum IPiecewiseFunctionProxyMode { +declare enum IPiecewiseFunctionProxyMode { Gaussians = 0, Points = 1, Nodes = 2, } +/** + * The type is public; the value is reached through the module default export. + */ +export type { IPiecewiseFunctionProxyMode }; + export interface IPiecewiseFunctionProxyDefaults { Gaussians: PiecewiseGaussian[]; Points: number[][]; @@ -44,18 +49,33 @@ export interface vtkPiecewiseFunctionProxy extends VtkProxy { setDataRange(min: number, max: number): void; getDataRange(): [number, number]; getPiecewiseFunction(): vtkPiecewiseFunction; + setArrayName(arrayName: string): boolean; + getArrayName(): string; } export interface IPiecewiseFunctionProxyInitialValues { + arrayName?: string; + dataRange?: [number, number]; + gaussians?: PiecewiseGaussian[]; + mode?: number; + nodes?: PiecewiseNode[]; + points?: number[][]; piecewiseFunction?: vtkPiecewiseFunction; } +declare function extend( + publicAPI: object, + model: object, + initialValues?: IPiecewiseFunctionProxyInitialValues +): void; + export function newInstance( initialValues?: IPiecewiseFunctionProxyInitialValues ): vtkPiecewiseFunctionProxy; export declare const vtkPiecewiseFunctionProxy: { newInstance: typeof newInstance; + extend: typeof extend; Mode: typeof IPiecewiseFunctionProxyMode; Defaults: IPiecewiseFunctionProxyDefaults; }; diff --git a/Sources/Proxy/Core/ProxyManager/index.d.ts b/Sources/Proxy/Core/ProxyManager/index.d.ts index 41240cbe891..8bf2b43f73a 100644 --- a/Sources/Proxy/Core/ProxyManager/index.d.ts +++ b/Sources/Proxy/Core/ProxyManager/index.d.ts @@ -1,10 +1,10 @@ -import { vtkObject } from '../../../interfaces'; +import { vtkSubscription } from '../../../interfaces'; import { vtkSourceProxy } from '../SourceProxy'; import { vtkViewProxy } from '../ViewProxy'; import { vtkAbstractRepresentationProxy } from '../AbstractRepresentationProxy'; import { vtkLookupTableProxy } from '../LookupTableProxy'; import { vtkPiecewiseFunctionProxy } from '../PiecewiseFunctionProxy'; -import { VtkProxy } from '../../../macros'; +import { VtkProxy, VtkProxySection } from '../../../macros'; export type ProxyConfiguration = object; @@ -20,21 +20,33 @@ export interface IProxyManagerInitialValues { proxyConfiguration?: ProxyConfiguration; } -export interface vtkProxyManager extends vtkObject { +export interface vtkProxyManager extends VtkProxy { // core // setProxyConfiguration(config: ProxyConfiguration): boolean; getProxyConfiguration(): ProxyConfiguration; - setActiveSource(sourceProxy: vtkSourceProxy): boolean; - getActiveSource(): vtkSourceProxy; - - setActiveView(viewProxy: vtkViewProxy): boolean; - getActiveView(): vtkViewProxy; + setActiveSource(sourceProxy: vtkSourceProxy | undefined): void; + getActiveSource(): vtkSourceProxy | undefined; + onActiveSourceChange( + callback: (source: vtkSourceProxy) => void, + priority?: number + ): vtkSubscription; + invokeActiveSourceChange(source: vtkSourceProxy): void; + + setActiveView(viewProxy: vtkViewProxy | undefined): void; + getActiveView(): vtkViewProxy | undefined; + onActiveViewChange( + callback: (view: vtkViewProxy) => void, + priority?: number + ): vtkSubscription; + invokeActiveViewChange(view: vtkViewProxy): void; onProxyRegistrationChange( - callback: (changeInfo: ProxyRegistrationChangeInfo) => void - ); + callback: (changeInfo: ProxyRegistrationChangeInfo) => void, + priority?: number + ): vtkSubscription; + invokeProxyRegistrationChange(changeInfo: ProxyRegistrationChangeInfo): void; getProxyById(id: string): T | undefined; getProxyGroups(): string[]; @@ -48,7 +60,7 @@ export interface vtkProxyManager extends vtkObject { group: string, name: string, options?: object - ): T; + ): T | null; getRepresentation( source: vtkSourceProxy, @@ -59,17 +71,59 @@ export interface vtkProxyManager extends vtkObject { // view // + create3DView(options?: object): vtkViewProxy; + create2DView(options?: object): vtkViewProxy; render(view?: vtkViewProxy): void; - renderAllViews(): void; - setAnimationOnAllViews(): void; + renderAllViews(blocking?: boolean): void; + setAnimationOnAllViews(enable?: boolean): void; autoAnimateViews(debounceTimeout: number): void; resizeAllViews(): void; resetCamera(view?: vtkViewProxy): void; createRepresentationInAllViews(source: vtkSourceProxy): void; resetCameraInAllViews(): void; + // state // + + /** + * Rebuild the proxy graph described by a state previously produced by + * `saveState`. Resolves with the state's `userData` plus a `$oldToNewIdMapping` + * entry mapping saved proxy ids to the ids of the recreated proxies. + */ + loadState( + state: object, + options?: { datasetHandler?: (dataset: any) => any } + ): Promise; + + /** + * Serialize the registered sources, views and representations. `options` is + * copied into the state, minus its `datasetHandler` entry, and `userData` is + * stored alongside it. + */ + saveState( + options?: { datasetHandler?: (dataset: any, source?: any) => any }, + userData?: object + ): Promise; + // properties // + /** + * UI sections of the active source, its representation in the active view and + * the active view, skipping the ones with an empty ui description. + */ + getSections(): Array; + + /** + * Record whether the section with the given name is collapsed. + */ + updateCollapseState(name: string, state: boolean): void; + + /** + * Apply a set of `${proxyId}:${propertyName}` changes at once, then render + * every view. The value `__command_execute__` calls the named method instead + * of setting it. + */ + applyChanges(changeSet: Record): void; + // these are specific to the proxy configuration... getLookupTable(arrayName: string, options?: any): vtkLookupTableProxy; getPiecewiseFunction( diff --git a/Sources/Proxy/Core/SourceProxy/index.d.ts b/Sources/Proxy/Core/SourceProxy/index.d.ts index c77adc5d59a..5f3249142fc 100644 --- a/Sources/Proxy/Core/SourceProxy/index.d.ts +++ b/Sources/Proxy/Core/SourceProxy/index.d.ts @@ -1,4 +1,8 @@ -import { vtkAlgorithm } from '../../../interfaces'; +import { + EventHandler, + vtkAlgorithm, + vtkSubscription, +} from '../../../interfaces'; import { VtkProxy } from '../../../macros'; export interface vtkSourceProxy extends VtkProxy { @@ -7,17 +11,70 @@ export interface vtkSourceProxy extends VtkProxy { setInputAlgorithm( algo: vtkAlgorithm, type: string, - autoUpdate: boolean + autoUpdate?: boolean ): void; update(): void; + /** + * Returns true when the algorithm has been modified more recently than the + * dataset it produced. Requires both an algorithm and a dataset to be set. + */ + getUpdate(): boolean; + getName(): string; setName(name: string): boolean; - getType(): string; - getDataset(): T | null; - getAlgo(): vtkAlgorithm | null; - getInputProxy(): vtkSourceProxy | null; + getType(): string | undefined; + getDataset(): T | undefined; + getAlgo(): vtkAlgorithm | undefined; + getInputProxy(): vtkSourceProxy | undefined; + + /** + * Register a callback to be invoked when the `DatasetChange` event occurs. + * + * @param {EventHandler} cb The callback to register + * @param {Number} [priority] Priority of this subscription + */ + onDatasetChange( + cb: EventHandler, + priority?: number + ): Readonly; + + /** + * Invoke the `DatasetChange` event with the given payload. + * + * @param args The event payload + */ + invokeDatasetChange(...args: unknown[]): void; +} + +export interface ISourceProxyInitialValues { + name?: string; } -declare const _default: vtkSourceProxy; -export default _default; +/** + * Decorates a given publicAPI + model with vtkSourceProxy characteristics. + * + * @param publicAPI + * @param model + * @param {object} [initialValues] + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ISourceProxyInitialValues +): void; + +/** + * Creates a vtkSourceProxy. + * @param {object} [initialValues] + */ +export function newInstance( + initialValues?: ISourceProxyInitialValues +): vtkSourceProxy; + +declare const vtkSourceProxy: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkSourceProxy; diff --git a/Sources/Proxy/Core/View2DProxy/index.d.ts b/Sources/Proxy/Core/View2DProxy/index.d.ts index 310251b6745..6d1141b912a 100644 --- a/Sources/Proxy/Core/View2DProxy/index.d.ts +++ b/Sources/Proxy/Core/View2DProxy/index.d.ts @@ -1,8 +1,27 @@ -import { vtkViewProxy } from '../ViewProxy'; +import { IViewProxyInitialValues, vtkViewProxy } from '../ViewProxy'; export interface vtkView2DProxy extends vtkViewProxy { getAxis(): number; + getFitProps(): boolean; } -declare const _default: vtkView2DProxy; -export default _default; +export interface IView2DProxyInitialValues extends IViewProxyInitialValues { + fitProps?: boolean; +} + +export function extend( + publicAPI: object, + model: object, + initialValues?: IView2DProxyInitialValues +): void; + +export function newInstance( + initialValues?: IView2DProxyInitialValues +): vtkView2DProxy; + +declare const vtkView2DProxy: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkView2DProxy; diff --git a/Sources/Proxy/Core/ViewProxy/index.d.ts b/Sources/Proxy/Core/ViewProxy/index.d.ts index 93d893da42a..7d6653f47d3 100644 --- a/Sources/Proxy/Core/ViewProxy/index.d.ts +++ b/Sources/Proxy/Core/ViewProxy/index.d.ts @@ -31,58 +31,79 @@ export interface vtkViewProxy extends VtkProxy { addRepresentation(representation: vtkAbstractRepresentationProxy): void; removeRepresentation(representation: vtkAbstractRepresentationProxy): void; - // TODO correct? - captureImage(opts: { format: string } & object): Array>; - openCaptureImage(target: string): void; + captureImage(opts?: { format?: string } & object): Promise; + openCaptureImage(target?: string): Promise; // TODO corner annotations - setBackground(color: Vector3 | Vector4): void; + setBackground(color: Vector3 | Vector4): boolean; getBackground(): Vector3 | Vector4; - setAnimation(enable: boolean, requester?: vtkObject); + setAnimation(enable: boolean, requester?: vtkObject): void; updateOrientation( axisIndex: 0 | 1 | 2, orientation: -1 | 1, viewUp: Vector3, - animateSteps: number + animateSteps?: number ): Promise; moveCamera( focalPoint: Vector3, position: Vector3, viewUp: Vector3, - animateSteps: number + animateSteps?: number ): Promise; - resetOrientation(animateSteps: number): void; - rotate(angle): void; + resetOrientation(animateSteps?: number): void; + rotate(angle: number): void; focusTo(focalPoint: Vector3): void; getCamera(): vtkCamera; - // getAnnotationOpacity - getContainer(): HTMLElement | null; + getAnnotationOpacity(): number; + getContainer(): HTMLElement | null | undefined; // getCornerAnnotation getInteractor(): vtkRenderWindowInteractor; getInteractorStyle2D(): vtkInteractorStyle; getInteractorStyle3D(): vtkInteractorStyle; getApiSpecificRenderWindow(): vtkOpenGLRenderWindow | vtkWebGPURenderWindow; getOrientationAxesType(): string; - getPresetToOrientationAxes(): any; + getPresetToOrientationAxes(): string; getRenderer(): vtkRenderer; getRenderWindow(): vtkRenderWindow; getRepresentations(): vtkAbstractRepresentationProxy[]; getUseParallelRendering(): boolean; getDisableAnimation(): boolean; setDisableAnimation(disabled: boolean): boolean; + getResetCameraOnFirstRender(): boolean; onResize( cb: (size: { width: number; height: number }) => void ): vtkSubscription; + invokeResize(size: { width: number; height: number }): void; // TODO proxy property mappings } -declare const _default: vtkViewProxy; -export default _default; +export interface IViewProxyInitialValues { + annotationOpacity?: number; + disableAnimation?: boolean; + orientationAxesType?: string; + presetToOrientationAxes?: any; + resetCameraOnFirstRender?: boolean; +} + +export function newInstance( + initialValues?: IViewProxyInitialValues +): vtkViewProxy; + +declare const vtkViewProxy: { + newInstance: typeof newInstance; + extend: ( + publicAPI: object, + model: object, + initialValues?: IViewProxyInitialValues + ) => void; +}; + +export default vtkViewProxy; diff --git a/Sources/Proxy/Representations/GeometryRepresentationProxy/index.d.ts b/Sources/Proxy/Representations/GeometryRepresentationProxy/index.d.ts index 43d298f71f7..c0ff4730e50 100644 --- a/Sources/Proxy/Representations/GeometryRepresentationProxy/index.d.ts +++ b/Sources/Proxy/Representations/GeometryRepresentationProxy/index.d.ts @@ -32,5 +32,18 @@ export interface vtkGeometryRepresentationProxy extends vtkAbstractRepresentatio setLineWidth(width: number): boolean; } -declare const _default: vtkGeometryRepresentationProxy; -export default _default; +export function extend( + publicAPI: object, + model: object, + initialValues?: object +): void; + +export function newInstance( + initialValues?: object +): vtkGeometryRepresentationProxy; + +declare const vtkGeometryRepresentationProxy: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkGeometryRepresentationProxy; diff --git a/Sources/Proxy/Representations/GlyphRepresentationProxy/index.d.ts b/Sources/Proxy/Representations/GlyphRepresentationProxy/index.d.ts new file mode 100644 index 00000000000..f0b6d9c9811 --- /dev/null +++ b/Sources/Proxy/Representations/GlyphRepresentationProxy/index.d.ts @@ -0,0 +1,35 @@ +import { vtkAbstractRepresentationProxy } from '../../Core/AbstractRepresentationProxy'; + +export interface vtkGlyphRepresentationProxy extends vtkAbstractRepresentationProxy { + /** + * Coloring is driven by the color map embedded in the input description, + * so this is a no-op. + */ + setColorBy(): void; + getColorBy(): []; + listDataArrays(): []; + + // proxy property mappings + getEdgeVisibility(): boolean; + setEdgeVisibility(edgeVisibility: boolean): boolean; +} + +export function extend( + publicAPI: object, + model: object, + initialValues?: object +): void; + +export function newInstance( + initialValues?: object +): vtkGlyphRepresentationProxy; + +/** + * Representation proxy that builds one glyph mapper per mapping entry of a + * JSON description holding the glyph sources, their placement and a color map. + */ +declare const vtkGlyphRepresentationProxy: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkGlyphRepresentationProxy; diff --git a/Sources/Proxy/Representations/MoleculeRepresentationProxy/index.d.ts b/Sources/Proxy/Representations/MoleculeRepresentationProxy/index.d.ts new file mode 100644 index 00000000000..be2ede8c837 --- /dev/null +++ b/Sources/Proxy/Representations/MoleculeRepresentationProxy/index.d.ts @@ -0,0 +1,44 @@ +import { vtkAbstractRepresentationProxy } from '../../Core/AbstractRepresentationProxy'; + +export interface vtkMoleculeRepresentationProxy extends vtkAbstractRepresentationProxy { + /** + * Atoms and bonds are colored by the molecule filter, so this is a no-op. + */ + setColorBy(): void; + getColorBy(): []; + listDataArrays(): []; + + // proxy property mappings + getTolerance(): number; + setTolerance(tolerance: number): boolean; + getAtomicRadiusScaleFactor(): number; + setAtomicRadiusScaleFactor(atomicRadiusScaleFactor: number): boolean; + getBondRadius(): number; + setBondRadius(bondRadius: number): boolean; + getDeltaBondFactor(): number; + setDeltaBondFactor(deltaBondFactor: number): boolean; + getRadiusType(): string; + setRadiusType(radiusType: string): boolean; + getHideElements(): string; + setHideElements(hideElements: string): boolean; +} + +export function extend( + publicAPI: object, + model: object, + initialValues?: object +): void; + +export function newInstance( + initialValues?: object +): vtkMoleculeRepresentationProxy; + +/** + * Representation proxy rendering a molecule as spheres for the atoms and + * sticks for the bonds, both produced by vtkMoleculeToRepresentation. + */ +declare const vtkMoleculeRepresentationProxy: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkMoleculeRepresentationProxy; diff --git a/Sources/Proxy/Representations/ResliceRepresentationProxy/index.d.ts b/Sources/Proxy/Representations/ResliceRepresentationProxy/index.d.ts index b51c23a5588..11f3867597a 100644 --- a/Sources/Proxy/Representations/ResliceRepresentationProxy/index.d.ts +++ b/Sources/Proxy/Representations/ResliceRepresentationProxy/index.d.ts @@ -16,12 +16,13 @@ export interface vtkResliceRepresentationProxy extends vtkAbstractRepresentation getInterpolationType(): number; setOutlineLineWidth(lineWidth: number): boolean; getOutlineLineWidth(): number; + setOutlineColor(r: number, g: number, b: number): boolean; setOutlineColor(color: RGBColor): boolean; getOutlineColor(): RGBColor; setOutlineVisibility(visibility: boolean): boolean; getOutlineVisibility(): boolean; setSlabType(type: number): boolean; - getSlabtype(): number; + getSlabType(): number; setSlicePlane(plane: vtkPlane): boolean; getSlicePlane(): vtkPlane; setSlicePolyData(polydata: vtkPolyData): boolean; @@ -32,5 +33,18 @@ export interface vtkResliceRepresentationProxy extends vtkAbstractRepresentation getSlabTrapezoidIntegration(): number; } -declare const _default: vtkResliceRepresentationProxy; -export default _default; +export function extend( + publicAPI: object, + model: object, + initialValues?: object +): void; + +export function newInstance( + initialValues?: object +): vtkResliceRepresentationProxy; + +declare const vtkResliceRepresentationProxy: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkResliceRepresentationProxy; diff --git a/Sources/Proxy/Representations/SkyboxRepresentationProxy/index.d.ts b/Sources/Proxy/Representations/SkyboxRepresentationProxy/index.d.ts new file mode 100644 index 00000000000..aaa6b8e4f54 --- /dev/null +++ b/Sources/Proxy/Representations/SkyboxRepresentationProxy/index.d.ts @@ -0,0 +1,36 @@ +import { vtkAbstractRepresentationProxy } from '../../Core/AbstractRepresentationProxy'; + +export interface vtkSkyboxRepresentationProxy extends vtkAbstractRepresentationProxy { + /** + * A skybox is textured, not colored by an array, so this is a no-op. + */ + setColorBy(): void; + getColorBy(): []; + listDataArrays(): []; + + /** + * Move the skybox to one of the positions offered by the input source. + */ + setPosition(value: string): void; + getPosition(): string; +} + +export function extend( + publicAPI: object, + model: object, + initialValues?: object +): void; + +export function newInstance( + initialValues?: object +): vtkSkyboxRepresentationProxy; + +/** + * Representation proxy showing its input texture on a vtkSkybox, and exposing + * the positions the input source can be viewed from. + */ +declare const vtkSkyboxRepresentationProxy: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkSkyboxRepresentationProxy; diff --git a/Sources/Proxy/Representations/SliceRepresentationProxy/index.d.ts b/Sources/Proxy/Representations/SliceRepresentationProxy/index.d.ts index 3b2c1e3a9ee..135466e9467 100644 --- a/Sources/Proxy/Representations/SliceRepresentationProxy/index.d.ts +++ b/Sources/Proxy/Representations/SliceRepresentationProxy/index.d.ts @@ -23,5 +23,19 @@ export interface vtkSliceRepresentationProxy extends vtkAbstractRepresentationPr getSlice(): number; } -declare const _default: vtkSliceRepresentationProxy; -export default _default; +export function extend( + publicAPI: object, + model: object, + initialValues?: object +): void; + +export function newInstance( + initialValues?: object +): vtkSliceRepresentationProxy; + +declare const vtkSliceRepresentationProxy: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkSliceRepresentationProxy; diff --git a/Sources/Proxy/Representations/SlicedGeometryRepresentationProxy/index.d.ts b/Sources/Proxy/Representations/SlicedGeometryRepresentationProxy/index.d.ts new file mode 100644 index 00000000000..4db8596257a --- /dev/null +++ b/Sources/Proxy/Representations/SlicedGeometryRepresentationProxy/index.d.ts @@ -0,0 +1,67 @@ +import { RGBColor } from '../../../types'; +import { SlicingMode } from '../../../Rendering/Core/ImageMapper/Constants'; +import { + IAbstractRepresentationProxyInitialValues, + vtkAbstractRepresentationProxy, +} from '../../Core/AbstractRepresentationProxy'; + +export interface vtkSlicedGeometryRepresentationProxy extends vtkAbstractRepresentationProxy { + /** + * Move the cutting plane along its normal. Returns true when the plane or + * the stored slice actually changed. + */ + setSlice(slice?: number): boolean; + + /** + * Translate the actor along the plane normal, to pull the cut geometry off + * the surface it was cut from. Returns true when anything changed. + */ + setOffset(offset?: number): boolean; + + /** + * @param mode one of the vtkImageMapper slicing mode names, 'X', 'Y' or 'Z' + */ + setSlicingMode(mode: string): void; + + getSlicingMode(): string | SlicingMode; + getSlice(): number; + getOffset(): number; + + // proxy property mappings + getOpacity(): number; + setOpacity(opacity: number): boolean; + getVisibility(): boolean; + setVisibility(visible: boolean): boolean; + getColor(): RGBColor; + setColor(color: RGBColor): boolean; + getUseShadow(): boolean; + setUseShadow(lighting: boolean): boolean; + getUseBounds(): boolean; + setUseBounds(useBounds: boolean): boolean; +} + +export interface ISlicedGeometryRepresentationProxyInitialValues extends IAbstractRepresentationProxyInitialValues { + offset?: number; + slice?: number; + slicingMode?: string | SlicingMode; +} + +export function extend( + publicAPI: object, + model: object, + initialValues?: ISlicedGeometryRepresentationProxyInitialValues +): void; + +export function newInstance( + initialValues?: ISlicedGeometryRepresentationProxyInitialValues +): vtkSlicedGeometryRepresentationProxy; + +/** + * Representation proxy cutting its input geometry with an axis-aligned plane + * and rendering the resulting slice. + */ +declare const vtkSlicedGeometryRepresentationProxy: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkSlicedGeometryRepresentationProxy; diff --git a/Sources/Proxy/Representations/VolumeRepresentationProxy/index.d.ts b/Sources/Proxy/Representations/VolumeRepresentationProxy/index.d.ts index 67c8d2da5ae..ef5a98519d7 100644 --- a/Sources/Proxy/Representations/VolumeRepresentationProxy/index.d.ts +++ b/Sources/Proxy/Representations/VolumeRepresentationProxy/index.d.ts @@ -1,5 +1,12 @@ -import { vtkAbstractRepresentationProxy } from '../../Core/AbstractRepresentationProxy'; +import { + IAbstractRepresentationProxyInitialValues, + vtkAbstractRepresentationProxy, +} from '../../Core/AbstractRepresentationProxy'; import { vtkImageCropFilter } from '../../../Filters/General/ImageCropFilter'; +import vtkDataArray from '../../../Common/Core/DataArray'; +import vtkImageData from '../../../Common/DataModel/ImageData'; +import vtkVolumeMapper from '../../../Rendering/Core/VolumeMapper'; +import vtkVolumeProperty from '../../../Rendering/Core/VolumeProperty'; export interface vtkVolumeRepresentationProxy extends vtkAbstractRepresentationProxy { setIs2DVolume(is2D: boolean): void; @@ -9,9 +16,9 @@ export interface vtkVolumeRepresentationProxy extends vtkAbstractRepresentationP getVisibility(): boolean; setSliceVisibility(isVisible: boolean): void; getSliceVisibility(): boolean; - setSampleDistance(samp: number): void; + setSampleDistance(samp?: number): void; getSampleDistance(): number; - setEdgeGradient(grad: number): void; + setEdgeGradient(grad?: number): void; getEdgeGradient(): number; getCropFilter(): vtkImageCropFilter; @@ -40,5 +47,30 @@ export interface vtkVolumeRepresentationProxy extends vtkAbstractRepresentationP setCroppingPlanes(planes: number[]): boolean; } -declare const _default: vtkVolumeRepresentationProxy; -export default _default; +export interface IVolumeRepresentationProxyInitialValues extends IAbstractRepresentationProxyInitialValues { + edgeGradient?: number; + is2DVolume?: boolean; + sampleDistance?: number; +} + +export function extend( + publicAPI: object, + model: object, + initialValues?: IVolumeRepresentationProxyInitialValues +): void; + +export function newInstance( + initialValues?: IVolumeRepresentationProxyInitialValues +): vtkVolumeRepresentationProxy; + +declare const vtkVolumeRepresentationProxy: { + newInstance: typeof newInstance; + extend: typeof extend; + updateConfiguration: ( + dataset: vtkImageData, + dataArray: vtkDataArray, + config: { mapper: vtkVolumeMapper; property: vtkVolumeProperty } + ) => void; +}; + +export default vtkVolumeRepresentationProxy; diff --git a/Sources/Rendering/Core/AbstractImageMapper/index.d.ts b/Sources/Rendering/Core/AbstractImageMapper/index.d.ts index b2abb919df9..016a0c5cdf2 100644 --- a/Sources/Rendering/Core/AbstractImageMapper/index.d.ts +++ b/Sources/Rendering/Core/AbstractImageMapper/index.d.ts @@ -74,7 +74,7 @@ export interface vtkAbstractImageMapper extends vtkAbstractMapper3D { * @param {RGBAColor} color specify the background color to use * in RGBA format as an array of 4 values. Values are copied. */ - setBackgroundColorFrom(color: RGBAColor): boolean; + setBackgroundColorFrom(color: RGBAColor): void; /** * @@ -125,7 +125,7 @@ export interface vtkAbstractImageMapper extends vtkAbstractMapper3D { * * @param customDisplayExtent */ - setCustomDisplayExtentFrom(customDisplayExtent: number[]): boolean; + setCustomDisplayExtentFrom(customDisplayExtent: number[]): void; /** * Set the opacity texture width. diff --git a/Sources/Rendering/Core/AbstractMapper3D/index.d.ts b/Sources/Rendering/Core/AbstractMapper3D/index.d.ts index 6b3872b8000..0252ac8cb20 100755 --- a/Sources/Rendering/Core/AbstractMapper3D/index.d.ts +++ b/Sources/Rendering/Core/AbstractMapper3D/index.d.ts @@ -49,6 +49,18 @@ export interface vtkAbstractMapper3D extends vtkAbstractMapper { * @return {Number} The diagonal length of mapper bounding box. */ getLength(): number; + + /** + * Get the properties the rendering backends read their own settings from, + * keyed by backend name. + */ + getViewSpecificProperties(): object; + + /** + * Set the properties the rendering backends read their own settings from. + * @param viewSpecificProperties + */ + setViewSpecificProperties(viewSpecificProperties: object): boolean; } /** diff --git a/Sources/Rendering/Core/AbstractPicker/index.d.ts b/Sources/Rendering/Core/AbstractPicker/index.d.ts index b113a76c051..7e991c576ca 100755 --- a/Sources/Rendering/Core/AbstractPicker/index.d.ts +++ b/Sources/Rendering/Core/AbstractPicker/index.d.ts @@ -1,5 +1,5 @@ import { vtkObject } from '../../../interfaces'; -import { Vector3 } from '../../../types'; +import { Nullable, Vector3 } from '../../../types'; import vtkProp3D from '../Prop3D'; import vtkRenderer from '../Renderer'; @@ -56,7 +56,7 @@ export interface vtkAbstractPicker extends vtkObject { /** * */ - getRenderer(): vtkRenderer; + getRenderer(): Nullable; /** * @@ -103,11 +103,19 @@ export interface vtkAbstractPicker extends vtkObject { * @param {IAbstractPickerInitialValues} [initialValues] (default: {}) */ export function extend( - publicAPI: IAbstractPickerInitialValues, + publicAPI: object, model: object, - initialValues?: object + initialValues?: IAbstractPickerInitialValues ): void; +/** + * Method used to create a new instance of vtkAbstractPicker. + * @param {IAbstractPickerInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IAbstractPickerInitialValues +): vtkAbstractPicker; + /** * vtkAbstractPicker is an abstract superclass that defines a minimal API for its concrete subclasses. * The minimum functionality of a picker is to return the x-y-z global coordinate position of a pick (the pick itself is defined in display coordinates). @@ -117,6 +125,7 @@ export function extend( * @see [vtkPointPicker](./Rendering_Core_PointPicker.html) */ export declare const vtkAbstractPicker: { + newInstance: typeof newInstance; extend: typeof extend; }; export default vtkAbstractPicker; diff --git a/Sources/Rendering/Core/Actor/index.d.ts b/Sources/Rendering/Core/Actor/index.d.ts index 3035ce513e9..713a646e976 100755 --- a/Sources/Rendering/Core/Actor/index.d.ts +++ b/Sources/Rendering/Core/Actor/index.d.ts @@ -34,7 +34,7 @@ export interface vtkActor extends vtkProp3D { * properties. * @return {vtkProperty} the backface property. */ - getBackfaceProperty(): vtkProperty; + getBackfaceProperty(): Nullable; /** * Check whether the opaque is forced or not. diff --git a/Sources/Rendering/Core/Actor2D/index.d.ts b/Sources/Rendering/Core/Actor2D/index.d.ts index ac008e80e9e..a4524d0ddbf 100755 --- a/Sources/Rendering/Core/Actor2D/index.d.ts +++ b/Sources/Rendering/Core/Actor2D/index.d.ts @@ -3,7 +3,7 @@ import vtkCoordinate from '../Coordinate'; import vtkMapper from '../Mapper'; import vtkProperty2D, { IProperty2DInitialValues } from '../Property2D'; import vtkMapper2D from '../Mapper2D'; -import { Bounds } from '../../../types'; +import { Bounds, Nullable } from '../../../types'; /** * @@ -38,6 +38,17 @@ export interface vtkActor2D extends vtkProp { */ getProperty(): vtkProperty2D; + /** + * Create the property object if it does not exist yet and return it. + */ + ensureProperty(): vtkProperty2D; + + /** + * Set the property object that controls this actor's surface properties. + * @param {vtkProperty2D} property + */ + setProperty(property: vtkProperty2D): boolean; + /** * Create a new property suitable for use with this type of Actor. * @param {IProperty2DInitialValues} [initialValues] (default: {}) @@ -52,7 +63,7 @@ export interface vtkActor2D extends vtkProp { /** * Gets the 2D mapper. */ - getMapper(): vtkMapper2D; + getMapper(): Nullable; /** * Set the layer number for this 2D actor. @@ -63,7 +74,7 @@ export interface vtkActor2D extends vtkProp { * they were added to the renderer via `addActor` or `addActor2D`. * By default, each actor2D has a layer number of 0. */ - setLayerNumber(layer: number): void; + setLayerNumber(layer: number): boolean; /** * Get the layer number for this 2D actor. @@ -114,7 +125,7 @@ export interface vtkActor2D extends vtkProp { * Get the bounds as [xmin, xmax, ymin, ymax, zmin, zmax]. * @return {Bounds} The bounds for the mapper. */ - getBounds(): Bounds; + getBounds(): Bounds | []; /** * Return the actual vtkCoordinate reference that the mapper should use diff --git a/Sources/Rendering/Core/AnnotatedCubeActor/Presets.d.ts b/Sources/Rendering/Core/AnnotatedCubeActor/Presets.d.ts new file mode 100644 index 00000000000..f52391c072e --- /dev/null +++ b/Sources/Rendering/Core/AnnotatedCubeActor/Presets.d.ts @@ -0,0 +1,57 @@ +// Imported as '../AnnotatedCubeActor' rather than './index' so that the path +// stays valid once the ESM package flattens `/index.d.ts` to +// `.d.ts`. +import { + vtkAnnotatedCubeActor, + IFaceProperty, + IStyle, +} from '../AnnotatedCubeActor'; + +/** + * The set of properties a preset can apply to a vtkAnnotatedCubeActor. + */ +export interface IAnnotatedCubePresetDefinitions { + defaultStyle?: IStyle; + xMinusFaceProperty?: IFaceProperty; + xPlusFaceProperty?: IFaceProperty; + yMinusFaceProperty?: IFaceProperty; + yPlusFaceProperty?: IFaceProperty; + zMinusFaceProperty?: IFaceProperty; + zPlusFaceProperty?: IFaceProperty; +} + +declare const vtkAnnotatedCubePresets: { + /** + * Apply a set of face/style definitions onto an annotated cube actor. + * + * @param {IAnnotatedCubePresetDefinitions} definitions The definitions to apply + * @param {vtkAnnotatedCubeActor} cubeActor The actor to configure + */ + applyDefinitions( + definitions: IAnnotatedCubePresetDefinitions, + cubeActor: vtkAnnotatedCubeActor + ): void; + + /** + * Apply a registered preset onto an annotated cube actor. + * + * The presets shipped with vtk.js are `'default'` and `'lps'`. + * + * @param {string} name The name of the preset + * @param {vtkAnnotatedCubeActor} cubeActor The actor to configure + */ + applyPreset(name: string, cubeActor: vtkAnnotatedCubeActor): void; + + /** + * Register a new preset, or override an existing one. + * + * @param {string} name The name of the preset + * @param {IAnnotatedCubePresetDefinitions} definitions The definitions of the preset + */ + registerStylePreset( + name: string, + definitions: IAnnotatedCubePresetDefinitions + ): void; +}; + +export default vtkAnnotatedCubePresets; diff --git a/Sources/Rendering/Core/AnnotatedCubeActor/index.d.ts b/Sources/Rendering/Core/AnnotatedCubeActor/index.d.ts index 46bc6df19d1..5e582f8c485 100755 --- a/Sources/Rendering/Core/AnnotatedCubeActor/index.d.ts +++ b/Sources/Rendering/Core/AnnotatedCubeActor/index.d.ts @@ -1,4 +1,5 @@ import vtkActor, { IActorInitialValues } from '../Actor'; +import Presets from './Presets'; export interface IStyle { text?: string; @@ -21,50 +22,57 @@ export interface IFaceProperty extends IStyle { /** * */ -export interface IAnnotatedCubeActorInitialValues extends IActorInitialValues {} +export interface IAnnotatedCubeActorInitialValues extends IActorInitialValues { + defaultStyle?: IStyle; +} export interface vtkAnnotatedCubeActor extends vtkActor { + /** + * + */ + getDefaultStyle(): Readonly>; + /** * Set the default style. * @param {IStyle} style */ - setDefaultStyle(style: IStyle): boolean; + setDefaultStyle(style: IStyle): void; /** * The +X face property. * @param {IFaceProperty} prop +X face property */ - setXPlusFaceProperty(prop: IFaceProperty): boolean; + setXPlusFaceProperty(prop: IFaceProperty): void; /** * The -X face property. * @param {IFaceProperty} prop The -X face property. */ - setXMinusFaceProperty(prop: IFaceProperty): boolean; + setXMinusFaceProperty(prop: IFaceProperty): void; /** * The +Y face property. * @param {IFaceProperty} prop The +Y face property. */ - setYPlusFaceProperty(prop: IFaceProperty): boolean; + setYPlusFaceProperty(prop: IFaceProperty): void; /** * The -Y face property. * @param {IFaceProperty} prop The -Y ace property. */ - setYMinusFaceProperty(prop: IFaceProperty): boolean; + setYMinusFaceProperty(prop: IFaceProperty): void; /** * The +Z face property. * @param {IFaceProperty} prop The +Z face property. */ - setZPlusFaceProperty(prop: IFaceProperty): boolean; + setZPlusFaceProperty(prop: IFaceProperty): void; /** * The -Z face property. * @param {IFaceProperty} prop The -Z face property. */ - setZMinusFaceProperty(prop: IFaceProperty): boolean; + setZMinusFaceProperty(prop: IFaceProperty): void; } /** @@ -104,8 +112,13 @@ export function newInstance( * resolution: the pixel resolution of a face, i.e. pixel side length (default 200) * If a key is not specified, then the default value is used. */ +export declare const DEFAULT_VALUES: Readonly<{ + defaultStyle: Readonly>; +}>; + export declare const vtkAnnotatedCubeActor: { newInstance: typeof newInstance; extend: typeof extend; + Presets: typeof Presets; }; export default vtkAnnotatedCubeActor; diff --git a/Sources/Rendering/Core/Camera/index.d.ts b/Sources/Rendering/Core/Camera/index.d.ts index b0c84ff523d..017667be1b8 100755 --- a/Sources/Rendering/Core/Camera/index.d.ts +++ b/Sources/Rendering/Core/Camera/index.d.ts @@ -6,6 +6,8 @@ import { Bounds, Nullable, Vector3, Range } from '../../../types'; * */ export interface ICameraInitialValues { + explicitProjectionMatrix?: Nullable; + modelTransformMatrix?: mat4; position?: number[]; focalPoint?: number[]; viewUp?: number[]; @@ -95,9 +97,9 @@ export interface vtkCamera extends vtkObject { elevation(angle: number): void; /** - * Not implemented yet + * @param {mat4} matrix The matrix to fill with the camera light transform. */ - getCameraLightTransformMatrix(): void; + getCameraLightTransformMatrix(matrix: mat4): mat4; /** * Get the location of the near and far clipping planes along the direction @@ -323,7 +325,7 @@ export interface vtkCamera extends vtkObject { * This matrix could be used for model related transformations such as scale, shear, rotations and translations. * @returns {mat4} mat The value of the model transform matrix. */ - getModelTransformMatrix(): mat4; + getModelTransformMatrix(): Nullable; /** * Get the ViewPlaneNormal. @@ -410,7 +412,7 @@ export interface vtkCamera extends vtkObject { * of projection. * @param {Range} clippingRange */ - setClippingRangeFrom(clippingRange: Range): boolean; + setClippingRangeFrom(clippingRange: Range): void; /** * Used to handle convert js device orientation angles @@ -439,7 +441,7 @@ export interface vtkCamera extends vtkObject { beta: number, gamma: number, screen: number - ): boolean; + ): void; /** * Set the direction of projection. @@ -447,7 +449,7 @@ export interface vtkCamera extends vtkObject { * @param {Number} y The y coordinate. * @param {Number} z The z coordinate. */ - setDirectionOfProjection(x: number, y: number, z: number): boolean; + setDirectionOfProjection(x: number, y: number, z: number): void; /** * Move the focal point so that it is the specified distance from the camera @@ -456,7 +458,7 @@ export interface vtkCamera extends vtkObject { * This distance must be positive. * @param {Number} distance The value of the distance. */ - setDistance(distance: number): boolean; + setDistance(distance: number): void; /** * Set the focal of the camera in world coordinates. @@ -466,12 +468,6 @@ export interface vtkCamera extends vtkObject { */ setFocalPoint(x: number, y: number, z: number): boolean; - /** - * Set the focal of the camera in world coordinates. - * @param {Vector3} focalPoint - */ - setFocalPointFrom(focalPoint: Vector3): boolean; - /** * Set the value of the FreezeDolly instance variable. * @param {Boolean} freezeFocalPoint @@ -492,7 +488,7 @@ export interface vtkCamera extends vtkObject { * @param {Number} alpha The aplha angle value. * @param {Number} beta The beta angle value. */ - setObliqueAngles(alpha: number, beta: number): boolean; + setObliqueAngles(alpha: number, beta: number): void; /** * Set the value of the OrientationWXYZ. @@ -501,7 +497,7 @@ export interface vtkCamera extends vtkObject { * @param {Number} y The y coordinate. * @param {Number} z The z coordinate. */ - setOrientationWXYZ(degrees: number, x: number, y: number, z: number): boolean; + setOrientationWXYZ(degrees: number, x: number, y: number, z: number): void; /** * Set the value of the ParallelProjection. @@ -533,7 +529,7 @@ export interface vtkCamera extends vtkObject { * Set the value of the physicalTranslation. * @param {Number[]} physicalTranslation The value of the physicalTranslation. */ - setPhysicalTranslationFrom(physicalTranslation: number[]): boolean; + setPhysicalTranslationFrom(physicalTranslation: number[]): void; /** * @@ -547,7 +543,7 @@ export interface vtkCamera extends vtkObject { * * @param {Number[]} physicalViewNorth */ - setPhysicalViewNorthFrom(physicalViewNorth: number[]): boolean; + setPhysicalViewNorthFrom(physicalViewNorth: number[]): void; /** * @@ -561,7 +557,7 @@ export interface vtkCamera extends vtkObject { * * @param {Number[]} physicalViewUp */ - setPhysicalViewUpFrom(physicalViewUp: number[]): boolean; + setPhysicalViewUpFrom(physicalViewUp: number[]): void; /** * Set the position of the camera in world coordinates. @@ -594,7 +590,7 @@ export interface vtkCamera extends vtkObject { * @todo Not implemented yet * @param {Number} angle The value of the roll angle. */ - setRoll(angle: number): boolean; + setRoll(angle: number): void; /** * Set top left corner point of the screen. @@ -618,7 +614,7 @@ export interface vtkCamera extends vtkObject { * Set top left corner point of the screen. * @param {Vector3} screenBottomLeft The screenBottomLeft coordiante. */ - setScreenBottomLeftFrom(screenBottomLeft: Vector3): boolean; + setScreenBottomLeftFrom(screenBottomLeft: Vector3): void; /** * @@ -638,7 +634,7 @@ export interface vtkCamera extends vtkObject { * Set bottom right corner point of the screen. * @param {Vector3} screenBottomRight The screenBottomRight coordiante. */ - setScreenBottomRightFrom(screenBottomRight: Vector3): boolean; + setScreenBottomRightFrom(screenBottomRight: Vector3): void; /** * Set top right corner point of the screen. @@ -662,7 +658,7 @@ export interface vtkCamera extends vtkObject { * Set top right corner point of the screen. * @param {Vector3} screenTopRight The screenTopRight coordiante. */ - setScreenTopRightFrom(screenTopRight: Vector3): boolean; + setScreenTopRightFrom(screenTopRight: Vector3): void; /** * Set the distance between clipping planes. @@ -671,13 +667,13 @@ export interface vtkCamera extends vtkObject { * 'thickness' beyond the near clipping plane. * @param {Number} thickness */ - setThickness(thickness: number): boolean; + setThickness(thickness: number): void; /** * * @param {Number} thickness The value of the thickness. */ - setThicknessFromFocalPoint(thickness: number): boolean; + setThicknessFromFocalPoint(thickness: number): void; /** * Set the value of the useHorizontalViewAngle. @@ -744,7 +740,7 @@ export interface vtkCamera extends vtkObject { * Set the view up direction for the camera. * @param {Vector3} viewUp The viewUp coordinate. */ - setViewUpFrom(viewUp: Vector3): boolean; + setViewUpFrom(viewUp: Vector3): void; /** * Set the center of the window in viewport coordinates. @@ -763,7 +759,7 @@ export interface vtkCamera extends vtkObject { * Set the center of the window in viewport coordinates from an array. * @param {Range} windowCenter */ - setWindowCenterFrom(windowCenter: Range): boolean; + setWindowCenterFrom(windowCenter: Range): void; /** * @@ -815,6 +811,33 @@ export function newInstance(initialValues?: ICameraInitialValues): vtkCamera; * complex methods allow the manipulation of the computer graphics model * including view up vector, clipping planes, and camera perspective. */ +export declare const DEFAULT_VALUES: Readonly<{ + position: number[]; + focalPoint: number[]; + viewUp: number[]; + directionOfProjection: number[]; + parallelProjection: boolean; + useHorizontalViewAngle: boolean; + viewAngle: number; + parallelScale: number; + clippingRange: number[]; + windowCenter: number[]; + viewPlaneNormal: number[]; + useOffAxisProjection: boolean; + screenBottomLeft: number[]; + screenBottomRight: number[]; + screenTopRight: number[]; + freezeFocalPoint: boolean; + explicitProjectionMatrix: null; + viewMatrix: null; + modelTransformMatrix: null; + cameraLightTransform: mat4; + physicalTranslation: number[]; + physicalScale: number; + physicalViewUp: number[]; + physicalViewNorth: number[]; +}>; + export declare const vtkCamera: { newInstance: typeof newInstance; extend: typeof extend; diff --git a/Sources/Rendering/Core/CellPicker/index.d.ts b/Sources/Rendering/Core/CellPicker/index.d.ts index e7710f1bbad..c510573538e 100755 --- a/Sources/Rendering/Core/CellPicker/index.d.ts +++ b/Sources/Rendering/Core/CellPicker/index.d.ts @@ -5,6 +5,7 @@ import vtkPicker, { IPickerInitialValues } from '../Picker'; import vtkProp3D from '../Prop3D'; import vtkRenderer from '../Renderer'; import { Nullable } from '../../../types'; +import { mat4 } from 'gl-matrix'; /** * @@ -52,7 +53,17 @@ export interface vtkCellPicker extends vtkPicker { /** * Get the opacity threshold for volume picking */ - setOpacityThreshold(value: number); + setOpacityThreshold(value: number): boolean; + + /** + * Get the normal of the surface at the PickPosition, in world coordinates. + */ + getPickNormal(): number[]; + + /** + * Get the normal of the surface at the PickPosition, in world coordinates. + */ + getPickNormalByReference(): number[]; /** * Get the parametric coordinates of the picked cell. @@ -91,6 +102,20 @@ export interface vtkCellPicker extends vtkPicker { pick(selection: any, renderer: vtkRenderer): void; } +interface IClipLineWithPlaneResult { + planeId: number; + t1: number; + t2: number; + intersect: 0 | 1; +} + +declare function clipLineWithPlane( + mapper: vtkMapper, + matrix: mat4, + p1: Vector3, + p2: Vector3 +): IClipLineWithPlaneResult | 0; + /** * Method use to decorate a given object (publicAPI+model) with vtkCellPicker characteristics. * @@ -115,5 +140,9 @@ export function newInstance( export declare const vtkCellPicker: { newInstance: typeof newInstance; extend: typeof extend; + clipLineWithPlane: typeof clipLineWithPlane; }; +export declare const STATIC: Readonly<{ + clipLineWithPlane: typeof clipLineWithPlane; +}>; export default vtkCellPicker; diff --git a/Sources/Rendering/Core/ColorTransferFunction/ColorMaps.d.ts b/Sources/Rendering/Core/ColorTransferFunction/ColorMaps.d.ts index b35bc03f509..4cc1bc9c43e 100644 --- a/Sources/Rendering/Core/ColorTransferFunction/ColorMaps.d.ts +++ b/Sources/Rendering/Core/ColorTransferFunction/ColorMaps.d.ts @@ -7,17 +7,30 @@ import { Vector3 } from '../../../types'; export interface IColorMapPreset { Name: string; Creator?: string; + Notes?: string; + Source?: string; + License?: string; ColorSpace?: string; NanColor?: Vector3; + BelowRangeColor?: Vector3; + AboveRangeColor?: Vector3; + /** + * Always present on presets reachable through this module: both the built-in + * preset table and `addPreset` reject presets without RGBPoints. + */ RGBPoints: number[]; IndexedColors?: number[]; Annotations?: (number | string)[]; + ShowIndexedColorActiveValues?: number; } -export declare const vtkColorMaps: { +declare const vtkColorMaps: { addPreset(preset: IColorMapPreset): void; removePresetByName(name: string): void; - getPresetByName(name: string): IColorMapPreset; + /** + * Undefined when no preset carries that name. + */ + getPresetByName(name: string): IColorMapPreset | undefined; rgbPresetNames: string[]; }; diff --git a/Sources/Rendering/Core/ColorTransferFunction/ColorMapsLite.d.ts b/Sources/Rendering/Core/ColorTransferFunction/ColorMapsLite.d.ts new file mode 100644 index 00000000000..4cc1bc9c43e --- /dev/null +++ b/Sources/Rendering/Core/ColorTransferFunction/ColorMapsLite.d.ts @@ -0,0 +1,37 @@ +/** + * vtkColorMaps represents a global registry of preset color maps. + */ + +import { Vector3 } from '../../../types'; + +export interface IColorMapPreset { + Name: string; + Creator?: string; + Notes?: string; + Source?: string; + License?: string; + ColorSpace?: string; + NanColor?: Vector3; + BelowRangeColor?: Vector3; + AboveRangeColor?: Vector3; + /** + * Always present on presets reachable through this module: both the built-in + * preset table and `addPreset` reject presets without RGBPoints. + */ + RGBPoints: number[]; + IndexedColors?: number[]; + Annotations?: (number | string)[]; + ShowIndexedColorActiveValues?: number; +} + +declare const vtkColorMaps: { + addPreset(preset: IColorMapPreset): void; + removePresetByName(name: string): void; + /** + * Undefined when no preset carries that name. + */ + getPresetByName(name: string): IColorMapPreset | undefined; + rgbPresetNames: string[]; +}; + +export default vtkColorMaps; diff --git a/Sources/Rendering/Core/ColorTransferFunction/Constants.d.ts b/Sources/Rendering/Core/ColorTransferFunction/Constants.d.ts index ba0470fb15b..6498b996308 100644 --- a/Sources/Rendering/Core/ColorTransferFunction/Constants.d.ts +++ b/Sources/Rendering/Core/ColorTransferFunction/Constants.d.ts @@ -1,14 +1,18 @@ -export declare enum ColorSpace { - RGB = 0, - HSV = 1, - LAB = 2, - DIVERGING = 3, -} +export declare const ColorSpace: { + readonly RGB: 0; + readonly HSV: 1; + readonly LAB: 2; + readonly DIVERGING: 3; +}; + +export type ColorSpace = (typeof ColorSpace)[keyof typeof ColorSpace]; + +export declare const Scale: { + readonly LINEAR: 0; + readonly LOG10: 1; +}; -export declare enum Scale { - LINEAR = 0, - LOG10 = 1, -} +export type Scale = (typeof Scale)[keyof typeof Scale]; declare const _default: { ColorSpace: typeof ColorSpace; diff --git a/Sources/Rendering/Core/ColorTransferFunction/index.d.ts b/Sources/Rendering/Core/ColorTransferFunction/index.d.ts index a00eb377125..4f1ea1b6b20 100755 --- a/Sources/Rendering/Core/ColorTransferFunction/index.d.ts +++ b/Sources/Rendering/Core/ColorTransferFunction/index.d.ts @@ -1,7 +1,32 @@ import vtkDataArray from '../../../Common/Core/DataArray'; -import vtkScalarsToColors from '../../../Common/Core/ScalarsToColors'; +import vtkScalarsToColors, { + IScalarsToColorsInitialValues, +} from '../../../Common/Core/ScalarsToColors'; +import { vtkObject } from '../../../interfaces'; +import { RGBAColor } from '../../../types'; import { ColorSpace, Scale } from './Constants'; +export interface IColorTransferFunctionNode { + x: number; + r: number; + g: number; + b: number; + midpoint: number; + sharpness: number; +} + +export interface IColorTransferFunctionInitialValues extends IScalarsToColorsInitialValues { + aboveRangeColor?: RGBAColor; + belowRangeColor?: RGBAColor; + colorSpace?: ColorSpace; + discretize?: boolean; + nanColor?: RGBAColor; + numberOfValues?: number; + scale?: Scale; + useAboveRangeColor?: boolean; + useBelowRangeColor?: boolean; +} + export interface vtkColorTransferFunction extends vtkScalarsToColors { /** * Add a point defined in RGB @@ -115,7 +140,7 @@ export interface vtkColorTransferFunction extends vtkScalarsToColors { * the nodes can end up unsorted, the cached range stale, and the change * will not propagate through the pipeline. */ - getDataPointer(): any[]; + getDataPointer(): IColorTransferFunctionNode[]; /** * Set nodes directly @@ -123,7 +148,7 @@ export interface vtkColorTransferFunction extends vtkScalarsToColors { * * @returns true if a change happen */ - setNodes(nodes: any): boolean; + setNodes(nodes: IColorTransferFunctionNode[]): boolean; /** * Sort the vector in increasing order, then fill in @@ -189,6 +214,9 @@ export interface vtkColorTransferFunction extends vtkScalarsToColors { */ getBlueValue(x: number): number; + /** Return whether logarithmic scaling is selected. */ + logScaleEnabled(): boolean; + /** * Get a table of RGB colors at regular intervals along the function * @param {Number} xStart The index of the first point. @@ -208,8 +236,8 @@ export interface vtkColorTransferFunction extends vtkScalarsToColors { xStart: number, xEnd: number, size: number, - withAlpha: boolean - ): Float32Array; + withAlpha?: boolean + ): Uint8Array; /** * Construct a color transfer function from a vtkDataArray. @@ -334,7 +362,7 @@ export interface vtkColorTransferFunction extends vtkScalarsToColors { * Set the color space of the color transfer function. * @param {ColorSpace} colorSpace */ - setColorSpace(colorSpace: ColorSpace): void; + setColorSpace(colorSpace: ColorSpace): boolean; /** * Get the scale of the color transfer function. @@ -346,7 +374,146 @@ export interface vtkColorTransferFunction extends vtkScalarsToColors { * Set the scale of the color transfer function. * @param {Scale} scale */ - setScale(scale: Scale): void; + setScale(scale: Scale): boolean; + + /** + * The timestamp of the last color table build. + */ + getBuildTime(): vtkObject; + + /** + * Get the color used for NaN values. + */ + getNanColor(): RGBAColor; + + /** + * Get the color used for NaN values, without copying it out of the model. + */ + getNanColorByReference(): RGBAColor; + + /** + * Set the color used for NaN values. + * @param {RGBAColor} nanColor + */ + setNanColor(nanColor: RGBAColor): boolean; + + /** + * Set the color used for NaN values. + */ + setNanColor(r: number, g: number, b: number, a: number): boolean; + + /** + * Copy the four components of the given color into the NaN color without + * marking the function modified. + */ + setNanColorFrom(nanColor: RGBAColor): void; + + /** + * Get the color used for values below the mapping range. + * @see getUseBelowRangeColor + */ + getBelowRangeColor(): RGBAColor; + + /** + * Get the below range color, without copying it out of the model. + */ + getBelowRangeColorByReference(): RGBAColor; + + /** + * Set the color used for values below the mapping range. + * @param {RGBAColor} belowRangeColor + */ + setBelowRangeColor(belowRangeColor: RGBAColor): boolean; + + /** + * Set the color used for values below the mapping range. + */ + setBelowRangeColor(r: number, g: number, b: number, a: number): boolean; + + /** + * Copy the four components of the given color into the below range color + * without marking the function modified. + */ + setBelowRangeColorFrom(belowRangeColor: RGBAColor): void; + + /** + * Get the color used for values above the mapping range. + * @see getUseAboveRangeColor + */ + getAboveRangeColor(): RGBAColor; + + /** + * Get the above range color, without copying it out of the model. + */ + getAboveRangeColorByReference(): RGBAColor; + + /** + * Set the color used for values above the mapping range. + * @param {RGBAColor} aboveRangeColor + */ + setAboveRangeColor(aboveRangeColor: RGBAColor): boolean; + + /** + * Set the color used for values above the mapping range. + */ + setAboveRangeColor(r: number, g: number, b: number, a: number): boolean; + + /** + * Copy the four components of the given color into the above range color + * without marking the function modified. + */ + setAboveRangeColorFrom(aboveRangeColor: RGBAColor): void; + + /** + * Whether values below the mapping range are mapped to the below range color + * rather than clamped to the first node. + * @default false + */ + getUseBelowRangeColor(): boolean; + + /** + * @param {Boolean} useBelowRangeColor + * @see getUseBelowRangeColor + */ + setUseBelowRangeColor(useBelowRangeColor: boolean): boolean; + + /** + * Whether values above the mapping range are mapped to the above range color + * rather than clamped to the last node. + * @default false + */ + getUseAboveRangeColor(): boolean; + + /** + * @param {Boolean} useAboveRangeColor + * @see getUseAboveRangeColor + */ + setUseAboveRangeColor(useAboveRangeColor: boolean): boolean; + + /** + * Whether the function is discretized into `numberOfValues` colors when it is + * used to build a table. + * @default false + */ + getDiscretize(): boolean; + + /** + * @param {Boolean} discretize + * @see getDiscretize + */ + setDiscretize(discretize: boolean): boolean; + + /** + * The number of colors the discretized function is built with. + * @default 256 + */ + getNumberOfValues(): number; + + /** + * @param {Number} numberOfValues + * @see getNumberOfValues + */ + setNumberOfValues(numberOfValues: number): boolean; } /** @@ -359,14 +526,16 @@ export interface vtkColorTransferFunction extends vtkScalarsToColors { export function extend( publicAPI: object, model: object, - initialValues?: object + initialValues?: IColorTransferFunctionInitialValues ): void; /** * Method use to create a new instance of vtkColorTransferFunction * @param {object} [initialValues] for pre-setting some of its content */ -export function newInstance(initialValues?: object): vtkColorTransferFunction; +export function newInstance( + initialValues?: IColorTransferFunctionInitialValues +): vtkColorTransferFunction; /** * vtkColorTransferFunction is a color mapping in RGB or HSV space that diff --git a/Sources/Rendering/Core/Coordinate/Constants.d.ts b/Sources/Rendering/Core/Coordinate/Constants.d.ts index 8f4b98d8a0a..d68259b1406 100644 --- a/Sources/Rendering/Core/Coordinate/Constants.d.ts +++ b/Sources/Rendering/Core/Coordinate/Constants.d.ts @@ -1,12 +1,14 @@ -export declare enum Coordinate { - DISPLAY = 0, - NORMALIZED_DISPLAY = 1, - VIEWPORT = 2, - NORMALIZED_VIEWPORT = 3, - PROJECTION = 4, - VIEW = 5, - WORLD = 6, -} +export declare const Coordinate: { + readonly DISPLAY: 0; + readonly NORMALIZED_DISPLAY: 1; + readonly VIEWPORT: 2; + readonly NORMALIZED_VIEWPORT: 3; + readonly PROJECTION: 4; + readonly VIEW: 5; + readonly WORLD: 6; +}; + +export type Coordinate = (typeof Coordinate)[keyof typeof Coordinate]; declare const _default: { Coordinate: typeof Coordinate; diff --git a/Sources/Rendering/Core/Coordinate/index.d.ts b/Sources/Rendering/Core/Coordinate/index.d.ts index 4b6b6a933de..50a3162afa3 100755 --- a/Sources/Rendering/Core/Coordinate/index.d.ts +++ b/Sources/Rendering/Core/Coordinate/index.d.ts @@ -1,6 +1,7 @@ import { vtkObject, vtkProperty } from '../../../interfaces'; import vtkRenderer from '../Renderer'; import { Coordinate } from './Constants'; +import { Nullable } from '../../../types'; /** * @@ -75,15 +76,20 @@ export interface vtkCoordinate extends vtkObject { */ getValue(): number[]; + /** + * Get the value of this coordinate. + */ + getValueByReference(): number[]; + /** * */ - getReferenceCoordinate(): vtkCoordinate; + getReferenceCoordinate(): Nullable; /** * Get mapper that was picked (if any) */ - getRenderer(): vtkRenderer; + getRenderer(): Nullable; /** * Set the coordinate system which this coordinate is defined in. The diff --git a/Sources/Rendering/Core/CubeAxesActor/index.d.ts b/Sources/Rendering/Core/CubeAxesActor/index.d.ts new file mode 100644 index 00000000000..d8bbf2eb923 --- /dev/null +++ b/Sources/Rendering/Core/CubeAxesActor/index.d.ts @@ -0,0 +1,333 @@ +import { mat4 } from 'gl-matrix'; +import { vtkObject } from '../../../interfaces'; +import { Bounds, Nullable, Vector2 } from '../../../types'; +import vtkPolyData from '../../../Common/DataModel/PolyData'; +import vtkActor, { IActorInitialValues } from '../Actor'; +import vtkCamera from '../Camera'; +import vtkTexture from '../Texture'; + +/** + * Styling of the text drawn into the label texture atlas. + */ +export interface ICubeAxesTextStyle { + fontColor?: string; + fontStyle?: string; + fontSize?: number; + fontFamily?: string; + strokeColor?: string; + strokeSize?: number; +} + +/** + * Tick positions and their formatted labels, one entry per axis. + */ +export interface IGeneratedTicks { + ticks: number[][]; + tickStrings: string[][]; +} + +/** + * Placement of one string inside the label texture atlas. + */ +export interface ITextAtlasEntry { + width: number; + height: number; + startingHeight: number; + textStyle: ICubeAxesTextStyle; + /** + * The four (u, v) pairs of the label quad, set once the atlas dimensions + * are known. + */ + tcoords?: number[]; +} + +/** + * Accumulator filled while building the label quads. + */ +export interface ILabelPolyDataResults { + ptIdx: number; + cellIdx: number; + points: Float64Array; + polys: Uint16Array; + tcoords: Float32Array; +} + +export interface ICubeAxesActorInitialValues extends IActorInitialValues { + /** + * Factor by which the grid bounds are expanded to account for the labels. + */ + boundsScaleFactor?: number; + camera?: Nullable; + dataBounds?: Bounds; + /** + * Angle in degrees under which a face is considered too edge-on to draw. + */ + faceVisibilityAngle?: number; + gridLines?: boolean; + axisLabels?: [string, string, string]; + axisTitlePixelOffset?: number; + tickLabelPixelOffset?: number; + generateTicks?: (dataBounds: Bounds) => IGeneratedTicks; + axisTextStyle?: ICubeAxesTextStyle; + tickTextStyle?: ICubeAxesTextStyle; +} + +export interface vtkCubeAxesActor extends vtkActor { + getAxisTitlePixelOffset(): number; + setAxisTitlePixelOffset(axisTitlePixelOffset: number): boolean; + + getBoundsScaleFactor(): number; + setBoundsScaleFactor(boundsScaleFactor: number): boolean; + + getFaceVisibilityAngle(): number; + setFaceVisibilityAngle(faceVisibilityAngle: number): boolean; + + getGridLines(): boolean; + setGridLines(gridLines: boolean): boolean; + + getTickLabelPixelOffset(): number; + setTickLabelPixelOffset(tickLabelPixelOffset: number): boolean; + + getGenerateTicks(): (dataBounds: Bounds) => IGeneratedTicks; + setGenerateTicks( + generateTicks: (dataBounds: Bounds) => IGeneratedTicks + ): boolean; + + getDataBounds(): Bounds; + getDataBoundsByReference(): Bounds; + setDataBounds(dataBounds: Bounds): boolean; + setDataBounds( + xMin: number, + xMax: number, + yMin: number, + yMax: number, + zMin: number, + zMax: number + ): boolean; + setDataBoundsFrom(dataBounds: Bounds): void; + + getAxisLabels(): [string, string, string]; + getAxisLabelsByReference(): [string, string, string]; + setAxisLabels(axisLabels: [string, string, string]): boolean; + setAxisLabels(x: string, y: string, z: string): boolean; + setAxisLabelsFrom(axisLabels: [string, string, string]): void; + + getAxisTextStyle(): ICubeAxesTextStyle; + + /** + * Merge the given properties into the axis title text style. + * @param {ICubeAxesTextStyle} axisStyle + */ + setAxisTextStyle(axisStyle: ICubeAxesTextStyle): void; + + getTickTextStyle(): ICubeAxesTextStyle; + + /** + * Merge the given properties into the tick label text style. + * @param {ICubeAxesTextStyle} tickStyle + */ + setTickTextStyle(tickStyle: ICubeAxesTextStyle): void; + + getCamera(): Nullable; + + /** + * Set the camera used to decide which faces are visible. The actor is + * updated on every camera modification. + * @param camera + */ + setCamera(camera: Nullable): void; + + /** + * Texture atlas holding the rendering of every label string. + */ + getTmTexture(): vtkTexture; + + /** + * The label strings, in the order the label quads are built. + */ + getTextValues(): string[]; + + /** + * Polydata holding the world coordinates the labels are anchored to. + */ + getTextPolyData(): vtkPolyData; + + /** + * Number of tick labels per drawn axis. + */ + getTickCounts(): number[]; + + /** + * The actor drawing the bounding edges and the grid lines. + */ + getGridActor(): vtkActor; + + /** + * Placement of every label string inside the texture atlas. + */ + get_tmAtlas(): Map; + + /** + * Recompute which of the six faces face the camera. + * @return true when the set of visible faces changed + */ + computeFacesToDraw(): boolean; + + /** + * Rebuild the polydata holding the bounding edges and the grid lines. + * @param {Boolean[]} facesToDraw one entry per face + * @param {Number[]} edgesToDraw number of drawn faces sharing each of the + * twelve edges; an edge is labeled when exactly one face uses it + * @param {Number[][]} ticks tick positions per axis + */ + updatePolyData( + facesToDraw: boolean[], + edgesToDraw: number[], + ticks: number[][] + ): void; + + /** + * Rebuild the world coordinates and the strings of the labels. + * @param {Boolean[]} facesToDraw one entry per face + * @param {Number[]} edgesToDraw number of drawn faces sharing each edge + * @param {Number[][]} ticks tick positions per axis + * @param {String[][]} tickStrings formatted tick labels per axis + */ + updateTextData( + facesToDraw: boolean[], + edgesToDraw: number[], + ticks: number[][], + tickStrings: string[][] + ): void; + + /** + * Redraw the label texture atlas. + * @param {String[][]} tickStrings formatted tick labels per axis + */ + updateTextureAtlas(tickStrings: string[][]): void; + + /** + * Rebuild whatever the current camera and data bounds invalidated. Called + * on every camera modification and on every modification of the actor. + */ + update(): void; +} + +export interface vtkCubeAxesActorHelper extends vtkObject { + getRenderable(): Nullable; + + /** + * Bind the helper to a cube axes actor and share its texture and property + * with the internal label actor. + * @param renderable + */ + setRenderable(renderable: vtkCubeAxesActor): void; + + getLastSize(): Vector2; + + getLastAspectRatio(): number; + + getAxisTextStyle(): ICubeAxesTextStyle; + + getTickTextStyle(): ICubeAxesTextStyle; + + /** + * The actor drawing the label quads. + */ + getTmActor(): vtkActor; + + getTicks(): number[][] | undefined; + + /** + * Append the two triangles and the texture coordinates of one label quad to + * `results`. + * @param {String} text the label string, looked up in the texture atlas + * @param {Number} pos index of the anchor point in the text polydata + * @param {mat4} cmat world to normalized device coordinates matrix + * @param {mat4} imat inverse of `cmat` + * @param {Vector2} dir screen space direction the label is pushed towards + * @param {Number} offset distance in pixels the label is pushed by + * @param {ILabelPolyDataResults} results accumulator, updated in place + */ + createPolyDataForOneLabel( + text: string, + pos: number, + cmat: mat4, + imat: mat4, + dir: Vector2, + offset: number, + results: ILabelPolyDataResults + ): void; + + /** + * Rebuild the label quads, which depend on the current camera. + */ + updateTexturePolyData(): void; + + /** + * Record the view resolution and camera, then rebuild the label quads. + * @param {Vector2} size the view size in pixels + * @param {vtkCamera} camera + * @param renderWindow + */ + updateAPISpecificData( + size: Vector2, + camera: vtkCamera, + renderWindow: unknown + ): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with + * vtkCubeAxesActor characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ICubeAxesActorInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ICubeAxesActorInitialValues +): void; + +/** + * Method used to create a new instance of vtkCubeAxesActor. + * @param {ICubeAxesActorInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: ICubeAxesActorInitialValues +): vtkCubeAxesActor; + +/** + * Create the view dependent companion of a cube axes actor. One helper is + * instantiated per view, as the label sizes depend on the view resolution. + * @param [initialValues] for pre-setting some of its content + */ +declare function newCubeAxesActorHelper(initialValues?: { + renderable?: Nullable; +}): vtkCubeAxesActorHelper; + +/** + * Default tick generator, producing about five d3 linear scale ticks per axis. + * @param {Bounds} dataBounds + */ +declare function defaultGenerateTicks(dataBounds: Bounds): IGeneratedTicks; + +/** + * vtkCubeAxesActor draws a labeled bounding box with tick marks and optional + * grid lines around a region of interest. Only the faces facing away from the + * camera are drawn, so the axes never occlude the data. + * + * The class is split in two: this actor holds the view independent properties + * while vtkCubeAxesActorHelper, created once per view, holds everything that + * depends on the view resolution and aspect ratio. + * @see [vtkAxesActor](./Rendering_Core_AxesActor.html) + */ +export declare const vtkCubeAxesActor: { + newInstance: typeof newInstance; + extend: typeof extend; + newCubeAxesActorHelper: typeof newCubeAxesActorHelper; + defaultGenerateTicks: typeof defaultGenerateTicks; +}; +export default vtkCubeAxesActor; diff --git a/Sources/Rendering/Core/Follower/index.d.ts b/Sources/Rendering/Core/Follower/index.d.ts index e5bd8846d5c..cd0b2914c62 100755 --- a/Sources/Rendering/Core/Follower/index.d.ts +++ b/Sources/Rendering/Core/Follower/index.d.ts @@ -1,5 +1,6 @@ import vtkActor, { IActorInitialValues } from '../Actor'; import vtkCamera from '../Camera'; +import { Nullable } from '../../../types'; /** * @@ -22,7 +23,7 @@ export interface vtkFollower extends vtkActor { /** * Get the camera to follow. */ - getCamera(): vtkCamera; + getCamera(): Nullable; /** * Check whether the view up vector is used. @@ -57,6 +58,12 @@ export interface vtkFollower extends vtkActor { * @param {Number[]} viewUp The view up vector. */ setViewUp(viewUp: number[]): boolean; + + /** + * Set the viewUp vector from an array. + * @param {Number[]} viewUp The view up vector. + */ + setViewUpFrom(viewUp: number[]): void; } /** diff --git a/Sources/Rendering/Core/Glyph3DMapper/Constants.d.ts b/Sources/Rendering/Core/Glyph3DMapper/Constants.d.ts index 59369bb1188..8eb4ce90e18 100644 --- a/Sources/Rendering/Core/Glyph3DMapper/Constants.d.ts +++ b/Sources/Rendering/Core/Glyph3DMapper/Constants.d.ts @@ -1,14 +1,19 @@ -export declare enum OrientationModes { - DIRECTION = 0, - ROTATION = 1, - MATRIX = 2, -} +export declare const OrientationModes: { + readonly DIRECTION: 0; + readonly ROTATION: 1; + readonly MATRIX: 2; +}; + +export type OrientationModes = + (typeof OrientationModes)[keyof typeof OrientationModes]; + +export declare const ScaleModes: { + readonly SCALE_BY_CONSTANT: 0; + readonly SCALE_BY_MAGNITUDE: 1; + readonly SCALE_BY_COMPONENTS: 2; +}; -export declare enum ScaleModes { - SCALE_BY_CONSTANT = 0, - SCALE_BY_MAGNITUDE = 1, - SCALE_BY_COMPONENTS = 2, -} +export type ScaleModes = (typeof ScaleModes)[keyof typeof ScaleModes]; declare const _default: { OrientationModes: typeof OrientationModes; diff --git a/Sources/Rendering/Core/Glyph3DMapper/index.d.ts b/Sources/Rendering/Core/Glyph3DMapper/index.d.ts index 85de5154073..673155ed74e 100755 --- a/Sources/Rendering/Core/Glyph3DMapper/index.d.ts +++ b/Sources/Rendering/Core/Glyph3DMapper/index.d.ts @@ -1,4 +1,6 @@ import { Bounds, Nullable, vtkPipelineConnection } from '../../../types'; +import { vtkObject } from '../../../interfaces'; +import vtkDataArray from '../../../Common/Core/DataArray'; import vtkMapper, { IMapperInitialValues } from '../Mapper'; import { OrientationModes, ScaleModes } from './Constants'; @@ -64,12 +66,12 @@ export interface vtkGlyph3DMapper extends vtkMapper { /** * Gets the name of the array used as scale values. */ - getScaleArray(): string; + getScaleArray(): Nullable; /** * Get scale mode as array */ - getScaleArrayData(): number[]; + getScaleArrayData(): vtkDataArray | null; /** * An orientation array is a vtkDataArray with 3 components. The first @@ -94,7 +96,7 @@ export interface vtkGlyph3DMapper extends vtkMapper { /** * Get orientation as array */ - getOrientationArrayData(): number[]; + getOrientationArrayData(): vtkDataArray | null; /** * Sets the name of the array to use as orientation. @@ -105,7 +107,7 @@ export interface vtkGlyph3DMapper extends vtkMapper { /** * Gets the name of the array used as orientation values. */ - getOrientationArray(): string; + getOrientationArray(): Nullable; /** * Orientation mode indicates if the OrientationArray provides the direction @@ -164,6 +166,55 @@ export interface vtkGlyph3DMapper extends vtkMapper { * @param {vtkPipelineConnection} outputPort The output port of the glyph source. */ setSourceConnection(outputPort: vtkPipelineConnection): void; + + /** + * Timestamp of the last `buildArrays()` execution. + */ + getBuildTime(): vtkObject; + + /** + * Colors computed by `buildArrays()` by mapping the input scalars through the + * lookup table. Null when there is no lookup table or no scalars. + */ + getColorArray(): Nullable; + + /** + * Per-glyph 4x4 model matrices computed by `buildArrays()`, packed as 16 + * floats per input point. + */ + getMatrixArray(): Nullable; + + /** + * Per-glyph 3x3 normal matrices computed by `buildArrays()`, packed as 9 + * floats per input point. + */ + getNormalArray(): Nullable; + + /** + * Check whether glyphs are oriented using the orientation array. + * @default true + */ + getOrient(): boolean; + + /** + * Turn on/off orienting glyphs with the orientation array. + * @param {Boolean} orient + * @default true + */ + setOrient(orient: boolean): boolean; + + /** + * Check whether glyphs are scaled using the scale array and scale factor. + * @default true + */ + getScaling(): boolean; + + /** + * Turn on/off scaling glyphs with the scale array and scale factor. + * @param {Boolean} scaling + * @default true + */ + setScaling(scaling: boolean): boolean; } /** diff --git a/Sources/Rendering/Core/ImageArrayMapper/index.d.ts b/Sources/Rendering/Core/ImageArrayMapper/index.d.ts index b9c94f1e780..77e3a19aafe 100644 --- a/Sources/Rendering/Core/ImageArrayMapper/index.d.ts +++ b/Sources/Rendering/Core/ImageArrayMapper/index.d.ts @@ -18,12 +18,12 @@ interface ISliceToSubSlice { } export interface IImageArrayMapperInitialValues extends IAbstractImageMapperInitialValues { - slicingMode: SlicingMode.K; - sliceToSubSliceMap: ISliceToSubSlice[]; + slicingMode?: SlicingMode; + sliceToSubSliceMap?: ISliceToSubSlice[]; } export interface vtkImageArrayMapper - extends vtkAbstractImageMapper, CoincidentTopologyHelper { + extends Omit, CoincidentTopologyHelper { /** * * @param inputData set input as a vtkCollection of vtkImageData objects. @@ -73,11 +73,17 @@ export interface vtkImageArrayMapper */ getTotalSlices(): number; + /** + * Get the slicing mode used to index into each image of the collection. + * @default SlicingMode.K + */ + getSlicingMode(): SlicingMode; + /** * * @param {Number} slice The slice index. */ - setSlice(slice: number): boolean; + setSlice(slice: number): void; /** * Calculate the global slice number that corresponds to the provided image and subSlice number. @@ -101,12 +107,6 @@ export interface vtkImageArrayMapper */ getSubSlice(slice?: number): number; - /** - * Set the slicing mode. - * @param {Number} mode The slicing mode. - */ - setSlicingMode(mode: number): boolean; - /** * * @param {Number[]} p1 The coordinates of the first point. @@ -154,6 +154,5 @@ export function newInstance( export declare const vtkImageArrayMapper: { newInstance: typeof newInstance; extend: typeof extend; - SlicingMode: typeof SlicingMode; } & StaticCoincidentTopologyMethods; export default vtkImageArrayMapper; diff --git a/Sources/Rendering/Core/ImageCPRMapper/Constants.d.ts b/Sources/Rendering/Core/ImageCPRMapper/Constants.d.ts index 25619ff0e41..8938273adbe 100644 --- a/Sources/Rendering/Core/ImageCPRMapper/Constants.d.ts +++ b/Sources/Rendering/Core/ImageCPRMapper/Constants.d.ts @@ -1,8 +1,11 @@ -export declare enum ProjectionMode { - MAX = 0, - MIN = 1, - AVERAGE = 2, -} +export declare const ProjectionMode: { + readonly MAX: 0; + readonly MIN: 1; + readonly AVERAGE: 2; +}; + +export type ProjectionMode = + (typeof ProjectionMode)[keyof typeof ProjectionMode]; declare const _default: { ProjectionMode: typeof ProjectionMode; diff --git a/Sources/Rendering/Core/ImageCPRMapper/index.d.ts b/Sources/Rendering/Core/ImageCPRMapper/index.d.ts index 39d9a282d84..366d21ed323 100644 --- a/Sources/Rendering/Core/ImageCPRMapper/index.d.ts +++ b/Sources/Rendering/Core/ImageCPRMapper/index.d.ts @@ -2,9 +2,9 @@ import { mat3, mat4, quat, vec3 } from 'gl-matrix'; import { Nullable } from '../../../types'; import { vtkOutputPort } from '../../../interfaces'; import { - vtkAbstractMapper3D, - IAbstractMapper3DInitialValues, -} from '../AbstractMapper3D'; + vtkAbstractImageMapper, + IAbstractImageMapperInitialValues, +} from '../AbstractImageMapper'; import { vtkDataArray } from '../../../Common/Core/DataArray'; import { vtkImageData } from '../../../Common/DataModel/ImageData'; import { vtkPolyData } from '../../../Common/DataModel/PolyData'; @@ -17,19 +17,19 @@ import { type TOrientation = mat4 | mat3 | quat | vec3; -export interface IImageCPRMapperInitialValues extends IAbstractMapper3DInitialValues { - width: number; - uniformOrientation: TOrientation; // Don't use vec3 if possible - useUniformOrientation: boolean; - preferSizeOverAccuracy: boolean; // Whether to use halfFloat representation of float, when it is inaccurate - orientationArrayName: Nullable; - tangentDirection: vec3; - bitangentDirection: vec3; - normalDirection: vec3; +export interface IImageCPRMapperInitialValues extends IAbstractImageMapperInitialValues { + width?: number; + uniformOrientation?: TOrientation; // Don't use vec3 if possible + useUniformOrientation?: boolean; + preferSizeOverAccuracy?: boolean; // Whether to use halfFloat representation of float, when it is inaccurate + orientationArrayName?: Nullable; + tangentDirection?: vec3; + bitangentDirection?: vec3; + normalDirection?: vec3; } export interface vtkImageCPRMapper - extends vtkAbstractMapper3D, CoincidentTopologyHelper { + extends vtkAbstractImageMapper, CoincidentTopologyHelper { /** * @returns the width of the image in model coordinates of the input volume */ diff --git a/Sources/Rendering/Core/ImageMapper/Constants.d.ts b/Sources/Rendering/Core/ImageMapper/Constants.d.ts index e72282f3cc6..34974a589bd 100644 --- a/Sources/Rendering/Core/ImageMapper/Constants.d.ts +++ b/Sources/Rendering/Core/ImageMapper/Constants.d.ts @@ -1,12 +1,14 @@ -export declare enum SlicingMode { - NONE = -1, - I = 0, - J = 1, - K = 2, - X = 3, - Y = 4, - Z = 5, -} +export declare const SlicingMode: { + readonly NONE: -1; + readonly I: 0; + readonly J: 1; + readonly K: 2; + readonly X: 3; + readonly Y: 4; + readonly Z: 5; +}; + +export type SlicingMode = (typeof SlicingMode)[keyof typeof SlicingMode]; declare const _default: { SlicingMode: typeof SlicingMode; diff --git a/Sources/Rendering/Core/ImageMapper/index.d.ts b/Sources/Rendering/Core/ImageMapper/index.d.ts index f60e06549cd..3a1b4557f56 100755 --- a/Sources/Rendering/Core/ImageMapper/index.d.ts +++ b/Sources/Rendering/Core/ImageMapper/index.d.ts @@ -17,6 +17,8 @@ export interface IClosestIJKAxis { } export interface IImageMapperInitialValues extends IAbstractImageMapperInitialValues { + preferSizeOverAccuracy?: boolean; + slicingMode?: SlicingMode; closestIJKAxis?: IClosestIJKAxis; renderToRectangle?: boolean; sliceAtFocalPoint?: boolean; @@ -108,7 +110,7 @@ export interface vtkImageMapper * Set the slice from a given camera. * @param {vtkCamera} cam The camera object. */ - setSliceFromCamera(cam: vtkCamera): boolean; + setSliceFromCamera(cam: vtkCamera): void; /** * Set the slice from a given focal point. @@ -120,37 +122,37 @@ export interface vtkImageMapper * Set the slice for the X axis. * @param {Number} id The slice index. */ - setXSlice(id: number): boolean; + setXSlice(id: number): void; /** * Set the slice for the Y axis. * @param {Number} id The slice index. */ - setYSlice(id: number): boolean; + setYSlice(id: number): void; /** * Set the slice for the Z axis. * @param {Number} id The slice index. */ - setZSlice(id: number): boolean; + setZSlice(id: number): void; /** * Set the slice for the I axis. * @param {Number} id The slice index. */ - setISlice(id: number): boolean; + setISlice(id: number): void; /** * Set the slice for the J axis. * @param {Number} id The slice index. */ - setJSlice(id: number): boolean; + setJSlice(id: number): void; /** * Set the slice for the K axis. * @param {Number} id The slice index. */ - setKSlice(id: number): boolean; + setKSlice(id: number): void; /** * @@ -166,7 +168,7 @@ export interface vtkImageMapper * Set the slicing mode. * @param {SlicingMode} mode The slicing mode. */ - setSlicingMode(mode: SlicingMode): boolean; + setSlicingMode(mode: SlicingMode): void; /** * Get the preference to use halfFloat representation of float diff --git a/Sources/Rendering/Core/ImageProperty/Constants.d.ts b/Sources/Rendering/Core/ImageProperty/Constants.d.ts index 0dcf153d285..783b720f7e3 100644 --- a/Sources/Rendering/Core/ImageProperty/Constants.d.ts +++ b/Sources/Rendering/Core/ImageProperty/Constants.d.ts @@ -1,7 +1,10 @@ -export declare enum InterpolationType { - NEAREST = 0, - LINEAR = 1, -} +export declare const InterpolationType: { + readonly NEAREST: 0; + readonly LINEAR: 1; +}; + +export type InterpolationType = + (typeof InterpolationType)[keyof typeof InterpolationType]; declare const _default: { InterpolationType: typeof InterpolationType; diff --git a/Sources/Rendering/Core/ImageProperty/index.d.ts b/Sources/Rendering/Core/ImageProperty/index.d.ts index 4d022580888..7b38984d42c 100755 --- a/Sources/Rendering/Core/ImageProperty/index.d.ts +++ b/Sources/Rendering/Core/ImageProperty/index.d.ts @@ -148,6 +148,12 @@ export interface vtkImageProperty extends vtkObject { */ setLabelOutlineThickness(labelOutlineThickness: number | number[]): boolean; + /** + * Set the label outline thickness from an array. + * @param {Number[]} labelOutlineThickness + */ + setLabelOutlineThicknessFrom(labelOutlineThickness: number[]): void; + /** * Set the ambient lighting coefficient. * @param {Number} ambient The ambient lighting coefficient. @@ -245,6 +251,13 @@ export interface vtkImageProperty extends vtkObject { */ setUseLookupTableScalarRange(useLookupTableScalarRange: boolean): boolean; + /** + * Check whether the range set on the lookup table is used instead of the + * range derived from the ColorWindow/ColorLevel settings. + * @default false + */ + getUseLookupTableScalarRange(): boolean; + /** * Informs the mapper to only update the specified extents at the next render. * diff --git a/Sources/Rendering/Core/ImageResliceMapper/Constants.d.ts b/Sources/Rendering/Core/ImageResliceMapper/Constants.d.ts index a39d945f50b..fbe931691c6 100644 --- a/Sources/Rendering/Core/ImageResliceMapper/Constants.d.ts +++ b/Sources/Rendering/Core/ImageResliceMapper/Constants.d.ts @@ -1,9 +1,11 @@ -export declare enum SlabTypes { - MIN = 0, - MAX = 1, - MEAN = 2, - SUM = 3, -} +export declare const SlabTypes: { + readonly MIN: 0; + readonly MAX: 1; + readonly MEAN: 2; + readonly SUM: 3; +}; + +export type SlabTypes = (typeof SlabTypes)[keyof typeof SlabTypes]; declare const _default: { SlabTypes: typeof SlabTypes; diff --git a/Sources/Rendering/Core/ImageResliceMapper/index.d.ts b/Sources/Rendering/Core/ImageResliceMapper/index.d.ts index 241e043f107..577cafa7597 100755 --- a/Sources/Rendering/Core/ImageResliceMapper/index.d.ts +++ b/Sources/Rendering/Core/ImageResliceMapper/index.d.ts @@ -4,7 +4,7 @@ import { } from '../AbstractImageMapper'; import { vtkPlane } from '../../../Common/DataModel/Plane'; import { vtkPolyData } from '../../../Common/DataModel/PolyData'; -import { Bounds } from '../../../types'; +import { Bounds, Nullable } from '../../../types'; import { SlabTypes } from './Constants'; import { CoincidentTopologyHelper, @@ -54,13 +54,13 @@ export interface vtkImageResliceMapper * * Get the implicit plane used to slice the volume with. */ - getSlicePlane(): vtkPlane; + getSlicePlane(): Nullable; /** * * Get the custom polydata used to slice the volume with. */ - getSlicePolyData(): vtkPolyData; + getSlicePolyData(): Nullable; /** * diff --git a/Sources/Rendering/Core/ImageSlice/index.d.ts b/Sources/Rendering/Core/ImageSlice/index.d.ts index 71e3466a68f..0a4410ad5db 100755 --- a/Sources/Rendering/Core/ImageSlice/index.d.ts +++ b/Sources/Rendering/Core/ImageSlice/index.d.ts @@ -1,4 +1,4 @@ -import { Bounds } from '../../../types'; +import { Bounds, Nullable } from '../../../types'; import vtkImageProperty, { IImagePropertyInitialValues, } from '../ImageProperty'; @@ -6,6 +6,8 @@ import vtkAbstractImageMapper from '../AbstractImageMapper'; import vtkProp3D, { IProp3DInitialValues } from '../Prop3D'; export interface IImageSliceInitialValues extends IProp3DInitialValues { + forceOpaque?: boolean; + forceTranslucent?: boolean; mapper?: vtkAbstractImageMapper; property?: vtkImageProperty; bounds?: Bounds; @@ -38,7 +40,7 @@ export interface vtkImageSlice extends vtkProp3D { /** * */ - getMapper(): vtkAbstractImageMapper; + getMapper(): Nullable; /** * Get the minimum X bound @@ -113,6 +115,16 @@ export interface vtkImageSlice extends vtkProp3D { */ setMapper(mapper: vtkAbstractImageMapper): boolean; + /** + * If true, render during the opaque pass even if the opacity value is below 1.0. + */ + getForceOpaque(): boolean; + + /** + * If true, render during the translucent pass even if the opacity value is 1.0. + */ + getForceTranslucent(): boolean; + /** * * @param {boolean} forceOpaque If true, render during opaque pass even if opacity value is below 1.0. diff --git a/Sources/Rendering/Core/InteractorObserver/index.d.ts b/Sources/Rendering/Core/InteractorObserver/index.d.ts index 119feeb6f2d..abf0b14c810 100644 --- a/Sources/Rendering/Core/InteractorObserver/index.d.ts +++ b/Sources/Rendering/Core/InteractorObserver/index.d.ts @@ -1,7 +1,13 @@ import { vtkRenderer } from '../Renderer'; import { vtkRenderWindowInteractor } from '../RenderWindowInteractor'; import { vtkObject, EventHandler, vtkSubscription } from '../../../interfaces'; -import { Vector3 } from '../../../types'; +import { Nullable, Vector3 } from '../../../types'; + +export interface IInteractorObserverInitialValues { + enabled?: boolean; + priority?: number; + processEvents?: boolean; +} export interface vtkInteractorObserver extends vtkObject { /** @@ -120,7 +126,7 @@ export interface vtkInteractorObserver extends vtkObject { x: number, y: number, z: number - ): Vector3; + ): Nullable; /** * Transform from display to world coordinates. @@ -135,8 +141,69 @@ export interface vtkInteractorObserver extends vtkObject { x: number, y: number, z: number - ): Vector3; + ): Nullable; } -declare const _default: vtkInteractorObserver; +/** + * Transform from world to display coordinates. + * + * @param {vtkRenderer} renderer The vtkRenderer instance. + * @param {Number} x + * @param {Number} y + * @param {Number} z + */ +declare function computeWorldToDisplay( + renderer: vtkRenderer, + x: number, + y: number, + z: number +): Vector3; + +/** + * Transform from display to world coordinates. + * + * @param {vtkRenderer} renderer The vtkRenderer instance. + * @param {Number} x + * @param {Number} y + * @param {Number} z + */ +declare function computeDisplayToWorld( + renderer: vtkRenderer, + x: number, + y: number, + z: number +): Vector3; + +/** + * Method used to decorate a given object (publicAPI+model) with + * vtkInteractorObserver characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IInteractorObserverInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IInteractorObserverInitialValues +): void; + +/** + * Method used to create a new instance of vtkInteractorObserver. + * @param {IInteractorObserverInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IInteractorObserverInitialValues +): vtkInteractorObserver; + +declare const _default: { + newInstance: typeof newInstance; + extend: typeof extend; + computeWorldToDisplay: typeof computeWorldToDisplay; + computeDisplayToWorld: typeof computeDisplayToWorld; +}; +export declare const STATIC: Readonly<{ + computeWorldToDisplay: typeof computeWorldToDisplay; + computeDisplayToWorld: typeof computeDisplayToWorld; +}>; export default _default; diff --git a/Sources/Rendering/Core/InteractorStyle/Constants.d.ts b/Sources/Rendering/Core/InteractorStyle/Constants.d.ts index 029a54005bc..68dc646548f 100644 --- a/Sources/Rendering/Core/InteractorStyle/Constants.d.ts +++ b/Sources/Rendering/Core/InteractorStyle/Constants.d.ts @@ -1,16 +1,18 @@ -export declare enum States { - IS_START = 0, - IS_NONE = 0, - IS_ROTATE = 1, - IS_PAN = 2, - IS_SPIN = 3, - IS_DOLLY = 4, - IS_CAMERA_POSE = 11, - IS_WINDOW_LEVEL = 1024, - IS_SLICE = 1025, -} +export declare const States: { + readonly IS_START: 0; + readonly IS_NONE: 0; + readonly IS_ROTATE: 1; + readonly IS_PAN: 2; + readonly IS_SPIN: 3; + readonly IS_DOLLY: 4; + readonly IS_CAMERA_POSE: 11; + readonly IS_WINDOW_LEVEL: 1024; + readonly IS_SLICE: 1025; +}; + +export type States = (typeof States)[keyof typeof States]; declare const _default: { - States: States; + States: typeof States; }; export default _default; diff --git a/Sources/Rendering/Core/InteractorStyle/index.d.ts b/Sources/Rendering/Core/InteractorStyle/index.d.ts index 4f6b743a11b..0d88eb8255b 100644 --- a/Sources/Rendering/Core/InteractorStyle/index.d.ts +++ b/Sources/Rendering/Core/InteractorStyle/index.d.ts @@ -1,5 +1,6 @@ import { EventHandler, vtkSubscription } from '../../../interfaces'; import { Nullable } from '../../../types'; +import { States } from './Constants'; import { vtkInteractorObserver } from '../InteractorObserver'; import { vtkRenderer } from '../Renderer'; @@ -237,8 +238,18 @@ export function extend( initialValues?: IInteractorStyleInitialValues ): void; +/** + * Method used to create a new instance of vtkInteractorStyle + * @param {IInteractorStyleInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IInteractorStyleInitialValues +): vtkInteractorStyle; + export const vtkInteractorStyle: { + newInstance: typeof newInstance; extend: typeof extend; + States: typeof States; }; export default vtkInteractorStyle; diff --git a/Sources/Rendering/Core/Light/index.d.ts b/Sources/Rendering/Core/Light/index.d.ts index 255838c9db1..0d2c672399f 100755 --- a/Sources/Rendering/Core/Light/index.d.ts +++ b/Sources/Rendering/Core/Light/index.d.ts @@ -9,6 +9,7 @@ export enum LIGHT_TYPES { } export interface ILightInitialValues { + transformMatrix?: mat4; switch?: boolean; intensity?: number; color?: RGBColor; @@ -111,6 +112,26 @@ export interface vtkLight extends vtkObject { */ getPositional(): boolean; + /** + * Get the shadow intensity of the light. + * By default a light will be completely blocked when in shadow. By setting + * this value to less than 1.0 you can control how much light is attenuated + * when in shadow. + */ + getShadowAttenuation(): number; + + /** + * Get whether the light is on or off. + */ + getSwitch(): boolean; + + /** + * Get the light's transformation matrix. If a matrix is set for a light, + * the light's parameters (position and focal point) are transformed by the + * matrix before being rendered. + */ + getTransformMatrix(): mat4 | null; + /** * Get the position of the light, modified by the transformation matrix (if * it exists). @@ -135,7 +156,7 @@ export interface vtkLight extends vtkObject { * Set the quadratic attenuation constants from an array. * @param {Number[]} attenuationValues The quadratic attenuation. */ - setAttenuationValuesFrom(attenuationValues: number[]): boolean; + setAttenuationValuesFrom(attenuationValues: number[]): void; /** * Set the color of the object. Has the side effect of setting the @@ -155,23 +176,13 @@ export interface vtkLight extends vtkObject { */ setColor(color: RGBColor): boolean; - /** - * Set the color of the object. Has the side effect of setting the - * ambient diffuse and specular colors as well. This is basically - * a quick overall color setting method. - * @param {Number} r Defines the red component (between 0 and 1). - * @param {Number} g Defines the green component (between 0 and 1). - * @param {Number} b Defines the blue component (between 0 and 1). - */ - setColorFrom(r: number, g: number, b: number): boolean; - /** * Set the color of the object. Has the side effect of setting the * ambient diffuse and specular colors as well. This is basically * a quick overall color setting method. * @param {RGBColor} color Defines the RGB color array.. */ - setColorFrom(color: RGBColor): boolean; + setColorFrom(color: RGBColor): void; /** * Set the lighting cone angle of a positional light in degrees. @@ -201,21 +212,13 @@ export interface vtkLight extends vtkObject { * @param {Number} elevation * @param {Number} azimuth */ - setDirectionAngle(elevation: number, azimuth: number): boolean; - - /** - * Set the direction vector of the light from X, Y, and Z values - * @param {Number} x The x coordinate. - * @param {Number} y The y coordinate. - * @param {Number} z The z coordinate. - */ - setDirection(x: number, y: number, z: number): boolean; + setDirectionAngle(elevation: number, azimuth: number): void; /** * Set the direction vector of the light from X, Y, and Z values * @param {Vector3} direction */ - setDirection(direction: Vector3): boolean; + setDirection(direction: Vector3): void; /** * Set the exponent of the cosine used in positional lighting. @@ -235,7 +238,7 @@ export interface vtkLight extends vtkObject { * Set the focal point from an array * @param {Vector3} focalPoint The focal point array. */ - setFocalPointFrom(focalPoint: Vector3): boolean; + setFocalPointFrom(focalPoint: Vector3): void; /** * Set the brightness of the light (from one to zero). @@ -252,17 +255,17 @@ export interface vtkLight extends vtkObject { /** * Set the type of the light is CameraLight. */ - setLightTypeToCameraLight(): boolean; + setLightTypeToCameraLight(): void; /** * Set the the type of the light is HeadLight. */ - setLightTypeToHeadLight(): boolean; + setLightTypeToHeadLight(): void; /** * Set the the type of the light is SceneLight. */ - setLightTypeToSceneLight(): boolean; + setLightTypeToSceneLight(): void; /** * Check if the type of the light is CameraLight. @@ -291,7 +294,7 @@ export interface vtkLight extends vtkObject { * Set the position of the light. * @param {Vector3} position The position coordinate of the light. */ - setPositionFrom(position: Vector3): boolean; + setPositionFrom(position: Vector3): void; /** * Turn positional lighting on or off. diff --git a/Sources/Rendering/Core/Mapper/CoincidentTopologyHelper.d.ts b/Sources/Rendering/Core/Mapper/CoincidentTopologyHelper.d.ts index 12858971d9e..9286ff9bf6f 100644 --- a/Sources/Rendering/Core/Mapper/CoincidentTopologyHelper.d.ts +++ b/Sources/Rendering/Core/Mapper/CoincidentTopologyHelper.d.ts @@ -8,7 +8,14 @@ export enum Resolve { PolygonOffset, } -export interface StaticCoincidentTopologyMethods { +export const CATEGORIES: string[]; + +export interface StaticOffsetAPI { + /** + * + */ + modified(): void; + /** * * @param {ICoincidentTopology} params @@ -77,17 +84,21 @@ export interface StaticCoincidentTopologyMethods { * */ getResolveCoincidentTopologyPolygonOffsetParameters(): ICoincidentTopology; +} + +export interface OtherStaticMethods { + Resolve: typeof Resolve; /** * */ - getResolveCoincidentTopologyPolygonOffsetFaces(): ICoincidentTopology; + getResolveCoincidentTopologyPolygonOffsetFaces(): Resolve; /** * * @param {Number} value */ - setResolveCoincidentTopologyPolygonOffsetFaces(value: number): boolean; + setResolveCoincidentTopologyPolygonOffsetFaces(value: Resolve): boolean; /** * @@ -121,6 +132,9 @@ export interface StaticCoincidentTopologyMethods { getResolveCoincidentTopologyAsString(): string; } +export interface StaticCoincidentTopologyMethods + extends StaticOffsetAPI, OtherStaticMethods {} + export interface CoincidentTopologyHelper extends StaticCoincidentTopologyMethods { /** * @@ -176,6 +190,21 @@ export interface CoincidentTopologyHelper extends StaticCoincidentTopologyMethod offset: number ): boolean; + /** + * + */ + getRelativeCoincidentTopologyLineOffsetParameters(): ICoincidentTopology; + + /** + * + */ + getRelativeCoincidentTopologyPointOffsetParameters(): ICoincidentTopology; + + /** + * + */ + getRelativeCoincidentTopologyPolygonOffsetParameters(): ICoincidentTopology; + /** * */ @@ -189,8 +218,21 @@ export interface CoincidentTopologyHelper extends StaticCoincidentTopologyMethod /** * */ - getCoincidentTopologyPointOffsetParameters(): ICoincidentTopology; + getCoincidentTopologyPointOffsetParameter(): ICoincidentTopology; } -declare const _default: CoincidentTopologyHelper; -export default _default; +declare const vtkCoincidentTopologyHelper: { + /** + * Method used to decorate a given object (publicAPI+model) with coincident + * topology methods. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + */ + implementCoincidentTopologyMethods(publicAPI: object, model: object): void; + staticOffsetAPI: StaticOffsetAPI; + otherStaticMethods: OtherStaticMethods; + CATEGORIES: string[]; + Resolve: typeof Resolve; +}; +export default vtkCoincidentTopologyHelper; diff --git a/Sources/Rendering/Core/Mapper/Constants.d.ts b/Sources/Rendering/Core/Mapper/Constants.d.ts index 8788cfb346c..69ed40691b4 100644 --- a/Sources/Rendering/Core/Mapper/Constants.d.ts +++ b/Sources/Rendering/Core/Mapper/Constants.d.ts @@ -1,22 +1,28 @@ -export declare enum ColorMode { - DEFAULT = 0, - MAP_SCALARS = 1, - DIRECT_SCALARS = 2, -} +export declare const ColorMode: { + readonly DEFAULT: 0; + readonly MAP_SCALARS: 1; + readonly DIRECT_SCALARS: 2; +}; -export declare enum ScalarMode { - DEFAULT = 0, - USE_POINT_DATA = 1, - USE_CELL_DATA = 2, - USE_POINT_FIELD_DATA = 3, - USE_CELL_FIELD_DATA = 4, - USE_FIELD_DATA = 5, -} +export type ColorMode = (typeof ColorMode)[keyof typeof ColorMode]; -export declare enum GetArray { - BY_ID = 0, - BY_NAME = 1, -} +export declare const ScalarMode: { + readonly DEFAULT: 0; + readonly USE_POINT_DATA: 1; + readonly USE_CELL_DATA: 2; + readonly USE_POINT_FIELD_DATA: 3; + readonly USE_CELL_FIELD_DATA: 4; + readonly USE_FIELD_DATA: 5; +}; + +export type ScalarMode = (typeof ScalarMode)[keyof typeof ScalarMode]; + +export declare const GetArray: { + readonly BY_ID: 0; + readonly BY_NAME: 1; +}; + +export type GetArray = (typeof GetArray)[keyof typeof GetArray]; /** * Debug output channels for PBR material inspection. diff --git a/Sources/Rendering/Core/Mapper/ScalarColoringHelper.d.ts b/Sources/Rendering/Core/Mapper/ScalarColoringHelper.d.ts index ba9f189cb1a..3f8c5758ed1 100644 --- a/Sources/Rendering/Core/Mapper/ScalarColoringHelper.d.ts +++ b/Sources/Rendering/Core/Mapper/ScalarColoringHelper.d.ts @@ -1,5 +1,7 @@ import { Nullable, Range } from '../../../types'; import { vtkDataArray } from '../../../Common/Core/DataArray'; +import { vtkScalarsToColors } from '../../../Common/Core/ScalarsToColors'; +import { vtkImageData } from '../../../Common/DataModel/ImageData'; import { ColorMode, ScalarMode } from './Constants'; /** @@ -131,14 +133,14 @@ export interface IScalarColoring { /** * Return the generated color texture, or null if none exists. */ - getColorTextureMap(): any; + getColorTextureMap(): Nullable; /** * Return the field-data tuple that colors the data set. * * @default -1 */ - getFieldDataTupleId(): any; + getFieldDataTupleId(): number; /** * Return true if the mapper maps point scalars before interpolation. @@ -153,7 +155,7 @@ export interface IScalarColoring { /** * Return the lookup table. Create a default table if no table exists. */ - getLookupTable(): any; + getLookupTable(): Nullable; /** * Return the number of colors that map values in the scalar range. @@ -280,7 +282,7 @@ export interface IScalarColoring { * @param lookupTable - The lookup table to use. * @returns True if the value changed. */ - setLookupTable(lookupTable: any): boolean; + setLookupTable(lookupTable: Nullable): boolean; /** * Set the source of the scalar data. diff --git a/Sources/Rendering/Core/Mapper/index.d.ts b/Sources/Rendering/Core/Mapper/index.d.ts index ff18d289227..76ee395760e 100755 --- a/Sources/Rendering/Core/Mapper/index.d.ts +++ b/Sources/Rendering/Core/Mapper/index.d.ts @@ -3,7 +3,7 @@ import { vtkAbstractMapper3D, IAbstractMapper3DInitialValues, } from '../AbstractMapper3D'; -import { ColorMode, GetArray, ScalarMode } from './Constants'; +import { ColorMode, DebugChannel, GetArray, ScalarMode } from './Constants'; import { CoincidentTopologyHelper, StaticCoincidentTopologyMethods, @@ -31,7 +31,10 @@ export interface IMapperInitialValues renderTime?: number; forceCompileOnly?: number; useInvertibleColors?: boolean; - customShaderAttributes?: any; + customShaderAttributes?: string[]; + debugChannel?: DebugChannel; + populateSelectionSettings?: boolean; + selectionWebGLIdsToVTKIds?: Nullable; } export interface vtkMapper @@ -61,7 +64,13 @@ export interface vtkMapper * * @default [] */ - getCustomShaderAttributes(): any; + getCustomShaderAttributes(): string[]; + + /** Get the material channel shown for debugging. */ + getDebugChannel(): DebugChannel; + + /** Select the material channel shown for debugging. */ + setDebugChannel(debugChannel: DebugChannel): boolean; /** * Check if the mapper does not expect to have translucent geometry. This @@ -121,7 +130,7 @@ export interface vtkMapper * @param {Number} forceCompileOnly * @default 0 */ - setForceCompileOnly(forceCompileOnly: number): boolean; + setForceCompileOnly(forceCompileOnly: number): void; /** * Set whether selection ID mappings should be populated. @@ -232,5 +241,6 @@ export declare const vtkMapper: { ColorMode: typeof ColorMode; ScalarMode: typeof ScalarMode; GetArray: typeof GetArray; + DebugChannel: typeof DebugChannel; } & StaticCoincidentTopologyMethods; export default vtkMapper; diff --git a/Sources/Rendering/Core/Mapper2D/index.d.ts b/Sources/Rendering/Core/Mapper2D/index.d.ts index 86e562ddb72..982d007e7d0 100644 --- a/Sources/Rendering/Core/Mapper2D/index.d.ts +++ b/Sources/Rendering/Core/Mapper2D/index.d.ts @@ -4,34 +4,26 @@ import vtkAbstractMapper, { import { IPrimitiveCount } from '../Mapper'; import { IScalarColoringInitialValues, - TScalarColoringWithout, + IScalarColoring, } from '../Mapper/ScalarColoringHelper'; - -export { ColorMode, GetArray, ScalarMode } from '../Mapper/Constants'; +import { Nullable } from '../../../types'; +import { vtkCoordinate } from '../Coordinate'; export interface IMapper2DInitialValues extends IAbstractMapperInitialValues, IScalarColoringInitialValues { - customShaderAttributes?: any; + customShaderAttributes?: string[]; renderTime?: number; static?: boolean; + transformCoordinate?: Nullable; + viewSpecificProperties?: object; } -export interface vtkMapper2D - extends - vtkAbstractMapper, - TScalarColoringWithout< - | 'clearColorArrays' - | 'getFieldDataTupleId' - | 'getInterpolateScalarsBeforeMapping' - | 'getNumberOfColorsInRange' - | 'setFieldDataTupleId' - | 'setInterpolateScalarsBeforeMapping' - > { +export interface vtkMapper2D extends vtkAbstractMapper, IScalarColoring { /** * * @default [] */ - getCustomShaderAttributes(): any; + getCustomShaderAttributes(): string[]; /** * @@ -46,7 +38,7 @@ export interface vtkMapper2D /** * Get the transformCoordinate. */ - getTransformCoordinate(): any; + getTransformCoordinate(): Nullable; /** * Check whether the mapper’s data is static. @@ -74,7 +66,7 @@ export interface vtkMapper2D /** * Set the transformCoordinate. */ - setTransformCoordinate(coordinate: any): boolean; + setTransformCoordinate(coordinate: Nullable): boolean; /** * Turn on/off flag to control whether the mapper’s data is static. Static data diff --git a/Sources/Rendering/Core/Picker/index.d.ts b/Sources/Rendering/Core/Picker/index.d.ts index 2fdcd46021d..8717fb9aa68 100755 --- a/Sources/Rendering/Core/Picker/index.d.ts +++ b/Sources/Rendering/Core/Picker/index.d.ts @@ -100,7 +100,7 @@ export interface vtkPicker extends vtkAbstractPicker { * Set position in mapper coordinates of pick point. * @param {Vector3} mapperPosition The mapper coordinates of pick point. */ - setMapperPositionFrom(mapperPosition: Vector3): boolean; + setMapperPositionFrom(mapperPosition: Vector3): void; /** * Specify tolerance for performing pick operation. Tolerance is specified diff --git a/Sources/Rendering/Core/PixelSpaceCallbackMapper/index.d.ts b/Sources/Rendering/Core/PixelSpaceCallbackMapper/index.d.ts index 230fbcc41a2..dce3b7bd83b 100755 --- a/Sources/Rendering/Core/PixelSpaceCallbackMapper/index.d.ts +++ b/Sources/Rendering/Core/PixelSpaceCallbackMapper/index.d.ts @@ -1,12 +1,19 @@ -import { Vector3 } from '../../../types'; import vtkCamera from '../Camera'; import vtkMapper, { IMapperInitialValues } from '../Mapper'; /** * */ +export type PixelSpaceCallbackCoord = [number, number, number, number]; + export interface IPixelSpaceCallbackMapperInitialValues extends IMapperInitialValues { - callback?: any; + callback?: ( + coords: PixelSpaceCallbackCoord[], + camera: vtkCamera, + aspect: number, + depthBuffer: Uint8Array, + size: [number, number] + ) => any; useZValues?: boolean; } @@ -19,7 +26,13 @@ export interface vtkPixelSpaceCallbackMapper extends vtkMapper { /** * */ - getCallback(): any; + getCallback(): ( + coords: PixelSpaceCallbackCoord[], + camera: vtkCamera, + aspect: number, + depthBuffer: Uint8Array, + size: [number, number] + ) => any; /** * @@ -96,10 +109,11 @@ export interface vtkPixelSpaceCallbackMapper extends vtkMapper { */ setCallback( callback: ( - coords: Vector3[], + coords: PixelSpaceCallbackCoord[], camera: vtkCamera, aspect: number, - depthBuffer: Uint8Array + depthBuffer: Uint8Array, + size: [number, number] ) => any ): boolean; diff --git a/Sources/Rendering/Core/Prop/Constants.d.ts b/Sources/Rendering/Core/Prop/Constants.d.ts index 234fae89d88..b11810e6f7e 100644 --- a/Sources/Rendering/Core/Prop/Constants.d.ts +++ b/Sources/Rendering/Core/Prop/Constants.d.ts @@ -1,7 +1,10 @@ -export declare enum CoordinateSystem { - WORLD = 0, - DISPLAY = 1, -} +export declare const CoordinateSystem: { + readonly WORLD: 1; + readonly DISPLAY: 0; +}; + +export type CoordinateSystem = + (typeof CoordinateSystem)[keyof typeof CoordinateSystem]; declare const _default: { CoordinateSystem: typeof CoordinateSystem; diff --git a/Sources/Rendering/Core/Prop/index.d.ts b/Sources/Rendering/Core/Prop/index.d.ts index da9365d7fee..8b94f6f91a2 100755 --- a/Sources/Rendering/Core/Prop/index.d.ts +++ b/Sources/Rendering/Core/Prop/index.d.ts @@ -1,4 +1,5 @@ import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; import vtkActor from '../Actor'; import vtkActor2D from '../Actor2D'; import vtkTexture from '../Texture'; @@ -6,6 +7,7 @@ import vtkVolume from '../Volume'; import { CoordinateSystem } from './Constants'; export interface IPropInitialValues { + coordinateSystem?: CoordinateSystem; visibility?: boolean; pickable?: boolean; dragable?: boolean; @@ -18,6 +20,9 @@ export interface IPropInitialValues { } export interface vtkProp extends vtkObject { + /** Process selector pixel buffers for this prop during hardware picking. */ + processSelectorPixelBuffers(selector: any, pixelOffsets: number[]): void; + /** * * @param estimatedRenderTime @@ -96,7 +101,7 @@ export interface vtkProp extends vtkObject { /** * */ - getRendertimemultiplier(): number; + getRenderTimeMultiplier(): number; /** * The value is returned in seconds. For simple geometry the accuracy may not be great @@ -114,7 +119,7 @@ export interface vtkProp extends vtkObject { /** * */ - getNestedProps(): any; + getNestedProps(): Nullable; /** * Return parent prop set by setParentProp @@ -186,7 +191,7 @@ export interface vtkProp extends vtkObject { * Not all mappers support all coordinate systems. * @param {CoordinateSystem} coordinateSystem */ - setCoordinateSystem(coordinateSystem: CoordinateSystem): void; + setCoordinateSystem(coordinateSystem: CoordinateSystem): boolean; /** * Indicate that this prop's data should be in world coordinates. @@ -194,7 +199,7 @@ export interface vtkProp extends vtkObject { * userMatrix the resulting values will be treated as in world coordinates. * Not all mappers support all coordinate systems. */ - setCoordinateSystemToWorld(): void; + setCoordinateSystemToWorld(): boolean; /** * Indicate that this prop's data should be in display coordinates. @@ -204,7 +209,7 @@ export interface vtkProp extends vtkObject { * and a z range of -1 at the near plane and 1 at the far. * Not all mappers support all coordinate systems. */ - setCoordinateSystemToDisplay(): void; + setCoordinateSystemToDisplay(): boolean; /** * Set whether prop is dragable. @@ -230,7 +235,7 @@ export interface vtkProp extends vtkObject { * @see combineDragable * @default null */ - setParentProp(parentProp: vtkProp): void; + setParentProp(parentProp: vtkProp): boolean; /** * Set whether prop is pickable. @@ -307,5 +312,6 @@ export function newInstance(initialValues?: IPropInitialValues): vtkProp; export declare const vtkProp: { newInstance: typeof newInstance; extend: typeof extend; + CoordinateSystem: typeof CoordinateSystem; }; export default vtkProp; diff --git a/Sources/Rendering/Core/Prop3D/index.d.ts b/Sources/Rendering/Core/Prop3D/index.d.ts index e538c3a4e20..91c5e122cae 100755 --- a/Sources/Rendering/Core/Prop3D/index.d.ts +++ b/Sources/Rendering/Core/Prop3D/index.d.ts @@ -4,6 +4,7 @@ import vtkProp, { IPropInitialValues } from '../Prop'; import { vtkObject } from '../../../interfaces'; export interface IProp3DInitialValues extends IPropInitialValues { + properties?: vtkObject[]; origin?: number[]; position?: Vector3; orientation?: number[]; @@ -133,6 +134,9 @@ export interface vtkProp3D extends vtkProp { */ getZRange(): Range; + /** Recompute the transformed bounds from the mapper. */ + computeBounds(): void; + /** * Get the transformation matrix set for your own use. * The matrix is returned by reference: if you modify it in place, call @@ -214,6 +218,13 @@ export interface vtkProp3D extends vtkProp { */ setOrientation(x: number, y: number, z: number): boolean; + /** + * Set the orientation of the Prop3D from a quaternion. + * The quaternion should follow the gl-matrix convention: [x,y,z,w] + * @param {quat} q The orientation quaternion. + */ + setOrientationFromQuaternion(q: quat): boolean; + /** * Set the origin of the Prop3D. This is the point about which all rotations take place. * @param {Number} x The x coordinate. @@ -234,7 +245,7 @@ export interface vtkProp3D extends vtkProp { * take place. * @param {Number[]} origin */ - setOriginFrom(origin: number[]): boolean; + setOriginFrom(origin: number[]): void; /** * Set the origin of the Prop3D. @@ -249,7 +260,7 @@ export interface vtkProp3D extends vtkProp { * Set the origin of the Prop3D. * @param {Vector3} position */ - setPositionFrom(position: Vector3): boolean; + setPositionFrom(position: Vector3): void; /** * Set the scale of the actor. @@ -264,7 +275,7 @@ export interface vtkProp3D extends vtkProp { * * @param {Number[]} scale */ - setScaleFrom(scale: number[]): boolean; + setScaleFrom(scale: number[]): void; /** * In addition to the instance variables such as position and orientation, @@ -274,7 +285,7 @@ export interface vtkProp3D extends vtkProp { * setOrientation(). * @param {mat4} matrix */ - setUserMatrix(matrix: mat4): void; + setUserMatrix(matrix: mat4): boolean; /** * Generate the matrix based on internal model. diff --git a/Sources/Rendering/Core/Property/Constants.d.ts b/Sources/Rendering/Core/Property/Constants.d.ts index fa63c29d070..169e6dff712 100644 --- a/Sources/Rendering/Core/Property/Constants.d.ts +++ b/Sources/Rendering/Core/Property/Constants.d.ts @@ -1,21 +1,29 @@ -export declare enum Shading { - FLAT = 0, - GOURAUD = 1, - PHONG = 2, - PBR = 3, -} +export declare const Shading: { + readonly FLAT: 0; + readonly GOURAUD: 1; + readonly PHONG: 2; + readonly PBR: 3; +}; + +export type Shading = (typeof Shading)[keyof typeof Shading]; + +export declare const Representation: { + readonly POINTS: 0; + readonly WIREFRAME: 1; + readonly SURFACE: 2; +}; + +export type Representation = + (typeof Representation)[keyof typeof Representation]; -export declare enum Representation { - POINTS = 0, - WIREFRAME = 1, - SURFACE = 2, -} +export declare const Interpolation: { + readonly FLAT: 0; + readonly GOURAUD: 1; + readonly PHONG: 2; + readonly PBR: 3; +}; -export declare enum Interpolation { - FLAT = 0, - GOURAUD = 1, - PHONG = 2, -} +export type Interpolation = (typeof Interpolation)[keyof typeof Interpolation]; declare const _default: { Shading: typeof Shading; diff --git a/Sources/Rendering/Core/Property/index.d.ts b/Sources/Rendering/Core/Property/index.d.ts index df8daff1d8f..51777882218 100755 --- a/Sources/Rendering/Core/Property/index.d.ts +++ b/Sources/Rendering/Core/Property/index.d.ts @@ -1,21 +1,30 @@ import { vtkObject } from '../../../interfaces'; -import { Nullable, RGBColor } from '../../../types'; +import { Nullable, RGBColor, Vector2 } from '../../../types'; import { Interpolation, Representation, Shading } from './Constants'; import { vtkTexture } from '../../Core/Texture'; +export type TextureTransform = { + offset?: Vector2; + scale?: Vector2; + rotation?: number; + texCoord?: number; +}; + export interface IPropertyInitialValues { + interpolation?: Interpolation; + representation?: Representation; color?: RGBColor; ambientColor?: RGBColor; diffuseColor?: RGBColor; specularColor?: RGBColor; - diffuseTexture?: vtkTexture; - metallicTexture?: vtkTexture; - roughnessTexture?: vtkTexture; - normalTexture?: vtkTexture; - ambientOcclusionTexture?: vtkTexture; - emissionTexture?: vtkTexture; - RMTexture?: vtkTexture; - ORMTexture?: vtkTexture; + diffuseTexture?: Nullable; + metallicTexture?: Nullable; + roughnessTexture?: Nullable; + normalTexture?: Nullable; + ambientOcclusionTexture?: Nullable; + emissionTexture?: Nullable; + RMTexture?: Nullable; + ORMTexture?: Nullable; edgeColor?: RGBColor; edgeOpacity?: number; ambient?: number; @@ -35,9 +44,170 @@ export interface IPropertyInitialValues { lineWidth?: number; lighting?: boolean; shading?: boolean; + anisotropy?: number; + anisotropyRotation?: number; + coatStrength?: number; + coatRoughness?: number; + coatF0?: number; + coatNormalStrength?: number; + displacementFactor?: number; + emissiveStrength?: number; + occlusionStrength?: number; + transmissionFactor?: number; + alphaCutoff?: number; + alphaMode?: number; + thicknessFactor?: number; + attenuationDistance?: number; + iridescenceFactor?: number; + iridescenceIOR?: number; + iridescenceThicknessMinimum?: number; + iridescenceThicknessMaximum?: number; + sheenRoughnessFactor?: number; + diffuseTransmissionFactor?: number; + dispersion?: number; + specularFactor?: number; + anisotropyTexture?: Nullable; + coatTexture?: Nullable; + coatRoughnessTexture?: Nullable; + coatNormalTexture?: Nullable; + displacementTexture?: Nullable; + transmissionTexture?: Nullable; + thicknessTexture?: Nullable; + iridescenceTexture?: Nullable; + iridescenceThicknessTexture?: Nullable; + sheenColorTexture?: Nullable; + sheenRoughnessTexture?: Nullable; + diffuseTransmissionTexture?: Nullable; + diffuseTransmissionColorTexture?: Nullable; + specularTexture?: Nullable; + specularColorTexture?: Nullable; + coatColor?: RGBColor; + attenuationColor?: RGBColor; + sheenColorFactor?: RGBColor; + diffuseTransmissionColorFactor?: RGBColor; + specularColorFactor?: RGBColor; + textureTransforms?: Nullable>; } export interface vtkProperty extends vtkObject { + getAnisotropy(): number; + setAnisotropy(anisotropy: number): boolean; + getAnisotropyRotation(): number; + setAnisotropyRotation(anisotropyRotation: number): boolean; + getCoatStrength(): number; + setCoatStrength(coatStrength: number): boolean; + getCoatRoughness(): number; + setCoatRoughness(coatRoughness: number): boolean; + getCoatF0(): number; + setCoatF0(coatF0: number): boolean; + getCoatNormalStrength(): number; + setCoatNormalStrength(coatNormalStrength: number): boolean; + getDisplacementFactor(): number; + setDisplacementFactor(displacementFactor: number): boolean; + getEmissiveStrength(): number; + setEmissiveStrength(emissiveStrength: number): boolean; + getOcclusionStrength(): number; + setOcclusionStrength(occlusionStrength: number): boolean; + getTransmissionFactor(): number; + setTransmissionFactor(transmissionFactor: number): boolean; + getAlphaCutoff(): number; + setAlphaCutoff(alphaCutoff: number): boolean; + getAlphaMode(): number; + setAlphaMode(alphaMode: number): boolean; + getThicknessFactor(): number; + setThicknessFactor(thicknessFactor: number): boolean; + getAttenuationDistance(): number; + setAttenuationDistance(attenuationDistance: number): boolean; + getIridescenceFactor(): number; + setIridescenceFactor(iridescenceFactor: number): boolean; + getIridescenceIOR(): number; + setIridescenceIOR(iridescenceIOR: number): boolean; + getIridescenceThicknessMinimum(): number; + setIridescenceThicknessMinimum(iridescenceThicknessMinimum: number): boolean; + getIridescenceThicknessMaximum(): number; + setIridescenceThicknessMaximum(iridescenceThicknessMaximum: number): boolean; + getSheenRoughnessFactor(): number; + setSheenRoughnessFactor(sheenRoughnessFactor: number): boolean; + getDiffuseTransmissionFactor(): number; + setDiffuseTransmissionFactor(diffuseTransmissionFactor: number): boolean; + getDispersion(): number; + setDispersion(dispersion: number): boolean; + getSpecularFactor(): number; + setSpecularFactor(specularFactor: number): boolean; + getAnisotropyTexture(): Nullable; + setAnisotropyTexture(anisotropyTexture: Nullable): boolean; + getCoatTexture(): Nullable; + setCoatTexture(coatTexture: Nullable): boolean; + getCoatRoughnessTexture(): Nullable; + setCoatRoughnessTexture(coatRoughnessTexture: Nullable): boolean; + getCoatNormalTexture(): Nullable; + setCoatNormalTexture(coatNormalTexture: Nullable): boolean; + getDisplacementTexture(): Nullable; + setDisplacementTexture(displacementTexture: Nullable): boolean; + getTransmissionTexture(): Nullable; + setTransmissionTexture(transmissionTexture: Nullable): boolean; + getThicknessTexture(): Nullable; + setThicknessTexture(thicknessTexture: Nullable): boolean; + getIridescenceTexture(): Nullable; + setIridescenceTexture(iridescenceTexture: Nullable): boolean; + getIridescenceThicknessTexture(): Nullable; + setIridescenceThicknessTexture( + iridescenceThicknessTexture: Nullable + ): boolean; + getSheenColorTexture(): Nullable; + setSheenColorTexture(sheenColorTexture: Nullable): boolean; + getSheenRoughnessTexture(): Nullable; + setSheenRoughnessTexture( + sheenRoughnessTexture: Nullable + ): boolean; + getDiffuseTransmissionTexture(): Nullable; + setDiffuseTransmissionTexture( + diffuseTransmissionTexture: Nullable + ): boolean; + getDiffuseTransmissionColorTexture(): Nullable; + setDiffuseTransmissionColorTexture( + diffuseTransmissionColorTexture: Nullable + ): boolean; + getSpecularTexture(): Nullable; + setSpecularTexture(specularTexture: Nullable): boolean; + getSpecularColorTexture(): Nullable; + setSpecularColorTexture(specularColorTexture: Nullable): boolean; + getCoatColor(): RGBColor; + getCoatColorByReference(): RGBColor; + setCoatColor(r: number, g: number, b: number): boolean; + setCoatColor(coatColor: RGBColor): boolean; + setCoatColorFrom(coatColor: RGBColor): void; + getAttenuationColor(): RGBColor; + getAttenuationColorByReference(): RGBColor; + setAttenuationColor(r: number, g: number, b: number): boolean; + setAttenuationColor(attenuationColor: RGBColor): boolean; + setAttenuationColorFrom(attenuationColor: RGBColor): void; + getSheenColorFactor(): RGBColor; + getSheenColorFactorByReference(): RGBColor; + setSheenColorFactor(r: number, g: number, b: number): boolean; + setSheenColorFactor(sheenColorFactor: RGBColor): boolean; + setSheenColorFactorFrom(sheenColorFactor: RGBColor): void; + getDiffuseTransmissionColorFactor(): RGBColor; + getDiffuseTransmissionColorFactorByReference(): RGBColor; + setDiffuseTransmissionColorFactor(r: number, g: number, b: number): boolean; + setDiffuseTransmissionColorFactor( + diffuseTransmissionColorFactor: RGBColor + ): boolean; + setDiffuseTransmissionColorFactorFrom( + diffuseTransmissionColorFactor: RGBColor + ): void; + getSpecularColorFactor(): RGBColor; + getSpecularColorFactorByReference(): RGBColor; + setSpecularColorFactor(r: number, g: number, b: number): boolean; + setSpecularColorFactor(specularColorFactor: RGBColor): boolean; + setSpecularColorFactorFrom(specularColorFactor: RGBColor): void; + getTextureTransform(key: string): Nullable; + getTextureTransforms(): Record; + setTextureTransform(key: string, transform: TextureTransform): void; + setTextureTransforms( + transforms: Nullable> + ): void; + /** * Not Implemented yet */ @@ -224,12 +394,12 @@ export interface vtkProperty extends vtkObject { /** * Get the diffuse texture. */ - getDiffuseTexture(): Nullable; + getDiffuseTexture(): Nullable | undefined; /** * Get the metallic texture. */ - getMetallicTexture(): Nullable; + getMetallicTexture(): Nullable | undefined; /** * Get the roughness & metallic texture. @@ -244,22 +414,22 @@ export interface vtkProperty extends vtkObject { /** * Get the roughness texture. */ - getRoughnessTexture(): Nullable; + getRoughnessTexture(): Nullable | undefined; /** * Get the normal texture. */ - getNormalTexture(): Nullable; + getNormalTexture(): Nullable | undefined; /** * Get the ambient occlusion texture. */ - getAmbientOcclusionTexture(): Nullable; + getAmbientOcclusionTexture(): Nullable | undefined; /** * Get the emission texture. */ - getEmissionTexture(): Nullable; + getEmissionTexture(): Nullable | undefined; /** * Set the ambient lighting coefficient. @@ -292,7 +462,7 @@ export interface vtkProperty extends vtkObject { * Set the ambient surface color from an RGB array * @param {RGBColor} ambientColor An Array of the RGB color. */ - setAmbientColorFrom(ambientColor: RGBColor): boolean; + setAmbientColorFrom(ambientColor: RGBColor): void; /** * Turn on/off fast culling of polygons based on orientation of normal @@ -310,7 +480,7 @@ export interface vtkProperty extends vtkObject { * @param {Number} g Defines the green component (between 0 and 1) * @param {Number} b Defines the blue component (between 0 and 1) */ - setColor(r: number, g: number, b: number): boolean; + setColor(r: number, g: number, b: number): void; /** * Set the color of the object. Has the side effect of setting the @@ -318,7 +488,7 @@ export interface vtkProperty extends vtkObject { * a quick overall color setting method. * @param {RGBColor} color An Array of the RGB color. */ - setColor(color: RGBColor): boolean; + setColor(color: RGBColor): void; /** * Set the diffuse lighting coefficient. @@ -344,7 +514,7 @@ export interface vtkProperty extends vtkObject { * Set the diffuse surface color from an RGB array * @param {RGBColor} diffuseColor An Array of the RGB color. */ - setDiffuseColorFrom(diffuseColor: RGBColor): boolean; + setDiffuseColorFrom(diffuseColor: RGBColor): void; /** * Set the color of primitive edges (if edge visibility is enabled). @@ -364,7 +534,7 @@ export interface vtkProperty extends vtkObject { * Set the color of primitive edges from an RGB array. * @param {RGBColor} edgeColor An Array of the RGB color. */ - setEdgeColorFrom(edgeColor: RGBColor): boolean; + setEdgeColorFrom(edgeColor: RGBColor): void; /** * Set the opacity of primitive edges. If not set explicitly, edge opacity @@ -410,6 +580,11 @@ export interface vtkProperty extends vtkObject { */ setInterpolationToPhong(): boolean; + /** + * Set interpolation to 3 for physically based rendering. + */ + setInterpolationToPBR(): boolean; + /** * Set lighting flag for an object. * @param {Boolean} lighting @@ -469,6 +644,24 @@ export interface vtkProperty extends vtkObject { */ setSpecular(specular: number): boolean; + /** + * Set the roughness coefficient. + * @param {Number} roughness + */ + setRoughness(roughness: number): boolean; + + /** + * Set the metallic coefficient. + * @param {Number} metallic + */ + setMetallic(metallic: number): boolean; + + /** + * Set the index of refraction of the base layer. + * @param {Number} baseIOR + */ + setBaseIOR(baseIOR: number): boolean; + /** * Set the normal map strength. * @param {Boolean} normal @@ -499,7 +692,7 @@ export interface vtkProperty extends vtkObject { * Set the specular surface color from an RGB array * @param {RGBColor} specularColor An Array of the RGB color. */ - setSpecularColorFrom(specularColor: RGBColor): boolean; + setSpecularColorFrom(specularColor: RGBColor): void; /** * Set the specular power. @@ -511,49 +704,51 @@ export interface vtkProperty extends vtkObject { * Set the diffuse texture. * @param {vtkTexture} diffuseTexture */ - setDiffuseTexture(diffuseTexture: vtkTexture): boolean; + setDiffuseTexture(diffuseTexture: Nullable): boolean; /** * Set the metallic texture. * @param {vtkTexture} metallicTexture */ - setMetallicTexture(metallicTexture: vtkTexture): boolean; + setMetallicTexture(metallicTexture: Nullable): boolean; /** * Set the roughness texture. * @param {vtkTexture} roughnessTexture */ - setRoughnessTexture(roughnessTexture: vtkTexture): boolean; + setRoughnessTexture(roughnessTexture: Nullable): boolean; /** * Set the roughness & metallic texture. * @param {vtkTexture} RMTexture */ - setRMTexture(RMTexture: vtkTexture): boolean; + setRMTexture(RMTexture: Nullable): boolean; /** * Set the occlusion, roughness & metallic texture. * @param {vtkTexture} ORMTexture */ - setORMTexture(ORMTexture: vtkTexture): boolean; + setORMTexture(ORMTexture: Nullable): boolean; /** * Set the normal texture. * @param {vtkTexture} normalTexture */ - setNormalTexture(normalTexture: vtkTexture): boolean; + setNormalTexture(normalTexture: Nullable): boolean; /** * Set the ambient occlusion texture. * @param {vtkTexture} ambientOcclusionTexture */ - setAmbientOcclusionTexture(ambientOcclusionTexture: vtkTexture): boolean; + setAmbientOcclusionTexture( + ambientOcclusionTexture: Nullable + ): boolean; /** * Set the emission texture. * @param {vtkTexture} emissionTexture */ - setEmissionTexture(emissionTexture: vtkTexture): boolean; + setEmissionTexture(emissionTexture: Nullable): boolean; } /** diff --git a/Sources/Rendering/Core/Property2D/Constants.d.ts b/Sources/Rendering/Core/Property2D/Constants.d.ts index e46158913aa..8f3a66cdefa 100644 --- a/Sources/Rendering/Core/Property2D/Constants.d.ts +++ b/Sources/Rendering/Core/Property2D/Constants.d.ts @@ -1,7 +1,10 @@ -export declare enum DisplayLocation { - BACKGROUND = 0, - FOREGROUND = 1, -} +export declare const DisplayLocation: { + readonly BACKGROUND: 0; + readonly FOREGROUND: 1; +}; + +export type DisplayLocation = + (typeof DisplayLocation)[keyof typeof DisplayLocation]; declare const _default: { DisplayLocation: typeof DisplayLocation; diff --git a/Sources/Rendering/Core/Property2D/index.d.ts b/Sources/Rendering/Core/Property2D/index.d.ts index 13ed8bbd717..7384abbdb6c 100755 --- a/Sources/Rendering/Core/Property2D/index.d.ts +++ b/Sources/Rendering/Core/Property2D/index.d.ts @@ -1,5 +1,6 @@ import { vtkObject } from '../../../interfaces'; import { RGBColor } from '../../../types'; +import { Representation } from '../Property/Constants'; import { DisplayLocation } from './Constants'; export interface IProperty2DInitialValues { @@ -10,6 +11,7 @@ export interface IProperty2DInitialValues { displayLocation?: DisplayLocation; backfaceCulling?: boolean; frontfaceCulling?: boolean; + representation?: Representation; } export interface vtkProperty2D extends vtkObject { @@ -56,6 +58,12 @@ export interface vtkProperty2D extends vtkObject { */ getPointSize(): number; + /** Get the geometric representation mode. */ + getRepresentation(): Representation; + + /** Get the geometric representation mode as a string. */ + getRepresentationAsString(): string; + /** * Set the color of the object. Has the side effect of setting the * ambient diffuse and specular colors as well. This is basically @@ -82,7 +90,7 @@ export interface vtkProperty2D extends vtkObject { * @param {Number} g Defines the green component (between 0 and 1). * @param {Number} b Defines the blue component (between 0 and 1). */ - setColorFrom(r: number, g: number, b: number): boolean; + setColorFrom(r: number, g: number, b: number): void; /** * Set the color of the object. Has the side effect of setting the @@ -90,7 +98,7 @@ export interface vtkProperty2D extends vtkObject { * a quick overall color setting method. * @param {RGBColor} color Defines the RGB color array.. */ - setColorFrom(color: RGBColor): boolean; + setColorFrom(color: RGBColor): void; /** * Turn on/off fast culling of polygons based on orientation of normal @@ -136,6 +144,24 @@ export interface vtkProperty2D extends vtkObject { * @default 1.0 */ setPointSize(pointSize: number): boolean; + + /** Set the geometric representation mode. */ + setRepresentation(representation: Representation): boolean; + + /** Set representation to points. */ + setRepresentationToPoints(): boolean; + + /** Set representation to surface. */ + setRepresentationToSurface(): boolean; + + /** Set representation to wireframe. */ + setRepresentationToWireframe(): boolean; + + /** Set display location to the background. */ + setDisplayLocationToBackground(): boolean; + + /** Set display location to the foreground. */ + setDisplayLocationToForeground(): boolean; } /** @@ -174,5 +200,6 @@ export function newInstance( export declare const vtkProperty2D: { newInstance: typeof newInstance; extend: typeof extend; + DisplayLocation: typeof DisplayLocation; }; export default vtkProperty2D; diff --git a/Sources/Rendering/Core/RenderWindow/index.d.ts b/Sources/Rendering/Core/RenderWindow/index.d.ts index 771cbce33b8..77f507c87db 100755 --- a/Sources/Rendering/Core/RenderWindow/index.d.ts +++ b/Sources/Rendering/Core/RenderWindow/index.d.ts @@ -1,11 +1,13 @@ import { vtkObject, vtkSubscription } from '../../../interfaces'; +import { Nullable } from '../../../types'; import vtkRenderer from '../Renderer'; import vtkRenderWindowInteractor from '../RenderWindowInteractor'; -// import vtkOpenGLRenderWindow from "../../../OpenGL/RenderWindow"; +import vtkRenderWindowViewNode from '../../SceneGraph/RenderWindowViewNode'; export interface IRenderWindowInitialValues { + defaultViewAPI?: string; renderers?: vtkRenderer[]; - views?: vtkRenderWindow[]; + views?: vtkRenderWindowViewNode[]; interactor?: any; neverRendered?: boolean; numberOfLayers?: number; @@ -42,7 +44,7 @@ export interface vtkRenderWindow extends vtkObject { * Add a child render window * @param {vtkRenderWindow} renderWindow The vtkRenderWindow instance. */ - addRenderWindow(renderWindow: vtkRenderWindow): void; + addRenderWindow(renderWindow: vtkRenderWindow): boolean; /** * Add renderer @@ -62,12 +64,12 @@ export interface vtkRenderWindow extends vtkObject { * By default, the WebGL backend is used. To switch, to WebGPU call * `renderWindow.setDefaultViewAPI('WebGPU')` before calling `render`. */ - getDefaultViewAPI(): string; + getDefaultViewAPI(): DEFAULT_VIEW_API; /** * */ - getInteractor(): vtkRenderWindowInteractor; + getInteractor(): Nullable; /** * @@ -107,9 +109,7 @@ export interface vtkRenderWindow extends vtkObject { /** * */ - getViews(): any[]; - - // getViews(): vtkOpenGLRenderWindow[]; + getViews(): vtkRenderWindowViewNode[]; /** * @@ -126,6 +126,11 @@ export interface vtkRenderWindow extends vtkObject { //hasView(view: vtkOpenGLRenderWindow): boolean; + /** + * Invoke a Completion event. + */ + invokeCompletion(...args: unknown[]): void; + /** * * @param callback @@ -157,6 +162,13 @@ export interface vtkRenderWindow extends vtkObject { */ removeView(view: any): void; + /** + * Handle any pre-render initializations, such as creating a camera for any + * renderer that does not have an active one yet. + * Called by `render()`. + */ + preRender(): void; + /** * */ @@ -187,9 +199,7 @@ export interface vtkRenderWindow extends vtkObject { * * @param views */ - setViews(views: any[]): boolean; - - // setViews(views: vtkOpenGLRenderWindow[]): boolean; + setViews(views: vtkRenderWindowViewNode[]): boolean; } /** diff --git a/Sources/Rendering/Core/RenderWindowInteractor/Constants.d.ts b/Sources/Rendering/Core/RenderWindowInteractor/Constants.d.ts index 0ded6820d3b..9d386b6eb5e 100644 --- a/Sources/Rendering/Core/RenderWindowInteractor/Constants.d.ts +++ b/Sources/Rendering/Core/RenderWindowInteractor/Constants.d.ts @@ -1,33 +1,41 @@ -export declare enum Device { - Unknown = 0, - LeftController = 1, - RightController = 2, -} - -export declare enum Input { - Unknown = 0, - Trigger = 1, - TrackPad = 2, - Grip = 3, - Thumbstick = 4, - A = 5, - B = 6, - ApplicationMenu = 7, // Not exposed in WebXR API -} - -export declare enum Axis { - Unknown = 0, - TouchpadX = 1, - TouchpadY = 2, - ThumbstickX = 3, - ThumbstickY = 4, -} - -export declare enum MouseButton { - LeftButton = 1, - MiddleButton = 2, - RightButton = 3, -} +export declare const Device: { + readonly Unknown: 0; + readonly LeftController: 1; + readonly RightController: 2; +}; + +export type Device = (typeof Device)[keyof typeof Device]; + +export declare const Input: { + readonly Unknown: 0; + readonly Trigger: 1; + readonly TrackPad: 2; + readonly Grip: 3; + readonly Thumbstick: 4; + readonly A: 5; + readonly B: 6; + readonly ApplicationMenu: 7; // Not exposed in WebXR API +}; + +export type Input = (typeof Input)[keyof typeof Input]; + +export declare const Axis: { + readonly Unknown: 0; + readonly TouchpadX: 1; + readonly TouchpadY: 2; + readonly ThumbstickX: 3; + readonly ThumbstickY: 4; +}; + +export type Axis = (typeof Axis)[keyof typeof Axis]; + +export declare const MouseButton: { + readonly LeftButton: 1; + readonly MiddleButton: 2; + readonly RightButton: 3; +}; + +export type MouseButton = (typeof MouseButton)[keyof typeof MouseButton]; declare const _default: { Device: typeof Device; diff --git a/Sources/Rendering/Core/RenderWindowInteractor/index.d.ts b/Sources/Rendering/Core/RenderWindowInteractor/index.d.ts index a5275215122..740b3782274 100755 --- a/Sources/Rendering/Core/RenderWindowInteractor/index.d.ts +++ b/Sources/Rendering/Core/RenderWindowInteractor/index.d.ts @@ -1,215 +1,696 @@ +/// + import { vtkObject, vtkSubscription } from '../../../interfaces'; import { Nullable } from '../../../types'; +import vtkAbstractPicker from '../AbstractPicker'; +import vtkInteractorStyle from '../InteractorStyle'; import vtkRenderer from '../Renderer'; +import vtkRenderWindowViewNode from '../../SceneGraph/RenderWindowViewNode'; import { Axis, Device, Input, MouseButton } from './Constants'; -declare enum handledEvents { - StartAnimation, - Animation, - EndAnimation, - MouseEnter, - MouseLeave, - StartMouseMove, - MouseMove, - EndMouseMove, - LeftButtonPress, - LeftButtonRelease, - MiddleButtonPress, - MiddleButtonRelease, - RightButtonPress, - RightButtonRelease, - KeyPress, - KeyDown, - KeyUp, - StartMouseWheel, - MouseWheel, - EndMouseWheel, - StartPinch, - Pinch, - EndPinch, - StartPan, - Pan, - EndPan, - Tap, - LongTap, - StartRotate, - Rotate, - EndRotate, - Button3D, - Move3D, - StartPointerLock, - EndPointerLock, - StartInteraction, - Interaction, - EndInteraction, - AnimationFrameRateUpdate, -} +declare enum handledEvents { + StartAnimation, + Animation, + EndAnimation, + PointerEnter, + PointerLeave, + MouseEnter, + MouseLeave, + StartMouseMove, + MouseMove, + EndMouseMove, + LeftButtonPress, + LeftButtonRelease, + MiddleButtonPress, + MiddleButtonRelease, + RightButtonPress, + RightButtonRelease, + KeyPress, + KeyDown, + KeyUp, + StartMouseWheel, + MouseWheel, + EndMouseWheel, + StartPinch, + Pinch, + EndPinch, + StartPan, + Pan, + EndPan, + Tap, + LongTap, + StartRotate, + Rotate, + EndRotate, + Button3D, + Move3D, + StartPointerLock, + EndPointerLock, + StartInteraction, + Interaction, + EndInteraction, + AnimationFrameRateUpdate, +} + +/** + * + */ +export interface IRenderWindowInteractorInitialValues { + initialized?: boolean; + enabled?: boolean; + enableRender?: boolean; + lightFollowCamera?: boolean; + desiredUpdateRate?: number; + stillUpdateRate?: number; + recognizeGestures?: boolean; + currentGesture?: string; + lastFrameTime?: number; + moveTimeoutID?: number; + preventDefaultOnPointerDown?: boolean; + preventDefaultOnPointerUp?: boolean; + wheelEndDebounceDelay?: number; + mouseWheelSpinYBuffering?: boolean; + longTapDuration?: number; + container?: HTMLElement; + interactorStyle?: vtkInteractorStyle; + longTapMaximumDistance?: number; + picker?: vtkAbstractPicker; +} + +export interface IPosition { + type: string; +} + +export type InteractorEventCallback = (e: IRenderWindowInteractorEvent) => void; + +export type InteractorEventType = + | 'StartInteractionEvent' + | 'InteractionEvent' + | 'EndInteractionEvent'; + +export interface IRenderWindowInteractorEvent { + altKey: boolean; + controlKey: boolean; + firstRenderer: vtkRenderer; + pokedRenderer: vtkRenderer; + position: { x: number; y: number; z: number }; + shiftKey: boolean; + type: InteractorEventType; +} + +export interface I3DEvent { + gamepad: Gamepad; + position: DOMPointReadOnly; + orientation: DOMPointReadOnly; + targetPosition: DOMPointReadOnly; + targetOrientation: DOMPointReadOnly; + device: Device; +} + +export interface IButton3DEvent extends I3DEvent { + pressed: boolean; + input: Input; +} + +export interface vtkRenderWindowInteractor extends vtkObject { + getInitialized(): boolean; + getEnabled(): boolean; + setEnabled(enabled: boolean): boolean; + getEnableRender(): boolean; + setEnableRender(enableRender: boolean): boolean; + getLightFollowCamera(): boolean; + getDesiredUpdateRate(): number; + getStillUpdateRate(): number; + getRecognizeGestures(): boolean; + getLastFrameTime(): number; + getRecentAnimationFrameRate(): number; + getPreventDefaultOnPointerDown(): boolean; + getPreventDefaultOnPointerUp(): boolean; + getLongTapDuration(): number; + getView(): vtkRenderWindowViewNode | undefined; + + /** @deprecated Use getWheelEndDebounceDelay() instead. */ + getMouseScrollDebounceByPass(): boolean; + + /** + * Set the desired update rate. + * @param desiredUpdateRate + */ + setDesiredUpdateRate(desiredUpdateRate: number): boolean; + + /** + * Set the desired update rate when movement has stopped. + * @param stillUpdateRate + */ + setStillUpdateRate(stillUpdateRate: number): boolean; + + /** + * Start the event loop. + * This is provided so that you do not have to implement your own event loop. + * You still can use your own event loop if you want. + */ + start(): void; + + /** + * + * @param args + */ + startAnimationEvent(args: any): any; + + /** + * + * @param args + */ + animationEvent(args: any): any; + + /** + * + * @param args + */ + endAnimationEvent(args: any): any; + + /** + * + * @param args + */ + pointerEnterEvent(args: any): any; + + /** + * + * @param args + */ + pointerLeaveEvent(args: any): any; + + /** + * + * @param args + */ + mouseEnterEvent(args: any): any; + + /** + * + * @param args + */ + mouseLeaveEvent(args: any): any; + + /** + * + * @param args + */ + startMouseMoveEvent(args: any): any; + + /** + * + * @param args + */ + mouseMoveEvent(args: any): any; + + /** + * + * @param args + */ + endMouseMoveEvent(args: any): any; + + /** + * + * @param args + */ + leftButtonPressEvent(args: any): any; + + /** + * + * @param args + */ + leftButtonReleaseEvent(args: any): any; + + /** + * + * @param args + */ + middleButtonPressEvent(args: any): any; + + /** + * + * @param args + */ + middleButtonReleaseEvent(args: any): any; + + /** + * + * @param args + */ + rightButtonPressEvent(args: any): any; + + /** + * + * @param args + */ + rightButtonReleaseEvent(args: any): any; + + /** + * + * @param args + */ + keyPressEvent(args: any): any; + + /** + * + * @param args + */ + keyDownEvent(args: any): any; + + /** + * + * @param args + */ + keyUpEvent(args: any): any; + + /** + * + * @param args + */ + startMouseWheelEvent(args: any): any; + + /** + * + * @param args + */ + mouseWheelEvent(args: any): any; + + /** + * + * @param args + */ + endMouseWheelEvent(args: any): any; + + /** + * + * @param args + */ + startPinchEvent(args: any): any; + + /** + * + * @param args + */ + pinchEvent(args: any): any; + + /** + * + * @param args + */ + endPinchEvent(args: any): any; + + /** + * + * @param args + */ + startPanEvent(args: any): any; + + /** + * + * @param args + */ + panEvent(args: any): any; + + /** + * + * @param args + */ + endPanEvent(args: any): any; + + /** + * + * @param args + */ + tapEvent(args: any): any; + + /** + * + * @param args + */ + longTapEvent(args: any): any; + + /** + * + * @param args + */ + startRotateEvent(args: any): any; + + /** + * + * @param args + */ + rotateEvent(args: any): any; + + /** + * + * @param args + */ + endRotateEvent(args: any): any; + + /** + * + * @param args + */ + button3DEvent(args: any): any; + + /** + * + * @param args + */ + move3DEvent(args: any): any; + + /** + * + * @param args + */ + startPointerLockEvent(args: any): any; + + /** + * + * @param args + */ + endPointerLockEvent(args: any): any; + + /** + * + * @param args + */ + startInteractionEvent(args: any): any; + + /** + * + * @param args + */ + interactionEvent(args: any): any; + + /** + * + * @param args + */ + endInteractionEvent(args: any): any; + + /** + * + * @param args + */ + animationFrameRateUpdateEvent(args: any): any; + + /** + * Set/Get the rendering window being controlled by this object. + * @param aren + */ + setRenderWindow(aren: any): void; + + /** + * External switching between joystick/trackball/new? modes. + * @param style + */ + setInteractorStyle(style: Nullable): void; + + /** + * + */ + getInteractorStyle(): Nullable; + + /** + * + */ + getContainer(): Nullable; + + /** + * + * @param container + */ + setContainer(container: Nullable): boolean; + + /** + * + */ + getPicker(): Nullable; + + /** + * + * @param picker + */ + setPicker(picker: Nullable): boolean; + + /** + * + */ + getLongTapMaximumDistance(): number; + + /** + * + * @param longTapMaximumDistance + */ + setLongTapMaximumDistance(longTapMaximumDistance: number): boolean; + + /** + * --------------------------------------------------------------------- + */ + initialize(): void; + + /** + * Enable/Disable interactions. + * By default interactors are enabled when initialized. + * Initialize() must be called prior to enabling/disabling interaction. + * These methods are used when a window/widget is being shared by multiple renderers and interactors. + * This allows a "modal" display where one interactor is active when its data is to be displayed and all other interactors associated with the widget are disabled when their data is not displayed. + */ + enable(): void; + + /** + * @default false + * @deprecated Use getWheelEndDebounceDelay() instead. + */ + disable(): void; + + /** + * @default 200 + */ + getWheelEndDebounceDelay(): number; + + /** + * @default false + */ + getMouseWheelSpinYBuffering(): boolean; + + /** + * @default 500 + */ + startEventLoop(): void; + + /** + * + */ + getCurrentRenderer(): Nullable; + + /** + * Manually sets the current renderer. + * @param {vtkRenderer} ren + */ + setCurrentRenderer(ren: vtkRenderer): void; + + /** + * + * @param container kept for backward compatibility. + * @deprecated please use vtkRenderWindowInteractor.setContainer(container: HTMLElement) + * which will also bind events. + */ + bindEvents(container: any): void; -/** - * - */ -export interface IRenderWindowInteractorInitialValues { - initialized?: boolean; - enabled?: boolean; - enableRender?: boolean; - lightFollowCamera?: boolean; - desiredUpdateRate?: number; - stillUpdateRate?: number; - recognizeGestures?: boolean; - currentGesture?: string; - lastFrameTime?: number; - moveTimeoutID?: number; - preventDefaultOnPointerDown?: boolean; - preventDefaultOnPointerUp?: boolean; - wheelEndDebounceDelay?: number; - mouseWheelSpinYBuffering?: boolean; - longTapDuration?: number; - longTapDistance?: number; -} + /** + * + * @deprecated please use vtkRenderWindowInteractor.setContainer(null) instead. + */ + unbindEvents(): void; -export interface IPosition { - type: string; -} + /** + * + * @param {KeyboardEvent} event + */ + handleKeyPress(event: KeyboardEvent): void; -export type InteractorEventCallback = (e: IRenderWindowInteractorEvent) => void; + /** + * + * @param {KeyboardEvent} event + */ + handleKeyDown(event: KeyboardEvent): void; -export type InteractorEventType = - | 'StartInteractionEvent' - | 'InteractionEvent' - | 'EndInteractionEvent'; + /** + * + * @param {KeyboardEvent} event + */ + handleKeyUp(event: KeyboardEvent): void; -export interface IRenderWindowInteractorEvent { - altKey: boolean; - controlKey: boolean; - firstRenderer: vtkRenderer; - pokedRenderer: vtkRenderer; - position: { x: number; y: number; z: number }; - shiftKey: boolean; - type: InteractorEventType; -} + /** + * + * @param {PointerEvent} event + */ + handlePointerDown(event: PointerEvent): void; -export interface I3DEvent { - gamepad: Gamepad; - position: DOMPointReadOnly; - orientation: DOMPointReadOnly; - targetPosition: DOMPointReadOnly; - targetOrientation: DOMPointReadOnly; - device: Device; -} + /** + * + * @param {PointerEvent} event + */ + handlePointerUp(event: PointerEvent): void; -export interface IButton3DEvent extends I3DEvent { - pressed: boolean; - input: Input; -} + /** + * + * @param {PointerEvent} event + */ + handlePointerCancel(event: PointerEvent): void; -export interface vtkRenderWindowInteractor extends vtkObject { /** * - * @default false + * @param {PointerEvent} event */ - getInitialized(): boolean; + handlePointerMove(event: PointerEvent): void; /** * - * @default null + * @param {PointerEvent} event */ - getContainer(): Nullable; + handleMouseDown(event: PointerEvent): void; /** * - * @default false */ + requestPointerLock(): Promise | undefined; - getEnabled(): boolean; + /** + * + */ + exitPointerLock(): void; /** * - * @default true */ - getEnableRender(): boolean; + isPointerLocked(): boolean; /** * - * @default null */ - getInteractorStyle(): any; + handlePointerLockChange(): void; /** * - * @default 0.1 + * @param requestor */ - getLastFrameTime(): number; + requestAnimation(requestor: any): void; /** * - * @default null */ - getView(): any; + isAnimating(): boolean; /** * - * @default true + * @param requestor + * @param {Boolean} [skipWarning] */ - getLightFollowCamera(): boolean; + cancelAnimation(requestor: any, skipWarning?: boolean): void; /** * + * @param {PointerEvent} event */ - getPicker(): any; + handleMouseMove(event: PointerEvent): void; /** * - * @default true */ - getRecognizeGestures(): boolean; + handleAnimation(): void; /** * - * @default 30.0 + * @param {MouseEvent} event */ - getDesiredUpdateRate(): number; + handleWheel(event: MouseEvent): void; /** * - * @default 2.0 + * @param {PointerEvent} event */ - getStillUpdateRate(): number; + handlePointerEnter(event: PointerEvent): void; /** - * @default false + * + * @param {PointerEvent} event */ - getPreventDefaultOnPointerDown(): boolean; + handlePointerLeave(event: PointerEvent): void; /** - * @default false + * + * @param {PointerEvent} event */ - getPreventDefaultOnPointerUp(): boolean; + handleMouseUp(event: PointerEvent): void; /** - * @default false - * @deprecated Use getWheelEndDebounceDelay() instead. + * + * @param {PointerEvent} event */ - getMouseScrollDebounceByPass(): boolean; + handleTouchStart(event: PointerEvent): void; /** - * @default 200 + * + * @param {PointerEvent} event */ - getWheelEndDebounceDelay(): number; + handleTouchMove(event: PointerEvent): void; /** - * @default false + * + * @param {PointerEvent} event */ - getMouseWheelSpinYBuffering(): boolean; + handleTouchEnd(event: PointerEvent): void; /** - * @default 500 + * + * @param val */ - getLongTapDuration(): number; + setView(val: any): void; + + /** + * @return first renderer to be used for camera manipulation + */ + getFirstRenderer(): vtkRenderer; + + /** + * + * @param {Number} x + * @param {Number} y + */ + findPokedRenderer(x?: number, y?: number): Nullable; + + /** + * only render if we are not animating. If we are animating + * then renders will happen naturally anyhow and we definitely + * do not want extra renders as the make the apparent interaction + * rate slower. + */ + render(): void; + + /** + * we know we are in multitouch now, so start recognizing + * @param event + * @param positions + */ + recognizeGesture( + event: 'TouchStart' | 'TouchMove' | 'TouchEnd', + positions: IPosition + ): void; + + /** + * + */ + handleVisibilityChange(): void; /** - * @default 30 + * Stop animating if the renderWindowInteractor is deleted. */ - getLongTapDistance(): number; + delete(): void; /** * @@ -435,19 +916,25 @@ export interface vtkRenderWindowInteractor extends vtkObject { * * @param {IRenderWindowInteractorEvent} callData */ - invokeStartInteractionEvent(callData: IRenderWindowInteractorEvent): void; + invokeStartInteraction(callData: IRenderWindowInteractorEvent): void; + + /** + * + * @param {IRenderWindowInteractorEvent} callData + */ + invokeInteraction(callData: IRenderWindowInteractorEvent): void; /** * * @param {IRenderWindowInteractorEvent} callData */ - invokeInteractionEvent(callData: IRenderWindowInteractorEvent): void; + invokeEndInteraction(callData: IRenderWindowInteractorEvent): void; /** * * @param {IRenderWindowInteractorEvent} callData */ - invokeEndInteractionEvent(callData: IRenderWindowInteractorEvent): void; + invokeAnimationFrameRateUpdate(callData: IRenderWindowInteractorEvent): void; /** * @@ -826,7 +1313,17 @@ export interface vtkRenderWindowInteractor extends vtkObject { * @param {InteractorEventCallback} cb The callback to be called. * @param {Number} [priority] The priority of the event. */ - onStartInteractionEvent( + onStartInteraction( + cb: InteractorEventCallback, + priority?: number + ): Readonly; + + /** + * + * @param {InteractorEventCallback} cb The callback to be called. + * @param {Number} [priority] The priority of the event. + */ + onInteraction( cb: InteractorEventCallback, priority?: number ): Readonly; @@ -836,7 +1333,7 @@ export interface vtkRenderWindowInteractor extends vtkObject { * @param {InteractorEventCallback} cb The callback to be called. * @param {Number} [priority] The priority of the event. */ - onInteractionEvent( + onEndInteraction( cb: InteractorEventCallback, priority?: number ): Readonly; @@ -846,7 +1343,7 @@ export interface vtkRenderWindowInteractor extends vtkObject { * @param {InteractorEventCallback} cb The callback to be called. * @param {Number} [priority] The priority of the event. */ - onEndInteractionEvent( + onAnimationFrameRateUpdate( cb: InteractorEventCallback, priority?: number ): Readonly; @@ -1109,13 +1606,6 @@ export interface vtkRenderWindowInteractor extends vtkObject { */ setLongTapDuration(longTapDuration: number): boolean; - /** - * Set the maximum distance (in pixels) a press may move before the - * long-press is canceled. - * @param longTapDistance - */ - setLongTapDistance(longTapDistance: number): boolean; - /** * Set the desired update rate. * @param desiredUpdateRate @@ -1339,18 +1829,25 @@ export interface vtkRenderWindowInteractor extends vtkObject { /** * */ - switchToVRAnimation(): void; + switchToXRAnimation(): void; /** * */ - returnFromVRAnimation(): void; + returnFromXRAnimation(): void; /** * - * @param {Number} displayId The ID of the display. + * Update controller button and motion events from the current XR frame. */ - updateGamepads(displayId: number): void; + updateXRGamepads( + xrSession: XRSession, + xrFrame: XRFrame, + xrRefSpace: XRReferenceSpace + ): void; + + /** Continue animating for at least the given number of milliseconds. */ + extendAnimation(duration: number): void; /** * diff --git a/Sources/Rendering/Core/Renderer/index.d.ts b/Sources/Rendering/Core/Renderer/index.d.ts index 45248ffdb91..e6a05100992 100755 --- a/Sources/Rendering/Core/Renderer/index.d.ts +++ b/Sources/Rendering/Core/Renderer/index.d.ts @@ -1,4 +1,4 @@ -import { Bounds, Nullable } from '../../../types'; +import { Bounds, Nullable, RGBAColor } from '../../../types'; import vtkCamera from '../Camera'; import vtkLight from '../Light'; @@ -7,10 +7,14 @@ import vtkProp from '../Prop'; import vtkViewport, { IViewportInitialValues } from '../Viewport'; import vtkVolume from '../Volume'; import vtkTexture from '../Texture'; +import vtkHardwareSelector from '../HardwareSelector'; import { EventHandler, vtkSubscription } from '../../../interfaces'; export interface IRendererInitialValues extends IViewportInitialValues { - allBounds?: Bounds[]; + backgroundTexture?: vtkTexture; + delegate?: any; + renderWindow?: vtkRenderWindow; + allBounds?: Bounds; ambient?: number[]; allocatedRenderTime?: number; timeFactor?: number; @@ -49,7 +53,10 @@ export type VtkRendererEvent = | { type: 'ResetCameraClippingRangeEvent'; renderer: vtkRenderer } | { type: 'ResetCameraEvent'; renderer: vtkRenderer }; -export interface vtkRenderer extends vtkViewport { +export interface vtkRenderer extends Omit< + vtkViewport, + 'getBackground' | 'getBackgroundByReference' | 'setBackgroundFrom' +> { /** * */ @@ -59,7 +66,7 @@ export interface vtkRenderer extends vtkViewport { * Add different types of props to the renderer. * @param {vtkProp} actor The vtkProp instance. */ - addActor(actor: vtkProp): boolean; + addActor(actor: vtkProp): void; /** * Check if the renderer already has the specified light. @@ -82,7 +89,7 @@ export interface vtkRenderer extends vtkViewport { * Add a volume to the renderer.. * @param volume The vtkVolume instance. */ - addVolume(volume: vtkVolume): boolean; + addVolume(volume: vtkVolume): void; /** * Create and add a light to renderer. @@ -131,7 +138,7 @@ export interface vtkRenderer extends vtkViewport { * * @default null */ - getEnvironmentTexture(): vtkTexture; + getEnvironmentTexture(): Nullable; /** * Returns the diffuse strength of the set environment texture. @@ -284,7 +291,7 @@ export interface vtkRenderer extends vtkViewport { * * @default null */ - getSelector(): any; + getSelector(): Nullable; /** * @@ -302,25 +309,31 @@ export interface vtkRenderer extends vtkViewport { * * @default false */ - getTexturedbackground(): boolean; + getTexturedBackground(): boolean; /** * * @default true */ - getTwosidedlighting(): boolean; + getTwoSidedLighting(): boolean; /** * * @default false */ - getUsedepthpeeling(): boolean; + getUseDepthPeeling(): boolean; /** * * @default false */ - getUseshadows(): boolean; + getUseShadows(): boolean; + + /** + * + * @default null + */ + getBackgroundTexture(): Nullable; /** * @@ -498,6 +511,12 @@ export interface vtkRenderer extends vtkViewport { */ setPreserveDepthBuffer(preserveDepthBuffer: boolean): boolean; + /** + * + * @param {vtkTexture} backgroundTexture + */ + setBackgroundTexture(backgroundTexture: vtkTexture): boolean; + /** * * @param {Boolean} texturedBackground @@ -644,13 +663,23 @@ export interface vtkRenderer extends vtkViewport { * space (for instance, Headlights or CameraLights that are attached to the * camera). */ - updateLightGeometry(): boolean; + updateLightGeometry(): boolean | undefined; /** * Not Implemented yet */ visibleVolumeCount(): any; + /** + * Get the viewport background. + */ + getBackground(): RGBAColor; + + /** + * Get the viewport background. + */ + getBackgroundByReference(): RGBAColor; + /** * Set the viewport background. * @@ -677,6 +706,13 @@ export interface vtkRenderer extends vtkViewport { */ setBackground(background: number[]): boolean; + /** + * Set the viewport background. + * + * @param {RGBAColor} background The RGBA color array. + */ + setBackgroundFrom(background: RGBAColor): void; + /** * Adds an event listener. */ diff --git a/Sources/Rendering/Core/ScalarBarActor/Constants.d.ts b/Sources/Rendering/Core/ScalarBarActor/Constants.d.ts new file mode 100644 index 00000000000..ffa2613e527 --- /dev/null +++ b/Sources/Rendering/Core/ScalarBarActor/Constants.d.ts @@ -0,0 +1,12 @@ +export declare const Orientation: { + readonly HORIZONTAL: 'horizontal'; + readonly VERTICAL: 'vertical'; + readonly AUTO: 'auto'; +}; + +export type Orientation = (typeof Orientation)[keyof typeof Orientation]; + +declare const _default: { + Orientation: typeof Orientation; +}; +export default _default; diff --git a/Sources/Rendering/Core/ScalarBarActor/index.d.ts b/Sources/Rendering/Core/ScalarBarActor/index.d.ts index 30fc0f00418..c1070a83140 100644 --- a/Sources/Rendering/Core/ScalarBarActor/index.d.ts +++ b/Sources/Rendering/Core/ScalarBarActor/index.d.ts @@ -1,8 +1,15 @@ +import { vtkObject } from '../../../interfaces'; import vtkScalarsToColors from '../../../Common/Core/ScalarsToColors'; -import { Size, Vector2, Vector3 } from '../../../types'; +import { Nullable, Range, Size, Vector2, Vector3 } from '../../../types'; import vtkActor, { IActorInitialValues } from '../Actor'; +import vtkCamera from '../Camera'; +import { Orientation } from './Constants'; + +export type { Orientation }; export interface ITextSizes { + titleWidth: number; + titleHeight: number; tickWidth: number; tickHeight: number; } @@ -10,8 +17,8 @@ export interface ITextSizes { export interface IResult { ptIdx: number; cellIdx: number; - polys: Float64Array; - points: Uint16Array; + polys: Uint16Array; + points: Float64Array; tcoords: Float32Array; } @@ -22,8 +29,6 @@ export interface IStyle { fontSize?: number | string; } -export type Orientation = 'horizontal' | 'vertical' | 'auto' | null; - /** * */ @@ -32,7 +37,7 @@ export interface IScalarBarActorInitialValues extends Omit< 'orientation' > { automated?: boolean; - autoLayout?: (publicAPI: object, model: object) => void; + autoLayout?: (helper: vtkScalarBarActorHelper) => void; axisLabel?: string; barPosition?: Vector2; barSize?: Size; @@ -43,11 +48,11 @@ export interface IScalarBarActorInitialValues extends Omit< axisTextStyle?: IStyle; tickLabelPixelOffset?: number; tickTextStyle?: IStyle; - generateTicks?: (helper: any) => void; + generateTicks?: (helper: vtkScalarBarActorHelper) => void; drawBelowRangeSwatch?: boolean; drawAboveRangeSwatch?: boolean; drawNanAnnotation?: boolean; - orientation?: Orientation; + orientation?: Orientation | null; } export interface vtkScalarBarActor extends Omit< @@ -56,97 +61,78 @@ export interface vtkScalarBarActor extends Omit< > { /** * - * @param {Boolean} doUpdate */ - completedImage(doUpdate: boolean): void; + getActors(): vtkActor[]; /** - * based on all the settins compute a barSegments array containing the - * segments opf the scalar bar each segment contains : - * corners[4][2] - * title - e.g. NaN, Above, ticks - * scalars - the normalized scalars values to use for that segment * - * Note that the bar consumes the space in the box that remains - * after leaving room for the text labels. - * @param {ITextSizes} textSizes */ - computeBarSize(textSizes: ITextSizes): Size; + getAutoLayout(): (helper: vtkScalarBarActorHelper) => void; /** - * Called by updatePolyDataForLabels modifies class constants ptv3, tmpv3 - * @param text - * @param pos - * @param xdir - * @param ydir - * @param dir - * @param offset - * @param results + * */ - createPolyDataForOneLabel( - text: string, - pos: Vector3, - xdir: Vector3, - ydir: Vector3, - dir: Vector2, - offset: number, - results: IResult - ): void; + getGenerateTicks(): (helper: vtkScalarBarActorHelper) => void; /** * */ - getActors(): vtkActor[]; + getAutomated(): boolean; /** * */ - getAutoLayout(): any; + getAxisLabel(): string; /** * */ - getGenerateTicks(): any; + getAxisTextStyle(): IStyle; /** * */ - getAutomated(): boolean; + getAxisTitlePixelOffset(): number; /** * */ - getAxisLabel(): string; + getBoxPosition(): Vector2; /** * */ - getAxisTextStyle(): IStyle; + getBoxPositionByReference(): Vector2; /** * */ - getAxisTitlePixelOffset(): number; + getBoxSize(): Size; /** * */ - getBoxPosition(): Vector2; + getBoxSizeByReference(): Size; /** * */ - getBoxPositionByReference(): Vector2; + getBarPosition(): Vector2; /** * */ - getBoxSize(): Size; + getBarPositionByReference(): Vector2; /** * */ - getBoxSizeByReference(): Size; + getBarSize(): Size; + + /** + * + */ + getBarSizeByReference(): Size; /** * @@ -176,24 +162,28 @@ export interface vtkScalarBarActor extends Omit< /** * */ - getTickTextStyle(): IStyle; + getTickLabelPixelOffset(): number; /** * - * @param {ITextSizes} textSizes */ - recomputeBarSegments(textSizes: ITextSizes): void; + getTickTextStyle(): IStyle; /** * */ resetAutoLayoutToDefault(): void; + /** + * + */ + resetGenerateTicksToDefault(): void; + /** * * @param autoLayout */ - setAutoLayout(autoLayout: any): boolean; + setAutoLayout(autoLayout: (helper: vtkScalarBarActorHelper) => void): boolean; /** * Sets the function used to generate legend ticks. @@ -211,7 +201,9 @@ export interface vtkScalarBarActor extends Omit< * ``` * @param generateTicks */ - setGenerateTicks(generateTicks: (helper: any) => void): boolean; + setGenerateTicks( + generateTicks: (helper: vtkScalarBarActorHelper) => void + ): boolean; /** * @@ -229,12 +221,12 @@ export interface vtkScalarBarActor extends Omit< * * @param {IStyle} axisTextStyle */ - setAxisTextStyle(axisTextStyle: IStyle): boolean; + setAxisTextStyle(axisTextStyle: IStyle): void; /** * Get the current bar orientation setting */ - getOrientation(): Orientation; + getOrientation(): Orientation | null; /** * Forces the scalar bar to use horizontal orientation regardless of aspect ratio @@ -250,7 +242,7 @@ export interface vtkScalarBarActor extends Omit< * Set the orientation of the scalar bar * @param orientation 'horizontal' to force horizontal, 'vertical' to force vertical, or null/undefined for auto */ - setOrientation(orientation: Orientation): boolean; + setOrientation(orientation: Orientation | null): boolean; /** * @@ -268,7 +260,7 @@ export interface vtkScalarBarActor extends Omit< * * @param {Vector2} boxPosition */ - setBoxPositionFrom(boxPosition: Vector2): boolean; + setBoxPositionFrom(boxPosition: Vector2): void; /** * @@ -280,7 +272,7 @@ export interface vtkScalarBarActor extends Omit< * * @param {Size} boxSize */ - setBoxSizeFrom(boxSize: Size): boolean; + setBoxSizeFrom(boxSize: Size): void; /** * @@ -292,7 +284,7 @@ export interface vtkScalarBarActor extends Omit< * * @param {Vector2} barPosition */ - setBarPositionFrom(barPosition: Vector2): boolean; + setBarPositionFrom(barPosition: Vector2): void; /** * @@ -304,7 +296,7 @@ export interface vtkScalarBarActor extends Omit< * * @param {Size} barSize */ - setBarSizeFrom(barSize: Size): boolean; + setBarSizeFrom(barSize: Size): void; /** * @@ -346,33 +338,254 @@ export interface vtkScalarBarActor extends Omit< * */ setVisibility(visibility: boolean): boolean; +} +export interface IScalarBarActorHelperInitialValues { + renderable?: Nullable; +} + +/** + * View dependent half of vtkScalarBarActor. + * + * One helper is instantiated per API specific view, and holds the properties + * that depend on view specific values such as the view resolution. API + * specific views (vtkOpenGLScalarBarActor, vtkWebGPUScalarBarActor) delegate + * most of their work to it. + */ +export interface vtkScalarBarActorHelper extends vtkObject { /** - * main method to rebuild the scalarBar when something has changed tracks - * modified times + * Get the actor drawing the colored bar segments. */ - update(): void; + getBarActor(): vtkActor; + + /** + * Get the actor drawing the text label quads. + */ + getTmActor(): vtkActor; /** * */ - updatePolyDataForBarSegments(): void; + getAxisTextStyle(): IStyle; + + /** + * + */ + getTickTextStyle(): IStyle; + + /** + * Pixel offset between the bar and the axis title, as used for this view. + */ + getAxisTitlePixelOffset(): number; + + /** + * Pixel offset between the bar and the axis title, as used for this view. + * @param {Number} axisTitlePixelOffset + */ + setAxisTitlePixelOffset(axisTitlePixelOffset: number): boolean; + + /** + * Pixel offset between the bar and the tick labels, as used for this view. + */ + getTickLabelPixelOffset(): number; + + /** + * Pixel offset between the bar and the tick labels, as used for this view. + * @param {Number} tickLabelPixelOffset + */ + setTickLabelPixelOffset(tickLabelPixelOffset: number): boolean; + + /** + * Get the actor this helper renders for. + */ + getRenderable(): Nullable; + + /** + * Bind this helper to an actor. Rebinds the internal actors' property, + * parent prop and coordinate system, and copies the actor's text styles. + * @param {vtkScalarBarActor} renderable + */ + setRenderable(renderable: vtkScalarBarActor): void; + + /** + * Whether the axis title is drawn above the bar rather than beside it. + */ + getTopTitle(): boolean; + + /** + * Whether the axis title is drawn above the bar rather than beside it. + * @param {Boolean} topTitle + */ + setTopTitle(topTitle: boolean): boolean; + + /** + * The scalar values the ticks are drawn at. + */ + getTicks(): number[]; + + /** + * The scalar values the ticks are drawn at. + * @param {Number[]} ticks + */ + setTicks(ticks: number[]): boolean; /** - * Udate the polydata associated with drawing the text labels - * specifically the quads used for each label and their associated tcoords - * etc. This changes every time the camera viewpoint changes + * The label drawn for each entry of `getTicks()`. + */ + getTickStrings(): string[]; + + /** + * The label drawn for each entry of `getTicks()`. + * @param {String[]} tickStrings + */ + setTickStrings(tickStrings: string[]): boolean; + + /** + * Normalized position along the tick segment for each tick. When unset, the + * position is derived from the tick value and the mapping range. + */ + getTickPositions(): number[] | undefined; + + /** + * Normalized position along the tick segment for each tick. + * @param {Number[]} tickPositions + */ + setTickPositions(tickPositions: number[]): boolean; + + /** + * The view size in pixels recorded at the last `updateAPISpecificData()`. + */ + getLastSize(): Vector2; + + /** + * The view aspect ratio recorded at the last `updateAPISpecificData()`. + */ + getLastAspectRatio(): number; + + /** + * The scalar range the bar was last built for. + */ + getLastTickBounds(): Range; + + /** + * Position of the box the bar and its labels are laid out in, in normalized + * viewport coordinates. + */ + getBoxPosition(): Vector2; + + /** + * + */ + getBoxPositionByReference(): Vector2; + + /** + * + * @param {Vector2} boxPosition + */ + setBoxPosition(boxPosition: Vector2): boolean; + + /** + * + * @param {Vector2} boxPosition + */ + setBoxPositionFrom(boxPosition: Vector2): void; + + /** + * Size of the box the bar and its labels are laid out in, in normalized + * viewport coordinates. + */ + getBoxSize(): Size; + + /** + * + */ + getBoxSizeByReference(): Size; + + /** + * + * @param {Size} boxSize + */ + setBoxSize(boxSize: Size): boolean; + + /** + * + * @param {Size} boxSize + */ + setBoxSizeFrom(boxSize: Size): void; + + /** + * Record the view resolution, camera and render window, and rebuild the + * texture atlas, bar segments and polydata when anything they depend on has + * changed. + * @param {Vector2} size the view size in pixels + * @param {vtkCamera} camera + * @param renderWindow + */ + updateAPISpecificData( + size: Vector2, + camera: vtkCamera, + renderWindow: unknown + ): void; + + /** + * Render every label into the texture atlas and return the resulting text + * measurements. Only needs to be called when the strings change. + */ + updateTextureAtlas(): ITextSizes; + + /** + * Compute the bar position and size within the box, and return the size of a + * single bar segment in normalized bar coordinates. + * @param {ITextSizes} textSizes + */ + computeBarSize(textSizes: ITextSizes): Vector2; + + /** + * Rebuild the bar segments (NaN, Below, ticks, Above) from the current + * settings. + * @param {ITextSizes} textSizes + */ + recomputeBarSegments(textSizes: ITextSizes): void; + + /** + * Append the quad for a single label to `results`, advancing its point and + * cell indices. Does nothing when the text is absent from the texture atlas. + * @param {String} text + * @param {Vector3} pos anchor point in normalized viewport coordinates + * @param alignment horizontal and vertical anchoring of the text + * @param orientation text orientation + * @param {Vector2} offset pixel offset applied to the anchor point + * @param {IResult} results accumulator that is mutated in place + */ + createPolyDataForOneLabel( + text: string, + pos: Vector3, + alignment: ['left' | 'middle' | 'right', 'bottom' | 'middle' | 'top'], + orientation: 'horizontal' | 'vertical', + offset: Vector2, + results: IResult + ): void; + + /** + * Rebuild the polydata holding the label quads and their texture + * coordinates. */ updatePolyDataForLabels(): void; /** - * create the texture map atlas that contains the rendering of - * all the text strings. Only needs to be called when the text strings - * have changed (labels and ticks) + * Rebuild the polydata holding the colored bar segments. */ - updateTextureAtlas(): void; + updatePolyDataForBarSegments(): void; } +/** + * Create a view dependent helper for a vtkScalarBarActor. + * @param {IScalarBarActorHelperInitialValues} [initialValues] for pre-setting some of its content + */ +declare function newScalarBarActorHelper( + initialValues?: IScalarBarActorHelperInitialValues +): vtkScalarBarActorHelper; + /** * Method use to decorate a given object (publicAPI+model) with vtkScalarBarActor characteristics. * @@ -404,5 +617,7 @@ export function newInstance( export declare const vtkScalarBarActor: { newInstance: typeof newInstance; extend: typeof extend; + newScalarBarActorHelper: typeof newScalarBarActorHelper; + Orientation: typeof Orientation; }; export default vtkScalarBarActor; diff --git a/Sources/Rendering/Core/Skybox/index.d.ts b/Sources/Rendering/Core/Skybox/index.d.ts index c1681c49b55..b66951a120a 100755 --- a/Sources/Rendering/Core/Skybox/index.d.ts +++ b/Sources/Rendering/Core/Skybox/index.d.ts @@ -8,7 +8,7 @@ export interface vtkSkybox extends vtkActor { /** * */ - getFromat(): string; + getFormat(): string; /** * @@ -29,7 +29,7 @@ export interface vtkSkybox extends vtkActor { * * @param format */ - setFromat(format: string): boolean; + setFormat(format: string): boolean; } /** diff --git a/Sources/Rendering/Core/SphereMapper/index.d.ts b/Sources/Rendering/Core/SphereMapper/index.d.ts index f0274be9961..f889fb10def 100755 --- a/Sources/Rendering/Core/SphereMapper/index.d.ts +++ b/Sources/Rendering/Core/SphereMapper/index.d.ts @@ -1,6 +1,9 @@ +import { Nullable } from '../../../types'; import vtkMapper, { IMapperInitialValues } from '../Mapper'; export interface ISphereInitialValues extends IMapperInitialValues { + scaleArray?: Nullable; + scaleFactor?: number; radius?: number; } @@ -13,7 +16,7 @@ export interface vtkSphereMapper extends vtkMapper { /** * */ - getScaleArray(): any; + getScaleArray(): Nullable; /** * @@ -30,7 +33,7 @@ export interface vtkSphereMapper extends vtkMapper { * * @param scaleArray */ - setScaleArray(scaleArray: any): boolean; + setScaleArray(scaleArray: Nullable): boolean; /** * Factor multiplied with scale array elements. Radius is used when no scale array is given. diff --git a/Sources/Rendering/Core/StickMapper/index.d.ts b/Sources/Rendering/Core/StickMapper/index.d.ts index 91e7852460a..fc8dac237da 100755 --- a/Sources/Rendering/Core/StickMapper/index.d.ts +++ b/Sources/Rendering/Core/StickMapper/index.d.ts @@ -1,10 +1,11 @@ import vtkMapper, { IMapperInitialValues } from '../Mapper'; +import { Nullable } from '../../../types'; interface IStickMappereInitialValues extends IMapperInitialValues { radius?: number; length?: number; - scaleArray?: number[]; - orientationArray?: number[]; + scaleArray?: Nullable; + orientationArray?: Nullable; } export interface vtkStickMapper extends vtkMapper { @@ -16,7 +17,7 @@ export interface vtkStickMapper extends vtkMapper { /** * */ - getScaleArray(): number[]; + getScaleArray(): Nullable; /** * @@ -28,7 +29,24 @@ export interface vtkStickMapper extends vtkMapper { * * @param scaleArray */ - setScaleArray(scaleArray: number[]): boolean; + setScaleArray(scaleArray: Nullable): boolean; + + /** + * Get the name of the point data array holding the stick orientations. + */ + getOrientationArray(): Nullable; + + /** + * Set the name of the point data array holding the stick orientations. + * @param {String} orientationArray Name of the array + */ + setOrientationArray(orientationArray: Nullable): boolean; + + /** + * + * @param {Number} length + */ + setLength(length: number): boolean; } /** diff --git a/Sources/Rendering/Core/SurfaceLICInterface/Constants.d.ts b/Sources/Rendering/Core/SurfaceLICInterface/Constants.d.ts new file mode 100644 index 00000000000..3b35592255b --- /dev/null +++ b/Sources/Rendering/Core/SurfaceLICInterface/Constants.d.ts @@ -0,0 +1,30 @@ +export declare const ContrastEnhanceMode: { + readonly NONE: 0; + readonly LIC: 1; + readonly COLOR: 2; + readonly BOTH: 3; +}; + +export type ContrastEnhanceMode = + (typeof ContrastEnhanceMode)[keyof typeof ContrastEnhanceMode]; + +export declare const NoiseType: { + readonly UNIFORM: 0; + readonly GAUSSIAN: 1; +}; + +export type NoiseType = (typeof NoiseType)[keyof typeof NoiseType]; + +export declare const ColorMode: { + readonly BLEND: 0; + readonly MULTIPLY: 1; +}; + +export type ColorMode = (typeof ColorMode)[keyof typeof ColorMode]; + +declare const _default: { + ColorMode: typeof ColorMode; + ContrastEnhanceMode: typeof ContrastEnhanceMode; + NoiseType: typeof NoiseType; +}; +export default _default; diff --git a/Sources/Rendering/Core/SurfaceLICInterface/index.d.ts b/Sources/Rendering/Core/SurfaceLICInterface/index.d.ts new file mode 100644 index 00000000000..0c8c37f6400 --- /dev/null +++ b/Sources/Rendering/Core/SurfaceLICInterface/index.d.ts @@ -0,0 +1,175 @@ +import { vtkObject } from '../../../interfaces'; +import { RGBColor } from '../../../types'; +import { ColorMode, ContrastEnhanceMode, NoiseType } from './Constants'; + +export interface ISurfaceLICInterfaceInitialValues { + enableLIC?: boolean; + numberOfSteps?: number; + stepSize?: number; + transformVectors?: boolean; + normalizeVectors?: boolean; + maskOnSurface?: boolean; + maskThreshold?: number; + maskColor?: RGBColor; + maskIntensity?: number; + enhancedLIC?: boolean; + enhanceContrast?: ContrastEnhanceMode; + lowLICContrastEnhancementFactor?: number; + highLICContrastEnhancementFactor?: number; + lowColorContrastEnhancementFactor?: number; + highColorContrastEnhancementFactor?: number; + antiAlias?: number; + colorMode?: ColorMode; + LICIntensity?: number; + mapModeBias?: number; + noiseTextureSize?: number; + noiseTextureType?: NoiseType; + noiseGrainSize?: number; + noiseImpulseProbability?: number; + noiseImpulseBackgroundValue?: number; + noiseGeneratorSeed?: number; + minNoiseValue?: number; + maxNoiseValue?: number; + numberOfNoiseLevels?: number; + shadersNeedBuilding?: boolean; + reallocateTextures?: boolean; + rebuildNoiseTexture?: boolean; + viewPortScale?: number; +} + +export interface vtkSurfaceLICInterface extends vtkObject { + getEnableLIC(): boolean; + setEnableLIC(enableLIC: boolean): boolean; + + /** + * Number of integration steps taken on each side of a seed. + */ + getNumberOfSteps(): number; + setNumberOfSteps(numberOfSteps: number): boolean; + + getStepSize(): number; + setStepSize(stepSize: number): boolean; + + getNormalizeVectors(): boolean; + setNormalizeVectors(normalizeVectors: boolean): boolean; + + getTransformVectors(): boolean; + setTransformVectors(transformVectors: boolean): boolean; + + getMaskOnSurface(): boolean; + setMaskOnSurface(maskOnSurface: boolean): boolean; + + getMaskThreshold(): number; + setMaskThreshold(maskThreshold: number): boolean; + + getMaskColor(): RGBColor; + setMaskColor(maskColor: RGBColor): boolean; + + getMaskIntensity(): number; + setMaskIntensity(maskIntensity: number): boolean; + + getEnhancedLIC(): boolean; + setEnhancedLIC(enhancedLIC: boolean): boolean; + + getEnhanceContrast(): ContrastEnhanceMode; + setEnhanceContrast(enhanceContrast: ContrastEnhanceMode): boolean; + + getLowLICContrastEnhancementFactor(): number; + setLowLICContrastEnhancementFactor( + lowLICContrastEnhancementFactor: number + ): boolean; + + getHighLICContrastEnhancementFactor(): number; + setHighLICContrastEnhancementFactor( + highLICContrastEnhancementFactor: number + ): boolean; + + getLowColorContrastEnhancementFactor(): number; + setLowColorContrastEnhancementFactor( + lowColorContrastEnhancementFactor: number + ): boolean; + + getHighColorContrastEnhancementFactor(): number; + setHighColorContrastEnhancementFactor( + highColorContrastEnhancementFactor: number + ): boolean; + + getAntiAlias(): number; + setAntiAlias(antiAlias: number): boolean; + + getColorMode(): ColorMode; + setColorMode(colorMode: ColorMode): boolean; + + getLICIntensity(): number; + setLICIntensity(LICIntensity: number): boolean; + + getMapModeBias(): number; + setMapModeBias(mapModeBias: number): boolean; + + getNoiseTextureSize(): number; + setNoiseTextureSize(noiseTextureSize: number): boolean; + + getNoiseTextureType(): NoiseType; + setNoiseTextureType(noiseTextureType: NoiseType): boolean; + + getNoiseGrainSize(): number; + setNoiseGrainSize(noiseGrainSize: number): boolean; + + getMinNoiseValue(): number; + setMinNoiseValue(minNoiseValue: number): boolean; + + getMaxNoiseValue(): number; + setMaxNoiseValue(maxNoiseValue: number): boolean; + + getNumberOfNoiseLevels(): number; + setNumberOfNoiseLevels(numberOfNoiseLevels: number): boolean; + + getNoiseImpulseProbability(): number; + setNoiseImpulseProbability(noiseImpulseProbability: number): boolean; + + getNoiseImpulseBackgroundValue(): number; + setNoiseImpulseBackgroundValue(noiseImpulseBackgroundValue: number): boolean; + + getNoiseGeneratorSeed(): number; + setNoiseGeneratorSeed(noiseGeneratorSeed: number): boolean; + + getViewPortScale(): number; + setViewPortScale(viewPortScale: number): boolean; + + getRebuildNoiseTexture(): boolean; + setRebuildNoiseTexture(rebuildNoiseTexture: boolean): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with + * vtkSurfaceLICInterface characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ISurfaceLICInterfaceInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ISurfaceLICInterfaceInitialValues +): void; + +/** + * Method used to create a new instance of vtkSurfaceLICInterface. + * @param {ISurfaceLICInterfaceInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: ISurfaceLICInterfaceInitialValues +): vtkSurfaceLICInterface; + +/** + * vtkSurfaceLICInterface is a parameter holder for the Line Integral + * Convolution surface rendering. It carries the LIC integration, masking, + * contrast enhancement and noise texture settings that the API specific + * mapper implementations read. + */ +export declare const vtkSurfaceLICInterface: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkSurfaceLICInterface; diff --git a/Sources/Rendering/Core/SurfaceLICMapper/index.d.ts b/Sources/Rendering/Core/SurfaceLICMapper/index.d.ts new file mode 100644 index 00000000000..821610cc92a --- /dev/null +++ b/Sources/Rendering/Core/SurfaceLICMapper/index.d.ts @@ -0,0 +1,50 @@ +import { Nullable } from '../../../types'; +import vtkMapper, { IMapperInitialValues } from '../Mapper'; +import vtkSurfaceLICInterface from '../SurfaceLICInterface'; + +export interface ISurfaceLICMapperInitialValues extends IMapperInitialValues { + licInterface?: Nullable; +} + +export interface vtkSurfaceLICMapper extends vtkMapper { + /** + * Get the LIC parameter holder, creating it on first access. + */ + getLicInterface(): vtkSurfaceLICInterface; + + setLicInterface(licInterface: vtkSurfaceLICInterface): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with + * vtkSurfaceLICMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ISurfaceLICMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ISurfaceLICMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkSurfaceLICMapper. + * @param {ISurfaceLICMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: ISurfaceLICMapperInitialValues +): vtkSurfaceLICMapper; + +/** + * vtkSurfaceLICMapper is a vtkMapper that carries a vtkSurfaceLICInterface, + * holding the Line Integral Convolution parameters used by the API specific + * mapper implementations. + * @see [vtkSurfaceLICInterface](./Rendering_Core_SurfaceLICInterface.html) + */ +export declare const vtkSurfaceLICMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkSurfaceLICMapper; diff --git a/Sources/Rendering/Core/TextProperty/index.d.ts b/Sources/Rendering/Core/TextProperty/index.d.ts index f0a1490eb28..47be011a796 100644 --- a/Sources/Rendering/Core/TextProperty/index.d.ts +++ b/Sources/Rendering/Core/TextProperty/index.d.ts @@ -91,6 +91,12 @@ export interface vtkTextProperty extends vtkProperty2D { */ setBackgroundColor(backgroundColor: RGBColor): boolean; + /** + * Set the background color. + * @param {RGBColor} backgroundColor The background color to set. + */ + setBackgroundColorFrom(backgroundColor: RGBColor): void; + /** * Set the fill style. * @param {string} fillStyle The fill style to set. @@ -109,7 +115,7 @@ export interface vtkTextProperty extends vtkProperty2D { * Set the font color. * @param {RGBColor} fontColor The font color to set. */ - setFontColorFrom(fontColor: RGBColor): boolean; + setFontColorFrom(fontColor: RGBColor): void; /** * Set the font family. @@ -122,9 +128,9 @@ export interface vtkTextProperty extends vtkProperty2D { * Scales the font size based on the given resolution. * Dividing by 1.8 ensures the font size is proportionate and not too large. * The value 1.8 is a chosen scaling factor for visual balance. - * @param {number} resolution The resolution to set. + * @param {Function} fontSizeScale The font size scale function to set. */ - setFontSizeScale(resolution: number): number; + setFontSizeScale(fontSizeScale: (resolution: number) => number): boolean; /** * Set the font style. @@ -156,7 +162,7 @@ export interface vtkTextProperty extends vtkProperty2D { * Set the shadow color. * @param {RGBColor} shadowColor The shadow color to set. */ - setShadowColorFrom(shadowColor: RGBColor): boolean; + setShadowColorFrom(shadowColor: RGBColor): void; /** * Set the shadow offset from x and y values. @@ -169,7 +175,7 @@ export interface vtkTextProperty extends vtkProperty2D { * Set the shadow offset. * @param {Array} shadowOffset The shadow offset to set, as an array of [x, y]. */ - setShadowOffsetFrom(shadowOffset: [number, number]): boolean; + setShadowOffsetFrom(shadowOffset: [number, number]): void; } /** diff --git a/Sources/Rendering/Core/Texture/index.d.ts b/Sources/Rendering/Core/Texture/index.d.ts index 57dc286122b..a289546a365 100755 --- a/Sources/Rendering/Core/Texture/index.d.ts +++ b/Sources/Rendering/Core/Texture/index.d.ts @@ -1,20 +1,43 @@ -import { vtkAlgorithm } from '../../../interfaces'; +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; import { Nullable } from '../../../types'; +export type TextureWrap = 'repeat' | 'clamp-to-edge' | 'mirror-repeat'; + /** * * @param {boolean} [resizable] Must be set to true if texture can be resized at run time (default: false) */ export interface ITextureInitialValues { + canvas?: HTMLCanvasElement; + image?: HTMLImageElement; + imageBitmap?: ImageBitmap; + jsImageData?: ImageData; repeat?: boolean; interpolate?: boolean; edgeClamp?: boolean; imageLoaded?: boolean; mipLevel?: number; resizable?: boolean; + wrapS?: Nullable; + wrapT?: Nullable; } -export interface vtkTexture extends vtkAlgorithm { +type vtkTextureBase = vtkObject & + Omit; + +export interface vtkTexture extends vtkTextureBase { + /** Get the horizontal wrap mode, or null to use repeat and edgeClamp. */ + getWrapS(): Nullable; + /** Set the horizontal wrap mode, or null to use repeat and edgeClamp. */ + setWrapS(wrapS: Nullable): boolean; + /** Get the vertical wrap mode, or null to use repeat and edgeClamp. */ + getWrapT(): Nullable; + /** Set the vertical wrap mode, or null to use repeat and edgeClamp. */ + setWrapT(wrapT: Nullable): boolean; + + /** Return the number of non-singleton dimensions in the texture input. */ + getDimensionality(): number; + /** * Returns the canvas used by the texture. */ @@ -50,6 +73,11 @@ export interface vtkTexture extends vtkAlgorithm { */ getImageLoaded(): boolean; + /** + * Returns the input image data as a JavaScript ImageData object. + */ + getJsImageData(): Nullable; + /** * Returns the input image data object. */ @@ -69,6 +97,12 @@ export interface vtkTexture extends vtkAlgorithm { */ getResizable(): boolean; + /** + * Marks the image as loaded and notifies listeners. + * Called automatically once the image set with setImage() has loaded. + */ + imageLoaded(): void; + /** * Returns the canvas used by the texture. */ @@ -153,7 +187,7 @@ export function newInstance(initialValues?: ITextureInitialValues): vtkTexture; * @param {GPUTexture} texture - The GPU texture for which mipmaps will be generated. * @param {number} mipLevelCount - The total number of mip levels to generate (including the base level). */ -export function generateMipmaps( +declare function generateMipmaps( device: any, texture: any, mipLevelCount: number @@ -174,5 +208,9 @@ export function generateMipmaps( export declare const vtkTexture: { newInstance: typeof newInstance; extend: typeof extend; + generateMipmaps: typeof generateMipmaps; }; +export declare const STATIC: Readonly<{ + generateMipmaps: typeof generateMipmaps; +}>; export default vtkTexture; diff --git a/Sources/Rendering/Core/VectorText/index.d.ts b/Sources/Rendering/Core/VectorText/index.d.ts index 9b78493d52f..090b7462f67 100644 --- a/Sources/Rendering/Core/VectorText/index.d.ts +++ b/Sources/Rendering/Core/VectorText/index.d.ts @@ -17,7 +17,16 @@ export interface IVectorTextInitialValues { perLetterFaceColors?: (letterIndex: number) => [number, number, number]; } -type vtkVectorTextBase = vtkObject & vtkAlgorithm; +type vtkVectorTextBase = vtkObject & + Omit< + vtkAlgorithm, + | 'getInputData' + | 'setInputData' + | 'setInputConnection' + | 'getInputConnection' + | 'addInputConnection' + | 'addInputData' + >; export interface vtkVectorText extends vtkVectorTextBase { /** @@ -68,7 +77,7 @@ export interface vtkVectorText extends vtkVectorTextBase { /** * Returns the current text string. */ - getText(): string; + getText(): string | null; /** * Gets or sets the per-letter face color function. @@ -76,6 +85,13 @@ export interface vtkVectorText extends vtkVectorTextBase { */ getPerLetterFaceColors(): Nullable<(letterIndex: number) => RGBColor>; + /** + * Expose methods + * @param inData + * @param outData + */ + requestData(inData: any, outData: any): void; + /** * Enables or disables beveling. * @param bevelEnabled - True to enable beveling, false to disable. diff --git a/Sources/Rendering/Core/Viewport/index.d.ts b/Sources/Rendering/Core/Viewport/index.d.ts index 874c07a28f2..04405c768a4 100755 --- a/Sources/Rendering/Core/Viewport/index.d.ts +++ b/Sources/Rendering/Core/Viewport/index.d.ts @@ -1,5 +1,5 @@ -import { vtkObject } from '../../../interfaces'; -import { RGBColor, Size } from '../../../types'; +import { EventHandler, vtkObject, vtkSubscription } from '../../../interfaces'; +import { RGBColor } from '../../../types'; import vtkActor2D from '../Actor2D'; import vtkProp from '../Prop'; @@ -70,7 +70,7 @@ export interface vtkViewport extends vtkObject { /** * Get the size and origin of the viewport in display coordinates. */ - getSize(): Size; + getSize(): void; /** * Viewport for the Viewport to draw in the rendering window. @@ -90,7 +90,7 @@ export interface vtkViewport extends vtkObject { /** * */ - getViewPropsWithNestedProps(): any; + getViewPropsWithNestedProps(): vtkProp[]; /** * @@ -179,13 +179,13 @@ export interface vtkViewport extends vtkObject { * Set the viewport secondary background. * @param {RGBColor} background */ - setBackground2From(background: RGBColor): boolean; + setBackground2From(background: RGBColor): void; /** * Set the viewport background. * @param {RGBColor} background */ - setBackgroundFrom(background: RGBColor): boolean; + setBackgroundFrom(background: RGBColor): void; /** * Set the gradient background flag. @@ -208,7 +208,7 @@ export interface vtkViewport extends vtkObject { * Coordinates are expressed as [xmin, ymin, xmax, ymax], where each coordinate is 0 <= coordinate <= 1.0. * @param {Number[]} viewport */ - setViewportFrom(viewport: number[]): boolean; + setViewportFrom(viewport: number[]): void; /** * @@ -244,6 +244,16 @@ export interface vtkViewport extends vtkObject { * Not Implemented yet */ PickPropFrom(): any; + + /** + * Adds an event listener. + */ + onEvent(cb: EventHandler, priority?: number): Readonly; + + /** + * + */ + invokeEvent(...args: unknown[]): void; } /** diff --git a/Sources/Rendering/Core/VolumeMapper/Constants.d.ts b/Sources/Rendering/Core/VolumeMapper/Constants.d.ts index eee908bef73..1e712fdcec1 100644 --- a/Sources/Rendering/Core/VolumeMapper/Constants.d.ts +++ b/Sources/Rendering/Core/VolumeMapper/Constants.d.ts @@ -1,12 +1,14 @@ -export declare enum BlendMode { - COMPOSITE_BLEND = 0, - MAXIMUM_INTENSITY_BLEND = 1, - MINIMUM_INTENSITY_BLEND = 2, - AVERAGE_INTENSITY_BLEND = 3, - ADDITIVE_INTENSITY_BLEND = 4, - RADON_TRANSFORM_BLEND = 5, - LABELMAP_EDGE_PROJECTION_BLEND = 6, -} +export declare const BlendMode: { + readonly COMPOSITE_BLEND: 0; + readonly MAXIMUM_INTENSITY_BLEND: 1; + readonly MINIMUM_INTENSITY_BLEND: 2; + readonly AVERAGE_INTENSITY_BLEND: 3; + readonly ADDITIVE_INTENSITY_BLEND: 4; + readonly RADON_TRANSFORM_BLEND: 5; + readonly LABELMAP_EDGE_PROJECTION_BLEND: 6; +}; + +export type BlendMode = (typeof BlendMode)[keyof typeof BlendMode]; declare const _default: { BlendMode: typeof BlendMode; diff --git a/Sources/Rendering/Core/VolumeMapper/index.d.ts b/Sources/Rendering/Core/VolumeMapper/index.d.ts index ee145d7d90d..7064c7d9aa9 100755 --- a/Sources/Rendering/Core/VolumeMapper/index.d.ts +++ b/Sources/Rendering/Core/VolumeMapper/index.d.ts @@ -5,6 +5,7 @@ import { IAbstractMapper3DInitialValues, } from '../AbstractMapper3D'; import { BlendMode } from './Constants'; +import { EventHandler, vtkSubscription } from '../../../interfaces'; /** * @@ -86,7 +87,7 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D { * Set blend mode to COMPOSITE_BLEND * @param {BlendMode} blendMode */ - setBlendMode(blendMode: BlendMode): void; + setBlendMode(blendMode: BlendMode): boolean; /** * Set blend mode to COMPOSITE_BLEND @@ -108,6 +109,9 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D { */ setBlendModeToAverageIntensity(): void; + /** Set blend mode to ADDITIVE_INTENSITY_BLEND. */ + setBlendModeToAdditiveIntensity(): void; + /** * Set blend mode to RADON_TRANSFORM_BLEND */ @@ -232,6 +236,24 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D { * Get the label outline texture width. */ getLabelOutlineTextureWidth(): number; + + /** + * Register a callback to be invoked when the `LightingActivated` event occurs. + * + * @param {EventHandler} cb The callback to register + * @param {Number} [priority] Priority of this subscription + */ + onLightingActivated( + cb: EventHandler, + priority?: number + ): Readonly; + + /** + * Invoke the `LightingActivated` event with the given payload. + * + * @param args The event payload + */ + invokeLightingActivated(...args: unknown[]): void; } /** @@ -257,7 +279,7 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D { * @param {vtkPiecewiseFunction} outputTransferFunction: To provide optionally to avoid instantiating a new transfer function each time. * @return {vtkPiecewiseFunction} the created absorption transfer function to set on VolumeMapper scalarOpacity. */ -export function createRadonTransferFunction( +declare function createRadonTransferFunction( firstAbsorbentMaterialHounsfieldValue: number, firstAbsorbentMaterialAbsorption: number, maxAbsorbentMaterialHounsfieldValue: number, @@ -292,6 +314,9 @@ export function newInstance( export declare const vtkVolumeMapper: { newInstance: typeof newInstance; extend: typeof extend; - BlendMode: typeof BlendMode; + createRadonTransferFunction: typeof createRadonTransferFunction; }; +export declare const STATIC: Readonly<{ + createRadonTransferFunction: typeof createRadonTransferFunction; +}>; export default vtkVolumeMapper; diff --git a/Sources/Rendering/Core/VolumeProperty/Constants.d.ts b/Sources/Rendering/Core/VolumeProperty/Constants.d.ts index 92ea3466ce3..f02ff495225 100644 --- a/Sources/Rendering/Core/VolumeProperty/Constants.d.ts +++ b/Sources/Rendering/Core/VolumeProperty/Constants.d.ts @@ -1,37 +1,47 @@ -export declare enum InterpolationType { - NEAREST = 0, - LINEAR = 1, - FAST_LINEAR = 2, -} +export declare const InterpolationType: { + readonly NEAREST: 0; + readonly LINEAR: 1; + readonly FAST_LINEAR: 2; +}; + +export type InterpolationType = + (typeof InterpolationType)[keyof typeof InterpolationType]; -export declare enum OpacityMode { - FRACTIONAL = 0, - PROPORTIONAL = 1, -} +export declare const OpacityMode: { + readonly FRACTIONAL: 0; + readonly PROPORTIONAL: 1; +}; -export declare enum ColorMixPreset { - DEFAULT = 0, +export type OpacityMode = (typeof OpacityMode)[keyof typeof OpacityMode]; + +export declare const ColorMixPreset: { + readonly DEFAULT: 0; // Two components preset // Out color: sum of colors weighted by opacity // Out opacity: sum of opacities - ADDITIVE = 1, + readonly ADDITIVE: 1; // Two components preset // Out color: color of the first component, colorized by second component with an intensity that is the second component's opacity // Out opacity: opacity of the first component - COLORIZE = 2, + readonly COLORIZE: 2; // Add a `//VTK::CustomColorMix` tag to the Fragment shader // See usage in file `testColorMix` and in function `setColorMixPreset` - CUSTOM = 3, -} - -export declare enum FilterMode { - OFF = 0, - NORMALIZED = 1, - RAW = 2, -} + readonly CUSTOM: 3; +}; + +export type ColorMixPreset = + (typeof ColorMixPreset)[keyof typeof ColorMixPreset]; + +export declare const FilterMode: { + readonly OFF: 0; + readonly NORMALIZED: 1; + readonly RAW: 2; +}; + +export type FilterMode = (typeof FilterMode)[keyof typeof FilterMode]; declare const _default: { InterpolationType: typeof InterpolationType; diff --git a/Sources/Rendering/Core/VolumeProperty/index.d.ts b/Sources/Rendering/Core/VolumeProperty/index.d.ts index 28851ebffd0..335a79beff5 100755 --- a/Sources/Rendering/Core/VolumeProperty/index.d.ts +++ b/Sources/Rendering/Core/VolumeProperty/index.d.ts @@ -1,8 +1,13 @@ import vtkPiecewiseFunction from '../../../Common/DataModel/PiecewiseFunction'; import { vtkObject } from '../../../interfaces'; -import { Extent, Nullable } from '../../../types'; +import { Extent, Nullable, Range } from '../../../types'; import vtkColorTransferFunction from '../ColorTransferFunction'; -import { ColorMixPreset, InterpolationType, OpacityMode } from './Constants'; +import { + ColorMixPreset, + FilterMode, + InterpolationType, + OpacityMode, +} from './Constants'; export interface IVolumePropertyInitialValues { independentComponents?: boolean; @@ -13,7 +18,11 @@ export interface IVolumePropertyInitialValues { specularPower?: number; useLabelOutline?: boolean; labelOutlineThickness?: number | number[]; + labelOutlineOpacity?: number; colorMixPreset?: ColorMixPreset; + filterMode?: FilterMode; + preferSizeOverAccuracy?: boolean; + computeNormalFromOpacity?: boolean; } export interface vtkVolumeProperty extends vtkObject { @@ -107,7 +116,13 @@ export interface vtkVolumeProperty extends vtkObject { /** * gets the label outline thickness */ - getLabelOutlineThickness(): number; + getLabelOutlineThickness(): number[]; + + /** + * Get the label outline thickness array by reference. + * This returns the actual internal array, not a copy. + */ + getLabelOutlineThicknessByReference(): number[]; /** * Get the currently set RGB transfer function. Create one if none set. @@ -153,6 +168,21 @@ export interface vtkVolumeProperty extends vtkObject { */ getUseLabelOutline(): boolean; + /** Get the opacity applied to label outlines. */ + getLabelOutlineOpacity(): number; + + /** Get the volume filtering mode. */ + getFilterMode(): FilterMode; + + /** Get the volume filtering mode as a string. */ + getFilterModeAsString(): string; + + /** Get whether half-float storage is preferred over accuracy. */ + getPreferSizeOverAccuracy(): boolean; + + /** Get whether normals are computed from opacity. */ + getComputeNormalFromOpacity(): boolean; + /** * Set the ambient lighting coefficient. * @param {Number} ambient The ambient lighting coefficient. @@ -251,6 +281,12 @@ export interface vtkVolumeProperty extends vtkObject { */ setLabelOutlineThickness(labelOutlineThickness: number | number[]): boolean; + /** + * Set the label outline thickness array from another array, without a copy. + * @param {Number[]} labelOutlineThickness + */ + setLabelOutlineThicknessFrom(labelOutlineThickness: number[]): void; + /** * * @param {Number} index @@ -306,6 +342,24 @@ export interface vtkVolumeProperty extends vtkObject { */ setUseLabelOutline(useLabelOutline: boolean): boolean; + /** Set the opacity applied to label outlines. */ + setLabelOutlineOpacity(labelOutlineOpacity: number): boolean; + + /** Set the volume filtering mode. */ + setFilterMode(filterMode: FilterMode): boolean; + + /** Set filtering off. */ + setFilterModeToOff(): void; + + /** Set normalized filtering. */ + setFilterModeToNormalized(): void; + + /** Set raw filtering. */ + setFilterModeToRaw(): void; + + /** Set whether half-float storage is preferred over accuracy. */ + setPreferSizeOverAccuracy(preferSizeOverAccuracy: boolean): boolean; + /** * Set the color of a volume to an RGB transfer function * @param {Number} index @@ -382,12 +436,12 @@ export interface vtkVolumeProperty extends vtkObject { /** * */ - getAverageIPScalarRange(): Range; + getIpScalarRange(): Range; /** * */ - getAverageIPScalarRangeByReference(): Range; + getIpScalarRangeByReference(): Range; /** * Get the blending coefficient that interpolates between surface and volume rendering @@ -425,18 +479,31 @@ export interface vtkVolumeProperty extends vtkObject { */ getLAOKernelRadius(): number; + /** + * @deprecated use setIpScalarRange + * @param x + * @param y + */ + setAverageIPScalarRange(x: number, y: number): void; + /** * * @param x * @param y */ - setAverageIPScalarRange(x: number, y: number): boolean; + setIpScalarRange(x: number, y: number): boolean; + + /** + * + * @param {Range} ipScalarRange + */ + setIpScalarRange(ipScalarRange: Range): boolean; /** * - * @param {Range} averageIPScalarRange + * @param {Range} ipScalarRange */ - setAverageIPScalarRangeFrom(averageIPScalarRange: Range): boolean; + setIpScalarRangeFrom(ipScalarRange: Range): void; /** * Set the normal computation to be dependent on the transfer function. @@ -604,5 +671,7 @@ export declare const vtkVolumeProperty: { extend: typeof extend; InterpolationType: typeof InterpolationType; OpacityMode: typeof OpacityMode; + ColorMixPreset: typeof ColorMixPreset; + FilterMode: typeof FilterMode; }; export default vtkVolumeProperty; diff --git a/Sources/Rendering/Misc/CanvasView/index.d.ts b/Sources/Rendering/Misc/CanvasView/index.d.ts index 8694e605b57..404efd7faf9 100644 --- a/Sources/Rendering/Misc/CanvasView/index.d.ts +++ b/Sources/Rendering/Misc/CanvasView/index.d.ts @@ -1,5 +1,6 @@ import { vtkObject } from '../../../interfaces'; -import { Size } from '../../../types'; +import { Nullable, Size } from '../../../types'; +import vtkRenderWindowInteractor from '../../Core/RenderWindowInteractor'; /** * @@ -32,22 +33,22 @@ export interface vtkCanvasView extends vtkObject { /** * Get the interactor */ - getInteractor(): any; + getInteractor(): Nullable; /** * */ - getRenderable(): any; + getRenderable(): vtkCanvasView; /** * */ - getRenderers(): any[]; + getRenderers(): vtkCanvasView[]; /** * */ - getRenderersByReference(): any[]; + getRenderersByReference(): vtkCanvasView[]; /** * Get the size of the canvas view @@ -57,7 +58,7 @@ export interface vtkCanvasView extends vtkObject { /** * Get the size of the canvas view */ - getSizeByReference(): boolean; + getSizeByReference(): Size; /** * @@ -78,7 +79,7 @@ export interface vtkCanvasView extends vtkObject { * * @param {HTMLImageElement} backgroundImage The background image HTML element. */ - setBackgroundImage(backgroundImage: HTMLImageElement): boolean; + setBackgroundImage(backgroundImage: HTMLImageElement): void; /** * @@ -90,7 +91,7 @@ export interface vtkCanvasView extends vtkObject { * * @param {HTMLElement} container The container HTML element. */ - setContainer(container: HTMLElement): boolean; + setContainer(container: HTMLElement): void; /** * @@ -102,7 +103,7 @@ export interface vtkCanvasView extends vtkObject { * * @param interactor */ - setInteractor(interactor: any): boolean; + setInteractor(interactor: Nullable): boolean; /** * Set the size of the canvas view. @@ -121,7 +122,7 @@ export interface vtkCanvasView extends vtkObject { * Set the size of the canvas view. * @param {Size} size The size of the canvas view. */ - setSizeFrom(size: Size): boolean; + setSizeFrom(size: Size): void; /** * diff --git a/Sources/Rendering/Misc/FullScreenRenderWindow/index.d.ts b/Sources/Rendering/Misc/FullScreenRenderWindow/index.d.ts index 47c8310a3e3..7a8973db181 100644 --- a/Sources/Rendering/Misc/FullScreenRenderWindow/index.d.ts +++ b/Sources/Rendering/Misc/FullScreenRenderWindow/index.d.ts @@ -3,9 +3,7 @@ import { RGBAColor, RGBColor } from '../../../types'; import vtkRenderer from '../../Core/Renderer'; import vtkRenderWindow, { DEFAULT_VIEW_API } from '../../Core/RenderWindow'; import vtkRenderWindowInteractor from '../../Core/RenderWindowInteractor'; - -// import vtkOpenGLRenderWindow from "../../../OpenGL/RenderWindow"; -// import vtkWebGPURenderWindow from "../../../WebGPU/RenderWindow"; +import vtkRenderWindowViewNode from '../../SceneGraph/RenderWindowViewNode'; /** * @@ -44,7 +42,7 @@ export interface vtkFullScreenRenderWindow extends vtkObject { * vtkFullScreenRenderWindow has been created with "defaultViewAPI: 'WebGPU'", * otherwise vtkOpenGLRenderWindow is returned. */ - getApiSpecificRenderWindow(): any; // vtkOpenGLRenderWindow || vtkWebGPURenderWindow + getApiSpecificRenderWindow(): vtkRenderWindowViewNode; /** * Get container element @@ -54,7 +52,7 @@ export interface vtkFullScreenRenderWindow extends vtkObject { /** * Get control container element */ - getControlContainer(): HTMLElement; + getControlContainer(): HTMLElement | undefined; /** * Get interactor object diff --git a/Sources/Rendering/Misc/GenericRenderWindow/index.d.ts b/Sources/Rendering/Misc/GenericRenderWindow/index.d.ts index 1d1c8904f5b..6dd87faf941 100644 --- a/Sources/Rendering/Misc/GenericRenderWindow/index.d.ts +++ b/Sources/Rendering/Misc/GenericRenderWindow/index.d.ts @@ -1,5 +1,5 @@ import { vtkObject, vtkSubscription } from '../../../interfaces'; -import { RGBAColor, RGBColor } from '../../../types'; +import { Nullable, RGBAColor, RGBColor } from '../../../types'; import vtkRenderer from '../../Core/Renderer'; import vtkRenderWindow from '../../Core/RenderWindow'; import vtkRenderWindowInteractor from '../../Core/RenderWindowInteractor'; @@ -24,7 +24,7 @@ export interface vtkGenericRenderWindow extends vtkObject { /** * Get container element */ - getContainer(): HTMLElement; + getContainer(): Nullable; /** * Get interactor object diff --git a/Sources/Rendering/Misc/RemoteView/index.d.ts b/Sources/Rendering/Misc/RemoteView/index.d.ts index 106fef4cacf..bd8e8a3e008 100644 --- a/Sources/Rendering/Misc/RemoteView/index.d.ts +++ b/Sources/Rendering/Misc/RemoteView/index.d.ts @@ -1,7 +1,10 @@ import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; import vtkCanvasView from '../CanvasView'; import vtkImageStream from '../../../IO/Core/ImageStream'; import vtkViewStream from '../../../IO/Core/ImageStream/ViewStream'; +import vtkRenderWindowInteractor from '../../Core/RenderWindowInteractor'; +import vtkInteractorStyleRemoteMouse from '../../../Interaction/Style/InteractorStyleRemoteMouse'; interface IRemoteViewInitialValues { viewId?: string; @@ -20,12 +23,12 @@ export interface vtkRemoteView extends vtkObject { /** * Get container HTML element */ - getContainer(): HTMLElement; + getContainer(): HTMLElement | undefined; /** * Get vtkViewStream object */ - getViewStream(): vtkViewStream; + getViewStream(): vtkViewStream | undefined; /** * Get the canvas HTML element @@ -40,12 +43,12 @@ export interface vtkRemoteView extends vtkObject { /** * */ - getInteractor(): any; + getInteractor(): vtkRenderWindowInteractor; /** * */ - getInteractorStyle(): any; + getInteractorStyle(): vtkInteractorStyleRemoteMouse; /** * @@ -92,24 +95,24 @@ export interface vtkRemoteView extends vtkObject { /** * */ - getRpcGestureEvent(): any; + getRpcGestureEvent(): Nullable; /** * * @param rpcGestureEvent */ - setRpcGestureEvent(rpcGestureEvent: any): boolean; + setRpcGestureEvent(rpcGestureEvent: Nullable): boolean; /** * */ - getRpcWheelEvent(): any; + getRpcWheelEvent(): Nullable; /** * * @param rpcWheelEvent */ - setRpcWheelEvent(rpcWheelEvent: any): boolean; + setRpcWheelEvent(rpcWheelEvent: Nullable): boolean; /** * Release GL context @@ -120,7 +123,7 @@ export interface vtkRemoteView extends vtkObject { * * @param viewStream */ - setViewStream(viewStream: vtkViewStream): boolean; + setViewStream(viewStream: vtkViewStream): void; /** * @@ -132,7 +135,7 @@ export interface vtkRemoteView extends vtkObject { * * @param {HTMLElement} container The container HTML element. */ - setContainer(container: HTMLElement): boolean; + setContainer(container: HTMLElement): void; /** * Handle window resize @@ -195,7 +198,7 @@ export function newInstance( initialValues?: IRemoteViewInitialValues ): vtkRemoteView; -export function connectImageStream(session: any): void; +export function connectImageStream(session: any, protocol?: any): void; export function disconnectImageStream(): void; diff --git a/Sources/Rendering/Misc/RenderWindowWithControlBar/index.d.ts b/Sources/Rendering/Misc/RenderWindowWithControlBar/index.d.ts index 3b369c8dad3..e16b7b92501 100644 --- a/Sources/Rendering/Misc/RenderWindowWithControlBar/index.d.ts +++ b/Sources/Rendering/Misc/RenderWindowWithControlBar/index.d.ts @@ -1,4 +1,4 @@ -import { Placement } from '../../../types'; +import { Nullable, Placement } from '../../../types'; import vtkGenericRenderWindow, { IGenericRenderWindowInitialValues, } from '../GenericRenderWindow'; @@ -26,7 +26,7 @@ export interface vtkRenderWindowWithControlBar extends vtkGenericRenderWindow { /** * Get root container element */ - getRootContainer(): HTMLElement; + getRootContainer(): Nullable; /** * Set control container element diff --git a/Sources/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/index.d.ts b/Sources/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/index.d.ts new file mode 100644 index 00000000000..704780f8595 --- /dev/null +++ b/Sources/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/index.d.ts @@ -0,0 +1,29 @@ +import vtkSynchronizableRenderWindow, { + ISynchronizerContext, + IViewState, +} from '..'; + +/** + * Create, update and delete the behaviors described by `state.behaviors` for + * the given render window. Behaviors are stored per synchronized view id, so + * a behavior removed from the state is deleted on the next call. + * + * The only mapped behavior type is `CameraSync`, which keeps a destination + * renderer camera oriented like a source renderer camera. An additional + * `autoOrientation` flag synchronizes the cameras of a two renderer render + * window without any explicit configuration. + * + * @param {vtkSynchronizableRenderWindow} renderWindow + * @param {IViewState} state + * @param {ISynchronizerContext} context used to resolve renderer instance ids + */ +export function applyBehaviors( + renderWindow: vtkSynchronizableRenderWindow, + state: IViewState, + context: ISynchronizerContext +): void; + +declare const _default: { + applyBehaviors: typeof applyBehaviors; +}; +export default _default; diff --git a/Sources/Rendering/Misc/SynchronizableRenderWindow/ObjectManager/index.d.ts b/Sources/Rendering/Misc/SynchronizableRenderWindow/ObjectManager/index.d.ts index e4f64903a8d..fd268314e9b 100644 --- a/Sources/Rendering/Misc/SynchronizableRenderWindow/ObjectManager/index.d.ts +++ b/Sources/Rendering/Misc/SynchronizableRenderWindow/ObjectManager/index.d.ts @@ -31,6 +31,18 @@ export interface IObjectManager { context: ISynchronizerContext ): Promise; + /** + * Generic updater function which applies the state properties, dependencies, + * calls and arrays to the given instance. + */ + genericUpdater: UpdaterFunction; + + /** + * Updater function which applies the generic update process only once per + * state id. + */ + oneTimeGenericUpdater: UpdaterFunction; + /** * Defines a new type handler with the specified builder and updater functions * @@ -59,12 +71,17 @@ export interface IObjectManager { /** * Clear all one time updaters */ - clearOneTimeUpdaters(): void; + clearOneTimeUpdaters(ids: string[]): void; + clearOneTimeUpdaters(...ids: string[]): void; /** * Update the associated render window */ - updateRenderWindow(): void; + updateRenderWindow( + instance: vtkObject, + props: IViewState, + context: ISynchronizerContext + ): Promise; /** * Register a new type to exclude diff --git a/Sources/Rendering/Misc/SynchronizableRenderWindow/index.d.ts b/Sources/Rendering/Misc/SynchronizableRenderWindow/index.d.ts index 14fbada154c..5eba32f43f5 100644 --- a/Sources/Rendering/Misc/SynchronizableRenderWindow/index.d.ts +++ b/Sources/Rendering/Misc/SynchronizableRenderWindow/index.d.ts @@ -1,3 +1,4 @@ +import { vtkSubscription } from '../../../interfaces'; import { Nullable } from '../../../types'; import vtkRenderWindow, { IRenderWindowInitialValues, @@ -20,7 +21,7 @@ export interface ISynchronizerContext { // instanceMap getInstance(id: any): any; - getInstanceId(instance: any): any | null; + getInstanceId(instance: any): Nullable; registerInstance(id: any, instance: any): void; unregister(id: any): void; emptyCachedInstances(): void; @@ -31,7 +32,14 @@ export interface ISynchronizerContext { setActiveViewId(viewId: string): void; getActiveViewId(): string; - // TODO: fill progresshandler + // progressHandler + onProgressEvent( + cb: (readyCount: number) => void, + priority?: number + ): vtkSubscription; + invokeProgressEvent(readyCount: number): void; + onProgressDone(cb: () => void, priority?: number): vtkSubscription; + invokeProgressDone(): void; } export interface ISynchronizableRenderWindowInitialValues extends IRenderWindowInitialValues { @@ -65,6 +73,12 @@ export interface vtkSynchronizableRenderWindow extends vtkRenderWindow { */ getSynchronizerContext(): ISynchronizerContext; + /** + * Handle any pre render initializations, such as creating a camera for + * renderers which do not have one yet. + */ + preRender(): void; + // methods added by createSyncFunction /** @@ -82,7 +96,7 @@ export interface vtkSynchronizableRenderWindow extends vtkRenderWindow { /** * */ - getSynchronizedViewId(): string; + getSynchronizedViewId(): Nullable; /** * @@ -126,56 +140,63 @@ export function newInstance( * * @param {String} [name] */ -export function getSynchronizerContext(name?: string): ISynchronizerContext; +declare function getSynchronizerContext(name?: string): ISynchronizerContext; /** * * @param {String} name * @param {Nullable} ctx */ -export function setSynchronizerContext( +declare function setSynchronizerContext( name: string, ctx: Nullable -); +): void; /** * * @param name of the context to remove and if nothing provided clear them all. */ -export function clearSynchronizerContext(name: Nullable); +declare function clearSynchronizerContext(name: Nullable): void; /** * * @param {vtkRenderWindow} renderWindow * @param {String} [name] */ -export function decorate(renderWindow: vtkRenderWindow, name?: string): object; +declare function decorate(renderWindow: vtkRenderWindow, name?: string): object; /** * */ -export function createInstanceMap(): object; +declare function createInstanceMap(): object; /** * */ -export function createArrayHandler(): object; +declare function createArrayHandler(): object; /** * */ -export function createProgressHandler(): object; +declare function createProgressHandler(): object; /** * */ -export function createSceneMtimeHandler(): object; +declare function createSceneMtimeHandler(): object; /** * */ +export declare const DEFAULT_VALUES: Readonly<{ + synchronizerContextName: string; + synchronizerContext: Nullable; + synchronizedViewId: Nullable; +}>; + export declare const vtkSynchronizableRenderWindow: { newInstance: typeof newInstance; + extend: typeof extend; getSynchronizerContext: typeof getSynchronizerContext; setSynchronizerContext: typeof setSynchronizerContext; clearSynchronizerContext: typeof clearSynchronizerContext; diff --git a/Sources/Rendering/Misc/TextureLODsDownloader/index.d.ts b/Sources/Rendering/Misc/TextureLODsDownloader/index.d.ts index 150ec0d3c97..dcb7ba5556a 100644 --- a/Sources/Rendering/Misc/TextureLODsDownloader/index.d.ts +++ b/Sources/Rendering/Misc/TextureLODsDownloader/index.d.ts @@ -25,7 +25,7 @@ export interface vtkTextureLODsDownloader extends vtkObject { /** * Get the crossorigin attribute */ - getCrossOrigin(): Nullable; + getCrossOrigin(): CrossOrigin | undefined; /** * Get the list of files to download @@ -40,12 +40,12 @@ export interface vtkTextureLODsDownloader extends vtkObject { /** * */ - getStepFinishedCallback(): any; + getStepFinishedCallback(): Nullable<() => void>; /** * Get the vtkTexture object */ - getTexture(): vtkTexture; + getTexture(): Nullable; /** * Get the delay between downloads @@ -85,7 +85,7 @@ export interface vtkTextureLODsDownloader extends vtkObject { * * @param stepFinishedCallback */ - setStepFinishedCallback(stepFinishedCallback: any): boolean; + setStepFinishedCallback(stepFinishedCallback: Nullable<() => void>): boolean; /** * Set the vtkTexture object diff --git a/Sources/Rendering/OpenGL/Actor/index.d.ts b/Sources/Rendering/OpenGL/Actor/index.d.ts new file mode 100644 index 00000000000..46e5043a359 --- /dev/null +++ b/Sources/Rendering/OpenGL/Actor/index.d.ts @@ -0,0 +1,133 @@ +import { Nullable } from '../../../types'; +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; +import vtkOpenGLTexture from '../Texture'; + +/** + * The cached matrices recomputed whenever the renderable changes. + */ +export interface IOpenGLActorKeyMatrices { + normalMatrix: Float64Array; + mcwc: Float64Array; +} + +export interface IOpenGLActorInitialValues extends IViewNodeInitialValues { + context?: Nullable; + activeTextures?: Nullable; +} + +export interface vtkOpenGLActor extends vtkViewNode { + /** + * Builds myself: resolve the render window, renderer and context, then adopt + * the renderable's textures and mapper as children. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * Render both opaque and translucent actors. + * @param {vtkRenderPass} renderPass + */ + traverseZBufferPass(renderPass: vtkRenderPass): void; + + /** + * Render only opaque actors. + * @param {vtkRenderPass} renderPass + */ + traverseOpaqueZBufferPass(renderPass: vtkRenderPass): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseOpaquePass(renderPass: vtkRenderPass): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseTranslucentPass(renderPass: vtkRenderPass): void; + + /** + * Render every child texture and keep the ones that produced a handle. + */ + activateTextures(): void; + + /** + * @param prepass + * @param {vtkRenderPass} renderPass + */ + queryPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * @param prepass + * @param {vtkRenderPass} renderPass + */ + zBufferPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * @param prepass + * @param {vtkRenderPass} renderPass + */ + opaqueZBufferPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * @param prepass + * @param {vtkRenderPass} renderPass + */ + opaquePass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * Renders myself. + * @param prepass + * @param {vtkRenderPass} renderPass + */ + translucentPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * Recompute the model-to-world and normal matrices if the renderable moved. + */ + getKeyMatrices(): IOpenGLActorKeyMatrices; + + /** + * The textures activated by the last `activateTextures()` call. + */ + getActiveTextures(): Nullable; + + /** + */ + getContext(): Nullable; + + /** + * @param context + */ + setContext(context: Nullable): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLActor characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLActorInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLActorInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLActor. + * @param {IOpenGLActorInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLActorInitialValues +): vtkOpenGLActor; + +/** + * The OpenGL backend view node for a vtkActor. + */ +export declare const vtkOpenGLActor: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOpenGLActor; diff --git a/Sources/Rendering/OpenGL/Actor2D/index.d.ts b/Sources/Rendering/OpenGL/Actor2D/index.d.ts new file mode 100644 index 00000000000..e5654b7102d --- /dev/null +++ b/Sources/Rendering/OpenGL/Actor2D/index.d.ts @@ -0,0 +1,109 @@ +import { Nullable } from '../../../types'; +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; +import vtkOpenGLTexture from '../Texture'; + +export interface IOpenGLActor2DInitialValues extends IViewNodeInitialValues { + context?: Nullable; + activeTextures?: Nullable; +} + +export interface vtkOpenGLActor2D extends vtkViewNode { + /** + * Builds myself: resolve the render window, renderer and context, then adopt + * the renderable's textures and mapper as children. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * @param prepass + * @param {vtkRenderPass} renderPass + */ + queryPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseOpaquePass(renderPass: vtkRenderPass): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseTranslucentPass(renderPass: vtkRenderPass): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseOverlayPass(renderPass: vtkRenderPass): void; + + /** + * Render every child texture and keep the ones that produced a handle. + */ + activateTextures(): void; + + /** + * Renders myself. + * @param prepass + * @param {vtkRenderPass} renderPass + */ + opaquePass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * Renders myself. + * @param prepass + * @param {vtkRenderPass} renderPass + */ + translucentPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * Renders myself. + * @param prepass + * @param {vtkRenderPass} renderPass + */ + overlayPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * The textures activated by the last `activateTextures()` call. + */ + getActiveTextures(): Nullable; + + /** + */ + getContext(): Nullable; + + /** + * @param context + */ + setContext(context: Nullable): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLActor2D characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLActor2DInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLActor2DInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLActor2D. + * @param {IOpenGLActor2DInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLActor2DInitialValues +): vtkOpenGLActor2D; + +/** + * The OpenGL backend view node for a vtkActor2D. + */ +export declare const vtkOpenGLActor2D: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOpenGLActor2D; diff --git a/Sources/Rendering/OpenGL/BufferObject/Constants.d.ts b/Sources/Rendering/OpenGL/BufferObject/Constants.d.ts index a3c5f8adecd..735ddafbd61 100644 --- a/Sources/Rendering/OpenGL/BufferObject/Constants.d.ts +++ b/Sources/Rendering/OpenGL/BufferObject/Constants.d.ts @@ -1,8 +1,10 @@ -export declare enum ObjectType { - ARRAY_BUFFER = 0, - ELEMENT_ARRAY_BUFFER = 1, - TEXTURE_BUFFER = 2, -} +export declare const ObjectType: { + readonly ARRAY_BUFFER: 0; + readonly ELEMENT_ARRAY_BUFFER: 1; + readonly TEXTURE_BUFFER: 2; +}; + +export type ObjectType = (typeof ObjectType)[keyof typeof ObjectType]; declare const _default: { ObjectType: typeof ObjectType; diff --git a/Sources/Rendering/OpenGL/BufferObject/index.d.ts b/Sources/Rendering/OpenGL/BufferObject/index.d.ts index 24ee9c596b8..cea5e5f889e 100644 --- a/Sources/Rendering/OpenGL/BufferObject/index.d.ts +++ b/Sources/Rendering/OpenGL/BufferObject/index.d.ts @@ -1,5 +1,7 @@ import { ObjectType } from './Constants'; import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; +import vtkOpenGLRenderWindow from '../RenderWindow'; /** * Interface for initial values of BufferObject @@ -14,6 +16,37 @@ export interface IBufferObjectInitialValues { * Interface for OpenGL Buffer Object */ export interface vtkOpenGLBufferObject extends vtkObject { + /** + * Gets the type of the buffer object. + * @returns {Nullable} The type of the buffer object. + */ + getType(): Nullable; + + /** + * Sets the type of the buffer object. + * @param value The type to set. + */ + setType(value: ObjectType): void; + + /** + * Gets the WebGL handle of the buffer object. + * @returns The WebGL buffer handle. + */ + getHandle(): Nullable; + + /** + * Checks if the buffer object is ready, i.e. data has been uploaded. + * @returns {boolean} Whether the buffer object is ready. + */ + isReady(): boolean; + + /** + * Generates the underlying WebGL buffer if needed. + * @param type The type of the buffer object. + * @returns {boolean} Whether the generated buffer is compatible with the given type. + */ + generateBuffer(type: ObjectType): boolean; + /** * Uploads data to the buffer object. * @param data The data to be uploaded. @@ -43,7 +76,19 @@ export interface vtkOpenGLBufferObject extends vtkObject { * Sets the OpenGL render window. * @param renWin The render window to set. */ - setOpenGLRenderWindow(renWin: any): void; + setOpenGLRenderWindow(renWin: vtkOpenGLRenderWindow): void; + + /** + * Gets the OpenGL render window. + * @returns The render window. + */ + getOpenGLRenderWindow(): Nullable; + + /** + * Gets the amount of GPU memory allocated by the buffer object in bytes. + * @returns {number} The allocated GPU memory in bytes. + */ + getAllocatedGPUMemoryInBytes(): number; /** * Retrieves the error message, if any. @@ -79,5 +124,7 @@ export function newInstance( export declare const vtkOpenGLBufferObject: { newInstance: typeof newInstance; extend: typeof extend; + ObjectType: typeof ObjectType; }; +export declare const STATIC: Readonly>; export default vtkOpenGLBufferObject; diff --git a/Sources/Rendering/OpenGL/Camera/index.d.ts b/Sources/Rendering/OpenGL/Camera/index.d.ts new file mode 100644 index 00000000000..e1152bd1dc2 --- /dev/null +++ b/Sources/Rendering/OpenGL/Camera/index.d.ts @@ -0,0 +1,111 @@ +import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; +import vtkRenderer from '../../Core/Renderer'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; + +/** + * The cached camera matrices, recomputed whenever the camera, the renderer or + * the render window changes. + */ +export interface IOpenGLCameraKeyMatrices { + normalMatrix: Float64Array; + vcpc: Float64Array; + wcvc: Float64Array; + wcpc: Float64Array; +} + +export interface IOpenGLCameraInitialValues extends IViewNodeInitialValues { + keyMatrixTime?: vtkObject; + context?: Nullable; + lastRenderer?: Nullable; +} + +export interface vtkOpenGLCamera extends vtkViewNode { + /** + * Builds myself: resolve the renderer, render window and context. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * Renders myself: set the viewport and scissor box from the renderer's tile. + * @param prepass + */ + opaquePass(prepass: boolean): void; + + /** + * @param prepass + */ + translucentPass(prepass: boolean): void; + + /** + * @param prepass + */ + zBufferPass(prepass: boolean): void; + + /** + * @param prepass + */ + opaqueZBufferPass(prepass: boolean): void; + + /** + * @param prepass + */ + volumePass(prepass: boolean): void; + + /** + * Recompute the view/projection matrices if the camera, renderer or render + * window changed since the last call. + * @param {vtkRenderer} ren + */ + getKeyMatrices(ren: vtkRenderer): IOpenGLCameraKeyMatrices; + + /** + */ + getContext(): Nullable; + + /** + * @param context + */ + setContext(context: Nullable): boolean; + + /** + * The time stamp guarding the cached key matrices. + */ + getKeyMatrixTime(): vtkObject; + + /** + * @param keyMatrixTime + */ + setKeyMatrixTime(keyMatrixTime: vtkObject): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLCamera characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLCameraInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLCameraInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLCamera. + * @param {IOpenGLCameraInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLCameraInitialValues +): vtkOpenGLCamera; + +/** + * The OpenGL backend view node for a vtkCamera. + */ +export declare const vtkOpenGLCamera: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOpenGLCamera; diff --git a/Sources/Rendering/OpenGL/CellArrayBufferObject/index.d.ts b/Sources/Rendering/OpenGL/CellArrayBufferObject/index.d.ts new file mode 100644 index 00000000000..3e1996aa91c --- /dev/null +++ b/Sources/Rendering/OpenGL/CellArrayBufferObject/index.d.ts @@ -0,0 +1,330 @@ +import { + IBufferObjectInitialValues, + vtkOpenGLBufferObject, +} from '../BufferObject'; +import vtkCellArray from '../../../Common/Core/CellArray'; +import vtkDataArray from '../../../Common/Core/DataArray'; +import vtkPoints from '../../../Common/Core/Points'; +import { Representation } from '../../Core/Property/Constants'; +import { Nullable } from '../../../types'; + +/** + * The input primitive kind a cell array holds. + */ +export type CellArrayInputRepresentation = + | 'verts' + | 'lines' + | 'polys' + | 'strips'; + +/** + * One extra vertex attribute packed into the interleaved VBO. + */ +export interface ICustomAttributeInfo { + data: ArrayLike; + offset: number; + components: number; + name: string; +} + +/** + * The arrays and flags describing what to pack into the VBO. + */ +export interface ICreateVBOOptions { + points: vtkPoints; + normals?: Nullable; + tcoords?: Nullable; + colors?: Nullable; + customAttributes?: Nullable[]; + + /** + * Id of the first cell of this primitive across all the primitives of a + * mapper. + */ + cellOffset?: number; + + /** + * Id of the first vertex of this primitive across all the primitives of a + * mapper. + */ + vertexOffset?: number; + haveCellScalars?: boolean; + haveCellNormals?: boolean; + useTCoordsPerCell?: boolean; + + /** + * Force the flattened layout, in which every cell vertex is expanded. Needed + * for per cell attributes and for cell accurate hardware selection. + */ + forceFlatten?: boolean; +} + +/** + * Per vertex maps filled while packing a flattened VBO, used to recover the + * point and cell a rendered vertex came from. + */ +export interface ISelectionMaps { + points: Nullable; + cells: Nullable; +} + +/** + * Initial values for creating a new instance of vtkOpenGLCellArrayBufferObject. + */ +export interface ICellArrayBufferObjectInitialValues extends IBufferObjectInitialValues { + elementCount?: number; + indexed?: boolean; + indexBO?: Nullable; + indexElementType?: Nullable; + stride?: number; + colorBOStride?: number; + vertexOffset?: number; + normalOffset?: number; + tCoordOffset?: number; + tCoordComponents?: number; + colorOffset?: number; + colorComponents?: number; + customData?: ICustomAttributeInfo[]; + coordShift?: Nullable; + coordScale?: Nullable; + coordShiftAndScaleEnabled?: boolean; + inverseShiftAndScaleMatrix?: Nullable; +} + +export interface vtkOpenGLCellArrayBufferObject extends vtkOpenGLBufferObject { + /** + * Pack the given cells into an interleaved vertex buffer and upload it. + * + * When the options allow it the cells are uploaded indexed, sharing the input + * points; otherwise every cell vertex is expanded. + * + * @param cellArray The cells to pack. + * @param inRep The primitive kind the cell array holds. + * @param outRep The representation to draw the cells with. + * @param {ICreateVBOOptions} options The attributes to pack. + * @param {ISelectionMaps} [selectionMaps] (default: null) Filled with the point and cell id of every packed vertex. + * @returns {number} The number of cells packed. + */ + createVBO( + cellArray: vtkCellArray, + inRep: CellArrayInputRepresentation, + outRep: Representation, + options: ICreateVBOOptions, + selectionMaps?: Nullable + ): number; + + /** + * Set the shift and the scale applied to the points before packing them, and + * recompute the inverse matrix. Both must be a `Float64Array` of three + * values, or both null to disable shift and scale. + * + * @param coordShift The shift. + * @param coordScale The scale. + */ + setCoordShiftAndScale( + coordShift: Nullable, + coordScale: Nullable + ): void; + + /** + * Get the buffer holding the packed colors, when the colors are uploaded + * separately. + */ + getColorBO(): Nullable; + + /** + * Set the buffer holding the packed colors. + * @param colorBO The buffer. + */ + setColorBO(colorBO: Nullable): boolean; + + /** + * Get the number of vertices, or of indices when indexed, to draw. + */ + getElementCount(): number; + + /** + * Set the number of vertices to draw. + * @param elementCount The number of vertices. + */ + setElementCount(elementCount: number): boolean; + + /** + * Get the size in bytes of one interleaved vertex block. + */ + getStride(): number; + + /** + * Set the size in bytes of one interleaved vertex block. + * @param stride The block size in bytes. + */ + setStride(stride: number): boolean; + + /** + * Get the size in bytes of one block of the color buffer. + */ + getColorBOStride(): number; + + /** + * Set the size in bytes of one block of the color buffer. + * @param colorBOStride The block size in bytes. + */ + setColorBOStride(colorBOStride: number): boolean; + + /** + * Get the offset in bytes of the position inside a block. + */ + getVertexOffset(): number; + + /** + * Set the offset in bytes of the position inside a block. + * @param vertexOffset The offset in bytes. + */ + setVertexOffset(vertexOffset: number): boolean; + + /** + * Get the offset in bytes of the normal inside a block. + */ + getNormalOffset(): number; + + /** + * Set the offset in bytes of the normal inside a block. + * @param normalOffset The offset in bytes. + */ + setNormalOffset(normalOffset: number): boolean; + + /** + * Get the offset in bytes of the texture coordinate inside a block. + */ + getTCoordOffset(): number; + + /** + * Set the offset in bytes of the texture coordinate inside a block. + * @param tCoordOffset The offset in bytes. + */ + setTCoordOffset(tCoordOffset: number): boolean; + + /** + * Get the number of components of the texture coordinate. + */ + getTCoordComponents(): number; + + /** + * Set the number of components of the texture coordinate. + * @param tCoordComponents The number of components. + */ + setTCoordComponents(tCoordComponents: number): boolean; + + /** + * Get the offset in bytes of the color inside a color buffer block. + */ + getColorOffset(): number; + + /** + * Set the offset in bytes of the color inside a color buffer block. + * @param colorOffset The offset in bytes. + */ + setColorOffset(colorOffset: number): boolean; + + /** + * Get the number of components of the color. + */ + getColorComponents(): number; + + /** + * Set the number of components of the color. + * @param colorComponents The number of components. + */ + setColorComponents(colorComponents: number): boolean; + + /** + * Get the description of the extra attributes packed into the VBO. + */ + getCustomData(): ICustomAttributeInfo[]; + + /** + * Set the description of the extra attributes packed into the VBO. + * @param customData The attribute descriptions. + */ + setCustomData(customData: ICustomAttributeInfo[]): boolean; + + /** + * Whether the VBO shares its points and is drawn through an index buffer. + */ + getIndexed(): boolean; + + /** + * Set whether the VBO is drawn through an index buffer. + * @param indexed The indexed flag. + */ + setIndexed(indexed: boolean): boolean; + + /** + * Get the index buffer, when the VBO is indexed. + */ + getIndexBO(): Nullable; + + /** + * Set the index buffer. + * @param indexBO The index buffer. + */ + setIndexBO(indexBO: Nullable): boolean; + + /** + * Get the GL type of the indices, `UNSIGNED_SHORT` or `UNSIGNED_INT`. + */ + getIndexElementType(): Nullable; + + /** + * Set the GL type of the indices. + * @param indexElementType The GL type. + */ + setIndexElementType(indexElementType: Nullable): boolean; + + /** + * Get the shift applied to the points before packing them. + */ + getCoordShift(): Nullable; + + /** + * Get the scale applied to the points before packing them. + */ + getCoordScale(): Nullable; + + /** + * Whether the packed positions are shifted and scaled. + */ + getCoordShiftAndScaleEnabled(): boolean; + + /** + * Get the matrix undoing the shift and the scale, as 16 values. + */ + getInverseShiftAndScaleMatrix(): Nullable; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLCellArrayBufferObject characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ICellArrayBufferObjectInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ICellArrayBufferObjectInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLCellArrayBufferObject. + * @param {ICellArrayBufferObjectInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: ICellArrayBufferObjectInitialValues +): vtkOpenGLCellArrayBufferObject; + +export declare const vtkOpenGLCellArrayBufferObject: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOpenGLCellArrayBufferObject; diff --git a/Sources/Rendering/OpenGL/Convolution2DPass/index.d.ts b/Sources/Rendering/OpenGL/Convolution2DPass/index.d.ts new file mode 100644 index 00000000000..9ef70dbcbbd --- /dev/null +++ b/Sources/Rendering/OpenGL/Convolution2DPass/index.d.ts @@ -0,0 +1,124 @@ +import { Nullable, TypedArray } from '../../../types'; +import type { vtkFramebuffer } from '../Framebuffer'; +import { + IRenderPassInitialValues, + vtkRenderPass, +} from '../../SceneGraph/RenderPass'; + +/** + * + */ +export interface IConvolution2DPassInitialValues extends IRenderPassInitialValues { + framebuffer?: Nullable; + convolutionShader?: any; + + /** + * The convolution kernel, in row-major form. + * @default [0, 0, 0, 0, 1, 0, 0, 0, 0] + */ + kernel?: Nullable; + + /** + * @default 3 + */ + oldKernelDimension?: number; + + /** + * @default 3 + */ + kernelDimension?: number; +} + +export interface vtkConvolution2DPass extends vtkRenderPass { + /** + * Build the vertex buffer of the screen-aligned quad the convolved result is + * drawn to. + */ + buildVertexBuffer(): void; + + /** + * Sum the kernel components to get the weight the convolved color is divided + * by. A kernel that sums to zero or less weighs 1, leaving the result unscaled. + * + * @param {Number[]|TypedArray} kernel The convolution kernel. + */ + computeKernelWeight(kernel: number[] | TypedArray): number; + + /** + * Get the framebuffer the delegate passes render into, or `null` before the + * first traversal. + */ + getFramebuffer(): Nullable; + + /** + * Generate the fragment shader that convolves the delegate output with a + * kernel of the given dimension. The kernel is unrolled into the source, so + * a new dimension needs a new shader. + * + * @param {Number} kernelDimension The width and height of the square kernel. + */ + getFragmentShaderCode(kernelDimension: number): string; + + /** + * Get the convolution kernel, in row-major form. + * @default [0, 0, 0, 0, 1, 0, 0, 0, 0] + */ + getKernel(): Nullable; + + /** + * Get the width and height of the square convolution kernel. + * @default 3 + */ + getKernelDimension(): number; + + /** + * Set the convolution kernel. It has to be a flat, row-major array of + * `kernelDimension * kernelDimension` components. Setting it to `null` makes + * the next traversal rebuild the identity kernel, which leaves the delegate + * output untouched. + * + * @param {Number[]|TypedArray} kernel The convolution kernel. + */ + setKernel(kernel: Nullable): boolean; + + /** + * Set the width and height of the square convolution kernel. It has to be + * odd, so that the kernel has a center. + * + * @param {Number} kernelDimension The kernel dimension. + */ + setKernelDimension(kernelDimension: number): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkConvolution2DPass characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IConvolution2DPassInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IConvolution2DPassInitialValues +): void; + +/** + * Method used to create a new instance of vtkConvolution2DPass. + * @param {IConvolution2DPassInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IConvolution2DPassInitialValues +): vtkConvolution2DPass; + +/** + * vtkConvolution2DPass is a render pass that post-processes the output of its + * delegate passes with a 2D convolution kernel, for effects such as sharpening + * or blurring. The delegates render into an offscreen framebuffer, which is + * then convolved onto a screen-aligned quad. + */ +declare const vtkConvolution2DPass: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkConvolution2DPass; diff --git a/Sources/Rendering/OpenGL/CubeAxesActor/index.d.ts b/Sources/Rendering/OpenGL/CubeAxesActor/index.d.ts new file mode 100644 index 00000000000..b007f67aad8 --- /dev/null +++ b/Sources/Rendering/OpenGL/CubeAxesActor/index.d.ts @@ -0,0 +1,51 @@ +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; + +export interface IOpenGLCubeAxesActorInitialValues extends IViewNodeInitialValues {} + +export interface vtkOpenGLCubeAxesActor extends vtkViewNode { + /** + * Builds myself: bind the cube axes helper to the renderable and adopt the + * text actor and the renderable's grid actor as children. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * Renders myself: hand the viewport size, the active camera and the render + * window to the cube axes helper. + * @param prepass + * @param {vtkRenderPass} renderPass + */ + opaquePass(prepass: boolean, renderPass: vtkRenderPass): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLCubeAxesActor characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLCubeAxesActorInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLCubeAxesActorInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLCubeAxesActor. + * @param {IOpenGLCubeAxesActorInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLCubeAxesActorInitialValues +): vtkOpenGLCubeAxesActor; + +/** + * The OpenGL backend view node for a vtkCubeAxesActor. + */ +export declare const vtkOpenGLCubeAxesActor: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOpenGLCubeAxesActor; diff --git a/Sources/Rendering/OpenGL/CutterMapper/index.d.ts b/Sources/Rendering/OpenGL/CutterMapper/index.d.ts new file mode 100644 index 00000000000..41c8d2ed448 --- /dev/null +++ b/Sources/Rendering/OpenGL/CutterMapper/index.d.ts @@ -0,0 +1,50 @@ +import { Nullable, Vector3 } from '../../../types'; +import { + IOpenGLPolyDataMapperInitialValues, + vtkOpenGLPolyDataMapper, +} from '../PolyDataMapper'; + +/** + * Initial values for creating a new instance of vtkOpenGLCutterMapper. + */ +export interface IOpenGLCutterMapperInitialValues extends IOpenGLPolyDataMapperInitialValues { + tmpVec3A?: Nullable; + tmpVec3B?: Nullable; +} + +/** + * The cutter mapper adds the cut plane clipping to the shaders of + * vtkOpenGLPolyDataMapper. The public surface is unchanged. + */ +export interface vtkOpenGLCutterMapper extends vtkOpenGLPolyDataMapper {} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLCutterMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLCutterMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLCutterMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLCutterMapper. + * @param {IOpenGLCutterMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLCutterMapperInitialValues +): vtkOpenGLCutterMapper; + +/** + * The OpenGL backend view node for vtkCutterMapper. + */ +export declare const vtkOpenGLCutterMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkOpenGLCutterMapper; diff --git a/Sources/Rendering/OpenGL/ForwardPass/index.d.ts b/Sources/Rendering/OpenGL/ForwardPass/index.d.ts new file mode 100644 index 00000000000..26fdd340f12 --- /dev/null +++ b/Sources/Rendering/OpenGL/ForwardPass/index.d.ts @@ -0,0 +1,111 @@ +import { Nullable } from '../../../types'; +import type { vtkFramebuffer } from '../Framebuffer'; +import vtkOpenGLTexture from '../Texture'; +import { + IRenderPassInitialValues, + vtkRenderPass, +} from '../../SceneGraph/RenderPass'; + +/** + * + */ +export interface IForwardPassInitialValues extends IRenderPassInitialValues { + opaqueActorCount?: number; + translucentActorCount?: number; + volumeCount?: number; + overlayActorCount?: number; + framebuffer?: Nullable; + depthRequested?: boolean; +} + +export interface vtkForwardPass extends vtkRenderPass { + /** + * Get the framebuffer the depth capture renders into, or `null` when no + * depth capture has been needed yet. + */ + getFramebuffer(): Nullable; + + /** + * Get the number of opaque actors seen by the last query pass. + */ + getOpaqueActorCount(): number; + + /** + * Get the number of translucent actors seen by the last query pass. + */ + getTranslucentActorCount(): number; + + /** + * Get the number of volumes seen by the last query pass. + */ + getVolumeCount(): number; + + /** + * Get the color texture holding the captured z-buffer, or `null`/`undefined` + * when no depth capture has been needed yet. + */ + getZBufferTexture(): Nullable | undefined; + + /** + * Ask for a z-buffer capture on the next traversal, whether or not the + * scene mixes geometry and volumes. + */ + requestDepth(): void; + + /** + * Count one opaque actor for the current query pass, and return the count + * before the increment. + */ + incrementOpaqueActorCount(): number; + + /** + * Count one translucent actor for the current query pass, and return the + * count before the increment. + */ + incrementTranslucentActorCount(): number; + + /** + * Count one volume for the current query pass, and return the count before + * the increment. + */ + incrementVolumeCount(): number; + + /** + * Count one overlay actor for the current query pass, and return the count + * before the increment. + */ + incrementOverlayActorCount(): number; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkForwardPass characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IForwardPassInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IForwardPassInitialValues +): void; + +/** + * Method used to create a new instance of vtkForwardPass. + * @param {IForwardPassInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IForwardPassInitialValues +): vtkForwardPass; + +/** + * vtkForwardPass implements a forward rendering pipeline. When a renderer holds + * both geometry and volumes, it first captures a z-buffer so the two can be + * mixed, then renders the opaque, translucent, volume and overlay actors of + * every renderer, layer by layer. + */ +declare const vtkForwardPass: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkForwardPass; diff --git a/Sources/Rendering/OpenGL/Framebuffer/index.d.ts b/Sources/Rendering/OpenGL/Framebuffer/index.d.ts new file mode 100644 index 00000000000..1152ff72477 --- /dev/null +++ b/Sources/Rendering/OpenGL/Framebuffer/index.d.ts @@ -0,0 +1,210 @@ +import { vtkObject } from '../../../interfaces'; +import { Nullable, Size } from '../../../types'; +import vtkOpenGLRenderWindow from '../RenderWindow'; +import vtkOpenGLTexture from '../Texture'; + +/** + * The framebuffer object created by `create()`, which carries the dimensions + * it was created with so that `getSize()` can read them back. + */ +export type SizedWebGLFramebuffer = WebGLFramebuffer & { + width: number; + height: number; +}; + +/** + * Initial values for creating a new instance of vtkFramebuffer. + * + * Note that `colorBuffers` cannot be set here: `extend` rejects it with an + * error and resets it to an empty array. Use `setColorBuffer()` instead. + */ +export interface IFramebufferInitialValues { + glFramebuffer?: Nullable; + depthTexture?: Nullable; + previousDrawBinding?: number; + previousReadBinding?: number; + previousDrawBuffer?: number; + previousReadBuffer?: number; + previousActiveFramebuffer?: Nullable; +} + +export interface vtkFramebuffer extends vtkObject { + /** + * Bind this framebuffer, and every color buffer attached to it, and make it + * the render window's active framebuffer. + * + * @param {Number} [modeArg] The bind target (default: `gl.FRAMEBUFFER`). + */ + bind(modeArg?: Nullable): void; + + /** + * Create the underlying WebGL framebuffer at the given size. Does nothing + * until the OpenGL render window has been set. + * + * @param {Number} width + * @param {Number} height + */ + create(width: number, height: number): void; + + /** + * Get the bind target that covers both reading and drawing, `gl.FRAMEBUFFER`. + */ + getBothMode(): number; + + /** + * Get a copy of the textures attached as color buffers, indexed by attachment. + */ + getColorBuffers(): (Nullable | undefined)[]; + + /** + * Get the textures attached as color buffers, indexed by attachment, without + * copying the array. + */ + getColorBuffersByReference(): (Nullable | undefined)[]; + + /** + * Get the texture attached as the first color buffer, if one is attached. + * + * @deprecated Use `getColorBuffers()[0]` instead. + */ + getColorTexture(): Nullable | undefined; + + /** + * Get the underlying WebGL framebuffer, or `null` before `create()`. + */ + getGLFramebuffer(): Nullable; + + /** + * Get the width and height the framebuffer was created with, or `null` + * before `create()`. + */ + getSize(): Nullable; + + /** + * Attach a color texture and a depth renderbuffer sized to the framebuffer, + * binding it first. Does nothing until the OpenGL render window has been set. + */ + populateFramebuffer(): void; + + /** + * Delete the underlying WebGL framebuffer, if one was created. + */ + releaseGraphicsResources(): void; + + /** + * Detach the texture bound to the given color attachment. + * + * @param {Number} [attachment] The color attachment index (default: 0). + */ + removeColorBuffer(attachment?: number): void; + + /** + * Detach the texture bound to the depth attachment. + */ + removeDepthBuffer(): void; + + /** + * Restore the bindings and the buffers saved by + * `saveCurrentBindingsAndBuffers`. + * + * @param {Number} [modeIn] The bind target (default: `gl.FRAMEBUFFER`). + */ + restorePreviousBindingsAndBuffers(modeIn?: number): void; + + /** + * Rebind the framebuffer that was bound when `saveCurrentBindings` ran, and + * restore it as the render window's active framebuffer. Does nothing until + * the OpenGL render window has been set. + * + * @param {Number} [modeIn] The bind target. + */ + restorePreviousBindings(modeIn?: number): void; + + /** + * A no-op on WebGL, where draw and read buffers are not saved. + * + * @param {Number} [modeIn] The bind target. + */ + restorePreviousBuffers(modeIn?: number): void; + + /** + * Remember the currently bound framebuffer and the render window's active + * framebuffer, along with the draw and read buffers, so that + * `restorePreviousBindingsAndBuffers` can put them back. + * + * @param {Number} [modeIn] The bind target (default: `gl.FRAMEBUFFER`). + */ + saveCurrentBindingsAndBuffers(modeIn?: number): void; + + /** + * Remember the currently bound framebuffer and the render window's active + * framebuffer. Does nothing until the OpenGL render window has been set. + * + * @param {Number} [modeIn] The bind target. + */ + saveCurrentBindings(modeIn?: number): void; + + /** + * A no-op on WebGL, where draw and read buffers cannot be queried. + * + * @param {Number} [modeIn] The bind target. + */ + saveCurrentBuffers(modeIn?: number): void; + + /** + * Attach a texture to the given color attachment. Does nothing until the + * OpenGL render window has been set. + * + * @param {vtkOpenGLTexture} texture The texture to attach. + * @param {Number} [attachment] The color attachment index (default: 0). + */ + setColorBuffer(texture: vtkOpenGLTexture, attachment?: number): void; + + /** + * Attach a texture to the depth attachment. Does nothing until the OpenGL + * render window has been set. + * + * @param {vtkOpenGLTexture} texture The texture to attach. + */ + setDepthBuffer(texture: vtkOpenGLTexture): void; + + /** + * Set the OpenGL render window this framebuffer belongs to, and take its + * WebGL context. Changing it releases the graphics resources held for the + * previous one. + * + * @param {vtkOpenGLRenderWindow} rw The OpenGL render window. + */ + setOpenGLRenderWindow(rw: Nullable): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkFramebuffer characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IFramebufferInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IFramebufferInitialValues +): void; + +/** + * Method used to create a new instance of vtkFramebuffer. + * @param {IFramebufferInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IFramebufferInitialValues +): vtkFramebuffer; + +/** + * vtkFramebuffer wraps a WebGL framebuffer object, so that a render pass can + * redirect its output to offscreen textures and then read them back. + */ +declare const vtkFramebuffer: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkFramebuffer; diff --git a/Sources/Rendering/OpenGL/Glyph3DMapper/index.d.ts b/Sources/Rendering/OpenGL/Glyph3DMapper/index.d.ts new file mode 100644 index 00000000000..d0886f11799 --- /dev/null +++ b/Sources/Rendering/OpenGL/Glyph3DMapper/index.d.ts @@ -0,0 +1,47 @@ +import { + IOpenGLPolyDataMapperInitialValues, + vtkOpenGLPolyDataMapper, +} from '../PolyDataMapper'; + +/** + * Initial values for creating a new instance of vtkOpenGLGlyph3DMapper. + */ +export interface IOpenGLGlyph3DMapperInitialValues extends IOpenGLPolyDataMapperInitialValues {} + +/** + * The glyph mapper renders the source polydata once per glyph point, so it + * replaces the buffer object and shader hooks of vtkOpenGLPolyDataMapper with + * instanced equivalents. The public surface is unchanged. + */ +export interface vtkOpenGLGlyph3DMapper extends vtkOpenGLPolyDataMapper {} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLGlyph3DMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLGlyph3DMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLGlyph3DMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLGlyph3DMapper. + * @param {IOpenGLGlyph3DMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLGlyph3DMapperInitialValues +): vtkOpenGLGlyph3DMapper; + +/** + * The OpenGL backend view node for vtkGlyph3DMapper. + */ +export declare const vtkOpenGLGlyph3DMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkOpenGLGlyph3DMapper; diff --git a/Sources/Rendering/OpenGL/HardwareSelector/Constants.d.ts b/Sources/Rendering/OpenGL/HardwareSelector/Constants.d.ts index a711b3885cf..082a65cf78e 100644 --- a/Sources/Rendering/OpenGL/HardwareSelector/Constants.d.ts +++ b/Sources/Rendering/OpenGL/HardwareSelector/Constants.d.ts @@ -1,8 +1,15 @@ -export declare enum PassTypes { - MIN_KNOWN_PASS = 0, - ACTOR_PASS = 0, - COMPOSITE_INDEX_PASS = 1, - ID_LOW24 = 2, - ID_HIGH24 = 3, - MAX_KNOWN_PASS = 3, -} +export declare const PassTypes: { + readonly MIN_KNOWN_PASS: 0; + readonly ACTOR_PASS: 0; + readonly COMPOSITE_INDEX_PASS: 1; + readonly ID_LOW24: 2; + readonly ID_HIGH24: 3; + readonly MAX_KNOWN_PASS: 3; +}; + +export type PassTypes = (typeof PassTypes)[keyof typeof PassTypes]; + +declare const _default: { + PassTypes: typeof PassTypes; +}; +export default _default; diff --git a/Sources/Rendering/OpenGL/HardwareSelector/index.d.ts b/Sources/Rendering/OpenGL/HardwareSelector/index.d.ts index 8d64ece42e8..3f53e0e598a 100644 --- a/Sources/Rendering/OpenGL/HardwareSelector/index.d.ts +++ b/Sources/Rendering/OpenGL/HardwareSelector/index.d.ts @@ -28,7 +28,6 @@ export interface SourceData { renderer: vtkRenderer; openGLRenderWindow: vtkOpenGLRenderWindow; generateSelection( - buffdata: BufferData, fx1: number, fy1: number, fx2: number, @@ -41,8 +40,8 @@ export interface PixelInformation { prop: vtkProp; propID: number; compositeID: number; - zValue: number; - displayPosition: Vector2; + zValue?: number; + displayPosition?: Vector2; attributeID?: number; } @@ -102,7 +101,7 @@ export interface vtkOpenGLHardwareSelector extends vtkHardwareSelector { fy1: number, fx2: number, fy2: number - ): Promise; + ): Promise; /** * Captures the scene for picking. @@ -228,7 +227,7 @@ export interface vtkOpenGLHardwareSelector extends vtkHardwareSelector { /** * Gets the current renderer. */ - getRenderer(): vtkRenderer; + getRenderer(): vtkRenderer | undefined; /** * Sets the current pass type. @@ -247,7 +246,7 @@ export interface vtkOpenGLHardwareSelector extends vtkHardwareSelector { */ setOpenGLRenderWindow(oglrw: vtkOpenGLRenderWindow): boolean; - getOpenGLRenderWindow(): vtkOpenGLRenderWindow; + getOpenGLRenderWindow(): vtkOpenGLRenderWindow | undefined; /** * Sets the maximum point ID. @@ -285,11 +284,22 @@ export interface vtkOpenGLHardwareSelector extends vtkHardwareSelector { */ setPropColorValue(r: number, g: number, b: number): boolean; + /** + * Sets the prop's color value from an array. + * @param color An array of the prop's color value. + */ + setPropColorValueFrom(color: Vector3): void; + /** * Gets the prop color value. */ getPropColorValue(): Vector3; + /** + * Gets the prop color value by reference. + */ + getPropColorValueByReference(): Vector3; + /** * Sets the selection area. * @@ -306,20 +316,40 @@ export interface vtkOpenGLHardwareSelector extends vtkHardwareSelector { */ setArea(fx1: number, fy1: number, fx2: number, fy2: number): boolean; + /** + * Sets the selection area from an array. + * @param area An area bounding box + */ + setAreaFrom(area: Area): void; + /** * Gets the selection area. */ getArea(): Area; + /** + * Gets the selection area by reference. + */ + getAreaByReference(): Area; + /** * Listen to the start/stop events. * @param cb * @param priority */ onEvent(cb: EventHandler, priority?: number): Readonly; + + /** + * Invoke the start/stop events. + * @param args + */ + invokeEvent(...args: unknown[]): void; } export interface IOpenGLHardwareSelectorInitialValues extends IHardwareSelectorInitialValues { + area?: Area; + currentPass?: PassTypes; + propColorValue?: Vector3; maximumPointId?: number; maximumCellId?: number; idOffset?: number; @@ -355,6 +385,7 @@ export function extend( export const vtkOpenGLHardwareSelector: { newInstance: typeof newInstance; extend: typeof extend; + PassTypes: typeof PassTypes; }; export default vtkOpenGLHardwareSelector; diff --git a/Sources/Rendering/OpenGL/Helper/index.d.ts b/Sources/Rendering/OpenGL/Helper/index.d.ts new file mode 100644 index 00000000000..2046c311234 --- /dev/null +++ b/Sources/Rendering/OpenGL/Helper/index.d.ts @@ -0,0 +1,274 @@ +import vtkOpenGLCellArrayBufferObject from '../CellArrayBufferObject'; +import vtkOpenGLRenderWindow from '../RenderWindow'; +import vtkOpenGLTexture from '../Texture'; +import { ITiledSizeAndOrigin } from '../Renderer'; +import vtkOpenGLVertexArrayObject from '../VertexArrayObject'; +import vtkShaderProgram from '../ShaderProgram'; +import vtkActor from '../../Core/Actor'; +import vtkRenderer from '../../Core/Renderer'; +import { Representation } from '../../Core/Property/Constants'; +import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; + +/** + * The primitive a helper draws, and the bounds used to loop over them. + */ +export declare const primTypes: { + Start: number; + Points: number; + Lines: number; + Tris: number; + TriStrips: number; + TrisEdges: number; + TriStripsEdges: number; + End: number; +}; + +/** + * The GLSL sources a mapper assembles before compiling them into a program. + */ +export interface IShaderSources { + Vertex: string; + Fragment: string; + Geometry: string; +} + +/** + * Initial values for creating a new instance of vtkOpenGLHelper. + */ +export interface IOpenGLHelperInitialValues { + context?: Nullable; + program?: Nullable; + shaderSourceTime?: vtkObject; + VAO?: Nullable; + attributeUpdateTime?: vtkObject; + CABO?: Nullable; + primitiveType?: number; + pointPicking?: boolean; +} + +export interface vtkOpenGLHelper extends vtkObject { + /** + * Attach this helper, its vertex array object and its buffers to an OpenGL + * render window. + * + * @param win The OpenGL render window. + */ + setOpenGLRenderWindow(win: vtkOpenGLRenderWindow): void; + + /** + * Release the vertex array object and the buffers. + */ + releaseGraphicsResources(oglwin?: vtkOpenGLRenderWindow): void; + + /** + * Update the shaders, bind the vertex array object and issue the draw call. + * + * @param {vtkRenderer} ren The renderer being drawn. + * @param {vtkActor} actor The actor being drawn. + * @param rep The representation to draw with. + * @param oglMapper The OpenGL mapper driving this helper. + * @returns {number} The number of primitives drawn. + */ + drawArrays( + ren: vtkRenderer, + actor: vtkActor, + rep: Representation, + oglMapper: any + ): number; + + /** + * Get the GL draw mode for this helper's primitive, `POINTS` while point + * picking. + * + * @param rep The representation to draw with. + */ + getOpenGLMode(rep: Representation): number; + + /** + * Whether the lines must be emulated with instanced quads because the + * hardware does not support the requested line width. + * + * @param {vtkRenderer} ren The renderer being drawn. + * @param {vtkActor} actor The actor being drawn. + */ + haveWideLines(ren: vtkRenderer, actor: vtkActor): boolean; + + /** + * Whether the shader program must be rebuilt before the next draw. + * + * @param {vtkRenderer} ren The renderer being drawn. + * @param {vtkActor} actor The actor being drawn. + * @param oglMapper The OpenGL mapper driving this helper. + */ + getNeedToRebuildShaders( + ren: vtkRenderer, + actor: vtkActor, + oglMapper: any + ): boolean; + + /** + * Rebuild the program if needed, bind it and let the mapper set its uniforms. + * + * @param {vtkRenderer} ren The renderer being drawn. + * @param {vtkActor} actor The actor being drawn. + * @param oglMapper The OpenGL mapper driving this helper. + */ + updateShaders(ren: vtkRenderer, actor: vtkActor, oglMapper: any): void; + + /** + * Set the wide line and point size uniforms. + * + * @param {vtkRenderer} ren The renderer being drawn. + * @param {vtkActor} actor The actor being drawn. + * @param {ITiledSizeAndOrigin} size The pixel extent of the viewport. + */ + setMapperShaderParameters( + ren: vtkRenderer, + actor: vtkActor, + size: ITiledSizeAndOrigin + ): void; + + /** + * Add the point size and, for wide lines, the line widening code to the + * vertex shader. + * + * @param {IShaderSources} shaders The shader sources to substitute into. + * @param {vtkRenderer} ren The renderer being drawn. + * @param {vtkActor} actor The actor being drawn. + */ + replaceShaderPositionVC( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor + ): void; + + /** + * Get the point size in pixels used to make this helper's primitive pickable. + */ + getPointPickingPrimitiveSize(): number; + + /** + * Get the amount of GPU memory this helper's buffers hold, in bytes. + */ + getAllocatedGPUMemoryInBytes(): number; + + /** + * Get the shader program this helper draws with. + */ + getProgram(): Nullable; + + /** + * Set the shader program this helper draws with. + * @param program The shader program. + */ + setProgram(program: Nullable): boolean; + + /** + * Get the time object tracking when the shader sources were last rebuilt. + */ + getShaderSourceTime(): vtkObject; + + /** + * Set the time object tracking when the shader sources were last rebuilt. + * @param shaderSourceTime The time object. + */ + setShaderSourceTime(shaderSourceTime: vtkObject): boolean; + + /** + * Get the vertex array object. + */ + getVAO(): vtkOpenGLVertexArrayObject; + + /** + * Set the vertex array object. + * @param VAO The vertex array object. + */ + setVAO(VAO: vtkOpenGLVertexArrayObject): boolean; + + /** + * Get the time object tracking when the attributes were last bound. + */ + getAttributeUpdateTime(): vtkObject; + + /** + * Set the time object tracking when the attributes were last bound. + * @param attributeUpdateTime The time object. + */ + setAttributeUpdateTime(attributeUpdateTime: vtkObject): boolean; + + /** + * Get the cell array buffer object holding the packed vertices. + */ + getCABO(): vtkOpenGLCellArrayBufferObject; + + /** + * Set the cell array buffer object holding the packed vertices. + * @param CABO The cell array buffer object. + */ + setCABO(CABO: vtkOpenGLCellArrayBufferObject): boolean; + + /** + * Get which of the `primTypes` this helper draws. + */ + getPrimitiveType(): number; + + /** + * Set which of the `primTypes` this helper draws. + * @param primitiveType The primitive type. + */ + setPrimitiveType(primitiveType: number): boolean; + + /** + * Whether the helper draws points for hardware point picking. + */ + getPointPicking(): boolean; + + /** + * Set whether the helper draws points for hardware point picking. + * @param pointPicking The point picking flag. + */ + setPointPicking(pointPicking: boolean): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLHelper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLHelperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLHelperInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLHelper. + * @param {IOpenGLHelperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLHelperInitialValues +): vtkOpenGLHelper; + +export type PolyDataMapperResourceModel = { + primitives: vtkOpenGLHelper[]; + internalColorTexture?: Nullable; + _openGLRenderWindow?: Nullable; + VBOBuildString?: Nullable; +}; + +/** Release the shared resources of a polydata mapper and invalidate its buffers. */ +export function releasePolyDataMapperResources( + publicAPI: vtkObject, + model: PolyDataMapperResourceModel, + renderWindow?: vtkOpenGLRenderWindow +): void; + +export declare const vtkOpenGLHelper: { + newInstance: typeof newInstance; + extend: typeof extend; + primTypes: typeof primTypes; +}; +export default vtkOpenGLHelper; diff --git a/Sources/Rendering/OpenGL/ImageCPRMapper/index.d.ts b/Sources/Rendering/OpenGL/ImageCPRMapper/index.d.ts new file mode 100644 index 00000000000..06356d6c8f4 --- /dev/null +++ b/Sources/Rendering/OpenGL/ImageCPRMapper/index.d.ts @@ -0,0 +1,316 @@ +import { vtkAlgorithm } from '../../../interfaces'; +import { Nullable } from '../../../types'; +import { ICoincidentTopology } from '../../Core/Mapper/CoincidentTopologyHelper'; +import { vtkImageSlice } from '../../Core/ImageSlice'; +import { vtkRenderer } from '../../Core/Renderer'; +import vtkOpenGLTexture from '../Texture'; +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; + +/** + * The vertex, fragment and geometry sources a mapper assembles before the + * shader program is compiled. + */ +export interface IShaderSources { + Vertex: string; + Fragment: string; + Geometry: string; +} + +/** + * + */ +export interface IOpenGLImageCPRMapperInitialValues extends IViewNodeInitialValues { + currentRenderPass?: Nullable; + volumeTexture?: Nullable; + colorTexture?: Nullable; + pwfTexture?: Nullable; + tris?: any; + lastHaveSeenDepthRequest?: boolean; + haveSeenDepthRequest?: boolean; + lastTextureComponents?: number; + lastIndependentComponents?: number; + imagemat?: Nullable; + imagematinv?: Nullable; +} + +/** + * The mapper has two input ports and no output port, so the pipeline half of + * `vtkAlgorithm` that reads an output is not installed. + */ +type vtkOpenGLImageCPRMapperBase = vtkViewNode & + Omit; + +export interface vtkOpenGLImageCPRMapper extends vtkOpenGLImageCPRMapperBase { + /** + * Build the volume, color and opacity textures, and the vertex buffer of the + * quads the straightened image is drawn on. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + buildBufferObjects(ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Resolve the ancestors this mapper renders with: its image slice, its + * renderer, its render window and the camera view node. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + buildPass(prepass: boolean): void; + + /** + * Fill in the shader template and run the mapper's own substitutions. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + buildShaders( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Get the polygon offset the renderable asks for, or `null` when it does not + * resolve coincident topology with a polygon offset. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + getCoincidentParameters( + ren: vtkRenderer, + actor: vtkImageSlice + ): Nullable; + + /** + * Whether the textures and the vertex buffer are out of date. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + getNeedToRebuildBufferObjects( + ren: vtkRenderer, + actor: vtkImageSlice + ): boolean; + + /** + * Whether the shader program has to be rebuilt for the given helper. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + getNeedToRebuildShaders( + cellBO: any, + ren: vtkRenderer, + actor: vtkImageSlice + ): boolean; + + /** + * Fill in the shader sources with the default polydata shader template. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + getShaderTemplate( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Render the straightened image during the opaque pass, remembering the + * render pass so that its shader replacement is applied. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + * @param {vtkRenderPass} renderPass The render pass being traversed. + */ + opaquePass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * Capture the depth of the straightened image during the opaque z-buffer + * pass. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + opaqueZBufferPass(prepass: boolean): void; + + /** + * Render the straightened image. + */ + render(): void; + + /** + * Update the renderable, then render the straightened image for the given + * renderer and prop. Does nothing when the renderable's pre-render check + * fails. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} prop The image slice being rendered. + */ + renderPiece(ren: vtkRenderer, prop: vtkImageSlice): void; + + /** + * Activate the textures, update the shaders and draw the quads. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + renderPieceDraw(ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Hook run after the straightened image has been drawn. It does nothing. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + renderPieceFinish(ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Bring the buffer objects up to date before the quads are drawn. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + renderPieceStart(ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Substitute the clipping plane declarations and implementation into the + * shader sources. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + replaceShaderClip( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Substitute the depth offset the renderable's coincident topology + * resolution asks for into the fragment shader. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + replaceShaderCoincidentOffset( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Substitute the mapper's own declarations and implementation into the + * shader sources. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + replaceShaderValues( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Set the camera uniforms of the shader program. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + setCameraShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Set the texture and geometry uniforms of the shader program. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + setMapperShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Set the image property uniforms of the shader program. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + setPropertyShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Rebuild the buffer objects when they are out of date, then set the texture + * filters from the interpolation type of the actor property. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + updateBufferObjects(ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Make the helper's shader program current, rebuilding it when needed, and + * push the mapper, camera and property uniforms. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + updateShaders(cellBO: any, ren: vtkRenderer, actor: vtkImageSlice): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLImageCPRMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLImageCPRMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLImageCPRMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLImageCPRMapper. + * @param {IOpenGLImageCPRMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLImageCPRMapperInitialValues +): vtkOpenGLImageCPRMapper; + +/** + * vtkOpenGLImageCPRMapper is the WebGL scene graph node that draws a + * vtkImageSlice whose mapper is a vtkImageCPRMapper. It samples the volume + * along the centerline the renderable carries and draws the straightened + * result as a strip of quads. + * + * Importing this module registers it as the OpenGL override for + * `vtkImageCPRMapper`. + */ +declare const vtkOpenGLImageCPRMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export declare const STATIC: Readonly>; +export default vtkOpenGLImageCPRMapper; diff --git a/Sources/Rendering/OpenGL/ImageMapper/index.d.ts b/Sources/Rendering/OpenGL/ImageMapper/index.d.ts new file mode 100644 index 00000000000..d263cd766b4 --- /dev/null +++ b/Sources/Rendering/OpenGL/ImageMapper/index.d.ts @@ -0,0 +1,374 @@ +import { Nullable, Vector2 } from '../../../types'; +import { ICoincidentTopology } from '../../Core/Mapper/CoincidentTopologyHelper'; +import { vtkImageSlice } from '../../Core/ImageSlice'; +import { vtkRenderer } from '../../Core/Renderer'; +import vtkOpenGLTexture from '../Texture'; +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; + +/** + * The vertex, fragment and geometry sources a mapper assembles before the + * shader program is compiled. + */ +export interface IShaderSources { + Vertex: string; + Fragment: string; + Geometry: string; +} + +/** + * + */ +export interface IOpenGLImageMapperInitialValues extends IViewNodeInitialValues { + VBOBuildString?: Nullable; + openGLTexture?: Nullable; + tris?: any; + imagemat?: Nullable; + imagematinv?: Nullable; + colorTexture?: Nullable; + pwfTexture?: Nullable; + labelOutlineThicknessTexture?: Nullable; + labelOutlineOpacityTexture?: Nullable; + lastHaveSeenDepthRequest?: boolean; + haveSeenDepthRequest?: boolean; + lastTextureComponents?: number; +} + +export interface vtkOpenGLImageMapper extends vtkViewNode { + /** + * Apply the shader replacements a renderable declares under its OpenGL view + * specific properties. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param viewSpec The OpenGL view specific properties of the renderable. + * @param {Boolean} [pre] Apply the replacements marked `replaceFirst`. + */ + applyShaderReplacements( + shaders: IShaderSources, + viewSpec: any, + pre?: boolean + ): void; + + /** + * Build the texture and the vertex buffer of the quad the slice is drawn on. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + buildBufferObjects(ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Resolve the ancestors this mapper renders with: its image slice, its + * renderer, its render window and the camera view node. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + buildPass(prepass: boolean): void; + + /** + * Assemble the shader sources, applying the render pass replacement, the + * user replacements and the mapper's own substitutions. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + buildShaders( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Get the polygon offset the renderable asks for, or `null` when it does not + * resolve coincident topology with a polygon offset. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + getCoincidentParameters( + ren: vtkRenderer, + actor: vtkImageSlice + ): Nullable; + + /** + * Whether the textures and the vertex buffer are out of date. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + getNeedToRebuildBufferObjects( + ren: vtkRenderer, + actor: vtkImageSlice + ): boolean; + + /** + * Whether the shader program has to be rebuilt for the given helper. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + getNeedToRebuildShaders( + cellBO: any, + ren: vtkRenderer, + actor: vtkImageSlice + ): boolean; + + /** + * Get the lower left corner of the viewport this mapper renders into. + */ + getRenderTargetOffset(): Vector2; + + /** + * Get the width and height of the viewport this mapper renders into. + */ + getRenderTargetSize(): Vector2; + + /** + * Fill in the shader template, letting the renderable's OpenGL view specific + * properties override any of the three shader sources. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + getReplacedShaderTemplate( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Fill in the shader sources with the default polydata shader template. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + getShaderTemplate( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Render the slice during the opaque pass. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + opaquePass(prepass: boolean): void; + + /** + * Capture the slice depth during the opaque z-buffer pass. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + opaqueZBufferPass(prepass: boolean): void; + + /** + * Render the slice for the given renderer and actor. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + renderPiece(ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Update the shaders and draw the quad the slice is textured onto. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + renderPieceDraw(ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Hook run after the slice has been drawn. It does nothing. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + renderPieceFinish(ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Bring the buffer objects and the texture filters up to date before the + * slice is drawn. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + renderPieceStart(ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Substitute the clipping plane declarations and implementation into the + * shader sources. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + replaceShaderClip( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Substitute the depth offset the renderable's coincident topology + * resolution asks for into the fragment shader. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + replaceShaderCoincidentOffset( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Substitute the mapper's own declarations and implementation into the + * shader sources. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + replaceShaderValues( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Render the slice. + */ + render(): void; + + /** + * Set the camera uniforms of the shader program. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + setCameraShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Set the texture and geometry uniforms of the shader program. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + setMapperShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Set the image property uniforms of the shader program. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + setPropertyShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Render the slice during the translucent pass, remembering the render pass + * so that its shader replacement is applied. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + * @param {vtkRenderPass} renderPass The render pass being traversed. + */ + translucentPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * Rebuild the buffer objects when they are out of date. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + updateBufferObjects(ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Build or reuse the texture holding the per-label outline opacities of the + * given image slice. + * + * @param {vtkImageSlice} image The image slice being rendered. + */ + updateLabelOutlineOpacityTexture(image: vtkImageSlice): void; + + /** + * Build or reuse the texture holding the per-label outline thicknesses of + * the given image slice. + * + * @param {vtkImageSlice} image The image slice being rendered. + */ + updatelabelOutlineThicknessTexture(image: vtkImageSlice): void; + + /** + * Make the helper's shader program current, rebuilding it when needed, and + * push the mapper, camera and property uniforms. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + updateShaders(cellBO: any, ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Render the slice depth only, so that a later pass can mix geometry with + * volumes. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + zBufferPass(prepass: boolean): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLImageMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLImageMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLImageMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLImageMapper. + * @param {IOpenGLImageMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLImageMapperInitialValues +): vtkOpenGLImageMapper; + +/** + * vtkOpenGLImageMapper is the WebGL scene graph node that draws a vtkImageSlice + * whose mapper is a vtkImageMapper. It textures the slice onto a quad and + * assembles the shader program that applies the color transfer function, the + * piecewise opacity function and, for label maps, the label outline. + * + * Importing this module registers it as the OpenGL override for + * `vtkAbstractImageMapper`. + */ +declare const vtkOpenGLImageMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOpenGLImageMapper; diff --git a/Sources/Rendering/OpenGL/ImageResliceMapper/index.d.ts b/Sources/Rendering/OpenGL/ImageResliceMapper/index.d.ts new file mode 100644 index 00000000000..65a190e6062 --- /dev/null +++ b/Sources/Rendering/OpenGL/ImageResliceMapper/index.d.ts @@ -0,0 +1,422 @@ +import { Nullable } from '../../../types'; +import { ICoincidentTopology } from '../../Core/Mapper/CoincidentTopologyHelper'; +import { vtkImageProperty } from '../../Core/ImageProperty'; +import { vtkImageSlice } from '../../Core/ImageSlice'; +import { vtkRenderer } from '../../Core/Renderer'; +import vtkOpenGLTexture from '../Texture'; +import vtkPolyData from '../../../Common/DataModel/PolyData'; +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; + +/** + * The vertex, fragment and geometry sources a mapper assembles before the + * shader program is compiled. + */ +export interface IShaderSources { + Vertex: string; + Fragment: string; + Geometry: string; +} + +/** + * One label map input, paired with the position it holds among the valid + * inputs of the mapper. + */ +export interface ILabelOutlineProperty { + property: vtkImageProperty; + arrayIndex: number; +} + +/** + * + */ +export interface IOpenGLImageResliceMapperInitialValues extends IViewNodeInitialValues { + VBOBuildString?: Nullable; + haveSeenDepthRequest?: boolean; + lastHaveSeenDepthRequest?: boolean; + lastIndependentComponents?: boolean; + lastUseLabelOutline?: boolean; + lastNumValidInputs?: number; + lastNumberOfComponents?: number; + lastMultiTexturePerVolumeEnabled?: boolean; + lastSlabThickness?: number; + lastSlabTrapezoidIntegration?: number; + lastSlabType?: number; + scalarTextures?: vtkOpenGLTexture[]; + colorTexture?: Nullable; + pwfTexture?: Nullable; + labelOutlineProperties?: ILabelOutlineProperty[]; + labelOutlineThicknessTexture?: Nullable; + labelOutlineOpacityTexture?: Nullable; + resliceGeom?: Nullable; + resliceGeomUpdateString?: Nullable; + tris?: any; +} + +export interface vtkOpenGLImageResliceMapper extends vtkViewNode { + /** + * Apply the shader replacements a renderable declares under its OpenGL view + * specific properties. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param viewSpec The OpenGL view specific properties of the renderable. + * @param {Boolean} [pre] Apply the replacements marked `replaceFirst`. + */ + applyShaderReplacements( + shaders: IShaderSources, + viewSpec: any, + pre?: boolean + ): void; + + /** + * Build the scalar, color, opacity and label outline textures, and the + * vertex buffer of the reslice geometry. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + buildBufferObjects(ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Resolve the ancestors this mapper renders with: its image slice, its + * renderer, its render window and the camera view node. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + buildPass(prepass: boolean): void; + + /** + * Assemble the shader sources, applying the render pass replacement, the + * user replacements and the mapper's own substitutions. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + buildShaders( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Get the polygon offset the renderable asks for, or `null` when it does not + * resolve coincident topology with a polygon offset. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + getCoincidentParameters( + ren: vtkRenderer, + actor: vtkImageSlice + ): Nullable; + + /** + * Whether the textures and the vertex buffer are out of date. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + getNeedToRebuildBufferObjects( + ren: vtkRenderer, + actor: vtkImageSlice + ): boolean; + + /** + * Whether the shader program has to be rebuilt for the given helper. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + getNeedToRebuildShaders( + cellBO: any, + ren: vtkRenderer, + actor: vtkImageSlice + ): boolean; + + /** + * Fill in the shader template, letting the renderable's OpenGL view specific + * properties override any of the three shader sources. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + getReplacedShaderTemplate( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Get the textures holding the scalars of the valid inputs, one per + * component. + */ + getScalarTextures(): vtkOpenGLTexture[]; + + /** + * Fill in the shader sources with the default polydata shader template. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + getShaderTemplate( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Render the slice during the opaque pass. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + opaquePass(prepass: boolean): void; + + /** + * Capture the slice depth during the opaque z-buffer pass. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + opaqueZBufferPass(prepass: boolean): void; + + /** + * Render the slice. + */ + render(): void; + + /** + * Render the slice for the given renderer and actor. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + renderPiece(ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Activate the textures, update the shaders and draw the reslice geometry. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + renderPieceDraw(ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Hook run after the slice has been drawn. It does nothing. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + renderPieceFinish(ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Bring the buffer objects up to date and set the texture filters from the + * interpolation type of each input property. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + renderPieceStart(ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Substitute the depth offset the renderable's coincident topology + * resolution asks for into the fragment shader. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + replaceShaderCoincidentOffset( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Substitute the view coordinate position declarations and implementation + * into the shader sources. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + replaceShaderPositionVC( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Substitute the texture sampling declarations and implementation, including + * slab compositing and label outlines, into the shader sources. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + replaceShaderTCoord( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Substitute the mapper's own declarations and implementation into the + * shader sources. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + replaceShaderValues( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Set the camera uniforms of the shader program. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + setCameraShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Set the texture and geometry uniforms of the shader program. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + setMapperShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Set the image property uniforms of the shader program. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + setPropertyShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkImageSlice + ): void; + + /** + * Supply the scalar textures from outside the mapper. The mapper then keeps + * them as they are instead of rebuilding them from its inputs. + * + * @param {vtkOpenGLTexture[]} scalarTextures The scalar textures to use. + */ + setScalarTextures(scalarTextures: vtkOpenGLTexture[]): void; + + /** + * Render the slice during the translucent pass, remembering the render pass + * so that its shader replacement is applied. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + * @param {vtkRenderPass} renderPass The render pass being traversed. + */ + translucentPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * Rebuild the buffer objects when they are out of date. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + updateBufferObjects(ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Build or reuse the texture holding one row of per-label outline opacities + * per label map input. + * + * @param {ILabelOutlineProperty[]} labelOutlineProperties The label map inputs. + */ + updateLabelOutlineOpacityTexture( + labelOutlineProperties: ILabelOutlineProperty[] + ): void; + + /** + * Build or reuse the texture holding one row of per-label outline + * thicknesses per label map input. + * + * @param {ILabelOutlineProperty[]} labelOutlineProperties The label map inputs. + */ + updateLabelOutlineThicknessTexture( + labelOutlineProperties: ILabelOutlineProperty[] + ): void; + + /** + * Rebuild the polydata the slice is drawn on, either from the renderable's + * slice polydata or by cutting the image bounding box with its slice plane. + */ + updateResliceGeometry(): void; + + /** + * Make the helper's shader program current, rebuilding it when needed, and + * push the mapper, camera and property uniforms. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkImageSlice} actor The image slice being rendered. + */ + updateShaders(cellBO: any, ren: vtkRenderer, actor: vtkImageSlice): void; + + /** + * Render the slice depth only, so that a later pass can mix geometry with + * volumes. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + zBufferPass(prepass: boolean): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLImageResliceMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLImageResliceMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLImageResliceMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLImageResliceMapper. + * @param {IOpenGLImageResliceMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLImageResliceMapperInitialValues +): vtkOpenGLImageResliceMapper; + +/** + * vtkOpenGLImageResliceMapper is the WebGL scene graph node that draws a + * vtkImageSlice whose mapper is a vtkImageResliceMapper. It samples the volume + * along an arbitrary slice plane, optionally integrating a slab, and assembles + * the shader program that colors the result. + * + * Importing this module registers it as the OpenGL override for + * `vtkImageResliceMapper`. + */ +declare const vtkOpenGLImageResliceMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOpenGLImageResliceMapper; diff --git a/Sources/Rendering/OpenGL/ImageSlice/index.d.ts b/Sources/Rendering/OpenGL/ImageSlice/index.d.ts new file mode 100644 index 00000000000..cc78713d1fc --- /dev/null +++ b/Sources/Rendering/OpenGL/ImageSlice/index.d.ts @@ -0,0 +1,119 @@ +import { Nullable } from '../../../types'; +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; + +/** + * The cached model-to-world matrix, recomputed whenever the renderable changes. + */ +export interface IOpenGLImageSliceKeyMatrices { + mcwc: Float64Array; +} + +export interface IOpenGLImageSliceInitialValues extends IViewNodeInitialValues { + context?: Nullable; +} + +export interface vtkOpenGLImageSlice extends vtkViewNode { + /** + * Builds myself: resolve the render window, renderer and context, then adopt + * the renderable's mapper as a child. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseZBufferPass(renderPass: vtkRenderPass): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseOpaqueZBufferPass(renderPass: vtkRenderPass): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseOpaquePass(renderPass: vtkRenderPass): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseTranslucentPass(renderPass: vtkRenderPass): void; + + /** + * @param prepass + * @param {vtkRenderPass} renderPass + */ + queryPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * @param prepass + * @param {vtkRenderPass} renderPass + */ + zBufferPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * @param prepass + * @param {vtkRenderPass} renderPass + */ + opaqueZBufferPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * Renders myself. + * @param prepass + * @param {vtkRenderPass} renderPass + */ + opaquePass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * Renders myself. + * @param prepass + * @param {vtkRenderPass} renderPass + */ + translucentPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * Recompute the model-to-world matrix if the renderable moved. + */ + getKeyMatrices(): IOpenGLImageSliceKeyMatrices; + + /** + */ + getContext(): Nullable; + + /** + * @param context + */ + setContext(context: Nullable): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLImageSlice characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLImageSliceInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLImageSliceInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLImageSlice. + * @param {IOpenGLImageSliceInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLImageSliceInitialValues +): vtkOpenGLImageSlice; + +/** + * The OpenGL backend view node for a vtkImageSlice. + */ +export declare const vtkOpenGLImageSlice: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOpenGLImageSlice; diff --git a/Sources/Rendering/OpenGL/OrderIndependentTranslucentPass/index.d.ts b/Sources/Rendering/OpenGL/OrderIndependentTranslucentPass/index.d.ts new file mode 100644 index 00000000000..8d7017c4771 --- /dev/null +++ b/Sources/Rendering/OpenGL/OrderIndependentTranslucentPass/index.d.ts @@ -0,0 +1,140 @@ +import { Nullable } from '../../../types'; +import type { vtkFramebuffer } from '../Framebuffer'; +import vtkOpenGLRenderWindow from '../RenderWindow'; +import { vtkViewNode } from '../../SceneGraph/ViewNode'; +import { vtkForwardPass } from '../ForwardPass'; +import { + IRenderPassInitialValues, + vtkRenderPass, +} from '../../SceneGraph/RenderPass'; + +/** + * The vertex, fragment and geometry sources a mapper assembles before the + * shader program is compiled. + */ +export interface IShaderSources { + Vertex: string; + Fragment: string; + Geometry: string; +} + +/** + * + */ +export interface IOrderIndependentTranslucentPassInitialValues extends IRenderPassInitialValues { + framebuffer?: Nullable; + copyShader?: any; + tris?: any; +} + +/** + * `traverse` takes three arguments here rather than the two of the base class, + * so the inherited signature is replaced. + */ +type vtkOpenGLOrderIndependentTranslucentPassBase = Omit< + vtkRenderPass, + 'traverse' +>; + +export interface vtkOpenGLOrderIndependentTranslucentPass extends vtkOpenGLOrderIndependentTranslucentPassBase { + /** + * Build the shader program that resolves the two accumulation buffers onto + * a screen-aligned quad. + * + * @param {vtkOpenGLRenderWindow} viewNode The render window view node. + */ + createCopyShader(viewNode: vtkOpenGLRenderWindow): void; + + /** + * Allocate the offscreen framebuffer the translucent geometry accumulates + * into, along with its RGBA, R and depth attachments. + * + * @param {vtkOpenGLRenderWindow} viewNode The render window view node. + */ + createFramebuffer(viewNode: vtkOpenGLRenderWindow): void; + + /** + * Build the vertex array object binding the quad vertex buffer to the copy + * shader. + * + * @param {vtkOpenGLRenderWindow} viewNode The render window view node. + */ + createVBO(viewNode: vtkOpenGLRenderWindow): void; + + /** + * Build the vertex buffer of the screen-aligned quad the resolved color is + * drawn to. + */ + createVertexBuffer(): void; + + /** + * Get the framebuffer the translucent geometry accumulates into, or `null` + * before the first traversal. + */ + getFramebuffer(): Nullable; + + /** + * Get the shader replacement that turns a mapper's fragment output into the + * weighted-blended accumulation this pass resolves, or `null` when the + * context lacks the float color buffer support the pass needs. + */ + getShaderReplacement(): Nullable<(shaders: IShaderSources) => void>; + + /** + * Release the framebuffer, its textures, the copy shader and its vertex + * array object. + * + * @param {vtkOpenGLRenderWindow} viewNode The render window view node. + */ + releaseGraphicsResources(viewNode: vtkOpenGLRenderWindow): void; + + /** + * Render the translucent actors of a renderer with order-independent + * transparency, then resolve the accumulation buffers onto the current + * framebuffer. Falls back to plain alpha blending when the context has no + * float color buffer extension or a hardware selector is active. + * + * @param {vtkOpenGLRenderWindow} viewNode The render window view node. + * @param {vtkViewNode} renNode The renderer view node to traverse. + * @param {vtkForwardPass} forwardPass The forward pass driving this pass. + */ + traverse( + viewNode: vtkOpenGLRenderWindow, + renNode: vtkViewNode, + forwardPass: vtkForwardPass + ): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLOrderIndependentTranslucentPass characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOrderIndependentTranslucentPassInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOrderIndependentTranslucentPassInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLOrderIndependentTranslucentPass. + * @param {IOrderIndependentTranslucentPassInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOrderIndependentTranslucentPassInitialValues +): vtkOpenGLOrderIndependentTranslucentPass; + +/** + * vtkOpenGLOrderIndependentTranslucentPass renders translucent geometry with + * weighted blended order-independent transparency. Color and weight accumulate + * into two float attachments of an offscreen framebuffer, which are then + * resolved onto a screen-aligned quad, so the result does not depend on the + * order the translucent actors are drawn in. + */ +declare const vtkOpenGLOrderIndependentTranslucentPass: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOpenGLOrderIndependentTranslucentPass; diff --git a/Sources/Rendering/OpenGL/PixelSpaceCallbackMapper/index.d.ts b/Sources/Rendering/OpenGL/PixelSpaceCallbackMapper/index.d.ts new file mode 100644 index 00000000000..7b75b999f28 --- /dev/null +++ b/Sources/Rendering/OpenGL/PixelSpaceCallbackMapper/index.d.ts @@ -0,0 +1,55 @@ +import vtkRenderPass from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; + +/** + * Initial values for creating a new instance of vtkOpenGLPixelSpaceCallbackMapper. + */ +export interface IOpenGLPixelSpaceCallbackMapperInitialValues extends IViewNodeInitialValues {} + +export interface vtkOpenGLPixelSpaceCallbackMapper extends vtkViewNode { + /** + * Invoke the renderable's callback with the current camera, aspect ratio, + * viewport size and, when z values were requested, the depth texels. + * @param prepass + * @param {vtkRenderPass} renderPass + */ + opaquePass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * Ask the render pass for a depth buffer when the renderable needs z values. + * @param prepass + * @param {vtkRenderPass} renderPass + */ + queryPass(prepass: boolean, renderPass: vtkRenderPass): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLPixelSpaceCallbackMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLPixelSpaceCallbackMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLPixelSpaceCallbackMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLPixelSpaceCallbackMapper. + * @param {IOpenGLPixelSpaceCallbackMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLPixelSpaceCallbackMapperInitialValues +): vtkOpenGLPixelSpaceCallbackMapper; + +/** + * The OpenGL backend view node for vtkPixelSpaceCallbackMapper. + */ +export declare const vtkOpenGLPixelSpaceCallbackMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkOpenGLPixelSpaceCallbackMapper; diff --git a/Sources/Rendering/OpenGL/PolyDataMapper/index.d.ts b/Sources/Rendering/OpenGL/PolyDataMapper/index.d.ts new file mode 100644 index 00000000000..efc5977cdcf --- /dev/null +++ b/Sources/Rendering/OpenGL/PolyDataMapper/index.d.ts @@ -0,0 +1,394 @@ +import { Nullable } from '../../../types'; +import vtkActor from '../../Core/Actor'; +import vtkRenderer from '../../Core/Renderer'; +import vtkRenderPass from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; +import { ICoincidentTopology } from '../../Core/Mapper/CoincidentTopologyHelper'; +import vtkOpenGLRenderWindow from '../RenderWindow'; + +/** + * The GLSL sources a mapper assembles before compiling them into a program. + */ +export interface IShaderSources { + Vertex: string; + Fragment: string; + Geometry: string; +} + +/** + * Initial values for creating a new instance of vtkOpenGLPolyDataMapper. + */ +export interface IOpenGLPolyDataMapperInitialValues extends IViewNodeInitialValues { + context?: Nullable; + VBOBuildTime?: number; + VBOBuildString?: Nullable; + primitives?: Nullable; + primTypes?: any; + shaderRebuildString?: Nullable; + tmpMat4?: Nullable; + lastHaveSeenDepthRequest?: boolean; + haveSeenDepthRequest?: boolean; + lastSelectionState?: number; + selectionWebGLIdsToVTKIds?: any; + pointPicking?: boolean; + lastForceFlatten?: boolean; +} + +export interface vtkOpenGLPolyDataMapper extends vtkViewNode { + /** Release the primitive buffers and the internal color texture. */ + releaseGraphicsResources(renderWindow?: vtkOpenGLRenderWindow): void; + + /** + * Locate the scene graph nodes this mapper renders through. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * @param prepass + * @param {vtkRenderPass} renderPass + */ + translucentPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * @param prepass + */ + zBufferPass(prepass: boolean): void; + + /** + * @param prepass + */ + opaqueZBufferPass(prepass: boolean): void; + + /** + * @param prepass + */ + opaquePass(prepass: boolean): void; + + /** + * Renders the piece held by this mapper. + */ + render(): void; + + /** + * Fill the shader sources with the templates this mapper starts from. + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + getShaderTemplate( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor + ): void; + + /** + * Apply the user supplied shader replacements found on the renderable's + * OpenGL view specific properties. + * @param shaders + * @param viewSpec the OpenGL view specific properties, may be undefined + * @param pre when true only the replacements flagged `replaceFirst` are applied + */ + applyShaderReplacements( + shaders: IShaderSources, + viewSpec: any, + pre?: boolean + ): void; + + /** + * Assemble the full shader sources for the given renderer and actor. + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + buildShaders( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor + ): void; + + /** + * Fetch the shader templates and apply the per shader code overrides found on + * the renderable's OpenGL view specific properties. + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + getReplacedShaderTemplate( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor + ): void; + + /** + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + replaceShaderColor( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor + ): void; + + /** + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + replaceShaderLight( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor + ): void; + + /** + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + replaceShaderNormal( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor + ): void; + + /** + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + replaceShaderPositionVC( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor + ): void; + + /** + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + replaceShaderTCoord( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor + ): void; + + /** + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + replaceShaderClip( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor + ): void; + + /** + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + replaceShaderPicking( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor + ): void; + + /** + * Add the polygon offset uniforms when the coincident parameters are non zero. + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + replaceShaderCoincidentOffset( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor + ): void; + + /** + * Run every shader replacement this mapper implements. + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + replaceShaderValues( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor + ): void; + + /** + * The polygon offset factor and offset to use for the primitive currently + * being rendered. + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + getCoincidentParameters( + ren: vtkRenderer, + actor: vtkActor + ): ICoincidentTopology; + + /** + * @param cellBO the helper holding the program for a primitive type + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + getNeedToRebuildShaders( + cellBO: any, + ren: vtkRenderer, + actor: vtkActor + ): boolean; + + /** + * Invoke the user supplied shader callbacks registered on the renderable. + * @param cellBO + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + invokeShaderCallbacks(cellBO: any, ren: vtkRenderer, actor: vtkActor): void; + + /** + * @param cellBO + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + setMapperShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkActor + ): void; + + /** + * @param cellBO + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + setLightingShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkActor + ): void; + + /** + * @param cellBO + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + setCameraShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkActor + ): void; + + /** + * @param cellBO + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + setPropertyShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkActor + ): void; + + /** + * Tell the hardware selector the largest point and cell ids this mapper can + * emit. + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + updateMaximumPointCellIds(ren: vtkRenderer, actor: vtkActor): void; + + /** + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + renderPieceStart(ren: vtkRenderer, actor: vtkActor): void; + + /** + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + renderPieceDraw(ren: vtkRenderer, actor: vtkActor): void; + + /** + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + renderPieceFinish(ren: vtkRenderer, actor: vtkActor): void; + + /** + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + renderPiece(ren: vtkRenderer, actor: vtkActor): void; + + /** + * Rebuild the buffer objects when they are out of date. + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + updateBufferObjects(ren: vtkRenderer, actor: vtkActor): void; + + /** + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + getNeedToRebuildBufferObjects(ren: vtkRenderer, actor: vtkActor): boolean; + + /** + * @param {vtkRenderer} ren + * @param {vtkActor} actor + */ + buildBufferObjects(ren: vtkRenderer, actor: vtkActor): void; + + /** + * The GPU memory the primitives of this mapper currently hold, in bytes. + */ + getAllocatedGPUMemoryInBytes(): number; + + /** + * The WebGL context this mapper renders into. + */ + getContext(): Nullable; + + /** + * @param context + */ + setContext(context: Nullable): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLPolyDataMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLPolyDataMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLPolyDataMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLPolyDataMapper. + * @param {IOpenGLPolyDataMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLPolyDataMapperInitialValues +): vtkOpenGLPolyDataMapper; + +/** + * The OpenGL backend view node for vtkMapper. + */ +export declare const vtkOpenGLPolyDataMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkOpenGLPolyDataMapper; diff --git a/Sources/Rendering/OpenGL/PolyDataMapper2D/index.d.ts b/Sources/Rendering/OpenGL/PolyDataMapper2D/index.d.ts new file mode 100644 index 00000000000..0df392227ce --- /dev/null +++ b/Sources/Rendering/OpenGL/PolyDataMapper2D/index.d.ts @@ -0,0 +1,309 @@ +import { Nullable } from '../../../types'; +import vtkActor2D from '../../Core/Actor2D'; +import vtkRenderer from '../../Core/Renderer'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; +import { IShaderSources } from '../PolyDataMapper'; +import vtkOpenGLRenderWindow from '../RenderWindow'; + +/** + * Initial values for creating a new instance of vtkOpenGLPolyDataMapper2D. + */ +export interface IOpenGLPolyDataMapper2DInitialValues extends IViewNodeInitialValues { + context?: Nullable; + VBOBuildTime?: number; + VBOBuildString?: Nullable; + primitives?: Nullable; + primTypes?: any; + shaderRebuildString?: Nullable; +} + +export interface vtkOpenGLPolyDataMapper2D extends vtkViewNode { + /** Release the primitive buffers and the internal color texture. */ + releaseGraphicsResources(renderWindow?: vtkOpenGLRenderWindow): void; + + /** + * Locate the scene graph nodes this mapper renders through. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * @param prepass + */ + overlayPass(prepass: boolean): void; + + /** + * Renders the piece held by this mapper. + */ + render(): void; + + /** + * Fill the shader sources with the templates this mapper starts from. + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + getShaderTemplate( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor2D + ): void; + + /** + * Apply the user supplied shader replacements found on the renderable's + * OpenGL view specific properties. + * @param shaders + * @param viewSpec the OpenGL view specific properties, may be undefined + * @param pre when true only the replacements flagged `replaceFirst` are applied + */ + applyShaderReplacements( + shaders: IShaderSources, + viewSpec: any, + pre?: boolean + ): void; + + /** + * Assemble the full shader sources for the given renderer and actor. + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + buildShaders( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor2D + ): void; + + /** + * Fetch the shader templates and apply the per shader code overrides found on + * the renderable's OpenGL view specific properties. + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + getReplacedShaderTemplate( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor2D + ): void; + + /** + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + replaceShaderColor( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor2D + ): void; + + /** + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + replaceShaderTCoord( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor2D + ): void; + + /** + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + replaceShaderPicking( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor2D + ): void; + + /** + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + replaceShaderPositionVC( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor2D + ): void; + + /** + * Add the polygon offset uniforms when the coincident parameters are non zero. + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + replaceShaderCoincidentOffset( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor2D + ): void; + + /** + * Run every shader replacement this mapper implements. + * @param shaders + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + replaceShaderValues( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkActor2D + ): void; + + /** + * @param cellBO the helper holding the program for a primitive type + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + getNeedToRebuildShaders( + cellBO: any, + ren: vtkRenderer, + actor: vtkActor2D + ): boolean; + + /** + * Invoke the user supplied shader callbacks registered on the renderable. + * @param cellBO + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + invokeShaderCallbacks(cellBO: any, ren: vtkRenderer, actor: vtkActor2D): void; + + /** + * @param cellBO + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + setMapperShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkActor2D + ): void; + + /** + * @param cellBO + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + setPropertyShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkActor2D + ): void; + + /** + * @param cellBO + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + setLightingShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkActor2D + ): void; + + /** + * @param cellBO + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + setCameraShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkActor2D + ): void; + + /** + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + renderPiece(ren: vtkRenderer, actor: vtkActor2D): void; + + /** + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + renderPieceStart(ren: vtkRenderer, actor: vtkActor2D): void; + + /** + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + renderPieceDraw(ren: vtkRenderer, actor: vtkActor2D): void; + + /** + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + renderPieceFinish(ren: vtkRenderer, actor: vtkActor2D): void; + + /** + * Rebuild the buffer objects when they are out of date. + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + updateBufferObjects(ren: vtkRenderer, actor: vtkActor2D): void; + + /** + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + getNeedToRebuildBufferObjects(ren: vtkRenderer, actor: vtkActor2D): boolean; + + /** + * @param {vtkRenderer} ren + * @param {vtkActor2D} actor + */ + buildBufferObjects(ren: vtkRenderer, actor: vtkActor2D): void; + + /** + * The GPU memory the primitives of this mapper currently hold, in bytes. + */ + getAllocatedGPUMemoryInBytes(): number; + + /** + * The WebGL context this mapper renders into. + */ + getContext(): Nullable; + + /** + * @param context + */ + setContext(context: Nullable): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLPolyDataMapper2D characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLPolyDataMapper2DInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLPolyDataMapper2DInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLPolyDataMapper2D. + * @param {IOpenGLPolyDataMapper2DInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLPolyDataMapper2DInitialValues +): vtkOpenGLPolyDataMapper2D; + +/** + * The OpenGL backend view node for vtkMapper2D. + */ +export declare const vtkOpenGLPolyDataMapper2D: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkOpenGLPolyDataMapper2D; diff --git a/Sources/Rendering/OpenGL/Profiles/All.d.ts b/Sources/Rendering/OpenGL/Profiles/All.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/OpenGL/Profiles/All.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/OpenGL/Profiles/Geometry.d.ts b/Sources/Rendering/OpenGL/Profiles/Geometry.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/OpenGL/Profiles/Geometry.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/OpenGL/Profiles/Glyph.d.ts b/Sources/Rendering/OpenGL/Profiles/Glyph.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/OpenGL/Profiles/Glyph.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/OpenGL/Profiles/LIC.d.ts b/Sources/Rendering/OpenGL/Profiles/LIC.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/OpenGL/Profiles/LIC.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/OpenGL/Profiles/Molecule.d.ts b/Sources/Rendering/OpenGL/Profiles/Molecule.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/OpenGL/Profiles/Molecule.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/OpenGL/Profiles/Volume.d.ts b/Sources/Rendering/OpenGL/Profiles/Volume.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/OpenGL/Profiles/Volume.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/OpenGL/RadialDistortionPass/index.d.ts b/Sources/Rendering/OpenGL/RadialDistortionPass/index.d.ts new file mode 100644 index 00000000000..efa3785cd37 --- /dev/null +++ b/Sources/Rendering/OpenGL/RadialDistortionPass/index.d.ts @@ -0,0 +1,157 @@ +import { Nullable } from '../../../types'; +import type { vtkFramebuffer } from '../Framebuffer'; +import { + IRenderPassInitialValues, + vtkRenderPass, +} from '../../SceneGraph/RenderPass'; + +/** + * + */ +export interface IRadialDistortionPassInitialValues extends IRenderPassInitialValues { + copyShader?: any; + framebuffer?: Nullable; + tris?: any; + + /** + * @default 0 + */ + k1?: number; + + /** + * @default 0 + */ + k2?: number; + + /** + * @default 0 + */ + cameraCenterX1?: number; + + /** + * @default 0 + */ + cameraCenterX2?: number; + + /** + * @default 0 + */ + cameraCenterY?: number; + + /** + * @default 2 + */ + renderRatio?: number; +} + +export interface vtkRadialDistortionPass extends vtkRenderPass { + /** + * Build the distorted grid the delegate output is drawn onto. The grid is + * two side-by-side halves, one per eye, whose texture coordinates carry the + * radial distortion. Also recomputes the render ratio from `k1` and `k2`. + */ + buildVBO(): void; + + /** + * Get the x coordinate of the left half's distortion center, in normalized + * device coordinates. + * @default 0 + */ + getCameraCenterX1(): number; + + /** + * Get the x coordinate of the right half's distortion center, in normalized + * device coordinates. + * @default 0 + */ + getCameraCenterX2(): number; + + /** + * Get the y coordinate of the distortion center, in normalized device + * coordinates. + * @default 0 + */ + getCameraCenterY(): number; + + /** + * Get the framebuffer the delegate passes render into, or `null` before the + * first traversal. + */ + getFramebuffer(): Nullable; + + /** + * Get the second-order radial distortion coefficient. + * @default 0 + */ + getK1(): number; + + /** + * Get the fourth-order radial distortion coefficient. + * @default 0 + */ + getK2(): number; + + /** + * Set the x coordinate of the left half's distortion center. + * @param {Number} cameraCenterX1 + */ + setCameraCenterX1(cameraCenterX1: number): boolean; + + /** + * Set the x coordinate of the right half's distortion center. + * @param {Number} cameraCenterX2 + */ + setCameraCenterX2(cameraCenterX2: number): boolean; + + /** + * Set the y coordinate of the distortion center. + * @param {Number} cameraCenterY + */ + setCameraCenterY(cameraCenterY: number): boolean; + + /** + * Set the second-order radial distortion coefficient. With both `k1` and + * `k2` at zero the pass is a no-op and simply forwards to its delegates. + * @param {Number} k1 + */ + setK1(k1: number): boolean; + + /** + * Set the fourth-order radial distortion coefficient. + * @param {Number} k2 + */ + setK2(k2: number): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkRadialDistortionPass characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IRadialDistortionPassInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IRadialDistortionPassInitialValues +): void; + +/** + * Method used to create a new instance of vtkRadialDistortionPass. + * @param {IRadialDistortionPassInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IRadialDistortionPassInitialValues +): vtkRadialDistortionPass; + +/** + * vtkRadialDistortionPass renders its delegate passes into an oversized + * offscreen framebuffer, then draws that texture onto a pre-distorted grid so + * that the barrel distortion of an HMD lens cancels out. It is a no-op when + * both distortion coefficients are zero. + */ +declare const vtkRadialDistortionPass: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkRadialDistortionPass; diff --git a/Sources/Rendering/OpenGL/RenderWindow/index.d.ts b/Sources/Rendering/OpenGL/RenderWindow/index.d.ts index e3e0ebdb6b2..a24beac774c 100644 --- a/Sources/Rendering/OpenGL/RenderWindow/index.d.ts +++ b/Sources/Rendering/OpenGL/RenderWindow/index.d.ts @@ -1,6 +1,6 @@ import { Nullable, Size, Vector2, Vector3 } from '../../../types'; -import { vtkAlgorithm } from '../../../interfaces'; -import { VtkDataTypes } from '../../../Common/Core/DataArray'; +import { vtkAlgorithm, vtkSubscription } from '../../../interfaces'; +import { VtkDataTypes } from '../../../Common/Core/DataArray/Constants'; import vtkBufferObject from '../../OpenGL/BufferObject'; import vtkCellArray from '../../../Common/Core/CellArray'; import vtkDataArray from '../../../Common/Core/DataArray'; @@ -43,6 +43,14 @@ export interface ICaptureOptions { scale?: number; } +/** + * The payload of the windowResize event. + */ +export interface IWindowResizeEvent { + width: number; + height: number; +} + export interface vtkOpenGLRenderWindow extends vtkViewNode { /** * Builds myself. @@ -274,7 +282,7 @@ export interface vtkOpenGLRenderWindow extends vtkViewNode { * @param {WebGLContextAttributes} options */ get3DContext( - options: WebGLContextAttributes + options?: WebGLContextAttributes ): Nullable; /** @@ -282,7 +290,7 @@ export interface vtkOpenGLRenderWindow extends vtkViewNode { * @param {CanvasRenderingContext2DSettings} options */ get2DContext( - options: CanvasRenderingContext2DSettings + options?: CanvasRenderingContext2DSettings ): Nullable; /** @@ -299,20 +307,20 @@ export interface vtkOpenGLRenderWindow extends vtkViewNode { /** * Returns the last ancestor of type vtkOpenGLRenderWindow if there is one - * If there is no parent vtkOpenGLRenderWindow, returns undefined + * If there is no parent vtkOpenGLRenderWindow, returns null or undefined */ - getRootOpenGLRenderWindow(): vtkOpenGLRenderWindow | undefined; + getRootOpenGLRenderWindow(): vtkOpenGLRenderWindow | null | undefined; /** * The context 2D is created during initialization instead of the WebGL context * when there is a parent render window */ - getContext2D(): CanvasRenderingContext2D | undefined; + getContext2D(): Nullable; /** * */ - setContext2D(context2D: CanvasRenderingContext2D | undefined): boolean; + setContext2D(context2D: Nullable): boolean; /** * @@ -350,7 +358,7 @@ export interface vtkOpenGLRenderWindow extends vtkViewNode { numComps: number, oglNorm16Ext?: unknown, useHalfFloat?: boolean - ): void; + ): number; /** * @@ -382,10 +390,22 @@ export interface vtkOpenGLRenderWindow extends vtkViewNode { * @param {ICaptureOptions} options */ captureNextImage( - format: string, + format?: string, options?: ICaptureOptions ): Nullable>; + /** + * Call any registered callbacks with the captured image URL. + * @param {String} imageURL + */ + invokeImageReady(imageURL: string): void; + + /** + * Register a callback to be called whenever a captured image becomes ready. + * @param callback + */ + onImageReady(callback: (imageURL: string) => any): vtkSubscription; + /** * */ @@ -419,6 +439,20 @@ export interface vtkOpenGLRenderWindow extends vtkViewNode { */ setViewStream(stream: vtkViewStream): boolean; + /** + * Call any registered callbacks whenever setSize() changes the size. + * @param {IWindowResizeEvent} size + */ + invokeWindowResizeEvent(size: IWindowResizeEvent): void; + + /** + * Register a callback to be called whenever setSize() changes the size. + * @param callback + */ + onWindowResizeEvent( + callback: (size: IWindowResizeEvent) => any + ): vtkSubscription; + /** * Sets the pixel width and height of the rendered image. * @@ -434,20 +468,31 @@ export interface vtkOpenGLRenderWindow extends vtkViewNode { * * @param {Vector2} size */ - setSize(size: Vector2): void; + setSize(size: Vector2): boolean; /** * * @param {Number} x * @param {Number} y */ - setSize(x: number, y: number): void; + setSize(x: number, y: number): boolean; /** * */ getSize(): Vector2; + /** + * + */ + getSizeByReference(): Vector2; + + /** + * + * @param {Vector2} size + */ + setSizeFrom(size: Vector2): void; + /** * Scales the size of a browser CSS pixel to a rendered canvas pixel. * `const renderedPixelWidth = cssPixelWidth * apiRenderWindow.getComputedDevicePixelRatio()` diff --git a/Sources/Rendering/OpenGL/Renderer/index.d.ts b/Sources/Rendering/OpenGL/Renderer/index.d.ts new file mode 100644 index 00000000000..d2346eedf48 --- /dev/null +++ b/Sources/Rendering/OpenGL/Renderer/index.d.ts @@ -0,0 +1,121 @@ +import { Nullable } from '../../../types'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; +import vtkOpenGLHardwareSelector from '../HardwareSelector'; +import vtkOpenGLRenderWindow from '../RenderWindow'; + +/** + * The pixel extent of this renderer's viewport within the render window. + */ +export interface ITiledSizeAndOrigin { + usize: number; + vsize: number; + lowerLeftU: number; + lowerLeftV: number; +} + +export interface IOpenGLRendererInitialValues extends IViewNodeInitialValues { + context?: Nullable; + _openGLRenderWindow?: Nullable; + selector?: Nullable; +} + +export interface vtkOpenGLRenderer extends vtkViewNode { + /** + * Builds myself: adopt the active camera and every view prop of the + * renderable as children. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * Create a default light when the renderable has none switched on. + * @returns the number of lights that are on. + */ + updateLights(): number; + + /** + * @param prepass + */ + zBufferPass(prepass: boolean): void; + + /** + * @param prepass + */ + opaqueZBufferPass(prepass: boolean): void; + + /** + * Renders myself. + * @param prepass + */ + cameraPass(prepass: boolean): void; + + /** + * The aspect ratio of this renderer's viewport, in pixels. + */ + getAspectRatio(): number; + + /** + * The pixel size and lower-left origin of this renderer's viewport. + */ + getTiledSizeAndOrigin(): ITiledSizeAndOrigin; + + /** + * Clear the color and depth buffers over this renderer's viewport, honoring + * the renderable's transparency and depth buffer preservation flags. + */ + clear(): void; + + /** + */ + releaseGraphicsResources(): void; + + /** + * Rebind this renderer to another render window, releasing the graphics + * resources held for the previous one. + * @param {vtkOpenGLRenderWindow} rw + */ + setOpenGLRenderWindow(rw: Nullable): void; + + /** + */ + getShaderCache(): any; + + /** + */ + getSelector(): Nullable; + + /** + * @param selector + */ + setSelector(selector: Nullable): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLRenderer characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLRendererInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLRendererInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLRenderer. + * @param {IOpenGLRendererInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLRendererInitialValues +): vtkOpenGLRenderer; + +/** + * The OpenGL backend view node for a vtkRenderer. + */ +export declare const vtkOpenGLRenderer: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOpenGLRenderer; diff --git a/Sources/Rendering/OpenGL/ReplacementShaderMapper/index.d.ts b/Sources/Rendering/OpenGL/ReplacementShaderMapper/index.d.ts new file mode 100644 index 00000000000..6d796751326 --- /dev/null +++ b/Sources/Rendering/OpenGL/ReplacementShaderMapper/index.d.ts @@ -0,0 +1,36 @@ +/** + * Adds `replaceShaderCoincidentOffset` to a mapper view node. The mixin relies + * on `publicAPI.getCoincidentParameters(ren, actor)` being available. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param [initialValues] (default: {}) + */ +declare function implementReplaceShaderCoincidentOffset( + publicAPI: object, + model: object, + initialValues?: object +): void; + +/** + * Adds `applyShaderReplacements`, `buildShaders` and + * `getReplacedShaderTemplate` to a mapper view node. The mixin relies on + * `publicAPI.getShaderTemplate(...)` and `publicAPI.replaceShaderValues(...)` + * being available, and reads the user replacements from the renderable's + * OpenGL view specific properties. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param [initialValues] (default: {}) + */ +declare function implementBuildShadersWithReplacements( + publicAPI: object, + model: object, + initialValues?: object +): void; + +export declare const vtkReplacementShaderMapper: { + implementReplaceShaderCoincidentOffset: typeof implementReplaceShaderCoincidentOffset; + implementBuildShadersWithReplacements: typeof implementBuildShadersWithReplacements; +}; +export default vtkReplacementShaderMapper; diff --git a/Sources/Rendering/OpenGL/ScalarBarActor/index.d.ts b/Sources/Rendering/OpenGL/ScalarBarActor/index.d.ts new file mode 100644 index 00000000000..63253900c07 --- /dev/null +++ b/Sources/Rendering/OpenGL/ScalarBarActor/index.d.ts @@ -0,0 +1,51 @@ +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; + +export interface IOpenGLScalarBarActorInitialValues extends IViewNodeInitialValues {} + +export interface vtkOpenGLScalarBarActor extends vtkViewNode { + /** + * Builds myself: bind the scalar bar helper to the renderable and adopt the + * bar and text actors it owns as children. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * Renders myself: hand the viewport size, the active camera and the render + * window to the scalar bar helper. + * @param prepass + * @param {vtkRenderPass} renderPass + */ + opaquePass(prepass: boolean, renderPass: vtkRenderPass): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLScalarBarActor characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLScalarBarActorInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLScalarBarActorInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLScalarBarActor. + * @param {IOpenGLScalarBarActorInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLScalarBarActorInitialValues +): vtkOpenGLScalarBarActor; + +/** + * The OpenGL backend view node for a vtkScalarBarActor. + */ +export declare const vtkOpenGLScalarBarActor: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOpenGLScalarBarActor; diff --git a/Sources/Rendering/OpenGL/Shader/index.d.ts b/Sources/Rendering/OpenGL/Shader/index.d.ts new file mode 100644 index 00000000000..61a7cf02697 --- /dev/null +++ b/Sources/Rendering/OpenGL/Shader/index.d.ts @@ -0,0 +1,113 @@ +import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; + +/** + * The kind of GLSL shader a vtkShader holds. 'Geometry' is accepted by the + * model but WebGL has no geometry stage, so it never compiles. + */ +export type ShaderType = 'Vertex' | 'Fragment' | 'Geometry' | 'Unknown'; + +/** + * Initial values for creating a new instance of vtkShader. + */ +export interface IShaderInitialValues { + shaderType?: ShaderType; + source?: string; + error?: string; + handle?: WebGLShader | number; + dirty?: boolean; + context?: Nullable; +} + +export interface vtkShader extends vtkObject { + /** + * Compile the shader source into the GL shader object. + * @returns {boolean} True when the shader compiled. + */ + compile(): boolean; + + /** + * Delete the GL shader object, if any. + */ + cleanup(): void; + + /** + * Get the type of this shader. + */ + getShaderType(): ShaderType; + + /** + * Set the type of this shader. + * @param shaderType The shader type. + */ + setShaderType(shaderType: ShaderType): boolean; + + /** + * Get the GLSL source of this shader. + */ + getSource(): string; + + /** + * Set the GLSL source of this shader. + * @param source The GLSL source. + */ + setSource(source: string): boolean; + + /** + * Get the last error message. + */ + getError(): string; + + /** + * Set the error message. + * @param error The error message. + */ + setError(error: string): boolean; + + /** + * Get the underlying GL shader object, or 0 when it has not been created. + */ + getHandle(): WebGLShader | number; + + /** + * Set the underlying GL shader object. + * @param handle The GL shader object. + */ + setHandle(handle: WebGLShader | number): boolean; + + /** + * Get the WebGL context used to compile this shader. + */ + getContext(): Nullable; + + /** + * Set the WebGL context used to compile this shader. + * @param context The WebGL context. + */ + setContext(context: Nullable): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkShader characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IShaderInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IShaderInitialValues +): void; + +/** + * Method used to create a new instance of vtkShader. + * @param {IShaderInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance(initialValues?: IShaderInitialValues): vtkShader; + +export declare const vtkShader: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkShader; diff --git a/Sources/Rendering/OpenGL/ShaderCache/index.d.ts b/Sources/Rendering/OpenGL/ShaderCache/index.d.ts new file mode 100644 index 00000000000..c05a2ef35de --- /dev/null +++ b/Sources/Rendering/OpenGL/ShaderCache/index.d.ts @@ -0,0 +1,158 @@ +import vtkOpenGLRenderWindow from '../RenderWindow'; +import vtkShaderProgram from '../ShaderProgram'; +import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; + +/** + * The three shader sources of a program. + */ +export interface IShaderCacheSources { + VSSource: string; + FSSource: string; + GSSource: string; +} + +/** + * Initial values for creating a new instance of vtkShaderCache. + */ +export interface IShaderCacheInitialValues { + lastShaderProgramBound?: Nullable; + context?: Nullable; + _openGLRenderWindow?: Nullable; +} + +export interface vtkShaderCache extends vtkObject { + /** + * Apply the WebGL2 system replacements to the given shader sources. + * + * @param VSSource The vertex shader source. + * @param FSSource The fragment shader source. + * @param GSSource The geometry shader source. + * @returns {IShaderCacheSources} The substituted sources. + */ + replaceShaderValues( + VSSource: string, + FSSource: string, + GSSource: string + ): IShaderCacheSources; + + /** + * Get, compile and bind the program matching the given sources. + * + * @param vertexCode The vertex shader source. + * @param fragmentCode The fragment shader source. + * @param geometryCode The geometry shader source. + * @returns {Nullable} The ready program, or null on failure. + */ + readyShaderProgramArray( + vertexCode: string, + fragmentCode: string, + geometryCode: string + ): Nullable; + + /** + * Compile and bind the given program if needed. + * + * @param program The program to ready. + * @returns {Nullable} The program, or null on failure. + */ + readyShaderProgram( + program: Nullable + ): Nullable; + + /** + * Get the cached program for the given sources, creating it when missing. + * The sources are used as given: they are not substituted. + * + * @param vertexCode The vertex shader source. + * @param fragmentCode The fragment shader source. + * @param geometryCode The geometry shader source. + */ + getShaderProgram( + vertexCode: string, + fragmentCode: string, + geometryCode: string + ): vtkShaderProgram; + + /** + * Release every program this cache created and empty the cache. + */ + releaseGraphicsResources(win?: vtkOpenGLRenderWindow): void; + + /** + * Release the currently bound program, if any. + */ + releaseCurrentShaderProgram(): void; + + /** + * Bind the given program, releasing the previously bound one. + * + * @param program The program to bind. + * @returns {number} 1 always. + */ + bindShaderProgram(program: vtkShaderProgram): number; + + /** + * Get the last bound program. + */ + getLastShaderProgramBound(): Nullable; + + /** + * Set the last bound program. + * @param lastShaderProgramBound The program. + */ + setLastShaderProgramBound( + lastShaderProgramBound: Nullable + ): boolean; + + /** + * Get the WebGL context. + */ + getContext(): Nullable; + + /** + * Set the WebGL context. + * @param context The WebGL context. + */ + setContext(context: Nullable): boolean; + + /** + * Get the OpenGL render window this cache belongs to. + */ + getOpenGLRenderWindow(): Nullable; + + /** + * Set the OpenGL render window this cache belongs to. + * @param openGLRenderWindow The OpenGL render window. + */ + setOpenGLRenderWindow( + openGLRenderWindow: Nullable + ): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkShaderCache characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IShaderCacheInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IShaderCacheInitialValues +): void; + +/** + * Method used to create a new instance of vtkShaderCache. + * @param {IShaderCacheInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IShaderCacheInitialValues +): vtkShaderCache; + +export declare const vtkShaderCache: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkShaderCache; diff --git a/Sources/Rendering/OpenGL/ShaderProgram/index.d.ts b/Sources/Rendering/OpenGL/ShaderProgram/index.d.ts new file mode 100644 index 00000000000..bef80449e04 --- /dev/null +++ b/Sources/Rendering/OpenGL/ShaderProgram/index.d.ts @@ -0,0 +1,414 @@ +import vtkShader from '../Shader'; +import { vtkObject } from '../../../interfaces'; +import { Matrix, Matrix3x3, Nullable, TypedArray } from '../../../types'; + +/** + * Result of a shader source substitution. + */ +export interface ISubstitutionResult { + /** + * Whether the substitution changed the source. + */ + replace: boolean; + + /** + * The resulting source. + */ + result: string; +} + +/** + * Initial values for creating a new instance of vtkShaderProgram. + */ +export interface IShaderProgramInitialValues { + fragmentShader?: vtkShader; + geometryShader?: vtkShader; + vertexShader?: vtkShader; + vertexShaderHandle?: WebGLShader | number; + fragmentShaderHandle?: WebGLShader | number; + geometryShaderHandle?: WebGLShader | number; + linked?: boolean; + bound?: boolean; + compiled?: boolean; + error?: string; + handle?: WebGLProgram | number; + numberOfOutputs?: number; + md5Hash?: string | number; + context?: Nullable; + lastCameraMTime?: Nullable; +} + +export interface vtkShaderProgram extends vtkObject { + /** + * Compile the vertex and fragment shaders, attach them and link the program. + * @returns {number} 1 on success, 0 on failure. + */ + compileShader(): number; + + /** + * Release the program and detach and delete its shaders. + */ + cleanup(): void; + + /** + * Make this program the current one, linking it first if needed. + * @returns {boolean} True when the program is bound. + */ + bind(): boolean; + + /** + * Whether this program is the current one. + */ + isBound(): boolean; + + /** + * Unbind this program. + */ + release(): void; + + /** + * Set the WebGL context of the program and of its shaders. + * @param context The WebGL context. + */ + setContext(context: Nullable): void; + + /** + * Link the program. + * @returns {boolean} True when the program is linked. + */ + link(): boolean; + + /** + * Set a mat4 uniform. + * @param name The uniform name. + * @param v The 16 matrix values. + */ + setUniformMatrix(name: string, v: Matrix | TypedArray): boolean; + + /** + * Set a mat3 uniform. + * @param name The uniform name. + * @param v The 9 matrix values. + */ + setUniformMatrix3x3(name: string, v: Matrix3x3 | TypedArray): boolean; + + /** + * Set a float uniform. + * @param name The uniform name. + * @param v The value. + */ + setUniformf(name: string, v: number): boolean; + + /** + * Set a float array uniform. + * @param name The uniform name. + * @param v The values. + */ + setUniformfv(name: string, v: number[] | Float32Array): boolean; + + /** + * Set an int uniform. + * @param name The uniform name. + * @param v The value. + */ + setUniformi(name: string, v: number): boolean; + + /** + * Set an int array uniform. + * @param name The uniform name. + * @param v The values. + */ + setUniformiv(name: string, v: number[] | Int32Array): boolean; + + /** + * Set a vec2 uniform. + * @param name The uniform name. + * @param v1 The first component. + * @param v2 The second component. + */ + setUniform2f(name: string, v1: number, v2: number): boolean; + + /** + * Set a vec2 array uniform. + * @param name The uniform name. + * @param v The values. + */ + setUniform2fv(name: string, v: number[] | Float32Array): boolean; + + /** + * Set an ivec2 uniform. + * @param name The uniform name. + * @param v1 The first component. + * @param v2 The second component. + */ + setUniform2i(name: string, v1: number, v2: number): boolean; + + /** + * Set an ivec2 array uniform. + * @param name The uniform name. + * @param v The values. + */ + setUniform2iv(name: string, v: number[] | Int32Array): boolean; + + /** + * Set a vec3 uniform. + * @param name The uniform name. + * @param a1 The first component. + * @param a2 The second component. + * @param a3 The third component. + */ + setUniform3f(name: string, a1: number, a2: number, a3: number): boolean; + + /** + * Set a vec3 uniform from an array of exactly three values. + * @param name The uniform name. + * @param a The three components. + */ + setUniform3fArray(name: string, a: number[]): boolean; + + /** + * Set a vec3 array uniform. + * @param name The uniform name. + * @param v The values. + */ + setUniform3fv(name: string, v: number[] | Float32Array): boolean; + + /** + * Set an ivec3 uniform, either as three arguments or as a single array of + * three values. + * @param name The uniform name. + * @param args The three components. + */ + setUniform3i( + name: string, + ...args: [number, number, number] | [number[]] + ): boolean; + + /** + * Set an ivec3 array uniform. + * @param name The uniform name. + * @param v The values. + */ + setUniform3iv(name: string, v: number[] | Int32Array): boolean; + + /** + * Set a vec4 uniform, either as four arguments or as a single array of four + * values. + * @param name The uniform name. + * @param args The four components. + */ + setUniform4f( + name: string, + ...args: [number, number, number, number] | [number[]] + ): boolean; + + /** + * Set a vec4 array uniform. + * @param name The uniform name. + * @param v The values. + */ + setUniform4fv(name: string, v: number[] | Float32Array): boolean; + + /** + * Set an ivec4 uniform, either as four arguments or as a single array of four + * values. + * @param name The uniform name. + * @param args The four components. + */ + setUniform4i( + name: string, + ...args: [number, number, number, number] | [number[]] + ): boolean; + + /** + * Set an ivec4 array uniform. + * @param name The uniform name. + * @param v The values. + */ + setUniform4iv(name: string, v: number[] | Int32Array): boolean; + + /** + * Get the cached location of a uniform, or -1 when it is not used. + * @param name The uniform name. + */ + findUniform(name: string): WebGLUniformLocation | number; + + /** + * Whether the given uniform exists in the linked program. + * @param name The uniform name. + */ + isUniformUsed(name: string): boolean; + + /** + * Whether the given attribute exists in the linked program. + * @param name The attribute name. + */ + isAttributeUsed(name: string): boolean; + + /** + * Attach a compiled shader to the program. + * @param shader The shader to attach. + */ + attachShader(shader: vtkShader): boolean; + + /** + * Detach a shader from the program. + * @param shader The shader to detach. + */ + detachShader(shader: vtkShader): boolean; + + /** + * Get the last error message. + */ + getError(): string; + + /** + * Set the error message. + * @param error The error message. + */ + setError(error: string): boolean; + + /** + * Get the underlying GL program object, or 0 when it has not been created. + */ + getHandle(): WebGLProgram | number; + + /** + * Set the underlying GL program object. + * @param handle The GL program object. + */ + setHandle(handle: WebGLProgram | number): boolean; + + /** + * Whether the program has been compiled. + */ + getCompiled(): boolean; + + /** + * Set the compiled flag. + * @param compiled The compiled flag. + */ + setCompiled(compiled: boolean): boolean; + + /** + * Whether the program is currently bound. + */ + getBound(): boolean; + + /** + * Set the bound flag. + * @param bound The bound flag. + */ + setBound(bound: boolean): boolean; + + /** + * Whether the program has been linked. + */ + getLinked(): boolean; + + /** + * Set the linked flag. + * @param linked The linked flag. + */ + setLinked(linked: boolean): boolean; + + /** + * Get the hash of the shader sources this program was built from. + */ + getMd5Hash(): string | number; + + /** + * Set the hash of the shader sources this program was built from. + * @param md5Hash The hash. + */ + setMd5Hash(md5Hash: string | number): boolean; + + /** + * Get the vertex shader. + */ + getVertexShader(): vtkShader; + + /** + * Set the vertex shader. + * @param vertexShader The vertex shader. + */ + setVertexShader(vertexShader: vtkShader): boolean; + + /** + * Get the fragment shader. + */ + getFragmentShader(): vtkShader; + + /** + * Set the fragment shader. + * @param fragmentShader The fragment shader. + */ + setFragmentShader(fragmentShader: vtkShader): boolean; + + /** + * Get the geometry shader. WebGL has no geometry stage; it is kept for + * source substitution only. + */ + getGeometryShader(): vtkShader; + + /** + * Set the geometry shader. + * @param geometryShader The geometry shader. + */ + setGeometryShader(geometryShader: vtkShader): boolean; + + /** + * Get the MTime of the camera the camera uniforms were last set from. + */ + getLastCameraMTime(): Nullable; + + /** + * Set the MTime of the camera the camera uniforms were last set from. + * @param mtime The camera MTime. + */ + setLastCameraMTime(mtime: Nullable): void; +} + +/** + * Perform string substitutions on shader source, used to build up shader + * strings from templates. + * + * @param source The source to substitute into. + * @param search The string or pattern to replace. + * @param replace The replacement, joined with newlines when an array. + * @param {Boolean} [all] (default: true) When false, only the first occurrence is replaced. + */ +export function substitute( + source: string, + search: string | RegExp, + replace: string | string[], + all?: boolean +): ISubstitutionResult; + +/** + * Method used to decorate a given object (publicAPI+model) with vtkShaderProgram characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IShaderProgramInitialValues} [initialValues] (default: {}) + */ +declare function extend( + publicAPI: object, + model: object, + initialValues?: IShaderProgramInitialValues +): void; + +/** + * Method used to create a new instance of vtkShaderProgram. + * @param {IShaderProgramInitialValues} [initialValues] for pre-setting some of its content + */ +declare function newInstance( + initialValues?: IShaderProgramInitialValues +): vtkShaderProgram; + +export declare const vtkShaderProgram: { + newInstance: typeof newInstance; + extend: typeof extend; + substitute: typeof substitute; +}; +export default vtkShaderProgram; diff --git a/Sources/Rendering/OpenGL/Skybox/index.d.ts b/Sources/Rendering/OpenGL/Skybox/index.d.ts new file mode 100644 index 00000000000..6f91c1e5864 --- /dev/null +++ b/Sources/Rendering/OpenGL/Skybox/index.d.ts @@ -0,0 +1,79 @@ +import { Nullable } from '../../../types'; +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; +import vtkOpenGLTexture from '../Texture'; + +export interface IOpenGLSkyboxInitialValues extends IViewNodeInitialValues { + context?: Nullable; +} + +export interface vtkOpenGLSkybox extends vtkViewNode { + /** + * Builds myself: resolve the renderer, render window and context, and bind + * the helper and cube map texture to that render window. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * @param prepass + * @param {vtkRenderPass} renderPass + */ + queryPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * Renders myself: draw the full screen quad with the skybox shader. + * @param prepass + * @param {vtkRenderPass} renderPass + */ + opaquePass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * Build the quad's vertex buffer, (re)compile the shader for the current + * skybox format and pick up the renderable's texture. + */ + updateBufferObjects(): void; + + /** + */ + getActiveTextures(): Nullable; + + /** + */ + getContext(): Nullable; + + /** + * @param context + */ + setContext(context: Nullable): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLSkybox characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLSkyboxInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLSkyboxInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLSkybox. + * @param {IOpenGLSkyboxInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLSkyboxInitialValues +): vtkOpenGLSkybox; + +/** + * The OpenGL backend view node for a vtkSkybox. + */ +export declare const vtkOpenGLSkybox: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOpenGLSkybox; diff --git a/Sources/Rendering/OpenGL/SphereMapper/index.d.ts b/Sources/Rendering/OpenGL/SphereMapper/index.d.ts new file mode 100644 index 00000000000..ffc270e6c99 --- /dev/null +++ b/Sources/Rendering/OpenGL/SphereMapper/index.d.ts @@ -0,0 +1,55 @@ +import { + IOpenGLPolyDataMapperInitialValues, + vtkOpenGLPolyDataMapper, +} from '../PolyDataMapper'; + +/** + * Initial values for creating a new instance of vtkOpenGLSphereMapper. + */ +export interface IOpenGLSphereMapperInitialValues extends IOpenGLPolyDataMapperInitialValues {} + +/** + * The sphere mapper draws imposter quads that are raycast into spheres in the + * fragment shader, so it replaces the shader and buffer object hooks of + * vtkOpenGLPolyDataMapper. + */ +export interface vtkOpenGLSphereMapper extends vtkOpenGLPolyDataMapper { + /** + * The primitive mode the imposter geometry is drawn with, always triangles + * whatever representation or primitive type is asked for. + * @param rep the representation of the actor property + * @param type the primitive type + */ + getOpenGLMode(rep: number, type: number): number; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLSphereMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLSphereMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLSphereMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLSphereMapper. + * @param {IOpenGLSphereMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLSphereMapperInitialValues +): vtkOpenGLSphereMapper; + +/** + * The OpenGL backend view node for vtkSphereMapper. + */ +export declare const vtkOpenGLSphereMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkOpenGLSphereMapper; diff --git a/Sources/Rendering/OpenGL/StickMapper/index.d.ts b/Sources/Rendering/OpenGL/StickMapper/index.d.ts new file mode 100644 index 00000000000..4192e55b6cc --- /dev/null +++ b/Sources/Rendering/OpenGL/StickMapper/index.d.ts @@ -0,0 +1,55 @@ +import { + IOpenGLPolyDataMapperInitialValues, + vtkOpenGLPolyDataMapper, +} from '../PolyDataMapper'; + +/** + * Initial values for creating a new instance of vtkOpenGLStickMapper. + */ +export interface IOpenGLStickMapperInitialValues extends IOpenGLPolyDataMapperInitialValues {} + +/** + * The stick mapper draws imposter quads that are raycast into sticks in the + * fragment shader, so it replaces the shader and buffer object hooks of + * vtkOpenGLPolyDataMapper. + */ +export interface vtkOpenGLStickMapper extends vtkOpenGLPolyDataMapper { + /** + * The primitive mode the imposter geometry is drawn with, always triangles + * whatever representation or primitive type is asked for. + * @param rep the representation of the actor property + * @param type the primitive type + */ + getOpenGLMode(rep: number, type: number): number; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLStickMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLStickMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLStickMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLStickMapper. + * @param {IOpenGLStickMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLStickMapperInitialValues +): vtkOpenGLStickMapper; + +/** + * The OpenGL backend view node for vtkStickMapper. + */ +export declare const vtkOpenGLStickMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkOpenGLStickMapper; diff --git a/Sources/Rendering/OpenGL/SurfaceLIC/index.d.ts b/Sources/Rendering/OpenGL/SurfaceLIC/index.d.ts new file mode 100644 index 00000000000..d4a09c4498a --- /dev/null +++ b/Sources/Rendering/OpenGL/SurfaceLIC/index.d.ts @@ -0,0 +1,25 @@ +import type { IViewNodeInitialValues } from '../../SceneGraph/ViewNode'; + +/** + * The factory shape shared by the two surface-LIC scene graph classes. Neither + * of them has a declaration of its own yet, so their instances are untyped. + */ +export interface ISurfaceLICFactory { + newInstance(initialValues?: IViewNodeInitialValues): any; + extend( + publicAPI: object, + model: object, + initialValues?: IViewNodeInitialValues + ): void; +} + +/** + * Barrel of the OpenGL surface line-integral-convolution classes. Importing it + * pulls in the mapper submodule, whose `registerOverride` call makes the OpenGL + * view node factory build it for a `vtkSurfaceLICMapper` renderable. + */ +declare const vtkOpenGLSurfaceLIC: { + vtkOpenGLSurfaceLICMapper: ISurfaceLICFactory; + vtkOpenGLSurfaceLICInterface: ISurfaceLICFactory; +}; +export default vtkOpenGLSurfaceLIC; diff --git a/Sources/Rendering/OpenGL/Texture/Constants.d.ts b/Sources/Rendering/OpenGL/Texture/Constants.d.ts index 4dca7c341ca..04069d533f8 100644 --- a/Sources/Rendering/OpenGL/Texture/Constants.d.ts +++ b/Sources/Rendering/OpenGL/Texture/Constants.d.ts @@ -1,17 +1,21 @@ -export declare enum Wrap { - CLAMP_TO_EDGE = 0, - REPEAT = 1, - MIRRORED_REPEAT = 2, -} +export declare const Wrap: { + readonly CLAMP_TO_EDGE: 0; + readonly REPEAT: 1; + readonly MIRRORED_REPEAT: 2; +}; + +export type Wrap = (typeof Wrap)[keyof typeof Wrap]; + +export declare const Filter: { + readonly NEAREST: 0; + readonly LINEAR: 1; + readonly NEAREST_MIPMAP_NEAREST: 2; + readonly NEAREST_MIPMAP_LINEAR: 3; + readonly LINEAR_MIPMAP_NEAREST: 4; + readonly LINEAR_MIPMAP_LINEAR: 5; +}; -export declare enum Filter { - NEAREST = 0, - LINEAR = 1, - NEAREST_MIPMAP_NEAREST = 2, - NEAREST_MIPMAP_LINEAR = 3, - LINEAR_MIPMAP_NEAREST = 4, - LINEAR_MIPMAP_LINEAR = 5, -} +export type Filter = (typeof Filter)[keyof typeof Filter]; declare const _default: { Wrap: typeof Wrap; diff --git a/Sources/Rendering/OpenGL/Texture/index.d.ts b/Sources/Rendering/OpenGL/Texture/index.d.ts index 01880883f75..1030bce0d61 100644 --- a/Sources/Rendering/OpenGL/Texture/index.d.ts +++ b/Sources/Rendering/OpenGL/Texture/index.d.ts @@ -1,7 +1,7 @@ import { Wrap, Filter } from './Constants'; import vtkOpenGLRenderWindow from '../RenderWindow'; import { Extent, Nullable } from '../../../types'; -import { VtkDataTypes } from '../../../Common/Core/DataArray'; +import { VtkDataTypes } from '../../../Common/Core/DataArray/Constants'; import { vtkViewNode } from '../../../Rendering/SceneGraph/ViewNode'; import { vtkObject, vtkRange } from '../../../interfaces'; @@ -39,6 +39,32 @@ export interface ITextureInitialValues { allocatedGPUMemoryInBytes?: number; } +/** + * Scale and offset needed to map texture values back to data values, as + * `data = texture * scale + offset`. + * + * The dimensions and the data-computed scale/offset are only recorded when the + * texture is built from a data array. + */ +export interface ITextureVolumeInfo { + scale: number[]; + offset: number[]; + dataComputedScale?: number[]; + dataComputedOffset?: number[]; + width?: number; + height?: number; + depth?: number; +} + +/** + * Scale and shift needed to map normalized OpenGL data type values back to + * data values, as `data = value * scale + shift`. + */ +export interface ITextureShiftAndScale { + shift: number; + scale: number; +} + /** * Interface for OpenGL Texture. */ @@ -103,7 +129,7 @@ export interface vtkOpenGLTexture extends vtkViewNode { * @param numComps The number of components in the texture. * @returns The internal format. */ - getInternalFormat(vtktype: VtkDataTypes, numComps: number): any; + getInternalFormat(vtktype: VtkDataTypes, numComps: number): number; /** * Gets the default internal format for the texture based on the VTK data type and number of components. @@ -111,13 +137,13 @@ export interface vtkOpenGLTexture extends vtkViewNode { * @param numComps The number of components in the texture. * @returns The default internal format. */ - getDefaultInternalFormat(vtktype: VtkDataTypes, numComps: number): any; + getDefaultInternalFormat(vtktype: VtkDataTypes, numComps: number): number; /** * Sets the internal format for the texture. * @param iformat The internal format to set. */ - setInternalFormat(iformat: any): void; + setInternalFormat(iformat: number): void; /** * Gets the format for the texture based on the VTK data type and number of components. @@ -125,7 +151,7 @@ export interface vtkOpenGLTexture extends vtkViewNode { * @param numComps The number of components in the texture. * @returns The format. */ - getFormat(vtktype: VtkDataTypes, numComps: number): any; + getFormat(vtktype: VtkDataTypes, numComps: number): number; /** * Gets the default format for the texture based on the VTK data type and number of components. @@ -133,7 +159,7 @@ export interface vtkOpenGLTexture extends vtkViewNode { * @param numComps The number of components in the texture. * @returns The default format. */ - getDefaultFormat(vtktype: VtkDataTypes, numComps: number): any; + getDefaultFormat(vtktype: VtkDataTypes, numComps: number): number; /** * Resets the texture format and type to their default values. @@ -145,7 +171,7 @@ export interface vtkOpenGLTexture extends vtkViewNode { * @param vtkScalarType The VTK scalar type. * @returns The default data type. */ - getDefaultDataType(vtkScalarType: VtkDataTypes): any; + getDefaultDataType(vtkScalarType: VtkDataTypes): number; /** * Gets the OpenGL data type for the texture based on the VTK scalar type and whether to force an update. @@ -153,27 +179,27 @@ export interface vtkOpenGLTexture extends vtkViewNode { * @param forceUpdate Whether to force the update of the data type. * @returns The OpenGL data type. */ - getOpenGLDataType(vtkScalarType: VtkDataTypes, forceUpdate: boolean): any; + getOpenGLDataType(vtkScalarType: VtkDataTypes, forceUpdate: boolean): number; /** * Gets the shift and scale values for the texture. * @returns The shift and scale values. */ - getShiftAndScale(): any; + getShiftAndScale(): ITextureShiftAndScale; /** * Gets the OpenGL filter mode for the texture. * @param emode The filter mode. * @returns The OpenGL filter mode. */ - getOpenGLFilterMode(emode: Filter): any; + getOpenGLFilterMode(emode: Filter): number; /** * Gets the OpenGL wrap mode for the texture. * @param vtktype The wrap type. * @returns The OpenGL wrap mode. */ - getOpenGLWrapMode(vtktype: Wrap): any; + getOpenGLWrapMode(vtktype: Wrap): number; /** * Updates the data array to match the required data type for OpenGL. @@ -184,13 +210,15 @@ export interface vtkOpenGLTexture extends vtkViewNode { * @param {string} dataType - The original data type of the input data. * @param {Array} data - The input data array that needs to be updated. * @param {boolean} [depth=false] - Indicates whether the data is a 3D array. + * @param {Array} imageExtents only consider these image extents (default: []) * @returns {Array} The updated data array that matches the OpenGL data type. */ updateArrayDataTypeForGL( dataType: VtkDataTypes, data: any, - depth?: boolean - ): void; + depth?: boolean, + imageExtents?: Extent[] + ): any[]; /** * Creates a 2D texture from raw data. @@ -241,6 +269,26 @@ export interface vtkOpenGLTexture extends vtkViewNode { data: any; }): boolean; + /** + * Creates a 2D depth texture from raw data. + * @param width The width of the texture. + * @param height The height of the texture. + * @param dataType The data type of the texture. + * @param data The raw data for the texture. + * @returns {boolean} True if the texture was successfully created, false otherwise. + */ + createDepthFromRaw({ + width, + height, + dataType, + data, + }: { + width: number; + height: number; + dataType: VtkDataTypes; + data: any; + }): boolean; + /** * Creates a 2D texture from an image. * @param image The image to use for the texture. @@ -302,7 +350,7 @@ export interface vtkOpenGLTexture extends vtkViewNode { height: number; dataArray: any; preferSizeOverAccuracy?: boolean; - }): boolean; + }): void; /** * Creates a 3D texture from raw data. @@ -425,6 +473,156 @@ export interface vtkOpenGLTexture extends vtkViewNode { * @param useHalfFloat - whether to use half float */ enableUseHalfFloat(useHalfFloat: boolean): void; + + /** + * Whether half float is both enabled and usable for the current data range. + * @returns {boolean} True when half float is in use. + */ + useHalfFloat(): boolean; + + /** + * Recomputes the scale and offset stored in the volume info for the given + * data type and number of components. + * @param dataType The VTK data type of the texture data. + * @param numComps The number of components in the texture. + * @returns {boolean} True if a scaling was applied for that data type. + */ + updateVolumeInfoForGL(dataType: VtkDataTypes, numComps: number): boolean; + + /** + * Gets the scale and offset mapping texture values back to data values. + */ + getVolumeInfo(): ITextureVolumeInfo; + + /** + * Gets the width of the texture. + */ + getWidth(): number; + + /** + * Gets the height of the texture. + */ + getHeight(): number; + + /** + * Gets the number of components of the texture. + */ + getComponents(): number; + + /** + * Gets the underlying WebGL texture object, or 0 when no texture is allocated. + */ + getHandle(): WebGLTexture | number; + + /** + * Gets the OpenGL texture target. + */ + getTarget(): number; + + /** + * Gets the amount of GPU memory allocated for this texture, in bytes. + */ + getAllocatedGPUMemoryInBytes(): number; + + /** + * Sets the format for the texture. + * @param format The format to set. + */ + setFormat(format: number): boolean; + + /** + * Sets the OpenGL data type for the texture. + * @param openGLDataType The OpenGL data type to set. + */ + setOpenGLDataType(openGLDataType: number): boolean; + + /** + * Gets the time stamp used to track matrix updates. + */ + getKeyMatrixTime(): vtkObject; + + /** + * Sets the time stamp used to track matrix updates. + * @param keyMatrixTime The time stamp to set. + */ + setKeyMatrixTime(keyMatrixTime: vtkObject): boolean; + + /** + * Gets the minification filter. + */ + getMinificationFilter(): Filter; + + /** + * Sets the minification filter. + * @param minificationFilter The filter to set. + */ + setMinificationFilter(minificationFilter: Filter): boolean; + + /** + * Gets the magnification filter. + */ + getMagnificationFilter(): Filter; + + /** + * Sets the magnification filter. + * @param magnificationFilter The filter to set. + */ + setMagnificationFilter(magnificationFilter: Filter): boolean; + + /** + * Gets the wrap mode along S. + */ + getWrapS(): Wrap; + + /** + * Sets the wrap mode along S. + * @param wrapS The wrap mode to set. + */ + setWrapS(wrapS: Wrap): boolean; + + /** + * Gets the wrap mode along T. + */ + getWrapT(): Wrap; + + /** + * Sets the wrap mode along T. + * @param wrapT The wrap mode to set. + */ + setWrapT(wrapT: Wrap): boolean; + + /** + * Gets the wrap mode along R. + */ + getWrapR(): Wrap; + + /** + * Sets the wrap mode along R. + * @param wrapR The wrap mode to set. + */ + setWrapR(wrapR: Wrap): boolean; + + /** + * Gets whether mipmaps are generated for the texture. + */ + getGenerateMipmap(): boolean; + + /** + * Sets whether mipmaps are generated for the texture. + * @param generateMipmap Whether to generate mipmaps. + */ + setGenerateMipmap(generateMipmap: boolean): boolean; + + /** + * Gets the EXT_texture_norm16 extension object, if available. + */ + getOglNorm16Ext(): Nullable; + + /** + * Sets the EXT_texture_norm16 extension object. + * @param oglNorm16Ext The extension object. + */ + setOglNorm16Ext(oglNorm16Ext: Nullable): boolean; } /** @@ -454,6 +652,8 @@ export function newInstance( export declare const vtkOpenGLTexture: { newInstance: typeof newInstance; extend: typeof extend; + Filter: typeof Filter; + Wrap: typeof Wrap; }; export default vtkOpenGLTexture; diff --git a/Sources/Rendering/OpenGL/TextureUnitManager/index.d.ts b/Sources/Rendering/OpenGL/TextureUnitManager/index.d.ts new file mode 100644 index 00000000000..045dafd8630 --- /dev/null +++ b/Sources/Rendering/OpenGL/TextureUnitManager/index.d.ts @@ -0,0 +1,92 @@ +import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; + +/** + * Initial values for creating a new instance of vtkOpenGLTextureUnitManager. + */ +export interface IOpenGLTextureUnitManagerInitialValues { + context?: Nullable; + numberOfTextureUnits?: number; +} + +export interface vtkOpenGLTextureUnitManager extends vtkObject { + /** + * Drop the allocation table, reporting any unit that was not released. + */ + deleteTable(): void; + + /** + * Set the WebGL context and size the allocation table from + * `MAX_TEXTURE_IMAGE_UNITS`. + * + * @param context The WebGL context. + */ + setContext(context: Nullable): void; + + /** + * Get the WebGL context. + */ + getContext(): Nullable; + + /** + * Reserve the first free texture unit. + * @returns {number} The unit number, or -1 when none is free. + */ + allocate(): number; + + /** + * Reserve a specific texture unit. + * @param unit The unit to reserve. + * @returns {number} The unit number, or -1 when it was already allocated. + */ + allocateUnit(unit: number): number; + + /** + * Whether the given texture unit is allocated. + * @param textureUnitId The unit to test. + */ + isAllocated(textureUnitId: number): boolean; + + /** + * Release a texture unit. + * @param val The unit to release. + */ + free(val: number): void; + + /** + * Release every texture unit. + */ + freeAll(): void; + + /** + * Get the number of texture units the context exposes. + */ + getNumberOfTextureUnits(): number; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLTextureUnitManager characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLTextureUnitManagerInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLTextureUnitManagerInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLTextureUnitManager. + * @param {IOpenGLTextureUnitManagerInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLTextureUnitManagerInitialValues +): vtkOpenGLTextureUnitManager; + +export declare const vtkOpenGLTextureUnitManager: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOpenGLTextureUnitManager; diff --git a/Sources/Rendering/OpenGL/VertexArrayObject/index.d.ts b/Sources/Rendering/OpenGL/VertexArrayObject/index.d.ts new file mode 100644 index 00000000000..052e3ce84c3 --- /dev/null +++ b/Sources/Rendering/OpenGL/VertexArrayObject/index.d.ts @@ -0,0 +1,168 @@ +import vtkOpenGLBufferObject from '../BufferObject'; +import vtkOpenGLRenderWindow from '../RenderWindow'; +import vtkShaderProgram from '../ShaderProgram'; +import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; + +/** + * Initial values for creating a new instance of vtkOpenGLVertexArrayObject. + */ +export interface IOpenGLVertexArrayObjectInitialValues { + handleVAO?: WebGLVertexArrayObject | number; + handleProgram?: WebGLProgram | number; + context?: Nullable; + _openGLRenderWindow?: Nullable; +} + +export interface vtkOpenGLVertexArrayObject extends vtkObject { + /** + * Create the underlying GL vertex array object. + */ + initialize(): void; + + /** + * Whether the GL vertex array object exists. + */ + isReady(): boolean; + + /** + * Bind the vertex array object, creating it if needed. + */ + bind(): void; + + /** + * Unbind the vertex array object. + */ + release(): void; + + /** + * Drop the vertex array object so that it is rebuilt against the new program. + */ + shaderProgramChanged(): void; + + /** + * Delete the vertex array object. + */ + releaseGraphicsResources(): void; + + /** + * Bind a buffer to a program attribute. + * + * @param program The bound shader program. + * @param buffer The array buffer holding the attribute. + * @param name The attribute name in the program. + * @param offset The offset in bytes of the attribute inside a block. + * @param stride The size in bytes of a block. + * @param elementType The GL type of a component. + * @param elementTupleSize The number of components. + * @param normalize Whether integer components are normalized. + * @returns {boolean} False when the attribute could not be bound. + */ + addAttributeArray( + program: Nullable, + buffer: vtkOpenGLBufferObject, + name: string, + offset: number, + stride: number, + elementType: number, + elementTupleSize: number, + normalize: boolean + ): boolean; + + /** + * Bind a buffer to a program attribute, optionally instanced. + * + * @param program The bound shader program. + * @param buffer The array buffer holding the attribute. + * @param name The attribute name in the program. + * @param offset The offset in bytes of the attribute inside a block. + * @param stride The size in bytes of a block. + * @param elementType The GL type of a component. + * @param elementTupleSize The number of components. + * @param normalize Whether integer components are normalized. + * @param divisor When greater than zero, the attribute advances per instance. + * @param isMatrix Whether the attribute is one row of a matrix attribute. + * @returns {boolean} False when the attribute could not be bound. + */ + addAttributeArrayWithDivisor( + program: Nullable, + buffer: vtkOpenGLBufferObject, + name: string, + offset: number, + stride: number, + elementType: number, + elementTupleSize: number, + normalize: boolean, + divisor: number, + isMatrix: boolean + ): boolean; + + /** + * Bind a buffer to a matrix program attribute, one attribute slot per row. + * + * @param program The bound shader program. + * @param buffer The array buffer holding the attribute. + * @param name The attribute name in the program. + * @param offset The offset in bytes of the attribute inside a block. + * @param stride The size in bytes of a block. + * @param elementType The GL type of a component. + * @param elementTupleSize The number of rows and columns of the matrix. + * @param normalize Whether integer components are normalized. + * @param divisor When greater than zero, the attribute advances per instance. + * @returns {boolean} False when the attribute could not be bound. + */ + addAttributeMatrixWithDivisor( + program: Nullable, + buffer: vtkOpenGLBufferObject, + name: string, + offset: number, + stride: number, + elementType: number, + elementTupleSize: number, + normalize: boolean, + divisor: number + ): boolean; + + /** + * The attribute state lives inside the vertex array object and is overwritten + * on the next bind, so this only reports whether the object is usable. + * + * @param name The attribute name in the program. + */ + removeAttributeArray(name: string): boolean; + + /** + * Attach this vertex array object to an OpenGL render window, releasing any + * resources held for a previous one. + * + * @param renWin The OpenGL render window. + */ + setOpenGLRenderWindow(renWin: Nullable): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLVertexArrayObject characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLVertexArrayObjectInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLVertexArrayObjectInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLVertexArrayObject. + * @param {IOpenGLVertexArrayObjectInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLVertexArrayObjectInitialValues +): vtkOpenGLVertexArrayObject; + +export declare const vtkOpenGLVertexArrayObject: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOpenGLVertexArrayObject; diff --git a/Sources/Rendering/OpenGL/ViewNodeFactory/index.d.ts b/Sources/Rendering/OpenGL/ViewNodeFactory/index.d.ts new file mode 100644 index 00000000000..19c6a376ace --- /dev/null +++ b/Sources/Rendering/OpenGL/ViewNodeFactory/index.d.ts @@ -0,0 +1,52 @@ +import { + IViewNodeFactoryInitialValues, + vtkViewNodeFactory, +} from '../../SceneGraph/ViewNodeFactory'; +import { vtkViewNode } from '../../SceneGraph/ViewNode'; + +/** + * Register the view node factory function used for a given renderable class + * name. The mapping is static and shared by every vtkOpenGLViewNodeFactory + * instance; each OpenGL backend module registers itself when imported. + * + * @param className the renderable class name, e.g. 'vtkActor' + * @param fn the factory creating the matching view node + */ +export function registerOverride( + className: string, + fn: (initialValues?: object) => vtkViewNode +): void; + +export interface IOpenGLViewNodeFactoryInitialValues extends IViewNodeFactoryInitialValues {} + +export interface vtkOpenGLViewNodeFactory extends vtkViewNodeFactory {} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLViewNodeFactory characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLViewNodeFactoryInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLViewNodeFactoryInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLViewNodeFactory. + * @param {IOpenGLViewNodeFactoryInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLViewNodeFactoryInitialValues +): vtkOpenGLViewNodeFactory; + +/** + * The factory choosing which OpenGL view node to create for a renderable. + */ +export declare const vtkOpenGLViewNodeFactory: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOpenGLViewNodeFactory; diff --git a/Sources/Rendering/OpenGL/Volume/index.d.ts b/Sources/Rendering/OpenGL/Volume/index.d.ts new file mode 100644 index 00000000000..3ec7793fd5f --- /dev/null +++ b/Sources/Rendering/OpenGL/Volume/index.d.ts @@ -0,0 +1,85 @@ +import { Nullable } from '../../../types'; +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; + +/** + * The cached matrices recomputed whenever the renderable changes. + */ +export interface IOpenGLVolumeKeyMatrices { + mcwc: Float64Array; + normalMatrix: Float64Array; +} + +export interface IOpenGLVolumeInitialValues extends IViewNodeInitialValues { + context?: Nullable; +} + +export interface vtkOpenGLVolume extends vtkViewNode { + /** + * Builds myself: resolve the render window, renderer and context, then adopt + * the renderable's mapper as a child. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * @param prepass + * @param {vtkRenderPass} renderPass + */ + queryPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseVolumePass(renderPass: vtkRenderPass): void; + + /** + * Renders myself. + * @param prepass + */ + volumePass(prepass: boolean): void; + + /** + * Recompute the model-to-world and normal matrices if the renderable moved. + */ + getKeyMatrices(): IOpenGLVolumeKeyMatrices; + + /** + */ + getContext(): Nullable; + + /** + * @param context + */ + setContext(context: Nullable): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLVolume characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLVolumeInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLVolumeInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLVolume. + * @param {IOpenGLVolumeInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLVolumeInitialValues +): vtkOpenGLVolume; + +/** + * The OpenGL backend view node for a vtkVolume. + */ +export declare const vtkOpenGLVolume: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOpenGLVolume; diff --git a/Sources/Rendering/OpenGL/VolumeMapper/index.d.ts b/Sources/Rendering/OpenGL/VolumeMapper/index.d.ts new file mode 100644 index 00000000000..acdf3c78404 --- /dev/null +++ b/Sources/Rendering/OpenGL/VolumeMapper/index.d.ts @@ -0,0 +1,377 @@ +import { Nullable, Vector2 } from '../../../types'; +import { vtkRenderer } from '../../Core/Renderer'; +import { vtkVolume } from '../../Core/Volume'; +import type { vtkFramebuffer } from '../Framebuffer'; +import { vtkForwardPass } from '../ForwardPass'; +import vtkOpenGLTexture from '../Texture'; +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; +import vtkOpenGLRenderWindow from '../RenderWindow'; + +/** + * The vertex, fragment and geometry sources a mapper assembles before the + * shader program is compiled. + */ +export interface IShaderSources { + Vertex: string; + Fragment: string; + Geometry: string; +} + +/** + * + */ +export interface IOpenGLVolumeMapperInitialValues extends IViewNodeInitialValues { + context?: Nullable; + scalarTextures?: vtkOpenGLTexture[]; + opacityTexture?: Nullable; + colorTexture?: Nullable; + labelOutlineThicknessTexture?: Nullable; + jitterTexture?: Nullable; + tris?: any; + framebuffer?: Nullable; + copyShader?: any; + copyVAO?: any; + + /** + * @default 1 + */ + lastXYF?: number; + + /** + * @default 1 + */ + targetXYF?: number; + + zBufferTexture?: Nullable; + lastZBufferTexture?: Nullable; + + /** + * @default 1 + */ + fullViewportTime?: number; + + idxToView?: Nullable; + vecISToVCMatrix?: Nullable; + modelToView?: Nullable; + projectionToView?: Nullable; + + /** + * @default 0 + */ + avgWindowArea?: number; + + /** + * @default 0 + */ + avgFrameTime?: number; +} + +export interface vtkOpenGLVolumeMapper extends vtkViewNode { + /** Release the framebuffers, textures and vertex buffers of this mapper. */ + releaseGraphicsResources(renderWindow?: vtkOpenGLRenderWindow): void; + + /** + * Apply the shader replacements a renderable declares under its OpenGL view + * specific properties. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param viewSpec The OpenGL view specific properties of the renderable. + * @param {Boolean} [pre] Apply the replacements marked `replaceFirst`. + */ + applyShaderReplacements( + shaders: IShaderSources, + viewSpec: any, + pre?: boolean + ): void; + + /** + * Build the scalar, color, opacity and label outline textures, and the + * vertex buffer of the box the volume is ray cast through. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkVolume} actor The volume being rendered. + */ + buildBufferObjects(ren: vtkRenderer, actor: vtkVolume): void; + + /** + * Drop the z-buffer texture captured by a previous traversal. + */ + buildPass(): void; + + /** + * Assemble the shader sources, applying the user replacements and the + * mapper's own substitutions. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkVolume} actor The volume being rendered. + */ + buildShaders( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkVolume + ): void; + + /** + * Set the clipping plane uniforms of the shader program. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkVolume} actor The volume being rendered. + */ + getClippingPlaneShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkVolume + ): void; + + /** + * Get the WebGL context this mapper renders with. + */ + getContext(): Nullable; + + /** + * Get the sample distance to ray cast with, which is the renderable's sample + * distance scaled by its interaction factor while the interactor animates. + * + * @param {vtkRenderer} ren The renderer. + */ + getCurrentSampleDistance(ren: vtkRenderer): number; + + /** + * Whether the textures and the vertex buffer are out of date. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkVolume} actor The volume being rendered. + */ + getNeedToRebuildBufferObjects(ren: vtkRenderer, actor: vtkVolume): boolean; + + /** + * Whether the shader program has to be rebuilt for the given helper. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkVolume} actor The volume being rendered. + */ + getNeedToRebuildShaders( + cellBO: any, + ren: vtkRenderer, + actor: vtkVolume + ): boolean; + + /** + * Get the lower left corner of the viewport this mapper renders into. + */ + getRenderTargetOffset(): Vector2; + + /** + * Get the width and height of the target this mapper renders into, which is + * the reduced offscreen size while the volume is rendered at a lower + * resolution. + */ + getRenderTargetSize(): Vector2; + + /** + * Fill in the shader template, letting the renderable's OpenGL view specific + * properties override any of the three shader sources. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkVolume} actor The volume being rendered. + */ + getReplacedShaderTemplate( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkVolume + ): void; + + /** + * Fill in the shader sources with the default volume shader template. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkVolume} actor The volume being rendered. + */ + getShaderTemplate( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkVolume + ): void; + + /** + * Capture the z-buffer texture of the pass, so that the volume can be mixed + * with the opaque geometry. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + * @param {vtkForwardPass} renderPass The pass holding the z-buffer texture. + */ + opaqueZBufferPass(prepass: boolean, renderPass: vtkForwardPass): void; + + /** + * Render the volume for the given renderer and actor. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkVolume} actor The volume being rendered. + */ + renderPiece(ren: vtkRenderer, actor: vtkVolume): void; + + /** + * Activate the textures, update the shaders and draw the box the volume is + * ray cast through. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkVolume} actor The volume being rendered. + */ + renderPieceDraw(ren: vtkRenderer, actor: vtkVolume): void; + + /** + * Blit the reduced-resolution offscreen result back onto the render target + * and update the frame timing that drives the resolution. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkVolume} actor The volume being rendered. + */ + renderPieceFinish(ren: vtkRenderer, actor: vtkVolume): void; + + /** + * Pick the render resolution from the recent frame times, bind the offscreen + * framebuffer when one is needed, and bring the buffer objects up to date. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkVolume} actor The volume being rendered. + */ + renderPieceStart(ren: vtkRenderer, actor: vtkVolume): void; + + /** + * Substitute the mapper's own declarations and implementation into the + * shader sources. + * + * @param {IShaderSources} shaders The shader sources, edited in place. + * @param {vtkRenderer} ren The renderer. + * @param {vtkVolume} actor The volume being rendered. + */ + replaceShaderValues( + shaders: IShaderSources, + ren: vtkRenderer, + actor: vtkVolume + ): void; + + /** + * Set the camera uniforms of the shader program. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkVolume} actor The volume being rendered. + */ + setCameraShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkVolume + ): void; + + /** + * Set the WebGL context this mapper renders with. + * + * @param context The WebGL context. + */ + setContext(context: Nullable): boolean; + + /** + * Set the texture and geometry uniforms of the shader program. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkVolume} actor The volume being rendered. + */ + setMapperShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkVolume + ): void; + + /** + * Set the volume property uniforms of the shader program, including the + * transfer function ranges and the lighting. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkVolume} actor The volume being rendered. + */ + setPropertyShaderParameters( + cellBO: any, + ren: vtkRenderer, + actor: vtkVolume + ): void; + + /** + * Rebuild the buffer objects when they are out of date. + * + * @param {vtkRenderer} ren The renderer. + * @param {vtkVolume} actor The volume being rendered. + */ + updateBufferObjects(ren: vtkRenderer, actor: vtkVolume): void; + + /** + * Make the helper's shader program current, rebuilding it when needed, and + * push the mapper, camera and property uniforms. + * + * @param cellBO The OpenGL helper carrying the shader program. + * @param {vtkRenderer} ren The renderer. + * @param {vtkVolume} actor The volume being rendered. + */ + updateShaders(cellBO: any, ren: vtkRenderer, actor: vtkVolume): void; + + /** + * Resolve the ancestors this mapper renders with and render the volume. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + * @param {vtkRenderPass} renderPass The render pass being traversed. + */ + volumePass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * Capture the z-buffer texture of the pass, so that the volume can be mixed + * with the opaque geometry. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + * @param {vtkForwardPass} renderPass The pass holding the z-buffer texture. + */ + zBufferPass(prepass: boolean, renderPass: vtkForwardPass): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkOpenGLVolumeMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOpenGLVolumeMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOpenGLVolumeMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkOpenGLVolumeMapper. + * @param {IOpenGLVolumeMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IOpenGLVolumeMapperInitialValues +): vtkOpenGLVolumeMapper; + +/** + * vtkOpenGLVolumeMapper is the WebGL scene graph node that ray casts a + * vtkVolume whose mapper is a vtkVolumeMapper. It renders into an offscreen + * framebuffer whose resolution follows the recent frame times, so that + * interaction stays responsive, and blits the result back. + * + * Importing this module registers it as the OpenGL override for + * `vtkVolumeMapper`. + */ +declare const vtkOpenGLVolumeMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOpenGLVolumeMapper; diff --git a/Sources/Rendering/Profiles/All.d.ts b/Sources/Rendering/Profiles/All.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/Profiles/All.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/Profiles/Geometry.d.ts b/Sources/Rendering/Profiles/Geometry.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/Profiles/Geometry.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/Profiles/Glyph.d.ts b/Sources/Rendering/Profiles/Glyph.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/Profiles/Glyph.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/Profiles/LIC.d.ts b/Sources/Rendering/Profiles/LIC.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/Profiles/LIC.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/Profiles/Molecule.d.ts b/Sources/Rendering/Profiles/Molecule.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/Profiles/Molecule.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/Profiles/Volume.d.ts b/Sources/Rendering/Profiles/Volume.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/Profiles/Volume.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/SceneGraph/RenderPass/index.d.ts b/Sources/Rendering/SceneGraph/RenderPass/index.d.ts index 627bb41aee7..63f024fd4f0 100644 --- a/Sources/Rendering/SceneGraph/RenderPass/index.d.ts +++ b/Sources/Rendering/SceneGraph/RenderPass/index.d.ts @@ -1,20 +1,23 @@ import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; import vtkViewNode from '../ViewNode'; /** * */ export interface IRenderPassInitialValues { - delegates: Array; - preDelegateOperations: Array; - postDelegateOperations: Array; + currentOperation?: string; + currentParent?: any; + delegates?: Array; + preDelegateOperations?: Array; + postDelegateOperations?: Array; } export interface vtkRenderPass extends vtkObject { /** * */ - getCurrentOperation(): string; + getCurrentOperation(): Nullable; /** * True when this pass captures the color texture of its delegates and @@ -31,22 +34,22 @@ export interface vtkRenderPass extends vtkObject { /** * */ - getDelegates(): any; + getDelegates(): vtkRenderPass[]; /** * */ - getOperation(): void; + getOperation(): Nullable; /** * */ - getPostDelegateOperations(): any; + getPostDelegateOperations(): string[]; /** * */ - getPreDelegateOperations(): any; + getPreDelegateOperations(): string[]; /** * @@ -77,19 +80,19 @@ export interface vtkRenderPass extends vtkObject { * * @param delegates */ - setDelegates(delegates: any): boolean; + setDelegates(delegates: vtkRenderPass[]): boolean; /** * * @param postDelegateOperations */ - setPostDelegateOperations(postDelegateOperations: any): boolean; + setPostDelegateOperations(postDelegateOperations: string[]): boolean; /** * * @param preDelegateOperations */ - setPreDelegateOperations(preDelegateOperations: any): boolean; + setPreDelegateOperations(preDelegateOperations: string[]): boolean; /** * by default this class will traverse all of its @@ -99,7 +102,7 @@ export interface vtkRenderPass extends vtkObject { * @param viewNode * @param parent */ - traverse(viewNode: vtkViewNode, parent: any): void; + traverse(viewNode: vtkViewNode, parent?: any): void; } /** diff --git a/Sources/Rendering/SceneGraph/RenderWindowViewNode/index.d.ts b/Sources/Rendering/SceneGraph/RenderWindowViewNode/index.d.ts new file mode 100644 index 00000000000..5300d7c89d8 --- /dev/null +++ b/Sources/Rendering/SceneGraph/RenderWindowViewNode/index.d.ts @@ -0,0 +1,253 @@ +import vtkHardwareSelector from '../../Core/HardwareSelector'; +import vtkRenderer from '../../Core/Renderer'; +import { Nullable, Vector2, Vector3 } from '../../../types'; +import vtkViewNode, { IViewNodeInitialValues } from '../ViewNode'; +import vtkViewNodeFactory from '../ViewNodeFactory'; + +/** + * + */ +export interface IRenderWindowViewNodeInitialValues extends IViewNodeInitialValues { + size?: Vector2; + selector?: vtkHardwareSelector; +} + +export interface vtkRenderWindowViewNode extends vtkViewNode { + /** + * Get the ratio between the width and the height of the render window. + */ + getAspectRatio(): number; + + /** + * Get the ratio between the width and the height of the renderer viewport. + * @param {vtkRenderer} renderer The vtkRenderer instance. + */ + getAspectRatioForRenderer(renderer: vtkRenderer): number; + + /** + * Get the ratio between the size of the render window and the size of its + * container. + */ + getComputedDevicePixelRatio(): number; + + /** + * Not implemented by this class, api specific subclasses provide it. + */ + getContainerSize(): void; + + /** + * Not implemented by this class, api specific subclasses provide it. + * @param {Number} x1 + * @param {Number} y1 + * @param {Number} x2 + * @param {Number} y2 + */ + getPixelData(x1: number, y1: number, x2: number, y2: number): void; + + /** + * Get the hardware selector of the render window, when a subclass created + * one. + */ + getSelector(): vtkHardwareSelector | undefined; + + /** + * Get the size of the render window. + */ + getSize(): Vector2; + + /** + * Get the size of the render window without copying it. + */ + getSizeByReference(): Vector2; + + /** + * Returns null, api specific subclasses provide their own factory. + */ + getViewNodeFactory(): Nullable; + + /** + * Get the center of the viewport. + * @param {vtkRenderer} viewport The viewport vtk element. + */ + getViewportCenter(viewport: vtkRenderer): Vector2; + + /** + * Get the size of the viewport, in pixels. + * @param {vtkRenderer} viewport The viewport vtk element. + */ + getViewportSize(viewport: vtkRenderer): Vector2; + + /** + * Not implemented by this class, api specific subclasses provide it. + */ + createSelector(): void; + + /** + * + * @param {Number} x + * @param {Number} y + * @param {Number} z + */ + displayToLocalDisplay(x: number, y: number, z: number): Vector3; + + /** + * + * @param {Number} x + * @param {Number} y + * @param {Number} z + */ + displayToNormalizedDisplay(x: number, y: number, z: number): Vector3; + + /** + * + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @param {vtkRenderer} renderer The vtkRenderer instance. + */ + displayToWorld( + x: number, + y: number, + z: number, + renderer: vtkRenderer + ): Vector3; + + /** + * Check if a point is in the viewport. + * @param {Number} x The x coordinate. + * @param {Number} y The y coordinate. + * @param {vtkRenderer} viewport The viewport vtk element. + */ + isInViewport(x: number, y: number, viewport: vtkRenderer): boolean; + + /** + * + * @param {Number} x + * @param {Number} y + * @param {Number} z + */ + normalizedDisplayToDisplay(x: number, y: number, z: number): Vector3; + + /** + * + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @param {vtkRenderer} renderer The vtkRenderer instance. + */ + normalizedDisplayToViewport( + x: number, + y: number, + z: number, + renderer: vtkRenderer + ): Vector3; + + /** + * + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @param {vtkRenderer} renderer The vtkRenderer instance. + */ + normalizedViewportToViewport( + x: number, + y: number, + z: number, + renderer: vtkRenderer + ): Vector3; + + /** + * + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @param {vtkRenderer} renderer The vtkRenderer instance. + */ + viewToWorld(x: number, y: number, z: number, renderer: vtkRenderer): Vector3; + + /** + * + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @param {vtkRenderer} renderer The vtkRenderer instance. + */ + viewportToNormalizedDisplay( + x: number, + y: number, + z: number, + renderer: vtkRenderer + ): Vector3; + + /** + * + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @param {vtkRenderer} renderer The vtkRenderer instance. + */ + viewportToNormalizedViewport( + x: number, + y: number, + z: number, + renderer: vtkRenderer + ): Vector3; + + /** + * + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @param {vtkRenderer} renderer The vtkRenderer instance. + */ + worldToDisplay( + x: number, + y: number, + z: number, + renderer: vtkRenderer + ): Vector3; + + /** + * + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @param {vtkRenderer} renderer The vtkRenderer instance. + */ + worldToView(x: number, y: number, z: number, renderer: vtkRenderer): Vector3; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkRenderWindowViewNode characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IRenderWindowViewNodeInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IRenderWindowViewNodeInitialValues +): void; + +/** + * Method used to create a new instance of vtkRenderWindowViewNode. + * @param {IRenderWindowViewNodeInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IRenderWindowViewNodeInitialValues +): vtkRenderWindowViewNode; + +/** + * vtkRenderWindowViewNode is intended to be a superclass for all api specific + * RenderWindows. It is intended to define a common API that can be invoked + * upon an api specific render window and provide some common method + * implementations. If your application requires communicating with an api + * specific view try to limit such interactions to methods defined in this + * class. + */ +export declare const vtkRenderWindowViewNode: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkRenderWindowViewNode; diff --git a/Sources/Rendering/SceneGraph/ViewNode/index.d.ts b/Sources/Rendering/SceneGraph/ViewNode/index.d.ts index 493e01db67b..af9f009506a 100644 --- a/Sources/Rendering/SceneGraph/ViewNode/index.d.ts +++ b/Sources/Rendering/SceneGraph/ViewNode/index.d.ts @@ -1,10 +1,12 @@ -import { vtkObject } from '../../../interfaces'; +import { EventHandler, vtkObject, vtkSubscription } from '../../../interfaces'; +import { Nullable } from '../../../types'; import vtkRenderPass from '../RenderPass'; +import vtkViewNodeFactory from '../ViewNodeFactory'; -export enum PASS_TYPES { - Build, - Render, -} +/** + * The traversal passes a view node supports, in traversal order. + */ +declare const PASS_TYPES: readonly string[]; /** * @@ -43,6 +45,13 @@ export interface vtkViewNode extends vtkObject { */ addMissingNodes(dataObjs: any, enforceOrder?: boolean): void; + /** + * Adopt child nodes that have no renderable of their own, so that a node can + * delegate passes to a helper. + * @param children + */ + addMissingChildren(children: vtkViewNode[]): void; + /** * * @param {vtkRenderPass} renderPass @@ -60,44 +69,44 @@ export interface vtkViewNode extends vtkObject { * * @param dataObj */ - createViewNode(dataObj: any): void; + createViewNode(dataObj: any): vtkViewNode | null; /** * */ - getChildren(): any; + getChildren(): vtkViewNode[]; /** * */ - getChildrenByReference(): any; + getChildrenByReference(): vtkViewNode[]; /** * Find the first parent/grandparent of the desired type * @param type */ - getFirstAncestorOfType(type: any): void; + getFirstAncestorOfType(type: any): vtkViewNode | null; /** * Find the last parent/grandparent of the desired type * @param type */ - getLastAncestorOfType(type: any): void; + getLastAncestorOfType(type: any): vtkViewNode | null; /** * */ - getMyFactory(): any; + getMyFactory(): Nullable; /** * */ - getParent(): any; + getParent(): Nullable; /** * Get The data object (thing to be rendered). */ - getRenderable(): any; + getRenderable(): Nullable; /** * Returns the view node that corresponding to the provided object @@ -105,15 +114,15 @@ export interface vtkViewNode extends vtkObject { * @param dataObject * @param [hint] the previously found node (for optimization) */ - getViewNodeFor(dataObject: any, hint?: any): any; + getViewNodeFor(dataObject: any, hint?: any): vtkViewNode | undefined; /** * */ getVisited(): boolean; - //invokeEvent - //onEvent(callback: (instance: vtkObject) => any): vtkSubscription; + invokeEvent(...args: unknown[]): void; + onEvent(cb: EventHandler, priority?: number): vtkSubscription; /** * @@ -135,19 +144,19 @@ export interface vtkViewNode extends vtkObject { * * @param myFactory */ - setMyFactory(myFactory: any): boolean; + setMyFactory(myFactory: Nullable): boolean; /** * * @param parent */ - setParent(parent: any): boolean; + setParent(parent: Nullable): boolean; /** * * @param renderable */ - setRenderable(renderable: any): boolean; + setRenderable(renderable: Nullable): boolean; /** * @@ -170,7 +179,7 @@ export interface vtkViewNode extends vtkObject { * @param model object on which data structure will be bounds (protected) * @param {IViewNodeInitialValues} [initialValues] (default: {}) */ -export function extend( +declare function extend( publicAPI: object, model: object, initialValues?: IViewNodeInitialValues @@ -180,7 +189,7 @@ export function extend( * Method used to create a new instance of vtkViewNode. * @param {IViewNodeInitialValues} [initialValues] for pre-setting some of its content */ -export function newInstance( +declare function newInstance( initialValues?: IViewNodeInitialValues ): vtkViewNode; @@ -196,5 +205,7 @@ export function newInstance( export declare const vtkViewNode: { newInstance: typeof newInstance; extend: typeof extend; + // constants + PASS_TYPES: typeof PASS_TYPES; }; export default vtkViewNode; diff --git a/Sources/Rendering/SceneGraph/ViewNodeFactory/index.d.ts b/Sources/Rendering/SceneGraph/ViewNodeFactory/index.d.ts index 9b2cc9fc541..5aab6ff4487 100644 --- a/Sources/Rendering/SceneGraph/ViewNodeFactory/index.d.ts +++ b/Sources/Rendering/SceneGraph/ViewNodeFactory/index.d.ts @@ -1,4 +1,5 @@ import { vtkObject } from '../../../interfaces'; +import { vtkViewNode } from '../ViewNode'; /** * @@ -10,7 +11,7 @@ export interface vtkViewNodeFactory extends vtkObject { * Creates and returns a vtkViewNode for the provided renderable. * @param dataObject */ - createNode(dataObject: any): void; + createNode(dataObject: any): vtkViewNode | null; } /** diff --git a/Sources/Rendering/WebGPU/Actor/index.d.ts b/Sources/Rendering/WebGPU/Actor/index.d.ts new file mode 100644 index 00000000000..d810ffa7cc3 --- /dev/null +++ b/Sources/Rendering/WebGPU/Actor/index.d.ts @@ -0,0 +1,111 @@ +import { vtkObject } from '../../../interfaces'; +import { Vector4 } from '../../../types'; +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; +import { vtkWebGPURenderer } from '../Renderer'; + +/** + * The cached matrices recomputed whenever the renderable or the stabilized + * center of the renderer changes. `bcwc` maps buffer coordinates to world + * coordinates and `bcsc` maps them to stabilized coordinates. + */ +export interface IWebGPUActorKeyMatrices { + normalMatrix: Float64Array; + bcwc: Float64Array; + bcsc: Float64Array; +} + +export interface IWebGPUActorInitialValues extends IViewNodeInitialValues { + propID?: number; +} + +export interface vtkWebGPUActor extends vtkViewNode { + /** + * Builds myself: resolve the renderer and render window, claim a prop id and + * adopt the renderable's mapper as a child. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * Render both opaque and translucent actors. + * @param {vtkRenderPass} renderPass + */ + traverseZBufferPass(renderPass: vtkRenderPass): void; + + /** + * Render only opaque actors. + * @param {vtkRenderPass} renderPass + */ + traverseOpaqueZBufferPass(renderPass: vtkRenderPass): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseOpaquePass(renderPass: vtkRenderPass): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseTranslucentPass(renderPass: vtkRenderPass): void; + + /** + * @param prepass + * @param {vtkRenderPass} renderPass + */ + queryPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * The translation applied to the vertex buffers of this actor to keep them + * near the origin. Recomputes the key matrices if needed. + * @param {vtkWebGPURenderer} wgpuRen + */ + getBufferShift(wgpuRen: vtkWebGPURenderer): Vector4; + + /** + * Recompute the buffer to world/stabilized and normal matrices if the + * renderable or the stabilized center moved. + * @param {vtkWebGPURenderer} wgpuRen + */ + getKeyMatrices(wgpuRen: vtkWebGPURenderer): IWebGPUActorKeyMatrices; + + /** + * The identifier used by hardware selection to recognize this prop. + */ + getPropID(): number; + + /** + * The time stamp guarding the cached key matrices. + */ + getKeyMatricesTime(): vtkObject; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUActor characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUActorInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUActorInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUActor. + * @param {IWebGPUActorInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUActorInitialValues +): vtkWebGPUActor; + +/** + * The WebGPU backend view node for a vtkActor. + */ +export declare const vtkWebGPUActor: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUActor; diff --git a/Sources/Rendering/WebGPU/Actor2D/index.d.ts b/Sources/Rendering/WebGPU/Actor2D/index.d.ts new file mode 100644 index 00000000000..2a69bddfe21 --- /dev/null +++ b/Sources/Rendering/WebGPU/Actor2D/index.d.ts @@ -0,0 +1,99 @@ +import { vtkObject } from '../../../interfaces'; +import { Vector4 } from '../../../types'; +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; +import { vtkWebGPURenderer } from '../Renderer'; + +/** + * The cached matrices recomputed whenever the renderable or the stabilized + * center of the renderer changes. Both are identity up to the buffer shift, + * since a 2D actor is not transformed by its own matrix. + */ +export interface IWebGPUActor2DKeyMatrices { + normalMatrix: Float64Array; + bcwc: Float64Array; + bcsc: Float64Array; +} + +export interface IWebGPUActor2DInitialValues extends IViewNodeInitialValues { + propID?: number; +} + +export interface vtkWebGPUActor2D extends vtkViewNode { + /** + * Builds myself: resolve the renderer and render window, claim a prop id and + * adopt the renderable's mapper as a child. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseOpaquePass(renderPass: vtkRenderPass): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseTranslucentPass(renderPass: vtkRenderPass): void; + + /** + * @param prepass + * @param {vtkRenderPass} renderPass + */ + queryPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * The translation applied to the vertex buffers of this actor to keep them + * near the origin. Recomputes the key matrices if needed. + * @param {vtkWebGPURenderer} wgpuRen + */ + getBufferShift(wgpuRen: vtkWebGPURenderer): Vector4; + + /** + * Recompute the buffer to world/stabilized and normal matrices if the + * renderable or the stabilized center moved. + * @param {vtkWebGPURenderer} wgpuRen + */ + getKeyMatrices(wgpuRen: vtkWebGPURenderer): IWebGPUActor2DKeyMatrices; + + /** + * The identifier used by hardware selection to recognize this prop. + */ + getPropID(): number; + + /** + * The time stamp guarding the cached key matrices. + */ + getKeyMatricesTime(): vtkObject; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUActor2D characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUActor2DInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUActor2DInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUActor2D. + * @param {IWebGPUActor2DInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUActor2DInitialValues +): vtkWebGPUActor2D; + +/** + * The WebGPU backend view node for a vtkActor2D. + */ +export declare const vtkWebGPUActor2D: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUActor2D; diff --git a/Sources/Rendering/WebGPU/Background/index.d.ts b/Sources/Rendering/WebGPU/Background/index.d.ts new file mode 100644 index 00000000000..6883931b683 --- /dev/null +++ b/Sources/Rendering/WebGPU/Background/index.d.ts @@ -0,0 +1,140 @@ +import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; +import vtkRenderer from '../../Core/Renderer'; +import vtkTexture from '../../Core/Texture'; +import vtkWebGPUCamera from '../Camera'; +import vtkWebGPUDevice from '../Device'; +import vtkWebGPUFullScreenQuad from '../FullScreenQuad'; +import vtkWebGPURenderEncoder from '../RenderEncoder'; +import vtkWebGPURenderer from '../Renderer'; +import vtkWebGPUUniformBuffer from '../UniformBuffer'; + +/** + * How a renderer's background is drawn: a flat color, a vertical gradient + * between the two background colors, a background texture, or the environment + * texture sampled along the view direction. + */ +export type WebGPUBackgroundMode = + | 'solid' + | 'gradient' + | 'texture' + | 'environment'; + +/** + * The background mode of a renderer, together with the texture it samples. + */ +export interface IWebGPUBackgroundDescription { + mode: WebGPUBackgroundMode; + + /** + * The texture sampled by the texture and environment modes, `null` for the + * solid and gradient modes. + */ + texture: Nullable; + + /** + * The WGSL name the texture is bound under, `null` when there is none. + */ + textureName: Nullable; + + /** + * The pipeline hash of the mode. + */ + pipelineHash: string; +} + +export interface IWebGPUBackgroundInitialValues { + quad?: Nullable; + UBO?: Nullable; + webgpuCamera?: Nullable; +} + +export interface vtkWebGPUBackground extends vtkObject { + /** + * Work out how a renderer's background must be drawn. A background or + * environment texture is only used once its image has loaded, and a + * gradient is only used when the two background colors differ. + * @param {vtkRenderer} renderer The renderer to inspect. + */ + getMode(renderer: vtkRenderer): IWebGPUBackgroundDescription; + + /** + * Create the full screen quad and its uniform buffer, once. + * @param device The device to create them on. + */ + ensureQuad(device: vtkWebGPUDevice): void; + + /** + * Get the fragment shader template of a background mode. + * @param mode The background mode. + */ + getFragmentTemplate(mode: WebGPUBackgroundMode): string; + + /** + * Bind the texture of the current background mode to the quad, or clear the + * bound views when there is no texture or it is not uploaded yet. + * @param device The device the texture is created on. + * @param texture The vtkTexture to bind, if any. + * @param textureName The WGSL name to bind it under, if any. + */ + updateTexture( + device: vtkWebGPUDevice, + texture: Nullable, + textureName: Nullable + ): void; + + /** + * Write the background colors and the full screen quad matrix into the + * uniform buffer, and send it when it changed. + * @param device The device to send the buffer to. + * @param {vtkWebGPURenderer} rendererNode The renderer view node. + * @param {vtkRenderer} renderer The renderer holding the colors. + */ + updateUBO( + device: vtkWebGPUDevice, + rendererNode: vtkWebGPURenderer, + renderer: vtkRenderer + ): void; + + /** + * Draw the background of a renderer into the given encoder. + * @param {vtkWebGPURenderEncoder} renderEncoder The encoder to draw into. + * @param {vtkWebGPURenderer} rendererNode The renderer view node. + */ + render( + renderEncoder: vtkWebGPURenderEncoder, + rendererNode: vtkWebGPURenderer + ): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUBackground characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUBackgroundInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUBackgroundInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUBackground. + * @param {IWebGPUBackgroundInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUBackgroundInitialValues +): vtkWebGPUBackground; + +/** + * vtkWebGPUBackground draws the background of a renderer with a full screen + * quad, picking the solid, gradient, texture or environment shader from the + * renderer's own background settings. + */ +export declare const vtkWebGPUBackground: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUBackground; diff --git a/Sources/Rendering/WebGPU/BindGroup/index.d.ts b/Sources/Rendering/WebGPU/BindGroup/index.d.ts new file mode 100644 index 00000000000..7f49c5029db --- /dev/null +++ b/Sources/Rendering/WebGPU/BindGroup/index.d.ts @@ -0,0 +1,121 @@ +/// + +import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; +import vtkWebGPUDevice from '../Device'; + +/** + * What a bind group requires of the objects it binds, such as uniform + * buffers, storage buffers, texture views and samplers. + */ +export interface IWebGPUBindable { + setDevice?(device: vtkWebGPUDevice): boolean | void; + getBindGroupLayoutEntry(): Partial; + getBindGroupEntry(): Omit; + getBindGroupTime(): vtkObject; + getShaderCode(binding: number, group: number): string; +} + +export interface IWebGPUBindGroupInitialValues { + device?: vtkWebGPUDevice; + handle?: unknown; + bindGroupDevice?: vtkWebGPUDevice; + label?: string; +} + +export interface vtkWebGPUBindGroup extends vtkObject { + /** + * Set the objects bound by this group, in binding order. The object is only + * modified when the list actually changed. + * @param bindables The objects to bind. + */ + setBindables(bindables: IWebGPUBindable[]): void; + + /** + * Get the bind group layout of the current bindables from the device cache. + * @param device The device to create the layout on. + */ + getBindGroupLayout(device: vtkWebGPUDevice): Nullable; + + /** + * Get the bind group, recreating it when the device or any bindable + * changed since the last call. + * @param device The device to create the bind group on. + */ + getBindGroup(device: vtkWebGPUDevice): GPUBindGroup; + + /** + * Get the WGSL declarations of every bindable, using the group index this + * bind group has in the given pipeline. + * @param pipeline The vtkWebGPUPipeline the shader code is built for. + */ + getShaderCode(pipeline: any): string; + + /** + * Drop the bind group so that it is recreated on the next getBindGroup. + */ + releaseGraphicsResources(): void; + + /** + * Get the object whose modified time changes when the bind group is + * recreated. + */ + getBindGroupTime(): vtkObject; + + getHandle(): unknown; + + getSizeInBytes(): number; + + getUsage(): unknown; + + /** + * Get the WGSL name of the bind group. + */ + getLabel(): Nullable; + + /** + * Set the WGSL name of the bind group. + */ + setLabel(label: string): boolean; + + /** + * Get the device this bind group belongs to. + */ + getDevice(): Nullable; + + /** + * Set the device this bind group belongs to. + */ + setDevice(device: vtkWebGPUDevice): boolean; + + getArrayInformation(): unknown; + + setArrayInformation(arrayInformation: unknown): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUBindGroup characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUBindGroupInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUBindGroupInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUBindGroup. + * @param {IWebGPUBindGroupInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUBindGroupInitialValues +): vtkWebGPUBindGroup; + +export declare const vtkWebGPUBindGroup: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUBindGroup; diff --git a/Sources/Rendering/WebGPU/Buffer/index.d.ts b/Sources/Rendering/WebGPU/Buffer/index.d.ts new file mode 100644 index 00000000000..46ad7a2601d --- /dev/null +++ b/Sources/Rendering/WebGPU/Buffer/index.d.ts @@ -0,0 +1,163 @@ +/// + +import { vtkObject } from '../../../interfaces'; +import { Nullable, TypedArray } from '../../../types'; +import { BufferUsage, PrimitiveTypes } from '../BufferManager/Constants'; +import vtkWebGPUDevice from '../Device'; + +/** + * Description of a single vertex attribute stored inside a buffer. + */ +export interface IWebGPUBufferArrayInformation { + offset?: number; + format: string; + interpolation?: string; +} + +export interface IWebGPUBufferInitialValues { + device?: vtkWebGPUDevice; + handle?: GPUBuffer; + sizeInBytes?: number; + strideInBytes?: number; + arrayInformation?: IWebGPUBufferArrayInformation[]; + usage?: GPUBufferUsageFlags; + label?: string; + sourceTime?: number; +} + +export interface vtkWebGPUBuffer extends vtkObject { + /** + * Allocate the underlying GPU buffer without writing to it. + * @param sizeInBytes The size of the buffer. + * @param usage The GPUBufferUsage flags of the buffer. + */ + create(sizeInBytes: number, usage: GPUBufferUsageFlags): void; + + /** + * Copy data into the already created GPU buffer. + * @param data The data to write, starting at offset zero. + */ + write(data: TypedArray): void; + + /** + * Allocate the GPU buffer, padded to a multiple of four bytes, and fill it. + * @param data The data to write. + * @param usage The GPUBufferUsage flags of the buffer. + */ + createAndWrite(data: TypedArray, usage: GPUBufferUsageFlags): void; + + /** + * Forwarded to the underlying GPUBuffer. + */ + getMappedRange(offset?: number, size?: number): ArrayBuffer; + + /** + * Forwarded to the underlying GPUBuffer. + */ + mapAsync( + mode: GPUMapModeFlags, + offset?: number, + size?: number + ): Promise; + + /** + * Forwarded to the underlying GPUBuffer. + */ + unmap(): void; + + /** + * Get the underlying GPUBuffer. + */ + getHandle(): Nullable; + + /** + * Get the size of the allocated buffer in bytes. + */ + getSizeInBytes(): number; + + /** + * Get the GPUBufferUsage flags the buffer was created with. + */ + getUsage(): Nullable; + + /** + * Get the stride, in bytes, between two consecutive vertices. + */ + getStrideInBytes(): number; + + /** + * Set the stride, in bytes, between two consecutive vertices. + */ + setStrideInBytes(strideInBytes: number): boolean; + + /** + * Get the device this buffer belongs to. + */ + getDevice(): Nullable; + + /** + * Set the device this buffer belongs to. + */ + setDevice(device: vtkWebGPUDevice): boolean; + + /** + * Get the description of the attributes packed into this buffer. + */ + getArrayInformation(): Nullable; + + /** + * Set the description of the attributes packed into this buffer. + */ + setArrayInformation( + arrayInformation: IWebGPUBufferArrayInformation[] + ): boolean; + + /** + * Get the label used when creating the GPUBuffer. + */ + getLabel(): Nullable; + + /** + * Set the label used when creating the GPUBuffer. + */ + setLabel(label: string): boolean; + + /** + * Get the modified time of the data this buffer was built from. + */ + getSourceTime(): Nullable; + + /** + * Set the modified time of the data this buffer was built from. + */ + setSourceTime(sourceTime: number): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUBuffer characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUBufferInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUBufferInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUBuffer. + * @param {IWebGPUBufferInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUBufferInitialValues +): vtkWebGPUBuffer; + +export declare const vtkWebGPUBuffer: { + newInstance: typeof newInstance; + extend: typeof extend; + BufferUsage: typeof BufferUsage; + PrimitiveTypes: typeof PrimitiveTypes; +}; +export default vtkWebGPUBuffer; diff --git a/Sources/Rendering/WebGPU/BufferManager/Constants.d.ts b/Sources/Rendering/WebGPU/BufferManager/Constants.d.ts new file mode 100644 index 00000000000..fa425231fcd --- /dev/null +++ b/Sources/Rendering/WebGPU/BufferManager/Constants.d.ts @@ -0,0 +1,38 @@ +export declare const BufferUsage: { + readonly Verts: 0; + readonly Lines: 1; + readonly Triangles: 2; + readonly Strips: 3; + readonly LinesFromStrips: 4; + readonly LinesFromTriangles: 5; + readonly Points: 6; + readonly UniformArray: 7; + readonly PointArray: 8; + readonly NormalsFromPoints: 9; + readonly Texture: 10; + readonly RawVertex: 11; + readonly Storage: 12; + readonly Index: 13; +}; + +export type BufferUsage = (typeof BufferUsage)[keyof typeof BufferUsage]; + +export declare const PrimitiveTypes: { + readonly Start: 0; + readonly Points: 0; + readonly Lines: 1; + readonly Triangles: 2; + readonly TriangleStrips: 3; + readonly TriangleEdges: 4; + readonly TriangleStripEdges: 5; + readonly End: 6; +}; + +export type PrimitiveTypes = + (typeof PrimitiveTypes)[keyof typeof PrimitiveTypes]; + +declare const _default: { + BufferUsage: typeof BufferUsage; + PrimitiveTypes: typeof PrimitiveTypes; +}; +export default _default; diff --git a/Sources/Rendering/WebGPU/BufferManager/index.d.ts b/Sources/Rendering/WebGPU/BufferManager/index.d.ts new file mode 100644 index 00000000000..5ed801df5c3 --- /dev/null +++ b/Sources/Rendering/WebGPU/BufferManager/index.d.ts @@ -0,0 +1,158 @@ +/// + +import { vtkObject } from '../../../interfaces'; +import { Nullable, TypedArray } from '../../../types'; +import vtkCellArray from '../../../Common/Core/CellArray'; +import vtkDataArray from '../../../Common/Core/DataArray'; +import { Representation } from '../../Core/Property/Constants'; +import vtkWebGPUBuffer from '../Buffer'; +import vtkWebGPUDevice from '../Device'; +import vtkWebGPUIndexBuffer from '../IndexBuffer'; +import { BufferUsage, PrimitiveTypes } from './Constants'; + +/** + * Description of a buffer to create or look up in the device object cache. + * Which fields are required depends on the requested usage. + */ +export interface IWebGPUBufferRequest { + /** + * When set, the created buffer is cached on the device under this hash. + */ + hash?: string; + usage: BufferUsage; + label?: string; + /** + * Modified time of the data the buffer is built from, stored as the + * buffer source time. + */ + time?: number; + /** + * WebGPU format string, e.g. 'float32x3' or 'uint16'. + */ + format?: string; + interpolation?: string; + nativeArray?: TypedArray; + dataArray?: vtkDataArray; + indexBuffer?: vtkWebGPUIndexBuffer; + cells?: vtkCellArray; + numberOfPoints?: number; + primitiveType?: PrimitiveTypes; + representation?: Representation; + /** + * Store point ids directly and use the primitive index to look up cell data. + */ + pointIds?: boolean; + cellData?: boolean; + cellOffset?: number; + packExtra?: boolean; + shift?: number | number[]; + scale?: number | number[]; +} + +export interface IWebGPUBufferManagerInitialValues { + device?: vtkWebGPUDevice; + fullScreenQuadBuffer?: vtkWebGPUBuffer; +} + +export interface vtkWebGPUBufferManager extends vtkObject { + /** + * Get the buffer cached on the device under the given hash, if any. + * @param hash The buffer hash. + */ + hasBuffer(hash: string): unknown; + + /** + * Get or create the buffer described by the request. When the request has a + * hash, the buffer is looked up in and stored into the device object cache. + * @param {IWebGPUBufferRequest} req The buffer request. + */ + getBuffer(req: IWebGPUBufferRequest): vtkWebGPUBuffer; + + /** + * Get a cached read only storage buffer. The array is created only when the + * device cache does not contain the hash. + */ + getStorageBuffer( + hash: string, + createNativeArray: () => TypedArray, + label?: string + ): vtkWebGPUBuffer; + + /** + * Get generated cell normals, one snorm8x4 value per cell, as a storage buffer. + */ + getStorageBufferForCellNormals( + cells: vtkCellArray, + points: vtkDataArray + ): vtkWebGPUBuffer; + + /** + * Get or create a vertex buffer holding the point data of the given array, + * expanded through the flat ids of the index buffer. + * @param dataArray The point data array. + * @param indexBuffer The index buffer providing the flat id mapping. + */ + getBufferForPointArray( + dataArray: vtkDataArray, + indexBuffer: vtkWebGPUIndexBuffer + ): vtkWebGPUBuffer; + + /** + * Get or create a vertex buffer holding the cell data of the given array, + * expanded through the flat ids of the index buffer. + * @param dataArray The cell data array. + * @param indexBuffer The index buffer providing the flat id mapping. + * @param {Number} [cellOffset] (default: 0) + */ + getBufferForCellArray( + dataArray: vtkDataArray, + indexBuffer: vtkWebGPUIndexBuffer, + cellOffset?: number + ): vtkWebGPUBuffer; + + /** + * Get the shared six vertex buffer covering the whole screen. + */ + getFullScreenQuadBuffer(): vtkWebGPUBuffer; + + /** + * Get the device the created buffers belong to. + */ + getDevice(): Nullable; + + /** + * Set the device the created buffers belong to. + */ + setDevice(device: vtkWebGPUDevice): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUBufferManager characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUBufferManagerInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUBufferManagerInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUBufferManager. + * @param {IWebGPUBufferManagerInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUBufferManagerInitialValues +): vtkWebGPUBufferManager; + +export declare const STATIC: Readonly>; + +export declare const vtkWebGPUBufferManager: { + newInstance: typeof newInstance; + extend: typeof extend; + BufferUsage: typeof BufferUsage; + PrimitiveTypes: typeof PrimitiveTypes; +}; +export default vtkWebGPUBufferManager; diff --git a/Sources/Rendering/WebGPU/Camera/index.d.ts b/Sources/Rendering/WebGPU/Camera/index.d.ts new file mode 100644 index 00000000000..fcd3a0be632 --- /dev/null +++ b/Sources/Rendering/WebGPU/Camera/index.d.ts @@ -0,0 +1,92 @@ +import { vtkObject } from '../../../interfaces'; +import { Vector2 } from '../../../types'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; +import { vtkWebGPURenderer } from '../Renderer'; + +/** + * The cached camera matrices, recomputed whenever the camera, the renderer, + * the render window or the stabilized center changes. `sc` denotes stabilized + * coordinates, `vc` view coordinates and `pc` projection coordinates. + */ +export interface IWebGPUCameraKeyMatrices { + normalMatrix: Float64Array; + vcpc: Float64Array; + pcsc: Float64Array; + wcvc: Float64Array; + scpc: Float64Array; + scvc: Float64Array; +} + +export interface IWebGPUCameraInitialValues extends IViewNodeInitialValues { + keyMatrixTime?: vtkObject; +} + +export interface vtkWebGPUCamera extends vtkViewNode { + /** + * Fill the given matrix with the WebGPU projection matrix, whose depth range + * is [0, 1] rather than the OpenGL [-1, 1]. + * @param outMat the 4x4 matrix to write into + * @param aspect the viewport aspect ratio + * @param cRange the clipping range + * @param windowCenter the normalized window center + */ + getProjectionMatrix( + outMat: Float64Array, + aspect: number, + cRange: Vector2, + windowCenter: Vector2 + ): void; + + /** + * Convert a WebGPU depth value into the equivalent OpenGL depth value. + * @param val + */ + convertToOpenGLDepth(val: number): number; + + /** + * Recompute the view/projection matrices if the camera, the renderer, the + * render window or the stabilized center changed since the last call. + * @param {vtkWebGPURenderer} webGPURenderer + */ + getKeyMatrices(webGPURenderer: vtkWebGPURenderer): IWebGPUCameraKeyMatrices; + + /** + * The time stamp guarding the cached key matrices. + */ + getKeyMatrixTime(): vtkObject; + + /** + * @param keyMatrixTime + */ + setKeyMatrixTime(keyMatrixTime: vtkObject): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUCamera characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUCameraInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUCameraInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUCamera. + * @param {IWebGPUCameraInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUCameraInitialValues +): vtkWebGPUCamera; + +/** + * The WebGPU backend view node for a vtkCamera. + */ +export declare const vtkWebGPUCamera: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUCamera; diff --git a/Sources/Rendering/WebGPU/CellArrayMapper/index.d.ts b/Sources/Rendering/WebGPU/CellArrayMapper/index.d.ts new file mode 100644 index 00000000000..2cd454055f9 --- /dev/null +++ b/Sources/Rendering/WebGPU/CellArrayMapper/index.d.ts @@ -0,0 +1,345 @@ +/// + +import vtkCellArray from '../../../Common/Core/CellArray'; +import vtkPolyData from '../../../Common/DataModel/PolyData'; +import { ICoincidentTopology } from '../../Core/Mapper/CoincidentTopologyHelper'; +import { Representation } from '../../Core/Property/Constants'; +import { BufferUsage, PrimitiveTypes } from '../BufferManager/Constants'; +import vtkWebGPUPipeline, { IWebGPUPipelineSettings } from '../Pipeline'; +import vtkWebGPURenderEncoder from '../RenderEncoder'; +import vtkWebGPUSimpleMapper, { + IWebGPUSimpleMapperInitialValues, +} from '../SimpleMapper'; +import vtkWebGPUVertexInput from '../VertexInput'; + +export interface IWebGPUCellArrayMapperInitialValues extends IWebGPUSimpleMapperInitialValues { + depthOnlyPass?: boolean; + selectionPass?: boolean; + is2D?: boolean; + cellArray?: vtkCellArray; + currentInput?: vtkPolyData; + cellOffset?: number; + primitiveType?: PrimitiveTypes; + colorTexture?: unknown; + renderEncoder?: vtkWebGPURenderEncoder; + textures?: unknown[]; + usePrimitiveIndex?: boolean; +} + +export interface vtkWebGPUCellArrayMapper extends vtkWebGPUSimpleMapper { + /** + * Locate the actor, renderer, render window and device this mapper draws + * through, and pick the coordinate system from the actor. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * Whether this mapper draws the edges of triangles or triangle strips. + */ + isEdgePrimitive(): boolean; + + /** + * Whether this pass should be skipped, which is the case for edges during + * the depth only and the selection passes. + */ + shouldSkipPass(): boolean; + + /** + * Prepare and register the draw callback of this mapper on an encoder. + * @param {vtkWebGPURenderEncoder} renderEncoder + * @param {Boolean} [depthOnly] (default: false) + */ + renderForPass( + renderEncoder: vtkWebGPURenderEncoder, + depthOnly?: boolean + ): void; + + /** + * @param prepass + */ + translucentPass(prepass: boolean): void; + + /** + * @param prepass + */ + opaquePass(prepass: boolean): void; + + /** + * @param prepass + */ + zBufferPass(prepass: boolean): void; + + /** + * @param prepass + */ + opaqueZBufferPass(prepass: boolean): void; + + /** + * Fill the mapper uniform buffer from the actor matrices, its property and + * the clipping planes of the renderable, then send it if anything changed. + */ + updateUBO(): void; + + /** + * Whether the primitive is drawn as wide lines, which are emulated with one + * instance per pixel of line width. + */ + haveWideLines(): boolean; + + /** + * Get the cull mode from the front and back face culling flags of the + * actor's property. + */ + getCullMode(): GPUCullMode; + + /** + * Get the pipeline settings: the cull mode, plus a color target with writes + * masked off during the depth only pass. + */ + getPipelineSettings(): IWebGPUPipelineSettings; + + /** + * Get the polygon offset factor and offset applied to this primitive, from + * the coincident topology resolution of the renderable. Point picking always + * adds an offset. + */ + getCoincidentParameters(): ICoincidentTopology; + + /** + * Add the fragment shader's vtkCellId helper and cell texture coordinates + * when the mapper uses primitive-index. + */ + addCellIdToFragmentShader(pipeline: vtkWebGPUPipeline): void; + + /** + * Get the WGSL matrix expression transforming cell normals to world space. + */ + getCellNormalMatrix(): string; + + /** + * Whether cell normals are read from a storage buffer. + */ + usesCellNormals(): boolean; + + /** Update the storage buffer holding the skinning transforms. */ + updateSkinSSBO(): void; + + /** Update the storage buffer holding cell scalar colors. */ + updateCellScalarSSBO(): void; + + /** Apply the alpha mode of the actor's property to the fragment shader. */ + replaceShaderAlpha( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderPosition( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderCoincidentOffset( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderNormal( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderLight( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderColor( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderTCoord( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderSelect( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * Get the buffer usage the primitive is drawn with for a representation. + * @param {Representation} rep the representation of the actor's property + * @param {PrimitiveTypes} i the primitive type + */ + getUsage(rep: Representation, i: PrimitiveTypes): BufferUsage; + + /** + * Get the part of the pipeline hash that depends on the buffer usage. + * @param {BufferUsage} usage + */ + getHashFromUsage(usage: BufferUsage): string; + + /** + * Get the primitive topology a buffer usage is drawn with. + * @param {BufferUsage} usage + */ + getTopologyFromUsage(usage: BufferUsage): GPUPrimitiveTopology; + + /** + * Build the vertex input of this mapper: the point, normal, color and + * texture coordinate buffers of the cell array, plus the index buffer when + * the primitive needs one. + */ + buildVertexInput(): void; + + /** + * Create the texture views and samplers of the textures of the renderable, + * dropping the ones that are no longer used. + */ + updateTextures(): void; + + /** + * Get the cell array this mapper draws. + */ + getCellArray(): vtkCellArray; + + /** + * Set the cell array this mapper draws. + * @param {vtkCellArray} cellArray + */ + setCellArray(cellArray: vtkCellArray): boolean; + + /** + * Get the polydata the cell array belongs to. + */ + getCurrentInput(): vtkPolyData; + + /** + * Set the polydata the cell array belongs to. + * @param {vtkPolyData} currentInput + */ + setCurrentInput(currentInput: vtkPolyData): boolean; + + /** + * Get the index of the first cell of this cell array within the polydata, + * used to look up cell data. + */ + getCellOffset(): number; + + /** + * Set the index of the first cell of this cell array within the polydata. + * @param {Number} cellOffset + */ + setCellOffset(cellOffset: number): boolean; + + /** + * Get whether this mapper draws in 2D, i.e. under a vtkWebGPUActor2D. + */ + getIs2D(): boolean; + + /** + * Set whether this mapper draws in 2D, i.e. under a vtkWebGPUActor2D. + * @param {Boolean} is2D + */ + setIs2D(is2D: boolean): boolean; + + /** + * Get the primitive type of the cell array. + */ + getPrimitiveType(): PrimitiveTypes; + + /** + * Set the primitive type of the cell array. + * @param {PrimitiveTypes} primitiveType + */ + setPrimitiveType(primitiveType: PrimitiveTypes): boolean; + + /** + * Get the render encoder this mapper last drew through. + */ + getRenderEncoder(): vtkWebGPURenderEncoder; + + /** + * Set the render encoder this mapper draws through. + * @param {vtkWebGPURenderEncoder} renderEncoder + */ + setRenderEncoder(renderEncoder: vtkWebGPURenderEncoder): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUCellArrayMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUCellArrayMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUCellArrayMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUCellArrayMapper. + * @param {IWebGPUCellArrayMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUCellArrayMapperInitialValues +): vtkWebGPUCellArrayMapper; + +/** + * Draws one cell array of a polydata. The WebGPU polydata mappers create one + * of these per non empty cell array, and this class assembles the shader code, + * the vertex input and the uniform buffer of that primitive. + */ +export declare const vtkWebGPUCellArrayMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUCellArrayMapper; diff --git a/Sources/Rendering/WebGPU/CubeAxesActor/index.d.ts b/Sources/Rendering/WebGPU/CubeAxesActor/index.d.ts new file mode 100644 index 00000000000..aebe8624e74 --- /dev/null +++ b/Sources/Rendering/WebGPU/CubeAxesActor/index.d.ts @@ -0,0 +1,51 @@ +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; + +export interface IWebGPUCubeAxesActorInitialValues extends IViewNodeInitialValues {} + +export interface vtkWebGPUCubeAxesActor extends vtkViewNode { + /** + * Builds myself: bind the cube axes helper to the renderable and adopt the + * text actor and the renderable's grid actor as children. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * Renders myself: hand the viewport size, the active camera and the render + * window to the cube axes helper. + * @param prepass + * @param {vtkRenderPass} renderPass + */ + opaquePass(prepass: boolean, renderPass: vtkRenderPass): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUCubeAxesActor characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUCubeAxesActorInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUCubeAxesActorInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUCubeAxesActor. + * @param {IWebGPUCubeAxesActorInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUCubeAxesActorInitialValues +): vtkWebGPUCubeAxesActor; + +/** + * The WebGPU backend view node for a vtkCubeAxesActor. + */ +export declare const vtkWebGPUCubeAxesActor: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUCubeAxesActor; diff --git a/Sources/Rendering/WebGPU/CutterMapper/index.d.ts b/Sources/Rendering/WebGPU/CutterMapper/index.d.ts new file mode 100644 index 00000000000..9bf15dee397 --- /dev/null +++ b/Sources/Rendering/WebGPU/CutterMapper/index.d.ts @@ -0,0 +1,45 @@ +import vtkWebGPUCellArrayMapper from '../CellArrayMapper'; +import vtkWebGPUPolyDataMapper, { + IWebGPUPolyDataMapperInitialValues, +} from '../PolyDataMapper'; + +export interface IWebGPUCutterMapperInitialValues extends IWebGPUPolyDataMapperInitialValues {} + +export interface vtkWebGPUCutterMapper extends vtkWebGPUPolyDataMapper { + /** + * Create a cell array mapper whose shaders cut the geometry against the + * implicit function of the renderable's cut function. + */ + createCellArrayMapper(): vtkWebGPUCellArrayMapper; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUCutterMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUCutterMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUCutterMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUCutterMapper. + * @param {IWebGPUCutterMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUCutterMapperInitialValues +): vtkWebGPUCutterMapper; + +/** + * The WebGPU view node of vtkCutterMapper. It cuts the input geometry on the + * GPU, in the vertex shader of its cell array mappers. + */ +export declare const vtkWebGPUCutterMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUCutterMapper; diff --git a/Sources/Rendering/WebGPU/Device/index.d.ts b/Sources/Rendering/WebGPU/Device/index.d.ts new file mode 100644 index 00000000000..e70954c19a9 --- /dev/null +++ b/Sources/Rendering/WebGPU/Device/index.d.ts @@ -0,0 +1,199 @@ +/// + +import { vtkObject, vtkSubscription } from '../../../interfaces'; +import { Nullable } from '../../../types'; +import vtkWebGPUBufferManager from '../BufferManager'; +import vtkWebGPUShaderCache from '../ShaderCache'; +import vtkWebGPUShaderModule from '../ShaderModule'; +import vtkWebGPUTextureManager from '../TextureManager'; + +/** + * A map of key to weak reference. Entries whose value has been garbage + * collected are dropped on the next lookup. + */ +export declare class WeakRefMap extends Map { + /** + * Dereference the entry stored under the given key. + */ + getValue(key: string): unknown; + + /** + * Store a weak reference to the given value. Non objects are not stored. + */ + setValue(key: string, value: unknown): unknown; + + /** + * Remove every entry whose weak reference resolves to the given value. + */ + deleteValue(value: unknown): void; +} + +export type WebGPUDeviceLostEvent = { + info: GPUDeviceLostInfo; + generation: number; +}; + +export interface IWebGPUDeviceInitialValues { + handle?: GPUDevice; + pipelines?: Record; + shaderCache?: unknown; + bindGroupLayouts?: unknown[]; + bufferManager?: vtkWebGPUBufferManager; + textureManager?: unknown; +} + +export interface vtkWebGPUDevice extends vtkObject { + /** + * Set the GPUDevice this object wraps. + * @param handle The WebGPU device. + */ + initialize(handle: GPUDevice): void; + + /** + * Whether the wrapped device exposes the feature. + */ + hasFeature(name: GPUFeatureName): boolean; + + /** Get the generation of the currently initialized device handle. */ + getGeneration(): number; + + onDeviceLost( + callback: (event: WebGPUDeviceLostEvent) => void, + priority?: number + ): vtkSubscription; + + invokeDeviceLost(event: WebGPUDeviceLostEvent): void; + + /** + * Create a new command encoder on the underlying device. + */ + createCommandEncoder(): GPUCommandEncoder; + + /** + * Finish the given command encoder and submit it to the device queue. + * @param commandEncoder The encoder to finish and submit. + */ + submitCommandEncoder(commandEncoder: GPUCommandEncoder): void; + + /** + * Run a callback after the next command encoder is submitted. Resources + * released there remain valid for commands recorded before the submission. + */ + afterNextSubmit(callback: () => void): void; + + /** + * Get a shader module from the shader cache for the given shader description. + * @param sd The vtkWebGPUShaderDescription to compile. + */ + getShaderModule(sd: any): vtkWebGPUShaderModule; + + /** + * Get a bind group layout matching the given description, creating and + * caching it when it is not already known. Missing binding and visibility + * entries are filled in with defaults. + * @param val The bind group layout descriptor. + */ + getBindGroupLayout( + val: GPUBindGroupLayoutDescriptor + ): Nullable; + + /** + * Get the stringified descriptor a cached bind group layout was built from. + * @param layout A layout previously returned by getBindGroupLayout. + */ + getBindGroupLayoutDescription(layout: GPUBindGroupLayout): Nullable; + + /** + * Get a previously created pipeline by hash. + * @param hash The pipeline hash. + */ + getPipeline(hash: string): Nullable; + + /** + * Initialize the given pipeline and store it under the given hash. + * @param hash The pipeline hash. + * @param pipeline The vtkWebGPUPipeline to initialize. + */ + createPipeline(hash: string, pipeline: any): void; + + /** + * Resolves once all work submitted to the device queue has completed. + */ + onSubmittedWorkDone(): Promise; + + /** + * Get the cached object stored under the given hash, if it is still alive. + * @param hash The object hash. + */ + hasCachedObject(hash: string): unknown; + + /** + * Remove every cache entry referring to this object. + */ + removeCachedObject(value: unknown): void; + + /** + * Get the cached object stored under the given hash, creating and caching it + * with the provided creator when it is missing. + * @param hash The object hash. + * @param creator Called with the remaining arguments when nothing is cached. + * @param args Extra arguments forwarded to the creator. + */ + getCachedObject( + hash: string, + creator: (...args: any[]) => T, + ...args: any[] + ): Nullable; + + /** + * Get the GPUDevice this object wraps. + */ + getHandle(): Nullable; + + /** + * Set the GPUDevice this object wraps. + */ + setHandle(handle: GPUDevice): boolean; + + /** + * Get the buffer manager owned by this device. + */ + getBufferManager(): vtkWebGPUBufferManager; + + /** + * Get the shader cache owned by this device. + */ + getShaderCache(): vtkWebGPUShaderCache; + + /** + * Get the texture manager owned by this device. + */ + getTextureManager(): vtkWebGPUTextureManager; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUDevice characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUDeviceInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUDeviceInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUDevice. + * @param {IWebGPUDeviceInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUDeviceInitialValues +): vtkWebGPUDevice; + +export declare const vtkWebGPUDevice: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUDevice; diff --git a/Sources/Rendering/WebGPU/ForwardPass/index.d.ts b/Sources/Rendering/WebGPU/ForwardPass/index.d.ts new file mode 100644 index 00000000000..c07c4f173b6 --- /dev/null +++ b/Sources/Rendering/WebGPU/ForwardPass/index.d.ts @@ -0,0 +1,140 @@ +import { Nullable } from '../../../types'; +import { + IRenderPassInitialValues, + vtkRenderPass, +} from '../../SceneGraph/RenderPass'; +import vtkWebGPURenderEncoder from '../RenderEncoder'; +import vtkWebGPURenderer from '../Renderer'; +import vtkWebGPURenderWindow from '../RenderWindow'; +import vtkWebGPUOpaquePass from '../OpaquePass'; +import vtkWebGPUOrderIndependentTranslucentPass from '../OrderIndependentTranslucentPass'; +import vtkWebGPUVolume from '../Volume'; +import { vtkWebGPUVolumePass } from '../VolumePass'; + +export interface IWebGPUForwardPassInitialValues extends IRenderPassInitialValues { + opaqueActorCount?: number; + translucentActorCount?: number; + volumes?: Nullable; + opaqueRenderEncoder?: Nullable; + opaquePass?: vtkWebGPUOpaquePass; + translucentPass?: Nullable; + volumePass?: Nullable; +} + +export interface vtkWebGPUForwardPass extends vtkRenderPass { + /** + * Render every layer of every drawn renderer of the render window: query + * the actors, run the opaque pass, then the translucent and volume passes + * when the renderer holds any, and blit the result into the swap chain. + * + * @param {vtkWebGPURenderWindow} viewNode The render window view node. + * @param parent (default: null) + */ + traverse(viewNode: vtkWebGPURenderWindow, parent?: any): void; + + /** + * Blit the opaque pass color texture into the current swap chain texture. + * + * @param {vtkWebGPURenderWindow} viewNode The render window view node. + * @param {vtkWebGPURenderer} renNode The renderer view node, used for its + * scissor and viewport. + */ + finalPass(viewNode: vtkWebGPURenderWindow, renNode: vtkWebGPURenderer): void; + + /** + * Create the render encoder, sampler and full screen quad the final blit is + * drawn with. + * + * @param {vtkWebGPURenderWindow} viewNode The render window view node. + */ + createFinalBlitEncoder(viewNode: vtkWebGPURenderWindow): void; + + /** + * Count one opaque actor for the current query pass, and return the count + * before the increment. + */ + incrementOpaqueActorCount(): number; + + /** + * Count one translucent actor for the current query pass, and return the + * count before the increment. + */ + incrementTranslucentActorCount(): number; + + /** + * Add a volume view node to the list the volume pass renders. + * @param {vtkWebGPUVolume} volume The volume view node to render. + */ + addVolume(volume: vtkWebGPUVolume): void; + + /** + * Release the delegate passes and everything the final blit owns. + */ + releaseGraphicsResources(): void; + + /** + * Get the opaque pass, or `undefined` before the first traversal. + */ + getOpaquePass(): vtkWebGPUOpaquePass | undefined; + + /** + * Set the opaque pass. + */ + setOpaquePass(opaquePass: vtkWebGPUOpaquePass): boolean; + + /** + * Get the translucent pass, or `null` while no renderer has held any + * translucent actor. + */ + getTranslucentPass(): Nullable; + + /** + * Set the translucent pass. + */ + setTranslucentPass( + translucentPass: vtkWebGPUOrderIndependentTranslucentPass + ): boolean; + + /** + * Get the volume pass, or `null` while no renderer has held any volume. + */ + getVolumePass(): Nullable; + + /** + * Set the volume pass. + */ + setVolumePass(volumePass: vtkWebGPUVolumePass): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUForwardPass characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUForwardPassInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUForwardPassInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUForwardPass. + * @param {IWebGPUForwardPassInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUForwardPassInitialValues +): vtkWebGPUForwardPass; + +/** + * vtkWebGPUForwardPass implements a forward rendering pipeline. Every layer of + * every drawn renderer is rendered opaque first, into an offscreen color and + * depth texture, so that the translucent and volume passes can be composited + * against a valid z-buffer before the result is blitted into the swap chain. + */ +export declare const vtkWebGPUForwardPass: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUForwardPass; diff --git a/Sources/Rendering/WebGPU/FullScreenQuad/index.d.ts b/Sources/Rendering/WebGPU/FullScreenQuad/index.d.ts new file mode 100644 index 00000000000..1ce3485f8bc --- /dev/null +++ b/Sources/Rendering/WebGPU/FullScreenQuad/index.d.ts @@ -0,0 +1,59 @@ +import vtkWebGPUPipeline from '../Pipeline'; +import vtkWebGPUSimpleMapper, { + IWebGPUSimpleMapperInitialValues, +} from '../SimpleMapper'; +import vtkWebGPUVertexInput from '../VertexInput'; + +export interface IWebGPUFullScreenQuadInitialValues extends IWebGPUSimpleMapperInitialValues {} + +export interface vtkWebGPUFullScreenQuad extends vtkWebGPUSimpleMapper { + /** + * Shader replacement, registered under `replaceShaderPosition`, emitting the + * clip space position and texture coordinates of the quad. + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderPosition( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * Bind the shared full screen quad buffer of the device as this mapper's + * vertex input. + */ + updateBuffers(): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUFullScreenQuad characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUFullScreenQuadInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUFullScreenQuadInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUFullScreenQuad. + * @param {IWebGPUFullScreenQuadInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUFullScreenQuadInitialValues +): vtkWebGPUFullScreenQuad; + +/** + * A mapper drawing two triangles covering the whole render target, used by the + * passes that run a fragment shader over the framebuffer. + */ +export declare const vtkWebGPUFullScreenQuad: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUFullScreenQuad; diff --git a/Sources/Rendering/WebGPU/Glyph3DMapper/index.d.ts b/Sources/Rendering/WebGPU/Glyph3DMapper/index.d.ts new file mode 100644 index 00000000000..4ba83498a9b --- /dev/null +++ b/Sources/Rendering/WebGPU/Glyph3DMapper/index.d.ts @@ -0,0 +1,86 @@ +import vtkWebGPUCellArrayMapper, { + IWebGPUCellArrayMapperInitialValues, +} from '../CellArrayMapper'; +import vtkWebGPUPolyDataMapper, { + IWebGPUPolyDataMapperInitialValues, +} from '../PolyDataMapper'; + +/** + * The cell array mapper of a glyph, drawing one instance per glyph transform + * held in the storage buffer of the glyph mapper. + */ +export interface vtkWebGPUGlyph3DCellArrayMapper extends vtkWebGPUCellArrayMapper { + /** + * Set the number of glyph instances to draw. + * @param {Number} val + */ + setGlyphInstances(val: number): void; +} + +export interface IWebGPUGlyph3DMapperInitialValues extends IWebGPUPolyDataMapperInitialValues {} + +export interface vtkWebGPUGlyph3DMapper extends vtkWebGPUPolyDataMapper { + /** + * Create a glyph cell array mapper sharing the storage buffer and the + * renderable of this mapper. + */ + createCellArrayMapper(): vtkWebGPUGlyph3DCellArrayMapper; + + /** + * Update the renderable, refill the glyph storage buffer and rebuild the + * cell array mappers of the glyph source. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * Fill the storage buffer with the per instance matrix, normal matrix and + * color of every glyph, and send it when the renderable rebuilt its arrays. + */ + updateSSBO(): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUGlyph3DCellArrayMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUCellArrayMapperInitialValues} [initialValues] (default: {}) + */ +export function caExtend( + publicAPI: object, + model: object, + initialValues?: IWebGPUCellArrayMapperInitialValues +): void; + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUGlyph3DMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUGlyph3DMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUGlyph3DMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUGlyph3DMapper. + * @param {IWebGPUGlyph3DMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUGlyph3DMapperInitialValues +): vtkWebGPUGlyph3DMapper; + +/** + * The WebGPU view node of vtkGlyph3DMapper. It draws the glyph source once per + * glyph as instances, reading the per instance transforms from a storage + * buffer. + */ +export declare const vtkWebGPUGlyph3DMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUGlyph3DMapper; diff --git a/Sources/Rendering/WebGPU/HardwareSelectionPass/index.d.ts b/Sources/Rendering/WebGPU/HardwareSelectionPass/index.d.ts new file mode 100644 index 00000000000..2c67e72473b --- /dev/null +++ b/Sources/Rendering/WebGPU/HardwareSelectionPass/index.d.ts @@ -0,0 +1,84 @@ +import { Nullable } from '../../../types'; +import { + IRenderPassInitialValues, + vtkRenderPass, +} from '../../SceneGraph/RenderPass'; +import vtkWebGPURenderEncoder from '../RenderEncoder'; +import vtkWebGPURenderer from '../Renderer'; +import vtkWebGPURenderWindow from '../RenderWindow'; +import vtkWebGPUTexture from '../Texture'; + +export interface IWebGPUHardwareSelectionPassInitialValues extends IRenderPassInitialValues { + selectionRenderEncoder?: Nullable; + colorTexture?: Nullable; + depthTexture?: Nullable; +} + +/** + * `traverse` takes the render window view node and the renderer view node + * here rather than the view node and parent of the base class, so the + * inherited signature is replaced. + */ +type vtkWebGPUHardwareSelectionPassBase = Omit; + +export interface vtkWebGPUHardwareSelectionPass extends vtkWebGPUHardwareSelectionPassBase { + /** + * Render the opaque actors of a renderer into an rgba32uint texture holding + * the prop, composite and attribute ids of every fragment, allocating or + * resizing the color and depth textures to the canvas first. + * + * @param {vtkWebGPURenderWindow} viewNode The render window view node. + * @param {vtkWebGPURenderer} renNode The renderer view node to traverse. + */ + traverse(viewNode: vtkWebGPURenderWindow, renNode: vtkWebGPURenderer): void; + + /** + * Create the render encoder the selection ids are written through, + * including the shader replacement packing them into the color attachment. + */ + createRenderEncoder(): void; + + /** + * Get the rgba32uint texture holding the selection ids, or `null` before + * the first traversal. + */ + getColorTexture(): Nullable; + + /** + * Get the depth32float texture this pass renders into, or `null` before the + * first traversal. + */ + getDepthTexture(): Nullable; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUHardwareSelectionPass characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUHardwareSelectionPassInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUHardwareSelectionPassInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUHardwareSelectionPass. + * @param {IWebGPUHardwareSelectionPassInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUHardwareSelectionPassInitialValues +): vtkWebGPUHardwareSelectionPass; + +/** + * vtkWebGPUHardwareSelectionPass renders the scene into an integer texture + * whose texels hold `[propID, compositeID, attributeID + 1, unused]`, which + * vtkWebGPUHardwareSelector reads back to resolve a pick. + */ +export declare const vtkWebGPUHardwareSelectionPass: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUHardwareSelectionPass; diff --git a/Sources/Rendering/WebGPU/HardwareSelector/index.d.ts b/Sources/Rendering/WebGPU/HardwareSelector/index.d.ts new file mode 100644 index 00000000000..414ac0a735f --- /dev/null +++ b/Sources/Rendering/WebGPU/HardwareSelector/index.d.ts @@ -0,0 +1,158 @@ +import { FieldAssociations } from '../../../Common/DataModel/DataSet/Constants'; +import vtkSelectionNode from '../../../Common/DataModel/SelectionNode'; +import { Nullable } from '../../../types'; +import { + IHardwareSelectorInitialValues, + vtkHardwareSelector, +} from '../../Core/HardwareSelector'; +import vtkProp from '../../Core/Prop'; +import vtkRenderer from '../../Core/Renderer'; +import vtkWebGPURenderer from '../Renderer'; +import vtkWebGPURenderWindow from '../RenderWindow'; + +/** + * The region of the selection buffer a capture covers, as + * `[x1, y1, x2, y2]` in pixels. + */ +export type WebGPUSelectionArea = [number, number, number, number]; + +/** + * One capture of the selection buffers, held by value so that overlapping + * asynchronous captures do not interfere with each other. + */ +export interface IWebGPUSourceData { + area: WebGPUSelectionArea; + captureZValues: boolean; + fieldAssociation: FieldAssociations; + + /** + * The props hit during the capture, indexed by the prop id written into the + * selection buffer. An entry is `null` when the mapper did not name a prop. + */ + props: Nullable[]; + renderer: vtkRenderer; + webGPURenderer: vtkWebGPURenderer; + webGPURenderWindow: vtkWebGPURenderWindow; + width: number; + height: number; + + /** + * The row stride, in texels, of the color buffer. Rounded up so that a row + * is a multiple of 256 bytes. + */ + colorBufferWidth: number; + colorBufferSizeInBytes: number; + + /** + * The `[propID, compositeID, attributeID + 1, unused]` texels of the + * capture, row padded to `colorBufferWidth`. + */ + colorValues: Uint32Array; + + /** + * The row stride, in texels, of the depth buffer. Only present when + * z values were captured. + */ + zbufferBufferWidth?: number; + zbufferSizeInBytes?: number; + + /** + * The depth of every texel of the capture, row padded to + * `zbufferBufferWidth`. Only present when z values were captured. + */ + depthValues?: Float32Array; + + /** + * Resolve the props, composite ids and attribute ids hit inside a region of + * this capture. + * + * @param {number} fx1 top left x coord + * @param {number} fy1 top left y coord + * @param {number} fx2 bottom right x coord + * @param {number} fy2 bottom right y coord + */ + generateSelection( + fx1: number, + fy1: number, + fx2: number, + fy2: number + ): vtkSelectionNode[]; +} + +export interface IWebGPUHardwareSelectorInitialValues extends IHardwareSelectorInitialValues { + WebGPURenderWindow?: vtkWebGPURenderWindow; + _WebGPURenderWindow?: vtkWebGPURenderWindow; +} + +export interface vtkWebGPUHardwareSelector extends vtkHardwareSelector { + /** Attach the selector to a render window and its renderer. */ + attach( + webGPURenderWindow: vtkWebGPURenderWindow, + renderer: vtkRenderer + ): void; + + /** + * Get the index this prop is written to the selection buffer under, + * assigning it one on first use. The indices are reset at the start of + * every capture. + * + * @param {number} runtimePropID The prop id of the actor view node. + * @param {vtkProp} [prop] The prop the selection should report (default: null) + */ + getPropIDForSelection( + runtimePropID: number, + prop?: Nullable + ): number; + + /** + * Detach this selector from the renderer it was capturing. + */ + endSelection(): void; + + /** + * Render the scene into the selection buffers and read them back. The whole + * canvas is always captured, so no region is taken. + * + * @param {vtkRenderer} renderer The renderer to capture. + * @returns the capture, or `false` when there is no renderer or view, or the + * renderer has no view node. + */ + getSourceDataAsync(renderer: vtkRenderer): Promise; + + /** + * Get the render window view node the capture renders through. + */ + getWebGPURenderWindow(): Nullable; + + /** + * Set the render window view node the capture renders through. + */ + setWebGPURenderWindow( + webGPURenderWindow: Nullable + ): boolean; +} + +export function newInstance( + initialValues?: IWebGPUHardwareSelectorInitialValues +): vtkWebGPUHardwareSelector; + +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUHardwareSelectorInitialValues +): void; + +/** + * The WebGPU implementation of the hardware selector renders the scene into an + * rgba32uint texture whose texels hold the prop, composite and attribute ids + * of the fragment, then copies that texture, and the depth texture when z + * values are wanted, into mappable buffers. Because the copy covers the whole + * texture, the capture always spans the full canvas and the picking region is + * only applied when the read back buffers are decoded. + */ +export declare const vtkWebGPUHardwareSelector: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkWebGPUHardwareSelector; diff --git a/Sources/Rendering/WebGPU/Helpers/StorageArray.d.ts b/Sources/Rendering/WebGPU/Helpers/StorageArray.d.ts new file mode 100644 index 00000000000..4ff361d7d46 --- /dev/null +++ b/Sources/Rendering/WebGPU/Helpers/StorageArray.d.ts @@ -0,0 +1,27 @@ +/// + +import { Nullable } from '../../../types'; +import { IWebGPUBindable } from '../BindGroup'; +import vtkWebGPUBuffer from '../Buffer'; + +/** + * A read only storage array whose bind group changes when its buffer changes. + */ +export type WebGPUStorageArray = IWebGPUBindable & { + getLabel(): string; + getBuffer(): Nullable; + setBuffer(buffer: Nullable): void; +}; + +/** + * Create a storage binding read by the shader as array. + */ +export function newStorageArray( + label: string, + elementType: string +): WebGPUStorageArray; + +declare const vtkWebGPUStorageArray: { + newStorageArray: typeof newStorageArray; +}; +export default vtkWebGPUStorageArray; diff --git a/Sources/Rendering/WebGPU/ImageCPRMapper/index.d.ts b/Sources/Rendering/WebGPU/ImageCPRMapper/index.d.ts new file mode 100644 index 00000000000..b9b20524e12 --- /dev/null +++ b/Sources/Rendering/WebGPU/ImageCPRMapper/index.d.ts @@ -0,0 +1,170 @@ +import { Nullable } from '../../../types'; +import { vtkImageData } from '../../../Common/DataModel/ImageData'; +import { vtkPolyData } from '../../../Common/DataModel/PolyData'; +import { ICoincidentTopology } from '../../Core/Mapper/CoincidentTopologyHelper'; +import { vtkWebGPUPipeline } from '../Pipeline'; +import { vtkWebGPUSampler } from '../Sampler'; +import { + IWebGPUSimpleMapperInitialValues, + vtkWebGPUSimpleMapper, +} from '../SimpleMapper'; + +export interface IWebGPUImageCPRMapperInitialValues extends IWebGPUSimpleMapperInitialValues { + rowLength?: number; + currentImageDataInput?: Nullable; + currentCenterlineInput?: Nullable; + colorTextureString?: Nullable; + pwfTextureString?: Nullable; + cprSampler?: Nullable; +} + +export interface vtkWebGPUImageCPRMapper extends vtkWebGPUSimpleMapper { + /** + * Resolve the ancestors this mapper renders with and bind it to its + * renderer. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + buildPass(prepass: boolean): void; + + /** + * Get the polygon offset the renderable asks for, or `null` when it does not + * resolve coincident topology with a polygon offset. + */ + getCoincidentParameters(): Nullable; + + /** + * Render the reformat during the opaque pass. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + opaquePass(prepass: boolean): void; + + /** + * Capture the reformat depth during the opaque z-buffer pass. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + opaqueZBufferPass(prepass: boolean): void; + + /** + * Render the reformat. + */ + render(): void; + + /** + * Shader replacement, registered under `replaceShaderClip`, emitting the + * clipping plane test in model coordinates. + * + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + */ + replaceShaderClip(hash: string, pipeline: vtkWebGPUPipeline): void; + + /** + * Shader replacement, registered under `replaceShaderCoincident`, emitting + * the depth offset the renderable's coincident topology resolution asks for. + * + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + */ + replaceShaderCoincident(hash: string, pipeline: vtkWebGPUPipeline): void; + + /** + * Shader replacement, registered under `replaceShaderImageCPR`, emitting the + * quad positions along the centerline and the volume sampling that straightens + * the image. + * + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + */ + replaceShaderImageCPR(hash: string, pipeline: vtkWebGPUPipeline): void; + + /** + * Shader replacement, registered under `replaceShaderRenderEncoder`, writing + * the prop identifier when the encoder is the hardware selector's. + * + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + */ + replaceShaderRenderEncoder(hash: string, pipeline: vtkWebGPUPipeline): void; + + /** + * Render the reformat during the translucent pass. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + translucentPass(prepass: boolean): void; + + /** + * Build or reuse the texture holding the sampled color transfer functions. + */ + updateColorTexture(): void; + + /** + * Rebuild the quad strip following the centerline, one quad per centerline + * segment, with its positions, orientations and distances. + */ + updateGeometry(): void; + + /** + * Build or reuse the texture holding the sampled piecewise opacity + * functions. + */ + updateOpacityTexture(): void; + + /** + * Recompute and send the mapper uniform buffer when the renderable, the + * actor, the property, the image or the stabilized center changed. + */ + updateUBO(): void; + + /** + * Bind a texture view of the input image as the volume this mapper samples. + */ + updateVolumeTexture(): void; + + /** + * Render the reformat depth only, so that a later pass can mix geometry with + * volumes. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + zBufferPass(prepass: boolean): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUImageCPRMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUImageCPRMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUImageCPRMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUImageCPRMapper. + * @param {IWebGPUImageCPRMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUImageCPRMapperInitialValues +): vtkWebGPUImageCPRMapper; + +/** + * vtkWebGPUImageCPRMapper is the WebGPU scene graph node that draws a + * vtkImageSlice whose mapper is a vtkImageCPRMapper. It builds a quad strip + * along the oriented centerline and assembles the WGSL that samples the volume + * along each quad, producing a curved planar reformat. + * + * Importing this module registers it as the WebGPU override for + * `vtkImageCPRMapper`. + */ +declare const vtkWebGPUImageCPRMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUImageCPRMapper; diff --git a/Sources/Rendering/WebGPU/ImageMapper/Constants.d.ts b/Sources/Rendering/WebGPU/ImageMapper/Constants.d.ts new file mode 100644 index 00000000000..8919314ee8d --- /dev/null +++ b/Sources/Rendering/WebGPU/ImageMapper/Constants.d.ts @@ -0,0 +1,23 @@ +export declare const TextureChannelMode: { + readonly SINGLE: 'single'; + readonly DEPENDENT_LA: 'dependent-la'; + readonly DEPENDENT_RGB: 'dependent-rgb'; + readonly DEPENDENT_RGBA: 'dependent-rgba'; + readonly INDEPENDENT_1: 'independent-1'; + readonly INDEPENDENT_2: 'independent-2'; + readonly INDEPENDENT_3: 'independent-3'; + readonly INDEPENDENT_4: 'independent-4'; +}; + +export type TextureChannelMode = + (typeof TextureChannelMode)[keyof typeof TextureChannelMode]; + +export declare const TextureSlot: { + readonly IMAGE: 0; + readonly COLOR_LUT: 1; + readonly OPACITY_LUT: 2; + readonly LABEL_OUTLINE_THICKNESS: 3; + readonly LABEL_OUTLINE_OPACITY: 4; +}; + +export type TextureSlot = (typeof TextureSlot)[keyof typeof TextureSlot]; diff --git a/Sources/Rendering/WebGPU/ImageMapper/index.d.ts b/Sources/Rendering/WebGPU/ImageMapper/index.d.ts new file mode 100644 index 00000000000..b0c63adf10e --- /dev/null +++ b/Sources/Rendering/WebGPU/ImageMapper/index.d.ts @@ -0,0 +1,231 @@ +/// + +import { Nullable } from '../../../types'; +import { ICoincidentTopology } from '../../Core/Mapper/CoincidentTopologyHelper'; +import { vtkImageProperty } from '../../Core/ImageProperty'; +import { + IWebGPUFullScreenQuadInitialValues, + vtkWebGPUFullScreenQuad, +} from '../FullScreenQuad'; +import { vtkWebGPUPipeline } from '../Pipeline'; +import {} from '../SimpleMapper'; +import { vtkWebGPUTextureView } from '../TextureView'; +import { vtkWebGPUVertexInput } from '../VertexInput'; +import { TextureChannelMode } from './Constants'; + +/** + * How the scalars of the image being rendered map onto the texture channels, + * and which of the property's transfer functions apply to them. + */ +export interface IWebGPUImageState { + actorProperty: vtkImageProperty; + numberOfComponents: number; + independentComponents: boolean; + numberOfIComponents: number; + useLabelOutline: boolean; + textureChannelMode: TextureChannelMode; +} + +export interface IWebGPUImageMapperInitialValues extends IWebGPUFullScreenQuadInitialValues { + imageState?: Nullable; + rowLength?: number; +} + +export interface vtkWebGPUImageMapper extends vtkWebGPUFullScreenQuad { + /** + * Resolve the ancestors this mapper renders with and, when the renderable + * slices at the focal point, move its slice to the active camera. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + buildPass(prepass: boolean): void; + + /** + * Compute how the image scalars map onto the texture channels from the + * property and the image texture currently bound. + */ + computeImageState(): IWebGPUImageState; + + /** + * Give the texture view a sampler matching the given options, unless the + * sampler it already has matches them. + * + * @param {vtkWebGPUTextureView} textureView + * @param {GPUSamplerDescriptor} options + */ + ensureTextureSampler( + textureView: Nullable, + options: GPUSamplerDescriptor + ): void; + + /** + * Get the polygon offset the renderable asks for, or a zero offset when it + * does not resolve coincident topology with a polygon offset. + */ + getCoincidentParameters(): ICoincidentTopology; + + /** + * Get the image state computed by the last `updateBuffers`, recomputing it + * when the buffers have not been updated yet. + */ + getImageState(): IWebGPUImageState; + + /** Whether the current image can use mipmaps for minification. */ + useImageMipmaps(): boolean; + + /** + * Render the slice during the opaque pass. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + opaquePass(prepass: boolean): void; + + /** + * Capture the slice depth during the opaque z-buffer pass. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + opaqueZBufferPass(prepass: boolean): void; + + /** + * Render the slice. + */ + render(): void; + + /** + * Shader replacement, registered under `replaceShaderClip`, emitting the + * clipping plane test in stabilized coordinates. + * + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderClip( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * Shader replacement, registered under `replaceShaderCoincidentOffset`, + * emitting the depth offset the renderable's coincident topology resolution + * asks for. + * + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderCoincidentOffset( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * Shader replacement, registered under `replaceShaderImage`, emitting the + * texture declarations, the transfer function lookups and, for label maps, + * the label outline code. + * + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderImage( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * Shader replacement, registered under `replaceShaderSelect`, emitting the + * composite and attribute identifiers the hardware selector reads. + * + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderSelect( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * Render the slice during the translucent pass. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + translucentPass(prepass: boolean): void; + + /** + * Build or reuse the texture holding the per-label outline opacities. + */ + updateLabelOutlineOpacityTexture(): void; + + /** + * Build or reuse the texture holding the per-label outline thicknesses. + */ + updateLabelOutlineThicknessTexture(): void; + + /** + * Build or reuse the texture holding the sampled color transfer functions. + */ + updateLUTImage(): void; + + /** + * Build or reuse the texture holding the sampled piecewise opacity + * functions. + */ + updateOpacityLUTImage(): void; + + /** + * Recompute and send the mapper uniform buffer when the renderable, the + * property or the clipping planes changed. + */ + updateUBO(): void; + + /** + * Render the slice depth only, so that a later pass can mix geometry with + * volumes. + * + * @param {Boolean} prepass Whether the traversal is on its way down. + */ + zBufferPass(prepass: boolean): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUImageMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUImageMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUImageMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUImageMapper. + * @param {IWebGPUImageMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUImageMapperInitialValues +): vtkWebGPUImageMapper; + +/** + * vtkWebGPUImageMapper is the WebGPU scene graph node that draws a + * vtkImageSlice whose mapper is a vtkImageMapper. It textures the slice onto a + * full screen quad clipped to the slice geometry and assembles the WGSL that + * applies the color transfer function, the piecewise opacity function and, for + * label maps, the label outline. + * + * Importing this module registers it as the WebGPU override for + * `vtkAbstractImageMapper`. + */ +declare const vtkWebGPUImageMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUImageMapper; diff --git a/Sources/Rendering/WebGPU/ImageResliceMapper/index.d.ts b/Sources/Rendering/WebGPU/ImageResliceMapper/index.d.ts new file mode 100644 index 00000000000..1efbc5b6705 --- /dev/null +++ b/Sources/Rendering/WebGPU/ImageResliceMapper/index.d.ts @@ -0,0 +1,111 @@ +import { Nullable } from '../../../types'; +import { vtkImageData } from '../../../Common/DataModel/ImageData'; +import { vtkPolyData } from '../../../Common/DataModel/PolyData'; +import { vtkImageProperty } from '../../Core/ImageProperty'; +import { + IWebGPUImageMapperInitialValues, + vtkWebGPUImageMapper, +} from '../ImageMapper'; +import { vtkWebGPUTexture } from '../Texture'; + +/** + * One of the mapper's connected input images and the port it came from. + */ +export interface IWebGPUResliceInput { + imageData: vtkImageData; + inputIndex: number; +} + +/** + * An input property asking for a label outline, and the index of that input in + * the list of valid inputs. + */ +export interface IWebGPUResliceLabelOutlineProperty { + property: vtkImageProperty; + arrayIndex: number; +} + +/** + * The scalar texture built for one input, kept until the scalars of that input + * are modified. + */ +export interface IWebGPUResliceScalarTexture { + texture: vtkWebGPUTexture; + mtime: number; +} + +export interface IWebGPUImageResliceMapperInitialValues extends IWebGPUImageMapperInitialValues { + currentValidInputs?: Nullable; + resliceGeom?: Nullable; + resliceGeomUpdateString?: Nullable; + multiTexturePerVolumeEnabled?: boolean; + numberOfComponents?: number; + labelOutlineProperties?: IWebGPUResliceLabelOutlineProperty[]; + scalarTextures?: Nullable[]; +} + +export interface vtkWebGPUImageResliceMapper extends vtkWebGPUImageMapper { + /** + * Get the per input scalar texture cache. Entries beyond the current number + * of inputs are cleared to `null`. + */ + getScalarTextures(): Nullable[]; + + /** + * Replace the per input scalar texture cache. + * + * @param {IWebGPUResliceScalarTexture[]} [scalarTextures] (default: []) + */ + setScalarTextures( + scalarTextures?: Nullable[] + ): void; + + /** + * Upload the reslice geometry as the index and vertex buffers of this + * mapper, adding vertex normals when the renderable asks for a slab. + */ + updateGeometryBuffers(): void; + + /** + * Rebuild the polydata the image is resliced onto, either the slice plane + * cut through the image outline or the renderable's own slice polydata. + */ + updateResliceGeometry(): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUImageResliceMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUImageResliceMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUImageResliceMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUImageResliceMapper. + * @param {IWebGPUImageResliceMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUImageResliceMapperInitialValues +): vtkWebGPUImageResliceMapper; + +/** + * vtkWebGPUImageResliceMapper is the WebGPU scene graph node that draws a + * vtkImageSlice whose mapper is a vtkImageResliceMapper. It cuts the slice + * polydata out of the image outline, textures every connected input onto it + * and assembles the WGSL that blends them, optionally averaging or projecting + * over a slab. + * + * Importing this module registers it as the WebGPU override for + * `vtkImageResliceMapper`. + */ +declare const vtkWebGPUImageResliceMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUImageResliceMapper; diff --git a/Sources/Rendering/WebGPU/ImageSlice/index.d.ts b/Sources/Rendering/WebGPU/ImageSlice/index.d.ts new file mode 100644 index 00000000000..8e25534769f --- /dev/null +++ b/Sources/Rendering/WebGPU/ImageSlice/index.d.ts @@ -0,0 +1,105 @@ +import { vtkObject } from '../../../interfaces'; +import { Vector4 } from '../../../types'; +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; +import { vtkWebGPURenderer } from '../Renderer'; + +/** + * The cached matrix built by `extend`, holding the model to world transform. + */ +export interface IWebGPUImageSliceKeyMatrices { + mcwc: Float64Array; +} + +export interface IWebGPUImageSliceInitialValues extends IViewNodeInitialValues { + propID?: number; +} + +export interface vtkWebGPUImageSlice extends vtkViewNode { + /** + * Builds myself: resolve the renderer and render window, claim a prop id and + * adopt the renderable's mapper as a child. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseZBufferPass(renderPass: vtkRenderPass): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseOpaqueZBufferPass(renderPass: vtkRenderPass): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseOpaquePass(renderPass: vtkRenderPass): void; + + /** + * @param {vtkRenderPass} renderPass + */ + traverseTranslucentPass(renderPass: vtkRenderPass): void; + + /** + * @param prepass + * @param {vtkRenderPass} renderPass + */ + queryPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * The translation applied to the vertex buffers of this slice to keep them + * near the origin. Recomputes the key matrices if needed. + * @param {vtkWebGPURenderer} wgpuRen + */ + getBufferShift(wgpuRen: vtkWebGPURenderer): Vector4; + + /** + * Recompute the key matrices if the renderable or the stabilized center + * moved. + * @param {vtkWebGPURenderer} wgpuRen + */ + getKeyMatrices(wgpuRen: vtkWebGPURenderer): IWebGPUImageSliceKeyMatrices; + + /** + * The identifier used by hardware selection to recognize this prop. + */ + getPropID(): number; + + /** + * The time stamp guarding the cached key matrices. + */ + getKeyMatricesTime(): vtkObject; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUImageSlice characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUImageSliceInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUImageSliceInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUImageSlice. + * @param {IWebGPUImageSliceInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUImageSliceInitialValues +): vtkWebGPUImageSlice; + +/** + * The WebGPU backend view node for a vtkImageSlice. + */ +export declare const vtkWebGPUImageSlice: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUImageSlice; diff --git a/Sources/Rendering/WebGPU/IndexBuffer/index.d.ts b/Sources/Rendering/WebGPU/IndexBuffer/index.d.ts new file mode 100644 index 00000000000..496552d6ca8 --- /dev/null +++ b/Sources/Rendering/WebGPU/IndexBuffer/index.d.ts @@ -0,0 +1,128 @@ +/// + +import { Nullable } from '../../../types'; +import vtkWebGPUBuffer, { IWebGPUBufferInitialValues } from '../Buffer'; +import { IWebGPUBufferRequest } from '../BufferManager'; +import { BufferUsage, PrimitiveTypes } from '../BufferManager/Constants'; + +export interface IWebGPUIndexBufferInitialValues extends IWebGPUBufferInitialValues { + flatIdToPointId?: Nullable; + flatIdToCellId?: Nullable; + flatSize?: number; + indexCount?: number; + primitiveToCellId?: Nullable; + primitiveToCellIdBuffer?: Nullable; +} + +export interface vtkWebGPUIndexBuffer extends vtkWebGPUBuffer { + /** + * Build the index buffer for the cells of the request. The + * resulting typed array is stored on the request as `nativeArray` and its + * WebGPU index format as `format`. When pointIds is true, the indices are + * point ids and the flat id maps are null. Otherwise, the indices refer to + * flattened vertices. + * @param {IWebGPUBufferRequest} req The request, providing cells, + * numberOfPoints, primitiveType, representation and cellOffset. + */ + buildIndexBuffer(req: IWebGPUBufferRequest): void; + + /** + * Build an index buffer of point ids for the primitive-index feature. + */ + buildPointIdIndexBuffer(req: IWebGPUBufferRequest): void; + + /** + * Build an index buffer with a separate provoking vertex for each cell. + */ + buildFlatIndexBuffer(req: IWebGPUBufferRequest): void; + + /** + * Get the global cell id of each primitive, or null for a one-to-one mapping. + */ + getPrimitiveToCellId(): Nullable; + + setPrimitiveToCellId(primitiveToCellId: Nullable): boolean; + + /** + * Get the storage buffer holding the primitive-to-cell map, when needed. + */ + getPrimitiveToCellIdBuffer(): Nullable; + + setPrimitiveToCellIdBuffer( + primitiveToCellIdBuffer: Nullable + ): boolean; + + /** + * Get the map from flat id to the point id it was expanded from. + */ + getFlatIdToPointId(): Nullable; + + /** + * Set the map from flat id to the point id it was expanded from. + */ + setFlatIdToPointId( + flatIdToPointId: Nullable + ): boolean; + + /** + * Get the map from flat id to the cell id it was expanded from. + */ + getFlatIdToCellId(): Nullable; + + /** + * Set the map from flat id to the cell id it was expanded from. + */ + setFlatIdToCellId( + flatIdToCellId: Nullable + ): boolean; + + /** + * Get the number of flat ids, i.e. the number of vertices the attribute + * buffers must hold. + */ + getFlatSize(): number; + + /** + * Set the number of flat ids. + */ + setFlatSize(flatSize: number): boolean; + + /** + * Get the number of indices stored in the buffer. + */ + getIndexCount(): number; + + /** + * Set the number of indices stored in the buffer. + */ + setIndexCount(indexCount: number): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUIndexBuffer characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUIndexBufferInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUIndexBufferInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUIndexBuffer. + * @param {IWebGPUIndexBufferInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUIndexBufferInitialValues +): vtkWebGPUIndexBuffer; + +export declare const vtkWebGPUIndexBuffer: { + newInstance: typeof newInstance; + extend: typeof extend; + BufferUsage: typeof BufferUsage; + PrimitiveTypes: typeof PrimitiveTypes; +}; +export default vtkWebGPUIndexBuffer; diff --git a/Sources/Rendering/WebGPU/OpaquePass/index.d.ts b/Sources/Rendering/WebGPU/OpaquePass/index.d.ts new file mode 100644 index 00000000000..a0a31908dcd --- /dev/null +++ b/Sources/Rendering/WebGPU/OpaquePass/index.d.ts @@ -0,0 +1,102 @@ +import { Nullable } from '../../../types'; +import { + IRenderPassInitialValues, + vtkRenderPass, +} from '../../SceneGraph/RenderPass'; +import vtkWebGPURenderEncoder from '../RenderEncoder'; +import vtkWebGPURenderer from '../Renderer'; +import vtkWebGPURenderWindow from '../RenderWindow'; +import vtkWebGPUTexture from '../Texture'; +import vtkWebGPUTextureView from '../TextureView'; + +export interface IWebGPUOpaquePassInitialValues extends IRenderPassInitialValues { + renderEncoder?: Nullable; + colorTexture?: Nullable; + depthTexture?: Nullable; +} + +/** + * `traverse` takes the renderer view node and the render window view node + * here rather than the view node and parent of the base class, so the + * inherited signature is replaced. + */ +type vtkWebGPUOpaquePassBase = Omit; + +export interface vtkWebGPUOpaquePass extends vtkWebGPUOpaquePassBase { + /** + * Render the opaque actors of a renderer into an offscreen color and depth + * texture, allocating or resizing them to the canvas first. + * + * @param {vtkWebGPURenderer} renNode The renderer view node to traverse. + * @param {vtkWebGPURenderWindow} viewNode The render window view node. + */ + traverse(renNode: vtkWebGPURenderer, viewNode: vtkWebGPURenderWindow): void; + + /** + * Get the view of the color texture this pass renders into. + */ + getColorTextureView(): vtkWebGPUTextureView; + + /** + * Get the view of the depth texture this pass renders into. + */ + getDepthTextureView(): Nullable; + + /** + * Create the render encoder the opaque actors are drawn with. + */ + createRenderEncoder(sampleCount?: number): void; + + /** + * Drop the render encoder and both textures so that they are recreated on + * the next traversal. + */ + releaseGraphicsResources(): void; + + /** + * Get the rgba16float color texture this pass renders into, or `null` + * before the first traversal. + */ + getColorTexture(): Nullable; + + /** Get the color resolve target when multisampling is enabled. */ + getResolveColorTexture(): Nullable; + + /** + * Get the depth32float texture this pass renders into, or `null` before the + * first traversal. + */ + getDepthTexture(): Nullable; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUOpaquePass characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUOpaquePassInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUOpaquePassInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUOpaquePass. + * @param {IWebGPUOpaquePassInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUOpaquePassInitialValues +): vtkWebGPUOpaquePass; + +/** + * vtkWebGPUOpaquePass renders the opaque geometry of a renderer into an + * offscreen color and depth texture, which the translucent and volume passes + * then composite onto. + */ +export declare const vtkWebGPUOpaquePass: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUOpaquePass; diff --git a/Sources/Rendering/WebGPU/OrderIndependentTranslucentPass/index.d.ts b/Sources/Rendering/WebGPU/OrderIndependentTranslucentPass/index.d.ts new file mode 100644 index 00000000000..c69ee5e3547 --- /dev/null +++ b/Sources/Rendering/WebGPU/OrderIndependentTranslucentPass/index.d.ts @@ -0,0 +1,132 @@ +import { Nullable } from '../../../types'; +import { + IRenderPassInitialValues, + vtkRenderPass, +} from '../../SceneGraph/RenderPass'; +import vtkWebGPURenderer from '../Renderer'; +import vtkWebGPURenderWindow from '../RenderWindow'; +import vtkWebGPUTexture from '../Texture'; +import vtkWebGPUTextureView from '../TextureView'; +import vtkWebGPUFullScreenQuad from '../FullScreenQuad'; + +export interface IWebGPUOrderIndependentTranslucentPassInitialValues extends IRenderPassInitialValues { + colorTextureView?: Nullable; + depthTextureView?: Nullable; +} + +/** + * `traverse` takes the renderer view node and the render window view node + * here rather than the view node and parent of the base class, so the + * inherited signature is replaced. + */ +type vtkWebGPUOrderIndependentTranslucentPassBase = Omit< + vtkRenderPass, + 'traverse' +>; + +export interface vtkWebGPUOrderIndependentTranslucentPass extends vtkWebGPUOrderIndependentTranslucentPassBase { + /** + * Accumulate the translucent actors of a renderer into the color and + * revealage textures, then resolve them onto the color texture view set on + * this pass. + * + * @param {vtkWebGPURenderer} renNode The renderer view node to traverse. + * @param {vtkWebGPURenderWindow} viewNode The render window view node. + */ + traverse(renNode: vtkWebGPURenderer, viewNode: vtkWebGPURenderWindow): void; + + /** + * Draw the full screen quad resolving the two accumulation textures onto + * the color texture view set on this pass. + * + * @param {vtkWebGPURenderWindow} viewNode The render window view node. + * @param {vtkWebGPURenderer} renNode The renderer view node, used for its + * scissor and viewport. + */ + finalPass(viewNode: vtkWebGPURenderWindow, renNode: vtkWebGPURenderer): void; + + /** + * Get the color and revealage accumulation textures, in that order. + */ + getTextures(): vtkWebGPUTexture[]; + + /** Get the full screen quad that composites the accumulation textures. */ + getFullScreenQuad(): Nullable; + + /** Get the resolved color target used when multisampling is enabled. */ + getTranslucentResolveColorTexture(): Nullable; + + /** Get the resolved accumulation target used when multisampling is enabled. */ + getTranslucentResolveAccumulateTexture(): Nullable; + + /** + * Create the render encoder the translucent actors accumulate through, + * including the shader replacement computing the depth weighting. + */ + createRenderEncoder(sampleCount?: number): void; + + /** + * Create the render encoder the resolve pass is drawn with. + */ + createFinalEncoder(): void; + + /** + * Drop both encoders, both accumulation textures and the full screen quad + * so that they are recreated on the next traversal. + */ + releaseGraphicsResources(): void; + + /** + * Get the view of the texture the resolved color is drawn onto. + */ + getColorTextureView(): Nullable; + + /** + * Set the view of the texture the resolved color is drawn onto. + */ + setColorTextureView(colorTextureView: vtkWebGPUTextureView): boolean; + + /** + * Get the view of the depth texture the accumulation pass tests against. + */ + getDepthTextureView(): Nullable; + + /** + * Set the view of the depth texture the accumulation pass tests against. + */ + setDepthTextureView(depthTextureView: vtkWebGPUTextureView): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUOrderIndependentTranslucentPass characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUOrderIndependentTranslucentPassInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUOrderIndependentTranslucentPassInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUOrderIndependentTranslucentPass. + * @param {IWebGPUOrderIndependentTranslucentPassInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUOrderIndependentTranslucentPassInitialValues +): vtkWebGPUOrderIndependentTranslucentPass; + +/** + * vtkWebGPUOrderIndependentTranslucentPass renders translucent geometry with + * weighted blended order-independent transparency. Color and revealage + * accumulate into two floating point textures, which a full screen quad then + * resolves onto the opaque pass color texture, so the result does not depend + * on the order the translucent actors are drawn in. + */ +export declare const vtkWebGPUOrderIndependentTranslucentPass: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUOrderIndependentTranslucentPass; diff --git a/Sources/Rendering/WebGPU/Pipeline/index.d.ts b/Sources/Rendering/WebGPU/Pipeline/index.d.ts new file mode 100644 index 00000000000..85f45191687 --- /dev/null +++ b/Sources/Rendering/WebGPU/Pipeline/index.d.ts @@ -0,0 +1,209 @@ +/// + +import { Nullable } from '../../../types'; +import { vtkObject } from '../../../interfaces'; +import vtkWebGPUBindGroup from '../BindGroup'; +import vtkWebGPUDevice from '../Device'; +import vtkWebGPURenderEncoder from '../RenderEncoder'; +import vtkWebGPUShaderDescription, { + WebGPUShaderType, +} from '../ShaderDescription'; +import vtkWebGPUVertexInput from '../VertexInput'; + +/** + * The parts of a GPU render pipeline description vtk.js fills in from the + * render encoder and the mapper. The shader modules, the layout and the + * topology are added by the pipeline itself when it is initialized. + */ +export interface IWebGPUPipelineSettings { + label?: string; + layout?: GPUPipelineLayout | GPUAutoLayoutMode; + primitive?: Partial; + depthStencil?: Partial; + fragment?: Partial; + vertex?: Partial; +} + +/** + * A bind group layout of the pipeline, kept with the label of the bind group + * it came from so that bind groups can find their index. + */ +export interface IWebGPUPipelineLayoutEntry { + layout: GPUBindGroupLayout; + label: string; +} + +export interface IWebGPUPipelineInitialValues { + extraPipelineSettings?: Nullable; + handle?: Nullable; + layouts?: IWebGPUPipelineLayoutEntry[]; + renderEncoder?: Nullable; + shaderDescriptions?: vtkWebGPUShaderDescription[]; + vertexState?: Nullable; + topology?: Nullable; + pipelineDescription?: Nullable; +} + +export interface vtkWebGPUPipeline extends vtkObject { + /** + * Get the shader descriptions of every stage of this pipeline. + */ + getShaderDescriptions(): vtkWebGPUShaderDescription[]; + + /** + * Merge extra pipeline settings onto base settings, merging the primitive, + * depthStencil and fragment states one level deep. Returns the base settings + * unchanged when there are no extra settings. + * @param {IWebGPUPipelineSettings} baseSettings + * @param {IWebGPUPipelineSettings} extraSettings + */ + applyPipelineSettings( + baseSettings: IWebGPUPipelineSettings, + extraSettings?: Nullable + ): IWebGPUPipelineSettings; + + /** + * Create the GPU render pipeline from the render encoder settings, the bind + * group layouts and the shader descriptions added so far. + * @param {vtkWebGPUDevice} device + * @param {String} hash the label given to the pipeline + */ + initialize(device: vtkWebGPUDevice, hash: string): void; + + /** + * Get the shader description of a stage, or null when this pipeline has + * none for it. + * @param {WebGPUShaderType} stype + */ + getShaderDescription( + stype: WebGPUShaderType + ): Nullable; + + /** + * Append the layout of a bind group to the pipeline layout. Does nothing + * when the bind group is falsy. + * @param {vtkWebGPUBindGroup} bindGroup + */ + addBindGroupLayout(bindGroup: vtkWebGPUBindGroup): void; + + /** + * Get the bind group layout at an index. + * @param {Number} idx + */ + getBindGroupLayout(idx: number): GPUBindGroupLayout; + + /** + * Get the index of the bind group layout registered under a label, or -1 + * when there is none. + * @param {String} llabel + */ + getBindGroupLayoutIndex(llabel: string): number; + + /** + * Bind the buffers of a vertex input onto a render encoder. + * @param {vtkWebGPURenderEncoder} renderEncoder + * @param {vtkWebGPUVertexInput} vInput + */ + bindVertexInput( + renderEncoder: vtkWebGPURenderEncoder, + vInput: vtkWebGPUVertexInput + ): void; + + /** + * Get the underlying GPU render pipeline. + */ + getHandle(): Nullable; + + /** + * Get the description the GPU render pipeline was created from. + */ + getPipelineDescription(): Nullable; + + /** + * Get the device this pipeline is created on. + */ + getDevice(): Nullable; + + /** + * Set the device this pipeline is created on. + * @param {vtkWebGPUDevice} device + */ + setDevice(device: Nullable): boolean; + + /** + * Get the settings merged on top of the render encoder settings. + */ + getExtraPipelineSettings(): Nullable; + + /** + * Set the settings merged on top of the render encoder settings. + * @param {IWebGPUPipelineSettings} extraPipelineSettings + */ + setExtraPipelineSettings( + extraPipelineSettings: Nullable + ): boolean; + + /** + * Get the render encoder providing the base pipeline settings. + */ + getRenderEncoder(): Nullable; + + /** + * Set the render encoder providing the base pipeline settings. + * @param {vtkWebGPURenderEncoder} renderEncoder + */ + setRenderEncoder(renderEncoder: Nullable): boolean; + + /** + * Get the primitive topology this pipeline draws. + */ + getTopology(): Nullable; + + /** + * Set the primitive topology this pipeline draws. + * @param {GPUPrimitiveTopology} topology + */ + setTopology(topology: Nullable): boolean; + + /** + * Get the vertex state, i.e. the buffer layouts, of this pipeline. + */ + getVertexState(): Nullable; + + /** + * Set the vertex state, i.e. the buffer layouts, of this pipeline. + * @param {GPUVertexState} vertexState + */ + setVertexState(vertexState: Nullable): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUPipeline characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUPipelineInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUPipelineInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUPipeline. + * @param {IWebGPUPipelineInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUPipelineInitialValues +): vtkWebGPUPipeline; + +/** + * A GPU render pipeline, built from the settings of a render encoder, the bind + * group layouts of its bindables and the shader modules of its stages. + */ +export declare const vtkWebGPUPipeline: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUPipeline; diff --git a/Sources/Rendering/WebGPU/PixelSpaceCallbackMapper/index.d.ts b/Sources/Rendering/WebGPU/PixelSpaceCallbackMapper/index.d.ts new file mode 100644 index 00000000000..a6cb4d869a6 --- /dev/null +++ b/Sources/Rendering/WebGPU/PixelSpaceCallbackMapper/index.d.ts @@ -0,0 +1,45 @@ +import vtkRenderPass from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; + +export interface IWebGPUPixelSpaceCallbackMapperInitialValues extends IViewNodeInitialValues {} + +export interface vtkWebGPUPixelSpaceCallbackMapper extends vtkViewNode { + /** + * Invoke the callback of the renderable with the input data, the active + * camera, the aspect ratio and the tiled size and origin of the renderer. + * @param prepass + * @param {vtkRenderPass} renderPass + */ + opaquePass(prepass: boolean, renderPass: vtkRenderPass): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUPixelSpaceCallbackMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUPixelSpaceCallbackMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUPixelSpaceCallbackMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUPixelSpaceCallbackMapper. + * @param {IWebGPUPixelSpaceCallbackMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUPixelSpaceCallbackMapperInitialValues +): vtkWebGPUPixelSpaceCallbackMapper; + +/** + * The WebGPU view node of vtkPixelSpaceCallbackMapper. It draws nothing, it + * only hands the pixel space information to the renderable's callback. + */ +export declare const vtkWebGPUPixelSpaceCallbackMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUPixelSpaceCallbackMapper; diff --git a/Sources/Rendering/WebGPU/PolyDataMapper/index.d.ts b/Sources/Rendering/WebGPU/PolyDataMapper/index.d.ts new file mode 100644 index 00000000000..8d4e139501d --- /dev/null +++ b/Sources/Rendering/WebGPU/PolyDataMapper/index.d.ts @@ -0,0 +1,59 @@ +import vtkPolyData from '../../../Common/DataModel/PolyData'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; +import vtkWebGPUCellArrayMapper from '../CellArrayMapper'; + +export interface IWebGPUPolyDataMapperInitialValues extends IViewNodeInitialValues { + primitives?: vtkWebGPUCellArrayMapper[]; +} + +export interface vtkWebGPUPolyDataMapper extends vtkViewNode { + /** + * Create the cell array mapper drawing one primitive of the polydata. + */ + createCellArrayMapper(): vtkWebGPUCellArrayMapper; + + /** + * Update the renderable and rebuild the cell array mappers of its polydata. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * Create, configure and adopt one cell array mapper per non empty cell array + * of the polydata, plus the edge mappers when the actor's property has edge + * visibility. + * @param {vtkPolyData} poly + */ + updateCellArrayMappers(poly: vtkPolyData): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUPolyDataMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUPolyDataMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUPolyDataMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUPolyDataMapper. + * @param {IWebGPUPolyDataMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUPolyDataMapperInitialValues +): vtkWebGPUPolyDataMapper; + +/** + * The WebGPU view node of vtkMapper. It does not draw anything itself, it + * delegates each cell array of the polydata to a vtkWebGPUCellArrayMapper. + */ +export declare const vtkWebGPUPolyDataMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUPolyDataMapper; diff --git a/Sources/Rendering/WebGPU/PolyDataMapper2D/index.d.ts b/Sources/Rendering/WebGPU/PolyDataMapper2D/index.d.ts new file mode 100644 index 00000000000..37f526dc088 --- /dev/null +++ b/Sources/Rendering/WebGPU/PolyDataMapper2D/index.d.ts @@ -0,0 +1,58 @@ +import vtkPolyData from '../../../Common/DataModel/PolyData'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; +import vtkWebGPUCellArrayMapper from '../CellArrayMapper'; + +export interface IWebGPUPolyDataMapper2DInitialValues extends IViewNodeInitialValues { + primitives?: vtkWebGPUCellArrayMapper[]; +} + +export interface vtkWebGPUPolyDataMapper2D extends vtkViewNode { + /** + * Create the cell array mapper drawing one primitive of the polydata. + */ + createCellArrayMapper(): vtkWebGPUCellArrayMapper; + + /** + * Update the renderable and rebuild the cell array mappers of its polydata. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * Create, configure and adopt one cell array mapper per non empty cell array + * of the polydata, up to the triangles, each drawing in 2D. + * @param {vtkPolyData} poly + */ + updateCellArrayMappers(poly: vtkPolyData): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUPolyDataMapper2D characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUPolyDataMapper2DInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUPolyDataMapper2DInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUPolyDataMapper2D. + * @param {IWebGPUPolyDataMapper2DInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUPolyDataMapper2DInitialValues +): vtkWebGPUPolyDataMapper2D; + +/** + * The WebGPU view node of vtkMapper2D. It delegates each cell array of the + * polydata to a vtkWebGPUCellArrayMapper drawing in 2D. + */ +export declare const vtkWebGPUPolyDataMapper2D: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUPolyDataMapper2D; diff --git a/Sources/Rendering/WebGPU/Profiles/All.d.ts b/Sources/Rendering/WebGPU/Profiles/All.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/WebGPU/Profiles/All.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/WebGPU/Profiles/Geometry.d.ts b/Sources/Rendering/WebGPU/Profiles/Geometry.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/WebGPU/Profiles/Geometry.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/WebGPU/Profiles/Glyph.d.ts b/Sources/Rendering/WebGPU/Profiles/Glyph.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/WebGPU/Profiles/Glyph.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/WebGPU/Profiles/LIC.d.ts b/Sources/Rendering/WebGPU/Profiles/LIC.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/WebGPU/Profiles/LIC.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/WebGPU/Profiles/Molecule.d.ts b/Sources/Rendering/WebGPU/Profiles/Molecule.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/WebGPU/Profiles/Molecule.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/WebGPU/Profiles/Volume.d.ts b/Sources/Rendering/WebGPU/Profiles/Volume.d.ts new file mode 100644 index 00000000000..47493a6c9d6 --- /dev/null +++ b/Sources/Rendering/WebGPU/Profiles/Volume.d.ts @@ -0,0 +1,5 @@ +/** + * Profile modules are imported for their side effects only: they register the + * class implementations needed by the corresponding rendering back-end. + */ +export {}; diff --git a/Sources/Rendering/WebGPU/RenderEncoder/index.d.ts b/Sources/Rendering/WebGPU/RenderEncoder/index.d.ts new file mode 100644 index 00000000000..fae4808fe08 --- /dev/null +++ b/Sources/Rendering/WebGPU/RenderEncoder/index.d.ts @@ -0,0 +1,267 @@ +/// + +import { Nullable } from '../../../types'; +import { vtkObject } from '../../../interfaces'; +import vtkWebGPUBindGroup from '../BindGroup'; +import vtkWebGPUPipeline, { IWebGPUPipelineSettings } from '../Pipeline'; +import vtkWebGPUTextureView from '../TextureView'; + +/** + * A callback registered by a mapper, invoked with the render encoder once its + * pipeline is bound. + */ +export type WebGPUDrawCallback = ( + renderEncoder: vtkWebGPURenderEncoder +) => void; + +export interface IWebGPURenderEncoderInitialValues { + description?: GPURenderPassDescriptor; + handle?: Nullable; + boundPipeline?: Nullable; + pipelineHash?: Nullable; + pipelineSettings?: IWebGPUPipelineSettings; + replaceShaderCodeFunction?: Nullable<(pipeline: vtkWebGPUPipeline) => void>; + depthTextureView?: Nullable; + label?: Nullable; +} + +export interface vtkWebGPURenderEncoder extends vtkObject { + /** + * Begin the render pass on a command encoder, clearing the draw callbacks + * registered for the previous pass. + * @param {GPUCommandEncoder} encoder + */ + begin(encoder: GPUCommandEncoder): void; + + /** + * Invoke the registered draw callbacks, pipeline by pipeline, then end the + * render pass. + */ + end(): void; + + /** + * Bind a pipeline, unless it is already bound, and check that its + * attachments match the ones of this encoder. + * @param {vtkWebGPUPipeline} pl + */ + setPipeline(pl: vtkWebGPUPipeline): void; + + /** + * Apply this encoder's shader replacements to a pipeline. + * @param {vtkWebGPUPipeline} pipeline + */ + replaceShaderCode(pipeline: vtkWebGPUPipeline): void; + + /** + * Set the texture view of a color attachment. + * @param {Number} idx + * @param {vtkWebGPUTextureView} view + */ + setColorTextureView(idx: number, view: vtkWebGPUTextureView): void; + + /** Set or clear the resolve target of a multisampled color attachment. */ + setResolveTextureView( + idx: number, + view: Nullable + ): void; + + /** + * Bind a bind group at the index the bound pipeline registered its layout + * under. + * @param {vtkWebGPUBindGroup} bg + */ + activateBindGroup(bg: vtkWebGPUBindGroup): void; + + /** + * Point the color and depth attachments of the pass description at the + * handles of the currently set texture views. + */ + attachTextureViews(): void; + + /** + * Register a draw callback to run for a pipeline when the pass ends. + * @param {vtkWebGPUPipeline} pipeline + * @param {WebGPUDrawCallback} cb + */ + registerDrawCallback( + pipeline: vtkWebGPUPipeline, + cb: WebGPUDrawCallback + ): void; + + /** + * Forwarded to the underlying render pass encoder. + */ + setBindGroup( + index: GPUIndex32, + bindGroup: Nullable, + dynamicOffsets?: Iterable + ): void; + + /** + * Forwarded to the underlying render pass encoder. + */ + setIndexBuffer( + buffer: GPUBuffer, + indexFormat: GPUIndexFormat, + offset?: GPUSize64, + size?: GPUSize64 + ): void; + + /** + * Forwarded to the underlying render pass encoder. + */ + setVertexBuffer( + slot: GPUIndex32, + buffer: Nullable, + offset?: GPUSize64, + size?: GPUSize64 + ): void; + + /** + * Forwarded to the underlying render pass encoder. + */ + draw( + vertexCount: GPUSize32, + instanceCount?: GPUSize32, + firstVertex?: GPUSize32, + firstInstance?: GPUSize32 + ): void; + + /** + * Forwarded to the underlying render pass encoder. + */ + drawIndexed( + indexCount: GPUSize32, + instanceCount?: GPUSize32, + firstIndex?: GPUSize32, + baseVertex?: GPUSignedOffset32, + firstInstance?: GPUSize32 + ): void; + + /** + * Get the pipeline currently bound on this encoder. + */ + getBoundPipeline(): Nullable; + + /** + * Get the texture views of the color attachments. + */ + getColorTextureViews(): vtkWebGPUTextureView[]; + + /** + * Get the texture view of the depth attachment. + */ + getDepthTextureView(): Nullable; + + /** + * Set the texture view of the depth attachment. + * @param {vtkWebGPUTextureView} depthTextureView + */ + setDepthTextureView( + depthTextureView: Nullable + ): boolean; + + /** + * Get the render pass description this encoder begins its pass with. + */ + getDescription(): GPURenderPassDescriptor; + + /** + * Set the render pass description this encoder begins its pass with. + * @param {GPURenderPassDescriptor} description + */ + setDescription(description: GPURenderPassDescriptor): boolean; + + /** + * Get the underlying render pass encoder, valid between begin() and end(). + */ + getHandle(): Nullable; + + /** + * Set the underlying render pass encoder. + * @param {GPURenderPassEncoder} handle + */ + setHandle(handle: Nullable): boolean; + + /** + * Get the debug label pushed around the render pass. + */ + getLabel(): Nullable; + + /** + * Set the debug label pushed around the render pass. + * @param {String} label + */ + setLabel(label: Nullable): boolean; + + /** + * Get the string mappers add to their pipeline hash for this encoder. + */ + getPipelineHash(): Nullable; + + /** + * Set the string mappers add to their pipeline hash for this encoder. + * @param {String} pipelineHash + */ + setPipelineHash(pipelineHash: Nullable): boolean; + + /** + * Get the pipeline settings every pipeline drawing into this encoder starts + * from. + */ + getPipelineSettings(): IWebGPUPipelineSettings; + + /** + * Set the pipeline settings every pipeline drawing into this encoder starts + * from. + * @param {IWebGPUPipelineSettings} pipelineSettings + */ + setPipelineSettings(pipelineSettings: IWebGPUPipelineSettings): boolean; + + /** + * Get the function performing this encoder's shader replacements. + */ + getReplaceShaderCodeFunction(): Nullable< + (pipeline: vtkWebGPUPipeline) => void + >; + + /** + * Set the function performing this encoder's shader replacements. The + * default one writes the computed color out to the first color attachment. + * @param replaceShaderCodeFunction + */ + setReplaceShaderCodeFunction( + replaceShaderCodeFunction: Nullable<(pipeline: vtkWebGPUPipeline) => void> + ): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPURenderEncoder characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPURenderEncoderInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPURenderEncoderInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPURenderEncoder. + * @param {IWebGPURenderEncoderInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPURenderEncoderInitialValues +): vtkWebGPURenderEncoder; + +/** + * One render pass: the attachments it draws into, the pipeline settings its + * pipelines are built from, and the draw callbacks the mappers register. + */ +export declare const vtkWebGPURenderEncoder: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPURenderEncoder; diff --git a/Sources/Rendering/WebGPU/RenderWindow/index.d.ts b/Sources/Rendering/WebGPU/RenderWindow/index.d.ts index 0e67915d6a7..7a0343134df 100644 --- a/Sources/Rendering/WebGPU/RenderWindow/index.d.ts +++ b/Sources/Rendering/WebGPU/RenderWindow/index.d.ts @@ -1,152 +1,212 @@ -import { vtkObject, vtkSubscription } from '../../../interfaces'; -import { Nullable } from '../../../types'; +/// + +import { Nullable, Size, Vector2 } from '../../../types'; +import { vtkSubscription } from '../../../interfaces'; +import { + IRenderWindowViewNodeInitialValues, + vtkRenderWindowViewNode, +} from '../../SceneGraph/RenderWindowViewNode'; import { vtkViewNode } from '../../SceneGraph/ViewNode'; +import vtkRenderPass from '../../SceneGraph/RenderPass'; +import vtkRenderer from '../../Core/Renderer'; +import vtkViewStream from '../../../IO/Core/ImageStream/ViewStream'; +import vtkWebGPUDevice from '../Device'; import { vtkWebGPUConfiguration } from '../Configuration'; +import vtkWebGPUViewNodeFactory from '../ViewNodeFactory'; -export interface IWebGPURenderWindowInitialValues { +export interface IWebGPURenderWindowInitialValues extends IRenderWindowViewNodeInitialValues { initialized?: boolean; - context?: any; - webGPUConfiguration?: vtkWebGPUConfiguration; - canvas?: HTMLCanvasElement; + initializing?: boolean; + handlingDeviceLost?: boolean; + deviceGeneration?: number; + deviceLostInfo?: Nullable; + context?: Nullable; + adapter?: Nullable; + device?: Nullable; + canvas?: Nullable; + cursorVisibility?: boolean; cursor?: string; - useOffScreen?: boolean; + containerSize?: Nullable; + renderPasses?: vtkRenderPass[]; + notifyStartCaptureImage?: boolean; imageFormat?: string; + useOffScreen?: boolean; useBackgroundImage?: boolean; + nextPropID?: number; xrSupported?: boolean; - presentationFormat?: Nullable; + presentationFormat?: Nullable; + webGPUConfiguration?: Nullable; multiSample?: 1 | 4; - size?: [number, number]; +} + +export interface IWebGPUCaptureOptions { + resetCamera?: boolean | ((options: { renderer: vtkRenderer }) => void); + size?: Nullable; + scale?: number; +} + +/** + * The payload of the deviceLost event. + */ +export interface IWebGPUDeviceLostEvent { + reason: GPUDeviceLostReason; + message: string; + + /** + * False when the device was lost because it was destroyed, in which case no + * new device is acquired. + */ + recoverable: boolean; } /** - * vtkWebGPURenderWindow is designed to view/render a vtkRenderWindow - * using the WebGPU API. + * The payload of the windowResize event. */ -export interface vtkWebGPURenderWindow extends vtkViewNode { - // ------------------------------------------------------------------- - // Explicitly defined methods on publicAPI - // ------------------------------------------------------------------- +export interface IWebGPUWindowResizeEvent { + width: number; + height: number; +} + +/** + * The pixels read back from the color texture of the forward pass. + */ +export interface IWebGPUPixels { + width: number; + height: number; + + /** + * The width, in texels, of the readback buffer. Rounded up so that a row is + * a multiple of 256 bytes, as WebGPU requires. + */ + colorBufferWidth: number; + colorBufferSizeInBytes: number; /** - * Get the view-node factory used to create WebGPU scene-graph nodes. + * The RGBA values of the image, tightly packed at `width` texels per row. */ - getViewNodeFactory(): any; + colorValues: Uint8ClampedArray; +} +export interface vtkWebGPURenderWindow extends vtkRenderWindowViewNode { /** - * Unconfigure and reconfigure the swap chain. Called automatically when - * the canvas size changes. + * Get the factory creating the WebGPU view nodes of this render window. + */ + getViewNodeFactory(): vtkWebGPUViewNodeFactory; + + /** + * Reconfigure the canvas context for the current device and size. */ recreateSwapChain(): void; /** - * Get the current swap-chain texture from the canvas context. + * Get the texture the canvas context is presenting this frame. */ - getCurrentTexture(): any; + getCurrentTexture(): GPUTexture; /** - * Build pass callback invoked by the scene-graph traversal. - * @param prepass Whether this is the pre-pass (`true`) or post-pass (`false`). + * Builds myself: adopt the renderers of the renderable as children and, on + * the second visit, create the command encoder of the frame. + * @param {Boolean} prepass */ buildPass(prepass: boolean): void; /** - * Initialize the render window. Triggers async GPU adapter/device - * creation; fires the `initialized` event on completion. + * Start acquiring the adapter, the device and the canvas context, unless + * that is already under way. The initialized event fires once they are + * available. */ initialize(): void; /** - * Set the container element for the render window. - * @param el The HTML element to use as the container, or `null` to detach. + * Move the canvas into a container element. + * @param {HTMLElement} el The container element. */ setContainer(el: Nullable): void; /** - * Get the current container element. + * Get the container element. */ getContainer(): Nullable; /** - * Get the size of the container element in pixels. - * @returns [width, height] + * Get the size of the container element, falling back to the size of the + * render window when there is no container. */ - getContainerSize(): [number, number]; + getContainerSize(): Vector2; /** - * Get the framebuffer size. - * @returns [width, height] + * Get the frame buffer size. */ - getFramebufferSize(): [number, number]; + getFramebufferSize(): Vector2; /** - * Create the WebGPU 3D context asynchronously. Initializes the - * configuration, which supplies the adapter and device, then configures the - * canvas context. + * Request the adapter and the device, watch the device for loss, and get + * the WebGPU context of the canvas. Resolves once the context is ready, or + * early when the render window was deleted while waiting. */ - create3DContextAsync(): Promise; + create3DContextAsync(): Promise; /** - * Release all GPU resources and clean up the rendering context. + * Release the resources of the render passes and of every view node, and + * drop the adapter, device and context. The render window initializes again + * on the next traversal. */ releaseGraphicsResources(): void; /** - * Set the background image element. - * @param img The image element. + * @param {HTMLImageElement} img The background image. */ setBackgroundImage(img: HTMLImageElement): void; /** - * Enable or disable rendering of a background image behind the scene. - * @param value Whether to use the background image. + * Add or remove the background image from the container. + * @param {Boolean} value */ setUseBackgroundImage(value: boolean): void; /** - * Capture the next rendered frame as an image. - * @param format The image format (default: 'image/png'). - * @param opts Options for capture. - * @param opts.resetCamera Whether to reset the camera before capture. - * @param opts.size Override the render size as [width, height]. - * @param opts.scale Scale factor for the render size. + * Capture a screenshot of the contents of this render window. The options + * object can include a `size` array (`[w, h]`) or a `scale` floating point + * value, as well as a `resetCamera` boolean. Returns a promise that + * resolves to the captured screenshot, or null when the render window was + * already deleted. + * @param {String} format + * @param {IWebGPUCaptureOptions} options */ captureNextImage( format?: string, - opts?: { resetCamera?: boolean; size?: [number, number]; scale?: number } - ): Promise; + options?: IWebGPUCaptureOptions + ): Nullable>; /** - * Traverse all registered render passes. + * Traverse the render passes, submitting the command encoder of the frame + * when they are done. Queues the traversal until the device is available + * when the render window is not initialized yet. */ traverseAllPasses(): void; /** - * Set a view stream for remote rendering. - * @param stream The view stream instance. + * @param {vtkViewStream} stream The vtkViewStream instance. */ - setViewStream(stream: any): boolean; + setViewStream(stream: vtkViewStream): boolean; /** - * Get a unique prop ID for hardware selection. + * Get an id no other prop of this render window uses, for hardware + * selection. */ getUniquePropID(): number; /** - * Get a prop (actor) by its hardware-selection ID. - * @param id The prop ID. - * @returns The matching prop, or `null` if not found. + * Get the view node of the prop holding an id, or null when none does. + * @param {Number} id */ - getPropFromID(id: number): vtkObject | null; + getPropFromID(id: number): Nullable; /** - * Read pixels from the current framebuffer asynchronously. - * Returns an object with `colorValues` (Uint8ClampedArray), `width`, and `height`. + * Read the color texture of the forward pass back into a tightly packed + * RGBA array. */ - getPixelsAsync(): Promise<{ - colorValues: Uint8ClampedArray; - width: number; - height: number; - }>; + getPixelsAsync(): Promise; /** * Create a hardware selector bound to this render window. @@ -154,223 +214,218 @@ export interface vtkWebGPURenderWindow extends vtkViewNode { createSelector(): any; /** - * Set the size of the render window. - * @param width Width in pixels. - * @param height Height in pixels. + * Sets the pixel width and height of the rendered image, and fires the + * windowResizeEvent when they changed. + * @param {Vector2} size */ - setSize(width: number, height: number): boolean; + setSize(size: Vector2): boolean; /** - * Controls the number of MSAA samples per pixel. - * - * - **Default:** `1` (no anti-aliasing) - * - * @param count The sample count (`1` or `4`). - * @returns `true` if the value changed, `false` otherwise. + * @param {Number} x + * @param {Number} y */ - setMultiSample(count: 1 | 4): boolean; + setSize(x: number, y: number): boolean; - // ------------------------------------------------------------------- - // macro.get (getter-only) - // ------------------------------------------------------------------- + /** + */ + getSize(): Vector2; /** - * Get the WebGPU command encoder for the current frame. */ - getCommandEncoder(): any; + getSizeByReference(): Vector2; /** - * Get whether a background image is being used. + * @param {Vector2} size */ - getUseBackgroundImage(): boolean; + setSizeFrom(size: Vector2): void; /** - * Get whether XR (WebXR) is supported. + * Get the command encoder of the frame being built. */ - getXrSupported(): boolean; + getCommandEncoder(): Nullable; /** - * Get the current MSAA sample count. + * Get the information of the last device loss, or null when the device was + * never lost or was reacquired. */ - getMultiSample(): 1 | 4; + getDeviceLostInfo(): Nullable; - // ------------------------------------------------------------------- - // macro.setGet - // ------------------------------------------------------------------- + /** + * Get the device this render window renders with. + */ + getDevice(): Nullable; /** - * Get whether the render window has been initialized. + * Get the configuration that supplies the adapter and device. */ - getInitialized(): boolean; + getWebGPUConfiguration(): vtkWebGPUConfiguration; /** - * Set the initialized state. - * @param initialized Whether initialized. + * Set the configuration before initialization. Passing null creates an + * internally owned configuration. */ - setInitialized(initialized: boolean): boolean; + setWebGPUConfiguration( + configuration: Nullable + ): boolean; /** - * Get the WebGPU canvas context. + * Get the texture format the canvas context is configured with. */ - getContext(): any; + getPresentationFormat(): Nullable; /** - * Set the WebGPU canvas context. - * @param context The GPU canvas context. + * Get the number of samples per pixel. */ - setContext(context: any): boolean; + getMultiSample(): 1 | 4; /** - * Get the current canvas element. + * Set the number of samples per pixel. Supported values are 1 and 4. */ - getCanvas(): HTMLCanvasElement; + setMultiSample(count: 1 | 4): boolean; /** - * Set the canvas element. - * @param canvas The canvas element. + * Whether the background image is attached to the container. */ - setCanvas(canvas: HTMLCanvasElement): boolean; + getUseBackgroundImage(): boolean; /** - * Get the vtkWebGPUDevice that holds resource caches for this - * render window, or null before initialization. - * - * One instance of this wrapper exists for each native device. Thus, render - * windows that share a configuration also share this object. Use - * `getWebGPUConfiguration().getDevice()` to get the native `GPUDevice`. */ - getDevice(): any; + getXrSupported(): boolean; /** - * Set the configuration that supplies the adapter and the device. - * - * Set this before initialization. Render windows that share a configuration - * share one device, and thus one set of vtk.js resource caches. Set null to - * go back to a configuration that this render window creates and owns. - * - * @param configuration the configuration to use, or null - * @returns true if the value changed + * Whether the device and the canvas context are ready. */ - setWebGPUConfiguration( - configuration: Nullable - ): boolean; + getInitialized(): boolean; /** - * Get the configuration that supplies the adapter and the device. - * - * A render window always has a configuration. Unless the application gives - * one, the render window creates and owns it, and deletes it with itself. + * @param {Boolean} initialized */ - getWebGPUConfiguration(): vtkWebGPUConfiguration; + setInitialized(initialized: boolean): boolean; /** - * Get the render passes. + * Get the WebGPU context of the canvas. */ - getRenderPasses(): any[]; + getContext(): Nullable; /** - * Set the render passes. - * @param passes Array of render passes. + * @param {GPUCanvasContext} context */ - setRenderPasses(passes: any[]): boolean; + setContext(context: Nullable): boolean; /** - * Get whether image capture notification is enabled. + * Get the canvas rendered into. + */ + getCanvas(): Nullable; + + /** + * @param {HTMLCanvasElement} canvas + */ + setCanvas(canvas: Nullable): boolean; + + /** + * Get the render passes traversed on every render. + */ + getRenderPasses(): vtkRenderPass[]; + + /** + * @param {vtkRenderPass[]} renderPasses + */ + setRenderPasses(renderPasses: vtkRenderPass[]): boolean; + + /** + * Whether the image ready event fires once the frame is done. */ getNotifyStartCaptureImage(): boolean; /** - * Set whether image capture notification is enabled. - * @param notify Whether to notify on capture start. + * @param {Boolean} notifyStartCaptureImage */ - setNotifyStartCaptureImage(notify: boolean): boolean; + setNotifyStartCaptureImage(notifyStartCaptureImage: boolean): boolean; /** - * Get the current cursor style. + * Get the CSS cursor of the container. */ getCursor(): string; /** - * Set the cursor style. - * @param cursor CSS cursor value. + * @param {String} cursor */ setCursor(cursor: string): boolean; /** - * Get whether off-screen rendering is enabled. + * Whether the canvas is hidden. */ getUseOffScreen(): boolean; /** - * Set whether to use off-screen rendering. - * @param useOffScreen Whether to render off-screen. + * @param {Boolean} useOffScreen */ setUseOffScreen(useOffScreen: boolean): boolean; /** - * Get the presentation texture format used by the swap chain. + * Call any registered callbacks with the captured image URL. + * @param {String} imageURL */ - getPresentationFormat(): string | null; - - // ------------------------------------------------------------------- - // macro.setGetArray - // ------------------------------------------------------------------- + invokeImageReady(imageURL: string): void; /** - * Get the current render window size. - * @returns [width, height] + * Register a callback to be called whenever a captured image becomes ready. + * @param callback */ - getSize(): [number, number]; - - // ------------------------------------------------------------------- - // macro.event - // ------------------------------------------------------------------- + onImageReady( + callback: (imageURL: string) => any, + priority?: number + ): vtkSubscription; /** - * Register a callback for when a captured image is ready. - * @param callback Called with the image data URL string. + * Call any registered callbacks once the device and the context are ready. */ - onImageReady(callback: (imageURL: string) => void): vtkSubscription; + invokeInitialized(): void; /** - * Programmatically fire the imageReady event. - * @param imageURL The image data URL. + * Register a callback to be called once the device and the context are + * ready. + * @param callback */ - invokeImageReady(imageURL: string): void; + onInitialized(callback: () => any, priority?: number): vtkSubscription; /** - * Register a callback for when the render window has finished initializing. - * @param callback Called once GPU context creation is complete. + * Call any registered callbacks with the reason the device was lost. + * @param {IWebGPUDeviceLostEvent} event */ - onInitialized(callback: () => void): vtkSubscription; + invokeDeviceLost(event: IWebGPUDeviceLostEvent): void; /** - * Programmatically fire the initialized event. + * Register a callback to be called whenever the device is lost. + * @param callback */ - invokeInitialized(): void; + onDeviceLost( + callback: (event: IWebGPUDeviceLostEvent) => any, + priority?: number + ): vtkSubscription; /** - * Register a callback for window resize events. - * @param callback Called with `{ width, height }` when the window is resized. + * Call any registered callbacks whenever setSize() changes the size. + * @param {IWebGPUWindowResizeEvent} size */ - onWindowResizeEvent( - callback: (event: { width: number; height: number }) => void - ): vtkSubscription; + invokeWindowResizeEvent(size: IWebGPUWindowResizeEvent): void; /** - * Programmatically fire the windowResizeEvent. - * @param event The resize event payload. + * Register a callback to be called whenever setSize() changes the size. + * @param callback */ - invokeWindowResizeEvent(event: { width: number; height: number }): void; + onWindowResizeEvent( + callback: (size: IWebGPUWindowResizeEvent) => any, + priority?: number + ): vtkSubscription; } /** - * Method used to decorate a given object (publicAPI+model) with - * vtkWebGPURenderWindow characteristics. + * Method used to decorate a given object (publicAPI+model) with vtkWebGPURenderWindow characteristics. * - * @param publicAPI object on which methods will be bound (public) - * @param model object on which data structure will be bound (protected) - * @param initialValues (default: {}) + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPURenderWindowInitialValues} [initialValues] (default: {}) */ export function extend( publicAPI: object, @@ -380,15 +435,18 @@ export function extend( /** * Method used to create a new instance of vtkWebGPURenderWindow. - * @param initialValues Initial property values. + * @param {IWebGPURenderWindowInitialValues} [initialValues] for pre-setting some of its content */ export function newInstance( initialValues?: IWebGPURenderWindowInitialValues ): vtkWebGPURenderWindow; /** - * vtkWebGPURenderWindow is designed to view/render a vtkRenderWindow - * using the WebGPU API. + * WebGPU rendering window + * + * vtkWebGPURenderWindow is designed to view/render a vtkRenderWindow with the + * WebGPU backend. It owns the canvas, the adapter and the device, and it + * reacquires them when the device is lost. */ export declare const vtkWebGPURenderWindow: { newInstance: typeof newInstance; diff --git a/Sources/Rendering/WebGPU/Renderer/index.d.ts b/Sources/Rendering/WebGPU/Renderer/index.d.ts new file mode 100644 index 00000000000..a7086574eb0 --- /dev/null +++ b/Sources/Rendering/WebGPU/Renderer/index.d.ts @@ -0,0 +1,245 @@ +import { Nullable, Vector3 } from '../../../types'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; +import vtkWebGPUBindGroup from '../BindGroup'; +import vtkWebGPUHardwareSelector from '../HardwareSelector'; +import vtkWebGPURenderEncoder from '../RenderEncoder'; +import vtkWebGPUUniformBuffer from '../UniformBuffer'; +import vtkWebGPUTextureView from '../TextureView'; + +/** + * The pixel extent of this renderer's viewport within the render window. + */ +export interface IWebGPUTiledSizeAndOrigin { + usize: number; + vsize: number; + lowerLeftU: number; + lowerLeftV: number; +} + +export interface IWebGPURendererInitialValues extends IViewNodeInitialValues { + bindGroup?: Nullable; + selector?: any; + renderEncoder?: Nullable; + recenterThreshold?: number; + suppressClear?: boolean; + stabilizedCenter?: Vector3; + opaqueColorTextureView?: Nullable; +} + +export interface vtkWebGPURenderer extends vtkViewNode { + /** Get the opaque background available for transmission rendering. */ + getOpaqueColorTextureView(): Nullable; + + /** Set or clear the opaque background for transmission rendering. */ + setOpaqueColorTextureView( + opaqueColorTextureView: Nullable + ): boolean; + + /** + * Builds myself: adopt the active camera and every view prop of the + * renderable as children, and update the stabilized matrix. + * @param {Boolean} prepass + */ + buildPass(prepass: boolean): void; + + /** + * Recenter the stabilized coordinate system when the center of the view + * frustum has moved far enough, relative to the clipping range, that single + * precision rendering would suffer. + */ + updateStabilizedMatrix(): void; + + /** + * Create a default light when the renderable has none switched on. + * @returns the number of lights that are on. + */ + updateLights(): number; + + /** + * Push the camera matrices, the light count and the viewport size into the + * renderer uniform buffer, when anything they depend on has changed. + */ + updateUBO(): void; + + /** + * Push the light positions, directions, colors and attenuations into the + * renderer storage buffer, when the lights have changed. + */ + updateSSBO(): void; + + /** + * Set the viewport and the scissor rectangle of an encoder to this + * renderer's viewport. + * @param {vtkWebGPURenderEncoder} encoder + */ + scissorAndViewport(encoder: vtkWebGPURenderEncoder): void; + + /** + * Bind the renderer bind group, holding the uniform and light buffers. + * @param {vtkWebGPURenderEncoder} renderEncoder + */ + bindUBO(renderEncoder: vtkWebGPURenderEncoder): void; + + /** + * Renders myself. + * @param {Boolean} prepass + */ + opaquePass(prepass: boolean): void; + + /** + * @param {Boolean} prepass + */ + zBufferPass(prepass: boolean): void; + + /** + * @param {Boolean} prepass + */ + opaqueZBufferPass(prepass: boolean): void; + + /** + * Draw the background of the renderer, unless the renderable is transparent + * or clearing is suppressed. + */ + clear(): void; + + /** + * @param {Boolean} prepass + */ + translucentPass(prepass: boolean): void; + + /** + * @param {Boolean} prepass + */ + volumeDepthRangePass(prepass: boolean): void; + + /** + * The aspect ratio of this renderer's viewport, in pixels. + */ + getAspectRatio(): number; + + /** + * Convert a WebGPU depth value to the OpenGL depth convention. + * @param {Number} val + */ + convertToOpenGLDepth(val: number): number; + + /** + * The pixel size and origin of this renderer's viewport, with the origin + * measured from the top of the render window. + */ + getYInvertedTiledSizeAndOrigin(): IWebGPUTiledSizeAndOrigin; + + /** + * The pixel size and lower-left origin of this renderer's viewport. + */ + getTiledSizeAndOrigin(): IWebGPUTiledSizeAndOrigin; + + /** + * Get the child node whose prop id matches, or null when none does. + * @param {Number} id + */ + getPropFromID(id: number): Nullable; + + /** + * The modified time of the stabilized coordinate system, which changes + * whenever the stabilized center is recentered. + */ + getStabilizedTime(): number; + + /** + */ + releaseGraphicsResources(): void; + + /** + * Get the bind group holding the renderer uniform and light buffers. + */ + getBindGroup(): vtkWebGPUBindGroup; + + /** + * Get a copy of the center of the stabilized coordinate system, in world + * coordinates. + */ + getStabilizedCenter(): Vector3; + + /** + * Get the center of the stabilized coordinate system without copying it. + */ + getStabilizedCenterByReference(): Vector3; + + /** + * Get the encoder this renderer draws its passes into. + */ + getRenderEncoder(): Nullable; + + /** + * Set the encoder this renderer draws its passes into. + * @param {vtkWebGPURenderEncoder} renderEncoder + */ + setRenderEncoder(renderEncoder: Nullable): boolean; + + /** + * Get the hardware selector currently selecting through this renderer. + */ + getSelector(): Nullable; + + /** + * Set the hardware selector currently selecting through this renderer. + * @param selector + */ + setSelector(selector: Nullable): boolean; + + /** + * Whether clearing the viewport is suppressed, e.g. when another renderer + * has already drawn into it. + */ + getSuppressClear(): boolean; + + /** + * Set whether clearing the viewport is suppressed. + * @param {Boolean} suppressClear + */ + setSuppressClear(suppressClear: boolean): boolean; + + /** + * Get the uniform buffer holding the camera matrices of this renderer. + */ + getUBO(): vtkWebGPUUniformBuffer; + + /** + * Set the uniform buffer holding the camera matrices of this renderer. + * @param {vtkWebGPUUniformBuffer} UBO + */ + setUBO(UBO: vtkWebGPUUniformBuffer): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPURenderer characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPURendererInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPURendererInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPURenderer. + * @param {IWebGPURendererInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPURendererInitialValues +): vtkWebGPURenderer; + +/** + * The WebGPU view node of a vtkRenderer: it owns the renderer uniform and + * light buffers, the stabilized coordinate system, and the viewport of the + * render passes. + */ +export declare const vtkWebGPURenderer: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPURenderer; diff --git a/Sources/Rendering/WebGPU/Sampler/index.d.ts b/Sources/Rendering/WebGPU/Sampler/index.d.ts new file mode 100644 index 00000000000..9c1eae88741 --- /dev/null +++ b/Sources/Rendering/WebGPU/Sampler/index.d.ts @@ -0,0 +1,110 @@ +/// + +import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; +import vtkWebGPUDevice from '../Device'; + +export interface IWebGPUSamplerInitialValues { + device?: vtkWebGPUDevice; + handle?: GPUSampler; + label?: string; + options?: GPUSamplerDescriptor; + bindGroupLayoutEntry?: Partial; +} + +export interface vtkWebGPUSampler extends vtkObject { + /** + * Create the GPUSampler. Any address mode or filter left out of the options + * falls back to 'clamp-to-edge' and 'nearest' respectively. + * @param device The device to create the sampler on. + * @param {GPUSamplerDescriptor} [options] (default: {}) + */ + create(device: vtkWebGPUDevice, options?: GPUSamplerDescriptor): void; + + /** + * Get the WGSL declaration of this sampler. + * @param binding The binding index. + * @param group The bind group index. + */ + getShaderCode(binding: number, group: number): string; + + /** + * Get the bind group entry for this sampler. The binding index is filled in + * by the bind group. + */ + getBindGroupEntry(): Omit; + + /** + * Get the object whose modified time changes when the sampler is created. + */ + getBindGroupTime(): vtkObject; + + /** + * Get the GPUSampler. + */ + getHandle(): Nullable; + + /** + * Get the descriptor the sampler was created with. + */ + getOptions(): GPUSamplerDescriptor; + + /** + * Get the bind group layout entry describing this sampler. + */ + getBindGroupLayoutEntry(): Partial; + + /** + * Set the bind group layout entry describing this sampler. + */ + setBindGroupLayoutEntry( + bindGroupLayoutEntry: Partial + ): boolean; + + /** + * Get the device the sampler belongs to. + */ + getDevice(): Nullable; + + /** + * Set the device the sampler belongs to. + */ + setDevice(device: vtkWebGPUDevice): boolean; + + /** + * Get the WGSL name of the sampler. + */ + getLabel(): Nullable; + + /** + * Set the WGSL name of the sampler. + */ + setLabel(label: string): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUSampler characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUSamplerInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUSamplerInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUSampler. + * @param {IWebGPUSamplerInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUSamplerInitialValues +): vtkWebGPUSampler; + +export declare const vtkWebGPUSampler: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUSampler; diff --git a/Sources/Rendering/WebGPU/ScalarBarActor/index.d.ts b/Sources/Rendering/WebGPU/ScalarBarActor/index.d.ts new file mode 100644 index 00000000000..206ab6ba163 --- /dev/null +++ b/Sources/Rendering/WebGPU/ScalarBarActor/index.d.ts @@ -0,0 +1,51 @@ +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; + +export interface IWebGPUScalarBarActorInitialValues extends IViewNodeInitialValues {} + +export interface vtkWebGPUScalarBarActor extends vtkViewNode { + /** + * Builds myself: bind the scalar bar helper to the renderable and adopt the + * bar and text actors it owns as children. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * Renders myself: hand the viewport size, the active camera and the render + * window to the scalar bar helper. + * @param prepass + * @param {vtkRenderPass} renderPass + */ + opaquePass(prepass: boolean, renderPass: vtkRenderPass): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUScalarBarActor characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUScalarBarActorInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUScalarBarActorInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUScalarBarActor. + * @param {IWebGPUScalarBarActorInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUScalarBarActorInitialValues +): vtkWebGPUScalarBarActor; + +/** + * The WebGPU backend view node for a vtkScalarBarActor. + */ +export declare const vtkWebGPUScalarBarActor: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUScalarBarActor; diff --git a/Sources/Rendering/WebGPU/ShaderCache/index.d.ts b/Sources/Rendering/WebGPU/ShaderCache/index.d.ts new file mode 100644 index 00000000000..5d1e5fc656a --- /dev/null +++ b/Sources/Rendering/WebGPU/ShaderCache/index.d.ts @@ -0,0 +1,105 @@ +import { Nullable } from '../../../types'; +import { vtkObject } from '../../../interfaces'; +import vtkWebGPUDevice from '../Device'; +import vtkWebGPURenderWindow from '../RenderWindow'; +import vtkWebGPUShaderDescription from '../ShaderDescription'; +import vtkWebGPUShaderModule from '../ShaderModule'; + +/** + * The outcome of a shader source substitution. + */ +export interface IWebGPUShaderSubstitution { + /** + * Whether the searched pattern was present in the source. + */ + replace: boolean; + + /** + * The source with the substitution applied. + */ + result: string; +} + +/** + * Perform in place string substitutions on a shader source. + * + * @param {String} source the shader source + * @param {String} search the pattern to replace + * @param {String|String[]} replace the replacement, joined by newlines when an array + * @param {Boolean} [all] replace every occurrence (default: true) + */ +declare function substitute( + source: string, + search: string, + replace: string | string[], + all?: boolean +): IWebGPUShaderSubstitution; + +export interface IWebGPUShaderCacheInitialValues { + device?: Nullable; + window?: Nullable; +} + +export interface vtkWebGPUShaderCache extends vtkObject { + /** + * Get the shader module for a description, creating and caching it when no + * module with the same type and hash was built yet. + * @param {vtkWebGPUShaderDescription} shaderDesc + */ + getShaderModule( + shaderDesc: vtkWebGPUShaderDescription + ): vtkWebGPUShaderModule; + + /** + * Get the device the cached modules are created on. + */ + getDevice(): Nullable; + + /** + * Set the device the cached modules are created on. + * @param {vtkWebGPUDevice} device + */ + setDevice(device: Nullable): boolean; + + /** + * Get the render window this cache belongs to. + */ + getWindow(): Nullable; + + /** + * Set the render window this cache belongs to. + * @param {vtkWebGPURenderWindow} window + */ + setWindow(window: Nullable): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUShaderCache characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUShaderCacheInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUShaderCacheInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUShaderCache. + * @param {IWebGPUShaderCacheInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUShaderCacheInitialValues +): vtkWebGPUShaderCache; + +/** + * Caches the shader modules of a device, keyed by shader type and hash. + */ +export declare const vtkWebGPUShaderCache: { + newInstance: typeof newInstance; + extend: typeof extend; + substitute: typeof substitute; +}; +export default vtkWebGPUShaderCache; diff --git a/Sources/Rendering/WebGPU/ShaderDescription/index.d.ts b/Sources/Rendering/WebGPU/ShaderDescription/index.d.ts new file mode 100644 index 00000000000..73346e1676c --- /dev/null +++ b/Sources/Rendering/WebGPU/ShaderDescription/index.d.ts @@ -0,0 +1,156 @@ +import { Nullable } from '../../../types'; +import { vtkObject } from '../../../interfaces'; +import vtkWebGPUVertexInput from '../VertexInput'; + +/** + * The shader stage a description belongs to. + */ +export type WebGPUShaderType = 'vertex' | 'fragment'; + +export interface IWebGPUShaderDescriptionInitialValues { + type?: WebGPUShaderType; + hash?: string; + code?: string; + outputNames?: string[]; + outputTypes?: string[]; +} + +export interface vtkWebGPUShaderDescription extends vtkObject { + /** + * Check whether an output of that name was already added. + * @param {String} name + */ + hasOutput(name: string): boolean; + + /** + * Add a location output to the shader's output struct. + * @param {String} type the WGSL type, e.g. `vec4` + * @param {String} name + * @param {String} [interpolation] the WGSL interpolation qualifier + */ + addOutput(type: string, name: string, interpolation?: string): void; + + /** + * Add a builtin output, e.g. `@builtin(position) Position`, to the shader's + * output struct. + * @param {String} type the WGSL type, e.g. `vec4` + * @param {String} name + */ + addBuiltinOutput(type: string, name: string): void; + + /** + * Add a builtin input, e.g. `@builtin(vertex_index) vertexIndex`, to the + * shader's input struct. + * @param {String} type the WGSL type, e.g. `u32` + * @param {String} name + */ + addBuiltinInput(type: string, name: string): void; + + /** + * Substitute the IOStructs tokens of the code with the input and output + * structs of this stage. The inputs are taken from the outputs of the prior + * stage and, when provided, from the vertex input. + * @param {vtkWebGPUShaderDescription} priorStage the preceding shader stage + * @param {vtkWebGPUVertexInput} [vertexInput] + */ + replaceShaderCode( + priorStage: Nullable, + vertexInput?: vtkWebGPUVertexInput + ): void; + + /** + * Get the shader stage this description is for. + */ + getType(): WebGPUShaderType; + + /** + * Set the shader stage this description is for. + * @param {WebGPUShaderType} type + */ + setType(type: WebGPUShaderType): boolean; + + /** + * Get the hash identifying the shader source. + */ + getHash(): string; + + /** + * Set the hash identifying the shader source. + * @param {String} hash + */ + setHash(hash: string): boolean; + + /** + * Get the WGSL source of the shader. + */ + getCode(): string; + + /** + * Set the WGSL source of the shader. + * @param {String} code + */ + setCode(code: string): boolean; + + /** + * Get a copy of the WGSL types of the location outputs. + */ + getOutputTypes(): string[]; + + /** + * Get the WGSL types of the location outputs without copying them. + */ + getOutputTypesByReference(): string[]; + + /** + * Get a copy of the names of the location outputs. + */ + getOutputNames(): string[]; + + /** + * Get the names of the location outputs without copying them. + */ + getOutputNamesByReference(): string[]; + + /** + * Get a copy of the interpolation qualifiers of the location outputs. An + * entry is undefined when the output was added without one. + */ + getOutputInterpolations(): Array; + + /** + * Get the interpolation qualifiers of the location outputs without copying + * them. + */ + getOutputInterpolationsByReference(): Array; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUShaderDescription characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUShaderDescriptionInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUShaderDescriptionInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUShaderDescription. + * @param {IWebGPUShaderDescriptionInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUShaderDescriptionInitialValues +): vtkWebGPUShaderDescription; + +/** + * The WGSL source of one shader stage, along with the inputs and outputs that + * are substituted into it. + */ +export declare const vtkWebGPUShaderDescription: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUShaderDescription; diff --git a/Sources/Rendering/WebGPU/ShaderModule/index.d.ts b/Sources/Rendering/WebGPU/ShaderModule/index.d.ts new file mode 100644 index 00000000000..0d6f86d859c --- /dev/null +++ b/Sources/Rendering/WebGPU/ShaderModule/index.d.ts @@ -0,0 +1,80 @@ +/// + +import { Nullable } from '../../../types'; +import { vtkObject } from '../../../interfaces'; +import vtkWebGPUDevice from '../Device'; +import vtkWebGPUShaderDescription from '../ShaderDescription'; + +export interface IWebGPUShaderModuleInitialValues { + device?: Nullable; + handle?: Nullable; +} + +export interface vtkWebGPUShaderModule extends vtkObject { + /** + * Create the GPU shader module from the WGSL code of the description. + * @param {vtkWebGPUDevice} device + * @param {vtkWebGPUShaderDescription} shaderDesc + */ + initialize( + device: vtkWebGPUDevice, + shaderDesc: vtkWebGPUShaderDescription + ): void; + + /** + * Get the modified time of the camera this module was last built for. + */ + getLastCameraMTime(): number; + + /** + * Get the device this module was created on. + */ + getDevice(): Nullable; + + /** + * Set the device this module was created on. + * @param {vtkWebGPUDevice} device + */ + setDevice(device: Nullable): boolean; + + /** + * Get the underlying GPU shader module. + */ + getHandle(): Nullable; + + /** + * Set the underlying GPU shader module. + * @param {GPUShaderModule} handle + */ + setHandle(handle: Nullable): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUShaderModule characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUShaderModuleInitialValues} [initialValues] (default: {}) + */ +declare function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUShaderModuleInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUShaderModule. + * @param {IWebGPUShaderModuleInitialValues} [initialValues] for pre-setting some of its content + */ +declare function newInstance( + initialValues?: IWebGPUShaderModuleInitialValues +): vtkWebGPUShaderModule; + +/** + * A compiled WGSL shader module. + */ +export declare const vtkWebGPUShaderModule: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUShaderModule; diff --git a/Sources/Rendering/WebGPU/SimpleMapper/index.d.ts b/Sources/Rendering/WebGPU/SimpleMapper/index.d.ts new file mode 100644 index 00000000000..7fd965d1d1e --- /dev/null +++ b/Sources/Rendering/WebGPU/SimpleMapper/index.d.ts @@ -0,0 +1,412 @@ +/// + +import { Nullable } from '../../../types'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; +import { IWebGPUBindable } from '../BindGroup'; +import vtkWebGPUDevice from '../Device'; +import vtkWebGPUPipeline, { IWebGPUPipelineSettings } from '../Pipeline'; +import vtkWebGPURenderEncoder from '../RenderEncoder'; +import vtkWebGPURenderer from '../Renderer'; +import vtkWebGPUStorageBuffer from '../StorageBuffer'; +import vtkWebGPUTextureView from '../TextureView'; +import vtkWebGPUUniformBuffer from '../UniformBuffer'; +import vtkWebGPUVertexInput from '../VertexInput'; + +/** + * A shader replacement function, registered on the mapper's replacement map + * under the name of the `//VTK::Section::` tag it fills in. + */ +export type WebGPUShaderReplacement = ( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput +) => void; + +export interface IWebGPUSimpleMapperInitialValues extends IViewNodeInitialValues { + additionalBindables?: IWebGPUBindable[]; + device?: Nullable; + fragmentShaderTemplate?: Nullable; + interpolate?: boolean; + numberOfInstances?: number; + numberOfVertices?: number; + pipelineHash?: Nullable; + shaderReplacements?: Nullable>; + SSBO?: Nullable; + textureViews?: vtkWebGPUTextureView[]; + topology?: GPUPrimitiveTopology; + UBO?: Nullable; + vertexShaderTemplate?: Nullable; + WebGPURenderer?: Nullable; +} + +export interface vtkWebGPUSimpleMapper extends vtkViewNode { + /** + * Create the vertex and fragment shader descriptions of a pipeline from the + * shader templates, then invoke every registered shader replacement whose + * `//VTK::Section::` tag appears in them. The IOStructs replacement is always + * invoked last, as the other replacements can add shader inputs and outputs. + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + generateShaderDescriptions( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * Build the input and output structs of both shader stages. + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderIOStructs( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * Let the render encoder emit its own fragment output declarations. + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderRenderEncoder( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * Emit the declarations of the renderer bind group. Does nothing when the + * mapper has no WebGPU renderer. + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderRenderer( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * Emit the declarations of the mapper bind group. + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderMapper( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * Emit the clip space position of the vertex. + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderPosition( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * Declare the texture coordinate passed from the vertex to the fragment + * stage. + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderTCoord( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * Add a texture view to the ones bound by this mapper, unless it is already + * there. + * @param {vtkWebGPUTextureView} view + */ + addTextureView(view: vtkWebGPUTextureView): void; + + /** + * Do everything needed for this mapper to be ready to draw: update the + * input, the buffers, the bindings and the pipeline. Does not bind anything + * nor record any draw command, as the pipeline may not be bound yet. + * @param {vtkWebGPURenderEncoder} renderEncoder + */ + prepareToDraw(renderEncoder: vtkWebGPURenderEncoder): void; + + /** + * Bring the input data of this mapper up to date. + */ + updateInput(): void; + + /** + * Create and update the buffers this mapper draws from. + */ + updateBuffers(): void; + + /** + * Set the bindables of the mapper bind group. Done on every draw, as + * bindings can change without the pipeline hash changing. + */ + updateBindings(): void; + + /** + * Compute the hash the pipeline of this mapper is cached under. + */ + computePipelineHash(): void; + + /** + * Get the pipeline settings merged on top of the render encoder settings. + */ + getPipelineSettings(): Nullable; + + /** + * Register this mapper's draw call on an encoder, to be invoked once the + * pipeline is bound. + * @param {vtkWebGPURenderEncoder} encoder + */ + registerDrawCallback(encoder: vtkWebGPURenderEncoder): void; + + /** + * Prepare, bind the pipeline and draw immediately. + * @param {vtkWebGPURenderEncoder} encoder + */ + prepareAndDraw(encoder: vtkWebGPURenderEncoder): void; + + /** + * Record the draw commands of this mapper. The command encoder and the + * pipeline must already be bound. + * @param {vtkWebGPURenderEncoder} renderEncoder + */ + draw(renderEncoder: vtkWebGPURenderEncoder): void; + + /** + * Get the objects bound by the mapper bind group: the additional bindables, + * the uniform and storage buffers, and the texture views with their + * samplers. + */ + getBindables(): IWebGPUBindable[]; + + /** + * Fetch the pipeline of the current hash from the device, building it when + * the device has none. + */ + updatePipeline(): void; + + /** + * Release the GPU resources of the vertex input, the bind group and the + * buffers, and drop the pipeline, the render encoder and the texture views. + */ + releaseGraphicsResources(): void; + + /** + * Get the render pipeline this mapper draws with. + */ + getPipeline(): Nullable; + + /** + * Get the vertex input of this mapper. + */ + getVertexInput(): vtkWebGPUVertexInput; + + /** + * Get the bindables added to the mapper bind group ahead of the buffers and + * texture views. + */ + getAdditionalBindables(): IWebGPUBindable[]; + + /** + * Set the bindables added to the mapper bind group ahead of the buffers and + * texture views. + * @param {IWebGPUBindable[]} additionalBindables + */ + setAdditionalBindables(additionalBindables: IWebGPUBindable[]): boolean; + + /** + * Get the device this mapper creates its resources on. + */ + getDevice(): Nullable; + + /** + * Set the device this mapper creates its resources on. + * @param {vtkWebGPUDevice} device + */ + setDevice(device: Nullable): boolean; + + /** + * Get the WGSL template the fragment shader is assembled from. + */ + getFragmentShaderTemplate(): Nullable; + + /** + * Set the WGSL template the fragment shader is assembled from. + * @param {String} fragmentShaderTemplate + */ + setFragmentShaderTemplate(fragmentShaderTemplate: Nullable): boolean; + + /** + * Get whether the textures of this mapper are sampled with interpolation. + */ + getInterpolate(): boolean; + + /** + * Set whether the textures of this mapper are sampled with interpolation. + * @param {Boolean} interpolate + */ + setInterpolate(interpolate: boolean): boolean; + + /** + * Get the number of instances drawn. + */ + getNumberOfInstances(): number; + + /** + * Set the number of instances drawn. + * @param {Number} numberOfInstances + */ + setNumberOfInstances(numberOfInstances: number): boolean; + + /** + * Get the number of vertices drawn when there is no index buffer. + */ + getNumberOfVertices(): number; + + /** + * Set the number of vertices drawn when there is no index buffer. + * @param {Number} numberOfVertices + */ + setNumberOfVertices(numberOfVertices: number): boolean; + + /** + * Get the hash the pipeline of this mapper is cached under. + */ + getPipelineHash(): Nullable; + + /** + * Set the hash the pipeline of this mapper is cached under. + * @param {String} pipelineHash + */ + setPipelineHash(pipelineHash: Nullable): boolean; + + /** + * Get the shader replacement functions, keyed by the name of the + * `//VTK::Section::` tag they fill in. + */ + getShaderReplacements(): Map; + + /** + * Set the shader replacement functions. + * @param shaderReplacements + */ + setShaderReplacements( + shaderReplacements: Map + ): boolean; + + /** + * Get the storage buffer bound by this mapper. + */ + getSSBO(): Nullable; + + /** + * Set the storage buffer bound by this mapper. + * @param {vtkWebGPUStorageBuffer} SSBO + */ + setSSBO(SSBO: Nullable): boolean; + + /** + * Get the texture views bound by this mapper. + */ + getTextureViews(): vtkWebGPUTextureView[]; + + /** + * Set the texture views bound by this mapper. + * @param {vtkWebGPUTextureView[]} textureViews + */ + setTextureViews(textureViews: vtkWebGPUTextureView[]): boolean; + + /** + * Get the primitive topology this mapper draws. + */ + getTopology(): GPUPrimitiveTopology; + + /** + * Set the primitive topology this mapper draws. + * @param {GPUPrimitiveTopology} topology + */ + setTopology(topology: GPUPrimitiveTopology): boolean; + + /** + * Get the uniform buffer bound by this mapper. + */ + getUBO(): Nullable; + + /** + * Set the uniform buffer bound by this mapper. + * @param {vtkWebGPUUniformBuffer} UBO + */ + setUBO(UBO: Nullable): boolean; + + /** + * Get the WGSL template the vertex shader is assembled from. + */ + getVertexShaderTemplate(): Nullable; + + /** + * Set the WGSL template the vertex shader is assembled from. + * @param {String} vertexShaderTemplate + */ + setVertexShaderTemplate(vertexShaderTemplate: Nullable): boolean; + + /** + * Get the scene graph renderer this mapper draws inside. + */ + getWebGPURenderer(): Nullable; + + /** + * Set the scene graph renderer this mapper draws inside. + * @param {vtkWebGPURenderer} WebGPURenderer + */ + setWebGPURenderer(WebGPURenderer: Nullable): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUSimpleMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUSimpleMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUSimpleMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUSimpleMapper. + * @param {IWebGPUSimpleMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUSimpleMapperInitialValues +): vtkWebGPUSimpleMapper; + +/** + * The base of the WebGPU mappers: owns a vertex input, a bind group, a + * pipeline and the shader templates and replacement functions the shader code + * is assembled from. + */ +export declare const vtkWebGPUSimpleMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUSimpleMapper; diff --git a/Sources/Rendering/WebGPU/Skybox/index.d.ts b/Sources/Rendering/WebGPU/Skybox/index.d.ts new file mode 100644 index 00000000000..2b49724427d --- /dev/null +++ b/Sources/Rendering/WebGPU/Skybox/index.d.ts @@ -0,0 +1,124 @@ +import { Nullable } from '../../../types'; +import { vtkTexture } from '../../Core/Texture'; +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; +import vtkWebGPUCamera from '../Camera'; +import vtkWebGPUDevice from '../Device'; +import vtkWebGPUFullScreenQuad from '../FullScreenQuad'; +import vtkWebGPUTexture from '../Texture'; +import vtkWebGPUTextureView from '../TextureView'; +import vtkWebGPUUniformBuffer from '../UniformBuffer'; + +export interface IWebGPUSkyboxInitialValues extends IViewNodeInitialValues { + backgroundInterpolate?: Nullable; + backgroundTextureView?: Nullable; + backgroundWebGPUTexture?: Nullable; + boxInterpolate?: Nullable; + boxTextureView?: Nullable; + boxWebGPUTexture?: Nullable; + lastFormat?: Nullable; + quad?: Nullable; + UBO?: Nullable; + webgpuCamera?: Nullable; +} + +export interface vtkWebGPUSkybox extends vtkViewNode { + /** + * Builds myself: resolve the renderer and render window and find the view + * node of the renderer's active camera. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * @param prepass + * @param {vtkRenderPass} renderPass + */ + queryPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * Create the full screen quad, its uniform buffer and its shader + * replacements, if they do not exist yet. + * @param {vtkWebGPUDevice} device + */ + ensureQuad(device: vtkWebGPUDevice): void; + + /** + * The first texture of the renderable, if any. + */ + getTexture(): Nullable; + + /** + * The cache key of the cube map built from the six inputs of the given + * texture, or null when one of them is missing. + * @param {vtkTexture} texture + */ + getCubeTextureHash(texture: vtkTexture): Nullable; + + /** + * Get, or build and cache on the device, the cube map texture for the given + * vtkTexture. + * @param {vtkWebGPUDevice} device + * @param {vtkTexture} texture + */ + getCubeTexture( + device: vtkWebGPUDevice, + texture: vtkTexture + ): Nullable; + + /** + * Bind the texture view matching the renderable's format to the quad. + * Returns false when no texture is ready to be drawn. + * @param {vtkWebGPUDevice} device + */ + updateTexture(device: vtkWebGPUDevice): boolean; + + /** + * Update and send the mapper uniform buffer holding the inverse projection + * matrix and the stabilized camera position. + * @param {vtkWebGPUDevice} device + */ + updateUBO(device: vtkWebGPUDevice): void; + + /** + * Drop the quad, the uniform buffer and the cached texture views. + */ + releaseGraphicsResources(): void; + + /** + * Renders myself: draw the full screen quad with the skybox shader for the + * renderable's format. + * @param prepass + */ + opaquePass(prepass: boolean): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUSkybox characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUSkyboxInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUSkyboxInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUSkybox. + * @param {IWebGPUSkyboxInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUSkyboxInitialValues +): vtkWebGPUSkybox; + +/** + * The WebGPU backend view node for a vtkSkybox. + */ +export declare const vtkWebGPUSkybox: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUSkybox; diff --git a/Sources/Rendering/WebGPU/SphereMapper/index.d.ts b/Sources/Rendering/WebGPU/SphereMapper/index.d.ts new file mode 100644 index 00000000000..32ba45c2920 --- /dev/null +++ b/Sources/Rendering/WebGPU/SphereMapper/index.d.ts @@ -0,0 +1,45 @@ +import vtkWebGPUCellArrayMapper, { + IWebGPUCellArrayMapperInitialValues, +} from '../CellArrayMapper'; + +export interface IWebGPUSphereMapperInitialValues extends IWebGPUCellArrayMapperInitialValues {} + +export interface vtkWebGPUSphereMapper extends vtkWebGPUCellArrayMapper { + /** + * Update the renderable and take its points as the cell array this mapper + * draws, then run the cell array mapper build pass. + * @param prepass + */ + buildPass(prepass: boolean): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUSphereMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUSphereMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUSphereMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUSphereMapper. + * @param {IWebGPUSphereMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUSphereMapperInitialValues +): vtkWebGPUSphereMapper; + +/** + * The WebGPU view node of vtkSphereMapper. It draws one impostor quad per + * point and ray casts a sphere in the fragment shader. + */ +export declare const vtkWebGPUSphereMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUSphereMapper; diff --git a/Sources/Rendering/WebGPU/StickMapper/index.d.ts b/Sources/Rendering/WebGPU/StickMapper/index.d.ts new file mode 100644 index 00000000000..938fba6d6cf --- /dev/null +++ b/Sources/Rendering/WebGPU/StickMapper/index.d.ts @@ -0,0 +1,45 @@ +import vtkWebGPUCellArrayMapper, { + IWebGPUCellArrayMapperInitialValues, +} from '../CellArrayMapper'; + +export interface IWebGPUStickMapperInitialValues extends IWebGPUCellArrayMapperInitialValues {} + +export interface vtkWebGPUStickMapper extends vtkWebGPUCellArrayMapper { + /** + * Update the renderable and take its points as the cell array this mapper + * draws, then run the cell array mapper build pass. + * @param prepass + */ + buildPass(prepass: boolean): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUStickMapper characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUStickMapperInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUStickMapperInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUStickMapper. + * @param {IWebGPUStickMapperInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUStickMapperInitialValues +): vtkWebGPUStickMapper; + +/** + * The WebGPU view node of vtkStickMapper. It draws one impostor box per point + * and ray casts a cylinder in the fragment shader. + */ +export declare const vtkWebGPUStickMapper: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUStickMapper; diff --git a/Sources/Rendering/WebGPU/StorageBuffer/index.d.ts b/Sources/Rendering/WebGPU/StorageBuffer/index.d.ts new file mode 100644 index 00000000000..7cf37ce0fc9 --- /dev/null +++ b/Sources/Rendering/WebGPU/StorageBuffer/index.d.ts @@ -0,0 +1,197 @@ +/// + +import { vtkObject } from '../../../interfaces'; +import { Nullable, TypedArray } from '../../../types'; +import vtkWebGPUDevice from '../Device'; + +export interface IWebGPUStorageBufferInitialValues { + device?: vtkWebGPUDevice; + bindGroupLayoutEntry?: Partial; + label?: string; + numberOfInstances?: number; + sizeInBytes?: number; +} + +/** + * A storage buffer holding one struct per instance. Unlike the uniform buffer + * the entries are laid out in the order they are added, so the caller is + * responsible for respecting the WGSL alignment rules. + */ +export interface vtkWebGPUStorageBuffer extends vtkObject { + /** + * Append an entry to the struct. + * @param name The WGSL member name. + * @param type The WGSL type, e.g. `vec4`. + */ + addEntry(name: string, type: string): void; + + /** + * Create the GPU buffer if needed and write the current contents to it. + * @param device The device to send the data to. + */ + send(device: vtkWebGPUDevice): void; + + /** + * Make sure a typed array view of the given type exists over the backing + * array buffer. + * @param type The typed array constructor name, e.g. 'Float32Array'. + */ + createView(type: string): void; + + /** + * Set a scalar entry for one instance. + * @param name The entry name. + * @param instance The instance index. + * @param val The value to store. + */ + setValue(name: string, instance: number, val: number): void; + + /** + * Set a vector or matrix entry for one instance. + * @param name The entry name. + * @param instance The instance index. + * @param arr The values to store. + */ + setArray(name: string, instance: number, arr: number[] | TypedArray): void; + + /** + * Set an entry for every instance from a single flat array. + * @param name The entry name. + * @param arr numberOfInstances contiguous blocks of values. + */ + setAllInstancesFromArray(name: string, arr: number[] | TypedArray): void; + + /** + * Set an entry for every instance from a single flat array of unsigned char + * colors, dividing each component by 255. + * @param name The entry name. + * @param arr numberOfInstances contiguous blocks of values. + */ + setAllInstancesFromArrayColorToFloat( + name: string, + arr: number[] | TypedArray + ): void; + + /** + * Set a mat4x4 entry for every instance from a flat array of 3x3 matrices. + * @param name The entry name. + * @param arr numberOfInstances blocks of nine values. + */ + setAllInstancesFromArray3x3To4x4( + name: string, + arr: number[] | TypedArray + ): void; + + /** + * Get the time of the last send. + */ + getSendTime(): number; + + /** + * Get the WGSL declaration of this storage buffer. + * @param binding The binding index. + * @param group The bind group index. + */ + getShaderCode(binding: number, group: number): string; + + /** + * Get the bind group entry for this buffer, creating the GPU buffer if + * needed. The binding index is filled in by the bind group. + */ + getBindGroupEntry(): Omit; + + /** + * Drop every entry and the GPU buffer, leaving an empty storage buffer. + */ + clearData(): void; + + /** + * Release the GPU buffer, forcing it to be recreated on the next send. + */ + releaseGraphicsResources(): void; + + /** + * Get the object whose modified time changes when the bind group entry + * becomes stale. + */ + getBindGroupTime(): vtkObject; + + /** + * Get the device the buffer was last sent to. + */ + getDevice(): Nullable; + + /** + * Set the device the buffer belongs to. + */ + setDevice(device: vtkWebGPUDevice): boolean; + + /** + * Get the bind group layout entry describing this buffer. + */ + getBindGroupLayoutEntry(): Partial; + + /** + * Set the bind group layout entry describing this buffer. + */ + setBindGroupLayoutEntry( + bindGroupLayoutEntry: Partial + ): boolean; + + /** + * Get the WGSL name of the storage buffer. + */ + getLabel(): Nullable; + + /** + * Set the WGSL name of the storage buffer. + */ + setLabel(label: string): boolean; + + /** + * Get the number of struct instances held by the buffer. + */ + getNumberOfInstances(): number; + + /** + * Set the number of struct instances held by the buffer. + */ + setNumberOfInstances(numberOfInstances: number): boolean; + + /** + * Get the size of a single struct instance in bytes. + */ + getSizeInBytes(): number; + + /** + * Set the size of a single struct instance in bytes. + */ + setSizeInBytes(sizeInBytes: number): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUStorageBuffer characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUStorageBufferInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUStorageBufferInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUStorageBuffer. + * @param {IWebGPUStorageBufferInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUStorageBufferInitialValues +): vtkWebGPUStorageBuffer; + +export declare const vtkWebGPUStorageBuffer: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUStorageBuffer; diff --git a/Sources/Rendering/WebGPU/Texture/index.d.ts b/Sources/Rendering/WebGPU/Texture/index.d.ts new file mode 100644 index 00000000000..497dd6af8c9 --- /dev/null +++ b/Sources/Rendering/WebGPU/Texture/index.d.ts @@ -0,0 +1,282 @@ +/// + +import { vtkObject } from '../../../interfaces'; +import { Nullable, TypedArray } from '../../../types'; +import vtkWebGPUDevice from '../Device'; +import vtkWebGPUTextureView from '../TextureView'; + +/** + * The extent, format and usage a texture is allocated with. + */ +export interface IWebGPUTextureCreateOptions { + width: number; + height: number; + + /** + * Defaults to 1. + */ + depth?: number; + + /** + * Defaults to '2d' for a single slice and '3d' otherwise. + */ + dimension?: GPUTextureDimension; + + /** + * Defaults to 'rgba8unorm'. + */ + format?: GPUTextureFormat; + + /** + * The highest mip level to allocate. Defaults to 0, a single level. + */ + mipLevel?: number; + + /** + * Defaults to TEXTURE_BINDING | COPY_DST. + */ + usage?: GPUTextureUsageFlags; + sampleCount?: number; +} + +/** + * A texture upload. Exactly one of the source fields is used, in the order + * canvas, imageBitmap, jsImageData, image, nativeArray. The image sources + * overwrite the width, height, depth, format and flip fields of the request. + */ +export interface IWebGPUTextureImageRequest { + canvas?: HTMLCanvasElement; + imageBitmap?: ImageBitmap; + jsImageData?: ImageData; + image?: HTMLImageElement; + nativeArray?: TypedArray; + width?: number; + height?: number; + depth?: number; + + /** + * The first slice written to. Defaults to 0. + */ + originZ?: number; + flip?: boolean; + format?: GPUTextureFormat; +} + +/** + * An upload into a sub region of an existing texture. Only nativeArray data + * is supported, and the region must lie within the texture extent. + */ +export interface IWebGPUTextureSubImageRequest { + nativeArray?: TypedArray; + + /** + * The origin of the written region. Each defaults to 0. + */ + x?: number; + y?: number; + z?: number; + + /** + * The size of the written region. Each defaults to the rest of the texture. + */ + width?: number; + height?: number; + depth?: number; + /** Layout of the full source array when uploading a region within it. */ + sourceLayout?: { + width?: number; + height?: number; + depth?: number; + x?: number; + y?: number; + z?: number; + }; + /** Regenerate mipmaps separately after several region uploads. */ + deferMipmaps?: boolean; +} + +export interface IWebGPUTextureInitialValues { + _device?: vtkWebGPUDevice; + dimension?: GPUTextureDimension; + handle?: GPUTexture; + buffer?: unknown; + ready?: boolean; + label?: string; + width?: number; + height?: number; + depth?: number; + format?: GPUTextureFormat; + usage?: GPUTextureUsageFlags; + mipLevel?: number; +} + +export interface vtkWebGPUTexture extends vtkObject { + /** + * Allocate the GPUTexture. + * @param device The device to allocate on. + * @param {IWebGPUTextureCreateOptions} options The extent, format and usage. + */ + create(device: vtkWebGPUDevice, options: IWebGPUTextureCreateOptions): void; + + /** + * Destroy the GPU texture, clear its handle and mark it as not ready. + */ + destroy(): void; + + /** + * Wrap a GPUTexture this object does not own. + * @param device The device the texture belongs to. + * @param handle The texture to wrap. + * @param {IWebGPUTextureCreateOptions} options The extent and format of the + * given texture. + */ + assignFromHandle( + device: vtkWebGPUDevice, + handle: GPUTexture, + options: IWebGPUTextureCreateOptions + ): void; + + /** + * Upload a full image into the texture, repacking and half float converting + * the data as the format requires, and regenerating the mipmaps of a 2d + * texture that has them. + * @param {IWebGPUTextureImageRequest} req The upload. + */ + writeImageData(req: IWebGPUTextureImageRequest): void; + + /** + * Upload into a sub region of the texture. + * @param {IWebGPUTextureSubImageRequest} req The upload. + */ + writeSubImageData(req: IWebGPUTextureSubImageRequest): boolean; + + /** Regenerate the mipmaps of a texture with more than one mip level. */ + generateMipmaps(): void; + + /** Get the highest allocated mip level. */ + getMipLevel(): number; + + /** Get the number of samples per texel. */ + getSampleCount(): number; + + /** + * The factor a value read back from this texture must be multiplied by to + * recover the original source value. 1.0 for the half float formats and + * 255.0 for normalized byte formats, 65535.0 for 16 bit unorm formats, + * and 32767.0 for 16 bit snorm formats. + */ + getScale(): number; + + /** + * The number of components a texel of this texture's format holds. + */ + getNumberOfComponents(): number; + + /** + * The number of extents larger than one texel. + */ + getDimensionality(): number; + + /** + * Reallocate the texture when its extent differs from the given texture's. + * @param tex The texture to match. + */ + resizeToMatch(tex: vtkWebGPUTexture): void; + + /** + * Reallocate the texture when the given extent differs from the current one. + * @param width + * @param height + * @param {Number} [depth] (default: 1) + */ + resize(width: number, height: number, depth?: number): void; + + /** + * Create a view of this texture. A missing view dimension is derived from + * the texture dimension and depth. + * @param label The WGSL name of the view. + * @param {GPUTextureViewDescriptor} [options] (default: {}) + */ + createView( + label: string, + options?: GPUTextureViewDescriptor + ): vtkWebGPUTextureView; + + /** + * Get the dimension the texture was allocated with. + */ + getDimension(): GPUTextureDimension; + + /** + * Get the GPUTexture. + */ + getHandle(): Nullable; + + /** + * Whether image data has been uploaded into the texture. + */ + getReady(): boolean; + + getWidth(): number; + + getHeight(): number; + + getDepth(): number; + + /** + * Get the format the texture was allocated with. + */ + getFormat(): GPUTextureFormat; + + /** + * Get the usage flags the texture was allocated with. + */ + getUsage(): GPUTextureUsageFlags; + + /** + * Get the device the texture belongs to. + */ + getDevice(): Nullable; + + /** + * Set the device the texture belongs to. + */ + setDevice(device: vtkWebGPUDevice): boolean; + + /** + * Get the debug label of the texture. + */ + getLabel(): Nullable; + + /** + * Set the debug label of the texture. + */ + setLabel(label: string): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUTexture characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUTextureInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUTextureInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUTexture. + * @param {IWebGPUTextureInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUTextureInitialValues +): vtkWebGPUTexture; + +export declare const vtkWebGPUTexture: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUTexture; diff --git a/Sources/Rendering/WebGPU/TextureManager/index.d.ts b/Sources/Rendering/WebGPU/TextureManager/index.d.ts new file mode 100644 index 00000000000..d14ae864568 --- /dev/null +++ b/Sources/Rendering/WebGPU/TextureManager/index.d.ts @@ -0,0 +1,144 @@ +/// + +import vtkImageData from '../../../Common/DataModel/ImageData'; +import { vtkObject } from '../../../interfaces'; +import { Extent, Nullable, TypedArray } from '../../../types'; +import vtkTexture from '../../Core/Texture'; +import vtkWebGPUDevice from '../Device'; +import vtkWebGPUTexture from '../Texture'; + +/** + * A texture creation request. The source fields are filled in by the manager + * from the vtkImageData or image source of the request, and `hash` keys the + * device object cache. + */ +export interface IWebGPUTextureRequest { + /** + * The cache key. When absent the texture is created without being cached. + */ + hash?: string; + + /** + * The modified time the hash is derived from. + */ + time?: number; + + /** + * The WGSL name given to the created texture. + */ + label?: string; + + imageData?: vtkImageData; + dataArray?: unknown; + image?: HTMLImageElement; + jsImageData?: ImageData; + imageBitmap?: ImageBitmap; + canvas?: HTMLCanvasElement; + nativeArray?: TypedArray; + width?: number; + height?: number; + depth?: number; + format?: GPUTextureFormat; + usage?: GPUTextureUsageFlags; + mipLevel?: number; + flip?: boolean; + preferSizeOverAccuracy?: boolean; + forceFloat32?: boolean; + existingFormat?: GPUTextureFormat; +} + +export type WebGPUImageDataTextureOptions = { + /** + * Modified regions of the image, used to patch an existing texture. + */ + updatedExtents?: Extent[]; + existingTexture?: Nullable; + /** + * Allow half float storage even when it cannot represent all scalar values. + */ + preferSizeOverAccuracy?: boolean; + generateMipmaps?: boolean; + /** + * A key for one texture binding. Release it when the binding is no longer used. + */ + owner?: object; +}; + +export interface IWebGPUTextureManagerInitialValues { + handle?: unknown; + device?: vtkWebGPUDevice; +} + +export interface vtkWebGPUTextureManager extends vtkObject { + /** + * Get the texture matching the request from the device cache, creating and + * caching it when it is missing. A request without a hash always creates a + * new texture. + * @param {IWebGPUTextureRequest} req The texture request. + */ + getTexture(req: IWebGPUTextureRequest): Nullable; + + /** + * Get the texture holding the point scalars of the given image data. The + * cache key covers both the image data and its scalar array modified times. + * @param imgData The image data to upload. + */ + getTextureForImageData( + imgData: vtkImageData, + options?: WebGPUImageDataTextureOptions + ): Nullable; + + /** + * Release the texture binding held by this owner. The texture is destroyed + * after the next submission when no owners still use it. + */ + releaseTexture(owner: object): void; + + /** + * Get the texture holding the contents of a vtkTexture, whichever of its + * image data, image, ImageData, ImageBitmap or canvas source is set. + * @param srcTexture The texture to upload. + * @param {String} [label] The WGSL name given to the created texture. + */ + getTextureForVTKTexture( + srcTexture: vtkTexture, + label?: string + ): Nullable; + + /** + * Get the device the textures are created on. + */ + getDevice(): Nullable; + + /** + * Set the device the textures are created on. + */ + setDevice(device: vtkWebGPUDevice): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUTextureManager characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUTextureManagerInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUTextureManagerInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUTextureManager. + * @param {IWebGPUTextureManagerInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUTextureManagerInitialValues +): vtkWebGPUTextureManager; + +export declare const vtkWebGPUTextureManager: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUTextureManager; diff --git a/Sources/Rendering/WebGPU/TextureView/index.d.ts b/Sources/Rendering/WebGPU/TextureView/index.d.ts new file mode 100644 index 00000000000..4e9635c76da --- /dev/null +++ b/Sources/Rendering/WebGPU/TextureView/index.d.ts @@ -0,0 +1,129 @@ +/// + +import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; +import vtkWebGPUDevice from '../Device'; +import vtkWebGPUSampler from '../Sampler'; +import vtkWebGPUTexture from '../Texture'; + +export interface IWebGPUTextureViewInitialValues { + texture?: any; + handle?: GPUTextureView; + sampler?: vtkWebGPUSampler; + label?: string; + bindGroupLayoutEntry?: Partial; +} + +export interface vtkWebGPUTextureView extends vtkObject { + /** + * Create a view of the given texture. The view is recreated automatically + * when the texture handle changes. + * @param texture The vtkWebGPUTexture to view. + * @param options The view descriptor, defaulting the dimension to '2d'. + */ + create(texture: any, options: GPUTextureViewDescriptor): void; + + /** + * Create a view of a GPUTexture that is not owned by a vtkWebGPUTexture. + * @param textureHandle The GPUTexture to view. + * @param options The view descriptor, whose format drives the sample type. + */ + createFromTextureHandle( + textureHandle: GPUTexture, + options: GPUTextureViewDescriptor + ): void; + + /** + * Get the bind group entry for this view. The binding index is filled in by + * the bind group. + */ + getBindGroupEntry(): Omit; + + /** + * Get the WGSL declaration of this texture. + * @param binding The binding index. + * @param group The bind group index. + */ + getShaderCode(binding: number, group: number): string; + + /** + * Create a sampler for this view and set it as the current sampler. + * @param device The device to create the sampler on. + * @param {GPUSamplerDescriptor} [options] The sampler descriptor. + */ + addSampler(device: vtkWebGPUDevice, options?: GPUSamplerDescriptor): void; + + /** + * Get the object whose modified time changes when the view is recreated. + */ + getBindGroupTime(): vtkObject; + + /** + * Get the GPUTextureView, recreating it when the texture handle changed. + */ + getHandle(): Nullable; + + /** + * Get the vtkWebGPUTexture this is a view of. + */ + getTexture(): Nullable; + + /** + * Get the bind group layout entry describing this view. + */ + getBindGroupLayoutEntry(): Partial; + + /** + * Set the bind group layout entry describing this view. + */ + setBindGroupLayoutEntry( + bindGroupLayoutEntry: Partial + ): boolean; + + /** + * Get the WGSL name of the texture. + */ + getLabel(): Nullable; + + /** + * Set the WGSL name of the texture. + */ + setLabel(label: string): boolean; + + /** + * Get the sampler paired with this view. + */ + getSampler(): Nullable; + + /** + * Set the sampler paired with this view. + */ + setSampler(sampler: vtkWebGPUSampler): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUTextureView characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUTextureViewInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUTextureViewInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUTextureView. + * @param {IWebGPUTextureViewInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUTextureViewInitialValues +): vtkWebGPUTextureView; + +export declare const vtkWebGPUTextureView: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUTextureView; diff --git a/Sources/Rendering/WebGPU/Types/index.d.ts b/Sources/Rendering/WebGPU/Types/index.d.ts new file mode 100644 index 00000000000..0052ffe60af --- /dev/null +++ b/Sources/Rendering/WebGPU/Types/index.d.ts @@ -0,0 +1,126 @@ +/// + +/** + * The typed array constructor matching the element type of a texture format. + */ +export type WebGPUNativeArrayConstructor = + | Int8ArrayConstructor + | Uint8ArrayConstructor + | Int16ArrayConstructor + | Uint16ArrayConstructor + | Int32ArrayConstructor + | Uint32ArrayConstructor + | Float32ArrayConstructor; + +/** + * The sample type of a texture format. `mixed` is used for the combined + * depth/stencil formats, which have no single WebGPU sample type. + */ +export type WebGPUTextureSampleType = GPUTextureSampleType | 'mixed'; + +/** + * Byte layout and sampling information for a WebGPU texture format. + */ +export interface IWebGPUTextureDetails { + /** + * The number of components a texel holds. + */ + numComponents: number; + + /** + * The typed array constructor able to hold the format's components. + */ + nativeType: WebGPUNativeArrayConstructor; + + /** + * The size, in bytes, of one texel. + */ + stride: number; + + /** + * The size, in bytes, of one component. Absent for the packed formats, + * whose components do not have a byte size of their own. + */ + elementSize?: number; + + /** + * How a shader samples the format. + */ + sampleType: WebGPUTextureSampleType; +} + +/** + * Get the byte layout and sampling information of a texture format. + * Returns 0 when the format is falsy or too short to be a format name, and + * null when it is not a format vtk.js knows about. + * @param {GPUTextureFormat} format + */ +declare function getDetailsFromTextureFormat( + format: GPUTextureFormat +): IWebGPUTextureDetails | null | 0; + +/** + * Get the size, in bytes, of one element of a vertex buffer format. + * Returns 0 when the format is falsy or too short to be a format name. + * @param {GPUVertexFormat} format + */ +declare function getByteStrideFromBufferFormat(format: GPUVertexFormat): number; + +/** + * Get the number of components of a vertex buffer format. + * Returns 0 when the format is falsy or too short to be a format name. + * @param {GPUVertexFormat} format + */ +declare function getNumberOfComponentsFromBufferFormat( + format: GPUVertexFormat +): number; + +/** + * Get the name of the typed array able to hold a vertex buffer format, e.g. + * `Float32Array`. Returns 0 when the format is falsy or too short to be a + * format name, and undefined when it cannot be parsed. + * @param {GPUVertexFormat} format + */ +declare function getNativeTypeFromBufferFormat( + format: GPUVertexFormat +): string | undefined | 0; + +/** + * Get the WGSL type, e.g. `vec4`, matching a vertex buffer format. + * Returns undefined when the format cannot be parsed. + * @param {GPUVertexFormat} format + */ +declare function getShaderTypeFromBufferFormat( + format: GPUVertexFormat +): string | undefined; + +/** + * Get the size, in bytes, of a WGSL type such as `vec3` or `mat4x4`. + * Returns 0 when the format is falsy. + * @param {String} format + */ +declare function getByteStrideFromShaderFormat(format: string): number; + +/** + * Get the name of the typed array able to hold a WGSL type, e.g. + * `Float32Array`. Returns undefined when the type is falsy or unknown. + * @param {String} format + */ +declare function getNativeTypeFromShaderFormat( + format: string +): string | undefined; + +/** + * Static helpers translating between the WebGPU buffer, shader and texture + * format names and the byte sizes, alignments and native arrays vtk.js needs. + */ +declare const vtkWebGPUTypes: { + getDetailsFromTextureFormat: typeof getDetailsFromTextureFormat; + getByteStrideFromBufferFormat: typeof getByteStrideFromBufferFormat; + getNumberOfComponentsFromBufferFormat: typeof getNumberOfComponentsFromBufferFormat; + getNativeTypeFromBufferFormat: typeof getNativeTypeFromBufferFormat; + getShaderTypeFromBufferFormat: typeof getShaderTypeFromBufferFormat; + getByteStrideFromShaderFormat: typeof getByteStrideFromShaderFormat; + getNativeTypeFromShaderFormat: typeof getNativeTypeFromShaderFormat; +}; +export default vtkWebGPUTypes; diff --git a/Sources/Rendering/WebGPU/UniformBuffer/index.d.ts b/Sources/Rendering/WebGPU/UniformBuffer/index.d.ts new file mode 100644 index 00000000000..452bc04db26 --- /dev/null +++ b/Sources/Rendering/WebGPU/UniformBuffer/index.d.ts @@ -0,0 +1,163 @@ +/// + +import { vtkObject } from '../../../interfaces'; +import { Nullable, TypedArray } from '../../../types'; +import vtkWebGPUDevice from '../Device'; + +export interface IWebGPUUniformBufferInitialValues { + sizeInBytes?: number; + label?: string; + binding?: number; + bindGroupLayoutEntry?: Partial; + device?: vtkWebGPUDevice; +} + +/** + * A uniform buffer holding a single WGSL struct. Entries are reordered to + * satisfy the WGSL memory layout rules before the buffer is sent. + */ +export interface vtkWebGPUUniformBuffer extends vtkObject { + /** + * Append an entry to the struct. + * @param name The WGSL member name. + * @param type The WGSL type, e.g. `vec4`. + */ + addEntry(name: string, type: string): void; + + /** + * Reorder and pack the entries if they changed since the last sort, and + * recompute the size of the struct. + */ + sortBufferEntries(): void; + + /** + * Create the GPU buffer if needed and write the contents when they changed. + * @param device The device to send the data to. + */ + sendIfNeeded(device: vtkWebGPUDevice): void; + + /** + * Make sure a typed array view of the given type exists over the backing + * array buffer. + * @param type The typed array constructor name, e.g. 'Float32Array'. + */ + createView(type: string): void; + + /** + * Set a scalar entry. + * @param name The entry name. + * @param val The value to store. + */ + setValue(name: string, val: number): void; + + /** + * Set a vector or matrix entry. + * @param name The entry name. + * @param arr The values to store. + */ + setArray(name: string, arr: number[] | TypedArray): void; + + /** + * Get the bind group entry for this buffer, creating the GPU buffer if + * needed. The binding index is filled in by the bind group. + */ + getBindGroupEntry(): Omit; + + /** + * Get the time of the last sendIfNeeded call. + */ + getSendTime(): number; + + /** + * Get the WGSL declaration of this uniform buffer. + * @param binding The binding index. + * @param group The bind group index. + */ + getShaderCode(binding: number, group: number): string; + + /** + * Release the GPU buffer, forcing it to be recreated and resent on the next + * sendIfNeeded call. + */ + releaseGraphicsResources(): void; + + /** + * Get the binding index. + */ + getBinding(): number; + + /** + * Get the object whose modified time changes when the bind group entry + * becomes stale. + */ + getBindGroupTime(): vtkObject; + + /** + * Get the bind group layout entry describing this buffer. + */ + getBindGroupLayoutEntry(): Partial; + + /** + * Set the bind group layout entry describing this buffer. + */ + setBindGroupLayoutEntry( + bindGroupLayoutEntry: Partial + ): boolean; + + /** + * Get the device the buffer was last sent to. + */ + getDevice(): Nullable; + + /** + * Set the device the buffer belongs to. + */ + setDevice(device: vtkWebGPUDevice): boolean; + + /** + * Get the WGSL name of the uniform buffer. + */ + getLabel(): Nullable; + + /** + * Set the WGSL name of the uniform buffer. + */ + setLabel(label: string): boolean; + + /** + * Get the size of the struct in bytes. + */ + getSizeInBytes(): number; + + /** + * Set the size of the struct in bytes. + */ + setSizeInBytes(sizeInBytes: number): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUUniformBuffer characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUUniformBufferInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUUniformBufferInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUUniformBuffer. + * @param {IWebGPUUniformBufferInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUUniformBufferInitialValues +): vtkWebGPUUniformBuffer; + +export declare const vtkWebGPUUniformBuffer: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUUniformBuffer; diff --git a/Sources/Rendering/WebGPU/VertexInput/index.d.ts b/Sources/Rendering/WebGPU/VertexInput/index.d.ts new file mode 100644 index 00000000000..ebd5fcc620f --- /dev/null +++ b/Sources/Rendering/WebGPU/VertexInput/index.d.ts @@ -0,0 +1,147 @@ +/// + +import { vtkObject } from '../../../interfaces'; +import { Nullable } from '../../../types'; +import vtkWebGPUBuffer from '../Buffer'; +import vtkWebGPUDevice from '../Device'; +import vtkWebGPUIndexBuffer from '../IndexBuffer'; + +/** + * The vertex state of a render pipeline, as built from the registered buffers. + */ +export interface IWebGPUVertexInputInformation { + buffers?: GPUVertexBufferLayout[]; +} + +export interface IWebGPUVertexInputInitialValues { + created?: boolean; + device?: vtkWebGPUDevice; + handle?: unknown; + indexBuffer?: vtkWebGPUIndexBuffer; +} + +export interface vtkWebGPUVertexInput extends vtkObject { + /** + * Register a vertex buffer under one or more attribute names. Registering a + * new set of names keeps the inputs sorted alphabetically, as the shader + * locations depend on that order. + * @param buffer The vertex buffer. + * @param inames The attribute name or names the buffer provides. + * @param {String} [stepMode] (default: 'vertex') + */ + addBuffer( + buffer: vtkWebGPUBuffer, + inames: string | string[], + stepMode?: GPUVertexStepMode + ): void; + + /** + * Remove the buffer providing the given attribute name, if there is one. + * @param name The attribute name. + */ + removeBufferIfPresent(name: string): void; + + /** + * Get the buffer providing the given attribute name. + * @param name The attribute name. + */ + getBuffer(name: string): Nullable; + + /** + * Check whether an attribute of the given name is registered. + * @param name The attribute name. + */ + hasAttribute(name: string): boolean; + + /** + * Get the source time of the buffer providing the given attribute, or zero + * when the attribute is not registered. + * @param name The attribute name. + */ + getAttributeTime(name: string): number; + + /** + * Get the WGSL declaration of the vertex shader inputs. + */ + getShaderCode(): string; + + /** + * Get the vertex buffer layouts of the render pipeline. + */ + getVertexInputInformation(): IWebGPUVertexInputInformation; + + /** + * Bind the vertex buffers, and the index buffer when there is one, on the + * given render encoder. + * @param renderEncoder The vtkWebGPURenderEncoder to bind onto. + */ + bindBuffers(renderEncoder: any): void; + + getReady(): void; + + /** + * Drop the registered buffers when this vertex input was created. + */ + releaseGraphicsResources(): void; + + /** + * Get whether the vertex input was created. + */ + getCreated(): boolean; + + /** + * Set whether the vertex input was created. + */ + setCreated(created: boolean): boolean; + + /** + * Get the device this vertex input belongs to. + */ + getDevice(): Nullable; + + /** + * Set the device this vertex input belongs to. + */ + setDevice(device: vtkWebGPUDevice): boolean; + + getHandle(): unknown; + + setHandle(handle: unknown): boolean; + + /** + * Get the index buffer bound along with the vertex buffers. + */ + getIndexBuffer(): Nullable; + + /** + * Set the index buffer bound along with the vertex buffers. + */ + setIndexBuffer(indexBuffer: vtkWebGPUIndexBuffer): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUVertexInput characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUVertexInputInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUVertexInputInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUVertexInput. + * @param {IWebGPUVertexInputInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUVertexInputInitialValues +): vtkWebGPUVertexInput; + +export declare const vtkWebGPUVertexInput: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUVertexInput; diff --git a/Sources/Rendering/WebGPU/ViewNodeFactory/index.d.ts b/Sources/Rendering/WebGPU/ViewNodeFactory/index.d.ts new file mode 100644 index 00000000000..a466fb29b07 --- /dev/null +++ b/Sources/Rendering/WebGPU/ViewNodeFactory/index.d.ts @@ -0,0 +1,52 @@ +import { + IViewNodeFactoryInitialValues, + vtkViewNodeFactory, +} from '../../SceneGraph/ViewNodeFactory'; +import { vtkViewNode } from '../../SceneGraph/ViewNode'; + +/** + * Register the view node factory function used for a given renderable class + * name. The mapping is static and shared by every vtkWebGPUViewNodeFactory + * instance; each WebGPU backend module registers itself when imported. + * + * @param className the renderable class name, e.g. 'vtkActor' + * @param fn the factory creating the matching view node + */ +export function registerOverride( + className: string, + fn: (initialValues?: object) => vtkViewNode +): void; + +export interface IWebGPUViewNodeFactoryInitialValues extends IViewNodeFactoryInitialValues {} + +export interface vtkWebGPUViewNodeFactory extends vtkViewNodeFactory {} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUViewNodeFactory characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUViewNodeFactoryInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUViewNodeFactoryInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUViewNodeFactory. + * @param {IWebGPUViewNodeFactoryInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUViewNodeFactoryInitialValues +): vtkWebGPUViewNodeFactory; + +/** + * The factory choosing which WebGPU view node to create for a renderable. + */ +export declare const vtkWebGPUViewNodeFactory: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUViewNodeFactory; diff --git a/Sources/Rendering/WebGPU/Volume/index.d.ts b/Sources/Rendering/WebGPU/Volume/index.d.ts new file mode 100644 index 00000000000..abe30ec4df7 --- /dev/null +++ b/Sources/Rendering/WebGPU/Volume/index.d.ts @@ -0,0 +1,88 @@ +import { vtkObject } from '../../../interfaces'; +import { vtkRenderPass } from '../../SceneGraph/RenderPass'; +import { IViewNodeInitialValues, vtkViewNode } from '../../SceneGraph/ViewNode'; +import { vtkWebGPURenderer } from '../Renderer'; + +/** + * The cached matrices recomputed whenever the renderable or the stabilized + * center of the renderer changes. + */ +export interface IWebGPUVolumeKeyMatrices { + bcwc: Float64Array; + bcsc: Float64Array; +} + +export interface IWebGPUVolumeInitialValues extends IViewNodeInitialValues { + propID?: number; +} + +export interface vtkWebGPUVolume extends vtkViewNode { + /** + * Builds myself: resolve the renderer and render window, claim a prop id and + * update the renderable's mapper. + * @param prepass + */ + buildPass(prepass: boolean): void; + + /** + * Register myself with the render pass so that the volume pass can render me. + * @param prepass + * @param {vtkRenderPass} renderPass + */ + queryPass(prepass: boolean, renderPass: vtkRenderPass): void; + + /** + * Write the eight world space corners of the volume's spatial extent into + * `result`, three components per point, starting at `offset`. + * @param result the array to write into + * @param offset the index of the first component to write + */ + getBoundingCubePoints(result: Float64Array | number[], offset: number): void; + + /** + * Recompute the buffer to world/stabilized matrices if the renderable or the + * stabilized center moved. + * @param {vtkWebGPURenderer} wgpuRen + */ + getKeyMatrices(wgpuRen: vtkWebGPURenderer): IWebGPUVolumeKeyMatrices; + + /** + * The identifier used by hardware selection to recognize this prop. + */ + getPropID(): number; + + /** + * The time stamp guarding the cached key matrices. + */ + getKeyMatricesTime(): vtkObject; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUVolume characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUVolumeInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUVolumeInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUVolume. + * @param {IWebGPUVolumeInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUVolumeInitialValues +): vtkWebGPUVolume; + +/** + * The WebGPU backend view node for a vtkVolume. + */ +export declare const vtkWebGPUVolume: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUVolume; diff --git a/Sources/Rendering/WebGPU/VolumePass/index.d.ts b/Sources/Rendering/WebGPU/VolumePass/index.d.ts new file mode 100644 index 00000000000..06de73641d9 --- /dev/null +++ b/Sources/Rendering/WebGPU/VolumePass/index.d.ts @@ -0,0 +1,190 @@ +import { Nullable } from '../../../types'; +import { + IRenderPassInitialValues, + vtkRenderPass, +} from '../../SceneGraph/RenderPass'; +import { vtkWebGPURenderer } from '../Renderer'; +import { vtkWebGPURenderWindow } from '../RenderWindow'; +import { vtkWebGPUTextureView } from '../TextureView'; +import { vtkWebGPUVolume } from '../Volume'; + +export interface IWebGPUVolumePassInitialValues extends IRenderPassInitialValues { + colorTextureView?: Nullable; + depthTextureView?: Nullable; + volumes?: Nullable; +} + +export interface vtkWebGPUVolumePass extends vtkRenderPass { + /** + * Create the encoders, textures and full screen quads this pass renders + * with. Anything already created is left alone. + * + * @param {vtkWebGPURenderWindow} viewNode + */ + initialize(viewNode: vtkWebGPURenderWindow): void; + + /** + * Decide whether the ray cast pass should render into a reduced viewport, + * based on the interactor's animation frame rate and the mappers' sample + * distance settings. + * + * @param {vtkWebGPURenderWindow} viewNode + */ + computeTiming(viewNode: vtkWebGPURenderWindow): void; + + /** + * Create the encoder that clears the volume color texture before the first + * group of volumes is ray cast. + * + * @param {vtkWebGPURenderWindow} viewNode + */ + createClearEncoder(viewNode: vtkWebGPURenderWindow): void; + + /** + * Create the encoder that blends the volume color texture back into the + * render window's color attachment. + * + * @param {vtkWebGPURenderWindow} viewNode + */ + createCopyEncoder(viewNode: vtkWebGPURenderWindow): void; + + /** + * Create the encoder that renders the volume bounding boxes into the two + * min/max depth textures. + * + * @param {vtkWebGPURenderWindow} viewNode + */ + createDepthRangeEncoder(viewNode: vtkWebGPURenderWindow): void; + + /** + * Create the encoder that composites a later group of volumes onto the + * result of the previous groups. + * + * @param {vtkWebGPURenderWindow} viewNode + */ + createMergeEncoder(viewNode: vtkWebGPURenderWindow): void; + + /** + * Render the bounding box geometry to fill the min and max depth textures + * the ray cast pass samples between. + * + * @param {vtkWebGPURenderer} renNode + * @param {vtkWebGPURenderWindow} viewNode + */ + drawDepthRange( + renNode: vtkWebGPURenderer, + viewNode: vtkWebGPURenderWindow + ): void; + + /** + * Ray cast one group of volumes into the volume color texture. + * + * @param {vtkWebGPURenderWindow} viewNode + * @param {vtkWebGPURenderer} renNode + * @param {vtkWebGPUVolume[]} volumes The group of volumes to render. + */ + rayCastPass( + viewNode: vtkWebGPURenderWindow, + renNode: vtkWebGPURenderer, + volumes: vtkWebGPUVolume[] + ): void; + + /** + * Free the encoders, textures, quads and buffers this pass holds. + */ + releaseGraphicsResources(): void; + + /** + * Build the bounding box polydata, upload it and draw it through the depth + * range encoder. + * + * @param {vtkWebGPURenderer} renNode + * @param {vtkWebGPURenderWindow} viewNode + */ + renderDepthBounds( + renNode: vtkWebGPURenderer, + viewNode: vtkWebGPURenderWindow + ): void; + + /** + * Rebuild the polydata holding one cube per volume, clipped against the + * camera near plane, in stabilized coordinates. + * + * @param {vtkWebGPURenderer} renNode + */ + updateDepthPolyData(renNode: vtkWebGPURenderer): void; + + /** + * Render the volumes of a renderer: depth bounds first, then one ray cast + * pass per group of volumes, then a copy back into the render window. + * + * @param {vtkWebGPURenderer} renNode + * @param {vtkWebGPURenderWindow} viewNode + */ + traverse(renNode: vtkWebGPURenderer, viewNode: vtkWebGPURenderWindow): void; + + /** + * Get the color texture view this pass composites its result into. + */ + getColorTextureView(): Nullable; + + /** + * Set the color texture view this pass composites its result into. + */ + setColorTextureView( + colorTextureView: Nullable + ): boolean; + + /** + * Get the depth texture view geometry has already been rendered into. + */ + getDepthTextureView(): Nullable; + + /** + * Set the depth texture view geometry has already been rendered into. + */ + setDepthTextureView( + depthTextureView: Nullable + ): boolean; + + /** + * Set the volumes this pass renders, marking the pass modified only when the + * list actually changed. + * + * @param {vtkWebGPUVolume[]} val + */ + setVolumes(val: vtkWebGPUVolume[]): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUVolumePass characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUVolumePassInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUVolumePassInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUVolumePass. + * @param {IWebGPUVolumePassInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUVolumePassInitialValues +): vtkWebGPUVolumePass; + +/** + * vtkWebGPUVolumePass renders the volumes of a renderer in two sub passes. The + * first rasterizes a bounding cube per volume to compute the minimum and + * maximum depth to march between, the second ray casts the volumes between + * those bounds and blends the result back into the render window. + */ +declare const vtkWebGPUVolumePass: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUVolumePass; diff --git a/Sources/Rendering/WebGPU/VolumePassFSQ/index.d.ts b/Sources/Rendering/WebGPU/VolumePassFSQ/index.d.ts new file mode 100644 index 00000000000..c04f928a0d7 --- /dev/null +++ b/Sources/Rendering/WebGPU/VolumePassFSQ/index.d.ts @@ -0,0 +1,90 @@ +import vtkWebGPUDevice from '../Device'; +import { + IWebGPUFullScreenQuadInitialValues, + vtkWebGPUFullScreenQuad, +} from '../FullScreenQuad'; +import { vtkWebGPUPipeline } from '../Pipeline'; +import {} from '../SimpleMapper'; +import { vtkWebGPUVertexInput } from '../VertexInput'; +import { vtkWebGPUVolume } from '../Volume'; + +export interface IWebGPUVolumePassFSQInitialValues extends IWebGPUFullScreenQuadInitialValues { + volumes?: vtkWebGPUVolume[]; + colorRowLength?: number; + opacityRowLength?: number; + lastVolumeLength?: number; +} + +export interface vtkWebGPUVolumePassFSQ extends vtkWebGPUFullScreenQuad { + /** + * Shader replacement, registered under `replaceShaderVolume`, generating the + * ray marching loop, the per volume sampling and compositing code and the + * transfer function lookups for every volume of the pass. + * + * @param {String} hash the pipeline hash + * @param {vtkWebGPUPipeline} pipeline + * @param {vtkWebGPUVertexInput} vertexInput + */ + replaceShaderVolume( + hash: string, + pipeline: vtkWebGPUPipeline, + vertexInput: vtkWebGPUVertexInput + ): void; + + /** + * Set the volumes this quad ray casts, marking the mapper modified only when + * the list actually changed. + * + * @param {vtkWebGPUVolume[]} val + */ + setVolumes(val: vtkWebGPUVolume[]): void; + + /** + * Rebuild the color and opacity transfer function textures of all volumes + * when any of their transfer functions changed. + * + * @param {vtkWebGPUDevice} device + */ + updateLUTImage(device: vtkWebGPUDevice): void; + + /** + * Rebuild and send the storage buffers holding the per volume and per + * component ray casting parameters. + * + * @param {vtkWebGPUDevice} device + */ + updateSSBO(device: vtkWebGPUDevice): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkWebGPUVolumePassFSQ characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IWebGPUVolumePassFSQInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IWebGPUVolumePassFSQInitialValues +): void; + +/** + * Method used to create a new instance of vtkWebGPUVolumePassFSQ. + * @param {IWebGPUVolumePassFSQInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IWebGPUVolumePassFSQInitialValues +): vtkWebGPUVolumePassFSQ; + +/** + * vtkWebGPUVolumePassFSQ is the full screen quad vtkWebGPUVolumePass ray casts + * its volumes with. It generates the WGSL that marches through every volume of + * a group between the min and max depth bounds, applying each volume's blend + * mode, transfer functions, lighting and clipping planes. + */ +declare const vtkWebGPUVolumePassFSQ: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkWebGPUVolumePassFSQ; diff --git a/Sources/Rendering/WebXR/RenderWindowHelper/Constants.d.ts b/Sources/Rendering/WebXR/RenderWindowHelper/Constants.d.ts index 6008787f0ab..ec1bbb7dda6 100644 --- a/Sources/Rendering/WebXR/RenderWindowHelper/Constants.d.ts +++ b/Sources/Rendering/WebXR/RenderWindowHelper/Constants.d.ts @@ -1,9 +1,12 @@ -export declare enum XrSessionTypes { - HmdVR = 0, - MobileAR = 1, - LookingGlassVR = 2, - HmdAR = 3, -} +export declare const XrSessionTypes: { + readonly HmdVR: 0; + readonly MobileAR: 1; + readonly LookingGlassVR: 2; + readonly HmdAR: 3; +}; + +export type XrSessionTypes = + (typeof XrSessionTypes)[keyof typeof XrSessionTypes]; declare const _default: { XrSessionTypes: typeof XrSessionTypes; diff --git a/Sources/Rendering/WebXR/RenderWindowHelper/index.d.ts b/Sources/Rendering/WebXR/RenderWindowHelper/index.d.ts index 96ccc3e2746..b30d68c85d0 100644 --- a/Sources/Rendering/WebXR/RenderWindowHelper/index.d.ts +++ b/Sources/Rendering/WebXR/RenderWindowHelper/index.d.ts @@ -1,17 +1,20 @@ -import { vtkObject } from '../../../interfaces'; +import { EventHandler, vtkObject, vtkSubscription } from '../../../interfaces'; import { Nullable } from '../../../types'; import vtkOpenGLRenderWindow from '../../OpenGL/RenderWindow'; +import vtkRenderWindow from '../../Core/RenderWindow'; +import { XrSessionTypes } from './Constants'; /** * */ export interface IWebXRRenderWindowHelperInitialValues { - initialized: boolean; + initialized?: boolean; + drawControllersRay?: boolean; initCanvasSize?: [number, number]; initBackground?: [number, number, number, number]; renderWindow?: Nullable; xrSession?: Nullable; - xrSessionType: number; + xrSessionType?: number; xrReferenceSpace?: any; } @@ -19,7 +22,12 @@ export interface vtkWebXRRenderWindowHelper extends vtkObject { /** * Initialize the instance. */ - initialize(): void; + initialize(renderWindow: vtkRenderWindow): void; + + /** + * Whether the browser exposes the WebXR device API. + */ + getXrSupported(): boolean; /** * Request an XR session on the user device with WebXR, @@ -39,7 +47,7 @@ export interface vtkWebXRRenderWindowHelper extends vtkObject { * @param {Number} inputRescaleFactor * @param {Number} inputTranslateZ */ - resetXRScene(inputRescaleFactor: number, inputTranslateZ: number): void; + resetXRScene(inputRescaleFactor?: number, inputTranslateZ?: number): void; /** * Request to stop the current XR session @@ -54,12 +62,32 @@ export interface vtkWebXRRenderWindowHelper extends vtkObject { /** * Set the underlying render window to drive XR rendering. */ - setRenderWindow(renderWindow: Nullable); + setRenderWindow(renderWindow: Nullable): boolean; /** * Get the active WebXR session. */ getXrSession(): Nullable; + + /** + * Whether a ray is drawn from each tracked-pointer controller. + */ + getDrawControllersRay(): boolean; + + /** + * Set whether a ray is drawn from each tracked-pointer controller. + */ + setDrawControllersRay(drawControllersRay: boolean): boolean; + + /** + * Subscribe to the generic event fired by this helper. + */ + onEvent(cb: EventHandler, priority?: number): vtkSubscription; + + /** + * Invoke the generic event fired by this helper. + */ + invokeEvent(...args: unknown[]): void; } /** @@ -91,5 +119,6 @@ export function newInstance( export declare const vtkWebXRRenderWindowHelper: { newInstance: typeof newInstance; extend: typeof extend; + XrSessionTypes: typeof XrSessionTypes; }; export default vtkWebXRRenderWindowHelper; diff --git a/Sources/Widgets/Core/AbstractWidget/Constants.d.ts b/Sources/Widgets/Core/AbstractWidget/Constants.d.ts new file mode 100644 index 00000000000..8b0a65e1daa --- /dev/null +++ b/Sources/Widgets/Core/AbstractWidget/Constants.d.ts @@ -0,0 +1,10 @@ +/** + * Priority at which widgets register their interactor observers, so that they + * are handled before the interactor style. + */ +export declare const WIDGET_PRIORITY: number; + +declare const _default: { + WIDGET_PRIORITY: typeof WIDGET_PRIORITY; +}; +export default _default; diff --git a/Sources/Widgets/Core/AbstractWidget/index.d.ts b/Sources/Widgets/Core/AbstractWidget/index.d.ts index efb04490157..57166eaf218 100644 --- a/Sources/Widgets/Core/AbstractWidget/index.d.ts +++ b/Sources/Widgets/Core/AbstractWidget/index.d.ts @@ -1,5 +1,8 @@ -import { vtkInteractorObserver } from '../../../Rendering/Core/InteractorObserver'; -import { vtkProp } from '../../../Rendering/Core/Prop'; +import { + IInteractorObserverInitialValues, + vtkInteractorObserver, +} from '../../../Rendering/Core/InteractorObserver'; +import { IPropInitialValues, vtkProp } from '../../../Rendering/Core/Prop'; import { vtkWidgetManager } from '../WidgetManager'; import { vtkWidgetRepresentation } from '../../Representations/WidgetRepresentation'; import { vtkWidgetState } from '../WidgetState'; @@ -7,6 +10,12 @@ import { Bounds } from '../../../types'; import { RenderingTypes } from '../WidgetManager/Constants'; import { EventHandler, vtkSubscription } from '../../../interfaces'; +export interface IAbstractWidgetInitialValues + extends IPropInitialValues, IInteractorObserverInitialValues { + contextVisibility?: boolean; + handleVisibility?: boolean; +} + export interface vtkAbstractWidget extends vtkProp, vtkInteractorObserver { /** * Get the bounds of the widget @@ -75,7 +84,7 @@ export interface vtkAbstractWidget extends vtkProp, vtkInteractorObserver { * * @param {Number} factor The place factor. */ - setPlaceFactor(factor: number): void; + setPlaceFactor(factor: number): boolean; /** * Get the `vtkWidgetRepresentation` instance associated with the given `vtkActor` instance. @@ -89,7 +98,7 @@ export interface vtkAbstractWidget extends vtkProp, vtkInteractorObserver { * * @param {RenderingTypes} renderingType Default value if `RenderingTypes.FRONT_BUFFER` */ - updateRepresentationForRender(renderingType: RenderingTypes): void; + updateRepresentationForRender(renderingType?: RenderingTypes): void; /** * Get all the underlyings view widgets. @@ -101,7 +110,7 @@ export interface vtkAbstractWidget extends vtkProp, vtkInteractorObserver { * * @param {Boolean} visible */ - setContextVisibility(visible: boolean): void; + setContextVisibility(visible: boolean): boolean; /** * Get the context visibility. @@ -113,7 +122,7 @@ export interface vtkAbstractWidget extends vtkProp, vtkInteractorObserver { * * @param {Boolean} visible */ - setHandleVisibility(visible: boolean): void; + setHandleVisibility(visible: boolean): boolean; /** * Returns true if the handles are visible, false otherwise. @@ -171,7 +180,7 @@ export interface vtkAbstractWidget extends vtkProp, vtkInteractorObserver { export function extend( publicAPI: object, model: object, - initialValues?: object + initialValues?: IAbstractWidgetInitialValues ): void; /** @@ -179,7 +188,9 @@ export function extend( * * @param initialValues For pre-setting some of its content */ -export function newInstance(initialValues?: object): vtkAbstractWidget; +export function newInstance( + initialValues?: IAbstractWidgetInitialValues +): vtkAbstractWidget; /** * vtkAbstractWidget is an abstract class to construct a widget. diff --git a/Sources/Widgets/Core/AbstractWidgetFactory/index.d.ts b/Sources/Widgets/Core/AbstractWidgetFactory/index.d.ts index 2b0d73e8602..27add072d15 100644 --- a/Sources/Widgets/Core/AbstractWidgetFactory/index.d.ts +++ b/Sources/Widgets/Core/AbstractWidgetFactory/index.d.ts @@ -6,7 +6,7 @@ import { Bounds, Nullable } from '../../../types'; import { EventHandler, vtkSubscription, vtkObject } from '../../../interfaces'; export interface IGetWidgetForViewParams { - viewId: number; + viewId: string; renderer?: vtkRenderer; viewType?: ViewTypes; initialValues?: object; @@ -67,7 +67,7 @@ export interface vtkAbstractWidgetFactory< * * @param {Boolean} visible */ - setHandleVisiblity(visible: boolean): void; + setHandleVisibility(visible: boolean): void; /** * Place a new widget at the given bounds. @@ -99,7 +99,7 @@ export interface vtkAbstractWidgetFactory< * @param {EventHandler} cb The callback to be invoked. * @param {Number} [priority] The priority of this subscription */ - onWidgetChangeEvent( + onWidgetChange( cb: EventHandler, priority?: number ): Readonly; @@ -109,7 +109,7 @@ export interface vtkAbstractWidgetFactory< * * @param args The event payload */ - invokeWidgetChangeEvent(...args: unknown[]): void; + invokeWidgetChange(...args: unknown[]): void; } /** diff --git a/Sources/Widgets/Core/StateBuilder/boundsMixin.d.ts b/Sources/Widgets/Core/StateBuilder/boundsMixin.d.ts new file mode 100644 index 00000000000..17891bba4f4 --- /dev/null +++ b/Sources/Widgets/Core/StateBuilder/boundsMixin.d.ts @@ -0,0 +1,97 @@ +import { Bounds, Vector3 } from '../../../types'; +import { vtkWidgetState } from '../WidgetState'; + +export interface IBoundsInitialValues { + bounds?: Bounds; + placeFactor?: number; +} + +export interface vtkBoundsMixinState extends vtkWidgetState { + /** + * Get a copy of the (place-factor scaled) bounds. + */ + getBounds(): Bounds; + + /** + * Get the (place-factor scaled) bounds by reference. + */ + getBoundsByReference(): Bounds; + + /** + * Set the bounds. + */ + setBounds(bounds: Bounds): boolean; + setBounds( + xMin: number, + xMax: number, + yMin: number, + yMax: number, + zMin: number, + zMax: number + ): boolean; + + /** + * Set the bounds by reference. + */ + setBoundsFrom(bounds: Bounds): void; + + /** + * Get the factor by which the bounds passed to `placeWidget` are scaled + * around their center. + */ + getPlaceFactor(): number; + + /** + * Set the place factor and re-apply it to the bounds last given to + * `placeWidget`. + * + * @param {Number} factor The scaling factor + */ + setPlaceFactor(factor: number): void; + + /** + * Scale the given bounds by the place factor and store them as the state + * bounds. Invokes the `BoundsChange` event. + * + * @param {Bounds} bounds The bounds to place the widget on + */ + placeWidget(bounds: Bounds): void; + + /** + * Test whether a point lies inside the current bounds. + */ + containsPoint(point: Vector3): boolean; + containsPoint(x: number, y: number, z: number): boolean; + + /** + * Register a callback invoked whenever the bounds change. + */ + onBoundsChange(cb: (bounds: Bounds) => void): Readonly<{ + unsubscribe: () => void; + }>; + + /** + * Invoke the `BoundsChange` event. + */ + invokeBoundsChange(bounds: Bounds): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with bounds + * characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IBoundsInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IBoundsInitialValues +): void; + +declare const vtkBoundsMixin: { + extend: typeof extend; +}; + +export default vtkBoundsMixin; diff --git a/Sources/Widgets/Core/StateBuilder/color3Mixin.d.ts b/Sources/Widgets/Core/StateBuilder/color3Mixin.d.ts new file mode 100644 index 00000000000..b8c22ec4341 --- /dev/null +++ b/Sources/Widgets/Core/StateBuilder/color3Mixin.d.ts @@ -0,0 +1,64 @@ +import { RGBColor } from '../../../types'; +import { vtkWidgetState } from '../WidgetState'; + +/** + * RGB Uint8 color mixin. Not to be used in conjunction with the `color` mixin. + * @see colorMixin + */ +export interface IColor3InitialValues { + color3?: RGBColor; + opacity?: number; +} + +export interface vtkColor3MixinState extends vtkWidgetState { + /** + * Get a copy of the Uint8 RGB color. + */ + getColor3(): RGBColor; + + /** + * Get the Uint8 RGB color by reference. + */ + getColor3ByReference(): RGBColor; + + /** + * Set the Uint8 RGB color. + */ + setColor3(color: RGBColor): boolean; + setColor3(r: number, g: number, b: number): boolean; + + /** + * Set the Uint8 RGB color by reference. + */ + setColor3From(color: RGBColor): void; + + /** + * Get the Uint8 opacity. + */ + getOpacity(): number; + + /** + * Set the Uint8 opacity. + */ + setOpacity(opacity: number): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with a Uint8 RGB + * color and opacity. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IColor3InitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IColor3InitialValues +): void; + +declare const vtkColor3Mixin: { + extend: typeof extend; +}; + +export default vtkColor3Mixin; diff --git a/Sources/Widgets/Core/StateBuilder/colorMixin.d.ts b/Sources/Widgets/Core/StateBuilder/colorMixin.d.ts new file mode 100644 index 00000000000..772b9b7ab7f --- /dev/null +++ b/Sources/Widgets/Core/StateBuilder/colorMixin.d.ts @@ -0,0 +1,41 @@ +import { vtkWidgetState } from '../WidgetState'; + +/** + * Scalar color mixin. The scalar value in [0, 1] references a color in the + * mapper lookup table. Not to be used in conjunction with the `color3` mixin. + * @see color3Mixin + */ +export interface IColorInitialValues { + color?: number; +} + +export interface vtkColorMixinState extends vtkWidgetState { + /** + * Get the scalar color value in [0, 1]. + */ + getColor(): number; + + /** + * Set the scalar color value in [0, 1]. + */ + setColor(color: number): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with a scalar color. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IColorInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IColorInitialValues +): void; + +declare const vtkColorMixin: { + extend: typeof extend; +}; + +export default vtkColorMixin; diff --git a/Sources/Widgets/Core/StateBuilder/cornerMixin.d.ts b/Sources/Widgets/Core/StateBuilder/cornerMixin.d.ts new file mode 100644 index 00000000000..fd5a0ca57a1 --- /dev/null +++ b/Sources/Widgets/Core/StateBuilder/cornerMixin.d.ts @@ -0,0 +1,54 @@ +import { Vector3 } from '../../../types'; +import { vtkWidgetState } from '../WidgetState'; + +export interface ICornerInitialValues { + corner?: Vector3; +} + +export interface vtkCornerMixinState extends vtkWidgetState { + /** + * Get a copy of the corner position. + */ + getCorner(): Vector3; + + /** + * Get the corner position by reference. + */ + getCornerByReference(): Vector3; + + /** + * Set the corner position. + */ + setCorner(corner: Vector3): boolean; + setCorner(x: number, y: number, z: number): boolean; + + /** + * Set the corner position from an array. + */ + setCornerFrom(corner: Vector3): void; + + /** + * Translate the corner by the given delta. + */ + translate(dx: number, dy: number, dz: number): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with a corner + * position. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ICornerInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ICornerInitialValues +): void; + +declare const vtkCornerMixin: { + extend: typeof extend; +}; + +export default vtkCornerMixin; diff --git a/Sources/Widgets/Core/StateBuilder/directionMixin.d.ts b/Sources/Widgets/Core/StateBuilder/directionMixin.d.ts new file mode 100644 index 00000000000..759032d417a --- /dev/null +++ b/Sources/Widgets/Core/StateBuilder/directionMixin.d.ts @@ -0,0 +1,87 @@ +import { Vector3 } from '../../../types'; +import { vtkWidgetState } from '../WidgetState'; + +export interface IDirectionInitialValues { + direction?: Vector3; + + /** + * The unit the `rotate*` angles are expressed in. Anything other than + * `'degree'` is treated as radians. + * @default 'radian' + */ + angleUnit?: 'degree' | 'radian'; +} + +export interface vtkDirectionMixinState extends vtkWidgetState { + /** + * Get a copy of the direction. + */ + getDirection(): Vector3; + + /** + * Get the direction by reference. + */ + getDirectionByReference(): Vector3; + + /** + * Set the direction. + */ + setDirection(direction: Vector3): boolean; + setDirection(x: number, y: number, z: number): boolean; + + /** + * Set the direction from an existing array without triggering a modified event. + */ + setDirectionFrom(direction: Vector3): void; + + /** + * Rotate the direction by the rotation taking `originDirection` onto + * `targetDirection`. + */ + rotateFromDirections( + originDirection: Vector3, + targetDirection: Vector3 + ): void; + + /** + * Rotate the direction around an arbitrary axis. + * + * @param {Number} angle The angle, in the unit given by the state `angleUnit` + * @param {Vector3} axis The rotation axis + */ + rotate(angle: number, axis: Vector3): void; + + /** + * Rotate the direction around the X axis. + */ + rotateX(angle: number): void; + + /** + * Rotate the direction around the Y axis. + */ + rotateY(angle: number): void; + + /** + * Rotate the direction around the Z axis. + */ + rotateZ(angle: number): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with a direction. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IDirectionInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IDirectionInitialValues +): void; + +declare const vtkDirectionMixin: { + extend: typeof extend; +}; + +export default vtkDirectionMixin; diff --git a/Sources/Widgets/Core/StateBuilder/index.d.ts b/Sources/Widgets/Core/StateBuilder/index.d.ts index d5ebcc5281d..b678c878c45 100644 --- a/Sources/Widgets/Core/StateBuilder/index.d.ts +++ b/Sources/Widgets/Core/StateBuilder/index.d.ts @@ -1,29 +1,85 @@ import vtkWidgetState from '../WidgetState'; +import { vtkBoundsMixinState } from './boundsMixin'; + +/** + * The root state a builder produces. It is always decorated with the bounds + * mixin, so that `placeWidget` and the widget factor are available on every + * widget state, plus whatever mixins are passed to `build`. + */ +export type vtkRootWidgetState = vtkWidgetState & vtkBoundsMixinState; + +/** + * The name of a mixin known to the state builder. Each one is implemented by + * the matching `Mixin` module of this directory. + */ +export type StateBuilderMixin = + | 'bounds' + | 'color' + | 'color3' + | 'corner' + | 'direction' + | 'manipulator' + | 'name' + | 'orientation' + | 'origin' + | 'scale1' + | 'scale3' + | 'text' + | 'visible' + | 'shape'; export interface StateBuilder { + /** + * Add a sub-state that can hold a varying number of instances, all built from + * the same set of mixins. The built state exposes `add`, + * `getList`, `remove` and `clearList` methods. + */ addDynamicMixinState(buildInfo: { labels: string[]; - mixins: string[]; + mixins: StateBuilderMixin[]; name: string; initialValues?: object; }): StateBuilder; + + /** + * Add a single sub-state built from the given mixins. + */ addStateFromMixin(buildInfo: { labels: string[]; - mixins: string[]; + mixins: StateBuilderMixin[]; name: string; initialValues?: object; }): StateBuilder; + + /** + * Add an already built state as a sub-state. + */ addStateFromInstance(stateInfo: { labels: string[]; name: string; instance: vtkWidgetState; - }); - addField(field: { name: string; initialValue: any }); - build(...mixins: string[]): vtkWidgetState; + }): StateBuilder; + + /** + * Add a plain field, with its `get`/`set` accessors, onto the + * state being built. + */ + addField(field: { name: string; initialValue: any }): StateBuilder; + + /** + * Build the state, optionally decorating the root state with the given + * mixins. + */ + build(...mixins: StateBuilderMixin[]): vtkRootWidgetState; } +/** + * Create a new, empty state builder. + */ export function createBuilder(): StateBuilder; -export declare const vtkStateBuilder: { +declare const vtkStateBuilder: { createBuilder: typeof createBuilder; }; + +export default vtkStateBuilder; diff --git a/Sources/Widgets/Core/StateBuilder/manipulatorMixin.d.ts b/Sources/Widgets/Core/StateBuilder/manipulatorMixin.d.ts new file mode 100644 index 00000000000..be2639c2aa3 --- /dev/null +++ b/Sources/Widgets/Core/StateBuilder/manipulatorMixin.d.ts @@ -0,0 +1,43 @@ +import vtkAbstractManipulator from '../../Manipulators/AbstractManipulator'; +import { vtkWidgetState } from '../WidgetState'; + +export interface IManipulatorInitialValues { + manipulator?: vtkAbstractManipulator | null; +} + +export interface vtkManipulatorMixinState extends vtkWidgetState { + /** + * Get the manipulator bound to the state. + */ + getManipulator(): vtkAbstractManipulator | null; + + /** + * Set the manipulator bound to the state. + */ + setManipulator(manipulator: vtkAbstractManipulator | null): boolean; + + /** + * Push the state's `origin`, `normal` and `direction` onto the manipulator, + * when the manipulator exposes the matching setters. + */ + updateManipulator(): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with a manipulator. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IManipulatorInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IManipulatorInitialValues +): void; + +declare const vtkManipulatorMixin: { + extend: typeof extend; +}; + +export default vtkManipulatorMixin; diff --git a/Sources/Widgets/Core/StateBuilder/nameMixin.d.ts b/Sources/Widgets/Core/StateBuilder/nameMixin.d.ts new file mode 100644 index 00000000000..14a85da7334 --- /dev/null +++ b/Sources/Widgets/Core/StateBuilder/nameMixin.d.ts @@ -0,0 +1,36 @@ +import { vtkWidgetState } from '../WidgetState'; + +export interface INameInitialValues { + name?: string; +} + +export interface vtkNameMixinState extends vtkWidgetState { + /** + * Get the name of the state. + */ + getName(): string; + + /** + * Set the name of the state. + */ + setName(name: string): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with a name. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {INameInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: INameInitialValues +): void; + +declare const vtkNameMixin: { + extend: typeof extend; +}; + +export default vtkNameMixin; diff --git a/Sources/Widgets/Core/StateBuilder/orientationMixin.d.ts b/Sources/Widgets/Core/StateBuilder/orientationMixin.d.ts new file mode 100644 index 00000000000..5682c6a4663 --- /dev/null +++ b/Sources/Widgets/Core/StateBuilder/orientationMixin.d.ts @@ -0,0 +1,76 @@ +import { Vector3 } from '../../../types'; +import { vtkWidgetState } from '../WidgetState'; + +export interface IOrientationInitialValues { + up?: Vector3; + right?: Vector3; + direction?: Vector3; +} + +export interface vtkOrientationMixinState extends vtkWidgetState { + /** + * Get a copy of the up vector. + */ + getUp(): Vector3; + getUpByReference(): Vector3; + setUp(up: Vector3): boolean; + setUp(x: number, y: number, z: number): boolean; + setUpFrom(up: Vector3): void; + + /** + * Get a copy of the right vector. + */ + getRight(): Vector3; + getRightByReference(): Vector3; + setRight(right: Vector3): boolean; + setRight(x: number, y: number, z: number): boolean; + setRightFrom(right: Vector3): void; + + /** + * Get a copy of the direction vector. + */ + getDirection(): Vector3; + getDirectionByReference(): Vector3; + setDirection(direction: Vector3): boolean; + setDirection(x: number, y: number, z: number): boolean; + setDirectionFrom(direction: Vector3): void; + + /** + * Normalize the up, right and direction vectors. + */ + normalize(): void; + + /** + * Recompute an orthonormal frame from an origin and two points defining the + * right and up directions. + * + * @param {Vector3} origin The frame origin + * @param {Vector3} rightPoint A point along the right direction + * @param {Vector3} upPoint A point along the up direction + */ + updateFromOriginRightUp( + origin: Vector3, + rightPoint: Vector3, + upPoint: Vector3 + ): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with an orthonormal + * orientation frame. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOrientationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOrientationInitialValues +): void; + +declare const vtkOrientationMixin: { + extend: typeof extend; +}; + +export default vtkOrientationMixin; diff --git a/Sources/Widgets/Core/StateBuilder/originMixin.d.ts b/Sources/Widgets/Core/StateBuilder/originMixin.d.ts new file mode 100644 index 00000000000..3c37ea59ac3 --- /dev/null +++ b/Sources/Widgets/Core/StateBuilder/originMixin.d.ts @@ -0,0 +1,83 @@ +import { Nullable, Vector3 } from '../../../types'; +import { IDisplayScaleParams } from '../WidgetManager'; +import { vtkWidgetState } from '../WidgetState'; + +export interface IOriginInitialValues { + origin?: Nullable; + /** + * Optional offset added to the origin. When `getOrigin` is called with + * display scale parameters, the offset is scaled to pixel screen space. + */ + offset?: Nullable; +} + +export interface vtkOriginMixinState extends vtkWidgetState { + /** + * Get a copy of the origin, with `offset` applied when one is set. + * + * @param {IDisplayScaleParams} [displayScaleParams] When provided, the offset + * is scaled to pixel screen space instead of being added in world space. + */ + getOrigin(displayScaleParams?: IDisplayScaleParams): Nullable; + + /** + * Get the origin by reference. The `offset` is not applied. + */ + getOriginByReference(): Nullable; + + /** + * Set the origin. + */ + setOrigin(origin: Vector3): boolean; + setOrigin(x: number, y: number, z: number): boolean; + + /** + * Set the origin. + */ + setOriginFrom(origin: Vector3): void; + + /** + * Get a copy of the offset. + */ + getOffset(): Nullable; + + /** + * Get the offset by reference. + */ + getOffsetByReference(): Nullable; + + /** + * Set the offset. + */ + setOffset(offset: Vector3): boolean; + setOffset(x: number, y: number, z: number): boolean; + + /** + * Set the offset. + */ + setOffsetFrom(offset: Vector3): void; + + /** + * Translate the origin by the given delta. + */ + translate(dx: number, dy: number, dz: number): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with an origin. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOriginInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOriginInitialValues +): void; + +declare const vtkOriginMixin: { + extend: typeof extend; +}; + +export default vtkOriginMixin; diff --git a/Sources/Widgets/Core/StateBuilder/scale1Mixin.d.ts b/Sources/Widgets/Core/StateBuilder/scale1Mixin.d.ts new file mode 100644 index 00000000000..06f398afd3e --- /dev/null +++ b/Sources/Widgets/Core/StateBuilder/scale1Mixin.d.ts @@ -0,0 +1,39 @@ +import { vtkWidgetState } from '../WidgetState'; + +export interface IScale1InitialValues { + scale1?: number; +} + +export interface vtkScale1MixinState extends vtkWidgetState { + /** + * Get the uniform scale of the state. + */ + getScale1(): number; + + /** + * Set the uniform scale of the state. + * + * @param {Number} scale + */ + setScale1(scale: number): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with a uniform + * scale. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IScale1InitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IScale1InitialValues +): void; + +declare const vtkScale1Mixin: { + extend: typeof extend; +}; + +export default vtkScale1Mixin; diff --git a/Sources/Widgets/Core/StateBuilder/scale3Mixin.d.ts b/Sources/Widgets/Core/StateBuilder/scale3Mixin.d.ts new file mode 100644 index 00000000000..32eb3be799b --- /dev/null +++ b/Sources/Widgets/Core/StateBuilder/scale3Mixin.d.ts @@ -0,0 +1,49 @@ +import { Vector3 } from '../../../types'; +import { vtkWidgetState } from '../WidgetState'; + +export interface IScale3InitialValues { + scale3?: Vector3; +} + +export interface vtkScale3MixinState extends vtkWidgetState { + /** + * Get a copy of the per-axis scale. + */ + getScale3(): Vector3; + + /** + * Get the per-axis scale by reference. + */ + getScale3ByReference(): Vector3; + + /** + * Set the per-axis scale. + */ + setScale3(scale: Vector3): boolean; + setScale3(x: number, y: number, z: number): boolean; + + /** + * Set the per-axis scale from an array. + */ + setScale3From(scale: Vector3): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with a per-axis + * scale. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IScale3InitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IScale3InitialValues +): void; + +declare const vtkScale3Mixin: { + extend: typeof extend; +}; + +export default vtkScale3Mixin; diff --git a/Sources/Widgets/Core/StateBuilder/shapeMixin.d.ts b/Sources/Widgets/Core/StateBuilder/shapeMixin.d.ts new file mode 100644 index 00000000000..898f9472bcb --- /dev/null +++ b/Sources/Widgets/Core/StateBuilder/shapeMixin.d.ts @@ -0,0 +1,36 @@ +import { vtkWidgetState } from '../WidgetState'; + +export interface IShapeInitialValues { + shape?: string; +} + +export interface vtkShapeMixinState extends vtkWidgetState { + /** + * Get the shape used to represent the state. + */ + getShape(): string; + + /** + * Set the shape used to represent the state. + */ + setShape(shape: string): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with a shape. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IShapeInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IShapeInitialValues +): void; + +declare const vtkShapeMixin: { + extend: typeof extend; +}; + +export default vtkShapeMixin; diff --git a/Sources/Widgets/Core/StateBuilder/textMixin.d.ts b/Sources/Widgets/Core/StateBuilder/textMixin.d.ts new file mode 100644 index 00000000000..cb5b4a8ddb0 --- /dev/null +++ b/Sources/Widgets/Core/StateBuilder/textMixin.d.ts @@ -0,0 +1,36 @@ +import { vtkWidgetState } from '../WidgetState'; + +export interface ITextInitialValues { + text?: string; +} + +export interface vtkTextMixinState extends vtkWidgetState { + /** + * Get the text associated with the state. + */ + getText(): string; + + /** + * Set the text associated with the state. + */ + setText(text: string): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with a text label. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ITextInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ITextInitialValues +): void; + +declare const vtkTextMixin: { + extend: typeof extend; +}; + +export default vtkTextMixin; diff --git a/Sources/Widgets/Core/StateBuilder/visibleMixin.d.ts b/Sources/Widgets/Core/StateBuilder/visibleMixin.d.ts new file mode 100644 index 00000000000..a8a459a9411 --- /dev/null +++ b/Sources/Widgets/Core/StateBuilder/visibleMixin.d.ts @@ -0,0 +1,44 @@ +import { vtkWidgetState } from '../WidgetState'; + +export interface IVisibleInitialValues { + visible?: boolean; +} + +export interface vtkVisibleMixinState extends vtkWidgetState { + /** + * Get the visibility of the state. + */ + getVisible(): boolean; + + /** + * Get the visibility of the state. Alias of `getVisible`. + */ + isVisible(): boolean; + + /** + * Set the visibility of the state. + * + * @param {Boolean} visible + */ + setVisible(visible: boolean): boolean; +} + +/** + * Method used to decorate a given object (publicAPI+model) with visibility + * characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IVisibleInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IVisibleInitialValues +): void; + +declare const vtkVisibleMixin: { + extend: typeof extend; +}; + +export default vtkVisibleMixin; diff --git a/Sources/Widgets/Core/WidgetManager/Constants.d.ts b/Sources/Widgets/Core/WidgetManager/Constants.d.ts index 1ffc3493ae6..cf345fce716 100644 --- a/Sources/Widgets/Core/WidgetManager/Constants.d.ts +++ b/Sources/Widgets/Core/WidgetManager/Constants.d.ts @@ -1,22 +1,29 @@ -export declare enum ViewTypes { - DEFAULT = 0, - GEOMETRY = 1, - SLICE = 2, - VOLUME = 3, - YZ_PLANE = 4, - XZ_PLANE = 5, - XY_PLANE = 6, -} +export declare const ViewTypes: { + readonly DEFAULT: 0; + readonly GEOMETRY: 1; + readonly SLICE: 2; + readonly VOLUME: 3; + readonly YZ_PLANE: 4; + readonly XZ_PLANE: 5; + readonly XY_PLANE: 6; +}; + +export type ViewTypes = (typeof ViewTypes)[keyof typeof ViewTypes]; + +export declare const RenderingTypes: { + readonly PICKING_BUFFER: 0; + readonly FRONT_BUFFER: 1; +}; + +export type RenderingTypes = + (typeof RenderingTypes)[keyof typeof RenderingTypes]; -export declare enum RenderingTypes { - PICKING_BUFFER = 0, - FRONT_BUFFER = 1, -} +export declare const CaptureOn: { + readonly MOUSE_MOVE: 0; + readonly MOUSE_RELEASE: 1; +}; -export declare enum CaptureOn { - MOUSE_MOVE = 0, - MOUSE_RELEASE = 1, -} +export type CaptureOn = (typeof CaptureOn)[keyof typeof CaptureOn]; declare const _default: { ViewTypes: typeof ViewTypes; diff --git a/Sources/Widgets/Core/WidgetManager/index.d.ts b/Sources/Widgets/Core/WidgetManager/index.d.ts index 95ad1abb004..1843925f5ad 100644 --- a/Sources/Widgets/Core/WidgetManager/index.d.ts +++ b/Sources/Widgets/Core/WidgetManager/index.d.ts @@ -9,8 +9,8 @@ import vtkSelectionNode from '../../../Common/DataModel/SelectionNode'; import vtkWidgetRepresentation from '../../Representations/WidgetRepresentation'; import vtkWidgetState from '../WidgetState'; import { vtkObject } from '../../../interfaces'; -import { CaptureOn, ViewTypes } from './Constants'; -import { Nullable } from '../../../types'; +import Constants, { CaptureOn, ViewTypes } from './Constants'; +import { Nullable, Vector3 } from '../../../types'; export interface IDisplayScaleParams { dispHeightFactor: number; @@ -54,7 +54,7 @@ export function extractRenderingComponents( * `coord`, you would compute `30 * getPixelWorldHeightAtCoord(coord)`. */ export function getPixelWorldHeightAtCoord( - coord: [], + coord: Vector3, displayScaleParams: IDisplayScaleParams ): number; @@ -87,8 +87,11 @@ export interface vtkWidgetManager extends vtkObject { /** * Get the current selection. + * + * Null until a capture has run, and reset to null on every + * getSelectedDataForXY call, so it stays null while picking is disabled. */ - getSelections(): vtkSelectionNode[]; + getSelections(): Nullable; /** * Get all the underlying widgets. @@ -105,7 +108,7 @@ export interface vtkWidgetManager extends vtkObject { /** * Get the view id. */ - getViewId(): string; + getViewId(): string | null; /** * Returns true if picking is enabled, false otherwise. @@ -138,6 +141,8 @@ export interface vtkWidgetManager extends vtkObject { * Register a widget on the widget manager instance. * Please note that one should link the widget manager to a view before calling this method. * + * Returns null if the widget manager has no renderer yet. + * * @param {vtkAbstractWidgetFactory} widget The abstract widget factory. * @param {ViewTypes} [viewType] * @param {Object} [initialValues] @@ -146,9 +151,11 @@ export interface vtkWidgetManager extends vtkObject { widget: WidgetFactory, viewType?: ViewTypes, initialValues?: object - ): WidgetFactory extends vtkAbstractWidgetFactory - ? WidgetInstance - : never; + ): Nullable< + WidgetFactory extends vtkAbstractWidgetFactory + ? WidgetInstance + : never + >; /** * Unregister all widgets from the widget manager. @@ -168,12 +175,18 @@ export interface vtkWidgetManager extends vtkObject { * @param {Number} x * @param {Number} y */ - getSelectedDataForXY(x: number, y: number): Promise; + getSelectedDataForXY( + x: number, + y: number + ): Promise>; /** * The all currently selected data. + * + * Empty when nothing is selected, or when the selected prop resolves to no + * widget and representation. Narrow with `'widget' in result`. */ - getSelectedData(): ISelectedData | {}; + getSelectedData(): ISelectedData | Record; /** * Given the focus to the given widget instance. @@ -236,6 +249,8 @@ export function newInstance( export declare const vtkWidgetManager: { newInstance: typeof newInstance; extend: typeof extend; + Constants: typeof Constants; + getPixelWorldHeightAtCoord: typeof getPixelWorldHeightAtCoord; }; export default vtkWidgetManager; diff --git a/Sources/Widgets/Core/WidgetState/index.d.ts b/Sources/Widgets/Core/WidgetState/index.d.ts index 7d9bf8f2b95..27eee225fa7 100644 --- a/Sources/Widgets/Core/WidgetState/index.d.ts +++ b/Sources/Widgets/Core/WidgetState/index.d.ts @@ -1,5 +1,9 @@ import { vtkObject } from '../../../interfaces'; +export interface IWidgetStateInitialValues { + active?: boolean; +} + export interface vtkWidgetState extends vtkObject { /** * Set the active flag of the widget state instance @@ -70,12 +74,12 @@ export interface vtkWidgetState extends vtkObject { * * @param publicAPI object on which methods will be bounds (public) * @param model object on which data structure will be bounds (protected) - * @param {object} [initialValues] (default: {}) + * @param {IWidgetStateInitialValues} [initialValues] (default: {}) */ export function extend( publicAPI: object, model: object, - initialValues?: object + initialValues?: IWidgetStateInitialValues ): vtkWidgetState; export declare const vtkWidgetState: { diff --git a/Sources/Widgets/Manipulators/AbstractManipulator/index.d.ts b/Sources/Widgets/Manipulators/AbstractManipulator/index.d.ts index 48a54e4d154..23614669772 100644 --- a/Sources/Widgets/Manipulators/AbstractManipulator/index.d.ts +++ b/Sources/Widgets/Manipulators/AbstractManipulator/index.d.ts @@ -6,6 +6,8 @@ import { Matrix3x3, Nullable, Vector3 } from '../../../types'; * */ export interface IAbstractManipulatorInitialValues { + useCameraFocalPoint?: boolean; + useCameraNormal?: boolean; userOrigin?: Vector3; handleOrigin?: Vector3; widgetOrigin?: Vector3; @@ -85,6 +87,17 @@ export interface vtkAbstractManipulator extends vtkObject { /* ------------------------------------------------------------------- */ + /** + * Get the user normal currently stored on the manipulator, or `undefined` when it + * has never been set. It takes precedence over the handle and widget normals. + */ + getUserNormal(): Nullable | undefined; + + /** + * Get the user normal without copying it out of the model (see getUserNormal). + */ + getUserNormalByReference(): Nullable | undefined; + /** * Set the user normal. * This normal take precedence on the handleNormal and the widgetNormal. @@ -105,7 +118,18 @@ export interface vtkAbstractManipulator extends vtkObject { * Set the user normal (see setUserNormal). * @param {Vector3} normal The normal coordinate. */ - setUserNormalFrom(normal: Vector3): boolean; + setUserNormalFrom(normal: Vector3): void; + + /** + * Get the user origin currently stored on the manipulator, or `undefined` when it + * has never been set. It takes precedence over the handle and widget origins. + */ + getUserOrigin(): Nullable | undefined; + + /** + * Get the user origin without copying it out of the model (see getUserOrigin). + */ + getUserOriginByReference(): Nullable | undefined; /** * Set the user origin. @@ -127,10 +151,21 @@ export interface vtkAbstractManipulator extends vtkObject { * Set the user origin (see setUserOrigin). * @param {Vector3} origin The coordinate of the origin point. */ - setUserOriginFrom(origin: Vector3): boolean; + setUserOriginFrom(origin: Vector3): void; /* ------------------------------------------------------------------- */ + /** + * Get the handle normal currently stored on the manipulator, or `undefined` when it + * has never been set. It is used after the user normal and before the widget normal. + */ + getHandleNormal(): Nullable | undefined; + + /** + * Get the handle normal without copying it out of the model (see getHandleNormal). + */ + getHandleNormalByReference(): Nullable | undefined; + /** * Set the handle normal. * This normal is used after the userNormal and before the widgetNormal. @@ -152,7 +187,18 @@ export interface vtkAbstractManipulator extends vtkObject { * Set the handle normal (see setHandleNormal). * @param {Vector3} normal The normal coordinate. */ - setHandleNormalFrom(normal: Vector3): boolean; + setHandleNormalFrom(normal: Vector3): void; + + /** + * Get the handle origin currently stored on the manipulator, or `undefined` when it + * has never been set. It is used after the user origin and before the widget origin. + */ + getHandleOrigin(): Nullable | undefined; + + /** + * Get the handle origin without copying it out of the model (see getHandleOrigin). + */ + getHandleOriginByReference(): Nullable | undefined; /** * Set the handle origin. @@ -175,10 +221,21 @@ export interface vtkAbstractManipulator extends vtkObject { * Set the handle origin (see setHandleOrigin). * @param {Vector3} origin The coordinate of the origin point. */ - setHandleOriginFrom(origin: Vector3): boolean; + setHandleOriginFrom(origin: Vector3): void; /* ------------------------------------------------------------------- */ + /** + * Get the widget normal currently stored on the manipulator, or `undefined` when it + * has never been set. It is used when no other normal is set. + */ + getWidgetNormal(): Nullable | undefined; + + /** + * Get the widget normal without copying it out of the model (see getWidgetNormal). + */ + getWidgetNormalByReference(): Nullable | undefined; + /** * Set the widget normal. * This normal is used if no other normals are set. @@ -199,7 +256,18 @@ export interface vtkAbstractManipulator extends vtkObject { * Set the widget normal (see setWidgetNormal). * @param {Vector3} normal The normal coordinate. */ - setWidgetNormalFrom(normal: Vector3): boolean; + setWidgetNormalFrom(normal: Vector3): void; + + /** + * Get the widget origin currently stored on the manipulator, or `undefined` when it + * has never been set. It is used when no other origin is set. + */ + getWidgetOrigin(): Nullable | undefined; + + /** + * Get the widget origin without copying it out of the model (see getWidgetOrigin). + */ + getWidgetOriginByReference(): Nullable | undefined; /** * Set the widget origin. @@ -221,7 +289,7 @@ export interface vtkAbstractManipulator extends vtkObject { * Set the widget origin (see setWidgetOrigin). * @param {Vector3} origin The coordinate of the origin point. */ - setWidgetOriginFrom(origin: Vector3): boolean; + setWidgetOriginFrom(origin: Vector3): void; } /** diff --git a/Sources/Widgets/Manipulators/CPRManipulator/index.d.ts b/Sources/Widgets/Manipulators/CPRManipulator/index.d.ts new file mode 100644 index 00000000000..e1479f31657 --- /dev/null +++ b/Sources/Widgets/Manipulators/CPRManipulator/index.d.ts @@ -0,0 +1,137 @@ +import vtkImageSlice from '../../../Rendering/Core/ImageSlice'; +import { Matrix3x3, Nullable, Vector3 } from '../../../types'; +import { + IAbstractManipulatorInitialValues, + vtkAbstractManipulator, +} from '../AbstractManipulator'; + +/** + * + */ +export interface ICPRManipulatorInitialValues extends IAbstractManipulatorInitialValues { + distanceStep?: number; + currentDistance?: number; + cprActor?: Nullable; +} + +/** + * Position and direction along the centerline, as returned by + * `distanceEvent` and `handleScroll`. + */ +export interface ICPRManipulatorEvent { + worldCoords: Nullable; + worldDirection?: Matrix3x3; +} + +export interface vtkCPRManipulator extends vtkAbstractManipulator { + /** + * Get the actor which holds the vtkImageCPRMapper this manipulator moves + * along. + */ + getCprActor(): Nullable; + + /** + * Get the distance from the first point of the centerline of the last + * handled event. + */ + getCurrentDistance(): number; + + /** + * Not used by the implementation, it is only stored on the model. + */ + getDistance(): number | undefined; + + /** + * Get the distance the manipulator moves for one scroll step. When no + * distance step has been set, the smallest spacing of the mapper input + * image is used instead. + */ + getDistanceStep(): number; + + /** + * Move to the given distance from the first point of the centerline, after + * clamping it to the height of the mapper. + * @param {Number} distance + */ + distanceEvent(distance: number): ICPRManipulatorEvent; + + /** + * Move by the given number of distance steps along the centerline. + * @param {Number} nbSteps + */ + handleScroll(nbSteps: number): ICPRManipulatorEvent; + + /** + * Set the actor which holds the vtkImageCPRMapper this manipulator moves + * along. + * @param {vtkImageSlice} cprActor + */ + setCprActor(cprActor: Nullable): boolean; + + /** + * Set the distance from the first point of the centerline. + * @param {Number} currentDistance + */ + setCurrentDistance(currentDistance: number): boolean; + + /** + * @see getDistance + * @param {Number} distance + */ + setDistance(distance: number): boolean; + + /** + * Set the distance the manipulator moves for one scroll step. + * @param {Number} distanceStep + */ + setDistanceStep(distanceStep: number): boolean; +} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkCPRManipulator characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ICPRManipulatorInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ICPRManipulatorInitialValues +): void; + +/** + * Method use to create a new instance of vtkCPRManipulator + */ +export function newInstance( + initialValues?: ICPRManipulatorInitialValues +): vtkCPRManipulator; + +/** + * + * @param {Number} x + * @param {Number} y + * @param {Vector3} planeOrigin + * @param {Vector3} planeNormal + * @param renderer + * @param glRenderWindow + */ +export function intersectDisplayWithPlane( + x: number, + y: number, + planeOrigin: Vector3, + planeNormal: Vector3, + renderer: any, + glRenderWindow: any +): Vector3 | []; + +/** + * vtkCPRManipulator moves a point along the centerline of a + * vtkImageCPRMapper. + */ +export declare const vtkCPRManipulator: { + newInstance: typeof newInstance; + extend: typeof extend; + intersectDisplayWithPlane: typeof intersectDisplayWithPlane; +}; +export default vtkCPRManipulator; diff --git a/Sources/Widgets/Manipulators/LineManipulator/index.d.ts b/Sources/Widgets/Manipulators/LineManipulator/index.d.ts index e4bdbccaf31..105bbeb87d4 100755 --- a/Sources/Widgets/Manipulators/LineManipulator/index.d.ts +++ b/Sources/Widgets/Manipulators/LineManipulator/index.d.ts @@ -47,7 +47,7 @@ export function projectDisplayToLine( lineDirection: Vector3, renderer: any, glRenderWindow: any -): Vector3; +): Vector3 | []; /** * vtkLineManipulator. diff --git a/Sources/Widgets/Manipulators/PickerManipulator/index.d.ts b/Sources/Widgets/Manipulators/PickerManipulator/index.d.ts index 581b831ad0a..b5e0b90c6eb 100755 --- a/Sources/Widgets/Manipulators/PickerManipulator/index.d.ts +++ b/Sources/Widgets/Manipulators/PickerManipulator/index.d.ts @@ -18,7 +18,7 @@ export interface vtkPickerManipulator extends vtkAbstractManipulator { /** * */ - setPicker(picker: vtkPicker): void; + setPicker(picker: vtkPicker): boolean; } /** diff --git a/Sources/Widgets/Manipulators/PlaneManipulator/index.d.ts b/Sources/Widgets/Manipulators/PlaneManipulator/index.d.ts index 782c6e0b573..15707b2af9c 100755 --- a/Sources/Widgets/Manipulators/PlaneManipulator/index.d.ts +++ b/Sources/Widgets/Manipulators/PlaneManipulator/index.d.ts @@ -47,7 +47,7 @@ export function intersectDisplayWithPlane( planeNormal: Vector3, renderer: any, glRenderWindow: any -): Vector3; +): Vector3 | []; /** * vtkPlaneManipulator. diff --git a/Sources/Widgets/Manipulators/TrackballManipulator/index.d.ts b/Sources/Widgets/Manipulators/TrackballManipulator/index.d.ts index 3610128897c..3516e7523cb 100755 --- a/Sources/Widgets/Manipulators/TrackballManipulator/index.d.ts +++ b/Sources/Widgets/Manipulators/TrackballManipulator/index.d.ts @@ -56,7 +56,7 @@ export function trackballRotate( direction: Vector3, renderer: any, glRenderWindow: any -): void; +): Float64Array; /** * vtkTrackballManipulator. diff --git a/Sources/Widgets/Representations/ArrowHandleRepresentation/index.d.ts b/Sources/Widgets/Representations/ArrowHandleRepresentation/index.d.ts new file mode 100644 index 00000000000..64242d66340 --- /dev/null +++ b/Sources/Widgets/Representations/ArrowHandleRepresentation/index.d.ts @@ -0,0 +1,93 @@ +import { Matrix, Nullable, Vector2, Vector3 } from '../../../types'; +import { ShapeType } from '../../Widgets3D/LineWidget/Constants'; +import vtkGlyphRepresentation, { + IGlyphRepresentationInitialValues, +} from '../GlyphRepresentation'; + +export interface IArrowHandleRepresentationInitialValues extends IGlyphRepresentationInitialValues { + /** + * Whether the glyph should face the camera: + * - `null`/`undefined` leaves it to the shape type (2D shapes face the + * camera, 3D shapes do not) + * - `true` always faces the camera + * - `false` never faces the camera + */ + faceCamera?: Nullable; + orientation?: Vector3; + /** + * Shape used when the `shape` mixin of the states is invalid. + */ + shape?: ShapeType; + viewMatrix?: Matrix; +} + +export interface vtkArrowHandleRepresentation extends vtkGlyphRepresentation { + getVisibilityFlagArray(): Vector2 | undefined; + getVisibilityFlagArrayByReference(): Vector2 | undefined; + setVisibilityFlagArray(visibilityFlagArray: Vector2): boolean; + setVisibilityFlagArray(a: number, b: number): boolean; + setVisibilityFlagArrayFrom(visibilityFlagArray: Vector2): void; + + /** + * Direction the glyph is oriented along, for the shapes that are orientable. + */ + getOrientation(): Vector3; + getOrientationByReference(): Vector3; + setOrientation(orientation: Vector3): boolean; + setOrientation(x: number, y: number, z: number): boolean; + setOrientationFrom(orientation: Vector3): void; + + /** + * View matrix used to orient the glyph towards the camera. + */ + getViewMatrix(): Matrix; + getViewMatrixByReference(): Matrix; + setViewMatrix(viewMatrix: Matrix): boolean; + setViewMatrixFrom(viewMatrix: Matrix): void; + + getFaceCamera(): Nullable; + setFaceCamera(faceCamera: Nullable): boolean; + + setGlyphResolution(glyphResolution: number): boolean; + + /** + * Set a callback called with the display coordinates of the active states, + * or with no argument when no state is active. + */ + setDisplayCallback(callback: Nullable<(coords?: Vector3[]) => void>): void; + + /** True when the current shape is a flat shape. */ + is2DShape(): boolean; + + /** True when the current shape can be oriented along `orientation`. */ + isOrientableShape(): boolean; +} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkArrowHandleRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IArrowHandleRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IArrowHandleRepresentationInitialValues +): void; + +export function newInstance( + initialValues?: IArrowHandleRepresentationInitialValues +): vtkArrowHandleRepresentation; + +/** + * vtkArrowHandleRepresentation renders one glyph per handle state, the glyph + * geometry being rebuilt whenever the `shape` mixin of the states changes. + * Depending on the shape, the glyph is oriented along `orientation` and/or + * rotated to face the camera. + */ +export declare const vtkArrowHandleRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkArrowHandleRepresentation; diff --git a/Sources/Widgets/Representations/CircleContextRepresentation/index.d.ts b/Sources/Widgets/Representations/CircleContextRepresentation/index.d.ts new file mode 100644 index 00000000000..4857cbc227a --- /dev/null +++ b/Sources/Widgets/Representations/CircleContextRepresentation/index.d.ts @@ -0,0 +1,53 @@ +import vtkGlyphRepresentation, { + IGlyphRepresentationInitialValues, +} from '../GlyphRepresentation'; + +export interface ICircleContextRepresentationInitialValues extends IGlyphRepresentationInitialValues { + glyphResolution?: number; + drawBorder?: boolean; + drawFace?: boolean; +} + +export interface vtkCircleContextRepresentation extends vtkGlyphRepresentation { + /** Number of segments of the circle. */ + getGlyphResolution(): number; + setGlyphResolution(glyphResolution: number): boolean; + + /** Whether the outline of the circle is rendered. */ + getDrawBorder(): boolean; + setDrawBorder(drawBorder: boolean): boolean; + + /** Whether the interior of the circle is rendered. */ + getDrawFace(): boolean; + setDrawFace(drawFace: boolean): boolean; + + /** Sets the opacity of the actor property. */ + setOpacity(opacity: number): void; +} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkCircleContextRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ICircleContextRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ICircleContextRepresentationInitialValues +): void; + +export function newInstance( + initialValues?: ICircleContextRepresentationInitialValues +): vtkCircleContextRepresentation; + +/** + * vtkCircleContextRepresentation renders a semi transparent circle per state, + * offset in depth so that it does not fight with coincident geometry. + */ +export declare const vtkCircleContextRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkCircleContextRepresentation; diff --git a/Sources/Widgets/Representations/ContextRepresentation/index.d.ts b/Sources/Widgets/Representations/ContextRepresentation/index.d.ts new file mode 100644 index 00000000000..63e7da7fa4f --- /dev/null +++ b/Sources/Widgets/Representations/ContextRepresentation/index.d.ts @@ -0,0 +1,35 @@ +import vtkWidgetRepresentation, { + IWidgetRepresentationInitialValues, +} from '../WidgetRepresentation'; +import { Behavior } from '../WidgetRepresentation/Constants'; + +export interface IContextRepresentationInitialValues extends IWidgetRepresentationInitialValues { + behavior?: Behavior; + pickable?: boolean; + dragable?: boolean; +} + +export interface vtkContextRepresentation extends vtkWidgetRepresentation {} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkContextRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IContextRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IContextRepresentationInitialValues +): void; + +/** + * vtkContextRepresentation is the base class for widget representations that + * render the non-interactive context of a widget. It only defaults the + * representation to the `CONTEXT` behavior and makes it non-pickable. + */ +export declare const vtkContextRepresentation: { + extend: typeof extend; +}; +export default vtkContextRepresentation; diff --git a/Sources/Widgets/Representations/ConvexFaceContextRepresentation/index.d.ts b/Sources/Widgets/Representations/ConvexFaceContextRepresentation/index.d.ts new file mode 100644 index 00000000000..a65642b613b --- /dev/null +++ b/Sources/Widgets/Representations/ConvexFaceContextRepresentation/index.d.ts @@ -0,0 +1,57 @@ +import { RGBColor } from '../../../types'; +import vtkActor from '../../../Rendering/Core/Actor'; +import vtkMapper from '../../../Rendering/Core/Mapper'; +import vtkContextRepresentation, { + IContextRepresentationInitialValues, +} from '../ContextRepresentation'; + +export interface IConvexFaceContextRepresentationInitialValues extends IContextRepresentationInitialValues { + defaultColor?: RGBColor; + opacity?: number; +} + +export interface vtkConvexFaceContextRepresentation extends vtkContextRepresentation { + requestData(inData: any[], outData: any[]): void; + + getDefaultColor(): RGBColor; + getDefaultColorByReference(): RGBColor; + setDefaultColor(defaultColor: RGBColor): boolean; + setDefaultColorFrom(defaultColor: RGBColor): void; + + getMapper(): vtkMapper; + getActor(): vtkActor; + + /** + * Opacity applied on the face actor. While picking, a `HANDLE` behaved + * representation is temporarily made fully opaque. + */ + getOpacity(): number; + setOpacity(opacity: number): boolean; +} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkConvexFaceContextRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IConvexFaceContextRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IConvexFaceContextRepresentationInitialValues +): void; + +export function newInstance( + initialValues?: IConvexFaceContextRepresentationInitialValues +): vtkConvexFaceContextRepresentation; + +/** + * vtkConvexFaceContextRepresentation renders the convex polygon whose corners + * are the origins of the widget states it is given. + */ +export declare const vtkConvexFaceContextRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkConvexFaceContextRepresentation; diff --git a/Sources/Widgets/Representations/CroppingOutlineRepresentation/index.d.ts b/Sources/Widgets/Representations/CroppingOutlineRepresentation/index.d.ts new file mode 100644 index 00000000000..a400cf93d32 --- /dev/null +++ b/Sources/Widgets/Representations/CroppingOutlineRepresentation/index.d.ts @@ -0,0 +1,53 @@ +import { RGBColor } from '../../../types'; +import vtkActor from '../../../Rendering/Core/Actor'; +import vtkMapper from '../../../Rendering/Core/Mapper'; +import vtkContextRepresentation, { + IContextRepresentationInitialValues, +} from '../ContextRepresentation'; + +export interface ICroppingOutlineRepresentationInitialValues extends IContextRepresentationInitialValues { + edgeColor?: RGBColor; +} + +export interface vtkCroppingOutlineRepresentation extends vtkContextRepresentation { + /** + * Expects exactly 8 states carrying an origin; logs an error otherwise. + */ + requestData(inData: any[], outData: any[]): void; + + getEdgeColor(): RGBColor; + getEdgeColorByReference(): RGBColor; + setEdgeColor(edgeColor: RGBColor): boolean; + setEdgeColorFrom(edgeColor: RGBColor): void; + + getMapper(): vtkMapper; + getActor(): vtkActor; +} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkCroppingOutlineRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ICroppingOutlineRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ICroppingOutlineRepresentationInitialValues +): void; + +export function newInstance( + initialValues?: ICroppingOutlineRepresentationInitialValues +): vtkCroppingOutlineRepresentation; + +/** + * vtkCroppingOutlineRepresentation renders the 12 edges of a box given its 8 + * corners as widget state origins. It does not handle an arbitrary set of + * points. + */ +export declare const vtkCroppingOutlineRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkCroppingOutlineRepresentation; diff --git a/Sources/Widgets/Representations/CubeHandleRepresentation/index.d.ts b/Sources/Widgets/Representations/CubeHandleRepresentation/index.d.ts new file mode 100644 index 00000000000..e5357714fb1 --- /dev/null +++ b/Sources/Widgets/Representations/CubeHandleRepresentation/index.d.ts @@ -0,0 +1,34 @@ +import vtkGlyphRepresentation, { + IGlyphRepresentationInitialValues, +} from '../GlyphRepresentation'; + +export interface ICubeHandleRepresentationInitialValues extends IGlyphRepresentationInitialValues {} + +export interface vtkCubeHandleRepresentation extends vtkGlyphRepresentation {} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkCubeHandleRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ICubeHandleRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ICubeHandleRepresentationInitialValues +): void; + +export function newInstance( + initialValues?: ICubeHandleRepresentationInitialValues +): vtkCubeHandleRepresentation; + +/** + * vtkCubeHandleRepresentation is a vtkGlyphRepresentation using a + * vtkCubeSource as glyph. + */ +export declare const vtkCubeHandleRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkCubeHandleRepresentation; diff --git a/Sources/Widgets/Representations/GlyphRepresentation/index.d.ts b/Sources/Widgets/Representations/GlyphRepresentation/index.d.ts new file mode 100644 index 00000000000..4bffa3cd008 --- /dev/null +++ b/Sources/Widgets/Representations/GlyphRepresentation/index.d.ts @@ -0,0 +1,183 @@ +import vtkPolyData from '../../../Common/DataModel/PolyData'; +import { vtkAlgorithm } from '../../../interfaces'; +import vtkActor from '../../../Rendering/Core/Actor'; +import vtkGlyph3DMapper from '../../../Rendering/Core/Glyph3DMapper'; +import vtkWidgetState from '../../Core/WidgetState'; +import { IWidgetPipeline } from '../WidgetRepresentation'; +import vtkContextRepresentation, { + IContextRepresentationInitialValues, +} from '../ContextRepresentation'; +import vtkHandleRepresentation, { + IHandleRepresentationInitialValues, +} from '../HandleRepresentation'; + +/** + * Fills one glyph attribute of `polyData` from the given widget states. + */ +export type GlyphMixinFunction = ( + polyData: vtkPolyData, + states: vtkWidgetState[] +) => void; + +/** + * The mixin functions the representation can apply, keyed by the name used in + * `getMixins()`/`setXXX()`. Each one can be replaced through the matching + * `set()` accessor. + */ +export interface IGlyphMixins { + origin: GlyphMixinFunction; + noPosition: GlyphMixinFunction; + color3: GlyphMixinFunction; + color: GlyphMixinFunction; + noColor: GlyphMixinFunction; + scale3: GlyphMixinFunction; + scale1: GlyphMixinFunction; + noScale: GlyphMixinFunction; + direction: GlyphMixinFunction; + noOrientation: GlyphMixinFunction; +} + +/** + * The mixin function selected for each glyph attribute, as returned by + * `getMixins()`. + */ +export interface IGlyphProperties { + position: GlyphMixinFunction; + color: GlyphMixinFunction; + scale: GlyphMixinFunction; + orientation: GlyphMixinFunction; +} + +export interface IGlyphRepresentationInitialValues + extends + IHandleRepresentationInitialValues, + IContextRepresentationInitialValues { + defaultScale?: number; + /** + * Applied on the actor property at `extend()` time only. + */ + lighting?: boolean; + _pipeline?: Partial; + applyMixin?: Partial; +} + +export interface vtkGlyphRepresentation + extends vtkHandleRepresentation, vtkContextRepresentation { + /** + * Pick, for each glyph attribute, the mixin function matching the mixins + * carried by the given states. + */ + getMixins(states: vtkWidgetState[]): IGlyphProperties; + + requestData(inData: any[], outData: any[]): void; + + /** + * Scale applied to the glyphs of the states that do not provide a scale + * mixin. + */ + getDefaultScale(): number | undefined; + setDefaultScale(defaultScale: number): boolean; + + /** The source producing the glyph geometry (a vtkSphereSource by default). */ + getGlyph(): vtkAlgorithm; + getMapper(): vtkGlyph3DMapper; + getActor(): vtkActor; + + getOrigin(): GlyphMixinFunction; + setOrigin(origin: GlyphMixinFunction): boolean; + + getNoPosition(): GlyphMixinFunction; + setNoPosition(noPosition: GlyphMixinFunction): boolean; + + getColor3(): GlyphMixinFunction; + setColor3(color3: GlyphMixinFunction): boolean; + + getColor(): GlyphMixinFunction; + setColor(color: GlyphMixinFunction): boolean; + + getNoColor(): GlyphMixinFunction; + setNoColor(noColor: GlyphMixinFunction): boolean; + + getScale3(): GlyphMixinFunction; + setScale3(scale3: GlyphMixinFunction): boolean; + + getScale1(): GlyphMixinFunction; + setScale1(scale1: GlyphMixinFunction): boolean; + + getNoScale(): GlyphMixinFunction; + setNoScale(noScale: GlyphMixinFunction): boolean; + + getDirection(): GlyphMixinFunction; + setDirection(direction: GlyphMixinFunction): boolean; + + getNoOrientation(): GlyphMixinFunction; + setNoOrientation(noOrientation: GlyphMixinFunction): boolean; +} + +/** Writes the states origins into the polydata points. */ +export function origin(publicAPI: object, model: object): GlyphMixinFunction; + +/** Empties the polydata points, hiding every glyph. */ +export function noPosition( + publicAPI: object, + model: object +): GlyphMixinFunction; + +/** Writes the states RGB color and opacity into a 4-component `color` array. */ +export function color3(publicAPI: object, model: object): GlyphMixinFunction; + +/** Writes the states scalar color into a 1-component `color` array. */ +export function color(publicAPI: object, model: object): GlyphMixinFunction; + +/** Disables coloring by array on the mapper. */ +export function noColor(publicAPI: object, model: object): GlyphMixinFunction; + +/** Writes a per-component scale into a 3-component `scale` array. */ +export function scale3(publicAPI: object, model: object): GlyphMixinFunction; + +/** Writes a uniform scale into a 1-component `scale` array. */ +export function scale1(publicAPI: object, model: object): GlyphMixinFunction; + +/** Applies `defaultScale` on the mapper instead of a scale array. */ +export function noScale(publicAPI: object, model: object): GlyphMixinFunction; + +/** Writes the states right/up/direction vectors into a 9-component matrix array. */ +export function direction(publicAPI: object, model: object): GlyphMixinFunction; + +/** Disables orientation by array on the mapper. */ +export function noOrientation( + publicAPI: object, + model: object +): GlyphMixinFunction; + +/** + * Method use to decorate a given object (publicAPI+model) with vtkGlyphRepresentation characteristics. + * + * Delegates to vtkContextRepresentation when `initialValues.behavior` is + * `Behavior.CONTEXT`, and to vtkHandleRepresentation otherwise. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IGlyphRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IGlyphRepresentationInitialValues +): void; + +export function newInstance( + initialValues?: IGlyphRepresentationInitialValues +): vtkGlyphRepresentation; + +/** + * vtkGlyphRepresentation renders one glyph per widget state through a + * vtkGlyph3DMapper. The position, color, scale and orientation of the glyphs + * are filled by mixin functions selected from the mixins the states actually + * carry. + */ +export declare const vtkGlyphRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkGlyphRepresentation; diff --git a/Sources/Widgets/Representations/HandleRepresentation/index.d.ts b/Sources/Widgets/Representations/HandleRepresentation/index.d.ts new file mode 100644 index 00000000000..9e5c0984f5d --- /dev/null +++ b/Sources/Widgets/Representations/HandleRepresentation/index.d.ts @@ -0,0 +1,36 @@ +import vtkWidgetRepresentation, { + IWidgetRepresentationInitialValues, +} from '../WidgetRepresentation'; +import { Behavior } from '../WidgetRepresentation/Constants'; + +export interface IHandleRepresentationInitialValues extends IWidgetRepresentationInitialValues { + behavior?: Behavior; + pickable?: boolean; + dragable?: boolean; +} + +export interface vtkHandleRepresentation extends vtkWidgetRepresentation {} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkHandleRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IHandleRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IHandleRepresentationInitialValues +): void; + +/** + * vtkHandleRepresentation is the base class for widget representations that + * render the interactive handles of a widget. It only defaults the + * representation to the `HANDLE` behavior, makes it pickable and dragable and + * enables display-space scaling. + */ +export declare const vtkHandleRepresentation: { + extend: typeof extend; +}; +export default vtkHandleRepresentation; diff --git a/Sources/Widgets/Representations/ImplicitPlaneRepresentation/index.d.ts b/Sources/Widgets/Representations/ImplicitPlaneRepresentation/index.d.ts new file mode 100644 index 00000000000..aa761c0eb6d --- /dev/null +++ b/Sources/Widgets/Representations/ImplicitPlaneRepresentation/index.d.ts @@ -0,0 +1,96 @@ +import vtkWidgetState from '../../Core/WidgetState'; +import vtkWidgetRepresentation, { + IWidgetRepresentationInitialValues, + IWidgetStyles, +} from '../WidgetRepresentation'; + +export interface IImplicitPlaneRepresentationInitialValues extends IWidgetRepresentationInitialValues { + /** Phi and theta resolution of the origin handle sphere. */ + sphereResolution?: number; + /** Handle size relative to the smallest dimension of the plane bounds. */ + handleSizeRatio?: number; + /** Radius factor applied on the normal cylinder. */ + axisScale?: number; + normalVisible?: boolean; + originVisible?: boolean; + planeVisible?: boolean; + outlineVisible?: boolean; +} + +export interface vtkImplicitPlaneRepresentation extends vtkWidgetRepresentation { + /** + * Cuts the outline cube with the state's plane and updates the outline, + * plane, origin and normal pipelines. + */ + requestData(inData: any[], outData: any[]): void; + + getSphereResolution(): number; + /** + * Forwards the resolution to the phi and theta resolutions of the origin + * handle sphere. + */ + setSphereResolution(sphereResolution: number): boolean; + + getRepresentationStyle(): IWidgetStyles; + /** + * Merges the given styles into the current ones and applies them. + */ + setRepresentationStyle(style: Partial): void; + + getHandleSizeRatio(): number; + setHandleSizeRatio(handleSizeRatio: number): boolean; + + getAxisScale(): number; + setAxisScale(axisScale: number): boolean; + + getNormalVisible(): boolean; + setNormalVisible(normalVisible: boolean): boolean; + + getOriginVisible(): boolean; + setOriginVisible(originVisible: boolean): boolean; + + getPlaneVisible(): boolean; + setPlaneVisible(planeVisible: boolean): boolean; + + getOutlineVisible(): boolean; + setOutlineVisible(outlineVisible: boolean): boolean; +} + +/** + * Builds the widget state expected by this representation: an `origin`, a + * `normal`, an `activeHandle` and an `updateMethodName` field. + * + * The module carries it on its default object only; there is no named runtime + * export to declare. + */ +declare function generateState(): vtkWidgetState; + +/** + * Method use to decorate a given object (publicAPI+model) with vtkImplicitPlaneRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IImplicitPlaneRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IImplicitPlaneRepresentationInitialValues +): void; + +export function newInstance( + initialValues?: IImplicitPlaneRepresentationInitialValues +): vtkImplicitPlaneRepresentation; + +/** + * vtkImplicitPlaneRepresentation renders an implicit plane as the intersection + * of the plane with the outline of its bounds, together with an origin handle, + * a normal handle and the bounds outline. The handle picked by the user is + * reported on the state through `activeHandle` and `updateMethodName`. + */ +export declare const vtkImplicitPlaneRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; + generateState: typeof generateState; +}; +export default vtkImplicitPlaneRepresentation; diff --git a/Sources/Widgets/Representations/LineHandleRepresentation/index.d.ts b/Sources/Widgets/Representations/LineHandleRepresentation/index.d.ts new file mode 100644 index 00000000000..af003b7011f --- /dev/null +++ b/Sources/Widgets/Representations/LineHandleRepresentation/index.d.ts @@ -0,0 +1,71 @@ +import { Nullable, Vector3 } from '../../../types'; +import vtkGlyphRepresentation, { + IGlyphRepresentationInitialValues, +} from '../GlyphRepresentation'; + +export interface ILineHandleRepresentationInitialValues extends IGlyphRepresentationInitialValues { + infiniteLine?: boolean; + glyphResolution?: number; + /** + * Initial angle of the cylinder glyph, in radians. Only read when building + * the glyph. + * @default Math.PI / 4 + */ + glyphAngle?: number; + holeWidth?: number; +} + +export interface vtkLineHandleRepresentation extends vtkGlyphRepresentation { + /** When true, the lines are scaled up so that they look infinite. */ + getInfiniteLine(): boolean; + setInfiniteLine(infiniteLine: boolean): boolean; + + /** Number of sides of the cylinder used as glyph. */ + getGlyphResolution(): number; + /** + * Sets the resolution on the model and on the cylinder glyph. Returns the + * result of each chained setter. + */ + setGlyphResolution(glyphResolution: number): boolean[]; + + /** + * Width of the gap left at the origin of each line. The line is split in two + * halves pushed away from the origin by half this width. When + * `scaleInPixels` is on, the width is expressed in pixels. + */ + getHoleWidth(): number; + setHoleWidth(holeWidth: number): boolean; + + /** + * Set a callback called with the display coordinates of the active states, + * or with no argument when no state is active. + */ + setDisplayCallback(callback: Nullable<(coords?: Vector3[]) => void>): void; +} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkLineHandleRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ILineHandleRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ILineHandleRepresentationInitialValues +): void; + +export function newInstance( + initialValues?: ILineHandleRepresentationInitialValues +): vtkLineHandleRepresentation; + +/** + * vtkLineHandleRepresentation renders a cylinder per state, optionally + * infinite and optionally split in two halves separated by `holeWidth`. + */ +export declare const vtkLineHandleRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkLineHandleRepresentation; diff --git a/Sources/Widgets/Representations/OutlineContextRepresentation/index.d.ts b/Sources/Widgets/Representations/OutlineContextRepresentation/index.d.ts new file mode 100644 index 00000000000..e3fc9101147 --- /dev/null +++ b/Sources/Widgets/Representations/OutlineContextRepresentation/index.d.ts @@ -0,0 +1,52 @@ +import { RGBColor } from '../../../types'; +import vtkActor from '../../../Rendering/Core/Actor'; +import vtkMapper from '../../../Rendering/Core/Mapper'; +import vtkContextRepresentation, { + IContextRepresentationInitialValues, +} from '../ContextRepresentation'; + +export interface IOutlineContextRepresentationInitialValues extends IContextRepresentationInitialValues { + edgeColor?: RGBColor; +} + +export interface vtkOutlineContextRepresentation extends vtkContextRepresentation { + /** + * Renders the outline of the bounding box of every state origin. + */ + requestData(inData: any[], outData: any[]): void; + + getEdgeColor(): RGBColor; + getEdgeColorByReference(): RGBColor; + setEdgeColor(edgeColor: RGBColor): boolean; + setEdgeColorFrom(edgeColor: RGBColor): void; + + getMapper(): vtkMapper; + getActor(): vtkActor; +} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkOutlineContextRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IOutlineContextRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IOutlineContextRepresentationInitialValues +): void; + +export function newInstance( + initialValues?: IOutlineContextRepresentationInitialValues +): vtkOutlineContextRepresentation; + +/** + * vtkOutlineContextRepresentation renders the axis-aligned box outline of the + * bounding box of the origins of the widget states it is given. + */ +export declare const vtkOutlineContextRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkOutlineContextRepresentation; diff --git a/Sources/Widgets/Representations/PolyLineRepresentation/index.d.ts b/Sources/Widgets/Representations/PolyLineRepresentation/index.d.ts new file mode 100644 index 00000000000..715afcbb8ec --- /dev/null +++ b/Sources/Widgets/Representations/PolyLineRepresentation/index.d.ts @@ -0,0 +1,60 @@ +import vtkWidgetRepresentation, { + IWidgetRepresentationInitialValues, +} from '../WidgetRepresentation'; + +export interface IPolyLineRepresentationInitialValues extends IWidgetRepresentationInitialValues { + threshold?: number; + /** Adds a segment between the last and the first point. */ + closePolyLine?: boolean; + /** + * Radius of the tube generated along the line. Overridden by the input + * state's `lineThickness` when it provides one. + */ + lineThickness?: number; +} + +export interface vtkPolyLineRepresentation extends vtkWidgetRepresentation { + /** + * Builds the poly line from the origins of the input states, dropping + * invalid and coincident points, then updates the tube radius. + */ + requestData(inData: any[], outData: any[]): void; + + getThreshold(): number; + setThreshold(threshold: number): boolean; + + getClosePolyLine(): boolean; + setClosePolyLine(closePolyLine: boolean): boolean; + + getLineThickness(): number; + setLineThickness(lineThickness: number): boolean; +} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkPolyLineRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IPolyLineRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IPolyLineRepresentationInitialValues +): void; + +export function newInstance( + initialValues?: IPolyLineRepresentationInitialValues +): vtkPolyLineRepresentation; + +/** + * vtkPolyLineRepresentation renders the poly line going through the origins of + * the widget states as a tube. When `scaleInPixels` is on, the tube radius is + * scaled to keep a constant size in display coordinates, and it is enlarged + * while rendering the picking buffer. + */ +export declare const vtkPolyLineRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkPolyLineRepresentation; diff --git a/Sources/Widgets/Representations/RectangleContextRepresentation/index.d.ts b/Sources/Widgets/Representations/RectangleContextRepresentation/index.d.ts new file mode 100644 index 00000000000..f054fbad354 --- /dev/null +++ b/Sources/Widgets/Representations/RectangleContextRepresentation/index.d.ts @@ -0,0 +1,62 @@ +import vtkActor from '../../../Rendering/Core/Actor'; +import vtkMapper from '../../../Rendering/Core/Mapper'; +import vtkContextRepresentation, { + IContextRepresentationInitialValues, +} from '../ContextRepresentation'; + +export interface IRectangleContextRepresentationInitialValues extends IContextRepresentationInitialValues { + drawBorder?: boolean; + drawFace?: boolean; +} + +export interface vtkRectangleContextRepresentation extends vtkContextRepresentation { + /** + * Builds the rectangle from the origin, corner and up vector of the first + * state. Only the first state is used. + */ + requestData(inData: any[], outData: any[]): void; + + getColor(): [number] | undefined; + getColorByReference(): [number] | undefined; + setColor(color: [number] | number): boolean; + setColorFrom(color: [number]): void; + + getDrawBorder(): boolean; + setDrawBorder(drawBorder: boolean): boolean; + + getDrawFace(): boolean; + setDrawFace(drawFace: boolean): boolean; + + getMapper(): vtkMapper; + getActor(): vtkActor; + + /** Forwards the opacity to the actor property. */ + setOpacity(opacity: number): void; +} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkRectangleContextRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IRectangleContextRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IRectangleContextRepresentationInitialValues +): void; + +export function newInstance( + initialValues?: IRectangleContextRepresentationInitialValues +): vtkRectangleContextRepresentation; + +/** + * vtkRectangleContextRepresentation renders the rectangle spanned by the + * origin and the corner of a widget state, as a filled face and/or a border. + */ +export declare const vtkRectangleContextRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkRectangleContextRepresentation; diff --git a/Sources/Widgets/Representations/RotateTransformHandleRepresentation/index.d.ts b/Sources/Widgets/Representations/RotateTransformHandleRepresentation/index.d.ts new file mode 100644 index 00000000000..b3f35ee72b1 --- /dev/null +++ b/Sources/Widgets/Representations/RotateTransformHandleRepresentation/index.d.ts @@ -0,0 +1,34 @@ +import vtkGlyphRepresentation, { + IGlyphRepresentationInitialValues, +} from '../GlyphRepresentation'; + +export interface IRotateTransformHandleRepresentationInitialValues extends IGlyphRepresentationInitialValues {} + +export interface vtkRotateTransformHandleRepresentation extends vtkGlyphRepresentation {} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkRotateTransformHandleRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IRotateTransformHandleRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IRotateTransformHandleRepresentationInitialValues +): void; + +export function newInstance( + initialValues?: IRotateTransformHandleRepresentationInitialValues +): vtkRotateTransformHandleRepresentation; + +/** + * vtkRotateTransformHandleRepresentation is a vtkGlyphRepresentation using a + * vtkTorusSource as glyph. + */ +export declare const vtkRotateTransformHandleRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkRotateTransformHandleRepresentation; diff --git a/Sources/Widgets/Representations/ScaleTransformHandleRepresentation/index.d.ts b/Sources/Widgets/Representations/ScaleTransformHandleRepresentation/index.d.ts new file mode 100644 index 00000000000..0ff70799920 --- /dev/null +++ b/Sources/Widgets/Representations/ScaleTransformHandleRepresentation/index.d.ts @@ -0,0 +1,55 @@ +import { ICubeSourceInitialValues } from '../../../Filters/Sources/CubeSource'; +import vtkGlyphRepresentation, { + IGlyphRepresentationInitialValues, +} from '../GlyphRepresentation'; + +export interface IScaleTransformHandleRepresentationInitialValues extends IGlyphRepresentationInitialValues { + /** + * Height of the cylinder joining the two cubes. + * @default 1 + */ + height?: number; + /** + * Radius of the cylinder joining the two cubes. + * @default 1 + */ + radius?: number; + /** + * Number of sides of the cylinder joining the two cubes. + * @default 12 + */ + glyphResolution?: number; + /** + * Initial values of the two vtkCubeSource capping the glyph. + */ + cubeSource?: ICubeSourceInitialValues; +} + +export interface vtkScaleTransformHandleRepresentation extends vtkGlyphRepresentation {} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkScaleTransformHandleRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IScaleTransformHandleRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IScaleTransformHandleRepresentationInitialValues +): void; + +export function newInstance( + initialValues?: IScaleTransformHandleRepresentationInitialValues +): vtkScaleTransformHandleRepresentation; + +/** + * vtkScaleTransformHandleRepresentation is a vtkGlyphRepresentation whose + * glyph is a cylinder capped at both ends by a cube. + */ +export declare const vtkScaleTransformHandleRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkScaleTransformHandleRepresentation; diff --git a/Sources/Widgets/Representations/SphereContextRepresentation/index.d.ts b/Sources/Widgets/Representations/SphereContextRepresentation/index.d.ts new file mode 100644 index 00000000000..2720ed1aede --- /dev/null +++ b/Sources/Widgets/Representations/SphereContextRepresentation/index.d.ts @@ -0,0 +1,54 @@ +import vtkGlyphRepresentation, { + IGlyphRepresentationInitialValues, +} from '../GlyphRepresentation'; + +export interface ISphereContextRepresentationInitialValues extends IGlyphRepresentationInitialValues { + glyphResolution?: number; + drawBorder?: boolean; + drawFace?: boolean; +} + +export interface vtkSphereContextRepresentation extends vtkGlyphRepresentation { + /** Phi and theta resolution of the sphere glyph. */ + getGlyphResolution(): number; + /** + * Sets the resolution on the model and on the sphere glyph. Returns the + * result of each chained setter. + */ + setGlyphResolution(glyphResolution: number): boolean[]; + + /** Whether the wireframe of the sphere is rendered. */ + setDrawBorder(drawBorder: boolean): void; + + /** Whether the faces of the sphere are rendered. */ + setDrawFace(drawFace: boolean): void; + + /** Sets the opacity of the actor property. */ + setOpacity(opacity: number): void; +} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkSphereContextRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ISphereContextRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ISphereContextRepresentationInitialValues +): void; + +export function newInstance( + initialValues?: ISphereContextRepresentationInitialValues +): vtkSphereContextRepresentation; + +/** + * vtkSphereContextRepresentation renders a semi transparent sphere per state. + */ +export declare const vtkSphereContextRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkSphereContextRepresentation; diff --git a/Sources/Widgets/Representations/SphereHandleRepresentation/index.d.ts b/Sources/Widgets/Representations/SphereHandleRepresentation/index.d.ts new file mode 100644 index 00000000000..47f41c8af30 --- /dev/null +++ b/Sources/Widgets/Representations/SphereHandleRepresentation/index.d.ts @@ -0,0 +1,47 @@ +import { Nullable, Vector3 } from '../../../types'; +import vtkGlyphRepresentation, { + IGlyphRepresentationInitialValues, +} from '../GlyphRepresentation'; + +export interface ISphereHandleRepresentationInitialValues extends IGlyphRepresentationInitialValues {} + +export interface vtkSphereHandleRepresentation extends vtkGlyphRepresentation { + /** Phi resolution of the sphere glyph. */ + getGlyphResolution(): number; + /** Sets both the phi and theta resolution of the sphere glyph. */ + setGlyphResolution(glyphResolution: number): boolean; + + /** + * Set a callback called with the display coordinates of the active states, + * or with no argument when no state is active. + */ + setDisplayCallback(callback: Nullable<(coords?: Vector3[]) => void>): void; +} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkSphereHandleRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ISphereHandleRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ISphereHandleRepresentationInitialValues +): void; + +export function newInstance( + initialValues?: ISphereHandleRepresentationInitialValues +): vtkSphereHandleRepresentation; + +/** + * vtkSphereHandleRepresentation renders the default sphere glyph of + * vtkGlyphRepresentation per handle state, and can report the display + * coordinates of the active handles through a callback. + */ +export declare const vtkSphereHandleRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkSphereHandleRepresentation; diff --git a/Sources/Widgets/Representations/SplineContextRepresentation/index.d.ts b/Sources/Widgets/Representations/SplineContextRepresentation/index.d.ts new file mode 100644 index 00000000000..afe193e0c12 --- /dev/null +++ b/Sources/Widgets/Representations/SplineContextRepresentation/index.d.ts @@ -0,0 +1,82 @@ +import { Nullable, RGBColor } from '../../../types'; +import { BoundaryCondition } from '../../../Common/DataModel/Spline1D/Constants'; +import vtkMapper from '../../../Rendering/Core/Mapper'; +import vtkWidgetState from '../../Core/WidgetState'; +import vtkContextRepresentation, { + IContextRepresentationInitialValues, +} from '../ContextRepresentation'; + +export interface ISplineContextRepresentationInitialValues extends IContextRepresentationInitialValues { + /** Number of segments generated between two consecutive control points. */ + resolution?: number; + fill?: boolean; + outputBorder?: boolean; + borderColor?: RGBColor; + /** Border color used when the triangulation of the area failed. */ + errorBorderColor?: RGBColor; +} + +export interface vtkSplineContextRepresentation extends vtkContextRepresentation { + /** + * Samples the spline defined by the origins of the input states, using the + * spline parameters carried by the input widget state. + */ + requestData(inData: any[], outData: any[]): void; + + /** Only the visible states carrying an origin are kept. */ + getRepresentationStates(input?: vtkWidgetState): vtkWidgetState[]; + + /** No mapper is stored on the model: each internal pipeline owns its own. */ + getMapper(): Nullable | undefined; + + getResolution(): number; + setResolution(resolution: number): boolean; + + getBoundaryCondition(): BoundaryCondition | undefined; + setBoundaryCondition(boundaryCondition: BoundaryCondition): boolean; + + /** Whether the area enclosed by the spline is triangulated and rendered. */ + getFill(): boolean; + setFill(fill: boolean): boolean; + + /** Whether the spline itself is rendered as a line. */ + getOutputBorder(): boolean; + setOutputBorder(outputBorder: boolean): boolean; + + getBorderColor(): RGBColor; + getBorderColorByReference(): RGBColor; + setBorderColor(borderColor: RGBColor): boolean; + setBorderColorFrom(borderColor: RGBColor): void; + + getErrorBorderColor(): RGBColor; + getErrorBorderColorByReference(): RGBColor; + setErrorBorderColor(errorBorderColor: RGBColor): boolean; + setErrorBorderColorFrom(errorBorderColor: RGBColor): void; +} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkSplineContextRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ISplineContextRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ISplineContextRepresentationInitialValues +): void; + +export function newInstance( + initialValues?: ISplineContextRepresentationInitialValues +): vtkSplineContextRepresentation; + +/** + * vtkSplineContextRepresentation renders the spline going through the origins + * of the widget states, as a filled area and/or as a border line. + */ +export declare const vtkSplineContextRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkSplineContextRepresentation; diff --git a/Sources/Widgets/Representations/TranslateTransformHandleRepresentation/index.d.ts b/Sources/Widgets/Representations/TranslateTransformHandleRepresentation/index.d.ts new file mode 100644 index 00000000000..bd2289940ea --- /dev/null +++ b/Sources/Widgets/Representations/TranslateTransformHandleRepresentation/index.d.ts @@ -0,0 +1,55 @@ +import { IConeSourceInitialValues } from '../../../Filters/Sources/ConeSource'; +import vtkGlyphRepresentation, { + IGlyphRepresentationInitialValues, +} from '../GlyphRepresentation'; + +export interface ITranslateTransformHandleRepresentationInitialValues extends IGlyphRepresentationInitialValues { + /** + * Height of the cylinder joining the two cones. + * @default 1 + */ + height?: number; + /** + * Radius of the cylinder joining the two cones. + * @default 1 + */ + radius?: number; + /** + * Number of sides of the cylinder joining the two cones. + * @default 12 + */ + glyphResolution?: number; + /** + * Initial values of the two vtkConeSource capping the glyph. + */ + coneSource?: IConeSourceInitialValues; +} + +export interface vtkTranslateTransformHandleRepresentation extends vtkGlyphRepresentation {} + +/** + * Method use to decorate a given object (publicAPI+model) with vtkTranslateTransformHandleRepresentation characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {ITranslateTransformHandleRepresentationInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: ITranslateTransformHandleRepresentationInitialValues +): void; + +export function newInstance( + initialValues?: ITranslateTransformHandleRepresentationInitialValues +): vtkTranslateTransformHandleRepresentation; + +/** + * vtkTranslateTransformHandleRepresentation is a vtkGlyphRepresentation whose + * glyph is a double headed arrow: a cylinder capped at both ends by a cone. + */ +export declare const vtkTranslateTransformHandleRepresentation: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkTranslateTransformHandleRepresentation; diff --git a/Sources/Widgets/Representations/WidgetRepresentation/Constants.d.ts b/Sources/Widgets/Representations/WidgetRepresentation/Constants.d.ts new file mode 100644 index 00000000000..9bb204903a1 --- /dev/null +++ b/Sources/Widgets/Representations/WidgetRepresentation/Constants.d.ts @@ -0,0 +1,12 @@ +export declare const Behavior: { + readonly HANDLE: 0; + readonly CONTEXT: 1; +}; + +export type Behavior = (typeof Behavior)[keyof typeof Behavior]; + +declare const _default: { + Behavior: typeof Behavior; +}; + +export default _default; diff --git a/Sources/Widgets/Representations/WidgetRepresentation/index.d.ts b/Sources/Widgets/Representations/WidgetRepresentation/index.d.ts index 214c8e7dac5..df7cb68f2b0 100644 --- a/Sources/Widgets/Representations/WidgetRepresentation/index.d.ts +++ b/Sources/Widgets/Representations/WidgetRepresentation/index.d.ts @@ -1,20 +1,42 @@ import vtkDataArray from '../../../Common/Core/DataArray'; import vtkPolyData from '../../../Common/DataModel/PolyData'; -import { vtkObject } from '../../../interfaces'; -import vtkProp from '../../../Rendering/Core/Prop'; +import { vtkAlgorithm, vtkObject } from '../../../interfaces'; +import vtkProp, { IPropInitialValues } from '../../../Rendering/Core/Prop'; +import vtkActor from '../../../Rendering/Core/Actor'; import { IDisplayScaleParams } from '../../../Widgets/Core/WidgetManager'; +import { RenderingTypes } from '../../../Widgets/Core/WidgetManager/Constants'; +import vtkWidgetState from '../../../Widgets/Core/WidgetState'; +import { Behavior } from './Constants'; -export interface IWidgetRepresentationInitialValues { +export interface IWidgetRepresentationInitialValues extends IPropInitialValues { labels?: Array; coincidentTopologyParameters?: object; displayScaleParams?: IDisplayScaleParams; scaleInPixels?: boolean; + behavior?: Behavior; + actors?: Array; + activeScaleFactor?: number; + activeColor?: number; + useActiveColor?: boolean; } -export interface vtkWidgetRepresentation extends vtkProp { +export interface vtkWidgetRepresentation extends vtkProp, vtkAlgorithm { + /** Add an actor and apply the representation's mapper settings. */ + addActor(actor: vtkActor): void; + + /** Update actor visibility for the current rendering pass. */ + updateActorVisibility( + renderingType?: RenderingTypes, + ctxVisible?: boolean, + handleVisible?: boolean + ): void; + getLabels(): Array; setLabels(labels: Array): void; + getRepresentationStates(input?: vtkWidgetState): vtkWidgetState[]; + getSelectedState(prop: vtkProp, compositeID: number): vtkWidgetState | null; + /** * Gets the coincident topology parameters applied on the actor mappers */ @@ -31,6 +53,26 @@ export interface vtkWidgetRepresentation extends vtkProp { */ setDisplayScaleParams(params: object): boolean; + /** + * Gets the current view and camera scale parameters. + */ + getDisplayScaleParams(): IDisplayScaleParams; + + /** + * Gets the scale applied to the representation while it is active. + */ + getActiveScaleFactor(): number; + setActiveScaleFactor(activeScaleFactor: number): boolean; + + /** + * Gets the scalar value the mapper turns into the active color. + */ + getActiveColor(): number; + setActiveColor(activeColor: number): boolean; + + getUseActiveColor(): boolean; + setUseActiveColor(useActiveColor: boolean): boolean; + /** * Gets wether actors should have a fix size in display coordinates. * @see setScaleInPixels() @@ -57,24 +99,6 @@ export function extend( initialValues?: IWidgetRepresentationInitialValues ): void; -/** - * Method use to create a new instance of vtkWidgetRepresentation - * @param {IWidgetRepresentationInitialValues} [initialValues] for pre-setting some of its content - */ -export function newInstance( - initialValues?: IWidgetRepresentationInitialValues -): vtkWidgetRepresentation; - -/** - * Static function to get the pixel size of a 3D point. - * @param {Number[]} worldCoord 3D point in world coordinates - * @param {IDisplayScaleParams} displayScaleParams Display and camera information - */ -export function getPixelWorldHeightAtCoord( - worldCoord: number[], - displayScaleParams: IDisplayScaleParams -): number[]; - export interface IWidgetPipeline { source?: object; filter?: object; @@ -82,6 +106,35 @@ export interface IWidgetPipeline { mapper: object; actor: object; } + +export interface IWidgetStyles { + active: any; + inactive: any; + static: any; +} + +/** + * Merge the given styles together for the given element names. + * @param {string[]} elementNames The names of the elements to merge styles for. + * @param {...any} stylesToMerge The styles to merge. + */ +export function mergeStyles( + elementNames: string[], + ...stylesToMerge: any[] +): IWidgetStyles; + +/** + * Apply the given styles to the given pipelines. + * @param {Record} pipelines The pipelines to apply styles to. + * @param {IWidgetStyles} styles The styles to apply. + * @param {any} [activeActor] The currently active actor. + */ +export function applyStyles( + pipelines: Record, + styles: IWidgetStyles, + activeActor?: any +): void; + /** * If provided, connects `source` (dataset or filter) to `filter`. * If provided, connects `filter` (otherwise `source`) to mapper @@ -112,7 +165,9 @@ export function allocateArray( ): vtkDataArray | null; export declare const vtkWidgetRepresentation: { - newInstance: typeof newInstance; extend: typeof extend; + mergeStyles: typeof mergeStyles; + applyStyles: typeof applyStyles; + connectPipeline: typeof connectPipeline; }; export default vtkWidgetRepresentation; diff --git a/Sources/Widgets/Widgets3D/AngleWidget/index.d.ts b/Sources/Widgets/Widgets3D/AngleWidget/index.d.ts new file mode 100644 index 00000000000..007c788d314 --- /dev/null +++ b/Sources/Widgets/Widgets3D/AngleWidget/index.d.ts @@ -0,0 +1,86 @@ +import vtkAbstractWidget from '../../Core/AbstractWidget'; +import vtkAbstractManipulator from '../../Manipulators/AbstractManipulator'; +import { + IAbstractWidgetFactoryInitialValues, + vtkAbstractWidgetFactory, +} from '../../Core/AbstractWidgetFactory'; +import { ViewTypes } from '../../Core/WidgetManager/Constants'; +import { vtkWidgetState } from '../../Core/WidgetState'; +import { vtkBoundsMixinState } from '../../Core/StateBuilder/boundsMixin'; +import { vtkColorMixinState } from '../../Core/StateBuilder/colorMixin'; +import { vtkManipulatorMixinState } from '../../Core/StateBuilder/manipulatorMixin'; +import { vtkOriginMixinState } from '../../Core/StateBuilder/originMixin'; +import { vtkScale1MixinState } from '../../Core/StateBuilder/scale1Mixin'; +import { vtkVisibleMixinState } from '../../Core/StateBuilder/visibleMixin'; + +export type IAngleWidgetHandleState = vtkOriginMixinState & + vtkColorMixinState & + vtkScale1MixinState & + vtkVisibleMixinState & + vtkManipulatorMixinState; + +// The internal state of the widget. +export interface vtkAngleWidgetState + extends vtkWidgetState, vtkBoundsMixinState { + // The handle used only during initial placement. + getMoveHandle(): IAngleWidgetHandleState; + + // The three placed handles, in placement order. + getHandleList(): IAngleWidgetHandleState[]; + addHandle(initialValues?: object): IAngleWidgetHandleState; + removeHandle(handleOrIndex: IAngleWidgetHandleState | number): void; + clearHandleList(): void; +} + +// The type of object returned by vtkWidgetManager.addWidget(). +export interface vtkAngleWidgetHandle extends vtkAbstractWidget { + setDisplayCallback(callback: (coords: any) => void): void; +} + +export interface vtkAngleWidget extends vtkAbstractWidgetFactory { + getWidgetState(): vtkAngleWidgetState; + + /** + * The representation builders the widget uses in the given view type. + */ + getRepresentationsForViewType(viewType: ViewTypes): unknown; + + /** + * The manipulator the handles are driven by. + */ + getManipulator(): vtkAbstractManipulator | undefined; + + /** + * Set the manipulator on the widget and on each of its handles. + */ + setManipulator(manipulator: vtkAbstractManipulator): boolean; + + /** + * The angle formed by the three placed handles, in radians. Returns 0 until + * the three handles are placed. + */ + getAngle(): number; +} + +export interface IAngleWidgetInitialValues extends IAbstractWidgetFactoryInitialValues { + manipulator?: vtkAbstractManipulator; +} + +export function extend( + publicAPI: object, + model: object, + initialValues?: IAngleWidgetInitialValues +): void; + +export function newInstance(props?: IAngleWidgetInitialValues): vtkAngleWidget; + +/** + * vtkAngleWidget places three handles and measures the angle they form at the + * second one. + */ +export declare const vtkAngleWidget: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkAngleWidget; diff --git a/Sources/Widgets/Widgets3D/EllipseWidget/index.d.ts b/Sources/Widgets/Widgets3D/EllipseWidget/index.d.ts new file mode 100644 index 00000000000..787c3e2f3fd --- /dev/null +++ b/Sources/Widgets/Widgets3D/EllipseWidget/index.d.ts @@ -0,0 +1,109 @@ +import { ViewTypes } from '../../Core/WidgetManager/Constants'; +import { TextPosition } from '../ShapeWidget/Constants'; +import { + IShapeWidgetInitialValues, + vtkShapeWidget, + vtkShapeWidgetHandle, +} from '../ShapeWidget'; +import { vtkWidgetState } from '../../Core/WidgetState'; +import { vtkBoundsMixinState } from '../../Core/StateBuilder/boundsMixin'; +import { vtkColorMixinState } from '../../Core/StateBuilder/colorMixin'; +import { vtkManipulatorMixinState } from '../../Core/StateBuilder/manipulatorMixin'; +import { vtkOrientationMixinState } from '../../Core/StateBuilder/orientationMixin'; +import { vtkOriginMixinState } from '../../Core/StateBuilder/originMixin'; +import { vtkScale1MixinState } from '../../Core/StateBuilder/scale1Mixin'; +import { vtkScale3MixinState } from '../../Core/StateBuilder/scale3Mixin'; +import { vtkTextMixinState } from '../../Core/StateBuilder/textMixin'; +import { vtkVisibleMixinState } from '../../Core/StateBuilder/visibleMixin'; + +// One of the two corner handles. +export type IEllipseWidgetPointHandleState = vtkOriginMixinState & + vtkColorMixinState & + vtkScale1MixinState & + vtkVisibleMixinState & + vtkManipulatorMixinState; + +// The handle used for displaying the ellipse. +export type IEllipseWidgetShapeHandleState = vtkOriginMixinState & + vtkColorMixinState & + vtkScale3MixinState & + vtkVisibleMixinState & + vtkOrientationMixinState; + +// The handle backing the SVG text. +export type IEllipseWidgetTextState = vtkOriginMixinState & + vtkColorMixinState & + vtkTextMixinState & + vtkVisibleMixinState; + +/** + * Where the text is placed relative to the bounding box of the shape, along + * the horizontal, vertical and depth axes of the view. + */ +export type EllipseWidgetTextPosition = [ + TextPosition, + TextPosition, + TextPosition, +]; + +// The internal state of the widget. +export interface vtkEllipseWidgetState + extends vtkWidgetState, vtkBoundsMixinState { + getPoint1Handle(): IEllipseWidgetPointHandleState; + getPoint2Handle(): IEllipseWidgetPointHandleState; + getEllipseHandle(): IEllipseWidgetShapeHandleState; + getText(): IEllipseWidgetTextState; + + getTextPosition(): EllipseWidgetTextPosition; + getTextPositionByReference(): EllipseWidgetTextPosition; + setTextPosition(textPosition: EllipseWidgetTextPosition): boolean; + setTextPosition( + horizontal: TextPosition, + vertical: TextPosition, + depth: TextPosition + ): boolean; + setTextPositionFrom(textPosition: EllipseWidgetTextPosition): void; + + /** + * The margin, in world units, between the text and the shape. + */ + getTextWorldMargin(): number; + setTextWorldMargin(textWorldMargin: number): boolean; +} + +// The type of object returned by vtkWidgetManager.addWidget(). +export interface vtkEllipseWidgetHandle extends vtkShapeWidgetHandle {} + +export interface vtkEllipseWidget extends vtkShapeWidget { + getWidgetState(): vtkEllipseWidgetState; + setWidgetState(widgetState: vtkEllipseWidgetState): boolean; + + /** + * The representation builders the widget uses in the given view type. + */ + getRepresentationsForViewType(viewType: ViewTypes): unknown; +} + +export interface IEllipseWidgetInitialValues extends IShapeWidgetInitialValues {} + +export function extend( + publicAPI: object, + model: object, + initialValues?: IEllipseWidgetInitialValues +): void; + +export function newInstance( + props?: IEllipseWidgetInitialValues +): vtkEllipseWidget; + +/** + * vtkEllipseWidget places an ellipse from two points. Modifier keys switch + * between corner-to-corner and center-to-corner placement and constrain the + * ratio to a circle. + */ +export declare const vtkEllipseWidget: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkEllipseWidget; diff --git a/Sources/Widgets/Widgets3D/ImageCroppingWidget/helpers.d.ts b/Sources/Widgets/Widgets3D/ImageCroppingWidget/helpers.d.ts new file mode 100644 index 00000000000..11e9742e948 --- /dev/null +++ b/Sources/Widgets/Widgets3D/ImageCroppingWidget/helpers.d.ts @@ -0,0 +1,41 @@ +import { mat4, vec3 } from 'gl-matrix'; +import { Vector3 } from '../../../types'; + +/** + * Labels used to encode a handle position in the handle state's name property. + * `'-'` is the lower bound, `'='` the middle and `'+'` the upper bound. + */ +export declare const AXES: string[]; + +/** + * Apply a 4x4 transform to a 3-component vector. + */ +export function transformVec3(ain: Vector3, transform: mat4): Float64Array; + +/** + * Apply only the rotation part of a 4x4 transform to a 3-component vector. + */ +export function rotateVec3(vec: Vector3, transform: mat4): vec3; + +/** + * Classify a handle from its name: `'corners'`, `'edges'` or `'faces'`. + * + * @param {String} name The handle name, made of three characters of `AXES` + */ +export function handleTypeFromName(name: string): string; + +/** + * Compute the world-space center of the crop box described by `planes`. + * + * @param planes The cropping planes, in index space + * @param {mat4} transform The index-to-world transform + */ +export function calculateCropperCenter( + planes: [number, number, number, number, number, number], + transform: mat4 +): Float64Array; + +/** + * Compute the normalized direction going from `v2` to `v1`. + */ +export function calculateDirection(v1: Vector3, v2: Vector3): vec3; diff --git a/Sources/Widgets/Widgets3D/ImageCroppingWidget/index.d.ts b/Sources/Widgets/Widgets3D/ImageCroppingWidget/index.d.ts new file mode 100644 index 00000000000..a6c4622a39a --- /dev/null +++ b/Sources/Widgets/Widgets3D/ImageCroppingWidget/index.d.ts @@ -0,0 +1,201 @@ +import { mat4 } from 'gl-matrix'; +import vtkImageData from '../../../Common/DataModel/ImageData'; +import vtkAbstractWidget from '../../Core/AbstractWidget'; +import vtkAbstractWidgetFactory, { + IAbstractWidgetFactoryInitialValues, +} from '../../Core/AbstractWidgetFactory'; +import { ViewTypes } from '../../Core/WidgetManager/Constants'; +import { vtkWidgetState } from '../../Core/WidgetState'; +import { vtkBoundsMixinState } from '../../Core/StateBuilder/boundsMixin'; +import { vtkColorMixinState } from '../../Core/StateBuilder/colorMixin'; +import { vtkManipulatorMixinState } from '../../Core/StateBuilder/manipulatorMixin'; +import { vtkNameMixinState } from '../../Core/StateBuilder/nameMixin'; +import { vtkOriginMixinState } from '../../Core/StateBuilder/originMixin'; +import { vtkScale1MixinState } from '../../Core/StateBuilder/scale1Mixin'; +import { vtkVisibleMixinState } from '../../Core/StateBuilder/visibleMixin'; +import vtkLineManipulator from '../../Manipulators/LineManipulator'; +import vtkPlaneManipulator from '../../Manipulators/PlaneManipulator'; + +/** + * The cropping planes, in index space, ordered as + * `[iMin, iMax, jMin, jMax, kMin, kMax]`. + */ +export type CroppingPlanes = [number, number, number, number, number, number]; + +export interface ImageCroppingPlanesState + extends vtkWidgetState, vtkBoundsMixinState { + /** + * Get the cropping planes, in index space. + */ + getPlanes(): CroppingPlanes; + + /** + * Set the cropping planes, in index space. + */ + setPlanes(planes: CroppingPlanes): boolean; + setPlanes( + iMin: number, + iMax: number, + jMin: number, + jMax: number, + kMin: number, + kMax: number + ): boolean; +} + +/** + * The state of a single crop handle. Handles are labelled `'handles'` plus + * their name and their type (`'corners'`, `'edges'` or `'faces'`). + */ +export type ImageCroppingHandleState = vtkNameMixinState & + vtkOriginMixinState & + vtkColorMixinState & + vtkScale1MixinState & + vtkVisibleMixinState & + vtkManipulatorMixinState; + +export interface ImageCroppingWidgetState + extends vtkWidgetState, vtkBoundsMixinState { + /** + * Get the index-to-world transform copied from the cropped image. + */ + getIndexToWorldT(): mat4; + + /** + * Set the index-to-world transform. + */ + setIndexToWorldT(transform: mat4): boolean; + + /** + * Get the world-to-index transform copied from the cropped image. + */ + getWorldToIndexT(): mat4; + + /** + * Set the world-to-index transform. + */ + setWorldToIndexT(transform: mat4): boolean; + + /** + * Get and set the sub-state holding the cropping planes. It can be observed + * independently of the rest of the widget state. + */ + getCroppingPlanes(): ImageCroppingPlanesState; + setCroppingPlanes(croppingPlanes: ImageCroppingPlanesState): boolean; +} + +/** + * The per-view widget returned by `vtkWidgetManager.addWidget()`. + */ +export interface vtkImageCroppingViewWidget extends vtkAbstractWidget { + getWidgetState(): ImageCroppingWidgetState; + + /** + * Set a callback invoked by the sphere handle representation when handles are + * rendered. + */ + setDisplayCallback(callback: (coords: any) => void): void; +} + +// The three manipulators are deliberately absent: the widget installs its own +// during initialization, unconditionally overwriting anything passed in. +export interface IImageCroppingWidgetInitialValues extends IAbstractWidgetFactoryInitialValues {} + +export interface vtkImageCroppingWidget extends vtkAbstractWidgetFactory { + getWidgetState(): ImageCroppingWidgetState; + + /** + * The representation builders the widget uses in the given view type. + */ + getRepresentationsForViewType(viewType: ViewTypes): unknown; + + /** + * Get the manipulator driving the corner handles. + */ + getCornerManipulator(): vtkPlaneManipulator | undefined; + + /** + * Set the manipulator driving the corner handles. + */ + setCornerManipulator(manipulator: vtkPlaneManipulator): void; + + /** + * Get the manipulator driving the edge handles. + */ + getEdgeManipulator(): vtkPlaneManipulator | undefined; + + /** + * Set the manipulator driving the edge handles. + */ + setEdgeManipulator(manipulator: vtkPlaneManipulator): void; + + /** + * Get the manipulator driving the face handles. + */ + getFaceManipulator(): vtkLineManipulator | undefined; + + /** + * Set the manipulator driving the face handles. + */ + setFaceManipulator(manipulator: vtkLineManipulator): void; + + /** + * Copy the transforms and dimensions of the given image into the widget + * state, resetting the cropping planes to the full extent of the image. + * + * @param {vtkImageData} image The image to crop + */ + copyImageDataDescription(image: vtkImageData): void; + + /** + * Reposition the handles from the current cropping planes. Called + * automatically whenever the cropping planes sub-state is modified. + */ + updateHandles(): void; + + /** + * Show or hide the six face handles. + */ + setFaceHandlesEnabled(enabled: boolean): void; + + /** + * Show or hide the eight corner handles. + */ + setCornerHandlesEnabled(enabled: boolean): void; + + /** + * Show or hide the twelve edge handles. + */ + setEdgeHandlesEnabled(enabled: boolean): void; +} + +/** + * Method used to decorate a given object (publicAPI+model) with vtkImageCroppingWidget characteristics. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + * @param {IImageCroppingWidgetInitialValues} [initialValues] (default: {}) + */ +export function extend( + publicAPI: object, + model: object, + initialValues?: IImageCroppingWidgetInitialValues +): void; + +/** + * Method used to create a new instance of vtkImageCroppingWidget + * @param {IImageCroppingWidgetInitialValues} [initialValues] for pre-setting some of its content + */ +export function newInstance( + initialValues?: IImageCroppingWidgetInitialValues +): vtkImageCroppingWidget; + +/** + * vtkImageCroppingWidget provides a box with corner, edge and face handles that + * lets the user interactively define cropping planes over a vtkImageData. + */ +declare const vtkImageCroppingWidget: { + newInstance: typeof newInstance; + extend: typeof extend; +}; +export default vtkImageCroppingWidget; diff --git a/Sources/Widgets/Widgets3D/ImplicitPlaneWidget/index.d.ts b/Sources/Widgets/Widgets3D/ImplicitPlaneWidget/index.d.ts new file mode 100644 index 00000000000..e3be5c936ce --- /dev/null +++ b/Sources/Widgets/Widgets3D/ImplicitPlaneWidget/index.d.ts @@ -0,0 +1,103 @@ +import vtkAbstractWidget from '../../Core/AbstractWidget'; +import { + IAbstractWidgetFactoryInitialValues, + vtkAbstractWidgetFactory, +} from '../../Core/AbstractWidgetFactory'; +import { ViewTypes } from '../../Core/WidgetManager/Constants'; +import { Nullable, Vector3 } from '../../../types'; +import { vtkProp } from '../../../Rendering/Core/Prop'; +import { vtkWidgetState } from '../../Core/WidgetState'; +import { vtkBoundsMixinState } from '../../Core/StateBuilder/boundsMixin'; + +/** + * The name of the interaction method the active handle dispatches to. + */ +export type ImplicitPlaneWidgetUpdateMethod = + | 'updateFromOrigin' + | 'updateFromPlane' + | 'updateFromNormal'; + +// The internal state of the widget, built by +// vtkImplicitPlaneRepresentation.generateState(). +export interface vtkImplicitPlaneWidgetState + extends vtkWidgetState, vtkBoundsMixinState { + getOrigin(): Vector3; + getOriginByReference(): Vector3; + setOrigin(origin: Vector3): boolean; + setOrigin(x: number, y: number, z: number): boolean; + setOriginFrom(origin: Vector3): void; + + getNormal(): Vector3; + getNormalByReference(): Vector3; + setNormal(normal: Vector3): boolean; + setNormal(x: number, y: number, z: number): boolean; + setNormalFrom(normal: Vector3): void; + + /** + * The actor of the representation pipeline that is currently picked. + */ + getActiveHandle(): Nullable; + setActiveHandle(activeHandle: Nullable): boolean; + + getUpdateMethodName(): ImplicitPlaneWidgetUpdateMethod | undefined; + setUpdateMethodName( + updateMethodName: ImplicitPlaneWidgetUpdateMethod + ): boolean; +} + +// The type of object returned by vtkWidgetManager.addWidget(). +export interface vtkImplicitPlaneWidgetHandle extends vtkAbstractWidget { + setDisplayCallback(callback: (coords: any) => void): void; + + /** + * Set the view cursor to the one matching the currently active handle. + */ + updateCursor(): void; + + /** + * Drag the plane origin inside the plane. + */ + updateFromOrigin(callData: any): void; + + /** + * Drag the plane along its normal. + */ + updateFromPlane(callData: any): void; + + /** + * Rotate the plane normal with a trackball manipulator. + */ + updateFromNormal(callData: any): void; +} + +export interface vtkImplicitPlaneWidget extends vtkAbstractWidgetFactory { + getWidgetState(): vtkImplicitPlaneWidgetState; + + /** + * The representation builders the widget uses in the given view type. + */ + getRepresentationsForViewType(viewType: ViewTypes): unknown; +} + +export interface IImplicitPlaneWidgetInitialValues extends IAbstractWidgetFactoryInitialValues {} + +export function extend( + publicAPI: object, + model: object, + initialValues?: IImplicitPlaneWidgetInitialValues +): void; + +export function newInstance( + props?: IImplicitPlaneWidgetInitialValues +): vtkImplicitPlaneWidget; + +/** + * vtkImplicitPlaneWidget manipulates an infinite plane: its origin can be + * dragged inside the plane or along the normal, and the normal can be rotated. + */ +export declare const vtkImplicitPlaneWidget: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkImplicitPlaneWidget; diff --git a/Sources/Widgets/Widgets3D/InteractiveOrientationWidget/index.d.ts b/Sources/Widgets/Widgets3D/InteractiveOrientationWidget/index.d.ts index a90caab0a42..cce9a10191b 100644 --- a/Sources/Widgets/Widgets3D/InteractiveOrientationWidget/index.d.ts +++ b/Sources/Widgets/Widgets3D/InteractiveOrientationWidget/index.d.ts @@ -5,9 +5,24 @@ import { import vtkAbstractWidget from '../../Core/AbstractWidget'; import { Bounds } from '../../../types'; import { ViewTypes } from '../../Core/WidgetManager/Constants'; +import { EventHandler, vtkSubscription } from '../../../interfaces'; + +export type vtkInteractiveOrientationWidgetHandle = vtkAbstractWidget & { + /** + * Registers a callback when an orientation change event occurs. + * @param cb EventHandler + */ + onOrientationChange(cb: EventHandler): vtkSubscription; + + /** + * Invokes an orientation change event. + */ + invokeOrientationChange(data: unknown): void; +}; export interface vtkInteractiveOrientationWidget< - WidgetInstance extends vtkAbstractWidget = vtkAbstractWidget, + WidgetInstance extends vtkAbstractWidget = + vtkInteractiveOrientationWidgetHandle, > extends vtkAbstractWidgetFactory { /** * Set the widget bounds @@ -19,7 +34,7 @@ export interface vtkInteractiveOrientationWidget< /** * @param {ViewTypes} viewType */ - getRepresentationForViewType(viewType: ViewTypes): unknown; + getRepresentationsForViewType(viewType: ViewTypes): unknown; } export interface IInteractiveOrientationWidgetInitialValues< @@ -45,7 +60,8 @@ export function extend( * @param {object} [initialValues] for pre-setting some of its content */ export function newInstance< - WidgetInstance extends vtkAbstractWidget = vtkAbstractWidget, + WidgetInstance extends vtkAbstractWidget = + vtkInteractiveOrientationWidgetHandle, >( initialValues?: IInteractiveOrientationWidgetInitialValues ): vtkInteractiveOrientationWidget; diff --git a/Sources/Widgets/Widgets3D/LabelWidget/index.d.ts b/Sources/Widgets/Widgets3D/LabelWidget/index.d.ts new file mode 100644 index 00000000000..b00dcc05d19 --- /dev/null +++ b/Sources/Widgets/Widgets3D/LabelWidget/index.d.ts @@ -0,0 +1,100 @@ +import vtkAbstractWidget from '../../Core/AbstractWidget'; +import vtkAbstractManipulator from '../../Manipulators/AbstractManipulator'; +import { + IAbstractWidgetFactoryInitialValues, + vtkAbstractWidgetFactory, +} from '../../Core/AbstractWidgetFactory'; +import { ViewTypes } from '../../Core/WidgetManager/Constants'; +import { vtkWidgetState } from '../../Core/WidgetState'; +import { vtkBoundsMixinState } from '../../Core/StateBuilder/boundsMixin'; +import { vtkColorMixinState } from '../../Core/StateBuilder/colorMixin'; +import { vtkManipulatorMixinState } from '../../Core/StateBuilder/manipulatorMixin'; +import { vtkOriginMixinState } from '../../Core/StateBuilder/originMixin'; +import { vtkScale1MixinState } from '../../Core/StateBuilder/scale1Mixin'; +import { vtkTextMixinState } from '../../Core/StateBuilder/textMixin'; +import { vtkVisibleMixinState } from '../../Core/StateBuilder/visibleMixin'; + +export type ILabelWidgetHandleState = vtkOriginMixinState & + vtkColorMixinState & + vtkScale1MixinState & + vtkVisibleMixinState & + vtkManipulatorMixinState; + +// The handle backing the SVG text. +export type ILabelWidgetTextState = vtkOriginMixinState & + vtkColorMixinState & + vtkTextMixinState & + vtkVisibleMixinState & + vtkManipulatorMixinState; + +// The internal state of the widget. +export interface vtkLabelWidgetState + extends vtkWidgetState, vtkBoundsMixinState { + // The handle that defines where the label points at. + getMoveHandle(): ILabelWidgetHandleState; + // The handle that carries the label text and its position. + getText(): ILabelWidgetTextState; +} + +// The type of object returned by vtkWidgetManager.addWidget(). +export interface vtkLabelWidgetHandle extends vtkAbstractWidget { + /** + * Set the label text and re-render. + */ + setText(text: string): void; + + /** + * Get the label text. + */ + getText(): string; + + setDisplayCallback(callback: (coords: any) => void): void; + + /** + * Reset the widget to its unplaced state. + */ + reset(): void; +} + +export interface vtkLabelWidget extends vtkAbstractWidgetFactory { + getWidgetState(): vtkLabelWidgetState; + + /** + * The representation builders the widget uses in the given view type. + */ + getRepresentationsForViewType(viewType: ViewTypes): unknown; + + /** + * The manipulator the move handle and the text handle are driven by. + */ + getManipulator(): vtkAbstractManipulator | undefined; + + /** + * Set the manipulator on the widget, on its move handle and on its text + * handle. + */ + setManipulator(manipulator: vtkAbstractManipulator): void; +} + +export interface ILabelWidgetInitialValues extends IAbstractWidgetFactoryInitialValues { + manipulator?: vtkAbstractManipulator; +} + +export function extend( + publicAPI: object, + model: object, + initialValues?: ILabelWidgetInitialValues +): void; + +export function newInstance(props?: ILabelWidgetInitialValues): vtkLabelWidget; + +/** + * vtkLabelWidget places a single point and displays a piece of text next to it + * in the SVG layer. + */ +export declare const vtkLabelWidget: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkLabelWidget; diff --git a/Sources/Widgets/Widgets3D/LineWidget/Constants.d.ts b/Sources/Widgets/Widgets3D/LineWidget/Constants.d.ts new file mode 100644 index 00000000000..a0098dbdf78 --- /dev/null +++ b/Sources/Widgets/Widgets3D/LineWidget/Constants.d.ts @@ -0,0 +1,34 @@ +export declare const ShapeType: { + /** + * A sphere handle that is always invisible, even on mouseover, which + * prevents the user from moving the handle once it is placed. + */ + readonly NONE: 'voidSphere'; + readonly SPHERE: 'sphere'; + readonly CUBE: 'cube'; + readonly CONE: 'cone'; + readonly ARROWHEAD3: 'triangle'; + readonly ARROWHEAD4: '4pointsArrowHead'; + readonly ARROWHEAD6: '6pointsArrowHead'; + readonly STAR: 'star'; + readonly DISK: 'disk'; + readonly CIRCLE: 'circle'; + readonly VIEWFINDER: 'viewFinder'; +}; + +export type ShapeType = (typeof ShapeType)[keyof typeof ShapeType]; + +export declare const Shapes2D: ShapeType[]; + +export declare const Shapes3D: ShapeType[]; + +export declare const ShapesOrientable: ShapeType[]; + +declare const _default: { + ShapeType: typeof ShapeType; + Shapes2D: typeof Shapes2D; + Shapes3D: typeof Shapes3D; + ShapesOrientable: typeof ShapesOrientable; +}; + +export default _default; diff --git a/Sources/Widgets/Widgets3D/LineWidget/index.d.ts b/Sources/Widgets/Widgets3D/LineWidget/index.d.ts new file mode 100644 index 00000000000..8c274900ca5 --- /dev/null +++ b/Sources/Widgets/Widgets3D/LineWidget/index.d.ts @@ -0,0 +1,157 @@ +import vtkAbstractWidget from '../../Core/AbstractWidget'; +import vtkAbstractManipulator from '../../Manipulators/AbstractManipulator'; +import { + IAbstractWidgetFactoryInitialValues, + vtkAbstractWidgetFactory, +} from '../../Core/AbstractWidgetFactory'; +import { ViewTypes } from '../../Core/WidgetManager/Constants'; +import { vtkWidgetState } from '../../Core/WidgetState'; +import { vtkBoundsMixinState } from '../../Core/StateBuilder/boundsMixin'; +import { vtkColorMixinState } from '../../Core/StateBuilder/colorMixin'; +import { vtkManipulatorMixinState } from '../../Core/StateBuilder/manipulatorMixin'; +import { vtkOriginMixinState } from '../../Core/StateBuilder/originMixin'; +import { vtkScale1MixinState } from '../../Core/StateBuilder/scale1Mixin'; +import { vtkShapeMixinState } from '../../Core/StateBuilder/shapeMixin'; +import { vtkTextMixinState } from '../../Core/StateBuilder/textMixin'; +import { vtkVisibleMixinState } from '../../Core/StateBuilder/visibleMixin'; + +export type ILineWidgetHandleState = vtkOriginMixinState & + vtkColorMixinState & + vtkScale1MixinState & + vtkVisibleMixinState & + vtkManipulatorMixinState & + vtkShapeMixinState; + +// The handle backing the SVG text. +export type ILineWidgetTextState = vtkOriginMixinState & + vtkColorMixinState & + vtkTextMixinState & + vtkVisibleMixinState; + +/** + * A sub-state holding only the relative position of the text along the line, + * so that it can be listened to on its own. + */ +export interface vtkLineWidgetPositionOnLineState extends vtkWidgetState { + /** + * Where the text sits along the line, from 0 at handle1 to 1 at handle2. + */ + getPosOnLine(): number; + setPosOnLine(posOnLine: number): boolean; +} + +// The internal state of the widget. +export interface vtkLineWidgetState + extends vtkWidgetState, vtkBoundsMixinState { + // The handle used only during initial placement. + getMoveHandle(): ILineWidgetHandleState; + // The first tip of the line. + getHandle1(): ILineWidgetHandleState; + // The second tip of the line. + getHandle2(): ILineWidgetHandleState; + getText(): ILineWidgetTextState; + getPositionOnLine(): vtkLineWidgetPositionOnLineState; + + getLineThickness(): number | undefined; + setLineThickness(lineThickness: number): boolean; +} + +// The type of object returned by vtkWidgetManager.addWidget(). +export interface vtkLineWidgetHandle extends vtkAbstractWidget { + /** + * The handle state at the given index. + * + * @param handleIndex 0 for handle1, 1 for handle2, 2 for the move handle + */ + getHandle(handleIndex: number): ILineWidgetHandleState; + + /** + * The index of the given handle state, or -1 when it is not one of the + * widget's handles. + */ + getHandleIndex(handle: ILineWidgetHandleState): number; + + /** + * True once both tips of the line have been placed. + */ + isPlaced(): boolean; + + /** + * Set the text displayed by the SVG layer and re-render. + */ + setText(text: string): void; + + /** + * Orient every handle along the direction of the line. + */ + updateHandleOrientations(): void; + + /** + * Make the two tip handles face the camera. + */ + rotateHandlesToFaceCamera(): void; + + /** + * Update the visibility flags of the given handle's representation from the + * handle state's visibility and shape. + */ + updateHandleVisibility(handleIndex: number): void; + + /** + * Place the given handle at the current position of the move handle. + */ + placeHandle(handleIndex: number): void; + + /** + * Reset the widget to its unplaced state. + */ + reset(): void; +} + +export interface vtkLineWidget extends vtkAbstractWidgetFactory { + getWidgetState(): vtkLineWidgetState; + + /** + * The representation builders the widget uses in the given view type. + */ + getRepresentationsForViewType(viewType: ViewTypes): unknown; + + /** + * The manipulator the handles are driven by. + */ + getManipulator(): vtkAbstractManipulator | undefined; + + /** + * Set the manipulator on the widget and on each of its handles. + */ + setManipulator(manipulator: vtkAbstractManipulator): void; + + /** + * The world distance between the two tips of the line. Returns 0 until both + * tips are placed. + */ + getDistance(): number; +} + +export interface ILineWidgetInitialValues extends IAbstractWidgetFactoryInitialValues { + manipulator?: vtkAbstractManipulator; +} + +export function extend( + publicAPI: object, + model: object, + initialValues?: ILineWidgetInitialValues +): void; + +export function newInstance(props?: ILineWidgetInitialValues): vtkLineWidget; + +/** + * vtkLineWidget places a line between two handles, each of which can take one + * of the shapes of `Constants.ShapeType`, and measures its length. + */ +export declare const vtkLineWidget: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkLineWidget; diff --git a/Sources/Widgets/Widgets3D/PaintWidget/index.d.ts b/Sources/Widgets/Widgets3D/PaintWidget/index.d.ts new file mode 100644 index 00000000000..85d5c4acd7d --- /dev/null +++ b/Sources/Widgets/Widgets3D/PaintWidget/index.d.ts @@ -0,0 +1,121 @@ +import vtkAbstractWidget from '../../Core/AbstractWidget'; +import vtkAbstractManipulator from '../../Manipulators/AbstractManipulator'; +import { + IAbstractWidgetFactoryInitialValues, + vtkAbstractWidgetFactory, +} from '../../Core/AbstractWidgetFactory'; +import { ViewTypes } from '../../Core/WidgetManager/Constants'; +import { Vector3 } from '../../../types'; +import { vtkWidgetState } from '../../Core/WidgetState'; +import { vtkBoundsMixinState } from '../../Core/StateBuilder/boundsMixin'; +import { vtkColorMixinState } from '../../Core/StateBuilder/colorMixin'; +import { vtkManipulatorMixinState } from '../../Core/StateBuilder/manipulatorMixin'; +import { vtkOrientationMixinState } from '../../Core/StateBuilder/orientationMixin'; +import { vtkOriginMixinState } from '../../Core/StateBuilder/originMixin'; +import { vtkScale1MixinState } from '../../Core/StateBuilder/scale1Mixin'; +import { vtkVisibleMixinState } from '../../Core/StateBuilder/visibleMixin'; + +// The brush handle that follows the pointer. +export type IPaintWidgetHandleState = vtkOriginMixinState & + vtkColorMixinState & + vtkScale1MixinState & + vtkOrientationMixinState & + vtkManipulatorMixinState & + vtkVisibleMixinState; + +// One stamp of the brush along the current stroke. +export type IPaintWidgetTrailState = vtkOriginMixinState & + vtkColorMixinState & + vtkScale1MixinState & + vtkOrientationMixinState & + vtkVisibleMixinState; + +// The internal state of the widget. +export interface vtkPaintWidgetState + extends vtkWidgetState, vtkBoundsMixinState { + /** + * The unsnapped world position of the pointer, before the handle origin is + * constrained. + */ + getTrueOrigin(): Vector3; + getTrueOriginByReference(): Vector3; + setTrueOrigin(trueOrigin: Vector3): boolean; + setTrueOrigin(x: number, y: number, z: number): boolean; + setTrueOriginFrom(trueOrigin: Vector3): void; + + getHandle(): IPaintWidgetHandleState; + + getTrailList(): IPaintWidgetTrailState[]; + addTrail(initialValues?: object): IPaintWidgetTrailState; + removeTrail(trailOrIndex: IPaintWidgetTrailState | number): void; + clearTrailList(): void; +} + +// The type of object returned by vtkWidgetManager.addWidget(). +export interface vtkPaintWidgetHandle extends vtkAbstractWidget {} + +export interface vtkPaintWidget extends vtkAbstractWidgetFactory { + getWidgetState(): vtkPaintWidgetState; + + /** + * The representation builders the widget uses in the given view type. + */ + getRepresentationsForViewType(viewType: ViewTypes): unknown; + + /** + * The manipulator the brush handle is driven by. + */ + getManipulator(): vtkAbstractManipulator | undefined; + + /** + * Set the manipulator on the widget and on its brush handle. + */ + setManipulator(manipulator: vtkAbstractManipulator): void; + + /** + * True while a stroke is being painted. + */ + getPainting(): boolean; + + /** + * The brush radius. + */ + getRadius(): number; + + /** + * Set the brush radius. Also updates the scale of the brush handle. + */ + setRadius(radius: number): void; + + /** + * The value the brush paints with. + */ + getColor(): number[]; + setColor(color: number[]): boolean; +} + +export interface IPaintWidgetInitialValues extends IAbstractWidgetFactoryInitialValues { + manipulator?: vtkAbstractManipulator; + radius?: number; + painting?: boolean; + color?: number[]; +} + +export function extend( + publicAPI: object, + model: object, + initialValues?: IPaintWidgetInitialValues +): void; + +export function newInstance(props?: IPaintWidgetInitialValues): vtkPaintWidget; + +/** + * vtkPaintWidget provides a circular or spherical brush that follows the + * pointer and records the stamps of the current stroke as a trail of states. + */ +export declare const vtkPaintWidget: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkPaintWidget; diff --git a/Sources/Widgets/Widgets3D/PolyLineWidget/index.d.ts b/Sources/Widgets/Widgets3D/PolyLineWidget/index.d.ts new file mode 100644 index 00000000000..298d74ffd40 --- /dev/null +++ b/Sources/Widgets/Widgets3D/PolyLineWidget/index.d.ts @@ -0,0 +1,83 @@ +import vtkAbstractWidget from '../../Core/AbstractWidget'; +import vtkAbstractManipulator from '../../Manipulators/AbstractManipulator'; +import { + IAbstractWidgetFactoryInitialValues, + vtkAbstractWidgetFactory, +} from '../../Core/AbstractWidgetFactory'; +import { ViewTypes } from '../../Core/WidgetManager/Constants'; +import { vtkWidgetState } from '../../Core/WidgetState'; +import { vtkBoundsMixinState } from '../../Core/StateBuilder/boundsMixin'; +import { vtkColorMixinState } from '../../Core/StateBuilder/colorMixin'; +import { vtkManipulatorMixinState } from '../../Core/StateBuilder/manipulatorMixin'; +import { vtkOriginMixinState } from '../../Core/StateBuilder/originMixin'; +import { vtkScale1MixinState } from '../../Core/StateBuilder/scale1Mixin'; +import { vtkVisibleMixinState } from '../../Core/StateBuilder/visibleMixin'; + +export type IPolyLineWidgetHandleState = vtkOriginMixinState & + vtkColorMixinState & + vtkScale1MixinState & + vtkVisibleMixinState & + vtkManipulatorMixinState; + +// The internal state of the widget. +export interface vtkPolyLineWidgetState + extends vtkWidgetState, vtkBoundsMixinState { + // The handle used only during initial placement. + getMoveHandle(): IPolyLineWidgetHandleState; + + // The placed handles, in placement order. + getHandleList(): IPolyLineWidgetHandleState[]; + addHandle(initialValues?: object): IPolyLineWidgetHandleState; + removeHandle(handleOrIndex: IPolyLineWidgetHandleState | number): void; + clearHandleList(): void; +} + +// The type of object returned by vtkWidgetManager.addWidget(). +export interface vtkPolyLineWidgetHandle extends vtkAbstractWidget { + setDisplayCallback(callback: (coords: any) => void): void; +} + +export interface vtkPolyLineWidget extends vtkAbstractWidgetFactory { + getWidgetState(): vtkPolyLineWidgetState; + + /** + * The representation builders the widget uses in the given view type. + */ + getRepresentationsForViewType(viewType: ViewTypes): unknown; + + /** + * The manipulator the handles are driven by. + */ + getManipulator(): vtkAbstractManipulator | undefined; + + /** + * Set the manipulator on the widget, on its move handle and on each of its + * placed handles. + */ + setManipulator(manipulator: vtkAbstractManipulator): void; +} + +export interface IPolyLineWidgetInitialValues extends IAbstractWidgetFactoryInitialValues { + manipulator?: vtkAbstractManipulator; +} + +export function extend( + publicAPI: object, + model: object, + initialValues?: IPolyLineWidgetInitialValues +): void; + +export function newInstance( + props?: IPolyLineWidgetInitialValues +): vtkPolyLineWidget; + +/** + * vtkPolyLineWidget places an arbitrary number of handles joined by a + * poly line. + */ +export declare const vtkPolyLineWidget: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkPolyLineWidget; diff --git a/Sources/Widgets/Widgets3D/RectangleWidget/index.d.ts b/Sources/Widgets/Widgets3D/RectangleWidget/index.d.ts new file mode 100644 index 00000000000..4548fb31447 --- /dev/null +++ b/Sources/Widgets/Widgets3D/RectangleWidget/index.d.ts @@ -0,0 +1,109 @@ +import { ViewTypes } from '../../Core/WidgetManager/Constants'; +import { TextPosition } from '../ShapeWidget/Constants'; +import { + IShapeWidgetInitialValues, + vtkShapeWidget, + vtkShapeWidgetHandle, +} from '../ShapeWidget'; +import { vtkWidgetState } from '../../Core/WidgetState'; +import { vtkBoundsMixinState } from '../../Core/StateBuilder/boundsMixin'; +import { vtkColorMixinState } from '../../Core/StateBuilder/colorMixin'; +import { vtkCornerMixinState } from '../../Core/StateBuilder/cornerMixin'; +import { vtkManipulatorMixinState } from '../../Core/StateBuilder/manipulatorMixin'; +import { vtkOrientationMixinState } from '../../Core/StateBuilder/orientationMixin'; +import { vtkOriginMixinState } from '../../Core/StateBuilder/originMixin'; +import { vtkScale1MixinState } from '../../Core/StateBuilder/scale1Mixin'; +import { vtkTextMixinState } from '../../Core/StateBuilder/textMixin'; +import { vtkVisibleMixinState } from '../../Core/StateBuilder/visibleMixin'; + +// One of the two corner handles. +export type IRectangleWidgetPointHandleState = vtkOriginMixinState & + vtkColorMixinState & + vtkScale1MixinState & + vtkVisibleMixinState & + vtkManipulatorMixinState; + +// The handle used for displaying the rectangle. +export type IRectangleWidgetShapeHandleState = vtkOriginMixinState & + vtkCornerMixinState & + vtkColorMixinState & + vtkVisibleMixinState & + vtkOrientationMixinState; + +// The handle backing the SVG text. +export type IRectangleWidgetTextState = vtkOriginMixinState & + vtkColorMixinState & + vtkTextMixinState & + vtkVisibleMixinState; + +/** + * Where the text is placed relative to the bounding box of the shape, along + * the horizontal, vertical and depth axes of the view. + */ +export type RectangleWidgetTextPosition = [ + TextPosition, + TextPosition, + TextPosition, +]; + +// The internal state of the widget. +export interface vtkRectangleWidgetState + extends vtkWidgetState, vtkBoundsMixinState { + getPoint1Handle(): IRectangleWidgetPointHandleState; + getPoint2Handle(): IRectangleWidgetPointHandleState; + getRectangleHandle(): IRectangleWidgetShapeHandleState; + getText(): IRectangleWidgetTextState; + + getTextPosition(): RectangleWidgetTextPosition; + getTextPositionByReference(): RectangleWidgetTextPosition; + setTextPosition(textPosition: RectangleWidgetTextPosition): boolean; + setTextPosition( + horizontal: TextPosition, + vertical: TextPosition, + depth: TextPosition + ): boolean; + setTextPositionFrom(textPosition: RectangleWidgetTextPosition): void; + + /** + * The margin, in world units, between the text and the shape. + */ + getTextWorldMargin(): number; + setTextWorldMargin(textWorldMargin: number): boolean; +} + +// The type of object returned by vtkWidgetManager.addWidget(). +export interface vtkRectangleWidgetHandle extends vtkShapeWidgetHandle {} + +export interface vtkRectangleWidget extends vtkShapeWidget { + getWidgetState(): vtkRectangleWidgetState; + setWidgetState(widgetState: vtkRectangleWidgetState): boolean; + + /** + * The representation builders the widget uses in the given view type. + */ + getRepresentationsForViewType(viewType: ViewTypes): unknown; +} + +export interface IRectangleWidgetInitialValues extends IShapeWidgetInitialValues {} + +export function extend( + publicAPI: object, + model: object, + initialValues?: IRectangleWidgetInitialValues +): void; + +export function newInstance( + props?: IRectangleWidgetInitialValues +): vtkRectangleWidget; + +/** + * vtkRectangleWidget places a rectangle from two points. Modifier keys switch + * between corner-to-corner and center-to-corner placement and constrain the + * ratio to a square. + */ +export declare const vtkRectangleWidget: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkRectangleWidget; diff --git a/Sources/Widgets/Widgets3D/ResliceCursorWidget/Constants.d.ts b/Sources/Widgets/Widgets3D/ResliceCursorWidget/Constants.d.ts index b0fb0cf29e9..0b7d84cb8bc 100644 --- a/Sources/Widgets/Widgets3D/ResliceCursorWidget/Constants.d.ts +++ b/Sources/Widgets/Widgets3D/ResliceCursorWidget/Constants.d.ts @@ -2,10 +2,10 @@ import { Vector3 } from '../../../types'; import { ViewTypes } from '../../Core/WidgetManager/Constants'; // Different types of plane from ViewTypes: -export type PlaneViewType = - | ViewTypes.YZ_PLANE - | ViewTypes.XZ_PLANE - | ViewTypes.XY_PLANE; +export type PlaneViewType = (typeof ViewTypes)[ + | 'YZ_PLANE' + | 'XZ_PLANE' + | 'XY_PLANE']; // 0, 1, 2 for X, Y, Z export type AxisIndex = 0 | 1 | 2; @@ -13,20 +13,26 @@ export type AxisIndex = 0 | 1 | 2; // Should be X, Y, Z export type PlaneName = typeof planeNames extends (infer U)[] ? U : never; -export declare enum ScrollingMethods { - MIDDLE_MOUSE_BUTTON = 0, - LEFT_MOUSE_BUTTON = 1, - RIGHT_MOUSE_BUTTON = 2, -} +export declare const ScrollingMethods: { + readonly MIDDLE_MOUSE_BUTTON: 0; + readonly LEFT_MOUSE_BUTTON: 1; + readonly RIGHT_MOUSE_BUTTON: 2; +}; + +export type ScrollingMethods = + (typeof ScrollingMethods)[keyof typeof ScrollingMethods]; // Note: These strings are used in ResliceCursorWidget/behavior.js // as method's names -export declare enum InteractionMethodsName { - TranslateAxis = 'translateAxis', - RotateLine = 'rotateLine', - TranslateCenter = 'translateCenter', - TranslateCenterAndUpdatePlanes = 'translateCenterAndUpdatePlanes', -} +export declare const InteractionMethodsName: { + readonly TranslateAxis: 'translateAxis'; + readonly RotateLine: 'rotateLine'; + readonly TranslateCenter: 'translateCenter'; + readonly TranslateCenterAndUpdatePlanes: 'translateCenterAndUpdatePlanes'; +}; + +export type InteractionMethodsName = + (typeof InteractionMethodsName)[keyof typeof InteractionMethodsName]; export declare const defaultViewUpFromViewType: { [plane in PlaneViewType]: Vector3; diff --git a/Sources/Widgets/Widgets3D/ResliceCursorWidget/behavior.d.ts b/Sources/Widgets/Widgets3D/ResliceCursorWidget/behavior.d.ts index 699925190f6..7fa5165931c 100644 --- a/Sources/Widgets/Widgets3D/ResliceCursorWidget/behavior.d.ts +++ b/Sources/Widgets/Widgets3D/ResliceCursorWidget/behavior.d.ts @@ -1,6 +1,23 @@ -import { Nullable } from '../../../types'; +import { Nullable, Vector3 } from '../../../types'; import { InteractionMethodsName, lineNames } from './Constants'; import { vtkAbstractWidget } from '../../Core/AbstractWidget'; +import { ViewTypes } from '../../Core/WidgetManager/Constants'; +import { vtkColor3MixinState } from '../../Core/StateBuilder/color3Mixin'; +import { vtkManipulatorMixinState } from '../../Core/StateBuilder/manipulatorMixin'; +import { vtkOrientationMixinState } from '../../Core/StateBuilder/orientationMixin'; +import { vtkOriginMixinState } from '../../Core/StateBuilder/originMixin'; +import { vtkScale3MixinState } from '../../Core/StateBuilder/scale3Mixin'; +import { vtkVisibleMixinState } from '../../Core/StateBuilder/visibleMixin'; + +/** + * The mixins the reslice cursor builds its line handles from. + */ +export type ResliceCursorLineHandleState = vtkOriginMixinState & + vtkColor3MixinState & + vtkScale3MixinState & + vtkOrientationMixinState & + vtkVisibleMixinState & + vtkManipulatorMixinState; type TLineName = (typeof lineNames)[number]; @@ -28,8 +45,112 @@ export interface vtkResliceCursorWidgetDefaultInstance extends vtkAbstractWidget setEnableTranslation(enableTranslation: boolean): void; setEnableRotation(enableRotation: boolean): void; + getInfiniteLine(): boolean; + setInfiniteLine(infiniteLine: boolean): boolean; + getActiveLineName(): TLineName | undefined; + + /** + * The line handle state of the line currently being interacted with. + */ + getActiveLineHandle(): ResliceCursorLineHandleState | undefined; + + /** + * The line handle state of the other line in the same view. + * + * @param {TLineName} lineName Returns `ZinX` for `YinX`, `YinX` for `ZinX`... + */ + getOtherLineHandle( + lineName: TLineName + ): ResliceCursorLineHandleState | undefined; + + /** + * Which of the two rotation handles of the active axis is active. + * + * @returns `'point0'`, `'point1'`, or null when the line itself is being + * rotated. + */ + getActiveRotationPointName(): Nullable<'point0' | 'point1'>; + + /** + * Start a scroll interaction, optionally seeding the previous position. + */ + startScrolling(newPosition: Nullable): void; + + /** + * End the current scroll interaction. + */ + endScrolling(): void; + + /** + * Apply the cursor style matching the current interaction to the view. + */ + updateCursor(): void; + + /** + * Move the center by the given number of slices along the normal of the + * widget's own view plane. + * + * @param {Number} nbSteps The number of slices, may be negative + */ + translateCenterOnPlaneDirection(nbSteps: number): void; + + /** + * Clamp the given center to the bounds of the image. + */ + getBoundedCenter(newCenter: Vector3): Vector3; + + /** + * Rotate a line of the widget's own view, and the orthogonal one when + * `keepOrthogonality` is set. + * + * @param {TLineName} lineName The line to rotate + * @param {Number} radianAngle Applied angle, in radians + */ + rotateLineInView(lineName: TLineName, radianAngle: number): void; + + /** + * Rotate a plane around an arbitrary axis. + * + * @param {ViewTypes} viewType Which plane is rotated + * @param {Number} radianAngle Applied angle, in radians + * @param {Vector3} planeNormal The axis to rotate around + */ + rotatePlane( + viewType: ViewTypes, + radianAngle: number, + planeNormal: Vector3 + ): void; + + /** + * Set the orientation of a plane. + * + * @param {ViewTypes} viewType Which plane is updated + * @param {Vector3} normal The new plane normal + * @param {Vector3} [viewUp] Defaults to the current view up of that plane + */ + setViewPlane( + viewType: ViewTypes, + normal: Vector3, + viewUp?: Nullable + ): void; + + /** + * The interaction handlers, installed under the InteractionMethodsName + * values and dispatched by name from the active interaction. + */ + translateAxis(callData: any): void; + translateCenter(callData: any): void; + rotateLine(callData: any): void; } -declare const _default: vtkResliceCursorWidgetDefaultInstance; -export default _default; +/** + * Decorates a widget instance (publicAPI+model) with the reslice cursor + * interaction methods described by `vtkResliceCursorWidgetDefaultInstance`. + * + * @param publicAPI object on which methods will be bounds (public) + * @param model object on which data structure will be bounds (protected) + */ +declare function widgetBehavior(publicAPI: object, model: object): void; + +export default widgetBehavior; diff --git a/Sources/Widgets/Widgets3D/ResliceCursorWidget/index.d.ts b/Sources/Widgets/Widgets3D/ResliceCursorWidget/index.d.ts index bcbe2e1f09a..bb003772760 100644 --- a/Sources/Widgets/Widgets3D/ResliceCursorWidget/index.d.ts +++ b/Sources/Widgets/Widgets3D/ResliceCursorWidget/index.d.ts @@ -11,13 +11,76 @@ import { vtkPlaneSource } from '../../../Filters/Sources/PlaneSource'; import { vtkRenderer } from '../../../Rendering/Core/Renderer'; import { vtkPlaneManipulator } from '../../Manipulators/PlaneManipulator'; import { ViewTypes } from '../../../Widgets/Core/WidgetManager/Constants'; -import { Vector2, Vector3 } from '../../../types'; +import { Nullable, Vector2, Vector3 } from '../../../types'; import { IDisplayScaleParams } from '../../../Widgets/Core/WidgetManager'; +import { vtkWidgetState } from '../../Core/WidgetState'; +import { vtkBoundsMixinState } from '../../Core/StateBuilder/boundsMixin'; +import { PlaneName, PlaneViewType, ScrollingMethods } from './Constants'; + +/** + * The orientation of one of the three reslice planes. + */ +export interface IResliceCursorPlane { + normal: Vector3; + viewUp: Vector3; +} + +export interface vtkResliceCursorWidgetState + extends vtkWidgetState, vtkBoundsMixinState { + /** + * The world-space point the three planes intersect at. + */ + getCenter(): Vector3; + getCenterByReference(): Vector3; + setCenter(center: Vector3): boolean; + setCenter(x: number, y: number, z: number): boolean; + setCenterFrom(center: Vector3): void; + + /** + * The image the widget reslices. + */ + getImage(): Nullable; + setImage(image: vtkImageData): boolean; + + /** + * The orientation of each reslice plane, keyed by view type. + */ + getPlanes(): Partial>; + setPlanes( + planes: Partial> + ): boolean; + + /** + * Which mouse button scrolls through the slices. + */ + getScrollingMethod(): ScrollingMethods; + setScrollingMethod(method: ScrollingMethods): boolean; + + /** + * The view type currently being interacted with, if any. + */ + getActiveViewType(): Nullable; + setActiveViewType(viewType: Nullable): boolean; + + getCameraOffsets(): Record; + setCameraOffsets(offsets: Record): boolean; + + getViewUpFromViewType(): Record; + setViewUpFromViewType(viewUps: Record): boolean; + + /** + * The handle sitting at the intersection of the three planes. + */ + getCenterHandle(): vtkWidgetState; + setCenterHandle(centerHandle: vtkWidgetState): boolean; +} export interface vtkResliceCursorWidget< WidgetInstance extends vtkAbstractWidget = vtkResliceCursorWidgetDefaultInstance, > extends vtkAbstractWidgetFactory { + getWidgetState(): vtkResliceCursorWidgetState; + /** * @param {ViewTypes} viewType */ @@ -58,27 +121,23 @@ export interface vtkResliceCursorWidget< getResliceMatrix(): mat4; - getDisplayScaleParams(): IDisplayScaleParams; + /** + * The display scale params of the first representation of each reslice view + * type. A view type with no representation, or whose representation predates + * the display-scale API, maps to undefined. + */ + getDisplayScaleParams(): Record< + PlaneViewType, + IDisplayScaleParams | undefined + >; setScaleInPixels(scale: boolean): boolean; getScaleInPixels(): boolean; - setHoleWidth(holeWidth: number): boolean; - - getHoleWidth(): number; - - /** - * Defines the length of the line - * The scaling of each line representation always define the dimensions of the circle / elipse (X and Y axes) - * The unit of this scaling is either in world coordinates or in pixels depending in scaleInPixels - * When the line is finite, this scaling on the Z axis also defines the length of the line - * When the line is infinite, the scaling on the Z axis is automatically huge - * @param infiniteLine - */ - setInfiniteLine(infiniteLine: boolean): boolean; - - getInfiniteLine(): boolean; + // holeWidth and infiniteLine are not on the factory: they are forwarded to + // the per-view widgets through model.methodsToLink, so they live on + // vtkResliceCursorWidgetDefaultInstance instead. setRotationHandlePosition(position: number): boolean; @@ -99,7 +158,31 @@ export interface vtkResliceCursorWidget< export interface IResliceCursorWidgetInitialValues< WidgetInstance extends vtkAbstractWidget, -> extends IAbstractWidgetFactoryInitialValues {} +> extends IAbstractWidgetFactoryInitialValues { + /** + * Which planes the widget state is generated for. + * @default ['X', 'Y', 'Z'] + */ + planes?: PlaneName[]; + + /** + * Whether handle sizes are expressed in pixels rather than world units. + * @default true + */ + scaleInPixels?: boolean; + + /** + * Where the rotation handles sit along their axis, in [0, 1]. + * @default 0.5 + */ + rotationHandlePosition?: number; + + /** + * The manipulator the view widgets interact through. + * @default vtkPlaneManipulator.newInstance() + */ + manipulator?: vtkPlaneManipulator; +} /** * Method used to decorate a given object (publicAPI+model) with vtkResliceCursorWidget characteristics. diff --git a/Sources/Widgets/Widgets3D/SeedWidget/index.d.ts b/Sources/Widgets/Widgets3D/SeedWidget/index.d.ts index 411595108d8..f8d7dfc0d39 100644 --- a/Sources/Widgets/Widgets3D/SeedWidget/index.d.ts +++ b/Sources/Widgets/Widgets3D/SeedWidget/index.d.ts @@ -1,28 +1,40 @@ import vtkAbstractWidget from '../../Core/AbstractWidget'; -import { Vector3, Bounds } from '../../../types'; - -export interface ISeedWidgetHandleState { - getOrigin(): Vector3; - setOrigin(arg: Vector3): void; - getColor3(): string; - setColor3(arg: string): void; - getScale1(): number; - setScale1(arg: number): void; - getVisible(): boolean; - setVisible(arg: boolean): void; - setShape(arg: string): void; - getShape(): string; -} +import vtkAbstractManipulator from '../../Manipulators/AbstractManipulator'; +import { + IAbstractWidgetFactoryInitialValues, + vtkAbstractWidgetFactory, +} from '../../Core/AbstractWidgetFactory'; +import { ViewTypes } from '../../Core/WidgetManager/Constants'; +import { Vector3 } from '../../../types'; +import { vtkWidgetState } from '../../Core/WidgetState'; +import { vtkBoundsMixinState } from '../../Core/StateBuilder/boundsMixin'; +import { vtkColor3MixinState } from '../../Core/StateBuilder/color3Mixin'; +import { vtkDirectionMixinState } from '../../Core/StateBuilder/directionMixin'; +import { vtkManipulatorMixinState } from '../../Core/StateBuilder/manipulatorMixin'; +import { vtkOriginMixinState } from '../../Core/StateBuilder/originMixin'; +import { vtkScale1MixinState } from '../../Core/StateBuilder/scale1Mixin'; +import { vtkVisibleMixinState } from '../../Core/StateBuilder/visibleMixin'; + +export interface ISeedWidgetHandleState + extends + vtkWidgetState, + vtkOriginMixinState, + vtkColor3MixinState, + vtkScale1MixinState, + vtkDirectionMixinState, + vtkVisibleMixinState, + vtkManipulatorMixinState {} // The internal state of the widget. -export interface vtkSeedWidgetState { +export interface vtkSeedWidgetState + extends vtkWidgetState, vtkBoundsMixinState { // A handle that defines the location getMoveHandle(): ISeedWidgetHandleState; } // Object returned by vtkWidgetManager.addWidget(). // One instance per view. -export interface vtkSeedWidgetHandle { +export interface vtkSeedWidgetHandle extends vtkAbstractWidget { /** * Place the seed position. * @param center Vector3 3D position @@ -42,20 +54,39 @@ export interface vtkSeedWidgetHandle { endInteract(): void; } -export interface vtkSeedWidget { - // Abstract widget methods. +export interface vtkSeedWidget extends vtkAbstractWidgetFactory { getWidgetState(): vtkSeedWidgetState; - onWidgetChange(fn: () => void): void; - placeWidget(bounds: Bounds): void; - setPlaceFactor(factor: number): void; + setWidgetState(widgetState: vtkSeedWidgetState): boolean; + + /** + * The representation builders the widget uses in the given view type. + */ + getRepresentationsForViewType(viewType: ViewTypes): unknown; + + /** + * The manipulator the move handle is driven by. + */ + getManipulator(): vtkAbstractManipulator | undefined; + + /** + * Set the manipulator on the widget and on its move handle. + */ + setManipulator(manipulator: vtkAbstractManipulator): void; } -export interface ISeedWidgetInitialValues {} +export interface ISeedWidgetInitialValues extends IAbstractWidgetFactoryInitialValues {} + +export function extend( + publicAPI: object, + model: object, + initialValues?: ISeedWidgetInitialValues +): void; export function newInstance(props?: ISeedWidgetInitialValues): vtkSeedWidget; export const vtkSeedWidget: { newInstance: typeof newInstance; + extend: typeof extend; }; export default vtkSeedWidget; diff --git a/Sources/Widgets/Widgets3D/ShapeWidget/Constants.d.ts b/Sources/Widgets/Widgets3D/ShapeWidget/Constants.d.ts new file mode 100644 index 00000000000..661faf9093d --- /dev/null +++ b/Sources/Widgets/Widgets3D/ShapeWidget/Constants.d.ts @@ -0,0 +1,40 @@ +export declare const BehaviorCategory: { + readonly POINTS: 'POINTS'; + readonly PLACEMENT: 'PLACEMENT'; + readonly RATIO: 'RATIO'; +}; + +export type BehaviorCategory = + (typeof BehaviorCategory)[keyof typeof BehaviorCategory]; + +export declare const ShapeBehavior: { + readonly POINTS: { + readonly CORNER_TO_CORNER: 0; + readonly CENTER_TO_CORNER: 1; + readonly RADIUS: 2; + readonly DIAMETER: 3; + }; + readonly PLACEMENT: { + readonly CLICK: 0; + readonly DRAG: 1; + readonly CLICK_AND_DRAG: 2; + }; + readonly RATIO: { + readonly FIXED: 0; + readonly FREE: 1; + }; +}; + +export type ShapeBehavior = (typeof ShapeBehavior)[keyof typeof ShapeBehavior]; + +export declare const TextPosition: { + readonly MIN: 'MIN'; + readonly CENTER: 'CENTER'; + readonly MAX: 'MAX'; +}; + +export type TextPosition = (typeof TextPosition)[keyof typeof TextPosition]; + +declare const _default: typeof ShapeBehavior; + +export default _default; diff --git a/Sources/Widgets/Widgets3D/ShapeWidget/index.d.ts b/Sources/Widgets/Widgets3D/ShapeWidget/index.d.ts new file mode 100644 index 00000000000..bcb782897f2 --- /dev/null +++ b/Sources/Widgets/Widgets3D/ShapeWidget/index.d.ts @@ -0,0 +1,161 @@ +import vtkAbstractWidget from '../../Core/AbstractWidget'; +import vtkAbstractManipulator from '../../Manipulators/AbstractManipulator'; +import { + IAbstractWidgetFactoryInitialValues, + vtkAbstractWidgetFactory, +} from '../../Core/AbstractWidgetFactory'; +import { BehaviorCategory } from './Constants'; +import { Nullable, Vector3 } from '../../../types'; + +/** + * The behavior flags that apply for each modifier key. The `None` entry holds + * the behavior used when no modifier key is pressed. + */ +export interface IShapeWidgetModifierBehavior { + None: Partial>; + [modifierKey: string]: Partial>; +} + +// The type of object returned by vtkWidgetManager.addWidget(). +export interface vtkShapeWidgetHandle extends vtkAbstractWidget { + setDisplayCallback(callback: (coords: any) => void): void; + + /** + * Set the text displayed by the SVG layer. + */ + setText(text: string): void; + + getResetAfterPointPlacement(): boolean; + setResetAfterPointPlacement(resetAfterPointPlacement: boolean): boolean; + + getModifierBehavior(): IShapeWidgetModifierBehavior; + setModifierBehavior(modifierBehavior: IShapeWidgetModifierBehavior): boolean; + + /** + * True when a currently pressed modifier key selects `flag` for `category`. + */ + isBehaviorActive(category: BehaviorCategory, flag: number): boolean; + + /** + * True when a currently pressed modifier key selects, for `category`, any + * flag other than `flag`. + */ + isOppositeBehaviorActive(category: BehaviorCategory, flag: number): boolean; + + /** + * The flag of `category` that the pressed modifier keys, or the default + * behavior, currently select. + */ + getActiveBehaviorFromCategory(category: BehaviorCategory): number | undefined; + + isRatioFixed(): boolean; + isDraggingEnabled(): boolean; + isDraggingForced(): boolean; + + getPoint1(): Nullable; + getPoint2(): Nullable; + + /** + * Place both points at once and update the shape. + */ + setPoints(point1: Vector3, point2: Vector3): void; + + /** + * Place the first point. Can be called right after `grabFocus()` to place + * the first point without waiting for an interaction. + */ + placePoint1(point: Vector3): void; + + /** + * Place the second point. + */ + placePoint2(point2: Vector3): void; + + /** + * The point that makes the shape a square, given the two opposite corners. + */ + makeSquareFromPoints(point1: Vector3, point2: Vector3): Vector3; + + /** + * Position the shape from two opposite corners. Reimplemented by each + * concrete shape widget. + */ + setCorners(point1: Vector3, point2: Vector3): void; + + /** + * Recompute the shape from the currently placed points, honoring the active + * points and ratio behaviors. + */ + updateShapeBounds(): void; + + /** + * Move the text handle to the position `textPosition` describes for the + * bounding box of the two given points. + */ + updateTextPosition(point1: Vector3, point2: Vector3): void; + + /** + * If the widget has the focus, reset it to its state just after it grabbed + * the focus. Otherwise reset it to its state before it grabbed the focus. + */ + reset(): void; +} + +export interface vtkShapeWidget< + WidgetInstance extends vtkShapeWidgetHandle = vtkShapeWidgetHandle, +> extends vtkAbstractWidgetFactory { + /** + * The manipulator the move handles are driven by. + */ + getManipulator(): vtkAbstractManipulator | undefined; + + /** + * Set the manipulator on the widget and on every state labelled + * `moveHandle`. + */ + setManipulator(manipulator: vtkAbstractManipulator): void; + + getModifierBehavior(): IShapeWidgetModifierBehavior; + setModifierBehavior(modifierBehavior: IShapeWidgetModifierBehavior): boolean; + + /** + * When true, placing the second point resets the widget instead of making it + * lose the focus. + */ + getResetAfterPointPlacement(): boolean; + setResetAfterPointPlacement(resetAfterPointPlacement: boolean): boolean; +} + +export interface IShapeWidgetInitialValues< + WidgetInstance extends vtkShapeWidgetHandle = vtkShapeWidgetHandle, +> extends IAbstractWidgetFactoryInitialValues { + manipulator?: vtkAbstractManipulator; + modifierBehavior?: IShapeWidgetModifierBehavior; + resetAfterPointPlacement?: boolean; +} + +export function extend< + WidgetInstance extends vtkShapeWidgetHandle = vtkShapeWidgetHandle, +>( + publicAPI: object, + model: object, + initialValues?: IShapeWidgetInitialValues +): void; + +export function newInstance< + WidgetInstance extends vtkShapeWidgetHandle = vtkShapeWidgetHandle, +>( + props?: IShapeWidgetInitialValues +): vtkShapeWidget; + +/** + * vtkShapeWidget is the base factory of the widgets that place a two-point + * shape, such as vtkEllipseWidget and vtkRectangleWidget. It holds the + * modifier-key behavior table that decides how the two points are interpreted. + */ +export declare const vtkShapeWidget: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkShapeWidget; diff --git a/Sources/Widgets/Widgets3D/SphereWidget/index.d.ts b/Sources/Widgets/Widgets3D/SphereWidget/index.d.ts index ddb1f46a1fe..186f215fbb9 100644 --- a/Sources/Widgets/Widgets3D/SphereWidget/index.d.ts +++ b/Sources/Widgets/Widgets3D/SphereWidget/index.d.ts @@ -1,45 +1,79 @@ import vtkAbstractWidget from '../../Core/AbstractWidget'; -import { Vector3, Bounds } from '../../../types'; - -export interface ISphereWidgetHandleState { - getOrigin(): Vector3; - setOrigin(arg: Vector3): void; - getColor(): string; - setColor(arg: string): void; - getScale1(): number; - setScale1(arg: number): void; - getVisible(): boolean; - setVisible(arg: boolean): void; - setShape(arg: string): void; - getShape(): string; -} +import vtkAbstractManipulator from '../../Manipulators/AbstractManipulator'; +import { + IAbstractWidgetFactoryInitialValues, + vtkAbstractWidgetFactory, +} from '../../Core/AbstractWidgetFactory'; +import { ViewTypes } from '../../Core/WidgetManager/Constants'; +import { Vector3 } from '../../../types'; +import { vtkWidgetState } from '../../Core/WidgetState'; +import { vtkBoundsMixinState } from '../../Core/StateBuilder/boundsMixin'; +import { vtkColorMixinState } from '../../Core/StateBuilder/colorMixin'; +import { vtkManipulatorMixinState } from '../../Core/StateBuilder/manipulatorMixin'; +import { vtkOrientationMixinState } from '../../Core/StateBuilder/orientationMixin'; +import { vtkOriginMixinState } from '../../Core/StateBuilder/originMixin'; +import { vtkScale1MixinState } from '../../Core/StateBuilder/scale1Mixin'; +import { vtkVisibleMixinState } from '../../Core/StateBuilder/visibleMixin'; + +export type ISphereWidgetHandleState = vtkOriginMixinState & + vtkColorMixinState & + vtkScale1MixinState & + vtkVisibleMixinState & + vtkManipulatorMixinState; // The internal state of the widget. -export interface vtkSphereWidgetState { +export interface vtkSphereWidgetState + extends vtkWidgetState, vtkBoundsMixinState { + // The handle used only for during initial placement. + getMoveHandle(): ISphereWidgetHandleState; // A handle that defines the center of the sphere. getCenterHandle(): ISphereWidgetHandleState; // An arbitrary point at the sphere border. Used only to set the radius. getBorderHandle(): ISphereWidgetHandleState; + // The handle used for displaying the sphere. + getSphereHandle(): vtkOriginMixinState & + vtkColorMixinState & + vtkScale1MixinState & + vtkVisibleMixinState & + vtkOrientationMixinState; } // The type of object returned by vtkWidgetManager.addWidget() -export interface vtkSphereWidgetHandle { +export interface vtkSphereWidgetHandle extends vtkAbstractWidget { // Set the sphere parameters. setCenterAndRadius(center: Vector3, radius: number): void; } -export interface vtkSphereWidget { - // Abstract widget methods. +export interface vtkSphereWidget extends vtkAbstractWidgetFactory { getWidgetState(): vtkSphereWidgetState; - onWidgetChange(fn: () => void): void; - placeWidget(bounds: Bounds): void; - setPlaceFactor(factor: number): void; + setWidgetState(widgetState: vtkSphereWidgetState): boolean; + + /** + * The representation builders the widget uses in the given view type. + */ + getRepresentationsForViewType(viewType: ViewTypes): unknown; + + /** + * The manipulator the widget handles are driven by. + */ + getManipulator(): vtkAbstractManipulator | undefined; + + /** + * Set the manipulator on the widget and on each of its handles. + */ + setManipulator(manipulator: vtkAbstractManipulator): void; // Methods specific to vtkSphereWidget. getRadius(): number; } -export interface ISphereWidgetInitialValues {} +export interface ISphereWidgetInitialValues extends IAbstractWidgetFactoryInitialValues {} + +export function extend( + publicAPI: object, + model: object, + initialValues?: ISphereWidgetInitialValues +): void; export function newInstance( props?: ISphereWidgetInitialValues @@ -47,6 +81,7 @@ export function newInstance( export const vtkSphereWidget: { newInstance: typeof newInstance; + extend: typeof extend; }; export default vtkSphereWidget; diff --git a/Sources/Widgets/Widgets3D/SplineWidget/index.d.ts b/Sources/Widgets/Widgets3D/SplineWidget/index.d.ts new file mode 100644 index 00000000000..bcae6245017 --- /dev/null +++ b/Sources/Widgets/Widgets3D/SplineWidget/index.d.ts @@ -0,0 +1,180 @@ +import vtkAbstractWidget from '../../Core/AbstractWidget'; +import vtkAbstractManipulator from '../../Manipulators/AbstractManipulator'; +import { + IAbstractWidgetFactoryInitialValues, + vtkAbstractWidgetFactory, +} from '../../Core/AbstractWidgetFactory'; +import { ViewTypes } from '../../Core/WidgetManager/Constants'; +import { TypedArray, Vector3 } from '../../../types'; +import { BoundaryCondition } from '../../../Common/DataModel/Spline1D/Constants'; +import { splineKind } from '../../../Common/DataModel/Spline3D/Constants'; +import { vtkWidgetState } from '../../Core/WidgetState'; +import { vtkBoundsMixinState } from '../../Core/StateBuilder/boundsMixin'; +import { vtkColorMixinState } from '../../Core/StateBuilder/colorMixin'; +import { vtkManipulatorMixinState } from '../../Core/StateBuilder/manipulatorMixin'; +import { vtkOriginMixinState } from '../../Core/StateBuilder/originMixin'; +import { vtkScale1MixinState } from '../../Core/StateBuilder/scale1Mixin'; +import { vtkVisibleMixinState } from '../../Core/StateBuilder/visibleMixin'; + +export type ISplineWidgetHandleState = vtkOriginMixinState & + vtkColorMixinState & + vtkScale1MixinState & + vtkVisibleMixinState & + vtkManipulatorMixinState; + +// The internal state of the widget. +export interface vtkSplineWidgetState + extends vtkWidgetState, vtkBoundsMixinState { + getSplineKind(): splineKind; + setSplineKind(splineKind: splineKind): boolean; + + getSplineClosed(): boolean; + setSplineClosed(splineClosed: boolean): boolean; + + getSplineBoundaryCondition(): BoundaryCondition; + setSplineBoundaryCondition(boundaryCondition: BoundaryCondition): boolean; + + getSplineBoundaryConditionValues(): Vector3; + getSplineBoundaryConditionValuesByReference(): Vector3; + setSplineBoundaryConditionValues(values: Vector3): boolean; + setSplineBoundaryConditionValues(x: number, y: number, z: number): boolean; + setSplineBoundaryConditionValuesFrom(values: Vector3): void; + + getSplineTension(): number; + setSplineTension(tension: number): boolean; + + getSplineContinuity(): number; + setSplineContinuity(continuity: number): boolean; + + getSplineBias(): number; + setSplineBias(bias: number): boolean; + + // The handle used only during initial placement. + getMoveHandle(): ISplineWidgetHandleState; + + // The placed handles, in placement order. + getHandleList(): ISplineWidgetHandleState[]; + addHandle(initialValues?: object): ISplineWidgetHandleState; + removeHandle(handleOrIndex: ISplineWidgetHandleState | number): void; + clearHandleList(): void; +} + +// The type of object returned by vtkWidgetManager.addWidget(). +export interface vtkSplineWidgetHandle extends vtkAbstractWidget { + setDisplayCallback(callback: (coords: any) => void): void; + + getResetAfterPointPlacement(): boolean; + setResetAfterPointPlacement(resetAfterPointPlacement: boolean): boolean; + + getFreehandMinDistance(): number; + setFreehandMinDistance(freehandMinDistance: number): boolean; + + getAllowFreehand(): boolean; + setAllowFreehand(allowFreehand: boolean): boolean; + + getDefaultCursor(): string; + setDefaultCursor(defaultCursor: string): boolean; + + getHandleSizeInPixels(): number; + /** + * Set the handle size and rescale the already placed handles. + */ + setHandleSizeInPixels(size: number): void; + + /** + * Set the number of points the spline is sampled at, on the widget and on + * its spline representation. + */ + setResolution(resolution: number): void; + + /** + * The sampled points of the spline, as the raw point data of the spline + * representation output. + */ + getPoints(): TypedArray; + + /** + * Remove every placed handle. + */ + reset(): void; +} + +export interface vtkSplineWidget extends vtkAbstractWidgetFactory { + getWidgetState(): vtkSplineWidgetState; + + /** + * The representation builders the widget uses in the given view type. + */ + getRepresentationsForViewType(viewType: ViewTypes): unknown; + + /** + * The manipulator the handles are driven by. + */ + getManipulator(): vtkAbstractManipulator | undefined; + + /** + * Set the manipulator on the widget, on its move handle and on each of its + * placed handles. + */ + setManipulator(manipulator: vtkAbstractManipulator): void; + + /** + * The minimum world distance between two handles placed by a freehand + * stroke. + */ + getFreehandMinDistance(): number; + setFreehandMinDistance(freehandMinDistance: number): boolean; + + getAllowFreehand(): boolean; + setAllowFreehand(allowFreehand: boolean): boolean; + + /** + * The number of points the spline is sampled at. + */ + getResolution(): number; + setResolution(resolution: number): boolean; + + getDefaultCursor(): string; + setDefaultCursor(defaultCursor: string): boolean; + + getHandleSizeInPixels(): number; + setHandleSizeInPixels(handleSizeInPixels: number): boolean; + + /** + * When true, closing the spline resets the widget instead of making it lose + * the focus. + */ + getResetAfterPointPlacement(): boolean; + setResetAfterPointPlacement(resetAfterPointPlacement: boolean): boolean; +} + +export interface ISplineWidgetInitialValues extends IAbstractWidgetFactoryInitialValues { + manipulator?: vtkAbstractManipulator; + freehandMinDistance?: number; + allowFreehand?: boolean; + resolution?: number; + defaultCursor?: string; + handleSizeInPixels?: number; + resetAfterPointPlacement?: boolean; +} + +export function extend( + publicAPI: object, + model: object, + initialValues?: ISplineWidgetInitialValues +): void; + +export function newInstance( + props?: ISplineWidgetInitialValues +): vtkSplineWidget; + +/** + * vtkSplineWidget places handles that a closed or open spline is fitted + * through, either point by point or with a freehand stroke. + */ +export declare const vtkSplineWidget: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkSplineWidget; diff --git a/Sources/Widgets/Widgets3D/TransformControlsWidget/constants.d.ts b/Sources/Widgets/Widgets3D/TransformControlsWidget/constants.d.ts new file mode 100644 index 00000000000..95f816aaafc --- /dev/null +++ b/Sources/Widgets/Widgets3D/TransformControlsWidget/constants.d.ts @@ -0,0 +1,19 @@ +export declare const ROTATE_HANDLE_PIXEL_SCALE: number; +export declare const TRANSLATE_HANDLE_RADIUS: number; +export declare const SCALE_HANDLE_RADIUS: number; +export declare const SCALE_HANDLE_CUBE_SIDE_LENGTH: number; +export declare const SCALE_HANDLE_PIXEL_SCALE: number; + +export declare const TransformMode: { + readonly TRANSLATE: 'translate'; + readonly SCALE: 'scale'; + readonly ROTATE: 'rotate'; +}; + +export type TransformMode = (typeof TransformMode)[keyof typeof TransformMode]; + +declare const _default: { + TransformMode: typeof TransformMode; +}; + +export default _default; diff --git a/Sources/Widgets/Widgets3D/TransformControlsWidget/index.d.ts b/Sources/Widgets/Widgets3D/TransformControlsWidget/index.d.ts new file mode 100644 index 00000000000..0b4cae9740c --- /dev/null +++ b/Sources/Widgets/Widgets3D/TransformControlsWidget/index.d.ts @@ -0,0 +1,133 @@ +import vtkAbstractWidget from '../../Core/AbstractWidget'; +import vtkAbstractManipulator from '../../Manipulators/AbstractManipulator'; +import { + IAbstractWidgetFactoryInitialValues, + vtkAbstractWidgetFactory, +} from '../../Core/AbstractWidgetFactory'; +import { ViewTypes } from '../../Core/WidgetManager/Constants'; +import { Vector3, Vector4 } from '../../../types'; +import { TransformMode } from './constants'; +import { vtkWidgetState } from '../../Core/WidgetState'; +import { vtkBoundsMixinState } from '../../Core/StateBuilder/boundsMixin'; +import { vtkColor3MixinState } from '../../Core/StateBuilder/color3Mixin'; +import { vtkNameMixinState } from '../../Core/StateBuilder/nameMixin'; +import { vtkOrientationMixinState } from '../../Core/StateBuilder/orientationMixin'; +import { vtkOriginMixinState } from '../../Core/StateBuilder/originMixin'; +import { vtkScale1MixinState } from '../../Core/StateBuilder/scale1Mixin'; +import { vtkScale3MixinState } from '../../Core/StateBuilder/scale3Mixin'; +import { vtkVisibleMixinState } from '../../Core/StateBuilder/visibleMixin'; + +/** + * The transform the widget edits. The handle states are re-derived from it + * whenever it is modified. + */ +export interface vtkTransformControlsWidgetTransformState extends vtkWidgetState { + getTranslation(): Vector3; + getTranslationByReference(): Vector3; + setTranslation(translation: Vector3): boolean; + setTranslation(x: number, y: number, z: number): boolean; + setTranslationFrom(translation: Vector3): void; + + getScale(): Vector3; + getScaleByReference(): Vector3; + setScale(scale: Vector3): boolean; + setScale(x: number, y: number, z: number): boolean; + setScaleFrom(scale: Vector3): void; + + /** + * The rotation, as a quaternion. + */ + getRotation(): Vector4; + getRotationByReference(): Vector4; + setRotation(rotation: Vector4): boolean; + setRotation(x: number, y: number, z: number, w: number): boolean; + setRotationFrom(rotation: Vector4): void; +} + +// A translate or scale axis handle. +export type ITransformControlsWidgetAxisHandleState = vtkNameMixinState & + vtkOriginMixinState & + vtkColor3MixinState & + vtkScale3MixinState & + vtkOrientationMixinState & + vtkVisibleMixinState; + +// A rotate axis handle. +export type ITransformControlsWidgetRotateHandleState = vtkNameMixinState & + vtkOriginMixinState & + vtkColor3MixinState & + vtkScale1MixinState & + vtkOrientationMixinState & + vtkVisibleMixinState; + +// The internal state of the widget. +export interface vtkTransformControlsWidgetState + extends vtkWidgetState, vtkBoundsMixinState { + getTransform(): vtkTransformControlsWidgetTransformState; + + getTranslateHandleX(): ITransformControlsWidgetAxisHandleState; + getTranslateHandleY(): ITransformControlsWidgetAxisHandleState; + getTranslateHandleZ(): ITransformControlsWidgetAxisHandleState; + + getScaleHandleX(): ITransformControlsWidgetAxisHandleState; + getScaleHandleY(): ITransformControlsWidgetAxisHandleState; + getScaleHandleZ(): ITransformControlsWidgetAxisHandleState; + + getRotateHandleX(): ITransformControlsWidgetRotateHandleState; + getRotateHandleY(): ITransformControlsWidgetRotateHandleState; + getRotateHandleZ(): ITransformControlsWidgetRotateHandleState; +} + +// The type of object returned by vtkWidgetManager.addWidget(). +export interface vtkTransformControlsWidgetHandle extends vtkAbstractWidget { + setDisplayCallback(callback: (coords: any) => void): void; +} + +export interface vtkTransformControlsWidget extends vtkAbstractWidgetFactory { + getWidgetState(): vtkTransformControlsWidgetState; + + /** + * The representation builders the widget uses in the given view type. + */ + getRepresentationsForViewType(viewType: ViewTypes): unknown; + + /** + * Which set of handles the widget shows and interacts with. + */ + getMode(): TransformMode; + setMode(mode: TransformMode): boolean; + + /** + * Show only the handles matching the current mode. + */ + updateHandleVisibility(): void; + + getLineManipulator(): vtkAbstractManipulator | undefined; + getRotateManipulator(): vtkAbstractManipulator | undefined; +} + +export interface ITransformControlsWidgetInitialValues extends IAbstractWidgetFactoryInitialValues { + mode?: TransformMode; +} + +export function extend( + publicAPI: object, + model: object, + initialValues?: ITransformControlsWidgetInitialValues +): void; + +export function newInstance( + props?: ITransformControlsWidgetInitialValues +): vtkTransformControlsWidget; + +/** + * vtkTransformControlsWidget shows a set of per-axis handles that translate, + * scale or rotate a transform, one mode at a time. + */ +export declare const vtkTransformControlsWidget: { + newInstance: typeof newInstance; + extend: typeof extend; + TransformMode: typeof TransformMode; +}; + +export default vtkTransformControlsWidget; diff --git a/Sources/interfaces.d.ts b/Sources/interfaces.d.ts index 91bcd1e9293..7d2c5da2f0c 100644 --- a/Sources/interfaces.d.ts +++ b/Sources/interfaces.d.ts @@ -55,7 +55,7 @@ export interface vtkAlgorithm { /** * @param {Number} [port] The port number (default 0). */ - getInputData(port?: number): any; + getInputData(port?: number): T; /** * @param outputPort @@ -85,7 +85,7 @@ export interface vtkAlgorithm { * port. * @param {Number} [port] The port number (default 0). */ - getOutputData(port?: number): any; + getOutputData(port?: number): T; /** * @@ -118,7 +118,7 @@ export interface vtkAlgorithm { * Get the actual data array for the input array sepcified by idx. * @param {Number} port (default 0) */ - getInputArrayToProcess(inputPort?: number): vtkDataArray; + getInputArrayToProcess(inputPort?: number): vtkDataArray | null; /** * Set the input data arrays that this algorithm will process. @@ -158,7 +158,7 @@ export interface vtkObject { * @param callback function * @returns subscription object so you can easily unsubscribe later on */ - onModified(callback: (instance: vtkObject) => any): vtkSubscription; + onModified(callback: (instance: vtkObject) => any): vtkSubscription | null; /** * Return the `Modified Time` which is a monotonic increasing integer @@ -236,7 +236,7 @@ export interface vtkObject { * @param name of the field to extract from the instance model * @returns model[name] */ - getReferenceByName(name: string): any; + getReferenceByName(name: string): T; /** * Dereference any internal object and remove any subscription. @@ -266,7 +266,7 @@ export interface vtkObject { * worker.postMessage(dataset.getState({ preserveTypedArrays: true })); * ``` */ - getState(options?: GetStateOptions): object; + getState(options?: GetStateOptions): object | null; /** * Used internally by JSON.stringify to get the content to serialize. diff --git a/Sources/macros.d.ts b/Sources/macros.d.ts index 82e9bed62ac..c52088c0c5c 100644 --- a/Sources/macros.d.ts +++ b/Sources/macros.d.ts @@ -5,6 +5,14 @@ import { vtkPropertyDomain, vtkObject, } from './interfaces'; +import { TypedArray } from './types'; + +/** + * Default parameter sentinel that throws when a required named parameter is + * missing. + * @param name of the missing parameter + */ +export function requiredParam(name: string): never; /** * Allow user to redefine vtkXXXMacro method call. @@ -56,16 +64,54 @@ export function vtkOnceErrorMacro(str: string): void; /** * A way to create typed array based on its name without using the window namespace */ -export enum TYPED_ARRAYS { - Float32Array, - Float64Array, - Uint8Array, - Int8Array, - Uint16Array, - Int16Array, - Uint32Array, - Int32Array, -} +export const TYPED_ARRAYS: { + Float32Array: typeof Float32Array; + Float64Array: typeof Float64Array; + Uint8Array: typeof Uint8Array; + Int8Array: typeof Int8Array; + Uint16Array: typeof Uint16Array; + Int16Array: typeof Int16Array; + Uint32Array: typeof Uint32Array; + Int32Array: typeof Int32Array; + Uint8ClampedArray: typeof Uint8ClampedArray; + BigInt64Array?: typeof BigInt64Array; + BigUint64Array?: typeof BigUint64Array; +}; + +// Unavailable optional constructors use the Float64Array fallback. +type TypedArrayForName = { + [K in T]: + | InstanceType> + | ({} extends Pick ? Float64Array : never); +}[T]; + +/** + * Create a new typed array based on its name without using the window namespace + * @param type name of the typed array constructor (e.g. 'Float32Array') + * @param args arguments forwarded to the typed array constructor + */ +export function newTypedArray( + type: K, + ...args: any[] +): TypedArrayForName; +export function newTypedArray( + type: string, + ...args: any[] +): TypedArray | BigInt64Array | BigUint64Array; + +/** + * Create a new typed array from an array-like or iterable object + * @param type name of the typed array constructor (e.g. 'Float32Array') + * @param args arguments forwarded to the typed array's `from()` method + */ +export function newTypedArrayFrom( + type: K, + ...args: any[] +): TypedArrayForName; +export function newTypedArrayFrom( + type: string, + ...args: any[] +): TypedArray | BigInt64Array | BigUint64Array; /** * Capitalize provided string. @@ -327,7 +373,7 @@ export function event( * @param args * @returns symbol to either keep going or interrupt existing callback call stack */ -export function VtkCallback(...args: any): void | symbol; +export type VtkCallback = (...args: any) => void | symbol; // Example of event(,, 'change') export interface VtkChangeEvent { @@ -359,7 +405,7 @@ export type VtkExtend = ( initialValues: object ) => void; -export function newInstance(extend: VtkExtend, className: string): any; +export function newInstance(extend: VtkExtend, className?: string): any; // ---------------------------------------------------------------------------- // Chain function calls @@ -498,7 +544,6 @@ export interface VtkProxy extends VtkKeyStore, vtkObject { getProxyManager: () => VtkProxyManager; updateUI: (ui: object) => void; - listProxyProperties: (groupName: string) => Array; updateProxyProperty: (propertyName: string, propUI: object) => void; activate: () => void; registerPropertyLinkForGC: (otherLink: VtkLink, type: string) => void; @@ -511,11 +556,6 @@ export interface VtkProxy extends VtkKeyStore, vtkObject { */ getPropertyLink(id: string, persistent?: boolean): VtkLink; - /** - * - * @param groupName (default: ROOT_GROUP_NAME) - */ - getProperties(groupName?: string): Array; listPropertyNames: () => Array; getPropertyByName: (name: string) => vtkProperty; getPropertyDomainByName: (name: string) => vtkPropertyDomain; @@ -701,6 +741,27 @@ export interface VtkNormalizedWheelEvent { export function normalizeWheel(wheelEvent: object): VtkNormalizedWheelEvent; +// ---------------------------------------------------------------------------- +// vtk.js internal use +// ---------------------------------------------------------------------------- + +/** + * Setter factories keyed by the `type` of an object field descriptor passed to + * `set`/`setGet`. Each factory returns the setter bound to `publicAPI`/`model`. + */ +declare const objectSetterMap: { + enum( + publicAPI: object, + model: object, + field: { name: string; enum: Record } + ): (value: string | number) => boolean; + object( + publicAPI: object, + model: object, + field: { name: string; params?: string[] } + ): (...args: any[]) => boolean; +}; + // ---------------------------------------------------------------------------- // Default export // ---------------------------------------------------------------------------- @@ -723,11 +784,15 @@ declare const Macro: { measurePromiseExecution: typeof measurePromiseExecution; moveToProtected: typeof moveToProtected; newInstance: typeof newInstance; + newTypedArray: typeof newTypedArray; + newTypedArrayFrom: typeof newTypedArrayFrom; normalizeWheel: typeof normalizeWheel; obj: typeof obj; + objectSetterMap: typeof objectSetterMap; proxy: typeof proxy; proxyPropertyMapping: typeof proxyPropertyMapping; proxyPropertyState: typeof proxyPropertyState; + requiredParam: typeof requiredParam; safeArrays: typeof safeArrays; set: typeof set; setArray: typeof setArray; diff --git a/Sources/vtk.d.ts b/Sources/vtk.d.ts index c0ad5e93670..2de97fc35f6 100644 --- a/Sources/vtk.d.ts +++ b/Sources/vtk.d.ts @@ -1,4 +1,5 @@ import { vtkObject } from './interfaces'; +import { Nullable } from './types'; interface ISerializedVtkObject { vtkClass: string; @@ -6,12 +7,29 @@ interface ISerializedVtkObject { } interface Ivtk { + (obj: null): null; + (obj: undefined): undefined; + (obj: T): T; + /** * Deserializes a serialized VTK.js object. + * + * Returns null when `vtkClass` names no registered factory, and when the + * registered factory itself returns null. */ - (obj: ISerializedVtkObject): vtkObject; + (obj: ISerializedVtkObject): Nullable; - register(vtkClassName: string, constructor: (model: unknown) => T): void; + /** + * Register the factory used to rebuild instances of `vtkClassName` when + * deserializing. + * + * @param vtkClassName The `vtkClass` value the factory handles + * @param constructor Typically the class's own `newInstance` + */ + register( + vtkClassName: string, + constructor: (initialValues?: any) => Nullable + ): void; } declare const vtk: Ivtk; diff --git a/tsconfig.esm-check.json b/tsconfig.esm-check.json index 3a3bfb78c77..fa3bd00812e 100644 --- a/tsconfig.esm-check.json +++ b/tsconfig.esm-check.json @@ -1,10 +1,4 @@ { - "include": ["dist/esm/**/*.d.ts"], - "compilerOptions": { - "noEmit": true, - "lib": [ - "esnext", - "dom" - ] - } + "extends": "./tsconfig.json", + "include": ["dist/esm/**/*.d.ts"] } diff --git a/tsconfig.json b/tsconfig.json index 9fbf53c19d7..8ce9c2a541b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,7 @@ "include": ["Sources/**/*.d.ts", "Utilities/**/*.d.ts"], "exclude": ["Utilities/build/macro-shim.d.ts"], "compilerOptions": { - "noEmit": true + "noEmit": true, + "lib": ["ES2020", "DOM"] } } diff --git a/tsconfig.umd-check.json b/tsconfig.umd-check.json index e0570456835..b2b8e53f40a 100644 --- a/tsconfig.umd-check.json +++ b/tsconfig.umd-check.json @@ -1,11 +1,7 @@ { + "extends": "./tsconfig.json", "include": ["dist/umd/**/*.d.ts"], "compilerOptions": { - "noEmit": true, - "lib": [ - "esnext", - "dom" - ], "baseUrl": "dist/umd", "paths": { "vtk.js/*": ["./*"]