@kitware/vtk.js 34.17.0 → 35.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,8 @@
1
+ ## From 34.x to 35
2
+
3
+ - **vtkMapper**: mappers should overwrite `computeBounds()` instead of `getBounds` that now calls `computeBounds()` before returning a copy of the mapper bounds.
4
+
5
+
1
6
  ## From 33.x to 34
2
7
 
3
8
  - **vtkMapper**: many properties have moved to `vtkVolumeProperty`. The full list of changed methods is: `getAnisotropy`, `getComputeNormalFromOpacity`, `getFilterMode`, `getFilterModeAsString`, `getGlobalIlluminationReach`, `getIpScalarRange`, `getIpScalarRangeByReference`, `getLAOKernelRadius`, `getLAOKernelSize`, `getLocalAmbientOcclusion`, `getPreferSizeOverAccuracy`, `getVolumetricScatteringBlending`, `setAnisotropy`, `setAverageIPScalarRange`, `setComputeNormalFromOpacity`, `setFilterMode`, `setFilterModeToNormalized`, `setFilterModeToOff`, `setFilterModeToRaw`, `setGlobalIlluminationReach`, `setIpScalarRange`, `setIpScalarRangeFrom`, `setLAOKernelRadius`, `setLAOKernelSize`, `setLocalAmbientOcclusion`, `setPreferSizeOverAccuracy`, `setVolumetricScatteringBlending`.
package/CONTRIBUTING.md CHANGED
@@ -128,7 +128,7 @@ The vtk.js documentation is part of the code repository and is entirely written
128
128
 
129
129
  If you create an example, please list it in the [examples landing page](Documentation/content/examples/index.md).
130
130
 
