@kitware/vtk.js 33.0.0-beta.4 → 33.0.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.
Files changed (44) hide show
  1. package/BREAKING_CHANGES.md +0 -3
  2. package/Common/Core/ScalarsToColors/Constants.js +7 -2
  3. package/Common/Core/ScalarsToColors.js +3 -1
  4. package/Rendering/Core/Actor.d.ts +20 -5
  5. package/Rendering/Core/Actor.js +68 -5
  6. package/Rendering/Core/ColorTransferFunction.js +26 -35
  7. package/Rendering/Core/ImageCPRMapper.d.ts +20 -1
  8. package/Rendering/Core/ImageCPRMapper.js +2 -1
  9. package/Rendering/Core/ImageProperty.d.ts +1 -20
  10. package/Rendering/Core/ImageProperty.js +5 -7
  11. package/Rendering/Core/ImageResliceMapper.d.ts +20 -1
  12. package/Rendering/Core/ImageResliceMapper.js +2 -1
  13. package/Rendering/Core/ImageSlice.d.ts +23 -7
  14. package/Rendering/Core/ImageSlice.js +68 -9
  15. package/Rendering/Core/Mapper.js +8 -16
  16. package/Rendering/Core/Prop3D.d.ts +2 -39
  17. package/Rendering/Core/Prop3D.js +2 -81
  18. package/Rendering/Core/ScalarBarActor.js +4 -2
  19. package/Rendering/Core/Volume.d.ts +20 -5
  20. package/Rendering/Core/Volume.js +70 -2
  21. package/Rendering/Core/VolumeMapper/Constants.d.ts +7 -0
  22. package/Rendering/Core/VolumeMapper/Constants.js +8 -2
  23. package/Rendering/Core/VolumeMapper.d.ts +173 -16
  24. package/Rendering/Core/VolumeMapper.js +51 -16
  25. package/Rendering/Core/VolumeProperty/Constants.d.ts +3 -12
  26. package/Rendering/Core/VolumeProperty/Constants.js +4 -11
  27. package/Rendering/Core/VolumeProperty.d.ts +5 -140
  28. package/Rendering/Core/VolumeProperty.js +7 -54
  29. package/Rendering/OpenGL/CellArrayBufferObject/helpers.js +45 -0
  30. package/Rendering/OpenGL/CellArrayBufferObject.js +6 -25
  31. package/Rendering/OpenGL/ImageCPRMapper.js +21 -30
  32. package/Rendering/OpenGL/ImageMapper.js +27 -27
  33. package/Rendering/OpenGL/ImageResliceMapper.js +183 -271
  34. package/Rendering/OpenGL/PolyDataMapper.js +8 -1
  35. package/Rendering/OpenGL/RenderWindow/resourceSharingHelper.d.ts +3 -3
  36. package/Rendering/OpenGL/RenderWindow/resourceSharingHelper.js +5 -8
  37. package/Rendering/OpenGL/SphereMapper.js +33 -13
  38. package/Rendering/OpenGL/VolumeMapper.js +784 -722
  39. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  40. package/Rendering/WebGPU/VolumePassFSQ.js +2 -2
  41. package/index.d.ts +0 -1
  42. package/macros2.js +1 -1
  43. package/package.json +1 -1
  44. package/Interaction/Manipulators/KeyboardCameraManipulator.d.ts +0 -113
@@ -1,6 +1,3 @@
1
- ## From 32.x to 33
2
-
3
- - **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`.
4
1
  ## From 31.x to 32
5
2
 
6
3
  - **vtkMapper**: remove `mapScalarsToTexture` from the public API. The function becomes protected and its API changes. This shouldn't cause any issue in most cases.
@@ -9,9 +9,14 @@ const ScalarMappingTarget = {
9
9
  RGB: 3,
10
10
  RGBA: 4
11
11
  };
12
+ const Scale = {
13
+ LINEAR: 0,
14
+ LOG10: 1
15
+ };
12
16
  var vtkScalarsToColors = {
13
17
  VectorMode,
14
- ScalarMappingTarget
18
+ ScalarMappingTarget,
19
+ Scale
15
20
  };
16
21
 
17
- export { ScalarMappingTarget, VectorMode, vtkScalarsToColors as default };
22
+ export { ScalarMappingTarget, Scale, VectorMode, vtkScalarsToColors as default };
@@ -5,6 +5,7 @@ import Constants from '../../Rendering/Core/Mapper/Constants.js';
5
5
 
6
6
  const {
7
7
  ScalarMappingTarget,
8
+ Scale,
8
9
  VectorMode
9
10
  } = vtkScalarsToColors$2;
10
11
  const {
@@ -469,7 +470,8 @@ const DEFAULT_VALUES = {
469
470
  mappingRange: null,
470
471
  annotationArray: null,
471
472
  annotatedValueMap: null,
472
- indexedLookup: false
473
+ indexedLookup: false,
474
+ scale: Scale.LINEAR
473
475
  };
474
476
 
475
477
  // ----------------------------------------------------------------------------
@@ -36,6 +36,12 @@ export interface vtkActor extends vtkProp3D {
36
36
  */
37
37
  getBackfaceProperty(): vtkProperty;
38
38
 
39
+ /**
40
+ * Get the bounds for this mapper as [xmin, xmax, ymin, ymax,zmin, zmax].
41
+ * @return {Bounds} The bounds for the mapper.
42
+ */
43
+ getBounds(): Bounds;
44
+
39
45
  /**
40
46
  * Check whether the opaque is forced or not.
41
47
  */
@@ -57,6 +63,16 @@ export interface vtkActor extends vtkProp3D {
57
63
  */
58
64
  getMapper(): Nullable<vtkMapper>;
59
65
 
66
+ /**
67
+ * Get the property object that controls this actors surface
68
+ * properties. This should be an instance of a vtkProperty object. Every
69
+ * actor must have a property associated with it. If one isn’t specified,
70
+ * then one will be generated automatically. Multiple actors can share one
71
+ * property object.
72
+ * @return {vtkProperty} The property object
73
+ */
74
+ getProperty(): vtkProperty;
75
+
60
76
  /**
61
77
  * Check whether if the actor supports selection
62
78
  * @return {Boolean} true if the actor support selection.
@@ -95,12 +111,11 @@ export interface vtkActor extends vtkProp3D {
95
111
  */
96
112
  setMapper(mapper: vtkMapper): boolean;
97
113
 
98
- // Inherited from vtkProp3D, but takes a vtkProperty instead of a generic vtkObject
99
- getProperty(mapperInputPort?: number): vtkProperty;
100
- getProperties(): vtkProperty[];
101
- setProperty(mapperInputPort: number, property: vtkProperty): boolean;
114
+ /**
115
+ * Set the property object that controls this actors surface properties.
116
+ * @param {vtkProperty} property The vtkProperty instance.
117
+ */
102
118
  setProperty(property: vtkProperty): boolean;
103
- setProperties(properties: vtkProperty[]): boolean;
104
119
  }
105
120
 
106
121
  /**
@@ -1,7 +1,13 @@
1
+ import { mat4, vec3 } from 'gl-matrix';
1
2
  import { m as macro } from '../../macros2.js';
3
+ import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
2
4
  import vtkProp3D from './Prop3D.js';
3
5
  import vtkProperty from './Property.js';
4
6
 
7
+ const {
8
+ vtkDebugMacro
9
+ } = macro;
10
+
5
11
  // ----------------------------------------------------------------------------
6
12
  // vtkActor methods
7
13
  // ----------------------------------------------------------------------------
@@ -23,11 +29,11 @@ function vtkActor(publicAPI, model) {
23
29
  return false;
24
30
  }
25
31
  // make sure we have a property
26
- if (!model.properties[0]) {
32
+ if (!model.property) {
27
33
  // force creation of a property
28
34
  publicAPI.getProperty();
29
35
  }
30
- let isOpaque = model.properties[0].getOpacity() >= 1.0;
36
+ let isOpaque = model.property.getOpacity() >= 1.0;
31
37
 
32
38
  // are we using an opaque texture, if any?
33
39
  isOpaque = isOpaque && (!model.texture || !model.texture.isTranslucent());
@@ -41,17 +47,71 @@ function vtkActor(publicAPI, model) {
41
47
  return false;
42
48
  }
43
49
  // make sure we have a property
44
- if (!model.properties[0]) {
50
+ if (model.property === null) {
45
51
  // force creation of a property
46
- publicAPI.getProperty();
52
+ publicAPI.setProperty(publicAPI.makeProperty());
47
53
  }
48
54
 
49
55
  // is this actor opaque ?
50
56
  return !publicAPI.getIsOpaque();
51
57
  };
52
58
  publicAPI.makeProperty = vtkProperty.newInstance;
59
+ publicAPI.getProperty = () => {
60
+ if (model.property === null) {
61
+ model.property = publicAPI.makeProperty();
62
+ }
63
+ return model.property;
64
+ };
65
+ publicAPI.getBounds = () => {
66
+ if (model.mapper === null) {
67
+ return model.bounds;
68
+ }
69
+
70
+ // Check for the special case when the mapper's bounds are unknown
71
+ const bds = model.mapper.getBounds();
72
+ if (!bds || bds.length !== 6) {
73
+ return bds;
74
+ }
75
+
76
+ // Check for the special case when the actor is empty.
77
+ if (bds[0] > bds[1]) {
78
+ model.mapperBounds = bds.concat(); // copy the mapper's bounds
79
+ model.bounds = [1, -1, 1, -1, 1, -1];
80
+ model.boundsMTime.modified();
81
+ return bds;
82
+ }
83
+
84
+ // Check if we have cached values for these bounds - we cache the
85
+ // values returned by model.mapper.getBounds() and we store the time
86
+ // of caching. If the values returned this time are different, or
87
+ // the modified time of this class is newer than the cached time,
88
+ // then we need to rebuild.
89
+ if (!model.mapperBounds || bds[0] !== model.mapperBounds[0] || bds[1] !== model.mapperBounds[1] || bds[2] !== model.mapperBounds[2] || bds[3] !== model.mapperBounds[3] || bds[4] !== model.mapperBounds[4] || bds[5] !== model.mapperBounds[5] || publicAPI.getMTime() > model.boundsMTime.getMTime()) {
90
+ vtkDebugMacro('Recomputing bounds...');
91
+ model.mapperBounds = bds.concat(); // copy the mapper's bounds
92
+ const bbox = [];
93
+ vtkBoundingBox.getCorners(bds, bbox);
94
+ publicAPI.computeMatrix();
95
+ const tmp4 = new Float64Array(16);
96
+ mat4.transpose(tmp4, model.matrix);
97
+ bbox.forEach(pt => vec3.transformMat4(pt, pt, tmp4));
98
+
99
+ /* eslint-disable no-multi-assign */
100
+ model.bounds[0] = model.bounds[2] = model.bounds[4] = Number.MAX_VALUE;
101
+ model.bounds[1] = model.bounds[3] = model.bounds[5] = -Number.MAX_VALUE;
102
+ /* eslint-enable no-multi-assign */
103
+
104
+ model.bounds = model.bounds.map((d, i) => i % 2 === 0 ? bbox.reduce((a, b) => a > b[i / 2] ? b[i / 2] : a, d) : bbox.reduce((a, b) => a < b[(i - 1) / 2] ? b[(i - 1) / 2] : a, d));
105
+ model.boundsMTime.modified();
106
+ }
107
+ return model.bounds;
108
+ };
53
109
  publicAPI.getMTime = () => {
54
110
  let mt = superClass.getMTime();
111
+ if (model.property !== null) {
112
+ const time = model.property.getMTime();
113
+ mt = time > mt ? time : mt;
114
+ }
55
115
  if (model.backfaceProperty !== null) {
56
116
  const time = model.backfaceProperty.getMTime();
57
117
  mt = time > mt ? time : mt;
@@ -86,9 +146,11 @@ function vtkActor(publicAPI, model) {
86
146
 
87
147
  const DEFAULT_VALUES = {
88
148
  mapper: null,
149
+ property: null,
89
150
  backfaceProperty: null,
90
151
  forceOpaque: false,
91
- forceTranslucent: false
152
+ forceTranslucent: false,
153
+ bounds: [1, -1, 1, -1, 1, -1]
92
154
  };
93
155
 
94
156
  // ----------------------------------------------------------------------------
@@ -105,6 +167,7 @@ function extend(publicAPI, model) {
105
167
  macro.obj(model.boundsMTime);
106
168
 
107
169
  // Build VTK API
170
+ macro.set(publicAPI, model, ['property']);
108
171
  macro.setGet(publicAPI, model, ['backfaceProperty', 'forceOpaque', 'forceTranslucent', 'mapper']);
109
172
 
110
173
  // Object methods
@@ -400,13 +400,18 @@ function vtkColorTransferFunction(publicAPI, model) {
400
400
  publicAPI.getColor(x, rgb);
401
401
  return rgb[2];
402
402
  };
403
+ publicAPI.logScaleEnabled = () => model.scale === Scale.LOG10;
404
+ publicAPI.usingLogScale = () => publicAPI.logScaleEnabled() && model.mappingRange[0] > 0.0;
403
405
 
404
406
  //----------------------------------------------------------------------------
405
407
  // Returns a table of RGB colors at regular intervals along the function
406
408
  publicAPI.getTable = (xStart_, xEnd_, size, table) => {
409
+ // Note: This requires range[0] <= range[1].
410
+ const usingLogScale = publicAPI.usingLogScale();
411
+
407
412
  // To handle BigInt limitation
408
- const xStart = Number(xStart_);
409
- const xEnd = Number(xEnd_);
413
+ const xStart = usingLogScale ? Math.log10(Number(xStart_)) : Number(xStart_);
414
+ const xEnd = usingLogScale ? Math.log10(Number(xEnd_)) : Number(xEnd_);
410
415
 
411
416
  // Special case: If either the start or end is a NaN, then all any
412
417
  // interpolation done on them is also a NaN. Therefore, fill the table with
@@ -443,17 +448,9 @@ function vtkColorTransferFunction(publicAPI, model) {
443
448
  const tmpVec = [];
444
449
 
445
450
  // If the scale is logarithmic, make sure the range is valid.
446
- let usingLogScale = model.scale === Scale.LOG10;
447
- if (usingLogScale) {
448
- // Note: This requires range[0] <= range[1].
449
- usingLogScale = model.mappingRange[0] > 0.0;
450
- }
451
- let logStart = 0.0;
452
- let logEnd = 0.0;
453
- let logX = 0.0;
451
+ let scaledMappingRange = model.mappingRange;
454
452
  if (usingLogScale) {
455
- logStart = Math.log10(xStart);
456
- logEnd = Math.log10(xEnd);
453
+ scaledMappingRange = [Math.log10(model.mappingRange[0]), Math.log10(model.mappingRange[1])];
457
454
  }
458
455
 
459
456
  // For each table entry
@@ -465,15 +462,7 @@ function vtkColorTransferFunction(publicAPI, model) {
465
462
  // it halfway between start and end (usually start and end will
466
463
  // be the same in this case)
467
464
  if (size > 1) {
468
- if (usingLogScale) {
469
- logX = logStart + i / (size - 1.0) * (logEnd - logStart);
470
- x = 10.0 ** logX;
471
- } else {
472
- x = xStart + i / (size - 1.0) * (xEnd - xStart);
473
- }
474
- } else if (usingLogScale) {
475
- logX = 0.5 * (logStart + logEnd);
476
- x = 10.0 ** logX;
465
+ x = xStart + i / (size - 1.0) * (xEnd - xStart);
477
466
  } else {
478
467
  x = 0.5 * (xStart + xEnd);
479
468
  }
@@ -482,7 +471,7 @@ function vtkColorTransferFunction(publicAPI, model) {
482
471
  // discretize (round down to the closest integer),
483
472
  // then map back to mappingRange
484
473
  if (model.discretize) {
485
- const range = model.mappingRange;
474
+ const range = scaledMappingRange;
486
475
  if (x >= range[0] && x <= range[1]) {
487
476
  const numberOfValues = model.numberOfValues;
488
477
  const deltaRange = range[1] - range[0];
@@ -509,10 +498,6 @@ function vtkColorTransferFunction(publicAPI, model) {
509
498
  if (idx < numNodes) {
510
499
  x1 = model.nodes[idx - 1].x;
511
500
  x2 = model.nodes[idx].x;
512
- if (usingLogScale) {
513
- x1 = Math.log10(x1);
514
- x2 = Math.log10(x2);
515
- }
516
501
  rgb1[0] = model.nodes[idx - 1].r;
517
502
  rgb2[0] = model.nodes[idx].r;
518
503
  rgb1[1] = model.nodes[idx - 1].g;
@@ -537,7 +522,7 @@ function vtkColorTransferFunction(publicAPI, model) {
537
522
  }
538
523
 
539
524
  // Are we at or past the end? If so, just use the last value
540
- if (x > model.mappingRange[1]) {
525
+ if (x > scaledMappingRange[1]) {
541
526
  table[tidx] = 0.0;
542
527
  table[tidx + 1] = 0.0;
543
528
  table[tidx + 2] = 0.0;
@@ -552,7 +537,7 @@ function vtkColorTransferFunction(publicAPI, model) {
552
537
  table[tidx + 2] = lastB;
553
538
  }
554
539
  }
555
- } else if (x < model.mappingRange[0] || isInf(x) && x < 0) {
540
+ } else if (x < scaledMappingRange[0] || isInf(x) && x < 0) {
556
541
  // we are before the first node? If so, duplicate this node's values.
557
542
  // We have to deal with -inf here
558
543
  table[tidx] = 0.0;
@@ -586,11 +571,7 @@ function vtkColorTransferFunction(publicAPI, model) {
586
571
  // sharpness to get the curve shape we want and to have
587
572
  // it pass through (y1+y2)/2 at the midpoint.
588
573
  let s = 0.0;
589
- if (usingLogScale) {
590
- s = (logX - x1) / (x2 - x1);
591
- } else {
592
- s = (x - x1) / (x2 - x1);
593
- }
574
+ s = (x - x1) / (x2 - x1);
594
575
 
595
576
  // Readjust based on the midpoint - linear adjustment
596
577
  if (s < midpoint) {
@@ -975,7 +956,9 @@ function vtkColorTransferFunction(publicAPI, model) {
975
956
  //----------------------------------------------------------------------------
976
957
  publicAPI.setMappingRange = (min, max) => {
977
958
  const range = [min, max];
959
+ const scaledRange = [min, max];
978
960
  const originalRange = publicAPI.getRange();
961
+ const logScaleEnabled = publicAPI.logScaleEnabled();
979
962
  if (originalRange[1] === range[1] && originalRange[0] === range[0]) {
980
963
  return;
981
964
  }
@@ -983,8 +966,16 @@ function vtkColorTransferFunction(publicAPI, model) {
983
966
  vtkErrorMacro('attempt to set zero width color range');
984
967
  return;
985
968
  }
986
- const scale = (range[1] - range[0]) / (originalRange[1] - originalRange[0]);
987
- const shift = range[0] - originalRange[0] * scale;
969
+ if (logScaleEnabled) {
970
+ if (range[0] <= 0.0) {
971
+ console.warn('attempt to set log scale color range with non-positive minimum');
972
+ } else {
973
+ scaledRange[0] = Math.log10(range[0]);
974
+ scaledRange[1] = Math.log10(range[1]);
975
+ }
976
+ }
977
+ const scale = (scaledRange[1] - scaledRange[0]) / (originalRange[1] - originalRange[0]);
978
+ const shift = scaledRange[0] - originalRange[0] * scale;
988
979
  for (let i = 0; i < model.nodes.length; ++i) {
989
980
  model.nodes[i].x = model.nodes[i].x * scale + shift;
990
981
  }
@@ -1,5 +1,5 @@
1
1
  import { mat3, mat4, quat, vec3 } from 'gl-matrix';
2
- import { Nullable } from './../../types';
2
+ import { Extent, Nullable } from './../../types';
3
3
  import { vtkOutputPort } from './../../interfaces';
4
4
  import vtkAbstractMapper3D, {
5
5
  IAbstractMapper3DInitialValues,
@@ -307,6 +307,25 @@ export interface vtkImageCPRMapper
307
307
  * @param imageData
308
308
  */
309
309
  setImageConnection(imageData: vtkOutputPort): void;
310
+
311
+ /**
312
+ * Tells the mapper to only update the specified extents.
313
+ *
314
+ * If there are zero extents, the mapper updates the entire volume texture.
315
+ * Otherwise, the mapper will only update the texture by the specified extents
316
+ * during the next render call.
317
+ *
318
+ * This array is cleared after a successful render.
319
+ * @param extents
320
+ */
321
+ setUpdatedExtents(extents: Extent[]): boolean;
322
+
323
+ /**
324
+ * Retrieves the updated extents.
325
+ *
326
+ * This array is cleared after every successful render.
327
+ */
328
+ getUpdatedExtents(): Extent[];
310
329
  }
311
330
 
312
331
  /**
@@ -283,6 +283,7 @@ const defaultValues = initialValues => ({
283
283
  projectionSlabThickness: 1,
284
284
  projectionSlabNumberOfSamples: 1,
285
285
  projectionMode: ProjectionMode.MAX,
286
+ updatedExtents: [],
286
287
  ...initialValues
287
288
  });
288
289
 
@@ -303,7 +304,7 @@ function extend(publicAPI, model) {
303
304
  });
304
305
 
305
306
  // Setters and getters
306
- macro.setGet(publicAPI, model, ['width', 'uniformOrientation', 'useUniformOrientation', 'centerPoint', 'preferSizeOverAccuracy', 'orientationArrayName', 'tangentDirection', 'bitangentDirection', 'normalDirection', 'projectionSlabThickness', 'projectionSlabNumberOfSamples', 'projectionMode']);
307
+ macro.setGet(publicAPI, model, ['width', 'uniformOrientation', 'useUniformOrientation', 'centerPoint', 'preferSizeOverAccuracy', 'orientationArrayName', 'tangentDirection', 'bitangentDirection', 'normalDirection', 'projectionSlabThickness', 'projectionSlabNumberOfSamples', 'projectionMode', 'updatedExtents']);
307
308
  CoincidentTopologyHelper.implementCoincidentTopologyMethods(publicAPI, model);
308
309
 
309
310
  // Object methods
@@ -1,5 +1,5 @@
1
1
  import { vtkObject } from './../../interfaces';
2
- import { Extent, Nullable } from './../../types';
2
+ import { Nullable } from './../../types';
3
3
  import vtkColorTransferFunction from './ColorTransferFunction';
4
4
  import vtkPiecewiseFunction from './../../Common/DataModel/PiecewiseFunction';
5
5
  import { InterpolationType } from './ImageProperty/Constants';
@@ -231,25 +231,6 @@ export interface vtkImageProperty extends vtkObject {
231
231
  * @param {Boolean} useLookupTableScalarRange
232
232
  */
233
233
  setUseLookupTableScalarRange(useLookupTableScalarRange: boolean): boolean;
234
-
235
- /**
236
- * Informs the mapper to only update the specified extents at the next render.
237
- *
238
- * If there are zero extents, the mapper updates the entire volume texture.
239
- * Otherwise, the mapper will only update the texture by the specified extents
240
- * during the next render call.
241
- *
242
- * This array is cleared after a successful render.
243
- * @param extents
244
- */
245
- setUpdatedExtents(extents: Extent[]): boolean;
246
-
247
- /**
248
- * Retrieves the updated extents.
249
- *
250
- * This array is cleared after every successful render.
251
- */
252
- getUpdatedExtents(): Extent[];
253
234
  }
254
235
 
255
236
  /**
@@ -136,7 +136,7 @@ function vtkImageProperty(publicAPI, model) {
136
136
  // ----------------------------------------------------------------------------
137
137
  // Object factory
138
138
  // ----------------------------------------------------------------------------
139
- const defaultValues = initialValues => ({
139
+ const DEFAULT_VALUES = {
140
140
  independentComponents: false,
141
141
  interpolationType: InterpolationType.LINEAR,
142
142
  colorWindow: 255,
@@ -147,16 +147,14 @@ const defaultValues = initialValues => ({
147
147
  useLookupTableScalarRange: false,
148
148
  useLabelOutline: false,
149
149
  labelOutlineThickness: [1],
150
- labelOutlineOpacity: 1.0,
151
- updatedExtents: [],
152
- ...initialValues
153
- });
150
+ labelOutlineOpacity: 1.0
151
+ };
154
152
 
155
153
  // ----------------------------------------------------------------------------
156
154
 
157
155
  function extend(publicAPI, model) {
158
156
  let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
159
- Object.assign(model, defaultValues(initialValues));
157
+ Object.assign(model, DEFAULT_VALUES, initialValues);
160
158
 
161
159
  // Build VTK API
162
160
  macro.obj(publicAPI, model);
@@ -170,7 +168,7 @@ function extend(publicAPI, model) {
170
168
  });
171
169
  }
172
170
  }
173
- macro.setGet(publicAPI, model, ['independentComponents', 'interpolationType', 'colorWindow', 'colorLevel', 'ambient', 'diffuse', 'opacity', 'useLookupTableScalarRange', 'useLabelOutline', 'labelOutlineOpacity', 'updatedExtents']);
171
+ macro.setGet(publicAPI, model, ['independentComponents', 'interpolationType', 'colorWindow', 'colorLevel', 'ambient', 'diffuse', 'opacity', 'useLookupTableScalarRange', 'useLabelOutline', 'labelOutlineOpacity']);
174
172
  macro.setGetArray(publicAPI, model, ['labelOutlineThickness']);
175
173
 
176
174
  // Object methods
@@ -3,7 +3,7 @@ import vtkAbstractImageMapper, {
3
3
  } from './AbstractImageMapper';
4
4
  import vtkPlane from './../../Common/DataModel/Plane';
5
5
  import vtkPolyData from './../../Common/DataModel/PolyData';
6
- import { Bounds } from './../../types';
6
+ import { Bounds, Extent } from './../../types';
7
7
  import { SlabTypes } from './ImageResliceMapper/Constants';
8
8
  import CoincidentTopologyHelper, {
9
9
  StaticCoincidentTopologyMethods,
@@ -115,6 +115,25 @@ export interface vtkImageResliceMapper
115
115
  * @param {vtkPolyData} slicePolyData The polydata to slice the volume with. Default: null
116
116
  */
117
117
  setSlicePolyData(slicePolyData: vtkPolyData): boolean;
118
+
119
+ /**
120
+ * Tells the mapper to only update the specified extents.
121
+ *
122
+ * If there are zero extents, the mapper updates the entire volume texture.
123
+ * Otherwise, the mapper will only update the texture by the specified extents
124
+ * during the next render call.
125
+ *
126
+ * This array is cleared after a successful render.
127
+ * @param extents
128
+ */
129
+ setUpdatedExtents(extents: Extent[]): boolean;
130
+
131
+ /**
132
+ * Retrieves the updated extents.
133
+ *
134
+ * This array is cleared after every successful render.
135
+ */
136
+ getUpdatedExtents(): Extent[];
118
137
  }
119
138
 
120
139
  /**
@@ -44,6 +44,7 @@ const defaultValues = initialValues => ({
44
44
  slabType: SlabTypes.MEAN,
45
45
  slicePlane: null,
46
46
  slicePolyData: null,
47
+ updatedExtents: [],
47
48
  ...initialValues
48
49
  });
49
50
 
@@ -55,7 +56,7 @@ function extend(publicAPI, model) {
55
56
 
56
57
  // Build VTK API
57
58
  vtkAbstractImageMapper.extend(publicAPI, model, initialValues);
58
- macro.setGet(publicAPI, model, ['slabThickness', 'slabTrapezoidIntegration', 'slabType', 'slicePlane', 'slicePolyData']);
59
+ macro.setGet(publicAPI, model, ['slabThickness', 'slabTrapezoidIntegration', 'slabType', 'slicePlane', 'slicePolyData', 'updatedExtents']);
59
60
  CoincidentTopologyHelper.implementCoincidentTopologyMethods(publicAPI, model);
60
61
 
61
62
  // Object methods
@@ -17,6 +17,18 @@ export interface vtkImageSlice extends vtkProp3D {
17
17
  */
18
18
  getActors(): any;
19
19
 
20
+ /**
21
+ * Get the bounds for this mapper as [xmin, xmax, ymin, ymax,zmin, zmax].
22
+ * @return {Bounds} The bounds for the mapper.
23
+ */
24
+ getBounds(): Bounds;
25
+
26
+ /**
27
+ * Get the bounds for this mapper as [xmin, xmax, ymin, ymax,zmin, zmax].
28
+ * @return {Bounds} The bounds for the mapper.
29
+ */
30
+ getBoundsByReference(): Bounds;
31
+
20
32
  /**
21
33
  * Get the bounds for a given slice as [xmin, xmax, ymin, ymax,zmin, zmax].
22
34
  * @param {Number} slice The slice index. If undefined, the current slice is considered.
@@ -35,6 +47,11 @@ export interface vtkImageSlice extends vtkProp3D {
35
47
  */
36
48
  getIsOpaque(): boolean;
37
49
 
50
+ /**
51
+ *
52
+ */
53
+ getProperty(): vtkImageProperty;
54
+
38
55
  /**
39
56
  *
40
57
  */
@@ -113,6 +130,12 @@ export interface vtkImageSlice extends vtkProp3D {
113
130
  */
114
131
  setMapper(mapper: vtkAbstractImageMapper): boolean;
115
132
 
133
+ /**
134
+ *
135
+ * @param {vtkImageProperty} property The vtkImageProperty instance.
136
+ */
137
+ setProperty(property: vtkImageProperty): boolean;
138
+
116
139
  /**
117
140
  *
118
141
  * @param {boolean} forceOpaque If true, render during opaque pass even if opacity value is below 1.0.
@@ -124,13 +147,6 @@ export interface vtkImageSlice extends vtkProp3D {
124
147
  * @param {boolean} forceTranslucent If true, render during translucent pass even if opacity value is 1.0.
125
148
  */
126
149
  setForceTranslucent(forceTranslucent: boolean): boolean;
127
-
128
- // Inherited from vtkProp3D, but takes a vtkImageProperty instead of a generic vtkObject
129
- getProperty(mapperInputPort?: number): vtkImageProperty;
130
- getProperties(): vtkImageProperty[];
131
- setProperty(mapperInputPort: number, property: vtkImageProperty): boolean;
132
- setProperty(property: vtkImageProperty): boolean;
133
- setProperties(properties: vtkImageProperty[]): boolean;
134
150
  }
135
151
 
136
152
  /**