@kitware/vtk.js 26.0.0-beta.2 → 26.0.0-beta.3

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/Common/Core/ClassHierarchy.js +6 -11
  2. package/Common/Core/Math/Constants.js +12 -0
  3. package/Common/Core/Math/index.js +48 -29
  4. package/Common/Core/Math.d.ts +34 -4
  5. package/Common/Core/Math.js +2 -1
  6. package/Common/Core/MatrixBuilder.d.ts +13 -2
  7. package/Common/Core/MatrixBuilder.js +14 -2
  8. package/Common/Core/ScalarsToColors.d.ts +1 -3
  9. package/Common/Core/ScalarsToColors.js +1 -1
  10. package/Common/DataModel/BoundingBox.js +7 -7
  11. package/Common/DataModel/EdgeLocator.d.ts +79 -0
  12. package/Common/DataModel/EdgeLocator.js +85 -0
  13. package/Common/DataModel/ImageData.js +2 -50
  14. package/Common/DataModel/IncrementalOctreeNode.d.ts +15 -0
  15. package/Common/DataModel/IncrementalOctreeNode.js +27 -8
  16. package/Common/DataModel/IncrementalOctreePointLocator.js +61 -5
  17. package/Common/DataModel/Polygon.js +2 -2
  18. package/Common/Transform/Transform.js +51 -0
  19. package/Common/Transform.js +3 -1
  20. package/Filters/General/ClipClosedSurface.js +21 -18
  21. package/Filters/General/ContourTriangulator/helper.js +1 -1
  22. package/Filters/General/ImageMarchingCubes.js +5 -22
  23. package/Filters/General/ImageMarchingSquares.js +6 -23
  24. package/Filters/General.js +6 -0
  25. package/Imaging/Core/ImageReslice.js +84 -36
  26. package/Rendering/Core/ColorTransferFunction.d.ts +20 -0
  27. package/Rendering/Core/ColorTransferFunction.js +76 -7
  28. package/Rendering/Core/Prop3D.js +6 -1
  29. package/Rendering/Core/VolumeProperty.js +3 -2
  30. package/Rendering/OpenGL/PolyDataMapper.js +7 -5
  31. package/Rendering/OpenGL/RenderWindow.d.ts +25 -1
  32. package/Rendering/OpenGL/Texture.js +22 -6
  33. package/Rendering/OpenGL/VolumeMapper.js +3 -1
  34. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  35. package/Rendering/SceneGraph/RenderWindowViewNode.js +8 -2
  36. package/Rendering/SceneGraph/ViewNode.js +11 -0
  37. package/Widgets/Core/AbstractWidget.js +1 -1
  38. package/Widgets/Core/WidgetManager.js +25 -19
  39. package/Widgets/Representations/WidgetRepresentation.js +19 -7
  40. package/index.d.ts +1 -0
  41. package/macros.d.ts +5 -3
  42. package/macros.js +41 -8
  43. package/package.json +3 -1
  44. package/Filters/General/ClipClosedSurface/ccsEdgeLocator.js +0 -40
@@ -1,7 +1,9 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
2
  import { mat4, vec4 } from 'gl-matrix';
3
- import macro from '../../macros.js';
3
+ import macro, { vtkWarningMacro } from '../../macros.js';
4
4
  import vtkDataArray from '../../Common/Core/DataArray.js';
5
+ import { g as vtkMath } from '../../Common/Core/Math/index.js';
6
+ import vtkMatrixBuilder from '../../Common/Core/MatrixBuilder.js';
5
7
  import { VtkDataTypes } from '../../Common/Core/DataArray/Constants.js';
6
8
  import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
7
9
  import vtkImageData from '../../Common/DataModel/ImageData.js';
@@ -15,14 +17,16 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
15
17
 
16
18
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
19
  var SlabMode = Constants.SlabMode;
18
- var capitalize = macro.capitalize,
19
- vtkErrorMacro = macro.vtkErrorMacro; // ----------------------------------------------------------------------------
20
+ var vtkErrorMacro = macro.vtkErrorMacro; // ----------------------------------------------------------------------------
20
21
  // vtkImageReslice methods
21
22
  // ----------------------------------------------------------------------------
22
23
 