131
- Images and GIF videos added to the [gallery](Documentation/public/gallery) must be compressed as much as possible (e.g. 432px by 300px with 50% JPEG compression). You may want to use [ezgif.com](https://ezgif.com/).
131
+ Images and GIF videos added to the [gallery](Documentation/public/gallery) must be compressed as much as possible (e.g. 500px by 280px with 50% JPEG compression). You may want to use [ezgif.com](https://ezgif.com/).
132
132
 
133
133
  ## Reporting Issues
134
134
 
@@ -1928,6 +1928,18 @@ function getMajorAxisIndex(vector) {
1928
1928
  }
1929
1929
  return axisIndex;
1930
1930
  }
1931
+ function getMinorAxisIndex(vector) {
1932
+ let minValue = Infinity;
1933
+ let axisIndex = -1;
1934
+ for (let i = 0; i < vector.length; i++) {
1935
+ const value = Math.abs(vector[i]);
1936
+ if (value < minValue) {
1937
+ axisIndex = i;
1938
+ minValue = value;
1939
+ }
1940
+ }
1941
+ return axisIndex;
1942
+ }
1931
1943
 
1932
1944
  // Return the closest orthogonal matrix of 1, -1 and 0
1933
1945
  // It works for both column major and row major matrices
@@ -2110,6 +2122,7 @@ var vtkMath = {
2110
2122
  // JS add-on
2111
2123
  createUninitializedBounds,
2112
2124
  getMajorAxisIndex,
2125
+ getMinorAxisIndex,
2113
2126
  getSparseOrthogonalMatrix,
2114
2127
  floatToHex2,
2115
2128
  floatRGB2HexCode,
@@ -2232,6 +2245,7 @@ var vtkMath$1 = /*#__PURE__*/Object.freeze({
2232
2245
  isNan: isNan,
2233
2246
  createUninitializedBounds: createUninitializedBounds,
2234
2247
  getMajorAxisIndex: getMajorAxisIndex,
2248
+ getMinorAxisIndex: getMinorAxisIndex,
2235
2249
  getSparseOrthogonalMatrix: getSparseOrthogonalMatrix,
2236
2250
  floatToHex2: floatToHex2,
2237
2251
  floatRGB2HexCode: floatRGB2HexCode,
@@ -2239,4 +2253,4 @@ var vtkMath$1 = /*#__PURE__*/Object.freeze({
2239
2253
  'default': vtkMath
2240
2254
  });
2241
2255
 
2242
- export { createArray as $, rowsToMat3 as A, degreesFromRadians as B, ldexp as C, xyz2rgb as D, areEquals as E, clampValue as F, arrayRange as G, getMajorAxisIndex as H, createUninitializedBounds as I, normalize4D as J, identity as K, multiplyMatrix as L, floor as M, isInf as N, rgb2hsv as O, rgb2lab as P, lab2rgb as Q, round as R, normalize2D as S, nearestPowerOfTwo as T, multiply3x3_vect3 as U, getSparseOrthogonalMatrix as V, areBoundsInitialized as W, floatRGB2HexCode as X, isPowerOfTwo as Y, angleBetweenVectors as Z, signedAngleBetweenVectors as _, areMatricesEqual as a, isNaN as a$, Pi as a0, ceil as a1, min as a2, max as a3, arrayMin as a4, arrayMax as a5, ceilLog2 as a6, factorial as a7, binomial as a8, beginCombination as a9, quaternionToMatrix3x3 as aA, roundNumber as aB, matrix3x3ToQuaternion as aC, multiplyQuaternion as aD, orthogonalize3x3 as aE, diagonalize3x3 as aF, singularValueDecomposition3x3 as aG, luFactorLinearSystem as aH, luSolveLinearSystem as aI, estimateMatrixCondition as aJ, solveHomogeneousLeastSquares as aK, solveLeastSquares as aL, hex2float as aM, lab2xyz as aN, xyz2lab as aO, rgb2xyz as aP, computeBoundsFromPoints as aQ, clampAndNormalizeValue as aR, getScalarTypeFittingRange as aS, getAdjustedScalarRange as aT, extentIsWithinOtherExtent as aU, boundsIsWithinOtherBounds as aV, pointIsWithinBounds as aW, solve3PointCircle as aX, inf as aY, negInf as aZ, isFinite as a_, nextCombination as aa, randomSeed as ab, getSeed as ac, gaussian as ad, multiplyScalar2D as ae, multiplyAccumulate2D as af, outer as ag, projectVector as ah, dot2D as ai, projectVector2D as aj, gaussianAmplitude as ak, gaussianWeight as al, outer2D as am, norm2D as an, rowsToMat4 as ao, columnsToMat4 as ap, columnsToMat3 as aq, LUFactor3x3 as ar, LUSolve3x3 as as, linearSolve3x3 as at, multiply3x3_mat3 as au, transpose3x3 as av, invert3x3 as aw, identity3x3 as ax, isIdentity as ay, isIdentity3x3 as az, vtkMath as b, floatToHex2 as b0, float2CssRGBA as b1, roundVector as c, dot as d, clampVector as e, distance2BetweenPoints as f, solveLinearSystem as g, hsv2rgb as h, isNan as i, cross as j, add as k, normalize as l, multiplyAccumulate as m, norm as n, determinant2x2 as o, invertMatrix as p, jacobiN as q, radiansFromDegrees as r, subtract as s, perpendiculars as t, uninitializeBounds as u, vtkMath$1 as v, jacobi as w, multiplyScalar as x, random as y, determinant3x3 as z };
2256
+ export { createArray as $, rowsToMat3 as A, degreesFromRadians as B, ldexp as C, xyz2rgb as D, areEquals as E, clampValue as F, arrayRange as G, getMajorAxisIndex as H, createUninitializedBounds as I, normalize4D as J, identity as K, multiplyMatrix as L, floor as M, isInf as N, rgb2hsv as O, rgb2lab as P, lab2rgb as Q, round as R, normalize2D as S, nearestPowerOfTwo as T, multiply3x3_vect3 as U, getSparseOrthogonalMatrix as V, areBoundsInitialized as W, floatRGB2HexCode as X, isPowerOfTwo as Y, angleBetweenVectors as Z, signedAngleBetweenVectors as _, areMatricesEqual as a, isNaN as a$, Pi as a0, ceil as a1, min as a2, max as a3, arrayMin as a4, arrayMax as a5, ceilLog2 as a6, factorial as a7, binomial as a8, beginCombination as a9, quaternionToMatrix3x3 as aA, roundNumber as aB, matrix3x3ToQuaternion as aC, multiplyQuaternion as aD, orthogonalize3x3 as aE, diagonalize3x3 as aF, singularValueDecomposition3x3 as aG, luFactorLinearSystem as aH, luSolveLinearSystem as aI, estimateMatrixCondition as aJ, solveHomogeneousLeastSquares as aK, solveLeastSquares as aL, hex2float as aM, lab2xyz as aN, xyz2lab as aO, rgb2xyz as aP, computeBoundsFromPoints as aQ, clampAndNormalizeValue as aR, getScalarTypeFittingRange as aS, getAdjustedScalarRange as aT, extentIsWithinOtherExtent as aU, boundsIsWithinOtherBounds as aV, pointIsWithinBounds as aW, solve3PointCircle as aX, inf as aY, negInf as aZ, isFinite as a_, nextCombination as aa, randomSeed as ab, getSeed as ac, gaussian as ad, multiplyScalar2D as ae, multiplyAccumulate2D as af, outer as ag, projectVector as ah, dot2D as ai, projectVector2D as aj, gaussianAmplitude as ak, gaussianWeight as al, outer2D as am, norm2D as an, rowsToMat4 as ao, columnsToMat4 as ap, columnsToMat3 as aq, LUFactor3x3 as ar, LUSolve3x3 as as, linearSolve3x3 as at, multiply3x3_mat3 as au, transpose3x3 as av, invert3x3 as aw, identity3x3 as ax, isIdentity as ay, isIdentity3x3 as az, vtkMath as b, getMinorAxisIndex as b0, floatToHex2 as b1, float2CssRGBA as b2, roundVector as c, dot as d, clampVector as e, distance2BetweenPoints as f, solveLinearSystem as g, hsv2rgb as h, isNan as i, cross as j, add as k, normalize as l, multiplyAccumulate as m, norm as n, determinant2x2 as o, invertMatrix as p, jacobiN as q, radiansFromDegrees as r, subtract as s, perpendiculars as t, uninitializeBounds as u, vtkMath$1 as v, jacobi as w, multiplyScalar as x, random as y, determinant3x3 as z };
@@ -1074,6 +1074,13 @@ export function createUninitializedBounds(): Bounds;
1074
1074
  */
1075
1075
  export function getMajorAxisIndex(vector: number[]): number;
1076
1076
 
1077
+ /**
1078
+ * Return the index of the component with the smallest absolute value.
1079
+ * Returns -1 for empty arrays.
1080
+ * @param {Number[]} vector
1081
+ */
1082
+ export function getMinorAxisIndex(vector: number[]): number;
1083
+
1077
1084
  /**
1078
1085
  * Return the closest orthogonal matrix of 1, -1 and 0
1079
1086
  * It works for both column major and row major matrices
@@ -1244,6 +1251,7 @@ export declare const vtkMath: {
1244
1251
  isInf: typeof isInf;
1245
1252
  createUninitializedBounds: typeof createUninitializedBounds;
1246
1253
  getMajorAxisIndex: typeof getMajorAxisIndex;
1254
+ getMinorAxisIndex: typeof getMinorAxisIndex;
1247
1255
  getSparseOrthogonalMatrix: typeof getSparseOrthogonalMatrix;
1248
1256
  floatToHex2: typeof floatToHex2;
1249
1257
  floatRGB2HexCode: typeof floatRGB2HexCode;
@@ -1,4 +1,4 @@
1
1
  import 'seedrandom';
2
2
  import '../../macros2.js';
3
3
  import './Math/Constants.js';
4
- export { ar as LUFactor3x3, as as LUSolve3x3, a0 as Pi, k as add, Z as angleBetweenVectors, W as areBoundsInitialized, E as areEquals, a as areMatricesEqual, a5 as arrayMax, a4 as arrayMin, G as arrayRange, a9 as beginCombination, a8 as binomial, aV as boundsIsWithinOtherBounds, a1 as ceil, a6 as ceilLog2, aR as clampAndNormalizeValue, F as clampValue, e as clampVector, aq as columnsToMat3, ap as columnsToMat4, aQ as computeBoundsFromPoints, $ as createArray, I as createUninitializedBounds, j as cross, b as default, B as degreesFromRadians, o as determinant2x2, z as determinant3x3, aF as diagonalize3x3, f as distance2BetweenPoints, d as dot, ai as dot2D, aJ as estimateMatrixCondition, aU as extentIsWithinOtherExtent, a7 as factorial, b1 as float2CssRGBA, X as floatRGB2HexCode, b0 as floatToHex2, M as floor, ad as gaussian, ak as gaussianAmplitude, al as gaussianWeight, aT as getAdjustedScalarRange, H as getMajorAxisIndex, aS as getScalarTypeFittingRange, ac as getSeed, V as getSparseOrthogonalMatrix, aM as hex2float, h as hsv2rgb, K as identity, ax as identity3x3, aY as inf, aw as invert3x3, p as invertMatrix, a_ as isFinite, ay as isIdentity, az as isIdentity3x3, N as isInf, a$ as isNaN, i as isNan, Y as isPowerOfTwo, w as jacobi, q as jacobiN, Q as lab2rgb, aN as lab2xyz, C as ldexp, at as linearSolve3x3, aH as luFactorLinearSystem, aI as luSolveLinearSystem, aC as matrix3x3ToQuaternion, a3 as max, a2 as min, au as multiply3x3_mat3, U as multiply3x3_vect3, m as multiplyAccumulate, af as multiplyAccumulate2D, L as multiplyMatrix, aD as multiplyQuaternion, x as multiplyScalar, ae as multiplyScalar2D, T as nearestPowerOfTwo, aZ as negInf, aa as nextCombination, n as norm, an as norm2D, l as normalize, S as normalize2D, J as normalize4D, aE as orthogonalize3x3, ag as outer, am as outer2D, t as perpendiculars, aW as pointIsWithinBounds, ah as projectVector, aj as projectVector2D, aA as quaternionToMatrix3x3, r as radiansFromDegrees, y as random, ab as randomSeed, O as rgb2hsv, P as rgb2lab, aP as rgb2xyz, R as round, aB as roundNumber, c as roundVector, A as rowsToMat3, ao as rowsToMat4, _ as signedAngleBetweenVectors, aG as singularValueDecomposition3x3, aX as solve3PointCircle, aK as solveHomogeneousLeastSquares, aL as solveLeastSquares, g as solveLinearSystem, s as subtract, av as transpose3x3, u as uninitializeBounds, aO as xyz2lab, D as xyz2rgb } from './Math/index.js';
4
+ export { ar as LUFactor3x3, as as LUSolve3x3, a0 as Pi, k as add, Z as angleBetweenVectors, W as areBoundsInitialized, E as areEquals, a as areMatricesEqual, a5 as arrayMax, a4 as arrayMin, G as arrayRange, a9 as beginCombination, a8 as binomial, aV as boundsIsWithinOtherBounds, a1 as ceil, a6 as ceilLog2, aR as clampAndNormalizeValue, F as clampValue, e as clampVector, aq as columnsToMat3, ap as columnsToMat4, aQ as computeBoundsFromPoints, $ as createArray, I as createUninitializedBounds, j as cross, b as default, B as degreesFromRadians, o as determinant2x2, z as determinant3x3, aF as diagonalize3x3, f as distance2BetweenPoints, d as dot, ai as dot2D, aJ as estimateMatrixCondition, aU as extentIsWithinOtherExtent, a7 as factorial, b2 as float2CssRGBA, X as floatRGB2HexCode, b1 as floatToHex2, M as floor, ad as gaussian, ak as gaussianAmplitude, al as gaussianWeight, aT as getAdjustedScalarRange, H as getMajorAxisIndex, b0 as getMinorAxisIndex, aS as getScalarTypeFittingRange, ac as getSeed, V as getSparseOrthogonalMatrix, aM as hex2float, h as hsv2rgb, K as identity, ax as identity3x3, aY as inf, aw as invert3x3, p as invertMatrix, a_ as isFinite, ay as isIdentity, az as isIdentity3x3, N as isInf, a$ as isNaN, i as isNan, Y as isPowerOfTwo, w as jacobi, q as jacobiN, Q as lab2rgb, aN as lab2xyz, C as ldexp, at as linearSolve3x3, aH as luFactorLinearSystem, aI as luSolveLinearSystem, aC as matrix3x3ToQuaternion, a3 as max, a2 as min, au as multiply3x3_mat3, U as multiply3x3_vect3, m as multiplyAccumulate, af as multiplyAccumulate2D, L as multiplyMatrix, aD as multiplyQuaternion, x as multiplyScalar, ae as multiplyScalar2D, T as nearestPowerOfTwo, aZ as negInf, aa as nextCombination, n as norm, an as norm2D, l as normalize, S as normalize2D, J as normalize4D, aE as orthogonalize3x3, ag as outer, am as outer2D, t as perpendiculars, aW as pointIsWithinBounds, ah as projectVector, aj as projectVector2D, aA as quaternionToMatrix3x3, r as radiansFromDegrees, y as random, ab as randomSeed, O as rgb2hsv, P as rgb2lab, aP as rgb2xyz, R as round, aB as roundNumber, c as roundVector, A as rowsToMat3, ao as rowsToMat4, _ as signedAngleBetweenVectors, aG as singularValueDecomposition3x3, aX as solve3PointCircle, aK as solveHomogeneousLeastSquares, aL as solveLeastSquares, g as solveLinearSystem, s as subtract, av as transpose3x3, u as uninitializeBounds, aO as xyz2lab, D as xyz2rgb } from './Math/index.js';
@@ -1,5 +1,5 @@
1
1
  import { mat4 } from 'gl-matrix';
2
- import { Bounds, Vector2, Vector3 } from './../../types';
2
+ import { Bounds, TypedArray, Vector2, Vector3 } from './../../types';
3
3
  import vtkPoints from './../Core/Points';
4
4
  import { Nullable } from './../../types';
5
5
 
@@ -394,11 +394,16 @@ declare class BoundingBox {
394
394
  /**
395
395
  * Adds points to a bounding box.
396
396
  * @param {Bounds} bounds
397
- * @param {number} x
397
+ * @param {number|Number[]|TypedArray} xOrPoint
398
398
  * @param {number} y
399
399
  * @param {number} z
400
400
  */
401
- addPoint(bounds: Bounds, x: number, y: number, z: number): Bounds;
401
+ addPoint(
402
+ bounds: Bounds,
403
+ xOrPoint: number | number[] | TypedArray,
404
+ y?: number,
405
+ z?: number
406
+ ): Bounds;
402
407
 
403
408
  /**
404
409
  * Adds points to a bounding box.
@@ -31,14 +31,23 @@ function setBounds(bounds, otherBounds) {
31
31
  function reset(bounds) {
32
32
  return setBounds(bounds, INIT_BOUNDS);
33
33
  }
34
- function addPoint(bounds, x, y, z) {
34
+ function addPoint(bounds, xOrPoint, y, z) {
35
35
  const [xMin, xMax, yMin, yMax, zMin, zMax] = bounds;
36
- bounds[0] = xMin < x ? xMin : x;
37
- bounds[1] = xMax > x ? xMax : x;
38
- bounds[2] = yMin < y ? yMin : y;
39
- bounds[3] = yMax > y ? yMax : y;
40
- bounds[4] = zMin < z ? zMin : z;
41
- bounds[5] = zMax > z ? zMax : z;
36
+ if (typeof xOrPoint === 'number') {
37
+ bounds[0] = xMin < xOrPoint ? xMin : xOrPoint;
38
+ bounds[1] = xMax > xOrPoint ? xMax : xOrPoint;
39
+ bounds[2] = yMin < y ? yMin : y;
40
+ bounds[3] = yMax > y ? yMax : y;
41
+ bounds[4] = zMin < z ? zMin : z;
42
+ bounds[5] = zMax > z ? zMax : z;
43
+ } else {
44
+ bounds[0] = xMin < xOrPoint[0] ? xMin : xOrPoint[0];
45
+ bounds[1] = xMax > xOrPoint[0] ? xMax : xOrPoint[0];
46
+ bounds[2] = yMin < xOrPoint[1] ? yMin : xOrPoint[1];
47
+ bounds[3] = yMax > xOrPoint[1] ? yMax : xOrPoint[1];
48
+ bounds[4] = zMin < xOrPoint[2] ? zMin : xOrPoint[2];
49
+ bounds[5] = zMax > xOrPoint[2] ? zMax : xOrPoint[2];
50
+ }
42
51
  return bounds;
43
52
  }
44
53
  function addPoints(bounds, points) {
@@ -117,7 +117,7 @@ function vtkBox(publicAPI, model) {
117
117
  }
118
118
  vtkBoundingBox.setBounds(model.bbox, boundsArray);
119
119
  };
120
- publicAPI.getBounds = () => model.bbox;
120
+ publicAPI.getBounds = () => [...model.bbox];
121
121
  publicAPI.evaluateFunction = (x, y, z) => {
122
122
  const point = Array.isArray(x) ? x : [x, y, z];
123
123
  let diff;
@@ -22,9 +22,9 @@ function vtkPointSet(publicAPI, model) {
22
22
  model.points = vtk(model.points);
23
23
  }
24
24
  publicAPI.getNumberOfPoints = () => model.points.getNumberOfPoints();
25
- publicAPI.getBounds = () => model.points.getBounds();
25
+ publicAPI.getBounds = () => model.points?.getBounds();
26
26
  publicAPI.computeBounds = () => {
27
- publicAPI.getBounds();
27
+ model.points?.computeBounds();
28
28
  };
29
29
  const superShallowCopy = publicAPI.shallowCopy;
30
30
  publicAPI.shallowCopy = (other, debug = false) => {
@@ -2,7 +2,6 @@ import { m as macro } from '../../macros2.js';
2
2
  import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
3
3
  import vtkDataArray from '../../Common/Core/DataArray.js';
4
4
  import { b as vtkMath } from '../../Common/Core/Math/index.js';
5
- import { AttributeTypes } from '../../Common/DataModel/DataSetAttributes/Constants.js';
6
5
  import vtkPoints from '../../Common/Core/Points.js';
7
6
  import vtkPolyData from '../../Common/DataModel/PolyData.js';
8
7
  import vtkTriangle from '../../Common/DataModel/Triangle.js';
@@ -484,8 +483,7 @@ function vtkWindowedSincPolyDataFilter(publicAPI, model) {
484
483
  numberOfComponents: 1,
485
484
  values: newScalars
486
485
  });
487
- const idx = output.getPointData().addArray(newScalarsArray);
488
- output.getPointData().setActiveAttribute(idx, AttributeTypes.SCALARS);
486
+ output.getPointData().setScalars(newScalarsArray);
489
487
  }
490
488
  if (model.generateErrorVectors) {
491
489
  const newVectors = new Float32Array(3 * numPts);
@@ -513,7 +511,7 @@ function vtkWindowedSincPolyDataFilter(publicAPI, model) {
513
511
  if (!input) {
514
512
  return;
515
513
  }
516
- const output = outData[0]?.initialize() || vtkPolyData.newInstance();
514
+ const output = outData[0] || vtkPolyData.newInstance();
517
515
  const outputPoints = publicAPI.vtkWindowedSincPolyDataFilterExecute(input.getPoints(), input, output);
518
516
  output.setPointData(input.getPointData());
519
517
  output.setCellData(input.getCellData());
@@ -321,7 +321,11 @@ function vtkViewProxy(publicAPI, model) {
321
321
 
322
322
  // --------------------------------------------------------------------------
323
323
 
324
- publicAPI.setBackground = chain(model.renderer.setBackground, updateAnnotationColor);
324
+ publicAPI.setBackground = (...args) => {
325
+ const res = model.renderer.setBackground(...args);
326
+ updateAnnotationColor();
327
+ return res;
328
+ };
325
329
 
326
330
  // --------------------------------------------------------------------------
327
331
 
@@ -10,6 +10,10 @@ export interface IAbstractImageMapperInitialValues
10
10
  customDisplayExtent?: number[];
11
11
  useCustomExtents?: boolean;
12
12
  slice?: number;
13
+ backgroundColor?: RGBAColor;
14
+ colorTextureWidth?: number;
15
+ opacityTextureWidth?: number;
16
+ labelOutlineTextureWidth?: number;
13
17
  }
14
18
 
15
19
  export interface vtkAbstractImageMapper extends vtkAbstractMapper3D {
@@ -15,11 +15,30 @@ export interface IAbstractMapper3DInitialValues
15
15
  export interface vtkAbstractMapper3D extends vtkAbstractMapper {
16
16
  /**
17
17
  * Get the bounds for this mapper as [xmin, xmax, ymin, ymax,zmin, zmax].
18
- * @default 0
19
- * @return {Bounds} The bounds for the mapper.
18
+ * Bounds are (re)computed if needed.
19
+ * @return {Bounds} A copy of the bounds for the mapper.
20
+ * @see getBoundsByReference
21
+ * @see computeBounds
20
22
  */
21
23
  getBounds(): Bounds;
22
24
 
25
+ /**
26
+ * Get the bounds for this mapper as [xmin, xmax, ymin, ymax,zmin, zmax].
27
+ * Bounds are (re)computed if needed.
28
+ * @return {Bounds} The bounds array of the mapper.
29
+ * @see getBounds
30
+ * @see computeBounds
31
+ */
32
+ getBoundsByReference(): Bounds;
33
+
34
+ /**
35
+ * Compute the bounds for this mapper.
36
+ * Must be implemented by sub-classes. Called by getBounds methods.
37
+ * @see getBoundsByReference
38
+ * @see getBounds
39
+ */
40
+ computeBounds(): void;
41
+
23
42
  /**
24
43
  * Get the center of this mapper’s data.
25
44
  * @return {Vector3} The center of the mapper's data.
@@ -1,24 +1,32 @@
1
1
  import { m as macro } from '../../macros2.js';
2
2
  import vtkAbstractMapper from './AbstractMapper.js';
3
3
  import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
4
- import { I as createUninitializedBounds } from '../../Common/Core/Math/index.js';
5
4
 
6
5
  // ----------------------------------------------------------------------------
7
6
  // vtkAbstractMapper methods
8
7
  // ----------------------------------------------------------------------------
9
8
 
10
9
  function vtkAbstractMapper3D(publicAPI, model) {
10
+ publicAPI.computeBounds = () => {
11
+ macro.vtkErrorMacro(`vtkAbstractMapper3D.computeBounds - NOT IMPLEMENTED`);
12
+ };
13
+ const superGetBounds = publicAPI.getBounds;
11
14
  publicAPI.getBounds = () => {
12
- macro.vtkErrorMacro(`vtkAbstractMapper3D.getBounds - NOT IMPLEMENTED`);
13
- return createUninitializedBounds();
15
+ publicAPI.computeBounds();
16
+ return superGetBounds();
17
+ };
18
+ const superGetBoundsByReference = publicAPI.getBoundsByReference;
19
+ publicAPI.getBoundsByReference = () => {
20
+ publicAPI.computeBounds();
21
+ return superGetBoundsByReference();
14
22
  };
15
23
  publicAPI.getCenter = () => {
16
- const bounds = publicAPI.getBounds();
24
+ const bounds = publicAPI.getBoundsByReference();
17
25
  model.center = vtkBoundingBox.isValid(bounds) ? vtkBoundingBox.getCenter(bounds) : null;
18
26
  return model.center?.slice();
19
27
  };
20
28
  publicAPI.getLength = () => {
21
- const bounds = publicAPI.getBounds();
29
+ const bounds = publicAPI.getBoundsByReference();
22
30
  return vtkBoundingBox.getDiagonalLength(bounds);
23
31
  };
24
32
  }
@@ -41,6 +49,7 @@ function extend(publicAPI, model, initialValues = {}) {
41
49
  // Inheritance
42
50
  vtkAbstractMapper.extend(publicAPI, model, initialValues);
43
51
  macro.setGet(publicAPI, model, ['viewSpecificProperties']);
52
+ macro.getArray(publicAPI, model, ['bounds'], 6);
44
53
  vtkAbstractMapper3D(publicAPI, model);
45
54
  }
46
55
 
@@ -665,16 +665,19 @@ function vtkCubeAxesActor(publicAPI, model) {
665
665
  // as it relies on the pixel size of the window. Every time the camera
666
666
  // changes the bounds change. This method simplifies by just expanding
667
667
  // the grid bounds by a user specified factor.
668
- publicAPI.getBounds = () => {
668
+ publicAPI.computeBounds = () => {
669
669
  publicAPI.update();
670
670
  vtkBoundingBox.setBounds(model.bounds, model.gridActor.getBounds());
671
671
  vtkBoundingBox.scaleAboutCenter(model.bounds, model.boundsScaleFactor, model.boundsScaleFactor, model.boundsScaleFactor);
672
- return model.bounds;
673
672
  };
674
673
 
675
674
  // Make sure the grid share the actor property
676
- const _setProp = macro.chain(publicAPI.setProperty, model.gridActor.setProperty);
677
- publicAPI.setProperty = p => _setProp(p)[0];
675
+ const superSetProp = publicAPI.setProperty;
676
+ publicAPI.setProperty = p => {
677
+ const res = superSetProp(p);
678
+ model.gridActor.setProperty(p);
679
+ return res;
680
+ };
678
681
  }
679
682
 
680
683
  // ----------------------------------------------------------------------------
@@ -2,7 +2,7 @@ import { mat4, vec3, mat3 } from 'gl-matrix';
2
2
  import Constants from './Glyph3DMapper/Constants.js';
3
3
  import { m as macro } from '../../macros2.js';
4
4
  import vtkMapper from './Mapper.js';
5
- import { I as createUninitializedBounds, n as norm } from '../../Common/Core/Math/index.js';
5
+ import { n as norm } from '../../Common/Core/Math/index.js';
6
6
  import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
7
7
 
8
8
  const {
@@ -60,21 +60,15 @@ function vtkGlyph3DMapper(publicAPI, model) {
60
60
  }
61
61
  return idata.getPointData().getArray(model.scaleArray);
62
62
  };
63
- publicAPI.getBounds = () => {
64
- const idata = publicAPI.getInputData(0);
65
- const gdata = publicAPI.getInputData(1);
66
- if (!idata || !gdata) {
67
- return createUninitializedBounds();
68
- }
69
-
70
- // first we build the arrays used for the glyphing
71
- publicAPI.buildArrays();
72
- return model.bounds;
73
- };
63
+ publicAPI.computeBounds = () => publicAPI.buildArrays();
74
64
  publicAPI.buildArrays = () => {
75
65
  // if the mtgime requires it, rebuild
76
66
  const idata = publicAPI.getInputData(0);
77
67
  const gdata = publicAPI.getInputData(1);
68
+ if (!idata || !gdata) {
69
+ vtkBoundingBox.reset(model.bounds);
70
+ return;
71
+ }
78
72
  if (model.buildTime.getMTime() < gdata.getMTime() || model.buildTime.getMTime() < idata.getMTime() || model.buildTime.getMTime() < publicAPI.getMTime()) {
79
73
  const pts = idata.getPoints().getData();
80
74
  let sArray = publicAPI.getScaleArrayData();
@@ -95,12 +89,7 @@ function vtkGlyph3DMapper(publicAPI, model) {
95
89
  // overall bounds while building the arrays
96
90
  const corners = [];
97
91
  vtkBoundingBox.getCorners(gbounds, corners);
98
- model.bounds[0] = vtkBoundingBox.INIT_BOUNDS[0];
99
- model.bounds[1] = vtkBoundingBox.INIT_BOUNDS[1];
100
- model.bounds[2] = vtkBoundingBox.INIT_BOUNDS[2];
101
- model.bounds[3] = vtkBoundingBox.INIT_BOUNDS[3];
102
- model.bounds[4] = vtkBoundingBox.INIT_BOUNDS[4];
103
- model.bounds[5] = vtkBoundingBox.INIT_BOUNDS[5];
92
+ vtkBoundingBox.reset(model.bounds);
104
93
  const tcorner = new Float64Array(3);
105
94
  const oArray = publicAPI.getOrientationArrayData();
106
95
  const identity = mat4.identity(new Float64Array(16));
@@ -193,24 +182,7 @@ function vtkGlyph3DMapper(publicAPI, model) {
193
182
  // update bounds
194
183
  for (let p = 0; p < 8; ++p) {
195
184
  vec3.transformMat4(tcorner, corners[p], z);
196
- if (tcorner[0] < model.bounds[0]) {
197
- model.bounds[0] = tcorner[0];
198
- }
199
- if (tcorner[1] < model.bounds[2]) {
200
- model.bounds[2] = tcorner[1];
201
- }
202
- if (tcorner[2] < model.bounds[4]) {
203
- model.bounds[4] = tcorner[2];
204
- }
205
- if (tcorner[0] > model.bounds[1]) {
206
- model.bounds[1] = tcorner[0];
207
- }
208
- if (tcorner[1] > model.bounds[3]) {
209
- model.bounds[3] = tcorner[1];
210
- }
211
- if (tcorner[2] > model.bounds[5]) {
212
- model.bounds[5] = tcorner[2];
213
- }
185
+ vtkBoundingBox.addPoint(model.bounds, tcorner);
214
186
  }
215
187
  const n = new Float32Array(nbuff, i * 36, 9);
216
188
  mat3.fromMat4(n, z);
@@ -276,10 +248,6 @@ function extend(publicAPI, model, initialValues = {}) {
276
248
  macro.obj(model.buildTime, {
277
249
  mtime: 0
278
250
  });
279
- model.boundsTime = {};
280
- macro.obj(model.boundsTime, {
281
- mtime: 0
282
- });
283
251
  macro.setGet(publicAPI, model, ['orient', 'orientationMode', 'orientationArray', 'scaleArray', 'scaleFactor', 'scaleMode', 'scaling']);
284
252
  macro.get(publicAPI, model, ['colorArray', 'matrixArray', 'normalArray', 'buildTime']);
285
253
 
@@ -1,5 +1,6 @@
1
1
  import { m as macro } from '../../macros2.js';
2
2
  import vtkAbstractImageMapper from './AbstractImageMapper.js';
3
+ import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
3
4
  import vtkImageMapper from './ImageMapper.js';
4
5
  import { I as createUninitializedBounds } from '../../Common/Core/Math/index.js';
5
6
  import { intersectWithLineForPointPicking, intersectWithLineForCellPicking } from './AbstractImageMapper/helper.js';
@@ -80,13 +81,17 @@ function vtkImageArrayMapper(publicAPI, model) {
80
81
  }
81
82
  return null;
82
83
  };
83
- publicAPI.getBounds = () => {
84
+
85
+ // reimplemented from AbstractMapper3D
86
+ publicAPI.computeBounds = () => {
84
87
  const image = publicAPI.getCurrentImage();
85
88
  if (!image) {
86
- return createUninitializedBounds();
89
+ vtkBoundingBox.reset(model.bounds);
90
+ return;
87
91
  }
88
92
  if (!model.useCustomExtents) {
89
- return image.getBounds();
93
+ vtkBoundingBox.setBounds(model.bounds, image.getBounds());
94
+ return;
90
95
  }
91
96
  const ex = model.customDisplayExtent.slice();
92
97
  // use sub-slice of the current image,
@@ -94,7 +99,7 @@ function vtkImageArrayMapper(publicAPI, model) {
94
99
  const nSlice = publicAPI.getSubSlice();
95
100
  ex[4] = nSlice;
96
101
  ex[5] = nSlice;
97
- return image.extentToBounds(ex);
102
+ vtkBoundingBox.setBounds(model.bounds, image.extentToBounds(ex));
98
103
  };
99
104
  publicAPI.getBoundsForSlice = (slice = publicAPI.getSlice(), halfThickness = 0) => {
100
105
  const image = publicAPI.getImage(slice);
@@ -1,4 +1,5 @@
1
1
  import { quat, vec3, mat4 } from 'gl-matrix';
2
+ import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
2
3
  import CoincidentTopologyHelper from './Mapper/CoincidentTopologyHelper.js';
3
4
  import vtkAbstractImageMapper from './AbstractImageMapper.js';
4
5
  import { m as macro } from '../../macros2.js';
@@ -26,12 +27,12 @@ function vtkImageCPRMapper(publicAPI, model) {
26
27
  };
27
28
 
28
29
  /**
29
- * Public methods
30
+ * Reimplemented from AbstractMapper3D
30
31
  */
31
- publicAPI.getBounds = () => {
32
+ publicAPI.computeBounds = () => {
32
33
  const imageWidth = publicAPI.getWidth();
33
34
  const imageHeight = publicAPI.getHeight();
34
- return [0, imageWidth, 0, imageHeight, 0, 0];
35
+ vtkBoundingBox.setBounds(model.bounds, [0, imageWidth, 0, imageHeight, 0, 0]);
35
36
  };
36
37
  publicAPI.getOrientationDataArray = () => {
37
38
  const pointData = publicAPI.getInputData(1)?.getPointData();
@@ -1,6 +1,7 @@
1
1
  import Constants from './ImageMapper/Constants.js';
2
2
  import { m as macro } from '../../macros2.js';
3
3
  import vtkAbstractImageMapper from './AbstractImageMapper.js';
4
+ import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
4
5
  import { intersectWithLineForPointPicking, intersectWithLineForCellPicking } from './AbstractImageMapper/helper.js';
5
6
  import { F as clampValue, U as multiply3x3_vect3, I as createUninitializedBounds, V as getSparseOrthogonalMatrix } from '../../Common/Core/Math/index.js';
6
7
  import CoincidentTopologyHelper from './Mapper/CoincidentTopologyHelper.js';
@@ -186,13 +187,15 @@ function vtkImageMapper(publicAPI, model) {
186
187
  }
187
188
  return model.closestIJKAxis;
188
189
  };
189
- publicAPI.getBounds = () => {
190
+ publicAPI.computeBounds = () => {
190
191
  const image = publicAPI.getCurrentImage();
191
192
  if (!image) {
192
- return createUninitializedBounds();
193
+ vtkBoundingBox.reset(model.bounds);
194
+ return;
193
195
  }
194
196
  if (!model.useCustomExtents) {
195
- return image.getBounds();
197
+ vtkBoundingBox.setBounds(model.bounds, image.getBounds());
198
+ return;
196
199
  }
197
200
  const ex = model.customDisplayExtent.slice();
198
201
  const {
@@ -217,7 +220,7 @@ function vtkImageMapper(publicAPI, model) {
217
220
  ex[5] = nSlice;
218
221
  break;
219
222
  }
220
- return image.extentToBounds(ex);
223
+ vtkBoundingBox.setBounds(model.bounds, image.extentToBounds(ex));
221
224
  };
222
225
  publicAPI.getBoundsForSlice = (slice = model.slice, halfThickness = 0) => {
223
226
  const image = publicAPI.getCurrentImage();
@@ -21,6 +21,7 @@ export interface IImagePropertyInitialValues {
21
21
  useLookupTableScalarRange?: boolean;
22
22
  useLabelOutline?: boolean;
23
23
  labelOutlineThickness?: number | number[];
24
+ labelOutlineOpacity?: number | number[];
24
25
  }
25
26
 
26
27
  export interface vtkImageProperty extends vtkObject {
@@ -127,6 +128,12 @@ export interface vtkImageProperty extends vtkObject {
127
128
  */
128
129
  getLabelOutlineThickness(): number;
129
130
 
131
+ /**
132
+ * Get the label outline thickness array by reference.
133
+ * This returns the actual internal array, not a copy.
134
+ */
135
+ getLabelOutlineThicknessByReference(): number[];
136
+
130
137
  /**
131
138
  * It will set the label outline thickness for the labelmaps. It can accept
132
139
  * a single number or an array of numbers. If a single number is provided,
@@ -19,18 +19,18 @@ const {
19
19
  function vtkImageResliceMapper(publicAPI, model) {
20
20
  // Set our className
21
21
  model.classHierarchy.push('vtkImageResliceMapper');
22
- publicAPI.getBounds = () => {
23
- let bds = [...vtkBoundingBox.INIT_BOUNDS];
22
+ publicAPI.computeBounds = () => {
24
23
  const image = publicAPI.getInputData();
25
24
  if (publicAPI.getSlicePolyData()) {
26
- bds = publicAPI.getSlicePolyData().getBounds();
25
+ vtkBoundingBox.setBounds(model.bounds, publicAPI.getSlicePolyData().getBounds());
27
26
  } else if (image) {
28
- bds = image.getBounds();
27
+ vtkBoundingBox.setBounds(model.bounds, image.getBounds());
29
28
  if (publicAPI.getSlicePlane()) {
30
- vtkBoundingBox.cutWithPlane(bds, publicAPI.getSlicePlane().getOrigin(), publicAPI.getSlicePlane().getNormal());
29
+ vtkBoundingBox.cutWithPlane(model.bounds, publicAPI.getSlicePlane().getOrigin(), publicAPI.getSlicePlane().getNormal());
31
30
  }
31
+ } else {
32
+ vtkBoundingBox.reset(model.bounds);
32
33
  }
33
- return bds;
34
34
  };
35
35
  }
36
36
 
@@ -55,22 +55,22 @@ function vtkImageSlice(publicAPI, model) {
55
55
 
56
56
  //----------------------------------------------------------------------------
57
57
  // Get the minimum X bound
58
- publicAPI.getMinXBound = () => publicAPI.getBounds()[0];
58
+ publicAPI.getMinXBound = () => publicAPI.getBoundsByReference()[0];
59
59
 
60
60
  // Get the maximum X bound
61
- publicAPI.getMaxXBound = () => publicAPI.getBounds()[1];
61
+ publicAPI.getMaxXBound = () => publicAPI.getBoundsByReference()[1];
62
62
 
63
63
  // Get the minimum Y bound
64
- publicAPI.getMinYBound = () => publicAPI.getBounds()[2];
64
+ publicAPI.getMinYBound = () => publicAPI.getBoundsByReference()[2];
65
65
 
66
66
  // Get the maximum Y bound
67
- publicAPI.getMaxYBound = () => publicAPI.getBounds()[3];
67
+ publicAPI.getMaxYBound = () => publicAPI.getBoundsByReference()[3];
68
68
 
69
69
  // Get the minimum Z bound
70
- publicAPI.getMinZBound = () => publicAPI.getBounds()[4];
70
+ publicAPI.getMinZBound = () => publicAPI.getBoundsByReference()[4];
71
71
 
72
72
  // Get the maximum Z bound
73
- publicAPI.getMaxZBound = () => publicAPI.getBounds()[5];
73
+ publicAPI.getMaxZBound = () => publicAPI.getBoundsByReference()[5];
74
74
  publicAPI.getRedrawMTime = () => {
75
75
  let mt = model.mtime;
76
76
  if (model.mapper !== null) {
@@ -1,9 +1,10 @@
1
1
  import { m as macro } from '../../macros2.js';
2
2
  import vtkAbstractMapper3D from './AbstractMapper3D.js';
3
+ import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
3
4
  import vtkDataArray from '../../Common/Core/DataArray.js';
4
5
  import vtkImageData from '../../Common/DataModel/ImageData.js';
5
6
  import vtkLookupTable from '../../Common/Core/LookupTable.js';
6
- import { I as createUninitializedBounds, i as isNan } from '../../Common/Core/Math/index.js';
7
+ import { i as isNan } from '../../Common/Core/Math/index.js';
7
8
  import vtkScalarsToColors from '../../Common/Core/ScalarsToColors/Constants.js';
8
9
  import CoincidentTopologyHelper from './Mapper/CoincidentTopologyHelper.js';
9
10
  import Constants from './Mapper/Constants.js';
@@ -268,17 +269,16 @@ function getOrCreateColorTextureCoordinates(input, component, range, useLogScale
268
269
  function vtkMapper(publicAPI, model) {
269
270
  // Set our className
270
271
  model.classHierarchy.push('vtkMapper');
271
- publicAPI.getBounds = () => {
272
+ publicAPI.computeBounds = () => {
272
273
  const input = publicAPI.getInputData();
273
274
  if (!input) {
274
- model.bounds = createUninitializedBounds();
275
+ vtkBoundingBox.reset(model.bounds);
275
276
  } else {
276
277
  if (!model.static) {
277
278
  publicAPI.update();
278
279
  }
279
- model.bounds = input.getBounds();
280
+ vtkBoundingBox.setBounds(model.bounds, input.getBounds());
280
281
  }
281
- return model.bounds;
282
282
  };
283
283
  publicAPI.setForceCompileOnly = v => {
284
284
  model.forceCompileOnly = v;