@ohif/app 3.14.0-beta.55 → 3.14.0-beta.57

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 (37) hide show
  1. package/dist/{9187.bundle.47a04a89.js → 1283.bundle.56abacf4.js} +162 -137
  2. package/dist/{4262.bundle.0c550b7f.js → 1558.bundle.03d5783b.js} +36 -11
  3. package/dist/{1566.bundle.8d90bb15.js → 1566.bundle.e9f5d851.js} +5 -1
  4. package/dist/{1645.bundle.65cff869.js → 1645.bundle.618a2886.js} +700 -389
  5. package/dist/{1724.bundle.b4757283.js → 1724.bundle.59b20c59.js} +1184 -1139
  6. package/dist/{1788.bundle.5b78672d.js → 1788.bundle.3f1349d2.js} +101 -43
  7. package/dist/1975.bundle.53cf5d7c.js +8216 -0
  8. package/dist/{5922.bundle.46b3e037.js → 2894.bundle.db3f8686.js} +240 -151
  9. package/dist/{6567.bundle.cc57e572.js → 3044.bundle.039294b9.js} +105 -76
  10. package/dist/{3386.bundle.7665dd43.js → 3386.bundle.25140fec.js} +92 -23
  11. package/dist/{4004.bundle.da822fd2.js → 4018.bundle.48c288e5.js} +128 -253
  12. package/dist/{2894.bundle.d612efb2.js → 513.bundle.9c0548cf.js} +1 -1
  13. package/dist/{5143.bundle.62bcf4ee.js → 5143.bundle.67167d39.js} +219 -147
  14. package/dist/{5895.bundle.b4892e1b.js → 5320.bundle.0c7b2cb7.js} +1473 -617
  15. package/dist/{5383.bundle.d393d2f5.js → 5383.bundle.79243338.js} +26 -4
  16. package/dist/{4324.bundle.8645d6b4.js → 5888.bundle.cd717f42.js} +1364 -8004
  17. package/dist/{8128.bundle.2afe5a05.js → 5914.bundle.00f408d2.js} +419 -49
  18. package/dist/{1284.bundle.a489bd1d.js → 5989.bundle.f8096a4e.js} +1175 -616
  19. package/dist/{6255.bundle.ee378f1c.js → 6255.bundle.521051c1.js} +42 -18
  20. package/dist/{829.bundle.e60fee3a.js → 641.bundle.4627a8e1.js} +472 -483
  21. package/dist/{1568.bundle.474a5a93.js → 9187.bundle.237037e4.js} +1 -1
  22. package/dist/{6711.bundle.baba2ccd.js → 9232.bundle.3b0caf8e.js} +10 -10
  23. package/dist/{1895.bundle.923d0bd4.js → 9620.bundle.67375c83.js} +82 -24
  24. package/dist/{app.bundle.3a861c86.js → app.bundle.b9e31304.js} +44 -44
  25. package/dist/{compute.bundle.caab94e6.js → compute.bundle.a8f26c49.js} +10 -10
  26. package/dist/index.html +1 -1
  27. package/dist/{interpolation.bundle.eed65b60.js → interpolation.bundle.aef2f614.js} +5 -5
  28. package/dist/{polySeg.bundle.34a58c4f.js → polySeg.bundle.ba052ac3.js} +11 -11
  29. package/dist/static/wasm/{27ff970b98.module.wasm → 0e14aeab30.module.wasm} +0 -0
  30. package/dist/static/wasm/58a146bc8c.module.wasm +0 -0
  31. package/dist/static/wasm/99a2672e64.module.wasm +0 -0
  32. package/dist/static/wasm/{11f8dc2413.module.wasm → d8b213f3ea.module.wasm} +0 -0
  33. package/dist/sw.js +1 -1
  34. package/package.json +6 -6
  35. package/dist/0.bundle.485115b4.js +0 -4498
  36. package/dist/static/wasm/58769f1d7d.module.wasm +0 -0
  37. /package/dist/{1895.bundle.css → 9620.bundle.css} +0 -0
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- (globalThis["rspackChunk_ohif_app"] ||= []).push([[8128], {
2
+ (globalThis["rspackChunk_ohif_app"] ||= []).push([[5914], {
3
3
  45376(__unused_rspack___webpack_module__, __webpack_exports__) {
4
4
  const CORNERSTONE_COLOR_LUT = [
5
5
  [0, 0, 0, 0],
@@ -398,48 +398,6 @@ __webpack_require__.d(__webpack_exports__, {
398
398
  });
399
399
 
400
400
 
401
- },
402
- 47290(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
403
- /* import */ var _SegmentationStateManager_js__rspack_import_0 = __webpack_require__(91155);
404
-
405
- function getSegmentationRepresentations(viewportId, specifier = {}) {
406
- const segmentationStateManager = _SegmentationStateManager_js__rspack_import_0/* .defaultSegmentationStateManager */._6;
407
- return segmentationStateManager.getSegmentationRepresentations(viewportId, specifier);
408
- }
409
- function getSegmentationRepresentation(viewportId, specifier) {
410
- const segmentationStateManager = _SegmentationStateManager_js__rspack_import_0/* .defaultSegmentationStateManager */._6;
411
- if (!specifier.segmentationId || !specifier.type) {
412
- throw new Error('getSegmentationRepresentation: No segmentationId or type provided, you need to provide at least one of them');
413
- }
414
- const representations = segmentationStateManager.getSegmentationRepresentations(viewportId, specifier);
415
- return representations?.[0];
416
- }
417
- function getSegmentationRepresentationsBySegmentationId(segmentationId) {
418
- const segmentationStateManager = _SegmentationStateManager_js__rspack_import_0/* .defaultSegmentationStateManager */._6;
419
- return segmentationStateManager.getSegmentationRepresentationsBySegmentationId(segmentationId);
420
- }
421
-
422
- __webpack_require__.d(__webpack_exports__, {
423
- Ut: () => (getSegmentationRepresentation),
424
- ny: () => (getSegmentationRepresentationsBySegmentationId),
425
- r$: () => (getSegmentationRepresentations)
426
- });
427
-
428
-
429
- },
430
- 45114(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
431
- /* import */ var _SegmentationStateManager_js__rspack_import_0 = __webpack_require__(91155);
432
-
433
- function getSegmentationRepresentationVisibility(viewportId, specifier) {
434
- const segmentationStateManager = _SegmentationStateManager_js__rspack_import_0/* .defaultSegmentationStateManager */._6;
435
- return segmentationStateManager.getSegmentationRepresentationVisibility(viewportId, specifier);
436
- }
437
-
438
- __webpack_require__.d(__webpack_exports__, {
439
- I: () => (getSegmentationRepresentationVisibility)
440
- });
441
-
442
-
443
401
  },
444
402
  32092(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
445
403
  /* import */ var _cornerstonejs_core__rspack_import_0 = __webpack_require__(62721);
@@ -574,6 +532,14 @@ function stackViewportReferencesImages(viewport, layers) {
574
532
  const referencedImageIdSet = new Set(referencedImageIds);
575
533
  return viewportImageIds.some((imageId) => referencedImageIdSet.has(imageId));
576
534
  }
535
+ function mountsAVolume(viewport) {
536
+ try {
537
+ return (viewport.getAllVolumeIds?.() ?? []).length > 0;
538
+ }
539
+ catch (error) {
540
+ return false;
541
+ }
542
+ }
577
543
  function isSegmentationOverlayCompatible(viewport, segmentationId, representationType) {
578
544
  if (representationType !== _enums_index_js__rspack_import_1.SegmentationRepresentations.Labelmap) {
579
545
  return true;
@@ -586,8 +552,11 @@ function isSegmentationOverlayCompatible(viewport, segmentationId, representatio
586
552
  return true;
587
553
  }
588
554
  const layers = (0,_labelmapModel_index_js__rspack_import_3/* .getLabelmaps */.m)(segmentation);
589
- const isVolumeViewport = typeof viewport
555
+ const exposesVolumeApi = typeof viewport
590
556
  .getAllVolumeIds === 'function';
557
+ const isVolumeViewport = exposesVolumeApi &&
558
+ (viewport.type !== _cornerstonejs_core__rspack_import_0.Enums.ViewportType.PLANAR_NEXT ||
559
+ mountsAVolume(viewport));
591
560
  return isVolumeViewport
592
561
  ? volumeViewportSharesFrameOfReference(viewport, layers)
593
562
  : stackViewportReferencesImages(viewport, layers);
@@ -858,6 +827,332 @@ __webpack_require__.d(__webpack_exports__, {
858
827
  });
859
828
 
860
829
 
830
+ },
831
+ 78691(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
832
+ /* import */ var _cornerstonejs_core__rspack_import_0 = __webpack_require__(62721);
833
+ /* import */ var _helpers_getViewportLabelmapRenderMode_js__rspack_import_1 = __webpack_require__(15422);
834
+ /* import */ var _normalizeLabelmapSegmentationData_js__rspack_import_2 = __webpack_require__(18782);
835
+ /* import */ var _labelmapLayerStore_js__rspack_import_3 = __webpack_require__(53325);
836
+ /* import */ var _labelmapSegmentBindings_js__rspack_import_4 = __webpack_require__(53344);
837
+ /* import */ var _labelmapLegacyAdapter_js__rspack_import_5 = __webpack_require__(19637);
838
+ /* import */ var _labelmapImageIdMapping_js__rspack_import_6 = __webpack_require__(27749);
839
+
840
+
841
+
842
+
843
+
844
+
845
+
846
+ class LabelmapImageReferenceResolver {
847
+ constructor(getSegmentation) {
848
+ this.stackLabelmapImageIdReferenceMap = new Map();
849
+ this.labelmapImageIdReferenceMap = new Map();
850
+ this.keysBySegmentationId = new Map();
851
+ this.completedScanResultsBySegmentationId = new Map();
852
+ this.getSegmentation = getSegmentation;
853
+ }
854
+ reset() {
855
+ this.stackLabelmapImageIdReferenceMap.clear();
856
+ this.labelmapImageIdReferenceMap.clear();
857
+ this.keysBySegmentationId.clear();
858
+ this.completedScanResultsBySegmentationId.clear();
859
+ }
860
+ removeSegmentation(segmentationId) {
861
+ this.stackLabelmapImageIdReferenceMap.delete(segmentationId);
862
+ this.completedScanResultsBySegmentationId.delete(segmentationId);
863
+ const keys = this.keysBySegmentationId.get(segmentationId);
864
+ if (keys) {
865
+ for (const key of keys) {
866
+ this.labelmapImageIdReferenceMap.delete(key);
867
+ }
868
+ this.keysBySegmentationId.delete(segmentationId);
869
+ }
870
+ }
871
+ setLabelmapImageIds(segmentationId, key, labelmapImageIds) {
872
+ this.labelmapImageIdReferenceMap.set(key, labelmapImageIds);
873
+ let keys = this.keysBySegmentationId.get(segmentationId);
874
+ if (!keys) {
875
+ keys = new Set();
876
+ this.keysBySegmentationId.set(segmentationId, keys);
877
+ }
878
+ keys.add(key);
879
+ }
880
+ getLabelmapImageIds(representationData) {
881
+ const labelmapData = representationData.Labelmap;
882
+ let labelmapImageIds;
883
+ if (!labelmapData) {
884
+ return;
885
+ }
886
+ if (labelmapData?.labelmaps) {
887
+ const imageIds = Object.values(labelmapData.labelmaps).flatMap((layer) => {
888
+ if (layer.imageIds?.length) {
889
+ return layer.imageIds;
890
+ }
891
+ if (layer.volumeId) {
892
+ return _cornerstonejs_core__rspack_import_0.cache.getVolume(layer.volumeId)
893
+ ?.imageIds;
894
+ }
895
+ return [];
896
+ });
897
+ return Array.from(new Set(imageIds.filter(Boolean)));
898
+ }
899
+ if (labelmapData.imageIds) {
900
+ labelmapImageIds = labelmapData
901
+ .imageIds;
902
+ }
903
+ else if (labelmapData.volumeId) {
904
+ const volumeId = labelmapData
905
+ .volumeId;
906
+ const volume = _cornerstonejs_core__rspack_import_0.cache.getVolume(volumeId);
907
+ labelmapImageIds = volume.imageIds;
908
+ }
909
+ return labelmapImageIds;
910
+ }
911
+ getLabelmapImageIdsForImageId(imageId, segmentationId) {
912
+ const segmentation = this.getSegmentation(segmentationId);
913
+ if (!segmentation?.representationData?.Labelmap) {
914
+ return;
915
+ }
916
+ (0,_normalizeLabelmapSegmentationData_js__rspack_import_2/* .ensureLabelmapState */.uk)(segmentation);
917
+ return (0,_labelmapLegacyAdapter_js__rspack_import_5/* .getReferencedImageIdToCurrentImageIdMap */._)(segmentation).get(imageId);
918
+ }
919
+ updateLabelmapSegmentationImageReferences(viewportId, segmentationId) {
920
+ const segmentation = this.getSegmentation(segmentationId);
921
+ if (!segmentation) {
922
+ return;
923
+ }
924
+ if (!this.stackLabelmapImageIdReferenceMap.has(segmentationId)) {
925
+ this.stackLabelmapImageIdReferenceMap.set(segmentationId, new Map());
926
+ }
927
+ const { representationData } = segmentation;
928
+ if (!representationData.Labelmap) {
929
+ return;
930
+ }
931
+ const labelmapImageIds = this.getLabelmapImageIds(representationData);
932
+ const enabledElement = (0,_cornerstonejs_core__rspack_import_0.getEnabledElementByViewportId)(viewportId);
933
+ if (!enabledElement || !labelmapImageIds?.length) {
934
+ return;
935
+ }
936
+ const viewport = enabledElement.viewport;
937
+ const scanKey = this.generateScanKey('current', viewport, labelmapImageIds);
938
+ if (scanKey && this.hasCompletedScan(segmentationId, scanKey)) {
939
+ return this.getCompletedScanResult(segmentationId, scanKey);
940
+ }
941
+ const result = this.updateLabelmapSegmentationReferences(segmentationId, viewport, labelmapImageIds);
942
+ if (scanKey) {
943
+ this.markCompletedScan(segmentationId, scanKey, result);
944
+ }
945
+ return result;
946
+ }
947
+ generateScanKey(kind, viewport, labelmapImageIds) {
948
+ const referenceImageId = typeof viewport.getCurrentImageId === 'function'
949
+ ? viewport.getCurrentImageId()
950
+ : undefined;
951
+ if (!referenceImageId) {
952
+ return;
953
+ }
954
+ return `${kind}|${viewport.id}|${referenceImageId}|${labelmapImageIds.length}|${labelmapImageIds[0]}|${labelmapImageIds[labelmapImageIds.length - 1]}`;
955
+ }
956
+ hasCompletedScan(segmentationId, scanKey) {
957
+ return !!this.completedScanResultsBySegmentationId
958
+ .get(segmentationId)
959
+ ?.has(scanKey);
960
+ }
961
+ getCompletedScanResult(segmentationId, scanKey) {
962
+ return this.completedScanResultsBySegmentationId
963
+ .get(segmentationId)
964
+ ?.get(scanKey);
965
+ }
966
+ markCompletedScan(segmentationId, scanKey, result) {
967
+ let results = this.completedScanResultsBySegmentationId.get(segmentationId);
968
+ if (!results) {
969
+ results = new Map();
970
+ this.completedScanResultsBySegmentationId.set(segmentationId, results);
971
+ }
972
+ results.set(scanKey, result);
973
+ }
974
+ getCurrentLabelmapImageIdsForViewport(viewportId, segmentationId) {
975
+ const enabledElement = (0,_cornerstonejs_core__rspack_import_0.getEnabledElementByViewportId)(viewportId);
976
+ if (!enabledElement) {
977
+ return;
978
+ }
979
+ const { viewport } = enabledElement;
980
+ const viewportRenderMode = (0,_helpers_getViewportLabelmapRenderMode_js__rspack_import_1/* ["default"] */.A)(viewport);
981
+ if (viewportRenderMode !== 'image' ||
982
+ typeof viewport.getCurrentImageId !== 'function') {
983
+ return;
984
+ }
985
+ const referenceImageId = viewport.getCurrentImageId();
986
+ const segmentation = this.getSegmentation(segmentationId);
987
+ if (!segmentation) {
988
+ return;
989
+ }
990
+ (0,_normalizeLabelmapSegmentationData_js__rspack_import_2/* .ensureLabelmapState */.uk)(segmentation);
991
+ const viewportImageIds = viewport.getImageIds();
992
+ const currentIndex = viewportImageIds.indexOf(referenceImageId);
993
+ const labelmapImageIds = [];
994
+ (0,_labelmapLayerStore_js__rspack_import_3/* .getLabelmaps */.m)(segmentation).forEach((layer) => {
995
+ const referencedLabelmapImageIds = (0,_labelmapImageIdMapping_js__rspack_import_6/* .getLabelmapImageIdsForReferencedImageId */.s_)(layer, referenceImageId);
996
+ if (referencedLabelmapImageIds.length) {
997
+ labelmapImageIds.push(...referencedLabelmapImageIds);
998
+ return;
999
+ }
1000
+ if (currentIndex !== -1 && layer.imageIds?.[currentIndex]) {
1001
+ labelmapImageIds.push(layer.imageIds[currentIndex]);
1002
+ return;
1003
+ }
1004
+ layer.imageIds?.some((candidateImageId) => {
1005
+ const viewableImageId = viewport.isReferenceViewable({ referencedImageId: candidateImageId }, { asOverlay: true });
1006
+ if (viewableImageId) {
1007
+ labelmapImageIds.push(candidateImageId);
1008
+ }
1009
+ return !!viewableImageId;
1010
+ });
1011
+ });
1012
+ const resolvedImageIds = Array.from(new Set(labelmapImageIds));
1013
+ const key = this.generateMapKey({
1014
+ segmentationId,
1015
+ referenceImageId,
1016
+ });
1017
+ this.setLabelmapImageIds(segmentationId, key, resolvedImageIds);
1018
+ if (!this.stackLabelmapImageIdReferenceMap.has(segmentationId)) {
1019
+ this.stackLabelmapImageIdReferenceMap.set(segmentationId, new Map());
1020
+ }
1021
+ const activeSegmentIndex = Object.keys(segmentation.segments).find((segmentIndex) => segmentation.segments[segmentIndex].active);
1022
+ const activeImageId = activeSegmentIndex
1023
+ ? (0,_labelmapSegmentBindings_js__rspack_import_4/* .getLabelmapForSegment */.r)(segmentation, Number(activeSegmentIndex))
1024
+ ?.imageIds?.[currentIndex]
1025
+ : undefined;
1026
+ this.stackLabelmapImageIdReferenceMap
1027
+ .get(segmentationId)
1028
+ .set(referenceImageId, activeImageId ?? resolvedImageIds[0]);
1029
+ return resolvedImageIds;
1030
+ }
1031
+ getCurrentLabelmapImageIdForViewport(viewportId, segmentationId) {
1032
+ const enabledElement = (0,_cornerstonejs_core__rspack_import_0.getEnabledElementByViewportId)(viewportId);
1033
+ if (!enabledElement) {
1034
+ return;
1035
+ }
1036
+ const { viewport } = enabledElement;
1037
+ const viewportRenderMode = (0,_helpers_getViewportLabelmapRenderMode_js__rspack_import_1/* ["default"] */.A)(viewport);
1038
+ if (viewportRenderMode !== 'image' ||
1039
+ typeof viewport.getCurrentImageId !== 'function') {
1040
+ return;
1041
+ }
1042
+ const currentImageId = viewport.getCurrentImageId();
1043
+ const currentImageIds = this.getCurrentLabelmapImageIdsForViewport(viewportId, segmentationId);
1044
+ if (!currentImageIds?.length) {
1045
+ return;
1046
+ }
1047
+ const segmentation = this.getSegmentation(segmentationId);
1048
+ const currentIndex = viewport
1049
+ .getImageIds()
1050
+ .indexOf(currentImageId);
1051
+ const activeSegmentIndex = segmentation
1052
+ ? Object.keys(segmentation.segments).find((segmentIndex) => segmentation.segments[segmentIndex].active)
1053
+ : undefined;
1054
+ const activeImageId = segmentation && activeSegmentIndex
1055
+ ? (0,_labelmapSegmentBindings_js__rspack_import_4/* .getLabelmapForSegment */.r)(segmentation, Number(activeSegmentIndex))
1056
+ ?.imageIds?.[currentIndex]
1057
+ : undefined;
1058
+ return activeImageId ?? currentImageIds[0];
1059
+ }
1060
+ getStackSegmentationImageIdsForViewport(viewportId, segmentationId) {
1061
+ const segmentation = this.getSegmentation(segmentationId);
1062
+ if (!segmentation) {
1063
+ return [];
1064
+ }
1065
+ this.updateAllLabelmapSegmentationImageReferences(viewportId, segmentationId);
1066
+ const enabledElement = (0,_cornerstonejs_core__rspack_import_0.getEnabledElementByViewportId)(viewportId);
1067
+ const imageIds = enabledElement?.viewport.getImageIds?.() ?? [];
1068
+ const imageIdMap = (0,_labelmapLegacyAdapter_js__rspack_import_5/* .getReferencedImageIdToCurrentImageIdMap */._)(segmentation);
1069
+ return imageIds.flatMap((imageId) => imageIdMap.get(imageId) ?? []);
1070
+ }
1071
+ updateLabelmapSegmentationReferences(segmentationId, viewport, labelmapImageIds, updateCallback) {
1072
+ const referenceImageId = viewport.getCurrentImageId();
1073
+ let viewableLabelmapImageIdFound = false;
1074
+ for (const labelmapImageId of labelmapImageIds) {
1075
+ const viewableImageId = viewport.isReferenceViewable({ referencedImageId: labelmapImageId }, { asOverlay: true });
1076
+ if (viewableImageId) {
1077
+ viewableLabelmapImageIdFound = true;
1078
+ this.stackLabelmapImageIdReferenceMap
1079
+ .get(segmentationId)
1080
+ .set(referenceImageId, labelmapImageId);
1081
+ this.updateLabelmapImageIdReferenceMap({
1082
+ segmentationId,
1083
+ referenceImageId,
1084
+ labelmapImageId,
1085
+ });
1086
+ }
1087
+ }
1088
+ updateCallback?.(viewport, segmentationId, labelmapImageIds);
1089
+ return viewableLabelmapImageIdFound
1090
+ ? this.stackLabelmapImageIdReferenceMap
1091
+ .get(segmentationId)
1092
+ .get(referenceImageId)
1093
+ : undefined;
1094
+ }
1095
+ updateAllLabelmapSegmentationImageReferences(viewportId, segmentationId) {
1096
+ const segmentation = this.getSegmentation(segmentationId);
1097
+ if (!segmentation) {
1098
+ return;
1099
+ }
1100
+ if (!this.stackLabelmapImageIdReferenceMap.has(segmentationId)) {
1101
+ this.stackLabelmapImageIdReferenceMap.set(segmentationId, new Map());
1102
+ }
1103
+ const { representationData } = segmentation;
1104
+ if (!representationData.Labelmap) {
1105
+ return;
1106
+ }
1107
+ const labelmapImageIds = this.getLabelmapImageIds(representationData);
1108
+ const enabledElement = (0,_cornerstonejs_core__rspack_import_0.getEnabledElementByViewportId)(viewportId);
1109
+ if (!enabledElement || !labelmapImageIds?.length) {
1110
+ return;
1111
+ }
1112
+ const stackViewport = enabledElement.viewport;
1113
+ const scanKey = this.generateScanKey('all', stackViewport, labelmapImageIds);
1114
+ if (scanKey && this.hasCompletedScan(segmentationId, scanKey)) {
1115
+ return;
1116
+ }
1117
+ if (scanKey) {
1118
+ this.markCompletedScan(segmentationId, scanKey);
1119
+ }
1120
+ this.updateLabelmapSegmentationReferences(segmentationId, stackViewport, labelmapImageIds, (stackViewport, segmentationId, labelmapImageIds) => {
1121
+ const imageIds = stackViewport.getImageIds();
1122
+ imageIds.forEach((referenceImageId, index) => {
1123
+ for (const labelmapImageId of labelmapImageIds) {
1124
+ const viewableImageId = stackViewport.isReferenceViewable({ referencedImageId: labelmapImageId, sliceIndex: index }, { asOverlay: true, withNavigation: true });
1125
+ if (viewableImageId) {
1126
+ this.stackLabelmapImageIdReferenceMap
1127
+ .get(segmentationId)
1128
+ .set(referenceImageId, labelmapImageId);
1129
+ this.updateLabelmapImageIdReferenceMap({
1130
+ segmentationId,
1131
+ referenceImageId,
1132
+ labelmapImageId,
1133
+ });
1134
+ }
1135
+ }
1136
+ });
1137
+ });
1138
+ }
1139
+ updateLabelmapImageIdReferenceMap({ segmentationId, referenceImageId, labelmapImageId, }) {
1140
+ const key = this.generateMapKey({ segmentationId, referenceImageId });
1141
+ if (!this.labelmapImageIdReferenceMap.has(key)) {
1142
+ this.setLabelmapImageIds(segmentationId, key, [labelmapImageId]);
1143
+ return;
1144
+ }
1145
+ const currentValues = this.labelmapImageIdReferenceMap.get(key) ?? [];
1146
+ const newValues = Array.from(new Set([...currentValues, labelmapImageId]));
1147
+ this.setLabelmapImageIds(segmentationId, key, newValues);
1148
+ }
1149
+ generateMapKey({ segmentationId, referenceImageId }) {
1150
+ return `${segmentationId}-${referenceImageId}`;
1151
+ }
1152
+ }
1153
+ /* export default */ __webpack_exports__.A = (LabelmapImageReferenceResolver);
1154
+
1155
+
861
1156
  },
862
1157
  53325(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
863
1158
  /* import */ var _cornerstonejs_core__rspack_import_0 = __webpack_require__(62721);
@@ -1904,7 +2199,7 @@ __webpack_require__.d(__webpack_exports__, {
1904
2199
  /* import */ var _base_index_js__rspack_import_1 = __webpack_require__(59865);
1905
2200
  /* import */ var _utilities_getViewportICamera_js__rspack_import_2 = __webpack_require__(40196);
1906
2201
  /* import */ var _enums_index_js__rspack_import_3 = __webpack_require__(36776);
1907
- /* import */ var _stateManagement_segmentation_index_js__rspack_import_4 = __webpack_require__(93285);
2202
+ /* import */ var _stateManagement_segmentation_index_js__rspack_import_4 = __webpack_require__(86274);
1908
2203
  /* import */ var _stateManagement_segmentation_triggerSegmentationEvents_js__rspack_import_5 = __webpack_require__(11815);
1909
2204
  /* import */ var _utilities_segmentation_growCut_constants_js__rspack_import_6 = __webpack_require__(58596);
1910
2205
  /* import */ var _utilities_segmentation_getSVGStyleForSegment_js__rspack_import_7 = __webpack_require__(41076);
@@ -4426,6 +4721,7 @@ var internalGetHiddenSegmentIndices = __webpack_require__(75482);
4426
4721
 
4427
4722
 
4428
4723
  const cs3dLogger = esm.utilities.logger.toolsLog.getLogger('tools.displayTools.Surface.surfaceDisplay');
4724
+ const polySegConversionBySegmentation = new Map();
4429
4725
  function removeRepresentation(viewportId, segmentationId, renderImmediate = false) {
4430
4726
  const enabledElement = (0,esm.getEnabledElementByViewportId)(viewportId);
4431
4727
  if (!enabledElement) {
@@ -4448,10 +4744,14 @@ async function render(viewport, representation) {
4448
4744
  if (!SurfaceData &&
4449
4745
  (0,config/* .getPolySeg */.Qy)()?.canComputeRequestedRepresentation(segmentationId, SegmentationRepresentations/* ["default"].Surface */.A.Surface)) {
4450
4746
  const polySeg = (0,config/* .getPolySeg */.Qy)();
4451
- SurfaceData = await (0,computeAndAddRepresentation/* .computeAndAddRepresentation */.d)(segmentationId, SegmentationRepresentations/* ["default"].Surface */.A.Surface, () => polySeg.computeSurfaceData(segmentationId, { viewport }));
4452
- if (!SurfaceData) {
4453
- throw new Error(`No Surface data found for segmentationId ${segmentationId} even we tried to compute it`);
4747
+ let conversion = polySegConversionBySegmentation.get(segmentationId);
4748
+ if (!conversion) {
4749
+ conversion = (0,computeAndAddRepresentation/* .computeAndAddRepresentation */.d)(segmentationId, SegmentationRepresentations/* ["default"].Surface */.A.Surface, () => polySeg.computeSurfaceData(segmentationId, { viewport })).finally(() => {
4750
+ polySegConversionBySegmentation.delete(segmentationId);
4751
+ });
4752
+ polySegConversionBySegmentation.set(segmentationId, conversion);
4454
4753
  }
4754
+ SurfaceData = await conversion;
4455
4755
  }
4456
4756
  else if (!SurfaceData && !(0,config/* .getPolySeg */.Qy)()) {
4457
4757
  cs3dLogger.debug(`No surface data found for segmentationId ${segmentationId} and PolySeg add-on is not configured. Unable to convert from other representations to surface. Please register PolySeg using cornerstoneTools.init({ addons: { polySeg } }) to enable automatic conversion.`);
@@ -6146,6 +6446,54 @@ __webpack_require__.d(__webpack_exports__, {
6146
6446
  });
6147
6447
 
6148
6448
 
6449
+ },
6450
+ 45393(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
6451
+ /* import */ var _isClosed_js__rspack_import_0 = __webpack_require__(89102);
6452
+
6453
+ function containsPoint(polyline, point, options = {
6454
+ closed: undefined,
6455
+ }) {
6456
+ if (polyline.length < 3) {
6457
+ return false;
6458
+ }
6459
+ const numPolylinePoints = polyline.length;
6460
+ let numIntersections = 0;
6461
+ const { closed, holes } = options;
6462
+ if (holes?.length) {
6463
+ for (const hole of holes) {
6464
+ if (containsPoint(hole, point)) {
6465
+ return false;
6466
+ }
6467
+ }
6468
+ }
6469
+ const shouldClose = !(closed === undefined ? (0,_isClosed_js__rspack_import_0/* ["default"] */.A)(polyline) : closed);
6470
+ const maxSegmentIndex = polyline.length - (shouldClose ? 1 : 2);
6471
+ for (let i = 0; i <= maxSegmentIndex; i++) {
6472
+ const p1 = polyline[i];
6473
+ const p2Index = i === numPolylinePoints - 1 ? 0 : i + 1;
6474
+ const p2 = polyline[p2Index];
6475
+ const maxX = p1[0] >= p2[0] ? p1[0] : p2[0];
6476
+ const maxY = p1[1] >= p2[1] ? p1[1] : p2[1];
6477
+ const minY = p1[1] <= p2[1] ? p1[1] : p2[1];
6478
+ const mayIntersectLineSegment = point[0] <= maxX && point[1] >= minY && point[1] < maxY;
6479
+ if (mayIntersectLineSegment) {
6480
+ const isVerticalLine = p1[0] === p2[0];
6481
+ let intersects = isVerticalLine;
6482
+ if (!intersects) {
6483
+ const xIntersection = ((point[1] - p1[1]) * (p2[0] - p1[0])) / (p2[1] - p1[1]) + p1[0];
6484
+ intersects = point[0] <= xIntersection;
6485
+ }
6486
+ numIntersections += intersects ? 1 : 0;
6487
+ }
6488
+ }
6489
+ return !!(numIntersections % 2);
6490
+ }
6491
+
6492
+ __webpack_require__.d(__webpack_exports__, {
6493
+ A: () => (containsPoint)
6494
+ });
6495
+
6496
+
6149
6497
  },
6150
6498
  33290(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
6151
6499
  function getAABB(polyline, options) {
@@ -6194,6 +6542,28 @@ __webpack_require__.d(__webpack_exports__, {
6194
6542
  });
6195
6543
 
6196
6544
 
6545
+ },
6546
+ 89102(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
6547
+ /* import */ var gl_matrix__rspack_import_0 = __webpack_require__(50341);
6548
+ /* import */ var _point_index_js__rspack_import_1 = __webpack_require__(3756);
6549
+
6550
+
6551
+ function isClosed(polyline) {
6552
+ if (polyline.length < 3) {
6553
+ return false;
6554
+ }
6555
+ const numPolylinePoints = polyline.length;
6556
+ const firstPoint = polyline[0];
6557
+ const lastPoint = polyline[numPolylinePoints - 1];
6558
+ const distFirstToLastPoints = (0,_point_index_js__rspack_import_1.distanceToPointSquared)(firstPoint, lastPoint);
6559
+ return gl_matrix__rspack_import_0/* .glMatrix.equals */.Fd.aI(0, distFirstToLastPoints);
6560
+ }
6561
+
6562
+ __webpack_require__.d(__webpack_exports__, {
6563
+ A: () => (isClosed)
6564
+ });
6565
+
6566
+
6197
6567
  },
6198
6568
  75018(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
6199
6569
  /* import */ var gl_matrix__rspack_import_0 = __webpack_require__(50341);
@@ -6715,7 +7085,7 @@ __webpack_require__.d(__webpack_exports__, {
6715
7085
  /* import */ var _enums_index_js__rspack_import_1 = __webpack_require__(36776);
6716
7086
  /* import */ var _stateManagement_segmentation_segmentationState_js__rspack_import_2 = __webpack_require__(61342);
6717
7087
  /* import */ var _stateManagement_index_js__rspack_import_3 = __webpack_require__(63666);
6718
- /* import */ var _math_polyline_index_js__rspack_import_4 = __webpack_require__(58232);
7088
+ /* import */ var _math_polyline_index_js__rspack_import_4 = __webpack_require__(1109);
6719
7089
  /* import */ var _planar_filterAnnotationsForDisplay_js__rspack_import_5 = __webpack_require__(29362);
6720
7090
  /* import */ var _stateManagement_segmentation_helpers_getSegmentationActor_js__rspack_import_6 = __webpack_require__(32092);
6721
7091
  /* import */ var _stateManagement_segmentation_helpers_getViewportLabelmapRenderMode_js__rspack_import_7 = __webpack_require__(15422);