@kitware/vtk.js 27.4.0 → 27.4.1

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,6 +1,7 @@
1
1
  import { vtkObject } from './../../interfaces';
2
2
  import { ColorMode } from './../../Rendering/Core/Mapper/Constants';
3
3
  import { Range } from './../../types';
4
+ import vtkDataArray from './DataArray';
4
5
  import { ScalarMappingTarget, VectorMode } from './ScalarsToColors/Constants';
5
6
 
6
7
  /**
@@ -132,9 +133,15 @@ export interface vtkScalarsToColors extends vtkObject {
132
133
  * Returns false if scalars are Uint8 LA or RGBA with A < 255,
133
134
  * otherwise rely on getAlpha() in case of direct mapping,
134
135
  * otherwise return isOpaque()
136
+ *
135
137
  * @see isOpaque, getAlpha
138
+ *
139
+ * @param {vtkDataArray} scalars
140
+ * @param {ColorMode} colorMode
141
+ * @param {Number} componentIn
142
+ *
136
143
  */
137
- areScalarsOpaque(scalars, colorMode, componentIn): boolean;
144
+ areScalarsOpaque(scalars: vtkDataArray, colorMode: ColorMode, componentIn: number): boolean;
138
145
 
139
146
  /**
140
147
  *
@@ -22,7 +22,7 @@ function _equals(a, b) {
22
22
  }
23
23
 
24
24
  function _isValid(bounds) {
25
- return bounds[0] <= bounds[1] && bounds[2] <= bounds[3] && bounds[4] <= bounds[5];
25
+ return (bounds === null || bounds === void 0 ? void 0 : bounds.length) >= 6 && bounds[0] <= bounds[1] && bounds[2] <= bounds[3] && bounds[4] <= bounds[5];
26
26
  }
27
27
 
28
28
  function _setBounds(bounds, otherBounds) {
@@ -275,8 +275,7 @@ function _getCorners(bounds, corners) {
275
275
  for (var ix = 0; ix < 2; ix++) {
276
276
  for (var iy = 2; iy < 4; iy++) {
277
277
  for (var iz = 4; iz < 6; iz++) {
278
- corners[count] = [bounds[ix], bounds[iy], bounds[iz]];
279
- count++;
278
+ corners[count++] = [bounds[ix], bounds[iy], bounds[iz]];
280
279
  }
281
280
  }
282
281
  }
@@ -297,16 +296,14 @@ function _computeCornerPoints(bounds, point1, point2) {
297
296
  function _transformBounds(bounds, transform) {
298
297
  var out = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
299
298
 
300
- if (out.length < 6) {
301
- _reset(out);
302
- }
303
-
304
299
  var corners = _getCorners(bounds, []);
305
300
 
306
301
  for (var i = 0; i < corners.length; ++i) {
307
302
  vec3.transformMat4(corners[i], corners[i], transform);
308
303
  }
309
304
 
305
+ _reset(out);
306
+
310
307
  return _addPoints(out, corners);
311
308
  }
312
309
 
@@ -146,8 +146,8 @@ function vtkLandmarkTransform(publicAPI, model) {
146
146
  model.targetLandmark.getPoint(0, t0);
147
147
  model.sourceLandmark.getPoint(1, s1);
148
148
  model.targetLandmark.getPoint(1, t1);
149
- var ds;
150
- var dt;
149
+ var ds = [0, 0, 0];
150
+ var dt = [0, 0, 0];
151
151
  var rs = 0;
152
152
  var rt = 0;
153
153
 
@@ -50,7 +50,7 @@ function getPropCoarseHull(prop) {
50
50
  var mapper = prop === null || prop === void 0 ? void 0 : (_prop$getMapper = prop.getMapper) === null || _prop$getMapper === void 0 ? void 0 : _prop$getMapper.call(prop);
51
51
  var mapperBounds = mapper === null || mapper === void 0 ? void 0 : (_mapper$getBounds = mapper.getBounds) === null || _mapper$getBounds === void 0 ? void 0 : _mapper$getBounds.call(mapper);
52
52
 
53
- if (mapperBounds && vtkBoundingBox.isValid(mapperBounds) && prop.getMatrix) {
53
+ if (vtkBoundingBox.isValid(mapperBounds) && prop.getMatrix) {
54
54
  var _mapper$getInputData;
55
55
 
56
56
  finestBounds = mapperBounds;
@@ -49,8 +49,9 @@ export interface vtkImageArrayMapper extends vtkAbstractImageMapper {
49
49
 
50
50
  /**
51
51
  * Get the bounds for a given slice as [xmin, xmax, ymin, ymax,zmin, zmax].
52
- * @param {Number} [slice] The slice index.
53
- * @param {Number} [halfThickness] Half the slice thickness in index space (unit voxel spacing).
52
+ * @param {Number} [slice] The slice index. If undefined, the current slice is considered.
53
+ * @param {Number} [halfThickness] Half the slice thickness in index space (unit voxel
54
+ * spacing). If undefined, 0 is considered.
54
55
  * @return {Number[]} The bounds for a given slice.
55
56
  */
