@ohif/app 3.10.0 → 3.10.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.
Files changed (47) hide show
  1. package/dist/{1919.bundle.fad7cb115701d2afd06f.js → 1919.bundle.6cb4a1f5ea770e504398.js} +2 -2
  2. package/dist/{1927.bundle.83810560c4d3a90eb7cf.js → 1927.bundle.5c25b9084f704a3582d2.js} +1 -1
  3. package/dist/{3396.bundle.858cfdfc5ab560840958.js → 2482.bundle.0947bc67ad4429d5fda3.js} +289 -1353
  4. package/dist/{2701.bundle.f1f15df81406d04851c4.js → 2701.bundle.87301d8d94693b5d5fcc.js} +2 -2
  5. package/dist/{2860.bundle.5d93c30e2df60e382bda.js → 2860.bundle.130f5c83c90c83017101.js} +1368 -28
  6. package/dist/{2914.bundle.a0a5ddfebfc9d429063d.js → 2914.bundle.adefec5b51b4955af1f9.js} +2 -0
  7. package/dist/{2932.bundle.e69c37b969d1844a01d3.js → 2932.bundle.2757ab993a28dab49d56.js} +4 -4
  8. package/dist/{3075.bundle.0624f6bf3f676f30d1b5.js → 3075.bundle.5d83563c3791a0d884df.js} +16 -3
  9. package/dist/{3353.bundle.184ebb9668df2cbebd26.js → 3353.bundle.1b2d3da25de70f5f1042.js} +33 -4
  10. package/dist/{3984.bundle.340254f70eefe76b8133.js → 3984.bundle.1248e382e82ee04eff72.js} +17 -12
  11. package/dist/{4113.bundle.49f82d38be003e19e515.js → 4113.bundle.1a3202dd6a1b2e6b9d5d.js} +5 -5
  12. package/dist/{4526.bundle.fbdd617a934353019be3.js → 4526.bundle.54c0b8f753ed5c39f6c5.js} +2 -2
  13. package/dist/{6029.bundle.c5d0baf943c367e7bcb8.js → 6029.bundle.a4206e2a2e75c7b1ad7b.js} +403 -52
  14. package/dist/{9464.bundle.bc0e50f8b60edfdcb9d4.js → 6066.bundle.89df990e4f257e8ac73b.js} +1603 -44
  15. package/dist/{6201.bundle.83db906635608599520a.js → 6201.bundle.b584d7554570344d9170.js} +4 -4
  16. package/dist/{7197.bundle.e5fa41fa6bfd9a88c7ad.js → 7197.bundle.2032eea26c084877d172.js} +3 -3
  17. package/dist/{810.bundle.4e580dc32bbcd921ff41.js → 810.bundle.8b29de53f9632f0f1bf9.js} +4 -4
  18. package/dist/{8185.bundle.0dde37bbed6dbbf102d3.js → 8185.bundle.c7e0ab58fa8f7070de26.js} +22 -16
  19. package/dist/{8558.bundle.51f082f0c68b3aedf54a.js → 8558.bundle.24bb90c2d5a0857577c5.js} +1 -1
  20. package/dist/{7241.bundle.3ec18bc9a5464d5c5c67.js → 8572.bundle.bd98ac784dae1e224a52.js} +135 -47
  21. package/dist/{3166.bundle.0f97235b970e279a4707.js → 908.bundle.7f901ab4610793bb5ee3.js} +29 -5
  22. package/dist/{934.bundle.33cc4ef2fdfd34987c87.js → 934.bundle.441c775536d8be5029af.js} +2 -2
  23. package/dist/{963.bundle.abae2bcc3d87b9260e6a.js → 963.bundle.4b88a54196fdd1976d6c.js} +2 -2
  24. package/dist/{9890.bundle.37d7ed265c0454337a57.js → 9890.bundle.b4c265e3609512785ae8.js} +2 -2
  25. package/dist/{9977.bundle.071821200c1921021d29.js → 9977.bundle.4f44190c1a5d6a69bc00.js} +3 -1
  26. package/dist/{app.bundle.c8d19c9902cb9ea1bb55.js → app.bundle.223c009cd6f636320f76.js} +2170 -1783
  27. package/dist/app.bundle.css +2 -2
  28. package/dist/{compute.bundle.f0c30502c027d04e94f2.js → compute.bundle.83a75c96620eedca973e.js} +3 -3
  29. package/dist/index.html +1 -1
  30. package/dist/{polySeg.bundle.707e6d9b0342d06ffa49.js → polySeg.bundle.30f6f13491f48e597605.js} +3 -3
  31. package/dist/sw.js +1 -1
  32. package/package.json +19 -19
  33. /package/dist/{1459.bundle.b2f3d51daf0583cbcf0b.js → 1459.bundle.ea2023918c1ef217d23a.js} +0 -0
  34. /package/dist/{1807.bundle.a22cda201e86b973c886.js → 1807.bundle.a04f3486b00cdcc6a305.js} +0 -0
  35. /package/dist/{213.bundle.36febd3a2c038128c92e.js → 213.bundle.e861b773d4779d7d724a.js} +0 -0
  36. /package/dist/{2424.bundle.8e789b3206f967d42032.js → 2424.bundle.425cb2260521f2a23f70.js} +0 -0
  37. /package/dist/{3658.bundle.d8fd1c155e97829ce8ee.js → 3658.bundle.a6a9c2e1b32d92e3b621.js} +0 -0
  38. /package/dist/{4759.bundle.a31dcfd4c3054e2ea980.js → 4759.bundle.d1fdc8e827d54c0f40c9.js} +0 -0
  39. /package/dist/{4991.bundle.f72a01fd158167a94ae8.js → 4991.bundle.8578c7880edc0fbef374.js} +0 -0
  40. /package/dist/{5674.bundle.b9c6a5039c2113262ae5.js → 5674.bundle.49f5a714f733cf20d560.js} +0 -0
  41. /package/dist/{6027.bundle.9f8dfb6fed029717ef3a.js → 6027.bundle.8e1b6021f0d570eb85f5.js} +0 -0
  42. /package/dist/{7639.bundle.a24b3a7b0abb6178e9bd.js → 7639.bundle.b622eafdc74d9bfc1280.js} +0 -0
  43. /package/dist/{8228.bundle.74c8ca5e66a44db80464.js → 8228.bundle.f520ecf3c0a8998e770a.js} +0 -0
  44. /package/dist/{85.bundle.31ab810e6a6779ff067c.js → 85.bundle.a27a1466f85e01adf8e8.js} +0 -0
  45. /package/dist/{8815.bundle.7db9450eac27c6ad9054.js → 8815.bundle.096958a5ae7253911a2e.js} +0 -0
  46. /package/dist/{9026.bundle.37f3be98189966cc21e4.js → 9026.bundle.019d8b4b70096b94302e.js} +0 -0
  47. /package/dist/{9862.bundle.ccb787865a82b9696113.js → 9862.bundle.b0ea941458506379f666.js} +0 -0
@@ -1,4 +1,4 @@
1
- (globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[3396],{
1
+ (globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[2482],{
2
2
 
3
3
  /***/ 46347:
4
4
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
@@ -7,7 +7,7 @@
7
7
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8
8
  /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
9
9
  /* harmony export */ });
10
- /* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(33739);
10
+ /* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(642);
11
11
  /* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction_ColorMaps__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(660);
12
12
  /* harmony import */ var _kitware_vtk_js_Common_DataModel_PiecewiseFunction__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(99341);
13
13
  /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3823);
@@ -372,19 +372,14 @@ class BaseVolumeViewport extends _Viewport__WEBPACK_IMPORTED_MODULE_18__/* ["def
372
372
  const { volumeActor } = applicableVolumeActorInfo;
373
373
  const ofun = _kitware_vtk_js_Common_DataModel_PiecewiseFunction__WEBPACK_IMPORTED_MODULE_2__/* ["default"].newInstance */ .Ay.newInstance();
374
374
  if (typeof colormap.opacity === 'number') {
375
- const range = volumeActor
376
- .getProperty()
377
- .getRGBTransferFunction(0)
378
- .getRange();
379
- ofun.addPoint(range[0], colormap.opacity);
380
- ofun.addPoint(range[1], colormap.opacity);
375
+ (0,_utilities_colormap__WEBPACK_IMPORTED_MODULE_11__.updateOpacity)(volumeActor, colormap.opacity);
381
376
  }
382
377
  else {
383
378
  colormap.opacity.forEach(({ opacity, value }) => {
384
379
  ofun.addPoint(value, opacity);
385
380
  });
381
+ volumeActor.getProperty().setScalarOpacity(0, ofun);
386
382
  }
387
- volumeActor.getProperty().setScalarOpacity(0, ofun);
388
383
  if (!this.viewportProperties.colormap) {
389
384
  this.viewportProperties.colormap = {};
390
385
  }
@@ -571,6 +566,7 @@ class BaseVolumeViewport extends _Viewport__WEBPACK_IMPORTED_MODULE_18__/* ["def
571
566
  const isNegativeNormal = (0,_utilities_isEqual__WEBPACK_IMPORTED_MODULE_24__/* .isEqualNegative */ .WC)(viewPlaneNormal, refViewPlaneNormal);
572
567
  const isSameNormal = (0,_utilities_isEqual__WEBPACK_IMPORTED_MODULE_24__/* ["default"] */ .Ay)(viewPlaneNormal, refViewPlaneNormal);
573
568
  if (typeof sliceIndex === 'number' &&
569
+ volumeId !== undefined &&
574
570
  viewRef.volumeId === volumeId &&
575
571
  (isNegativeNormal || isSameNormal)) {
576
572
  const { currentStepIndex, sliceRangeInfo, numScrollSteps } = (0,_utilities_getVolumeViewportScrollInfo__WEBPACK_IMPORTED_MODULE_20__/* ["default"] */ .A)(this, volumeId, true);
@@ -588,17 +584,6 @@ class BaseVolumeViewport extends _Viewport__WEBPACK_IMPORTED_MODULE_18__/* ["def
588
584
  this.setViewReference(viewRef);
589
585
  return;
590
586
  }
591
- if (cameraFocalPoint) {
592
- const focalDelta = gl_matrix__WEBPACK_IMPORTED_MODULE_3__/* .vec3.subtract */ .eR.subtract([0, 0, 0], cameraFocalPoint, focalPoint);
593
- const useNormal = refViewPlaneNormal ?? viewPlaneNormal;
594
- const normalDot = gl_matrix__WEBPACK_IMPORTED_MODULE_3__/* .vec3.dot */ .eR.dot(focalDelta, useNormal);
595
- if (!(0,_utilities_isEqual__WEBPACK_IMPORTED_MODULE_24__/* ["default"] */ .Ay)(normalDot, 0)) {
596
- gl_matrix__WEBPACK_IMPORTED_MODULE_3__/* .vec3.scale */ .eR.scale(focalDelta, useNormal, normalDot);
597
- }
598
- const newFocal = gl_matrix__WEBPACK_IMPORTED_MODULE_3__/* .vec3.add */ .eR.add([0, 0, 0], focalPoint, focalDelta);
599
- const newPosition = gl_matrix__WEBPACK_IMPORTED_MODULE_3__/* .vec3.add */ .eR.add([0, 0, 0], position, focalDelta);
600
- this.setCamera({ focalPoint: newFocal, position: newPosition });
601
- }
602
587
  if (referencedImageId && this.isInAcquisitionPlane()) {
603
588
  const imagePlaneModule = _metaData__WEBPACK_IMPORTED_MODULE_28__.get(_enums__WEBPACK_IMPORTED_MODULE_6__.MetadataModules.IMAGE_PLANE, referencedImageId);
604
589
  const { imagePositionPatient } = imagePlaneModule;
@@ -610,12 +595,36 @@ class BaseVolumeViewport extends _Viewport__WEBPACK_IMPORTED_MODULE_18__/* ["def
610
595
  focalPoint: newImagePositionPatient,
611
596
  });
612
597
  this.render();
598
+ return;
599
+ }
600
+ if (cameraFocalPoint) {
601
+ const focalDelta = gl_matrix__WEBPACK_IMPORTED_MODULE_3__/* .vec3.subtract */ .eR.subtract([0, 0, 0], cameraFocalPoint, focalPoint);
602
+ const useNormal = refViewPlaneNormal ?? viewPlaneNormal;
603
+ const normalDot = gl_matrix__WEBPACK_IMPORTED_MODULE_3__/* .vec3.dot */ .eR.dot(focalDelta, useNormal);
604
+ if (!(0,_utilities_isEqual__WEBPACK_IMPORTED_MODULE_24__/* ["default"] */ .Ay)(normalDot, 0)) {
605
+ gl_matrix__WEBPACK_IMPORTED_MODULE_3__/* .vec3.scale */ .eR.scale(focalDelta, useNormal, normalDot);
606
+ }
607
+ const newFocal = gl_matrix__WEBPACK_IMPORTED_MODULE_3__/* .vec3.add */ .eR.add([0, 0, 0], focalPoint, focalDelta);
608
+ const newPosition = gl_matrix__WEBPACK_IMPORTED_MODULE_3__/* .vec3.add */ .eR.add([0, 0, 0], position, focalDelta);
609
+ this.setCamera({ focalPoint: newFocal, position: newPosition });
613
610
  }