23
24
  function vtkImageReslice(publicAPI, model) {
24
25
  // Set our className
25
26
  model.classHierarchy.push('vtkImageReslice');
27
+
28
+ var superClass = _objectSpread({}, publicAPI);
29
+
26
30
  var indexMatrix = null;
27
31
  var optimizedTransform = null;
28
32
 
@@ -97,6 +101,16 @@ function vtkImageReslice(publicAPI, model) {
97
101
  getImageResliceSlabTrap(tmpPtr, inComponents, sampleCount, f);
98
102
  }
99
103
 
104
+ publicAPI.getMTime = function () {
105
+ var mTime = superClass.getMTime();
106
+
107
+ if (model.resliceTransform) {
108
+ mTime = Math.max(mTime, model.resliceTransform.getMTime());
109
+ }
110
+
111
+ return mTime;
112
+ };
113
+
100
114
  publicAPI.setResliceAxes = function (resliceAxes) {
101
115
  if (!model.resliceAxes) {
102
116
  model.resliceAxes = mat4.identity(new Float64Array(16));
@@ -131,12 +145,10 @@ function vtkImageReslice(publicAPI, model) {
131
145
  var outSpacing = [1, 1, 1];
132
146
  var outWholeExt = [0, 0, 0, 0, 0, 0];
133
147
  var outDims = [0, 0, 0];
134
- var matrix = null;
148
+ var matrix = mat4.identity(new Float64Array(16));
135
149
 
136
150
  if (model.resliceAxes) {
137
- matrix = model.resliceAxes;
138
- } else {
139
- matrix = mat4.identity(new Float64Array(16));
151
+ mat4.multiply(matrix, matrix, model.resliceAxes);
140
152
  }
141
153
 
142
154
  var imatrix = new Float64Array(16);
@@ -236,6 +248,11 @@ function vtkImageReslice(publicAPI, model) {
236
248
  output.setDimensions(outDims);
237
249
  output.setOrigin(outOrigin);
238
250
  output.setSpacing(outSpacing);
251
+
252
+ if (model.outputDirection) {
253
+ output.setDirection(model.outputDirection);
254
+ }
255
+
239
256
  output.getPointData().setScalars(outScalars);
240
257
  publicAPI.getIndexMatrix(input, output);
241
258
  var interpolationMode = model.interpolationMode;
@@ -340,7 +357,7 @@ function vtkImageReslice(publicAPI, model) {
340
357
  var floatPtr = null;
341
358
 
342
359
  if (!optimizeNearest) {
343
- floatPtr = new Float64Array(inComponents * (outExt[1] - outExt[0]));
360
+ floatPtr = new Float64Array(inComponents * (outExt[1] - outExt[0] + nsamples));
344
361
  }
345
362
 
346
363
  var background = macro.newTypedArray(inputScalarType, model.backgroundColor); // set color for area outside of input volume extent
@@ -577,6 +594,20 @@ function vtkImageReslice(publicAPI, model) {
577
594
  }
578
595
  }
579
596
  };
597
+ /**
598
+ * The transform matrix supplied by the user converts output coordinates
599
+ * to input coordinates.
600
+ * To speed up the pixel lookup, the following function provides a
601
+ * matrix which converts output pixel indices to input pixel indices.
602
+ * This will also concatenate the ResliceAxes and the ResliceTransform
603
+ * if possible (if the ResliceTransform is a 4x4 matrix transform).
604
+ * If it does, this->OptimizedTransform will be set to nullptr, otherwise
605
+ * this->OptimizedTransform will be equal to this->ResliceTransform.
606
+ * @param {vtkPolyData} input
607
+ * @param {vtkPolyData} output
608
+ * @returns
609
+ */
610
+
580
611
 
581
612
  publicAPI.getIndexMatrix = function (input, output) {
582
613
  // first verify that we have to update the matrix
@@ -586,6 +617,7 @@ function vtkImageReslice(publicAPI, model) {
586
617
 
587
618
  var inOrigin = input.getOrigin();
588
619
  var inSpacing = input.getSpacing();
620
+ var inDirection = input.getDirection();
589
621
  var outOrigin = output.getOrigin();
590
622
  var outSpacing = output.getSpacing();
591
623
  var transform = mat4.identity(new Float64Array(16));
@@ -596,14 +628,29 @@ function vtkImageReslice(publicAPI, model) {
596
628
  mat4.copy(transform, model.resliceAxes);
597
629
  }
598
630
 
599
- if (model.resliceTransform) ; // check to see if we have an identity matrix
631
+ if (model.resliceTransform) {
632
+ if (model.resliceTransform.isA('vtkHomogeneousTransform')) {
633
+ // transform->PostMultiply();
634
+ // transform->Concatenate(
635
+ // mat4.multiply(transform, transform, model.resliceTransform.getMatrix());
636
+ mat4.multiply(transform, model.resliceTransform.getMatrix(), transform);
637
+ } else {
638
+ // TODO
639
+ vtkWarningMacro('Non homogeneous transform have not yet been ported');
640
+ }
641
+ }
642
+
643
+ if (!vtkMath.isIdentity3x3(inDirection)) {
644
+ var imageTransform = vtkMatrixBuilder.buildFromRadian().translate(inOrigin[0], inOrigin[1], inOrigin[2]).multiply3x3(inDirection).translate(-inOrigin[0], -inOrigin[1], -inOrigin[2]);
645
+ mat4.multiply(transform, imageTransform.getMatrix(), transform);
646
+ } // check to see if we have an identity matrix
600
647
 
601
648
 
602
- var isIdentity = publicAPI.isIdentityMatrix(transform); // the outMatrix takes OutputData indices to OutputData coordinates,
649
+ var isIdentity = vtkMath.isIdentity(transform); // the outMatrix takes OutputData indices to OutputData coordinates,
603
650
  // the inMatrix takes InputData coordinates to InputData indices
604
651
 
605
652
  for (var i = 0; i < 3; i++) {
606
- if ((inSpacing[i] !== outSpacing[i] || inOrigin[i] !== outOrigin[i]) || optimizedTransform !== null ) {
653
+ if ((inSpacing[i] !== outSpacing[i] || inOrigin[i] !== outOrigin[i]) || optimizedTransform != null ) {
607
654
  isIdentity = false;
608
655
  }
609
656
 
@@ -633,6 +680,7 @@ function vtkImageReslice(publicAPI, model) {
633
680
  publicAPI.getAutoCroppedOutputBounds = function (input) {
634
681
  var inOrigin = input.getOrigin();
635
682
  var inSpacing = input.getSpacing();
683
+ var inDirection = input.getDirection();
636
684
  var dims = input.getDimensions();
637
685
  var inWholeExt = [0, dims[0] - 1, 0, dims[1] - 1, 0, dims[2] - 1];
638
686
  var matrix = new Float64Array(16);
@@ -643,6 +691,18 @@ function vtkImageReslice(publicAPI, model) {
643
691
  mat4.identity(matrix);
644
692
  }
645
693
 
694
+ var transform = null;
695
+
696
+ if (model.resliceTransform) {
697
+ transform = model.resliceTransform.getInverse();
698
+ }
699
+
700
+ var imageTransform = null;
701
+
702
+ if (!vtkMath.isIdentity3x3(inDirection)) {
703
+ imageTransform = vtkMatrixBuilder.buildFromRadian().translate(inOrigin[0], inOrigin[1], inOrigin[2]).multiply3x3(inDirection).translate(-inOrigin[0], -inOrigin[1], -inOrigin[2]).invert().getMatrix();
704
+ }
705
+
646
706
  var bounds = [Number.MAX_VALUE, -Number.MAX_VALUE, Number.MAX_VALUE, -Number.MAX_VALUE, Number.MAX_VALUE, -Number.MAX_VALUE];
647
707
  var point = [0, 0, 0, 0];
648
708
 
@@ -652,7 +712,13 @@ function vtkImageReslice(publicAPI, model) {
652
712
  point[2] = inOrigin[2] + inWholeExt[4 + Math.floor(i / 4) % 2] * inSpacing[2];
653
713
  point[3] = 1.0;
654
714
 
655
- if (model.resliceTransform) ;
715
+ if (imageTransform) {
716
+ vec4.transformMat4(point, point, imageTransform);
717
+ }
718
+
719
+ if (model.resliceTransform) {
720
+ transform.transformPoint(point, point);
721
+ }
656
722
 
657
723
  vec4.transformMat4(point, point, matrix);
658
724
  var f = 1.0 / point[3];
@@ -931,27 +997,6 @@ function vtkImageReslice(publicAPI, model) {
931
997
 
932
998
  return 1;
933
999
  };
934
- }
935
-
936
- function setNullArray(publicAPI, model, fieldNames) {
937
- fieldNames.forEach(function (field) {
938
- var setterName = "set".concat(capitalize(field));
939
- var superSet = publicAPI[setterName];
940
-
941
- publicAPI[setterName] = function () {
942
- if (arguments.length === 1 && (arguments.length <= 0 ? undefined : arguments[0]) == null || model[field] == null) {
943
- if ((arguments.length <= 0 ? undefined : arguments[0]) !== model[field]) {
944
- model[field] = arguments.length <= 0 ? undefined : arguments[0];
945
- publicAPI.modified();
946
- return true;
947
- }
948
-
949
- return null;
950
- }
951
-
952
- return superSet.apply(void 0, arguments);
953
- };
954
- });
955
1000
  } // ----------------------------------------------------------------------------
956
1001
  // Object factory
957
1002
  // ----------------------------------------------------------------------------
@@ -965,6 +1010,8 @@ var DEFAULT_VALUES = {
965
1010
  // automatically computed if null
966
1011
  outputOrigin: null,
967
1012
  // automatically computed if null
1013
+ outputDirection: null,
1014
+ // identity if null
968
1015
  outputExtent: null,
969
1016
  // automatically computed if null
970
1017
  outputScalarType: null,
@@ -987,7 +1034,7 @@ var DEFAULT_VALUES = {
987
1034
  scalarScale: 1,
988
1035
  backgroundColor: [0, 0, 0, 0],
989
1036
  resliceAxes: null,
990
- resliceTransform: null,
1037
+ // resliceTransform: null,
991
1038
  interpolator: vtkImageInterpolator.newInstance(),
992
1039
  usePermuteExecute: false // no supported yet
993
1040
 
@@ -1000,10 +1047,11 @@ function extend(publicAPI, model) {
1000
1047
  macro.obj(publicAPI, model); // Also make it an algorithm with one input and one output
1001
1048
 
1002
1049
  macro.algo(publicAPI, model, 1, 1);
1003
- macro.setGet(publicAPI, model, ['outputDimensionality', 'outputScalarType', 'scalarShift', 'scalarScale', 'transformInputSampling', 'autoCropOutput', 'wrap', 'mirror', 'border', 'backgroundColor', 'interpolationMode', 'slabMode', 'slabTrapezoidIntegration', 'slabNumberOfSlices', 'slabSliceSpacingFraction']);
1050
+ macro.setGet(publicAPI, model, ['outputDimensionality', 'outputScalarType', 'scalarShift', 'scalarScale', 'transformInputSampling', 'autoCropOutput', 'wrap', 'mirror', 'border', 'interpolationMode', 'resliceTransform', 'slabMode', 'slabTrapezoidIntegration', 'slabNumberOfSlices', 'slabSliceSpacingFraction']);
1004
1051
  macro.setGetArray(publicAPI, model, ['outputOrigin', 'outputSpacing'], 3);
1005
1052
  macro.setGetArray(publicAPI, model, ['outputExtent'], 6);
1006
- setNullArray(publicAPI, model, ['outputOrigin', 'outputSpacing', 'outputExtent']);
1053
+ macro.setGetArray(publicAPI, model, ['outputDirection'], 9);
1054
+ macro.setGetArray(publicAPI, model, ['backgroundColor'], 4);
1007
1055
  macro.get(publicAPI, model, ['resliceAxes']); // Object specific methods
1008
1056
 
1009
1057
  macro.algo(publicAPI, model, 1, 1);
@@ -1,3 +1,4 @@
1
+ import vtkDataArray from './../../Common/Core/DataArray';
1
2
  import { vtkObject } from './../../interfaces';
2
3
  import { ColorSpace, Scale } from './ColorTransferFunction/Constants';
3
4
 
@@ -201,6 +202,25 @@ export interface vtkColorTransferFunction extends vtkObject {
201
202
  withAlpha: boolean
202
203
  ): Float32Array;
203
204
 
205
+ /**
206
+ * Construct a color transfer function from a vtkDataArray.
207
+ * The order of values depends on the number of components
208
+ * of the array.
209
+ * 3 -> RGB
210
+ * 4 -> XRGB
211
+ * 5 -> RGBMS
212
+ * 6 -> XRGBMS
213
+ *
214
+ * X represents the input value to a function
215
+ * RGB represents the red, green, and blue value output
216
+ * M represents the midpoint
217
+ * S represents sharpness
218
+ * @param {vtkDataArray} array
219
+ */
220
+ buildFunctionFromArray(
221
+ array: vtkDataArray,
222
+ ): void;
223
+
204
224
  /**
205
225
  * Construct a color transfer function from a table.
206
226
  * @param {Number} xStart The index of the first point.
@@ -849,6 +849,69 @@ function vtkColorTransferFunction(publicAPI, model) {
849
849
 
850
850
  model.buildTime.modified();
851
851
  return model.table;
852
+ };
853
+
854
+ publicAPI.buildFunctionFromArray = function (array) {
855
+ publicAPI.removeAllPoints();
856
+ var numComponents = array.getNumberOfComponents();
857
+
858
+ for (var i = 0; i < array.getNumberOfTuples(); i++) {
859
+ switch (numComponents) {
860
+ case 3:
861
+ {
862
+ model.nodes.push({
863
+ x: i,
864
+ r: array.getComponent(i, 0),
865
+ g: array.getComponent(i, 1),
866
+ b: array.getComponent(i, 2),
867
+ midpoint: 0.5,
868
+ sharpness: 0.0
869
+ });
870
+ break;
871
+ }
872
+
873
+ case 4:
874
+ {
875
+ model.nodes.push({
876
+ x: array.getComponent(i, 0),
877
+ r: array.getComponent(i, 1),
878
+ g: array.getComponent(i, 2),
879
+ b: array.getComponent(i, 3),
880
+ midpoint: 0.5,
881
+ sharpness: 0.0
882
+ });
883
+ break;
884
+ }
885
+
886
+ case 5:
887
+ {
888
+ model.nodes.push({
889
+ x: i,
890
+ r: array.getComponent(i, 0),
891
+ g: array.getComponent(i, 1),
892
+ b: array.getComponent(i, 2),
893
+ midpoint: array.getComponent(i, 4),
894
+ sharpness: array.getComponent(i, 5)
895
+ });
896
+ break;
897
+ }
898
+
899
+ case 6:
900
+ {
901
+ model.nodes.push({
902
+ x: array.getComponent(i, 0),
903
+ r: array.getComponent(i, 1),
904
+ g: array.getComponent(i, 2),
905
+ b: array.getComponent(i, 3),
906
+ midpoint: array.getComponent(i, 4),
907
+ sharpness: array.getComponent(i, 5)
908
+ });
909
+ break;
910
+ }
911
+ }
912
+ }
913
+
914
+ publicAPI.sortAndUpdateRange();
852
915
  }; //----------------------------------------------------------------------------
853
916
 
854
917
 
@@ -1125,6 +1188,8 @@ function vtkColorTransferFunction(publicAPI, model) {
1125
1188
 
1126
1189
 
1127
1190
  publicAPI.applyColorMap = function (colorMap) {
1191
+ var oldColorSpace = JSON.stringify(model.colorSpace);
1192
+
1128
1193
  if (colorMap.ColorSpace) {
1129
1194
  model.colorSpace = ColorSpace[colorMap.ColorSpace.toUpperCase()];
1130
1195
 
@@ -1134,6 +1199,9 @@ function vtkColorTransferFunction(publicAPI, model) {
1134
1199
  }
1135
1200
  }
1136
1201
 
1202
+ var isModified = oldColorSpace !== JSON.stringify(model.colorSpace);
1203
+ var oldNanColor = isModified || JSON.stringify(model.nanColor);
1204
+
1137
1205
  if (colorMap.NanColor) {
1138
1206
  model.nanColor = [].concat(colorMap.NanColor);
1139
1207
 
@@ -1142,6 +1210,9 @@ function vtkColorTransferFunction(publicAPI, model) {
1142
1210
  }
1143
1211
  }
1144
1212
 
1213
+ isModified = isModified || oldNanColor !== JSON.stringify(model.nanColor);
1214
+ var oldNodes = isModified || JSON.stringify(model.nodes);
1215
+
1145
1216
  if (colorMap.RGBPoints) {
1146
1217
  var size = colorMap.RGBPoints.length;
1147
1218
  model.nodes = [];
@@ -1158,14 +1229,12 @@ function vtkColorTransferFunction(publicAPI, model) {
1158
1229
  sharpness: sharpness
1159
1230
  });
1160
1231
  }
1161
- } // FIXME: not supported ?
1162
- // if (colorMap.IndexedColors) {
1163
- // }
1164
- // if (colorMap.Annotations) {
1165
- // }
1166
-
1232
+ }
1167
1233
 
1168
- publicAPI.sortAndUpdateRange();
1234
+ var modifiedInvoked = publicAPI.sortAndUpdateRange();
1235
+ var callModified = !modifiedInvoked && (isModified || oldNodes !== JSON.stringify(model.nodes));
1236
+ if (callModified) publicAPI.modified();
1237
+ return modifiedInvoked || callModified;
1169
1238
  };
1170
1239
  } // ----------------------------------------------------------------------------
1171
1240
  // Object factory
@@ -1,7 +1,7 @@
1
1
  import { mat4, quat } from 'gl-matrix';
2
2
  import macro from '../../macros.js';
3
3
  import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
4
- import { B as degreesFromRadians, r as radiansFromDegrees } from '../../Common/Core/Math/index.js';
4
+ import { B as degreesFromRadians, r as radiansFromDegrees, a as areMatricesEqual } from '../../Common/Core/Math/index.js';
5
5
  import vtkProp from './Prop.js';
6
6
 
7
7
  // vtkProp3D methods
@@ -83,8 +83,13 @@ function vtkProp3D(publicAPI, model) {
83
83
  };
84
84
 
85
85
  publicAPI.setUserMatrix = function (matrix) {
86
+ if (areMatricesEqual(model.userMatrix, matrix)) {
87
+ return false;
88
+ }
89
+
86
90
  mat4.copy(model.userMatrix, matrix);
87
91
  publicAPI.modified();
92
+ return true;
88
93
  };
89
94
 
90
95
  publicAPI.getMatrix = function () {
@@ -243,7 +243,8 @@ var DEFAULT_VALUES = {
243
243
  specular: 0.2,
244
244
  specularPower: 10.0,
245
245
  useLabelOutline: false,
246
- labelOutlineThickness: 1
246
+ labelOutlineThickness: 1,
247
+ labelOutlineOpacity: 1.0
247
248
  }; // ----------------------------------------------------------------------------
248
249
 
249
250
  function extend(publicAPI, model) {
@@ -273,7 +274,7 @@ function extend(publicAPI, model) {
273
274
  }
274
275
  }
275
276
 
276
- macro.setGet(publicAPI, model, ['independentComponents', 'interpolationType', 'shade', 'ambient', 'diffuse', 'specular', 'specularPower', 'useLabelOutline', 'labelOutlineThickness']); // Object methods
277
+ macro.setGet(publicAPI, model, ['independentComponents', 'interpolationType', 'shade', 'ambient', 'diffuse', 'specular', 'specularPower', 'useLabelOutline', 'labelOutlineThickness', 'labelOutlineOpacity']); // Object methods
277
278
 
278
279
  vtkVolumeProperty(publicAPI, model);
279
280
  } // ----------------------------------------------------------------------------
@@ -1,3 +1,4 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
1
2
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
2
3
  import { mat3, mat4, vec3 } from 'gl-matrix';
3
4
  import { newInstance as newInstance$1, setGet, obj, vtkErrorMacro as vtkErrorMacro$1 } from '../../macros.js';
@@ -16,6 +17,9 @@ import { registerOverride } from './ViewNodeFactory.js';
16
17
  import { PassTypes } from './HardwareSelector/Constants.js';
17
18
  import vtkDataSet from '../../Common/DataModel/DataSet.js';
18
19
 
20
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
+
22
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
23
  var FieldAssociations = vtkDataSet.FieldAssociations;
20
24
  /* eslint-disable no-lonely-if */
21
25
 
@@ -1284,15 +1288,13 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
1284
1288
  } else {
1285
1289
  // if we have edge visibility build the edge VBOs
1286
1290
  if (drawSurfaceWithEdges) {
1287
- model.primitives[i].getCABO().createVBO(primitives[i].cells, primitives[i].inRep, Representation.WIREFRAME, {
1288
- points: points,
1289
- normals: n,
1291
+ options.cellOffset += model.primitives[i].getCABO().createVBO(primitives[i].cells, primitives[i].inRep, Representation.WIREFRAME, _objectSpread(_objectSpread({}, options), {}, {
1290
1292
  tcoords: null,
1291
1293
  colors: null,
1292
- cellOffset: 0,
1293
1294
  haveCellScalars: false,
1294
1295
  haveCellNormals: false
1295
- });
1296
+ }), model.selectionWebGLIdsToVTKIds);
1297
+ options.vertexOffset += model.primitives[i].getCABO().getElementCount();
1296
1298
  } else {
1297
1299
  // otherwise free them
1298
1300
  model.primitives[i].releaseGraphicsResources();
@@ -327,7 +327,18 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
327
327
  setViewStream(stream: vtkViewStream): boolean;
328
328
 
329
329
  /**
330
- *
330
+ * Sets the pixel width and height of the rendered image.
331
+ *
332
+ * WebGL and WebGPU render windows apply these values to
333
+ * the width and height attribute of the canvas element.
334
+ *
335
+ * To match the device resolution in browser environments,
336
+ * multiply the container size by `window.devicePixelRatio`
337
+ * `apiSpecificRenderWindow.setSize(Math.floor(containerWidth * devicePixelRatio), Math.floor(containerHeight * devicePixelRatio));
338
+ * See the VTK.js FullscreenRenderWindow class for an example.
339
+ *
340
+ * @see getComputedDevicePixelRatio()
341
+ *
331
342
  * @param {Vector2} size
332
343
  */
333
344
  setSize(size: Vector2): void;
@@ -361,6 +372,19 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
361
372
  *
362
373
  */
363
374
  getVrResolution(): Vector2;
375
+
376
+ /**
377
+ * Scales the size of a browser CSS pixel to a rendered canvas pixel.
378
+ * `const renderedPixelWidth = cssPixelWidth * apiRenderWindow.getComputedDevicePixelRatio()`
379
+ * Use to scale rendered objects to a consistent perceived size or DOM pixel position.
380
+ *
381
+ * Rather than using window.devicePixelRatio directly, the device pixel ratio is inferred
382
+ * from the container CSS pixel size and rendered image pixel size. The user directly sets the rendered pixel size.
383
+ *
384
+ * @see setSize()
385
+ * @see getContainerSize()
386
+ */
387
+ getComputedDevicePixelRatio(): number;
364
388
  }
365
389
 
366
390
  /**
@@ -298,7 +298,7 @@ function vtkOpenGLTexture(publicAPI, model) {
298
298
 
299
299
 
300
300
  publicAPI.getInternalFormat = function (vtktype, numComps) {
301
- if (!model.internalFormat) {
301
+ if (!model._forceInternalFormat) {
302
302
  model.internalFormat = publicAPI.getDefaultInternalFormat(vtktype, numComps);
303
303
  }
304
304
 
@@ -332,6 +332,8 @@ function vtkOpenGLTexture(publicAPI, model) {
332
332
 
333
333
 
334
334
  publicAPI.setInternalFormat = function (iFormat) {
335
+ model._forceInternalFormat = true;
336
+
335
337
  if (iFormat !== model.internalFormat) {
336
338
  model.internalFormat = iFormat;
337
339
  publicAPI.modified();
@@ -388,6 +390,7 @@ function vtkOpenGLTexture(publicAPI, model) {
388
390
  publicAPI.resetFormatAndType = function () {
389
391
  model.format = 0;
390
392
  model.internalFormat = 0;
393
+ model._forceInternalFormat = false;
391
394
  model.openGLDataType = 0;
392
395
  }; //----------------------------------------------------------------------------
393
396
 
@@ -591,8 +594,14 @@ function vtkOpenGLTexture(publicAPI, model) {
591
594
  // then the data array must be u16
592
595
 
593
596
 
594
- var halfFloatExt = model.context.getExtension('OES_texture_half_float');
595
- var halfFloat = model._openGLRenderWindow.getWebgl2() ? model.openGLDataType === model.context.HALF_FLOAT : halfFloatExt && model.openGLDataType === halfFloatExt.HALF_FLOAT_OES;
597
+ var halfFloat = false;
598
+
599
+ if (model._openGLRenderWindow.getWebgl2()) {
600
+ halfFloat = model.openGLDataType === model.context.HALF_FLOAT;
601
+ } else {
602
+ var halfFloatExt = model.context.getExtension('OES_texture_half_float');
603
+ halfFloat = halfFloatExt && model.openGLDataType === halfFloatExt.HALF_FLOAT_OES;
604
+ }
596
605
 
597
606
  if (halfFloat) {
598
607
  for (var _idx2 = 0; _idx2 < data.length; _idx2++) {
@@ -993,8 +1002,14 @@ function vtkOpenGLTexture(publicAPI, model) {
993
1002
  function checkUseHalfFloat(dataType, offset, scale, preferSizeOverAccuracy) {
994
1003
  var useHalfFloatType = true;
995
1004
  publicAPI.getOpenGLDataType(dataType, useHalfFloatType);
996
- var halfFloatExt = model.context.getExtension('OES_texture_half_float');
997
- var useHalfFloat = model._openGLRenderWindow.getWebgl2() ? model.openGLDataType === model.context.HALF_FLOAT : halfFloatExt && model.openGLDataType === halfFloatExt.HALF_FLOAT_OES;
1005
+ var useHalfFloat = false;
1006
+
1007
+ if (model._openGLRenderWindow.getWebgl2()) {
1008
+ useHalfFloat = model.openGLDataType === model.context.HALF_FLOAT;
1009
+ } else {
1010
+ var halfFloatExt = model.context.getExtension('OES_texture_half_float');
1011
+ useHalfFloat = halfFloatExt && model.openGLDataType === halfFloatExt.HALF_FLOAT_OES;
1012
+ }
998
1013
 
999
1014
  if (!useHalfFloat) {
1000
1015
  return false;
@@ -1287,7 +1302,8 @@ function vtkOpenGLTexture(publicAPI, model) {
1287
1302
 
1288
1303
 
1289
1304
  var DEFAULT_VALUES = {
1290
- // _openGLRenderWindow: null,
1305
+ _openGLRenderWindow: null,
1306
+ _forceInternalFormat: false,
1291
1307
  context: null,
1292
1308
  handle: 0,
1293
1309
  sendParametersTime: null,
@@ -461,7 +461,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
461
461
  var i2wmat4 = model.currentInput.getIndexToWorld();
462
462
  mat4.multiply(model.idxToView, model.modelToView, i2wmat4);
463
463
  mat3.multiply(model.idxNormalMatrix, keyMats.normalMatrix, actMats.normalMatrix);
464
- mat3.multiply(model.idxNormalMatrix, model.idxNormalMatrix, model.currentInput.getDirection());
464
+ mat3.multiply(model.idxNormalMatrix, model.idxNormalMatrix, model.currentInput.getDirectionByReference());
465
465
  var maxSamples = vec3.length(vsize) / model.renderable.getSampleDistance();
466
466
 
467
467
  if (maxSamples > model.renderable.getMaximumSamplesPerRay()) {
@@ -717,7 +717,9 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
717
717
 
718
718
  if (vtkImageLabelOutline === true) {
719
719
  var labelOutlineThickness = actor.getProperty().getLabelOutlineThickness();
720
+ var labelOutlineOpacity = actor.getProperty().getLabelOutlineOpacity();
720
721
  program.setUniformi('outlineThickness', labelOutlineThickness);
722
+ program.setUniformf('outlineOpacity', labelOutlineOpacity);
721
723
  }
722
724
 
723
725
  if (model.lastLightComplexity > 0) {