56
57
  getBoundsForSlice(slice?: number, halfThickness?: number): number[];
@@ -43,8 +43,9 @@ export interface vtkImageMapper extends vtkAbstractImageMapper {
43
43
 
44
44
  /**
45
45
  * Get the bounds for a given slice as [xmin, xmax, ymin, ymax,zmin, zmax].
46
- * @param {Number} [slice] The slice index.
47
- * @param {Number} [halfThickness] Half the slice thickness in index space (unit voxel spacing).
46
+ * @param {Number} [slice] The slice index. If undefined, the current slice is considered.
47
+ * @param {Number} [halfThickness] Half the slice thickness in index space (unit voxel
48
+ * spacing). If undefined, 0 is considered.
48
49
  * @return {Number[]} The bounds for a given slice.
49
50
  */
50
51
  getBoundsForSlice(slice?: number, halfThickness?: number): number[];
@@ -132,8 +132,7 @@ function vtkImageMapper(publicAPI, model) {
132
132
 
133
133
  publicAPI.getSlicingModeNormal = function () {
134
134
  var out = [0, 0, 0];
135
- var a = publicAPI.getCurrentImage().getDirection();
136
- var mat3 = [[a[0], a[1], a[2]], [a[3], a[4], a[5]], [a[6], a[7], a[8]]];
135
+ var mat3 = publicAPI.getCurrentImage().getDirection();
137
136
 
138
137
  switch (model.slicingMode) {
139
138
  case SlicingMode.X:
@@ -31,11 +31,11 @@ export interface vtkImageSlice extends vtkProp3D {
31
31
 
32
32
  /**
33
33
  * Get the bounds for a given slice as [xmin, xmax, ymin, ymax,zmin, zmax].
34
- * @param {Number} slice The slice index.
35
- * @param {Number} [thickness] The slice thickness.
34
+ * @param {Number} slice The slice index. If undefined, the current slice is considered.
35
+ * @param {Number} [thickness] The slice thickness. If undefined, 0 is considered.
36
36
  * @return {Bounds} The bounds for a given slice.
37
37
  */
38
- getBoundsForSlice(slice: number, thickness?: number): Bounds;
38
+ getBoundsForSlice(slice?: number, thickness?: number): Bounds;
39
39
 
40
40
  /**
41
41
  *
@@ -1,4 +1,5 @@
1
- import { mat4, vec3 } from 'gl-matrix';
1
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
2
+ import { mat4 } from 'gl-matrix';
2
3
  import macro from '../../macros.js';
3
4
  import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
4
5
  import vtkProp3D from './Prop3D.js';
@@ -101,101 +102,60 @@ function vtkImageSlice(publicAPI, model) {
101
102
  model.mapperBounds = bds.map(function (x) {
102
103
  return x;
103
104
  });
104
- var bbox = [];
105
- vtkBoundingBox.getCorners(bds, bbox);
106
105
  publicAPI.computeMatrix();
107
106
  var tmp4 = new Float64Array(16);
108
107
  mat4.transpose(tmp4, model.matrix);
109
- bbox.forEach(function (pt) {
110
- return vec3.transformMat4(pt, pt, tmp4);
111
- });
112
- /* eslint-disable no-multi-assign */
113
-
114
- model.bounds[0] = model.bounds[2] = model.bounds[4] = Number.MAX_VALUE;
115
- model.bounds[1] = model.bounds[3] = model.bounds[5] = -Number.MAX_VALUE;
116
- /* eslint-enable no-multi-assign */
117
-
118
- model.bounds = model.bounds.map(function (d, i) {
119
- return i % 2 === 0 ? bbox.reduce(function (a, b) {
120
- return a > b[i / 2] ? b[i / 2] : a;
121
- }, d) : bbox.reduce(function (a, b) {
122
- return a < b[(i - 1) / 2] ? b[(i - 1) / 2] : a;
123
- }, d);
124
- });
108
+ vtkBoundingBox.transformBounds(bds, tmp4, model.bounds);
125
109
  model.boundsMTime.modified();
126
110
  }
127
111
 
128
112
  return model.bounds;
129
113
  };
130
114
 
131
- publicAPI.getBoundsForSlice = function (slice) {
132
- var thickness = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
115
+ publicAPI.getBoundsForSlice = function (slice, thickness) {
133
116
  // Check for the special case when the mapper's bounds are unknown
134
- var bds = model.mapper.getBoundsForSlice(slice, thickness);
135
-
136
- if (!bds || bds.length !== 6) {
137
- return bds;
138
- } // Check for the special case when the actor is empty.
117
+ var bds = model.mapper.getBoundsForSlice(slice, thickness); // Check for the special case when the actor is empty.
139
118
 
140
-
141
- if (bds[0] > bds[1]) {
119
+ if (!vtkBoundingBox.isValid(bds)) {
142
120
  return bds;
143
121
  }
144
122
 
145
- var bbox = [];
146
- vtkBoundingBox.getCorners(bds, bbox);
147
123
  publicAPI.computeMatrix();
148
124
  var tmp4 = new Float64Array(16);
149
125
  mat4.transpose(tmp4, model.matrix);
150
- bbox.forEach(function (pt) {
151
- return vec3.transformMat4(pt, pt, tmp4);
152
- });
153
- var newBounds = [Number.MAX_VALUE, -Number.MAX_VALUE, Number.MAX_VALUE, -Number.MAX_VALUE, Number.MAX_VALUE, -Number.MAX_VALUE];
154
- newBounds = newBounds.map(function (d, i) {
155
- return i % 2 === 0 ? bbox.reduce(function (a, b) {
156
- return a > b[i / 2] ? b[i / 2] : a;
157
- }, d) : bbox.reduce(function (a, b) {
158
- return a < b[(i - 1) / 2] ? b[(i - 1) / 2] : a;
159
- }, d);
160
- });
126
+ var newBounds = vtkBoundingBox.transformBounds(bds, tmp4);
161
127
  return newBounds;
162
128
  }; //----------------------------------------------------------------------------
163
129
  // Get the minimum X bound
164
130
 
165
131
 
166
132
  publicAPI.getMinXBound = function () {
167
- publicAPI.getBounds();
168
- return model.bounds[0];
133
+ return publicAPI.getBounds()[0];
169
134
  }; // Get the maximum X bound
170
135
 
171
136
 
172
137
  publicAPI.getMaxXBound = function () {
173
- publicAPI.getBounds();
174
- return model.bounds[1];
138
+ return publicAPI.getBounds()[1];
175
139
  }; // Get the minimum Y bound
176
140
 
177
141
 
178
142
  publicAPI.getMinYBound = function () {
179
- publicAPI.getBounds();
180
- return model.bounds[2];
143
+ return publicAPI.getBounds()[2];
181
144
  }; // Get the maximum Y bound
182
145
 
183
146
 
184
147
  publicAPI.getMaxYBound = function () {
185
- publicAPI.getBounds();
186
- return model.bounds[3];
148
+ return publicAPI.getBounds()[3];
187
149
  }; // Get the minimum Z bound
188
150
 
189
151
 
190
152
  publicAPI.getMinZBound = function () {
191
- publicAPI.getBounds();
192
- return model.bounds[4];
153
+ return publicAPI.getBounds()[4];
193
154
  }; // Get the maximum Z bound
194
155
 
195
156
 
196
157
  publicAPI.getMaxZBound = function () {
197
- publicAPI.getBounds();
198
- return model.bounds[5];
158
+ return publicAPI.getBounds()[5];
199
159
  };
200
160
 
201
161
  publicAPI.getMTime = function () {
@@ -249,7 +209,7 @@ function vtkImageSlice(publicAPI, model) {
249
209
  var DEFAULT_VALUES = {
250
210
  mapper: null,
251
211
  property: null,
252
- bounds: [1, -1, 1, -1, 1, -1]
212
+ bounds: _toConsumableArray(vtkBoundingBox.INIT_BOUNDS)
253
213
  }; // ----------------------------------------------------------------------------
254
214
 
255
215
  function extend(publicAPI, model) {
@@ -3,7 +3,7 @@ import vtkRenderer from './../../Rendering/Core/Renderer';
3
3
  import vtkWidgetState from './WidgetState';
4
4
  import { ViewTypes } from './WidgetManager/Constants';
5
5
  import { Bounds, Nullable } from './../../types';
6
- import { EventHandler, vtkSubscription } from './../../interfaces';
6
+ import { EventHandler, vtkSubscription, vtkObject } from './../../interfaces';
7
7
 
8
8
  export interface IGetWidgetForViewParams {
9
9
  viewId: number;
@@ -12,7 +12,7 @@ export interface IGetWidgetForViewParams {
12
12
  initialValues?: object;
13
13
  }
14
14
 
15
- export interface vtkAbstractWidgetFactory {
15
+ export interface vtkAbstractWidgetFactory extends vtkObject {
16
16
  /**
17
17
  * Will return the widget associated with the view with Id id `locator.viewId`.
18
18
  * If there is no widget associated with the view, a new widget will be constructed, provided
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "27.4.0",
3
+ "version": "27.4.1",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",