614
611
  }
615
612
  else {
616
613
  throw new Error(`Incompatible view refs: ${refFrameOfReference}!==${this.getFrameOfReferenceUID()}`);
617
614
  }
618
615
  }
616
+ setThreshold(colormap, volumeId) {
617
+ const applicableVolumeActorInfo = this._getApplicableVolumeActor(volumeId);
618
+ if (!applicableVolumeActorInfo) {
619
+ return;
620
+ }
621
+ const { volumeActor } = applicableVolumeActorInfo;
622
+ (0,_utilities_colormap__WEBPACK_IMPORTED_MODULE_11__.updateThreshold)(volumeActor, colormap.threshold);
623
+ if (!this.viewportProperties.colormap) {
624
+ this.viewportProperties.colormap = {};
625
+ }
626
+ this.viewportProperties.colormap.threshold = colormap.threshold;
627
+ }
619
628
  setProperties({ voiRange, VOILUTFunction, invert, colormap, preset, interpolationType, slabThickness, } = {}, volumeId, suppressEvents = false) {
620
629
  if (this.globalDefaultProperties == null) {
621
630
  this.setDefaultProperties({
@@ -636,6 +645,9 @@ class BaseVolumeViewport extends _Viewport__WEBPACK_IMPORTED_MODULE_18__/* ["def
636
645
  if (colormap?.opacity != null) {
637
646
  this.setOpacity(colormap, volumeId);
638
647
  }
648
+ if (colormap?.threshold != null) {
649
+ this.setThreshold(colormap, volumeId);
650
+ }
639
651
  if (voiRange !== undefined) {
640
652
  this.setVOI(voiRange, volumeId, suppressEvents);
641
653
  }
@@ -898,14 +910,34 @@ class BaseVolumeViewport extends _Viewport__WEBPACK_IMPORTED_MODULE_18__/* ["def
898
910
  throw new Error('Invalid orientation object. It must contain viewPlaneNormal and viewUp');
899
911
  }
900
912
  }
901
- else if (typeof orientation === 'string' &&
902
- _constants__WEBPACK_IMPORTED_MODULE_5__.MPR_CAMERA_VALUES[orientation]) {
903
- this.viewportProperties.orientation = orientation;
904
- return _constants__WEBPACK_IMPORTED_MODULE_5__.MPR_CAMERA_VALUES[orientation];
913
+ else if (typeof orientation === 'string') {
914
+ if (orientation === 'acquisition') {
915
+ return this._getAcquisitionPlaneOrientation();
916
+ }
917
+ else if (_constants__WEBPACK_IMPORTED_MODULE_5__.MPR_CAMERA_VALUES[orientation]) {
918
+ this.viewportProperties.orientation = orientation;
919
+ return _constants__WEBPACK_IMPORTED_MODULE_5__.MPR_CAMERA_VALUES[orientation];
920
+ }
905
921
  }
906
- else {
907
- throw new Error(`Invalid orientation: ${orientation}. Valid orientations are: ${Object.keys(_constants__WEBPACK_IMPORTED_MODULE_5__.MPR_CAMERA_VALUES).join(', ')}`);
922
+ throw new Error(`Invalid orientation: ${orientation}. Valid orientations are: ${Object.keys(_constants__WEBPACK_IMPORTED_MODULE_5__.MPR_CAMERA_VALUES).join(', ')}`);
923
+ }
924
+ _getAcquisitionPlaneOrientation() {
925
+ const actorEntry = this.getDefaultActor();
926
+ if (!actorEntry) {
927
+ return;
928
+ }
929
+ const volumeId = this.getVolumeId();
930
+ const imageVolume = _cache_cache__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Ay.getVolume(volumeId);
931
+ if (!imageVolume) {
932
+ throw new Error(`imageVolume with id: ${volumeId} does not exist in cache`);
908
933
  }
934
+ const { direction } = imageVolume;
935
+ const viewPlaneNormal = direction.slice(6, 9).map((x) => -x);
936
+ const viewUp = direction.slice(3, 6).map((x) => -x);
937
+ return {
938
+ viewPlaneNormal,
939
+ viewUp,
940
+ };
909
941
  }
910
942
  getSlabThickness() {
911
943
  const actors = this.getActors();
@@ -984,8 +1016,8 @@ var DataArray = __webpack_require__(42008);
984
1016
  var ImageData = __webpack_require__(58498);
985
1017
  // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Rendering/Core/Camera.js
986
1018
  var Camera = __webpack_require__(26719);
987
- // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Rendering/Core/ColorTransferFunction.js + 1 modules
988
- var ColorTransferFunction = __webpack_require__(33739);
1019
+ // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Rendering/Core/ColorTransferFunction.js
1020
+ var ColorTransferFunction = __webpack_require__(642);
989
1021
  // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps.js + 1 modules
990
1022
  var ColorMaps = __webpack_require__(660);
991
1023
  // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Rendering/Core/ImageMapper/Constants.js
@@ -3260,6 +3292,10 @@ class StackViewport extends Viewport/* default */.A {
3260
3292
  origin = [0, 0, 0];
3261
3293
  }
3262
3294
  this._imageData.setOrigin(origin);
3295
+ const actor = this.getActor(this.id);
3296
+ if (actor) {
3297
+ actor.referencedId = image.imageId;
3298
+ }
3263
3299
  (0,updateVTKImageDataWithCornerstoneImage/* updateVTKImageDataWithCornerstoneImage */.J)(this._imageData, image);
3264
3300
  }
3265
3301
  _loadAndDisplayImage(imageId, imageIdIndex) {
@@ -3527,7 +3563,7 @@ class StackViewport extends Viewport/* default */.A {
3527
3563
  oldActors[0].actor = actor;
3528
3564
  }
3529
3565
  else {
3530
- oldActors.unshift({ uid: this.id, actor });
3566
+ oldActors.unshift({ uid: this.id, actor, referencedId: image.imageId });
3531
3567
  }
3532
3568
  this.setActors(oldActors);
3533
3569
  const { viewPlaneNormal, viewUp } = this._getCameraOrientation(direction);
@@ -3677,6 +3713,7 @@ class StackViewport extends Viewport/* default */.A {
3677
3713
  return Promise.resolve(this.getCurrentImageId());
3678
3714
  }
3679
3715
  const imageIdPromise = this._setImageIdIndex(imageIdIndex);
3716
+ this.targetImageIdIndex = imageIdIndex;
3680
3717
  return imageIdPromise;
3681
3718
  }
3682
3719
  calibrateSpacing(imageId) {
@@ -5168,22 +5205,41 @@ class Viewport {
5168
5205
  return this.getActors()[index];
5169
5206
  }
5170
5207
  setActors(actors) {
5208
+ const currentActors = this.getActors();
5171
5209
  this.removeAllActors();
5172
5210
  this.addActors(actors, { resetCamera: true });
5211
+ (0,_utilities_triggerEvent__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A)(this.element, _enums_Events__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .A.ACTORS_CHANGED, {
5212
+ viewportId: this.id,
5213
+ removedActors: currentActors,
5214
+ addedActors: actors,
5215
+ currentActors: actors,
5216
+ });
5173
5217
  }
5174
5218
  _removeActor(actorUID) {
5175
5219
  const actorEntry = this.getActor(actorUID);
5176
5220
  if (!actorEntry) {
5177
- console.warn(`Actor ${actorUID} does not exist for this viewport`);
5221
+ console.warn(`Actor ${actorUID} does not exist in ${this.id}, can't remove`);
5178
5222
  return;
5179
5223
  }
5180
5224
  const renderer = this.getRenderer();
5181
- renderer.removeViewProp(actorEntry.actor);
5225
+ renderer.removeActor(actorEntry.actor);
5182
5226
  this._actors.delete(actorUID);
5227
+ return actorEntry;
5183
5228
  }
5184
5229
  removeActors(actorUIDs) {
5230
+ const removedActors = [];
5185
5231
  actorUIDs.forEach((actorUID) => {
5186
- this._removeActor(actorUID);
5232
+ const removedActor = this._removeActor(actorUID);
5233
+ if (removedActor) {
5234
+ removedActors.push(removedActor);
5235
+ }
5236
+ });
5237
+ const currentActors = this.getActors();
5238
+ (0,_utilities_triggerEvent__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A)(this.element, _enums_Events__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .A.ACTORS_CHANGED, {
5239
+ viewportId: this.id,
5240
+ removedActors,
5241
+ addedActors: [],
5242
+ currentActors,
5187
5243
  });
5188
5244
  }
5189
5245
  addActors(actors, options = {}) {
@@ -5203,6 +5259,12 @@ class Viewport {
5203
5259
  this.setViewReference(prevViewRef);
5204
5260
  this.setViewPresentation(prevViewPresentation);
5205
5261
  }
5262
+ (0,_utilities_triggerEvent__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A)(this.element, _enums_Events__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .A.ACTORS_CHANGED, {
5263
+ viewportId: this.id,
5264
+ removedActors: [],
5265
+ addedActors: actors,
5266
+ currentActors: this.getActors(),
5267
+ });
5206
5268
  }
5207
5269
  addActor(actorEntry) {
5208
5270
  const { uid: actorUID, actor } = actorEntry;
@@ -5222,10 +5284,23 @@ class Viewport {
5222
5284
  renderer?.addActor(actor);
5223
5285
  this._actors.set(actorUID, Object.assign({}, actorEntry));
5224
5286
  this.updateCameraClippingPlanesAndRange();
5287
+ (0,_utilities_triggerEvent__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A)(this.element, _enums_Events__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .A.ACTORS_CHANGED, {
5288
+ viewportId: this.id,
5289
+ removedActors: [],
5290
+ addedActors: [actorEntry],
5291
+ currentActors: this.getActors(),
5292
+ });
5225
5293
  }
5226
5294
  removeAllActors() {
5295
+ const currentActors = this.getActors();
5227
5296
  this.getRenderer()?.removeAllViewProps();
5228
5297
  this._actors = new Map();
5298
+ (0,_utilities_triggerEvent__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A)(this.element, _enums_Events__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .A.ACTORS_CHANGED, {
5299
+ viewportId: this.id,
5300
+ removedActors: currentActors,
5301
+ addedActors: [],
5302
+ currentActors: [],
5303
+ });
5229
5304
  return;
5230
5305
  }
5231
5306
  resetCameraNoEvent() {
@@ -5385,7 +5460,15 @@ class Viewport {
5385
5460
  flipVertical: false,
5386
5461
  });
5387
5462
  const previousCamera = this.getCamera();
5388
- const bounds = renderer.computeVisiblePropBounds();
5463
+ let bounds;
5464
+ const defaultActor = this.getDefaultActor();
5465
+ if (defaultActor && (0,_utilities_actorCheck__WEBPACK_IMPORTED_MODULE_8__/* .isImageActor */ .e)(defaultActor)) {
5466
+ const imageData = defaultActor.actor.getMapper().getInputData();
5467
+ bounds = imageData.getBounds();
5468
+ }
5469
+ else {
5470
+ bounds = renderer.computeVisiblePropBounds();
5471
+ }
5389
5472
  const focalPoint = [0, 0, 0];
5390
5473
  const imageData = this.getDefaultImageData();
5391
5474
  if (imageData) {
@@ -6136,11 +6219,11 @@ class VolumeViewport extends BaseVolumeViewport/* default */.A {
6136
6219
  setOrientation(orientation, immediate = true) {
6137
6220
  let viewPlaneNormal, viewUp;
6138
6221
  if (typeof orientation === 'string') {
6139
- if (constants.MPR_CAMERA_VALUES[orientation]) {
6140
- ({ viewPlaneNormal, viewUp } = constants.MPR_CAMERA_VALUES[orientation]);
6222
+ if (orientation === enums.OrientationAxis.ACQUISITION) {
6223
+ ({ viewPlaneNormal, viewUp } = super._getAcquisitionPlaneOrientation());
6141
6224
  }
6142
- else if (orientation === 'acquisition') {
6143
- ({ viewPlaneNormal, viewUp } = this._getAcquisitionPlaneOrientation());
6225
+ else if (constants.MPR_CAMERA_VALUES[orientation]) {
6226
+ ({ viewPlaneNormal, viewUp } = constants.MPR_CAMERA_VALUES[orientation]);
6144
6227
  }
6145
6228
  else {
6146
6229
  throw new Error(`Invalid orientation: ${orientation}. Use Enums.OrientationAxis instead.`);
@@ -6173,24 +6256,6 @@ class VolumeViewport extends BaseVolumeViewport/* default */.A {
6173
6256
  activeCamera.setClippingRange(constants.RENDERING_DEFAULTS.MINIMUM_SLAB_THICKNESS, constants.RENDERING_DEFAULTS.MAXIMUM_RAY_DISTANCE);
6174
6257
  }
6175
6258
  }
6176
- _getAcquisitionPlaneOrientation() {
6177
- const actorEntry = this.getDefaultActor();
6178
- if (!actorEntry) {
6179
- return;
6180
- }
6181
- const volumeId = this.getVolumeId();
6182
- const imageVolume = cache/* default */.Ay.getVolume(volumeId);
6183
- if (!imageVolume) {
6184
- throw new Error(`imageVolume with id: ${volumeId} does not exist in cache`);
6185
- }
6186
- const { direction } = imageVolume;
6187
- const viewPlaneNormal = direction.slice(6, 9).map((x) => -x);
6188
- const viewUp = direction.slice(3, 6).map((x) => -x);
6189
- return {
6190
- viewPlaneNormal,
6191
- viewUp,
6192
- };
6193
- }
6194
6259
  _setViewPlaneToAcquisitionPlane(imageVolume) {
6195
6260
  let viewPlaneNormal, viewUp;
6196
6261
  if (imageVolume) {
@@ -9195,8 +9260,8 @@ var macros2 = __webpack_require__(28906);
9195
9260
  var BoundingBox = __webpack_require__(21734);
9196
9261
  // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Rendering/Core/Prop3D.js
9197
9262
  var Prop3D = __webpack_require__(62502);
9198
- // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Rendering/Core/ColorTransferFunction.js + 1 modules
9199
- var ColorTransferFunction = __webpack_require__(33739);
9263
+ // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Rendering/Core/ColorTransferFunction.js
9264
+ var ColorTransferFunction = __webpack_require__(642);
9200
9265
  // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Common/DataModel/PiecewiseFunction.js
9201
9266
  var PiecewiseFunction = __webpack_require__(99341);
9202
9267
  // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Rendering/Core/VolumeProperty/Constants.js
@@ -17783,11 +17848,12 @@ class BaseStreamingImageVolume extends _ImageVolume__WEBPACK_IMPORTED_MODULE_9__
17783
17848
  rescaleIntercept: modalityLutModule.rescaleIntercept,
17784
17849
  modality: generalSeriesModule.modality,
17785
17850
  };
17786
- if (scalingParameters.modality === 'PT') {
17787
- const suvFactor = _metaData__WEBPACK_IMPORTED_MODULE_0__.get('scalingModule', imageId);
17788
- if (suvFactor) {
17789
- this._addScalingToVolume(suvFactor);
17790
- scalingParameters.suvbw = suvFactor.suvbw;
17851
+ const modality = scalingParameters.modality;
17852
+ if (modality === 'PT' || modality === 'RTDOSE') {
17853
+ const scalingFactor = _metaData__WEBPACK_IMPORTED_MODULE_0__.get('scalingModule', imageId);
17854
+ if (scalingFactor) {
17855
+ this._addScalingToVolume(scalingFactor);
17856
+ Object.assign(scalingParameters, scalingFactor);
17791
17857
  }
17792
17858
  }
17793
17859
  const floatAfterScale = (0,_utilities_hasFloatScalingParameters__WEBPACK_IMPORTED_MODULE_6__/* .hasFloatScalingParameters */ .a)(scalingParameters);
@@ -22025,6 +22091,7 @@ var Events;
22025
22091
  Events["GEOMETRY_LOADED"] = "GEOMETRY_LOADED";
22026
22092
  Events["GEOMETRY_LOAD_PROGRESS"] = "GEOMETRY_LOAD_PROGRESS";
22027
22093
  Events["GEOMETRY_LOADED_FAILED"] = "GEOMETRY_LOADED_FAILED";
22094
+ Events["ACTORS_CHANGED"] = "CORNERSTONE_ACTORS_CHANGED";
22028
22095
  })(Events || (Events = {}));
22029
22096
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Events);
22030
22097
 
@@ -32800,6 +32867,8 @@ function getConstructorFromType(bufferType, isVolumeBuffer) {
32800
32867
  return Float32Array;
32801
32868
  case 'Uint8Array':
32802
32869
  return Uint8Array;
32870
+ case 'Uint32Array':
32871
+ return Uint32Array;
32803
32872
  case 'Uint16Array':
32804
32873
  case 'Int16Array':
32805
32874
  if (!isVolumeBuffer) {
@@ -32811,7 +32880,7 @@ function getConstructorFromType(bufferType, isVolumeBuffer) {
32811
32880
  }
32812
32881
  default:
32813
32882
  if (bufferType) {
32814
- throw new Error('TargetBuffer should be Float32Array, Uint8Array, Uint16Array, or Int16Array');
32883
+ throw new Error('TargetBuffer should be Float32Array, Uint8Array, Uint16Array, Int16Array, or Uint32Array');
32815
32884
  }
32816
32885
  else {
32817
32886
  return Float32Array;
@@ -32894,6 +32963,10 @@ function uuidv4() {
32894
32963
  /* harmony export */ zj: () => (/* binding */ getConfig)
32895
32964
  /* harmony export */ });
32896
32965
  /* unused harmony exports setConfig, getAddOns */
32966
+ /* harmony import */ var _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15327);
32967
+ /* harmony import */ var _enums_Events__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(94021);
32968
+
32969
+
32897
32970
  let config = {};
32898
32971
  function getConfig() {
32899
32972
  return config;
@@ -35210,6 +35283,7 @@ class ToolStyle {
35210
35283
  textBoxLinkLineDash: '2,3',
35211
35284
  textBoxShadow: true,
35212
35285
  markerSize: '10',
35286
+ angleArcLineDash: '',
35213
35287
  };
35214
35288
  this._initializeConfig(defaultConfig);
35215
35289
  }
@@ -36769,6 +36843,9 @@ BaseTool.toolName = 'BaseTool';
36769
36843
  /* harmony import */ var _removeContourFromElement__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(87420);
36770
36844
  /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(36625);
36771
36845
  /* harmony import */ var _utilities_segmentation_computeAndAddRepresentation__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(27479);
36846
+ /* harmony import */ var _utilities_segmentation_getUniqueSegmentIndices__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(25758);
36847
+ /* harmony import */ var _stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(82056);
36848
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(3823);
36772
36849
 
36773
36850
 
36774
36851
 
@@ -36776,7 +36853,10 @@ BaseTool.toolName = 'BaseTool';
36776
36853
 
36777
36854
 
36778
36855
 
36779
- let polySegConversionInProgress = false;
36856
+
36857
+
36858
+
36859
+ const polySegConversionInProgressForViewportId = new Map();
36780
36860
  const processedViewportSegmentations = new Map();
36781
36861
  function removeRepresentation(viewportId, segmentationId, renderImmediate = false) {
36782
36862
  const enabledElement = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.getEnabledElementByViewportId)(viewportId);
@@ -36784,10 +36864,10 @@ function removeRepresentation(viewportId, segmentationId, renderImmediate = fals
36784
36864
  return;
36785
36865
  }
36786
36866
  const { viewport } = enabledElement;
36867
+ (0,_removeContourFromElement__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .A)(viewportId, segmentationId);
36787
36868
  if (!renderImmediate) {
36788
36869
  return;
36789
36870
  }
36790
- (0,_removeContourFromElement__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .A)(viewportId, segmentationId);
36791
36871
  viewport.render();
36792
36872
  }
36793
36873
  async function render(viewport, contourRepresentation) {
@@ -36797,13 +36877,13 @@ async function render(viewport, contourRepresentation) {
36797
36877
  return;
36798
36878
  }
36799
36879
  let contourData = segmentation.representationData[_enums_SegmentationRepresentations__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Contour];
36880
+ const polySeg = (0,_config__WEBPACK_IMPORTED_MODULE_5__/* .getPolySeg */ .Qy)();
36800
36881
  if (!contourData &&
36801
36882
  (0,_config__WEBPACK_IMPORTED_MODULE_5__/* .getPolySeg */ .Qy)()?.canComputeRequestedRepresentation(segmentationId, _enums_SegmentationRepresentations__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Contour) &&
36802
- !polySegConversionInProgress) {
36803
- polySegConversionInProgress = true;
36804
- const polySeg = (0,_config__WEBPACK_IMPORTED_MODULE_5__/* .getPolySeg */ .Qy)();
36883
+ !polySegConversionInProgressForViewportId.get(viewport.id)) {
36884
+ polySegConversionInProgressForViewportId.set(viewport.id, true);
36805
36885
  contourData = await (0,_utilities_segmentation_computeAndAddRepresentation__WEBPACK_IMPORTED_MODULE_6__/* .computeAndAddRepresentation */ .d)(segmentationId, _enums_SegmentationRepresentations__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Contour, () => polySeg.computeContourData(segmentationId, { viewport }), () => undefined);
36806
- polySegConversionInProgress = false;
36886
+ polySegConversionInProgressForViewportId.set(viewport.id, false);
36807
36887
  }
36808
36888
  else if (!contourData && !(0,_config__WEBPACK_IMPORTED_MODULE_5__/* .getPolySeg */ .Qy)()) {
36809
36889
  console.debug(`No contour data found for segmentationId ${segmentationId} and PolySeg add-on is not configured. Unable to convert from other representations to contour. Please register PolySeg using cornerstoneTools.init({ addons: { polySeg } }) to enable automatic conversion.`);
@@ -36814,8 +36894,101 @@ async function render(viewport, contourRepresentation) {
36814
36894
  if (!contourData.geometryIds?.length) {
36815
36895
  return;
36816
36896
  }
36897
+ let hasContourDataButNotMatchingViewport = false;
36898
+ const viewportNormal = viewport.getCamera().viewPlaneNormal;
36899
+ if (contourData.annotationUIDsMap) {
36900
+ hasContourDataButNotMatchingViewport = !_checkContourNormalsMatchViewport(contourData.annotationUIDsMap, viewportNormal);
36901
+ }
36902
+ if (contourData.geometryIds.length > 0) {
36903
+ hasContourDataButNotMatchingViewport = !_checkContourGeometryMatchViewport(contourData.geometryIds, viewportNormal);
36904
+ }
36905
+ const viewportProcessed = processedViewportSegmentations.get(viewport.id) || new Set();
36906
+ if (hasContourDataButNotMatchingViewport &&
36907
+ !polySegConversionInProgressForViewportId.get(viewport.id) &&
36908
+ !viewportProcessed.has(segmentationId) &&
36909
+ viewport.viewportStatus === _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.Enums.ViewportStatus.RENDERED) {
36910
+ polySegConversionInProgressForViewportId.set(viewport.id, true);
36911
+ const segmentIndices = (0,_utilities_segmentation_getUniqueSegmentIndices__WEBPACK_IMPORTED_MODULE_7__/* .getUniqueSegmentIndices */ .O)(segmentationId);
36912
+ const surfacesInfo = await polySeg.computeSurfaceData(segmentationId, {
36913
+ segmentIndices,
36914
+ viewport,
36915
+ });
36916
+ const geometryIds = surfacesInfo.geometryIds;
36917
+ const pointsAndPolys = [];
36918
+ for (const geometryId of geometryIds.values()) {
36919
+ const geometry = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.cache.getGeometry(geometryId);
36920
+ const data = geometry.data;
36921
+ pointsAndPolys.push({
36922
+ points: data.points,
36923
+ polys: data.polys,
36924
+ segmentIndex: data.segmentIndex,
36925
+ id: data.segmentIndex,
36926
+ });
36927
+ }
36928
+ const polyDataCache = await polySeg.clipAndCacheSurfacesForViewport(pointsAndPolys, viewport);
36929
+ const rawResults = polySeg.extractContourData(polyDataCache);
36930
+ const annotationUIDsMap = polySeg.createAndAddContourSegmentationsFromClippedSurfaces(rawResults, viewport, segmentationId);
36931
+ contourData.annotationUIDsMap = new Map([
36932
+ ...contourData.annotationUIDsMap,
36933
+ ...annotationUIDsMap,
36934
+ ]);
36935
+ viewportProcessed.add(segmentationId);
36936
+ processedViewportSegmentations.set(viewport.id, viewportProcessed);
36937
+ polySegConversionInProgressForViewportId.set(viewport.id, false);
36938
+ }
36817
36939
  (0,_contourHandler_handleContourSegmentation__WEBPACK_IMPORTED_MODULE_2__/* .handleContourSegmentation */ .d)(viewport, contourData.geometryIds, contourData.annotationUIDsMap, contourRepresentation);
36818
36940
  }
36941
+ function _checkContourGeometryMatchViewport(geometryIds, viewportNormal) {
36942
+ let validGeometry = null;
36943
+ let geometryData = null;
36944
+ for (const geometryId of geometryIds) {
36945
+ const geometry = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.cache.getGeometry(geometryId);
36946
+ if (!geometry) {
36947
+ continue;
36948
+ }
36949
+ const data = geometry.data;
36950
+ if (data.contours?.[0]?.points?.length >= 3) {
36951
+ validGeometry = geometry;
36952
+ geometryData = data;
36953
+ break;
36954
+ }
36955
+ }
36956
+ if (!validGeometry || !geometryData) {
36957
+ return false;
36958
+ }
36959
+ const contours = geometryData.contours;
36960
+ const points = contours[0].points;
36961
+ const point1 = points[0];
36962
+ const point2 = points[1];
36963
+ const point3 = points[2];
36964
+ let normal = gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.cross */ .eR.cross(gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.create */ .eR.create(), gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.sub */ .eR.sub(gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.create */ .eR.create(), point2, point1), gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.sub */ .eR.sub(gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.create */ .eR.create(), point3, point1));
36965
+ normal = gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.normalize */ .eR.normalize(gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.create */ .eR.create(), normal);
36966
+ const dotProduct = gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.dot */ .eR.dot(normal, viewportNormal);
36967
+ return Math.abs(dotProduct) > 0.9;
36968
+ }
36969
+ function _checkContourNormalsMatchViewport(annotationUIDsMap, viewportNormal) {
36970
+ const annotationUIDs = Array.from(annotationUIDsMap.values())
36971
+ .flat()
36972
+ .map((uidSet) => Array.from(uidSet))
36973
+ .flat();
36974
+ const randomAnnotationUIDs = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.getRandomSampleFromArray(annotationUIDs, 3);
36975
+ for (const annotationUID of randomAnnotationUIDs) {
36976
+ const annotation = (0,_stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_8__.getAnnotation)(annotationUID);
36977
+ if (annotation?.metadata) {
36978
+ if (!annotation.metadata.viewPlaneNormal) {
36979
+ continue;
36980
+ }
36981
+ const annotationNormal = annotation.metadata.viewPlaneNormal;
36982
+ const dotProduct = Math.abs(viewportNormal[0] * annotationNormal[0] +
36983
+ viewportNormal[1] * annotationNormal[1] +
36984
+ viewportNormal[2] * annotationNormal[2]);
36985
+ if (Math.abs(dotProduct - 1) > 0.01) {
36986
+ return false;
36987
+ }
36988
+ }
36989
+ }
36990
+ return true;
36991
+ }
36819
36992
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
36820
36993
  render,
36821
36994
  removeRepresentation,
@@ -37634,9 +37807,6 @@ class RectangleROIStartEndThresholdTool extends _annotation_RectangleROITool__WE
37634
37807
  if (this.configuration.calculatePointsInsideVolume) {
37635
37808
  this._computePointsInsideVolume(annotation, targetId, imageVolume, enabledElement);
37636
37809
  }
37637
- if (this.configuration.calculatePointsInsideVolume) {
37638
- this._computePointsInsideVolume(annotation, targetId, imageVolume, enabledElement);
37639
- }
37640
37810
  annotation.invalidated = false;
37641
37811
  (0,_stateManagement_annotation_helpers_state__WEBPACK_IMPORTED_MODULE_13__.triggerAnnotationModified)(annotation, viewport.element);
37642
37812
  return cachedStats;
@@ -39855,10 +40025,14 @@ async function calculateVolumeStatistics({ operationData, indices, unit, mode, }
39855
40025
  origin: imageData.getOrigin(),
39856
40026
  direction: imageData.getDirection(),
39857
40027
  };
40028
+ if (!imageInfo.scalarData?.length) {
40029
+ return;
40030
+ }
39858
40031
  const stats = await (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.getWebWorkerManager)().executeTask('compute', 'calculateSegmentsStatisticsVolume', {
39859
40032
  segmentationInfo,
39860
40033
  imageInfo,
39861
40034
  indices,
40035
+ unit,
39862
40036
  mode,
39863
40037
  });
39864
40038
  (0,_utilsForWorker__WEBPACK_IMPORTED_MODULE_1__/* .triggerWorkerProgress */ .sg)(_enums__WEBPACK_IMPORTED_MODULE_4__.WorkerTypes.COMPUTE_STATISTICS, 100);
@@ -40017,7 +40191,9 @@ function getSphereStats(testMax, radiusIJK, segData, imageVoxels, spacing) {
40017
40191
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
40018
40192
 
40019
40193
  "use strict";
40020
- /* unused harmony export getUniqueSegmentIndices */
40194
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
40195
+ /* harmony export */ O: () => (/* binding */ getUniqueSegmentIndices)
40196
+ /* harmony export */ });
40021
40197
  /* harmony import */ var _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15327);
40022
40198
  /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(99737);
40023
40199
  /* harmony import */ var _utilities__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(64063);
@@ -40027,11 +40203,11 @@ function getSphereStats(testMax, radiusIJK, segData, imageVoxels, spacing) {
40027
40203
 
40028
40204
 
40029
40205
  function getUniqueSegmentIndices(segmentationId) {
40030
- const cachedResult = getCachedSegmentIndices(segmentationId);
40206
+ const cachedResult = (0,_utilities__WEBPACK_IMPORTED_MODULE_2__/* .getCachedSegmentIndices */ .R1)(segmentationId);
40031
40207
  if (cachedResult) {
40032
40208
  return cachedResult;
40033
40209
  }
40034
- const segmentation = getSegmentation(segmentationId);
40210
+ const segmentation = (0,_stateManagement_segmentation_getSegmentation__WEBPACK_IMPORTED_MODULE_3__/* .getSegmentation */ .T)(segmentationId);
40035
40211
  if (!segmentation) {
40036
40212
  throw new Error(`No segmentation found for segmentationId ${segmentationId}`);
40037
40213
  }
@@ -40048,11 +40224,11 @@ function getUniqueSegmentIndices(segmentationId) {
40048
40224
  else {
40049
40225
  throw new Error(`Unsupported segmentation type: ${segmentation.representationData}`);
40050
40226
  }
40051
- setCachedSegmentIndices(segmentationId, indices);
40227
+ (0,_utilities__WEBPACK_IMPORTED_MODULE_2__/* .setCachedSegmentIndices */ .Dm)(segmentationId, indices);
40052
40228
  return indices;
40053
40229
  }
40054
40230
  function handleLabelmapSegmentation(segmentation, segmentationId) {
40055
- const labelmapData = segmentation.representationData[SegmentationRepresentations.Labelmap];
40231
+ const labelmapData = segmentation.representationData[_enums__WEBPACK_IMPORTED_MODULE_1__.SegmentationRepresentations.Labelmap];
40056
40232
  const keySet = new Set();
40057
40233
  if (labelmapData.imageIds) {
40058
40234
  addImageSegmentIndices(keySet, labelmapData.imageIds);
@@ -40065,7 +40241,7 @@ function handleLabelmapSegmentation(segmentation, segmentationId) {
40065
40241
  .sort((a, b) => a - b);
40066
40242
  }
40067
40243
  function addVolumeSegmentIndices(keySet, segmentationId) {
40068
- const volume = cache.getVolume(segmentationId);
40244
+ const volume = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.cache.getVolume(segmentationId);
40069
40245
  volume.voxelManager.forEach(({ value }) => {
40070
40246
  if (value !== 0) {
40071
40247
  keySet.add(value);
@@ -40074,7 +40250,7 @@ function addVolumeSegmentIndices(keySet, segmentationId) {
40074
40250
  }
40075
40251
  function addImageSegmentIndices(keySet, imageIds) {
40076
40252
  imageIds.forEach((segmentationImageId) => {
40077
- const image = cache.getImage(segmentationImageId);
40253
+ const image = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.cache.getImage(segmentationImageId);
40078
40254
  const scalarData = image.voxelManager.getScalarData();
40079
40255
  scalarData.forEach((segmentIndex) => {
40080
40256
  if (segmentIndex !== 0) {
@@ -40090,7 +40266,7 @@ function handleContourSegmentation(segmentation) {
40090
40266
  }
40091
40267
  const indices = new Set([...annotationUIDsMap.keys()]);
40092
40268
  geometryIds.forEach((geometryId) => {
40093
- const geometry = cache.getGeometry(geometryId);
40269
+ const geometry = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.cache.getGeometry(geometryId);
40094
40270
  indices.add(geometry.data.segmentIndex);
40095
40271
  });
40096
40272
  return Array.from(indices).sort((a, b) => a - b);
@@ -40630,9 +40806,11 @@ function thresholdVolumeByRange(segmentationVolume, thresholdVolumeInformation,
40630
40806
 
40631
40807
  "use strict";
40632
40808
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
40633
- /* harmony export */ HM: () => (/* binding */ setSegmentationDirty)
40809
+ /* harmony export */ Dm: () => (/* binding */ setCachedSegmentIndices),
40810
+ /* harmony export */ HM: () => (/* binding */ setSegmentationDirty),
40811
+ /* harmony export */ R1: () => (/* binding */ getCachedSegmentIndices)
40634
40812
  /* harmony export */ });
40635
- /* unused harmony exports getVoxelOverlap, processVolumes, setSegmentationClean, getCachedSegmentIndices, setCachedSegmentIndices */
40813
+ /* unused harmony exports getVoxelOverlap, processVolumes, setSegmentationClean */
40636
40814
  /* harmony import */ var _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15327);
40637
40815
  /* harmony import */ var _boundingBox_getBoundingBoxAroundShape__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(87063);
40638
40816
 
@@ -40866,7 +41044,7 @@ const getImageReferenceInfo = (segVolumeId, segImageIds) => {
40866
41044
  const refImage = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.cache.getImage(refImageId);
40867
41045
  const scalingModule = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.metaData.get('scalingModule', refImageId);
40868
41046
  const modalityUnitOptions = {
40869
- isPreScaled: Boolean(refImage.preScale?.scaled),
41047
+ isPreScaled: Boolean(refImage?.preScale?.scaled),
40870
41048
  isSuvScaled: typeof scalingModule?.suvbw === 'number',
40871
41049
  };
40872
41050
  return { refImageId, modalityUnitOptions };
@@ -53554,1276 +53732,6 @@ var vtkCamera$1 = {
53554
53732
 
53555
53733
 
53556
53734
 
53557
- /***/ }),
53558
-
53559
- /***/ 33739:
53560
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
53561
-
53562
- "use strict";
53563
-
53564
- // EXPORTS
53565
- __webpack_require__.d(__webpack_exports__, {
53566
- Ay: () => (/* binding */ vtkColorTransferFunction$1)
53567
- });
53568
-
53569
- // UNUSED EXPORTS: extend, newInstance
53570
-
53571
- // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/macros2.js
53572
- var macros2 = __webpack_require__(28906);
53573
- // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Common/Core/Math/index.js
53574
- var Core_Math = __webpack_require__(16632);
53575
- // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Common/Core/ScalarsToColors.js
53576
- var ScalarsToColors = __webpack_require__(80993);
53577
- ;// CONCATENATED MODULE: ../../../node_modules/@kitware/vtk.js/Rendering/Core/ColorTransferFunction/Constants.js
53578
- const ColorSpace = {
53579
- RGB: 0,
53580
- HSV: 1,
53581
- LAB: 2,
53582
- DIVERGING: 3
53583
- };
53584
- const Scale = {
53585
- LINEAR: 0,
53586
- LOG10: 1
53587
- };
53588
- var Constants = {
53589
- ColorSpace,
53590
- Scale
53591
- };
53592
-
53593
-
53594
-
53595
- ;// CONCATENATED MODULE: ../../../node_modules/@kitware/vtk.js/Rendering/Core/ColorTransferFunction.js
53596
-
53597
-
53598
-
53599
-
53600
-
53601
- const {
53602
- ColorSpace: ColorTransferFunction_ColorSpace,
53603
- Scale: ColorTransferFunction_Scale
53604
- } = Constants;
53605
- const {
53606
- ScalarMappingTarget
53607
- } = ScalarsToColors/* default */.Ay;
53608
- const {
53609
- vtkDebugMacro,
53610
- vtkErrorMacro,
53611
- vtkWarningMacro
53612
- } = macros2.m;
53613
-
53614
- // ----------------------------------------------------------------------------
53615
- // Global methods
53616
- // ----------------------------------------------------------------------------
53617
- /* eslint-disable no-continue */
53618
-
53619
- // Convert to and from a special polar version of CIELAB (useful for creating
53620
- // continuous diverging color maps).
53621
- function vtkColorTransferFunctionLabToMsh(lab, msh) {
53622
- const L = lab[0];
53623
- const a = lab[1];
53624
- const b = lab[2];
53625
- const M = Math.sqrt(L * L + a * a + b * b);
53626
- const s = M > 0.001 ? Math.acos(L / M) : 0.0;
53627
- const h = s > 0.001 ? Math.atan2(b, a) : 0.0;
53628
- msh[0] = M;
53629
- msh[1] = s;
53630
- msh[2] = h;
53631
- }
53632
- function vtkColorTransferFunctionMshToLab(msh, lab) {
53633
- const M = msh[0];
53634
- const s = msh[1];
53635
- const h = msh[2];
53636
- lab[0] = M * Math.cos(s);
53637
- lab[1] = M * Math.sin(s) * Math.cos(h);
53638
- lab[2] = M * Math.sin(s) * Math.sin(h);
53639
- }
53640
-
53641
- // For the case when interpolating from a saturated color to an unsaturated
53642
- // color, find a hue for the unsaturated color that makes sense.
53643
- function vtkColorTransferFunctionAdjustHue(msh, unsatM) {
53644
- if (msh[0] >= unsatM - 0.1) {
53645
- // The best we can do is hold hue constant.
53646
- return msh[2];
53647
- }
53648
-
53649
- // This equation is designed to make the perceptual change of the
53650
- // interpolation to be close to constant.
53651
- const hueSpin = msh[1] * Math.sqrt(unsatM * unsatM - msh[0] * msh[0]) / (msh[0] * Math.sin(msh[1]));
53652
- // Spin hue away from 0 except in purple hues.
53653
- if (msh[2] > -0.3 * Math.PI) {
53654
- return msh[2] + hueSpin;
53655
- }
53656
- return msh[2] - hueSpin;
53657
- }
53658
- function vtkColorTransferFunctionAngleDiff(a1, a2) {
53659
- let adiff = a1 - a2;
53660
- if (adiff < 0.0) {
53661
- adiff = -adiff;
53662
- }
53663
- while (adiff >= 2.0 * Math.PI) {
53664
- adiff -= 2.0 * Math.PI;
53665
- }
53666
- if (adiff > Math.PI) {
53667
- adiff = 2.0 * Math.PI - adiff;
53668
- }
53669
- return adiff;
53670
- }
53671
-
53672
- // Interpolate a diverging color map.
53673
- function vtkColorTransferFunctionInterpolateDiverging(s, rgb1, rgb2, result) {
53674
- const lab1 = [];
53675
- const lab2 = [];
53676
- (0,Core_Math.N)(rgb1, lab1);
53677
- (0,Core_Math.N)(rgb2, lab2);
53678
- const msh1 = [];
53679
- const msh2 = [];
53680
- vtkColorTransferFunctionLabToMsh(lab1, msh1);
53681
- vtkColorTransferFunctionLabToMsh(lab2, msh2);
53682
-
53683
- // If the endpoints are distinct saturated colors, then place white in between
53684
- // them.
53685
- let localS = s;
53686
- if (msh1[1] > 0.05 && msh2[1] > 0.05 && vtkColorTransferFunctionAngleDiff(msh1[2], msh2[2]) > 0.33 * Math.PI) {
53687
- // Insert the white midpoint by setting one end to white and adjusting the
53688
- // scalar value.
53689
- let Mmid = Math.max(msh1[0], msh2[0]);
53690
- Mmid = Math.max(88.0, Mmid);
53691
- if (s < 0.5) {
53692
- msh2[0] = Mmid;
53693
- msh2[1] = 0.0;
53694
- msh2[2] = 0.0;
53695
- localS *= 2.0;
53696
- } else {
53697
- msh1[0] = Mmid;
53698
- msh1[1] = 0.0;
53699
- msh1[2] = 0.0;
53700
- localS = 2.0 * localS - 1.0;
53701
- }
53702
- }
53703
-
53704
- // If one color has no saturation, then its hue value is invalid. In this
53705
- // case, we want to set it to something logical so that the interpolation of
53706
- // hue makes sense.
53707
- if (msh1[1] < 0.05 && msh2[1] > 0.05) {
53708
- msh1[2] = vtkColorTransferFunctionAdjustHue(msh2, msh1[0]);
53709
- } else if (msh2[1] < 0.05 && msh1[1] > 0.05) {
53710
- msh2[2] = vtkColorTransferFunctionAdjustHue(msh1, msh2[0]);
53711
- }
53712
- const mshTmp = [];
53713
- mshTmp[0] = (1 - localS) * msh1[0] + localS * msh2[0];
53714
- mshTmp[1] = (1 - localS) * msh1[1] + localS * msh2[1];
53715
- mshTmp[2] = (1 - localS) * msh1[2] + localS * msh2[2];
53716
-
53717
- // Now convert back to RGB
53718
- const labTmp = [];
53719
- vtkColorTransferFunctionMshToLab(mshTmp, labTmp);
53720
- (0,Core_Math.O)(labTmp, result);
53721
- }
53722
-
53723
- // ----------------------------------------------------------------------------
53724
- // vtkColorTransferFunction methods
53725
- // ----------------------------------------------------------------------------
53726
-
53727
- function vtkColorTransferFunction(publicAPI, model) {
53728
- // Set our className
53729
- model.classHierarchy.push('vtkColorTransferFunction');
53730
-
53731
- // Return the number of points which specify this function
53732
- publicAPI.getSize = () => model.nodes.length;
53733
-
53734
- //----------------------------------------------------------------------------
53735
- // Add a point defined in RGB
53736
- publicAPI.addRGBPoint = (x, r, g, b) => publicAPI.addRGBPointLong(x, r, g, b, 0.5, 0.0);
53737
-
53738
- //----------------------------------------------------------------------------
53739
- // Add a point defined in RGB
53740
- publicAPI.addRGBPointLong = function (x, r, g, b) {
53741
- let midpoint = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0.5;
53742
- let sharpness = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0.0;
53743
- // Error check
53744
- if (midpoint < 0.0 || midpoint > 1.0) {
53745
- vtkErrorMacro('Midpoint outside range [0.0, 1.0]');
53746
- return -1;
53747
- }
53748
- if (sharpness < 0.0 || sharpness > 1.0) {
53749
- vtkErrorMacro('Sharpness outside range [0.0, 1.0]');
53750
- return -1;
53751
- }
53752
-
53753
- // remove any node already at this X location
53754
- if (!model.allowDuplicateScalars) {
53755
- publicAPI.removePoint(x);
53756
- }
53757
-
53758
- // Create the new node
53759
- const node = {
53760
- x,
53761
- r,
53762
- g,
53763
- b,
53764
- midpoint,
53765
- sharpness
53766
- };
53767
-
53768
- // Add it, then sort to get everything in order
53769
- model.nodes.push(node);
53770
- publicAPI.sortAndUpdateRange();
53771
-
53772
- // We need to find the index of the node we just added in order
53773
- // to return this value
53774
- let i = 0;
53775
- for (; i < model.nodes.length; i++) {
53776
- if (model.nodes[i].x === x) {
53777
- break;
53778
- }
53779
- }
53780
-
53781
- // If we didn't find it, something went horribly wrong so
53782
- // return -1
53783
- if (i < model.nodes.length) {
53784
- return i;
53785
- }
53786
- return -1;
53787
- };
53788
-
53789
- //----------------------------------------------------------------------------
53790
- // Add a point defined in HSV
53791
- publicAPI.addHSVPoint = (x, h, s, v) => publicAPI.addHSVPointLong(x, h, s, v, 0.5, 0.0);
53792
-
53793
- //----------------------------------------------------------------------------
53794
- // Add a point defined in HSV
53795
- publicAPI.addHSVPointLong = function (x, h, s, v) {
53796
- let midpoint = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0.5;
53797
- let sharpness = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0.0;
53798
- const rgb = [];
53799
- const hsv = [h, s, v];
53800
- (0,Core_Math.h)(hsv, rgb);
53801
- return publicAPI.addRGBPoint(x, rgb[0], rgb[1], rgb[2], midpoint, sharpness);
53802
- };
53803
-
53804
- //----------------------------------------------------------------------------
53805
- // Set nodes directly
53806
- publicAPI.setNodes = nodes => {
53807
- if (model.nodes !== nodes) {
53808
- const before = JSON.stringify(model.nodes);
53809
- model.nodes = nodes;
53810
- const after = JSON.stringify(model.nodes);
53811
- if (publicAPI.sortAndUpdateRange() || before !== after) {
53812
- publicAPI.modified();
53813
- return true;
53814
- }
53815
- }
53816
- return false;
53817
- };
53818
-
53819
- //----------------------------------------------------------------------------
53820
- // Sort the vector in increasing order, then fill in
53821
- // the Range
53822
- publicAPI.sortAndUpdateRange = () => {
53823
- const before = JSON.stringify(model.nodes);
53824
- model.nodes.sort((a, b) => a.x - b.x);
53825
- const after = JSON.stringify(model.nodes);
53826
- const modifiedInvoked = publicAPI.updateRange();
53827
- // If range is updated, Modified() has been called, don't call it again.
53828
- if (!modifiedInvoked && before !== after) {
53829
- publicAPI.modified();
53830
- return true;
53831
- }
53832
- return modifiedInvoked;
53833
- };
53834
-
53835
- //----------------------------------------------------------------------------
53836
- publicAPI.updateRange = () => {
53837
- const oldRange = [2];
53838
- oldRange[0] = model.mappingRange[0];
53839
- oldRange[1] = model.mappingRange[1];
53840
- const size = model.nodes.length;
53841
- if (size) {
53842
- model.mappingRange[0] = model.nodes[0].x;
53843
- model.mappingRange[1] = model.nodes[size - 1].x;
53844
- } else {
53845
- model.mappingRange[0] = 0;
53846
- model.mappingRange[1] = 0;
53847
- }
53848
-
53849
- // If the range is the same, then no need to call Modified()
53850
- if (oldRange[0] === model.mappingRange[0] && oldRange[1] === model.mappingRange[1]) {
53851
- return false;
53852
- }
53853
- publicAPI.modified();
53854
- return true;
53855
- };
53856
-
53857
- //----------------------------------------------------------------------------
53858
- // Remove a point
53859
- publicAPI.removePoint = x => {
53860
- // First find the node since we need to know its
53861
- // index as our return value
53862
- let i = 0;
53863
- for (; i < model.nodes.length; i++) {
53864
- if (model.nodes[i].x === x) {
53865
- break;
53866
- }
53867
- }
53868
- const retVal = i;
53869
-
53870
- // If the node doesn't exist, we return -1
53871
- if (i >= model.nodes.length) {
53872
- return -1;
53873
- }
53874
-
53875
- // If the first or last point has been removed, then we update the range
53876
- // No need to sort here as the order of points hasn't changed.
53877
- let modifiedInvoked = false;
53878
- model.nodes.splice(i, 1);
53879
- if (i === 0 || i === model.nodes.length) {
53880
- modifiedInvoked = publicAPI.updateRange();
53881
- }
53882
- if (!modifiedInvoked) {
53883
- publicAPI.modified();
53884
- }
53885
- return retVal;
53886
- };
53887
-
53888
- //----------------------------------------------------------------------------
53889
- publicAPI.movePoint = (oldX, newX) => {
53890
- if (oldX === newX) {
53891
- // Nothing to do.
53892
- return;
53893
- }
53894
- publicAPI.removePoint(newX);
53895
- for (let i = 0; i < model.nodes.length; i++) {
53896
- if (model.nodes[i].x === oldX) {
53897
- model.nodes[i].x = newX;
53898
- publicAPI.sortAndUpdateRange();
53899
- break;
53900
- }
53901
- }
53902
- };
53903
-
53904
- //----------------------------------------------------------------------------
53905
- // Remove all points
53906
- publicAPI.removeAllPoints = () => {
53907
- model.nodes = [];
53908
- publicAPI.sortAndUpdateRange();
53909
- };
53910
-
53911
- //----------------------------------------------------------------------------
53912
- // Add a line defined in RGB
53913
- publicAPI.addRGBSegment = (x1, r1, g1, b1, x2, r2, g2, b2) => {
53914
- // First, find all points in this range and remove them
53915
- publicAPI.sortAndUpdateRange();
53916
- for (let i = 0; i < model.nodes.length;) {
53917
- if (model.nodes[i].x >= x1 && model.nodes[i].x <= x2) {
53918
- model.nodes.splice(i, 1);
53919
- } else {
53920
- i++;
53921
- }
53922
- }
53923
-
53924
- // Now add the points
53925
- publicAPI.addRGBPointLong(x1, r1, g1, b1, 0.5, 0.0);
53926
- publicAPI.addRGBPointLong(x2, r2, g2, b2, 0.5, 0.0);
53927
- publicAPI.modified();
53928
- };
53929
-
53930
- //----------------------------------------------------------------------------
53931
- // Add a line defined in HSV
53932
- publicAPI.addHSVSegment = (x1, h1, s1, v1, x2, h2, s2, v2) => {
53933
- const hsv1 = [h1, s1, v1];
53934
- const hsv2 = [h2, s2, v2];
53935
- const rgb1 = [];
53936
- const rgb2 = [];
53937
- (0,Core_Math.h)(hsv1, rgb1);
53938
- (0,Core_Math.h)(hsv2, rgb2);
53939
- publicAPI.addRGBSegment(x1, rgb1[0], rgb1[1], rgb1[2], x2, rgb2[0], rgb2[1], rgb2[2]);
53940
- };
53941
-
53942
- //----------------------------------------------------------------------------
53943
- // Returns the RGBA color evaluated at the specified location
53944
- publicAPI.mapValue = x => {
53945
- const rgb = [];
53946
- publicAPI.getColor(x, rgb);
53947
- return [Math.floor(255.0 * rgb[0] + 0.5), Math.floor(255.0 * rgb[1] + 0.5), Math.floor(255.0 * rgb[2] + 0.5), 255];
53948
- };
53949
-
53950
- //----------------------------------------------------------------------------
53951
- // Returns the RGB color evaluated at the specified location
53952
- publicAPI.getColor = (x, rgb) => {
53953
- if (model.indexedLookup) {
53954
- const numNodes = publicAPI.getSize();
53955
- // todo
53956
- const idx = publicAPI.getAnnotatedValueIndexInternal(x);
53957
- if (idx < 0 || numNodes === 0) {
53958
- const nanColor = publicAPI.getNanColorByReference();
53959
- rgb[0] = nanColor[0];
53960
- rgb[1] = nanColor[1];
53961
- rgb[2] = nanColor[2];
53962
- } else {
53963
- const nodeVal = [];
53964
- publicAPI.getNodeValue(idx % numNodes, nodeVal);
53965
- // nodeVal[0] is the x value. nodeVal[1...3] is rgb.
53966
- rgb[0] = nodeVal[1];
53967
- rgb[1] = nodeVal[2];
53968
- rgb[2] = nodeVal[3];
53969
- }
53970
- return;
53971
- }
53972
- publicAPI.getTable(x, x, 1, rgb);
53973
- };
53974
-
53975
- //----------------------------------------------------------------------------
53976
- // Returns the red color evaluated at the specified location
53977
- publicAPI.getRedValue = x => {
53978
- const rgb = [];
53979
- publicAPI.getColor(x, rgb);
53980
- return rgb[0];
53981
- };
53982
-
53983
- //----------------------------------------------------------------------------
53984
- // Returns the green color evaluated at the specified location
53985
- publicAPI.getGreenValue = x => {
53986
- const rgb = [];
53987
- publicAPI.getColor(x, rgb);
53988
- return rgb[1];
53989
- };
53990
-
53991
- //----------------------------------------------------------------------------
53992
- // Returns the blue color evaluated at the specified location
53993
- publicAPI.getBlueValue = x => {
53994
- const rgb = [];
53995
- publicAPI.getColor(x, rgb);
53996
- return rgb[2];
53997
- };
53998
-
53999
- //----------------------------------------------------------------------------
54000
- // Returns a table of RGB colors at regular intervals along the function
54001
- publicAPI.getTable = (xStart_, xEnd_, size, table) => {
54002
- // To handle BigInt limitation
54003
- const xStart = Number(xStart_);
54004
- const xEnd = Number(xEnd_);
54005
-
54006
- // Special case: If either the start or end is a NaN, then all any
54007
- // interpolation done on them is also a NaN. Therefore, fill the table with
54008
- // the NaN color.
54009
- if ((0,Core_Math.i)(xStart) || (0,Core_Math.i)(xEnd)) {
54010
- for (let i = 0; i < size; i++) {
54011
- table[i * 3 + 0] = model.nanColor[0];
54012
- table[i * 3 + 1] = model.nanColor[1];
54013
- table[i * 3 + 2] = model.nanColor[2];
54014
- }
54015
- return;
54016
- }
54017
- let idx = 0;
54018
- const numNodes = model.nodes.length;
54019
-
54020
- // Need to keep track of the last value so that
54021
- // we can fill in table locations past this with
54022
- // this value if Clamping is On.
54023
- let lastR = 0.0;
54024
- let lastG = 0.0;
54025
- let lastB = 0.0;
54026
- if (numNodes !== 0) {
54027
- lastR = model.nodes[numNodes - 1].r;
54028
- lastG = model.nodes[numNodes - 1].g;
54029
- lastB = model.nodes[numNodes - 1].b;
54030
- }
54031
- let x = 0.0;
54032
- let x1 = 0.0;
54033
- let x2 = 0.0;
54034
- const rgb1 = [0.0, 0.0, 0.0];
54035
- const rgb2 = [0.0, 0.0, 0.0];
54036
- let midpoint = 0.0;
54037
- let sharpness = 0.0;
54038
- const tmpVec = [];
54039
-
54040
- // If the scale is logarithmic, make sure the range is valid.
54041
- let usingLogScale = model.scale === ColorTransferFunction_Scale.LOG10;
54042
- if (usingLogScale) {
54043
- // Note: This requires range[0] <= range[1].
54044
- usingLogScale = model.mappingRange[0] > 0.0;
54045
- }
54046
- let logStart = 0.0;
54047
- let logEnd = 0.0;
54048
- let logX = 0.0;
54049
- if (usingLogScale) {
54050
- logStart = Math.log10(xStart);
54051
- logEnd = Math.log10(xEnd);
54052
- }
54053
-
54054
- // For each table entry
54055
- for (let i = 0; i < size; i++) {
54056
- // Find our location in the table
54057
- const tidx = 3 * i;
54058
-
54059
- // Find our X location. If we are taking only 1 sample, make
54060
- // it halfway between start and end (usually start and end will
54061
- // be the same in this case)
54062
- if (size > 1) {
54063
- if (usingLogScale) {
54064
- logX = logStart + i / (size - 1.0) * (logEnd - logStart);
54065
- x = 10.0 ** logX;
54066
- } else {
54067
- x = xStart + i / (size - 1.0) * (xEnd - xStart);
54068
- }
54069
- } else if (usingLogScale) {
54070
- logX = 0.5 * (logStart + logEnd);
54071
- x = 10.0 ** logX;
54072
- } else {
54073
- x = 0.5 * (xStart + xEnd);
54074
- }
54075
-
54076
- // Linearly map x from mappingRange to [0, numberOfValues-1],
54077
- // discretize (round down to the closest integer),
54078
- // then map back to mappingRange
54079
- if (model.discretize) {
54080
- const range = model.mappingRange;
54081
- if (x >= range[0] && x <= range[1]) {
54082
- const numberOfValues = model.numberOfValues;
54083
- const deltaRange = range[1] - range[0];
54084
- if (numberOfValues <= 1) {
54085
- x = range[0] + deltaRange / 2.0;
54086
- } else {
54087
- // normalize x
54088
- const xn = (x - range[0]) / deltaRange;
54089
- // discretize
54090
- const discretizeIndex = (0,Core_Math.K)(numberOfValues * xn);
54091
- // get discretized x
54092
- x = range[0] + discretizeIndex / (numberOfValues - 1) * deltaRange;
54093
- }
54094
- }
54095
- }
54096
-
54097
- // Do we need to move to the next node?
54098
- while (idx < numNodes && x > model.nodes[idx].x) {
54099
- idx++;
54100
- // If we are at a valid point index, fill in
54101
- // the value at this node, and the one before (the
54102
- // two that surround our current sample location)
54103
- // idx cannot be 0 since we just incremented it.
54104
- if (idx < numNodes) {
54105
- x1 = model.nodes[idx - 1].x;
54106
- x2 = model.nodes[idx].x;
54107
- if (usingLogScale) {
54108
- x1 = Math.log10(x1);
54109
- x2 = Math.log10(x2);
54110
- }
54111
- rgb1[0] = model.nodes[idx - 1].r;
54112
- rgb2[0] = model.nodes[idx].r;
54113
- rgb1[1] = model.nodes[idx - 1].g;
54114
- rgb2[1] = model.nodes[idx].g;
54115
- rgb1[2] = model.nodes[idx - 1].b;
54116
- rgb2[2] = model.nodes[idx].b;
54117
-
54118
- // We only need the previous midpoint and sharpness
54119
- // since these control this region
54120
- midpoint = model.nodes[idx - 1].midpoint;
54121
- sharpness = model.nodes[idx - 1].sharpness;
54122
-
54123
- // Move midpoint away from extreme ends of range to avoid
54124
- // degenerate math
54125
- if (midpoint < 0.00001) {
54126
- midpoint = 0.00001;
54127
- }
54128
- if (midpoint > 0.99999) {
54129
- midpoint = 0.99999;
54130
- }
54131
- }
54132
- }
54133
-
54134
- // Are we at or past the end? If so, just use the last value
54135
- if (x > model.mappingRange[1]) {
54136
- table[tidx] = 0.0;
54137
- table[tidx + 1] = 0.0;
54138
- table[tidx + 2] = 0.0;
54139
- if (model.clamping) {
54140
- if (publicAPI.getUseAboveRangeColor()) {
54141
- table[tidx] = model.aboveRangeColor[0];
54142
- table[tidx + 1] = model.aboveRangeColor[1];
54143
- table[tidx + 2] = model.aboveRangeColor[2];
54144
- } else {
54145
- table[tidx] = lastR;
54146
- table[tidx + 1] = lastG;
54147
- table[tidx + 2] = lastB;
54148
- }
54149
- }
54150
- } else if (x < model.mappingRange[0] || (0,Core_Math.L)(x) && x < 0) {
54151
- // we are before the first node? If so, duplicate this node's values.
54152
- // We have to deal with -inf here
54153
- table[tidx] = 0.0;
54154
- table[tidx + 1] = 0.0;
54155
- table[tidx + 2] = 0.0;
54156
- if (model.clamping) {
54157
- if (publicAPI.getUseBelowRangeColor()) {
54158
- table[tidx] = model.belowRangeColor[0];
54159
- table[tidx + 1] = model.belowRangeColor[1];
54160
- table[tidx + 2] = model.belowRangeColor[2];
54161
- } else if (numNodes > 0) {
54162
- table[tidx] = model.nodes[0].r;
54163
- table[tidx + 1] = model.nodes[0].g;
54164
- table[tidx + 2] = model.nodes[0].b;
54165
- }
54166
- }
54167
- } else if (idx === 0 && (Math.abs(x - xStart) < 1e-6 || model.discretize)) {
54168
- if (numNodes > 0) {
54169
- table[tidx] = model.nodes[0].r;
54170
- table[tidx + 1] = model.nodes[0].g;
54171
- table[tidx + 2] = model.nodes[0].b;
54172
- } else {
54173
- table[tidx] = 0.0;
54174
- table[tidx + 1] = 0.0;
54175
- table[tidx + 2] = 0.0;
54176
- }
54177
- } else {
54178
- // OK, we are between two nodes - interpolate
54179
- // Our first attempt at a normalized location [0,1] -
54180
- // we will be modifying this based on midpoint and
54181
- // sharpness to get the curve shape we want and to have
54182
- // it pass through (y1+y2)/2 at the midpoint.
54183
- let s = 0.0;
54184
- if (usingLogScale) {
54185
- s = (logX - x1) / (x2 - x1);
54186
- } else {
54187
- s = (x - x1) / (x2 - x1);
54188
- }
54189
-
54190
- // Readjust based on the midpoint - linear adjustment
54191
- if (s < midpoint) {
54192
- s = 0.5 * s / midpoint;
54193
- } else {
54194
- s = 0.5 + 0.5 * (s - midpoint) / (1.0 - midpoint);
54195
- }
54196
-
54197
- // override for sharpness > 0.99
54198
- // In this case we just want piecewise constant
54199
- if (sharpness > 0.99) {
54200
- // Use the first value since we are below the midpoint
54201
- if (s < 0.5) {
54202
- table[tidx] = rgb1[0];
54203
- table[tidx + 1] = rgb1[1];
54204
- table[tidx + 2] = rgb1[2];
54205
- continue;
54206
- } else {
54207
- // Use the second value at or above the midpoint
54208
- table[tidx] = rgb2[0];
54209
- table[tidx + 1] = rgb2[1];
54210
- table[tidx + 2] = rgb2[2];
54211
- continue;
54212
- }
54213
- }
54214
-
54215
- // Override for sharpness < 0.01
54216
- // In this case we want piecewise linear
54217
- if (sharpness < 0.01) {
54218
- // Simple linear interpolation
54219
- if (model.colorSpace === ColorTransferFunction_ColorSpace.RGB) {
54220
- table[tidx] = (1 - s) * rgb1[0] + s * rgb2[0];
54221
- table[tidx + 1] = (1 - s) * rgb1[1] + s * rgb2[1];
54222
- table[tidx + 2] = (1 - s) * rgb1[2] + s * rgb2[2];
54223
- } else if (model.colorSpace === ColorTransferFunction_ColorSpace.HSV) {
54224
- const hsv1 = [];
54225
- const hsv2 = [];
54226
- (0,Core_Math.M)(rgb1, hsv1);
54227
- (0,Core_Math.M)(rgb2, hsv2);
54228
- if (model.hSVWrap && (hsv1[0] - hsv2[0] > 0.5 || hsv2[0] - hsv1[0] > 0.5)) {
54229
- if (hsv1[0] > hsv2[0]) {
54230
- hsv1[0] -= 1.0;
54231
- } else {
54232
- hsv2[0] -= 1.0;
54233
- }
54234
- }
54235
- const hsvTmp = [];
54236
- hsvTmp[0] = (1.0 - s) * hsv1[0] + s * hsv2[0];
54237
- if (hsvTmp[0] < 0.0) {
54238
- hsvTmp[0] += 1.0;
54239
- }
54240
- hsvTmp[1] = (1.0 - s) * hsv1[1] + s * hsv2[1];
54241
- hsvTmp[2] = (1.0 - s) * hsv1[2] + s * hsv2[2];
54242
-
54243
- // Now convert this back to RGB
54244
- (0,Core_Math.h)(hsvTmp, tmpVec);
54245
- table[tidx] = tmpVec[0];
54246
- table[tidx + 1] = tmpVec[1];
54247
- table[tidx + 2] = tmpVec[2];
54248
- } else if (model.colorSpace === ColorTransferFunction_ColorSpace.LAB) {
54249
- const lab1 = [];
54250
- const lab2 = [];
54251
- (0,Core_Math.N)(rgb1, lab1);
54252
- (0,Core_Math.N)(rgb2, lab2);
54253
- const labTmp = [];
54254
- labTmp[0] = (1 - s) * lab1[0] + s * lab2[0];
54255
- labTmp[1] = (1 - s) * lab1[1] + s * lab2[1];
54256
- labTmp[2] = (1 - s) * lab1[2] + s * lab2[2];
54257
-
54258
- // Now convert back to RGB
54259
- (0,Core_Math.O)(labTmp, tmpVec);
54260
- table[tidx] = tmpVec[0];
54261
- table[tidx + 1] = tmpVec[1];
54262
- table[tidx + 2] = tmpVec[2];
54263
- } else if (model.colorSpace === ColorTransferFunction_ColorSpace.DIVERGING) {
54264
- vtkColorTransferFunctionInterpolateDiverging(s, rgb1, rgb2, tmpVec);
54265
- table[tidx] = tmpVec[0];
54266
- table[tidx + 1] = tmpVec[1];
54267
- table[tidx + 2] = tmpVec[2];
54268
- } else {
54269
- vtkErrorMacro('ColorSpace set to invalid value.', model.colorSpace);
54270
- }
54271
- continue;
54272
- }
54273
-
54274
- // We have a sharpness between [0.01, 0.99] - we will
54275
- // used a modified hermite curve interpolation where we
54276
- // derive the slope based on the sharpness, and we compress
54277
- // the curve non-linearly based on the sharpness
54278
-
54279
- // First, we will adjust our position based on sharpness in
54280
- // order to make the curve sharper (closer to piecewise constant)
54281
- if (s < 0.5) {
54282
- s = 0.5 * (s * 2.0) ** (1.0 + 10.0 * sharpness);
54283
- } else if (s > 0.5) {
54284
- s = 1.0 - 0.5 * ((1.0 - s) * 2) ** (1 + 10.0 * sharpness);
54285
- }
54286
-
54287
- // Compute some coefficients we will need for the hermite curve
54288
- const ss = s * s;
54289
- const sss = ss * s;
54290
- const h1 = 2.0 * sss - 3 * ss + 1;
54291
- const h2 = -2 * sss + 3 * ss;
54292
- const h3 = sss - 2 * ss + s;
54293
- const h4 = sss - ss;
54294
- let slope;
54295
- let t;
54296
- if (model.colorSpace === ColorTransferFunction_ColorSpace.RGB) {
54297
- for (let j = 0; j < 3; j++) {
54298
- // Use one slope for both end points
54299
- slope = rgb2[j] - rgb1[j];
54300
- t = (1.0 - sharpness) * slope;
54301
-
54302
- // Compute the value
54303
- table[tidx + j] = h1 * rgb1[j] + h2 * rgb2[j] + h3 * t + h4 * t;
54304
- }
54305
- } else if (model.colorSpace === ColorTransferFunction_ColorSpace.HSV) {
54306
- const hsv1 = [];
54307
- const hsv2 = [];
54308
- (0,Core_Math.M)(rgb1, hsv1);
54309
- (0,Core_Math.M)(rgb2, hsv2);
54310
- if (model.hSVWrap && (hsv1[0] - hsv2[0] > 0.5 || hsv2[0] - hsv1[0] > 0.5)) {
54311
- if (hsv1[0] > hsv2[0]) {
54312
- hsv1[0] -= 1.0;
54313
- } else {
54314
- hsv2[0] -= 1.0;
54315
- }
54316
- }
54317
- const hsvTmp = [];
54318
- for (let j = 0; j < 3; j++) {
54319
- // Use one slope for both end points
54320
- slope = hsv2[j] - hsv1[j];
54321
- t = (1.0 - sharpness) * slope;
54322
-
54323
- // Compute the value
54324
- hsvTmp[j] = h1 * hsv1[j] + h2 * hsv2[j] + h3 * t + h4 * t;
54325
- if (j === 0 && hsvTmp[j] < 0.0) {
54326
- hsvTmp[j] += 1.0;
54327
- }
54328
- }
54329
- // Now convert this back to RGB
54330
- (0,Core_Math.h)(hsvTmp, tmpVec);
54331
- table[tidx] = tmpVec[0];
54332
- table[tidx + 1] = tmpVec[1];
54333
- table[tidx + 2] = tmpVec[2];
54334
- } else if (model.colorSpace === ColorTransferFunction_ColorSpace.LAB) {
54335
- const lab1 = [];
54336
- const lab2 = [];
54337
- (0,Core_Math.N)(rgb1, lab1);
54338
- (0,Core_Math.N)(rgb2, lab2);
54339
- const labTmp = [];
54340
- for (let j = 0; j < 3; j++) {
54341
- // Use one slope for both end points
54342
- slope = lab2[j] - lab1[j];
54343
- t = (1.0 - sharpness) * slope;
54344
-
54345
- // Compute the value
54346
- labTmp[j] = h1 * lab1[j] + h2 * lab2[j] + h3 * t + h4 * t;
54347
- }
54348
- // Now convert this back to RGB
54349
- (0,Core_Math.O)(labTmp, tmpVec);
54350
- table[tidx] = tmpVec[0];
54351
- table[tidx + 1] = tmpVec[1];
54352
- table[tidx + 2] = tmpVec[2];
54353
- } else if (model.colorSpace === ColorTransferFunction_ColorSpace.DIVERGING) {
54354
- // I have not implemented proper interpolation by a hermite curve for
54355
- // the diverging color map, but I cannot think of a good use case for
54356
- // that anyway.
54357
- vtkColorTransferFunctionInterpolateDiverging(s, rgb1, rgb2, tmpVec);
54358
- table[tidx] = tmpVec[0];
54359
- table[tidx + 1] = tmpVec[1];
54360
- table[tidx + 2] = tmpVec[2];
54361
- } else {
54362
- vtkErrorMacro('ColorSpace set to invalid value.');
54363
- }
54364
-
54365
- // Final error check to make sure we don't go outside [0,1]
54366
- for (let j = 0; j < 3; j++) {
54367
- table[tidx + j] = table[tidx + j] < 0.0 ? 0.0 : table[tidx + j];
54368
- table[tidx + j] = table[tidx + j] > 1.0 ? 1.0 : table[tidx + j];
54369
- }
54370
- }
54371
- }
54372
- };
54373
-
54374
- //----------------------------------------------------------------------------
54375
- publicAPI.getUint8Table = function (xStart, xEnd, size) {
54376
- let withAlpha = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
54377
- if (publicAPI.getMTime() <= model.buildTime && model.tableSize === size && model.tableWithAlpha !== withAlpha) {
54378
- return model.table;
54379
- }
54380
- if (model.nodes.length === 0) {
54381
- vtkErrorMacro('Attempting to lookup a value with no points in the function');
54382
- return model.table;
54383
- }
54384
- const nbChannels = withAlpha ? 4 : 3;
54385
- if (model.tableSize !== size || model.tableWithAlpha !== withAlpha) {
54386
- model.table = new Uint8Array(size * nbChannels);
54387
- model.tableSize = size;
54388
- model.tableWithAlpha = withAlpha;
54389
- }
54390
- const tmpTable = [];
54391
- publicAPI.getTable(xStart, xEnd, size, tmpTable);
54392
- for (let i = 0; i < size; i++) {
54393
- model.table[i * nbChannels + 0] = Math.floor(tmpTable[i * 3 + 0] * 255.0 + 0.5);
54394
- model.table[i * nbChannels + 1] = Math.floor(tmpTable[i * 3 + 1] * 255.0 + 0.5);
54395
- model.table[i * nbChannels + 2] = Math.floor(tmpTable[i * 3 + 2] * 255.0 + 0.5);
54396
- if (withAlpha) {
54397
- model.table[i * nbChannels + 3] = 255;
54398
- }
54399
- }
54400
- model.buildTime.modified();
54401
- return model.table;
54402
- };
54403
- publicAPI.buildFunctionFromArray = array => {
54404
- publicAPI.removeAllPoints();
54405
- const numComponents = array.getNumberOfComponents();
54406
- for (let i = 0; i < array.getNumberOfTuples(); i++) {
54407
- switch (numComponents) {
54408
- case 3:
54409
- {
54410
- model.nodes.push({
54411
- x: i,
54412
- r: array.getComponent(i, 0),
54413
- g: array.getComponent(i, 1),
54414
- b: array.getComponent(i, 2),
54415
- midpoint: 0.5,
54416
- sharpness: 0.0
54417
- });
54418
- break;
54419
- }
54420
- case 4:
54421
- {
54422
- model.nodes.push({
54423
- x: array.getComponent(i, 0),
54424
- r: array.getComponent(i, 1),
54425
- g: array.getComponent(i, 2),
54426
- b: array.getComponent(i, 3),
54427
- midpoint: 0.5,
54428
- sharpness: 0.0
54429
- });
54430
- break;
54431
- }
54432
- case 5:
54433
- {
54434
- model.nodes.push({
54435
- x: i,
54436
- r: array.getComponent(i, 0),
54437
- g: array.getComponent(i, 1),
54438
- b: array.getComponent(i, 2),
54439
- midpoint: array.getComponent(i, 4),
54440
- sharpness: array.getComponent(i, 5)
54441
- });
54442
- break;
54443
- }
54444
- case 6:
54445
- {
54446
- model.nodes.push({
54447
- x: array.getComponent(i, 0),
54448
- r: array.getComponent(i, 1),
54449
- g: array.getComponent(i, 2),
54450
- b: array.getComponent(i, 3),
54451
- midpoint: array.getComponent(i, 4),
54452
- sharpness: array.getComponent(i, 5)
54453
- });
54454
- break;
54455
- }
54456
- }
54457
- }
54458
- publicAPI.sortAndUpdateRange();
54459
- };
54460
-
54461
- //----------------------------------------------------------------------------
54462
- publicAPI.buildFunctionFromTable = (xStart, xEnd, size, table) => {
54463
- let inc = 0.0;
54464
- publicAPI.removeAllPoints();
54465
- if (size > 1) {
54466
- inc = (xEnd - xStart) / (size - 1.0);
54467
- }
54468
- for (let i = 0; i < size; i++) {
54469
- const node = {
54470
- x: xStart + inc * i,
54471
- r: table[i * 3],
54472
- g: table[i * 3 + 1],
54473
- b: table[i * 3 + 2],
54474
- sharpness: 0.0,
54475
- midpoint: 0.5
54476
- };
54477
- model.nodes.push(node);
54478
- }
54479
- publicAPI.sortAndUpdateRange();
54480
- };
54481
-
54482
- //----------------------------------------------------------------------------
54483
- // For a specified index value, get the node parameters
54484
- publicAPI.getNodeValue = (index, val) => {
54485
- if (index < 0 || index >= model.nodes.length) {
54486
- vtkErrorMacro('Index out of range!');
54487
- return -1;
54488
- }
54489
- val[0] = model.nodes[index].x;
54490
- val[1] = model.nodes[index].r;
54491
- val[2] = model.nodes[index].g;
54492
- val[3] = model.nodes[index].b;
54493
- val[4] = model.nodes[index].midpoint;
54494
- val[5] = model.nodes[index].sharpness;
54495
- return 1;
54496
- };
54497
-
54498
- //----------------------------------------------------------------------------
54499
- // For a specified index value, get the node parameters
54500
- publicAPI.setNodeValue = (index, val) => {
54501
- if (index < 0 || index >= model.nodes.length) {
54502
- vtkErrorMacro('Index out of range!');
54503
- return -1;
54504
- }
54505
- const oldX = model.nodes[index].x;
54506
- model.nodes[index].x = val[0];
54507
- model.nodes[index].r = val[1];
54508
- model.nodes[index].g = val[2];
54509
- model.nodes[index].b = val[3];
54510
- model.nodes[index].midpoint = val[4];
54511
- model.nodes[index].sharpness = val[5];
54512
- if (oldX !== val[0]) {
54513
- // The point has been moved, the order of points or the range might have
54514
- // been modified.
54515
- publicAPI.sortAndUpdateRange();
54516
- // No need to call Modified() here because SortAndUpdateRange() has done it
54517
- // already.
54518
- } else {
54519
- publicAPI.modified();
54520
- }
54521
- return 1;
54522
- };
54523
-
54524
- //----------------------------------------------------------------------------
54525
- publicAPI.getNumberOfAvailableColors = () => {
54526
- if (model.indexedLookup && publicAPI.getSize()) {
54527
- return publicAPI.getSize();
54528
- }
54529
- if (model.tableSize) {
54530
- // Not sure if this is correct since it is only set if
54531
- // "const unsigned char *::GetTable(double xStart, double xEnd,int size)"
54532
- // has been called.
54533
- return model.tableSize;
54534
- }
54535
- const nNodes = model.nodes?.length ?? 0;
54536
- // The minimum is 4094 colors so that it fills in the 4096 texels texture in `mapScalarsToTexture`
54537
- return Math.max(4094, nNodes);
54538
- };
54539
-
54540
- //----------------------------------------------------------------------------
54541
- publicAPI.getIndexedColor = (idx, rgba) => {
54542
- const n = publicAPI.getSize();
54543
- if (n > 0 && idx >= 0) {
54544
- const nodeValue = [];
54545
- publicAPI.getNodeValue(idx % n, nodeValue);
54546
- for (let j = 0; j < 3; ++j) {
54547
- rgba[j] = nodeValue[j + 1];
54548
- }
54549
- rgba[3] = 1.0; // NodeColor is RGB-only.
54550
- return;
54551
- }
54552
- const nanColor = publicAPI.getNanColorByReference();
54553
- rgba[0] = nanColor[0];
54554
- rgba[1] = nanColor[1];
54555
- rgba[2] = nanColor[2];
54556
- rgba[3] = 1.0; // NanColor is RGB-only.
54557
- };
54558
-
54559
- //----------------------------------------------------------------------------
54560
- publicAPI.fillFromDataPointer = (nb, ptr) => {
54561
- if (nb <= 0 || !ptr) {
54562
- return;
54563
- }
54564
- publicAPI.removeAllPoints();
54565
- for (let i = 0; i < nb; i++) {
54566
- publicAPI.addRGBPoint(ptr[i * 4], ptr[i * 4 + 1], ptr[i * 4 + 2], ptr[i * 4 + 3]);
54567
- }
54568
- };
54569
-
54570
- //----------------------------------------------------------------------------
54571
- publicAPI.setMappingRange = (min, max) => {
54572
- const range = [min, max];
54573
- const originalRange = publicAPI.getRange();
54574
- if (originalRange[1] === range[1] && originalRange[0] === range[0]) {
54575
- return;
54576
- }
54577
- if (range[1] === range[0]) {
54578
- vtkErrorMacro('attempt to set zero width color range');
54579
- return;
54580
- }
54581
- const scale = (range[1] - range[0]) / (originalRange[1] - originalRange[0]);
54582
- const shift = range[0] - originalRange[0] * scale;
54583
- for (let i = 0; i < model.nodes.length; ++i) {
54584
- model.nodes[i].x = model.nodes[i].x * scale + shift;
54585
- }
54586
- model.mappingRange[0] = range[0];
54587
- model.mappingRange[1] = range[1];
54588
- publicAPI.modified();
54589
- };
54590
-
54591
- //----------------------------------------------------------------------------
54592
- publicAPI.adjustRange = range => {
54593
- const functionRange = publicAPI.getRange();
54594
-
54595
- // Make sure we have points at each end of the range
54596
- const rgb = [];
54597
- if (functionRange[0] < range[0]) {
54598
- publicAPI.getColor(range[0], rgb);
54599
- publicAPI.addRGBPoint(range[0], rgb[0], rgb[1], rgb[2]);
54600
- } else {
54601
- publicAPI.getColor(functionRange[0], rgb);
54602
- publicAPI.addRGBPoint(range[0], rgb[0], rgb[1], rgb[2]);
54603
- }
54604
- if (functionRange[1] > range[1]) {
54605
- publicAPI.getColor(range[1], rgb);
54606
- publicAPI.addRGBPoint(range[1], rgb[0], rgb[1], rgb[2]);
54607
- } else {
54608
- publicAPI.getColor(functionRange[1], rgb);
54609
- publicAPI.addRGBPoint(range[1], rgb[0], rgb[1], rgb[2]);
54610
- }
54611
-
54612
- // Remove all points out-of-range
54613
- publicAPI.sortAndUpdateRange();
54614
- for (let i = 0; i < model.nodes.length;) {
54615
- if (model.nodes[i].x >= range[0] && model.nodes[i].x <= range[1]) {
54616
- model.nodes.splice(i, 1);
54617
- } else {
54618
- ++i;
54619
- }
54620
- }
54621
- return 1;
54622
- };
54623
-
54624
- //--------------------------------------------------------------------------
54625
- publicAPI.estimateMinNumberOfSamples = (x1, x2) => {
54626
- const d = publicAPI.findMinimumXDistance();
54627
- return Math.ceil((x2 - x1) / d);
54628
- };
54629
-
54630
- //----------------------------------------------------------------------------
54631
- publicAPI.findMinimumXDistance = () => {
54632
- if (model.nodes.length < 2) {
54633
- return -1.0;
54634
- }
54635
- let distance = Number.MAX_VALUE;
54636
- for (let i = 0; i < model.nodes.length - 1; i++) {
54637
- const currentDist = model.nodes[i + 1].x - model.nodes[i].x;
54638
- if (currentDist < distance) {
54639
- distance = currentDist;
54640
- }
54641
- }
54642
- return distance;
54643
- };
54644
- publicAPI.mapScalarsThroughTable = (input, output, outFormat, inputOffset) => {
54645
- if (publicAPI.getSize() === 0) {
54646
- vtkDebugMacro('Transfer Function Has No Points!');
54647
- return;
54648
- }
54649
- if (model.indexedLookup) {
54650
- publicAPI.mapDataIndexed(input, output, outFormat, inputOffset);
54651
- } else {
54652
- publicAPI.mapData(input, output, outFormat, inputOffset);
54653
- }
54654
- };
54655
-
54656
- //----------------------------------------------------------------------------
54657
- publicAPI.mapData = (input, output, outFormat, inputOffset) => {
54658
- if (publicAPI.getSize() === 0) {
54659
- vtkWarningMacro('Transfer Function Has No Points!');
54660
- return;
54661
- }
54662
- const alpha = Math.floor(publicAPI.getAlpha() * 255.0 + 0.5);
54663
- const length = input.getNumberOfTuples();
54664
- const inIncr = input.getNumberOfComponents();
54665
- const outputV = output.getData();
54666
- const inputV = input.getData();
54667
- const rgb = [];
54668
- if (outFormat === ScalarMappingTarget.RGBA) {
54669
- for (let i = 0; i < length; i++) {
54670
- const x = inputV[i * inIncr + inputOffset];
54671
- publicAPI.getColor(x, rgb);
54672
- outputV[i * 4] = Math.floor(rgb[0] * 255.0 + 0.5);
54673
- outputV[i * 4 + 1] = Math.floor(rgb[1] * 255.0 + 0.5);
54674
- outputV[i * 4 + 2] = Math.floor(rgb[2] * 255.0 + 0.5);
54675
- outputV[i * 4 + 3] = alpha;
54676
- }
54677
- }
54678
- if (outFormat === ScalarMappingTarget.RGB) {
54679
- for (let i = 0; i < length; i++) {
54680
- const x = inputV[i * inIncr + inputOffset];
54681
- publicAPI.getColor(x, rgb);
54682
- outputV[i * 3] = Math.floor(rgb[0] * 255.0 + 0.5);
54683
- outputV[i * 3 + 1] = Math.floor(rgb[1] * 255.0 + 0.5);
54684
- outputV[i * 3 + 2] = Math.floor(rgb[2] * 255.0 + 0.5);
54685
- }
54686
- }
54687
- if (outFormat === ScalarMappingTarget.LUMINANCE) {
54688
- for (let i = 0; i < length; i++) {
54689
- const x = inputV[i * inIncr + inputOffset];
54690
- publicAPI.getColor(x, rgb);
54691
- outputV[i] = Math.floor(rgb[0] * 76.5 + rgb[1] * 150.45 + rgb[2] * 28.05 + 0.5);
54692
- }
54693
- }
54694
- if (outFormat === ScalarMappingTarget.LUMINANCE_ALPHA) {
54695
- for (let i = 0; i < length; i++) {
54696
- const x = inputV[i * inIncr + inputOffset];
54697
- publicAPI.getColor(x, rgb);
54698
- outputV[i * 2] = Math.floor(rgb[0] * 76.5 + rgb[1] * 150.45 + rgb[2] * 28.05 + 0.5);
54699
- outputV[i * 2 + 1] = alpha;
54700
- }
54701
- }
54702
- };
54703
-
54704
- //----------------------------------------------------------------------------
54705
- publicAPI.applyColorMap = colorMap => {
54706
- const oldColorSpace = JSON.stringify(model.colorSpace);
54707
- if (colorMap.ColorSpace) {
54708
- model.colorSpace = ColorTransferFunction_ColorSpace[colorMap.ColorSpace.toUpperCase()];
54709
- if (model.colorSpace === undefined) {
54710
- vtkErrorMacro(`ColorSpace ${colorMap.ColorSpace} not supported, using RGB instead`);
54711
- model.colorSpace = ColorTransferFunction_ColorSpace.RGB;
54712
- }
54713
- }
54714
- let isModified = oldColorSpace !== JSON.stringify(model.colorSpace);
54715
- const oldNanColor = isModified || JSON.stringify(model.nanColor);
54716
- if (colorMap.NanColor) {
54717
- model.nanColor = [].concat(colorMap.NanColor);
54718
- while (model.nanColor.length < 4) {
54719
- model.nanColor.push(1.0);
54720
- }
54721
- }
54722
- isModified = isModified || oldNanColor !== JSON.stringify(model.nanColor);
54723
- const oldNodes = isModified || JSON.stringify(model.nodes);
54724
- if (colorMap.RGBPoints) {
54725
- const size = colorMap.RGBPoints.length;
54726
- model.nodes = [];
54727
- const midpoint = 0.5;
54728
- const sharpness = 0.0;
54729
- for (let i = 0; i < size; i += 4) {
54730
- model.nodes.push({
54731
- x: colorMap.RGBPoints[i],
54732
- r: colorMap.RGBPoints[i + 1],
54733
- g: colorMap.RGBPoints[i + 2],
54734
- b: colorMap.RGBPoints[i + 3],
54735
- midpoint,
54736
- sharpness
54737
- });
54738
- }
54739
- }
54740
- const modifiedInvoked = publicAPI.sortAndUpdateRange();
54741
- const callModified = !modifiedInvoked && (isModified || oldNodes !== JSON.stringify(model.nodes));
54742
- if (callModified) publicAPI.modified();
54743
- return modifiedInvoked || callModified;
54744
- };
54745
- }
54746
-
54747
- // ----------------------------------------------------------------------------
54748
- // Object factory
54749
- // ----------------------------------------------------------------------------
54750
-
54751
- const DEFAULT_VALUES = {
54752
- clamping: true,
54753
- colorSpace: ColorTransferFunction_ColorSpace.RGB,
54754
- hSVWrap: true,
54755
- scale: ColorTransferFunction_Scale.LINEAR,
54756
- nanColor: null,
54757
- belowRangeColor: null,
54758
- aboveRangeColor: null,
54759
- useAboveRangeColor: false,
54760
- useBelowRangeColor: false,
54761
- allowDuplicateScalars: false,
54762
- table: null,
54763
- tableSize: 0,
54764
- buildTime: null,
54765
- nodes: null,
54766
- discretize: false,
54767
- numberOfValues: 256
54768
- };
54769
-
54770
- // ----------------------------------------------------------------------------
54771
-
54772
- function extend(publicAPI, model) {
54773
- let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
54774
- Object.assign(model, DEFAULT_VALUES, initialValues);
54775
-
54776
- // Inheritance
54777
- ScalarsToColors/* default.extend */.Ay.extend(publicAPI, model, initialValues);
54778
-
54779
- // Internal objects initialization
54780
- model.table = [];
54781
- model.nodes = [];
54782
- model.nanColor = [0.5, 0.0, 0.0, 1.0];
54783
- model.belowRangeColor = [0.0, 0.0, 0.0, 1.0];
54784
- model.aboveRangeColor = [1.0, 1.0, 1.0, 1.0];
54785
- model.buildTime = {};
54786
- macros2.m.obj(model.buildTime);
54787
-
54788
- // Create get-only macros
54789
- macros2.m.get(publicAPI, model, ['buildTime', 'mappingRange']);
54790
-
54791
- // Create get-set macros
54792
- macros2.m.setGet(publicAPI, model, ['useAboveRangeColor', 'useBelowRangeColor', 'discretize', 'numberOfValues', {
54793
- type: 'enum',
54794
- name: 'colorSpace',
54795
- enum: ColorTransferFunction_ColorSpace
54796
- }, {
54797
- type: 'enum',
54798
- name: 'scale',
54799
- enum: ColorTransferFunction_Scale
54800
- }]);
54801
- macros2.m.setArray(publicAPI, model, ['nanColor', 'belowRangeColor', 'aboveRangeColor'], 4);
54802
-
54803
- // Create get macros for array
54804
- macros2.m.getArray(publicAPI, model, ['nanColor', 'belowRangeColor', 'aboveRangeColor']);
54805
-
54806
- // For more macro methods, see "Sources/macros.js"
54807
-
54808
- // Object specific methods
54809
- vtkColorTransferFunction(publicAPI, model);
54810
- }
54811
-
54812
- // ----------------------------------------------------------------------------
54813
-
54814
- const newInstance = macros2.m.newInstance(extend, 'vtkColorTransferFunction');
54815
-
54816
- // ----------------------------------------------------------------------------
54817
-
54818
- var vtkColorTransferFunction$1 = {
54819
- newInstance,
54820
- extend,
54821
- ...Constants
54822
- };
54823
-
54824
-
54825
-
54826
-
54827
53735
  /***/ }),
54828
53736
 
54829
53737
  /***/ 660:
@@ -69364,6 +68272,34 @@ var ColorMaps_vtkColorMaps = {
69364
68272
 
69365
68273
 
69366
68274
 
68275
+ /***/ }),
68276
+
68277
+ /***/ 25128:
68278
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
68279
+
68280
+ "use strict";
68281
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
68282
+ /* harmony export */ Ay: () => (/* binding */ Constants)
68283
+ /* harmony export */ });
68284
+ /* unused harmony exports ColorSpace, Scale */
68285
+ const ColorSpace = {
68286
+ RGB: 0,
68287
+ HSV: 1,
68288
+ LAB: 2,
68289
+ DIVERGING: 3
68290
+ };
68291
+ const Scale = {
68292
+ LINEAR: 0,
68293
+ LOG10: 1
68294
+ };
68295
+ var Constants = {
68296
+ ColorSpace,
68297
+ Scale
68298
+ };
68299
+
68300
+
68301
+
68302
+
69367
68303
  /***/ }),
69368
68304
 
69369
68305
  /***/ 94520: