@kitware/vtk.js 25.1.3 → 25.2.2

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,7 +1,9 @@
1
+ import vtkPiecewiseFunction from './../../Common/DataModel/PiecewiseFunction';
1
2
  import { vtkObject } from './../../interfaces';
3
+ import vtkColorTransferFunction from './ColorTransferFunction';
2
4
  import { InterpolationType, OpacityMode } from './VolumeProperty/Constants';
3
5
 
4
- interface IVolumePropertyInitialValues {
6
+ export interface IVolumePropertyInitialValues {
5
7
  independentComponents?: boolean;
6
8
  shade?: number;
7
9
  ambient?: number;
@@ -33,7 +35,7 @@ export interface vtkVolumeProperty extends vtkObject {
33
35
 
34
36
  /**
35
37
  *
36
- * @param {Number} index
38
+ * @param {Number} index
37
39
  */
38
40
  getColorChannels(index: number): number;
39
41
 
@@ -44,25 +46,25 @@ export interface vtkVolumeProperty extends vtkObject {
44
46
 
45
47
  /**
46
48
  *
47
- * @param {Number} index
49
+ * @param {Number} index
48
50
  */
49
51
  getGradientOpacityMaximumOpacity(index: number): number;
50
52
 
51
53
  /**
52
54
  *
53
- * @param {Number} index
55
+ * @param {Number} index
54
56
  */
55
57
  getGradientOpacityMaximumValue(index: number): number;
56
58
 
57
59
  /**
58
60
  *
59
- * @param {Number} index
61
+ * @param {Number} index
60
62
  */
61
63
  getGradientOpacityMinimumOpacity(index: number): number;
62
64
 
63
65
  /**
64
66
  *
65
- * @param {Number} index
67
+ * @param {Number} index
66
68
  */
67
69
  getGradientOpacityMinimumValue(index: number): number;
68
70
 
@@ -73,15 +75,15 @@ export interface vtkVolumeProperty extends vtkObject {
73
75
 
74
76
  /**
75
77
  * Get the unit distance on which the scalar opacity transfer function is defined.
76
- * @param {Number} index
78
+ * @param {Number} index
77
79
  */
78
80
  getScalarOpacityUnitDistance(index: number): number;
79
81
 
80
82
  /**
81
83
  * Get the currently set gray transfer function. Create one if none set.
82
- * @param {Number} index
84
+ * @param {Number} index
83
85
  */
84
- getGrayTransferFunction(index: number): any;
86
+ getGrayTransferFunction(index: number): vtkPiecewiseFunction;
85
87
 
86
88
  /**
87
89
  *
@@ -98,13 +100,13 @@ export interface vtkVolumeProperty extends vtkObject {
98
100
  * Get the currently set RGB transfer function. Create one if none set.
99
101
  * @param {Number} index
100
102
  */
101
- getRGBTransferFunction(index: number): any;
103
+ getRGBTransferFunction(index: number): vtkColorTransferFunction;
102
104
 
103
105
  /**
104
106
  * Get the scalar opacity transfer function. Create one if none set.
105
107
  * @param {Number} index
106
108
  */
107
- getScalarOpacity(index: number): any;
109
+ getScalarOpacity(index: number): vtkPiecewiseFunction;
108
110
 
109
111
  /**
110
112
  * Get the shading of a volume.
@@ -147,37 +149,37 @@ export interface vtkVolumeProperty extends vtkObject {
147
149
  /**
148
150
  *
149
151
  * @param {Number} index
150
- * @param {Number} value
152
+ * @param {Number} value
151
153
  */
152
154
  setGradientOpacityMaximumOpacity(index: number, value: number): boolean;
153
155
 
154
156
  /**
155
157
  *
156
158
  * @param {Number} index
157
- * @param {Number} value
159
+ * @param {Number} value
158
160
  */
159
161
  setGradientOpacityMaximumValue(index: number, value: number): boolean;
160
162
 
161
163
  /**
162
164
  *
163
165
  * @param {Number} index
164
- * @param {Number} value
166
+ * @param {Number} value
165
167
  */
166
168
  setGradientOpacityMinimumOpacity(index: number, value: number): boolean;
167
169
 
168
170
  /**
169
171
  *
170
172
  * @param {Number} index
171
- * @param {Number} value
173
+ * @param {Number} value
172
174
  */
173
175
  setGradientOpacityMinimumValue(index: number, value: number): boolean;
174
176
 
175
177
  /**
176
178
  * Set the color of a volume to a gray transfer function
177
179
  * @param {Number} index
178
- * @param func
180
+ * @param {vtkPiecewiseFunction} func
179
181
  */
180
- setGrayTransferFunction(index: number, func: any): boolean;
182
+ setGrayTransferFunction(index: number, func: vtkPiecewiseFunction): boolean;
181
183
 
182
184
  /**
183
185
  * Does the data have independent components, or do some define color only?
@@ -204,14 +206,14 @@ export interface vtkVolumeProperty extends vtkObject {
204
206
 
205
207
  /**
206
208
  *
207
- * @param {Number} labelOutlineThickness
209
+ * @param {Number} labelOutlineThickness
208
210
  */
209
211
  setLabelOutlineThickness(labelOutlineThickness: number): boolean;
210
212
 
211
213
  /**
212
214
  *
213
215
  * @param {Number} index
214
- * @param {Number} value
216
+ * @param {Number} value
215
217
  */
216
218
  setOpacityMode(index: number, value: number): boolean;
217
219
 
@@ -219,7 +221,7 @@ export interface vtkVolumeProperty extends vtkObject {
219
221
  * Set the unit distance on which the scalar opacity transfer function is
220
222
  * defined.
221
223
  * @param {Number} index
222
- * @param {Number} value
224
+ * @param {Number} value
223
225
  */
224
226
  setScalarOpacityUnitDistance(index: number, value: number): boolean;
225
227
 
@@ -234,7 +236,7 @@ export interface vtkVolumeProperty extends vtkObject {
234
236
  * turning shading off is generally the same as setting ambient=1,
235
237
  * diffuse=0, specular=0. Shading can be independently turned on/off per
236
238
  * component.
237
- * @param {Number} shade
239
+ * @param {Number} shade
238
240
  */
239
241
  setShade(shade: number): boolean;
240
242
 
@@ -252,35 +254,35 @@ export interface vtkVolumeProperty extends vtkObject {
252
254
 
253
255
  /**
254
256
  *
255
- * @param {Boolean} index
256
- * @param {Number} value
257
+ * @param {Number} index
258
+ * @param {Boolean} value
257
259
  */
258
260
  setUseGradientOpacity(index: number, value: boolean): boolean;
259
261
 
260
262
  /**
261
263
  *
262
- * @param {Boolean} useLabelOutline
264
+ * @param {Boolean} useLabelOutline
263
265
  */
264
266
  setUseLabelOutline(useLabelOutline: boolean): boolean;
265
267
 
266
268
  /**
267
269
  * Set the color of a volume to an RGB transfer function
268
270
  * @param {Number} index
269
- * @param func
271
+ * @param {vtkColorTransferFunction} func
270
272
  */
271
- setRGBTransferFunction(index: number, func: any): boolean;
273
+ setRGBTransferFunction(index: number, func: vtkColorTransferFunction): boolean;
272
274
 
273
275
  /**
274
276
  * Set the scalar opacity of a volume to a transfer function
275
277
  * @param {Number} index
276
- * @param func
278
+ * @param {vtkPiecewiseFunction} func
277
279
  */
278
- setScalarOpacity(index: number, func: any): boolean;
280
+ setScalarOpacity(index: number, func: vtkPiecewiseFunction): boolean;
279
281
 
280
282
  /**
281
283
  * Set the scalar component weights.
282
284
  * @param {Number} index
283
- * @param {Number} value
285
+ * @param {Number} value
284
286
  */
285
287
  setComponentWeight(index: number, value: number): boolean;
286
288
 
@@ -292,7 +294,7 @@ export interface vtkVolumeProperty extends vtkObject {
292
294
 
293
295
  /**
294
296
  * Set the interpolation type for sampling a volume.
295
- * @param {InterpolationType} interpolationType
297
+ * @param {InterpolationType} interpolationType
296
298
  */
297
299
  setInterpolationType(interpolationType: InterpolationType): boolean;
298
300
 
@@ -405,8 +405,6 @@ function vtkOpenGLImageMapper(publicAPI, model) {
405
405
  numClipPlanes = 6;
406
406
  }
407
407
 
408
- var image = model.currentInput;
409
- var w2imat4 = image.getWorldToIndex();
410
408
  var shiftScaleEnabled = cellBO.getCABO().getCoordShiftAndScaleEnabled();
411
409
  var inverseShiftScaleMatrix = shiftScaleEnabled ? cellBO.getCABO().getInverseShiftAndScaleMatrix() : null;
412
410
  var mat = inverseShiftScaleMatrix ? mat4.copy(model.imagematinv, actor.getMatrix()) : actor.getMatrix();
@@ -415,9 +413,11 @@ function vtkOpenGLImageMapper(publicAPI, model) {
415
413
  mat4.transpose(mat, mat);
416
414
  mat4.multiply(mat, mat, inverseShiftScaleMatrix);
417
415
  mat4.transpose(mat, mat);
418
- }
416
+ } // transform crop plane normal with transpose(inverse(worldToIndex))
417
+
419
418
 
420
- mat4.multiply(model.imagematinv, mat, w2imat4);
419
+ mat4.transpose(model.imagemat, model.currentInput.getIndexToWorld());
420
+ mat4.multiply(model.imagematinv, mat, model.imagemat);
421
421
  var planeEquations = [];
422
422
 
423
423
  for (var _i3 = 0; _i3 < numClipPlanes; _i3++) {
@@ -99,9 +99,7 @@ function vtkShaderCache(publicAPI, model) {
99
99
  var hashInput = "".concat(vertexCode).concat(fragmentCode).concat(geometryCode);
100
100
  var result = Md5.hash(hashInput); // does it already exist?
101
101
 
102
- var loc = Object.keys(model.shaderPrograms).indexOf(result);
103
-
104
- if (loc === -1) {
102
+ if (!(result in model.shaderPrograms)) {
105
103
  // create one
106
104
  var sps = vtkShaderProgram.newInstance();
107
105
  sps.setContext(model.context);
@@ -478,9 +478,7 @@ function vtkShaderProgram(publicAPI, model) {
478
478
  } // see if we have cached the result
479
479
 
480
480
 
481
- var loc = Object.keys(model.attributeLocs).indexOf(name);
482
-
483
- if (loc !== -1) {
481
+ if (name in model.attributeLocs) {
484
482
  return true;
485
483
  }
486
484
 
@@ -489,7 +487,7 @@ function vtkShaderProgram(publicAPI, model) {
489
487
  return false;
490
488
  }
491
489
 
492
- loc = model.context.getAttribLocation(model.handle, name);
490
+ var loc = model.context.getAttribLocation(model.handle, name);
493
491
 
494
492
  if (loc === -1) {
495
493
  return false;