@cornerstonejs/tools 4.22.13 → 5.0.0

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 (225) hide show
  1. package/dist/esm/config.d.ts +4 -0
  2. package/dist/esm/drawingSvg/drawPath.d.ts +3 -0
  3. package/dist/esm/drawingSvg/drawPath.js +4 -1
  4. package/dist/esm/eventListeners/keyboard/keyDownListener.js +2 -2
  5. package/dist/esm/eventListeners/mouse/getMouseEventPoints.d.ts +1 -1
  6. package/dist/esm/eventListeners/mouse/getMouseEventPoints.js +19 -1
  7. package/dist/esm/eventListeners/mouse/mouseDoubleClickListener.js +8 -1
  8. package/dist/esm/eventListeners/mouse/mouseDownListener.js +37 -5
  9. package/dist/esm/eventListeners/mouse/mouseMoveListener.js +3 -0
  10. package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js +60 -92
  11. package/dist/esm/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js +49 -21
  12. package/dist/esm/eventListeners/segmentation/labelmap/performStackLabelmapUpdate.js +7 -13
  13. package/dist/esm/eventListeners/segmentation/labelmap/performVolumeLabelmapUpdate.js +44 -18
  14. package/dist/esm/eventListeners/touch/getTouchEventPoints.js +27 -4
  15. package/dist/esm/eventListeners/touch/touchStartListener.js +27 -9
  16. package/dist/esm/eventListeners/wheel/wheelListener.js +5 -1
  17. package/dist/esm/init.js +2 -0
  18. package/dist/esm/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.js +10 -4
  19. package/dist/esm/stateManagement/segmentation/SegmentationRenderingEngine.js +23 -20
  20. package/dist/esm/stateManagement/segmentation/SegmentationRepresentationDisplayRegistry.d.ts +12 -0
  21. package/dist/esm/stateManagement/segmentation/SegmentationRepresentationDisplayRegistry.js +7 -0
  22. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.d.ts +1 -11
  23. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +28 -166
  24. package/dist/esm/stateManagement/segmentation/addColorLUT.js +7 -1
  25. package/dist/esm/stateManagement/segmentation/getCurrentLabelmapImageIdForViewport.js +16 -1
  26. package/dist/esm/stateManagement/segmentation/helpers/clearSegmentValue.js +9 -7
  27. package/dist/esm/stateManagement/segmentation/helpers/getSegmentationActor.d.ts +1 -1
  28. package/dist/esm/stateManagement/segmentation/helpers/getSegmentationActor.js +3 -2
  29. package/dist/esm/stateManagement/segmentation/helpers/getViewportLabelmapRenderMode.d.ts +5 -0
  30. package/dist/esm/stateManagement/segmentation/helpers/getViewportLabelmapRenderMode.js +58 -0
  31. package/dist/esm/stateManagement/segmentation/helpers/labelmapImageMapperSupport.d.ts +52 -0
  32. package/dist/esm/stateManagement/segmentation/helpers/labelmapImageMapperSupport.js +246 -0
  33. package/dist/esm/stateManagement/segmentation/helpers/labelmapSegmentationState.d.ts +1 -0
  34. package/dist/esm/stateManagement/segmentation/helpers/labelmapSegmentationState.js +1 -0
  35. package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +11 -1
  36. package/dist/esm/stateManagement/segmentation/internalAddSegmentationRepresentation.js +3 -3
  37. package/dist/esm/stateManagement/segmentation/labelmapModel/index.d.ts +9 -0
  38. package/dist/esm/stateManagement/segmentation/labelmapModel/index.js +7 -0
  39. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapEditTransaction.d.ts +54 -0
  40. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapEditTransaction.js +224 -0
  41. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageIdMapping.d.ts +6 -0
  42. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageIdMapping.js +39 -0
  43. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageReferenceResolver.d.ts +23 -0
  44. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageReferenceResolver.js +269 -0
  45. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLayerStore.d.ts +15 -0
  46. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLayerStore.js +160 -0
  47. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLegacyAdapter.d.ts +4 -0
  48. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLegacyAdapter.js +42 -0
  49. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapSegmentBindings.d.ts +11 -0
  50. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapSegmentBindings.js +73 -0
  51. package/dist/esm/stateManagement/segmentation/labelmapModel/normalizeLabelmapSegmentationData.d.ts +17 -0
  52. package/dist/esm/stateManagement/segmentation/labelmapModel/normalizeLabelmapSegmentationData.js +75 -0
  53. package/dist/esm/stateManagement/segmentation/labelmapModel/privateLabelmap.d.ts +5 -0
  54. package/dist/esm/stateManagement/segmentation/labelmapModel/privateLabelmap.js +106 -0
  55. package/dist/esm/stateManagement/segmentation/models/SegmentModel.d.ts +11 -0
  56. package/dist/esm/stateManagement/segmentation/models/SegmentModel.js +19 -0
  57. package/dist/esm/stateManagement/segmentation/models/SegmentationModel.d.ts +12 -0
  58. package/dist/esm/stateManagement/segmentation/models/SegmentationModel.js +23 -0
  59. package/dist/esm/stateManagement/segmentation/removeSegmentationRepresentations.js +6 -10
  60. package/dist/esm/stateManagement/segmentation/segmentIndex.js +24 -0
  61. package/dist/esm/stateManagement/segmentation/segmentationEventManager.js +2 -9
  62. package/dist/esm/stateManagement/segmentation/segmentationState.d.ts +2 -1
  63. package/dist/esm/stateManagement/segmentation/segmentationState.js +4 -1
  64. package/dist/esm/store/state.js +2 -1
  65. package/dist/esm/synchronizers/callbacks/imageSliceSyncCallback.js +12 -3
  66. package/dist/esm/synchronizers/callbacks/presentationViewSyncCallback.js +5 -2
  67. package/dist/esm/synchronizers/callbacks/zoomPanSyncCallback.js +51 -3
  68. package/dist/esm/tools/AdvancedMagnifyTool.js +1 -1
  69. package/dist/esm/tools/CrosshairsTool.js +5 -5
  70. package/dist/esm/tools/OrientationControllerTool.js +1 -1
  71. package/dist/esm/tools/OrientationMarkerTool.js +4 -4
  72. package/dist/esm/tools/PanTool.js +26 -3
  73. package/dist/esm/tools/PlanarRotateTool.js +19 -4
  74. package/dist/esm/tools/ReferenceCursors.js +7 -1
  75. package/dist/esm/tools/SculptorTool/CircleSculptCursor.js +1 -1
  76. package/dist/esm/tools/TrackballRotateTool.js +3 -2
  77. package/dist/esm/tools/VolumeCroppingTool.js +3 -2
  78. package/dist/esm/tools/WindowLevelTool.d.ts +2 -1
  79. package/dist/esm/tools/WindowLevelTool.js +48 -4
  80. package/dist/esm/tools/ZoomTool.d.ts +8 -0
  81. package/dist/esm/tools/ZoomTool.js +92 -11
  82. package/dist/esm/tools/annotation/AngleTool.js +33 -31
  83. package/dist/esm/tools/annotation/ArrowAnnotateTool.js +30 -28
  84. package/dist/esm/tools/annotation/BidirectionalTool.js +51 -49
  85. package/dist/esm/tools/annotation/CircleROITool.js +49 -44
  86. package/dist/esm/tools/annotation/CobbAngleTool.js +1 -1
  87. package/dist/esm/tools/annotation/DragProbeTool.js +1 -1
  88. package/dist/esm/tools/annotation/ETDRSGridTool.js +1 -1
  89. package/dist/esm/tools/annotation/EllipticalROITool.js +42 -37
  90. package/dist/esm/tools/annotation/HeightTool.js +1 -1
  91. package/dist/esm/tools/annotation/KeyImageTool.js +11 -11
  92. package/dist/esm/tools/annotation/LabelTool.js +37 -35
  93. package/dist/esm/tools/annotation/LengthTool.js +35 -33
  94. package/dist/esm/tools/annotation/LivewireContourSegmentationTool.js +6 -4
  95. package/dist/esm/tools/annotation/LivewireContourTool.js +1 -1
  96. package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js +6 -4
  97. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +1 -1
  98. package/dist/esm/tools/annotation/ProbeTool.js +51 -46
  99. package/dist/esm/tools/annotation/RectangleROITool.js +42 -37
  100. package/dist/esm/tools/annotation/RegionSegmentPlusTool.js +1 -1
  101. package/dist/esm/tools/annotation/RegionSegmentTool.js +1 -1
  102. package/dist/esm/tools/annotation/SplineContourSegmentationTool.js +1 -1
  103. package/dist/esm/tools/annotation/SplineROITool.js +51 -49
  104. package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js +1 -1
  105. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/UltrasoundPleuraBLineTool.js +57 -55
  106. package/dist/esm/tools/annotation/VideoRedactionTool.js +1 -1
  107. package/dist/esm/tools/base/AnnotationDisplayTool.js +9 -6
  108. package/dist/esm/tools/base/AnnotationTool.js +2 -1
  109. package/dist/esm/tools/base/BaseTool.js +16 -10
  110. package/dist/esm/tools/base/ContourSegmentationBaseTool.js +1 -1
  111. package/dist/esm/tools/base/GrowCutBaseTool.js +2 -2
  112. package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.d.ts +2 -4
  113. package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.js +15 -85
  114. package/dist/esm/tools/displayTools/Labelmap/labelmapActorStyle.d.ts +5 -0
  115. package/dist/esm/tools/displayTools/Labelmap/labelmapActorStyle.js +191 -0
  116. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.d.ts +4 -3
  117. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +48 -209
  118. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/createLabelmapRenderPlan.d.ts +3 -0
  119. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/createLabelmapRenderPlan.js +51 -0
  120. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/index.d.ts +4 -0
  121. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/index.js +3 -0
  122. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan.d.ts +14 -0
  123. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan.js +143 -0
  124. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/planarGenericVolumeLabelmap.d.ts +40 -0
  125. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/planarGenericVolumeLabelmap.js +79 -0
  126. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/removeLabelmapRepresentationFromViewport.d.ts +3 -0
  127. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/removeLabelmapRepresentationFromViewport.js +18 -0
  128. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/resolveLabelmapRenderPlan.d.ts +9 -0
  129. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/resolveLabelmapRenderPlan.js +56 -0
  130. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/stackImagePlan.d.ts +11 -0
  131. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/stackImagePlan.js +35 -0
  132. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/types.d.ts +48 -0
  133. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/types.js +0 -0
  134. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/volumeSliceImageMapperPlan.d.ts +13 -0
  135. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/volumeSliceImageMapperPlan.js +34 -0
  136. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan.d.ts +2 -0
  137. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan.js +1 -0
  138. package/dist/esm/tools/displayTools/Labelmap/labelmapRepresentationUID.d.ts +8 -0
  139. package/dist/esm/tools/displayTools/Labelmap/labelmapRepresentationUID.js +18 -0
  140. package/dist/esm/tools/displayTools/Labelmap/removeLabelmapFromElement.js +2 -5
  141. package/dist/esm/tools/displayTools/Labelmap/removeLabelmapRepresentationData.d.ts +3 -0
  142. package/dist/esm/tools/displayTools/Labelmap/removeLabelmapRepresentationData.js +16 -0
  143. package/dist/esm/tools/displayTools/Labelmap/syncStackLabelmapActors.d.ts +2 -0
  144. package/dist/esm/tools/displayTools/Labelmap/syncStackLabelmapActors.js +135 -0
  145. package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapImageMapper.d.ts +16 -0
  146. package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapImageMapper.js +267 -0
  147. package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapSliceData.d.ts +27 -0
  148. package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapSliceData.js +185 -0
  149. package/dist/esm/tools/displayTools/registerBuiltInSegmentationRepresentationDisplays.d.ts +1 -0
  150. package/dist/esm/tools/displayTools/registerBuiltInSegmentationRepresentationDisplays.js +16 -0
  151. package/dist/esm/tools/segmentation/BrushTool.d.ts +9 -2
  152. package/dist/esm/tools/segmentation/BrushTool.js +109 -25
  153. package/dist/esm/tools/segmentation/CircleScissorsTool.js +13 -6
  154. package/dist/esm/tools/segmentation/LabelmapBaseTool.d.ts +2 -3
  155. package/dist/esm/tools/segmentation/LabelmapBaseTool.js +77 -38
  156. package/dist/esm/tools/segmentation/LabelmapEditWithContour.js +3 -3
  157. package/dist/esm/tools/segmentation/PaintFillTool.js +11 -4
  158. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.d.ts +2 -0
  159. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +16 -8
  160. package/dist/esm/tools/segmentation/RectangleScissorsTool.js +13 -6
  161. package/dist/esm/tools/segmentation/SegmentBidirectionalTool.js +63 -61
  162. package/dist/esm/tools/segmentation/SegmentSelectTool.js +4 -4
  163. package/dist/esm/tools/segmentation/SphereScissorsTool.js +5 -1
  164. package/dist/esm/tools/segmentation/strategies/BrushStrategy.d.ts +7 -0
  165. package/dist/esm/tools/segmentation/strategies/BrushStrategy.js +47 -24
  166. package/dist/esm/tools/segmentation/strategies/compositions/circularCursor.js +49 -15
  167. package/dist/esm/tools/segmentation/strategies/compositions/determineSegmentIndex.js +2 -2
  168. package/dist/esm/tools/segmentation/strategies/compositions/dynamicThreshold.js +5 -1
  169. package/dist/esm/tools/segmentation/strategies/compositions/islandRemovalComposition.js +2 -2
  170. package/dist/esm/tools/segmentation/strategies/compositions/preview.js +2 -2
  171. package/dist/esm/tools/segmentation/strategies/compositions/setValue.js +14 -6
  172. package/dist/esm/tools/segmentation/strategies/utils/crossLayerErase.d.ts +4 -0
  173. package/dist/esm/tools/segmentation/strategies/utils/crossLayerErase.js +23 -0
  174. package/dist/esm/tools/segmentation/strategies/utils/getStrategyData.js +1 -1
  175. package/dist/esm/tools/segmentation/strategies/utils/handleUseSegmentCenterIndex.js +12 -11
  176. package/dist/esm/tools/segmentation/strategies/utils/labelmapOverlap.d.ts +4 -0
  177. package/dist/esm/tools/segmentation/strategies/utils/labelmapOverlap.js +41 -0
  178. package/dist/esm/tools/segmentation/strategies/utils/overwritePolicy.d.ts +3 -0
  179. package/dist/esm/tools/segmentation/strategies/utils/overwritePolicy.js +31 -0
  180. package/dist/esm/tools/segmentation/strategies/utils/segmentSeparation.d.ts +3 -0
  181. package/dist/esm/tools/segmentation/strategies/utils/segmentSeparation.js +38 -0
  182. package/dist/esm/tools/segmentation/utils/LazyBrushEditController.d.ts +19 -0
  183. package/dist/esm/tools/segmentation/utils/LazyBrushEditController.js +55 -0
  184. package/dist/esm/tools/segmentation/utils/lazyBrushPreview.d.ts +3 -0
  185. package/dist/esm/tools/segmentation/utils/lazyBrushPreview.js +34 -0
  186. package/dist/esm/tools/segmentation/utils/shouldUseLazyLabelmapEditing.d.ts +3 -0
  187. package/dist/esm/tools/segmentation/utils/shouldUseLazyLabelmapEditing.js +42 -0
  188. package/dist/esm/types/LabelmapToolOperationData.d.ts +5 -0
  189. package/dist/esm/types/LabelmapTypes.d.ts +29 -6
  190. package/dist/esm/types/SegmentationStateTypes.d.ts +4 -0
  191. package/dist/esm/utilities/calibrateImageSpacing.js +17 -2
  192. package/dist/esm/utilities/contours/AnnotationToPointData.js +1 -1
  193. package/dist/esm/utilities/getSphereBoundsInfo.js +5 -1
  194. package/dist/esm/utilities/getViewportICamera.d.ts +4 -0
  195. package/dist/esm/utilities/getViewportICamera.js +23 -0
  196. package/dist/esm/utilities/getViewportsForAnnotation.js +5 -1
  197. package/dist/esm/utilities/math/basic/BasicStatsCalculator.js +9 -7
  198. package/dist/esm/utilities/pointInSurroundingSphereCallback.js +8 -1
  199. package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js +121 -118
  200. package/dist/esm/utilities/segmentation/SegmentStatsCalculator.js +5 -4
  201. package/dist/esm/utilities/segmentation/VolumetricCalculator.js +1 -1
  202. package/dist/esm/utilities/segmentation/createLabelmapVolumeForViewport.js +1 -1
  203. package/dist/esm/utilities/segmentation/getReferenceVolumeForSegmentation.js +1 -1
  204. package/dist/esm/utilities/segmentation/getReferenceVolumeForSegmentationVolume.js +11 -2
  205. package/dist/esm/utilities/segmentation/getSegmentIndexAtLabelmapBorder.js +36 -17
  206. package/dist/esm/utilities/segmentation/getSegmentIndexAtWorldPoint.js +42 -25
  207. package/dist/esm/utilities/segmentation/getUniqueSegmentIndices.js +3 -30
  208. package/dist/esm/utilities/segmentation/index.d.ts +2 -1
  209. package/dist/esm/utilities/segmentation/index.js +2 -1
  210. package/dist/esm/utilities/segmentation/utilsForWorker.js +2 -2
  211. package/dist/esm/utilities/segmentation/validateLabelmap.js +1 -1
  212. package/dist/esm/utilities/stackPrefetch/stackPrefetch.js +0 -1
  213. package/dist/esm/utilities/touch/index.js +3 -2
  214. package/dist/esm/utilities/viewportCapabilities.d.ts +16 -0
  215. package/dist/esm/utilities/viewportCapabilities.js +18 -0
  216. package/dist/esm/utilities/viewportFilters/filterViewportsWithParallelNormals.d.ts +1 -1
  217. package/dist/esm/utilities/viewportFilters/filterViewportsWithParallelNormals.js +12 -4
  218. package/dist/esm/utilities/viewportFilters/filterViewportsWithSameOrientation.d.ts +1 -1
  219. package/dist/esm/utilities/viewportFilters/filterViewportsWithSameOrientation.js +11 -4
  220. package/dist/esm/utilities/viewportFilters/getViewportIdsWithToolToRender.js +1 -1
  221. package/dist/esm/utilities/viewportPresentation.d.ts +3 -0
  222. package/dist/esm/utilities/viewportPresentation.js +26 -0
  223. package/dist/esm/version.d.ts +1 -1
  224. package/dist/esm/version.js +1 -1
  225. package/package.json +10 -10
@@ -1,10 +1,25 @@
1
1
  import { defaultSegmentationStateManager } from './SegmentationStateManager';
2
+ import { getSegmentation } from './getSegmentation';
3
+ import { getActiveSegmentIndex } from './getActiveSegmentIndex';
4
+ import { getLabelmapForSegment } from './helpers/labelmapSegmentationState';
2
5
  export function getCurrentLabelmapImageIdForViewport(viewportId, segmentationId) {
3
6
  const imageIds = getCurrentLabelmapImageIdsForViewport(viewportId, segmentationId);
4
7
  if (!imageIds?.length) {
5
8
  return;
6
9
  }
7
- return imageIds[0];
10
+ if (imageIds.length === 1) {
11
+ return imageIds[0];
12
+ }
13
+ const segmentation = getSegmentation(segmentationId);
14
+ const activeSegmentIndex = getActiveSegmentIndex(segmentationId);
15
+ const activeLayer = activeSegmentIndex
16
+ ? getLabelmapForSegment(segmentation, activeSegmentIndex)
17
+ : undefined;
18
+ if (!activeLayer?.imageIds?.length) {
19
+ return imageIds[0];
20
+ }
21
+ return (imageIds.find((imageId) => activeLayer.imageIds.includes(imageId)) ??
22
+ imageIds[0]);
8
23
  }
9
24
  export function getCurrentLabelmapImageIdsForViewport(viewportId, segmentationId) {
10
25
  const segmentationStateManager = defaultSegmentationStateManager;
@@ -2,16 +2,17 @@ import { cache, utilities } from '@cornerstonejs/core';
2
2
  import { getSegmentation } from '../getSegmentation';
3
3
  import { triggerSegmentationDataModified } from '../triggerSegmentationEvents';
4
4
  import { createLabelmapMemo } from '../../../utilities/segmentation/createLabelmapMemo';
5
+ import { getSegmentBinding, getLabelmapForSegment, removeSegmentBinding, } from './labelmapSegmentationState';
5
6
  const { DefaultHistoryMemo } = utilities.HistoryMemo;
6
7
  export function clearSegmentValue(segmentationId, segmentIndex, options) {
7
8
  const segmentation = getSegmentation(segmentationId);
8
9
  if (segmentation.representationData.Labelmap) {
9
- const { representationData } = segmentation;
10
- const labelmapData = representationData.Labelmap;
11
- if ('imageIds' in labelmapData || 'volumeId' in labelmapData) {
12
- const items = 'imageIds' in labelmapData
13
- ? labelmapData.imageIds.map((imageId) => cache.getImage(imageId))
14
- : [cache.getVolume(labelmapData.volumeId)];
10
+ const binding = getSegmentBinding(segmentation, segmentIndex);
11
+ const layer = getLabelmapForSegment(segmentation, segmentIndex);
12
+ if (binding && layer) {
13
+ const items = layer.volumeId
14
+ ? [cache.getVolume(layer.volumeId)]
15
+ : (layer.imageIds ?? []).map((imageId) => cache.getImage(imageId));
15
16
  items.forEach((item) => {
16
17
  if (!item) {
17
18
  return;
@@ -22,7 +23,7 @@ export function clearSegmentValue(segmentationId, segmentIndex, options) {
22
23
  : null;
23
24
  const useVoxelManager = memo?.voxelManager ?? voxelManager;
24
25
  voxelManager.forEach(({ value, index }) => {
25
- if (value === segmentIndex) {
26
+ if (value === binding.labelValue) {
26
27
  useVoxelManager.setAtIndex(index, 0);
27
28
  }
28
29
  });
@@ -30,6 +31,7 @@ export function clearSegmentValue(segmentationId, segmentIndex, options) {
30
31
  DefaultHistoryMemo.push(memo);
31
32
  }
32
33
  });
34
+ removeSegmentBinding(segmentation, segmentIndex);
33
35
  }
34
36
  triggerSegmentationDataModified(segmentationId);
35
37
  }
@@ -1,6 +1,6 @@
1
1
  import type { Types } from '@cornerstonejs/core';
2
2
  export declare function getLabelmapActorUID(viewportId: string, segmentationId: string): string | undefined;
3
3
  export declare function getLabelmapActorEntries(viewportId: string, segmentationId: string): Types.ActorEntry[];
4
- export declare function getLabelmapActorEntry(viewportId: string, segmentationId: string): Types.ActorEntry;
4
+ export declare function getLabelmapActorEntry(viewportId: string, segmentationId: string, referencedId?: string): Types.ActorEntry;
5
5
  export declare function getSurfaceActorEntry(viewportId: string, segmentationId: string, segmentIndex?: number | string): Types.ActorEntry;
6
6
  export declare function getSurfaceRepresentationUID(segmentationId: string, segmentIndex?: number | string): string;
@@ -33,8 +33,9 @@ export function getLabelmapActorUID(viewportId, segmentationId) {
33
33
  export function getLabelmapActorEntries(viewportId, segmentationId) {
34
34
  return getActorEntries(viewportId, (actor) => actor.representationUID?.startsWith(`${segmentationId}-${SegmentationRepresentations.Labelmap}`));
35
35
  }
36
- export function getLabelmapActorEntry(viewportId, segmentationId) {
37
- return getActorEntry(viewportId, segmentationId, (actor) => actor.representationUID?.startsWith(`${segmentationId}-${SegmentationRepresentations.Labelmap}`));
36
+ export function getLabelmapActorEntry(viewportId, segmentationId, referencedId) {
37
+ return getActorEntry(viewportId, segmentationId, (actor) => actor.representationUID?.startsWith(`${segmentationId}-${SegmentationRepresentations.Labelmap}`) &&
38
+ (!referencedId || actor.referencedId === referencedId));
38
39
  }
39
40
  export function getSurfaceActorEntry(viewportId, segmentationId, segmentIndex) {
40
41
  return getActorEntry(viewportId, segmentationId, (actor) => actor.representationUID ===
@@ -0,0 +1,5 @@
1
+ import { type Types } from '@cornerstonejs/core';
2
+ export type ViewportLabelmapRenderMode = 'image' | 'volume' | 'unsupported';
3
+ export default function getViewportLabelmapRenderMode(viewport: Types.IViewport, options?: {
4
+ useSliceRendering?: boolean;
5
+ }): ViewportLabelmapRenderMode;
@@ -0,0 +1,58 @@
1
+ import { ActorRenderMode, BaseVolumeViewport, StackViewport, Enums, } from '@cornerstonejs/core';
2
+ import { canRenderVolumeViewportLabelmapAsImage, isSliceRenderingEnabled, } from './labelmapImageMapperSupport';
3
+ export default function getViewportLabelmapRenderMode(viewport, options) {
4
+ const compatibilityViewport = viewport;
5
+ const useSliceRendering = isSliceRenderingEnabled(options);
6
+ if (useSliceRendering && canRenderVolumeViewportLabelmapAsImage(viewport)) {
7
+ return 'image';
8
+ }
9
+ if (viewport instanceof BaseVolumeViewport) {
10
+ return 'volume';
11
+ }
12
+ if (viewport instanceof StackViewport) {
13
+ return 'image';
14
+ }
15
+ const defaultActor = typeof compatibilityViewport.getDefaultActor === 'function'
16
+ ? compatibilityViewport.getDefaultActor()
17
+ : undefined;
18
+ const actorMapper = defaultActor?.actorMapper;
19
+ const renderMode = actorMapper?.renderMode;
20
+ if (renderMode === ActorRenderMode.VTK_VOLUME ||
21
+ renderMode === ActorRenderMode.VTK_VOLUME_SLICE) {
22
+ return 'volume';
23
+ }
24
+ if (renderMode === ActorRenderMode.CPU_VOLUME) {
25
+ return 'volume';
26
+ }
27
+ if (renderMode === ActorRenderMode.VTK_IMAGE ||
28
+ renderMode === ActorRenderMode.CPU_IMAGE) {
29
+ return 'image';
30
+ }
31
+ const actorClassName = typeof defaultActor?.actor?.getClassName === 'function'
32
+ ? defaultActor.actor.getClassName()
33
+ : undefined;
34
+ if (actorClassName === 'vtkVolume') {
35
+ return 'volume';
36
+ }
37
+ if (actorClassName === 'vtkImageSlice') {
38
+ return 'image';
39
+ }
40
+ if (actorClassName === 'CanvasActor') {
41
+ const defaultActorRenderMode = actorMapper?.renderMode;
42
+ if (defaultActorRenderMode === ActorRenderMode.CPU_VOLUME) {
43
+ return 'volume';
44
+ }
45
+ return 'image';
46
+ }
47
+ if (compatibilityViewport.type === Enums.ViewportType.PLANAR_NEXT) {
48
+ if (compatibilityViewport.getVolumeId?.()) {
49
+ return 'volume';
50
+ }
51
+ return typeof compatibilityViewport.getCurrentImageId === 'function'
52
+ ? 'image'
53
+ : 'unsupported';
54
+ }
55
+ return typeof compatibilityViewport.getCurrentImageId === 'function'
56
+ ? 'image'
57
+ : 'unsupported';
58
+ }
@@ -0,0 +1,52 @@
1
+ import { Enums, type Types } from '@cornerstonejs/core';
2
+ import type { Segmentation } from '../../../types/SegmentationStateTypes';
3
+ declare const DIRECTION_ALIGNMENT_TOLERANCE = 0.999;
4
+ export declare const LABELMAP_IMAGE_MAPPER_URL_PARAM = "labelmapImageMapper";
5
+ export type VolumeViewportLabelmapImageMapperState = {
6
+ key: string;
7
+ sliceIndex: number;
8
+ supported: boolean;
9
+ };
10
+ type ViewportLabelmapImageMapperCompatibilityViewport = Types.IViewport & {
11
+ getCamera?: () => Pick<Types.ICamera, 'viewPlaneNormal' | 'viewUp'>;
12
+ getCurrentImageIdIndex?: () => number;
13
+ getDisplaySetRenderMode?: (displaySetId: string) => Types.ActorRenderMode | string | undefined;
14
+ getDisplaySetRole?: (displaySetId: string) => 'source' | 'overlay' | undefined;
15
+ getDisplaySetPresentation?: (dataId: string) => {
16
+ blendMode?: Enums.BlendModes;
17
+ slabThickness?: number;
18
+ };
19
+ getDefaultActor?: () => (Types.ActorEntry & {
20
+ actorMapper?: {
21
+ actor?: {
22
+ getMapper?: () => {
23
+ getBlendMode?: () => Enums.BlendModes;
24
+ getSlabThickness?: () => number;
25
+ };
26
+ };
27
+ mapper?: {
28
+ getBlendMode?: () => Enums.BlendModes;
29
+ getSlabThickness?: () => number;
30
+ };
31
+ renderMode?: Types.ActorRenderMode;
32
+ };
33
+ }) | undefined;
34
+ getSliceViewInfo?: () => {
35
+ sliceIndex: number;
36
+ };
37
+ getSourceDataId?: () => string | undefined;
38
+ getVolumeId?: () => string | undefined;
39
+ getResolvedView?: () => {
40
+ toICamera?: () => Pick<Types.ICamera, 'viewPlaneNormal' | 'viewUp'>;
41
+ } | undefined;
42
+ type?: string;
43
+ };
44
+ export declare function isSliceRenderingEnabled(options?: {
45
+ useSliceRendering?: boolean;
46
+ }): boolean;
47
+ export declare function shouldUseSliceRendering(segmentation?: Segmentation, options?: {
48
+ useSliceRendering?: boolean;
49
+ }): boolean;
50
+ export declare function canRenderVolumeViewportLabelmapAsImage(viewport: Types.IViewport): viewport is ViewportLabelmapImageMapperCompatibilityViewport;
51
+ export declare function getVolumeViewportLabelmapImageMapperState(viewport: Types.IViewport): VolumeViewportLabelmapImageMapperState;
52
+ export { DIRECTION_ALIGNMENT_TOLERANCE };
@@ -0,0 +1,246 @@
1
+ import { ActorRenderMode, Enums, VolumeViewport, } from '@cornerstonejs/core';
2
+ import { vec3 } from 'gl-matrix';
3
+ import { getLabelmaps } from '../labelmapModel/labelmapLayerStore';
4
+ const DIRECTION_ALIGNMENT_TOLERANCE = 0.999;
5
+ const MINIMUM_SLAB_THICKNESS = 0.1;
6
+ const SLAB_THICKNESS_EPSILON = 1e-3;
7
+ export const LABELMAP_IMAGE_MAPPER_URL_PARAM = 'labelmapImageMapper';
8
+ function isSupportedImageMapperBlendMode(blendMode) {
9
+ return (blendMode === Enums.BlendModes.COMPOSITE ||
10
+ blendMode === Enums.BlendModes.AVERAGE_INTENSITY_BLEND);
11
+ }
12
+ function isPlanarGpuVolumeSliceViewport(viewport) {
13
+ const compatibilityViewport = viewport;
14
+ if (compatibilityViewport.type !== Enums.ViewportType.PLANAR_NEXT) {
15
+ return false;
16
+ }
17
+ return (getPlanarPrimaryRenderMode(compatibilityViewport) ===
18
+ ActorRenderMode.VTK_VOLUME_SLICE);
19
+ }
20
+ function getPlanarPrimaryRenderMode(viewport) {
21
+ const primaryDataId = getPlanarPrimaryDataId(viewport);
22
+ if (primaryDataId) {
23
+ const renderMode = viewport.getDisplaySetRenderMode?.(primaryDataId);
24
+ if (renderMode) {
25
+ return renderMode;
26
+ }
27
+ }
28
+ return viewport.getDefaultActor?.()?.actorMapper?.renderMode;
29
+ }
30
+ function getPlanarVolumeSliceMapper(viewport) {
31
+ const defaultActor = viewport.getDefaultActor?.();
32
+ return (defaultActor?.actorMapper?.mapper ??
33
+ defaultActor?.actorMapper?.actor?.getMapper?.());
34
+ }
35
+ function getPlanarPrimaryDataId(viewport) {
36
+ const sourceDataId = viewport.getSourceDataId?.();
37
+ if (sourceDataId) {
38
+ return sourceDataId;
39
+ }
40
+ const renderModes = viewport._debug?.renderModes;
41
+ if (!renderModes) {
42
+ return;
43
+ }
44
+ return (Object.entries(renderModes).find(([dataId, renderMode]) => viewport.getDisplaySetRole?.(dataId) === 'source' &&
45
+ renderMode === ActorRenderMode.VTK_VOLUME_SLICE)?.[0] ??
46
+ Object.entries(renderModes).find(([, renderMode]) => renderMode === ActorRenderMode.VTK_VOLUME_SLICE)?.[0]);
47
+ }
48
+ function getLabelmapImageMapperCamera(viewport) {
49
+ const compatibilityViewport = viewport;
50
+ const resolvedCamera = compatibilityViewport
51
+ .getResolvedView?.()
52
+ ?.toICamera?.();
53
+ if (isLabelmapImageMapperCamera(resolvedCamera)) {
54
+ return resolvedCamera;
55
+ }
56
+ const legacyCamera = compatibilityViewport.getCamera?.();
57
+ return isLabelmapImageMapperCamera(legacyCamera) ? legacyCamera : undefined;
58
+ }
59
+ function isLabelmapImageMapperCamera(camera) {
60
+ const candidate = camera;
61
+ return Boolean(candidate &&
62
+ isPoint3Like(candidate.viewPlaneNormal) &&
63
+ isPoint3Like(candidate.viewUp));
64
+ }
65
+ function isPoint3Like(value) {
66
+ const candidate = value;
67
+ return Boolean(candidate &&
68
+ typeof candidate.length === 'number' &&
69
+ candidate.length >= 3 &&
70
+ Number.isFinite(Number(candidate[0])) &&
71
+ Number.isFinite(Number(candidate[1])) &&
72
+ Number.isFinite(Number(candidate[2])));
73
+ }
74
+ function getPlanarVolumeDataPresentation(viewport) {
75
+ if (!viewport.getDisplaySetPresentation) {
76
+ return;
77
+ }
78
+ const primaryDataId = getPlanarPrimaryDataId(viewport);
79
+ return primaryDataId
80
+ ? viewport.getDisplaySetPresentation(primaryDataId)
81
+ : undefined;
82
+ }
83
+ function getCompatibilityBlendMode(viewport) {
84
+ if (viewport instanceof VolumeViewport) {
85
+ return viewport.getBlendMode?.();
86
+ }
87
+ if (!isPlanarGpuVolumeSliceViewport(viewport)) {
88
+ return;
89
+ }
90
+ const presentationBlendMode = getPlanarVolumeDataPresentation(viewport)?.blendMode;
91
+ if (presentationBlendMode !== undefined) {
92
+ return presentationBlendMode;
93
+ }
94
+ return Enums.BlendModes.AVERAGE_INTENSITY_BLEND;
95
+ }
96
+ function getCompatibilitySlabThickness(viewport) {
97
+ if (viewport instanceof VolumeViewport) {
98
+ return viewport.getSlabThickness?.() ?? MINIMUM_SLAB_THICKNESS;
99
+ }
100
+ if (!isPlanarGpuVolumeSliceViewport(viewport)) {
101
+ return MINIMUM_SLAB_THICKNESS;
102
+ }
103
+ const mapperSlabThickness = getPlanarVolumeSliceMapper(viewport)?.getSlabThickness?.();
104
+ if (typeof mapperSlabThickness === 'number') {
105
+ return mapperSlabThickness;
106
+ }
107
+ return (getPlanarVolumeDataPresentation(viewport)?.slabThickness ??
108
+ MINIMUM_SLAB_THICKNESS);
109
+ }
110
+ export function isSliceRenderingEnabled(options) {
111
+ if (options?.useSliceRendering) {
112
+ return true;
113
+ }
114
+ if (typeof window === 'undefined') {
115
+ return false;
116
+ }
117
+ const params = new URLSearchParams(window.location.search);
118
+ if (!params.has(LABELMAP_IMAGE_MAPPER_URL_PARAM)) {
119
+ return false;
120
+ }
121
+ const value = params.get(LABELMAP_IMAGE_MAPPER_URL_PARAM);
122
+ if (value === null || value === '') {
123
+ return true;
124
+ }
125
+ const normalizedValue = value.trim().toLowerCase();
126
+ return (normalizedValue !== '0' &&
127
+ normalizedValue !== 'false' &&
128
+ normalizedValue !== 'off');
129
+ }
130
+ export function shouldUseSliceRendering(segmentation, options) {
131
+ if (isSliceRenderingEnabled(options)) {
132
+ return true;
133
+ }
134
+ if (!segmentation?.representationData?.Labelmap) {
135
+ return false;
136
+ }
137
+ const layers = getLabelmaps(segmentation);
138
+ return layers.length > 1 && layers.some((layer) => layer.type === 'stack');
139
+ }
140
+ export function canRenderVolumeViewportLabelmapAsImage(viewport) {
141
+ const isLegacyVolumeViewport = viewport instanceof VolumeViewport;
142
+ const isNextPlanarViewport = isPlanarGpuVolumeSliceViewport(viewport);
143
+ if (!isLegacyVolumeViewport && !isNextPlanarViewport) {
144
+ return false;
145
+ }
146
+ const blendMode = getCompatibilityBlendMode(viewport);
147
+ if (isLegacyVolumeViewport && !isSupportedImageMapperBlendMode(blendMode)) {
148
+ return false;
149
+ }
150
+ const slabThickness = getCompatibilitySlabThickness(viewport);
151
+ if (slabThickness > MINIMUM_SLAB_THICKNESS + SLAB_THICKNESS_EPSILON) {
152
+ return false;
153
+ }
154
+ if (isLegacyVolumeViewport) {
155
+ try {
156
+ viewport.getSliceViewInfo();
157
+ return true;
158
+ }
159
+ catch {
160
+ return false;
161
+ }
162
+ }
163
+ return true;
164
+ }
165
+ export function getVolumeViewportLabelmapImageMapperState(viewport) {
166
+ const compatibilityViewport = viewport;
167
+ const isLegacyVolumeViewport = viewport instanceof VolumeViewport;
168
+ const isNextPlanarViewport = isPlanarGpuVolumeSliceViewport(viewport);
169
+ if (!isLegacyVolumeViewport && !isNextPlanarViewport) {
170
+ return {
171
+ key: 'unsupported:viewport',
172
+ sliceIndex: NaN,
173
+ supported: false,
174
+ };
175
+ }
176
+ const camera = getLabelmapImageMapperCamera(viewport);
177
+ if (!camera) {
178
+ return {
179
+ key: 'unsupported:camera',
180
+ sliceIndex: NaN,
181
+ supported: false,
182
+ };
183
+ }
184
+ const { viewPlaneNormal, viewUp } = camera;
185
+ const normalizedNormal = vec3.normalize(vec3.create(), viewPlaneNormal);
186
+ const normalizedViewUp = vec3.normalize(vec3.create(), viewUp);
187
+ let sliceIndex;
188
+ if (isLegacyVolumeViewport) {
189
+ try {
190
+ sliceIndex = viewport.getSliceViewInfo().sliceIndex;
191
+ }
192
+ catch {
193
+ sliceIndex = undefined;
194
+ }
195
+ }
196
+ else {
197
+ sliceIndex = compatibilityViewport.getCurrentImageIdIndex?.();
198
+ }
199
+ const blendMode = getCompatibilityBlendMode(viewport);
200
+ const slabThickness = getCompatibilitySlabThickness(viewport);
201
+ const orientationKey = [
202
+ normalizedNormal.map((value) => value.toFixed(3)).join(','),
203
+ normalizedViewUp.map((value) => value.toFixed(3)).join(','),
204
+ ].join('|');
205
+ if (isLegacyVolumeViewport && !isSupportedImageMapperBlendMode(blendMode)) {
206
+ return {
207
+ key: `unsupported:blend:${blendMode}:${orientationKey}`,
208
+ sliceIndex: sliceIndex ?? NaN,
209
+ supported: false,
210
+ };
211
+ }
212
+ if (slabThickness > MINIMUM_SLAB_THICKNESS + SLAB_THICKNESS_EPSILON) {
213
+ return {
214
+ key: `unsupported:slab:${slabThickness.toFixed(3)}:${orientationKey}`,
215
+ sliceIndex: sliceIndex ?? NaN,
216
+ supported: false,
217
+ };
218
+ }
219
+ if (isLegacyVolumeViewport) {
220
+ try {
221
+ viewport.getSliceViewInfo();
222
+ }
223
+ catch {
224
+ return {
225
+ key: `unsupported:oblique:${orientationKey}`,
226
+ sliceIndex: sliceIndex ?? NaN,
227
+ supported: false,
228
+ };
229
+ }
230
+ }
231
+ if (isNextPlanarViewport &&
232
+ getPlanarPrimaryRenderMode(compatibilityViewport) !==
233
+ ActorRenderMode.VTK_VOLUME_SLICE) {
234
+ return {
235
+ key: `unsupported:renderMode:${orientationKey}`,
236
+ sliceIndex: sliceIndex ?? NaN,
237
+ supported: false,
238
+ };
239
+ }
240
+ return {
241
+ key: `supported:${orientationKey}:${sliceIndex ?? 0}`,
242
+ sliceIndex: sliceIndex ?? NaN,
243
+ supported: true,
244
+ };
245
+ }
246
+ export { DIRECTION_ALIGNMENT_TOLERANCE };
@@ -0,0 +1 @@
1
+ export * from '../labelmapModel';
@@ -0,0 +1 @@
1
+ export * from '../labelmapModel';
@@ -1,5 +1,6 @@
1
1
  import { SegmentationRepresentations } from '../../../enums';
2
2
  import { cache } from '@cornerstonejs/core';
3
+ import { ensureLabelmapState, syncLegacyLabelmapData, } from './labelmapSegmentationState';
3
4
  function normalizeSegmentationInput(segmentationInput) {
4
5
  const { segmentationId, representation, config } = segmentationInput;
5
6
  const { type, data: inputData } = representation;
@@ -12,18 +13,27 @@ function normalizeSegmentationInput(segmentationInput) {
12
13
  }
13
14
  const normalizedSegments = normalizeSegments(config?.segments, type, data);
14
15
  delete config?.segments;
15
- return {
16
+ const segmentation = {
16
17
  segmentationId,
17
18
  label: config?.label ?? null,
18
19
  fallbackLabel: config?.fallbackLabel ?? null,
19
20
  cachedStats: config?.cachedStats ?? {},
20
21
  segments: normalizedSegments,
22
+ segmentOrder: config?.segmentOrder ??
23
+ Object.keys(normalizedSegments)
24
+ .map(Number)
25
+ .sort((a, b) => a - b),
21
26
  representationData: {
22
27
  [type]: {
23
28
  ...data,
24
29
  },
25
30
  },
26
31
  };
32
+ if (type === SegmentationRepresentations.Labelmap) {
33
+ ensureLabelmapState(segmentation);
34
+ syncLegacyLabelmapData(segmentation);
35
+ }
36
+ return segmentation;
27
37
  }
28
38
  function normalizeContourData(contourData) {
29
39
  contourData.geometryIds = contourData.geometryIds ?? [];
@@ -1,4 +1,4 @@
1
- import { getEnabledElementByViewportId } from '@cornerstonejs/core';
1
+ import { getEnabledElementByViewportId, utilities } from '@cornerstonejs/core';
2
2
  import CORNERSTONE_COLOR_LUT from '../../constants/COLOR_LUT';
3
3
  import { triggerAnnotationRenderForViewportIds } from '../../utilities/triggerAnnotationRenderForViewportIds';
4
4
  import { SegmentationRepresentations } from '../../enums';
@@ -40,7 +40,7 @@ function internalAddSegmentationRepresentation(viewportId, representationInput)
40
40
  function getColorLUTIndex(config) {
41
41
  const { colorLUTOrIndex } = config || {};
42
42
  if (colorLUTOrIndex === undefined) {
43
- const index = addColorLUT(JSON.parse(JSON.stringify(CORNERSTONE_COLOR_LUT)));
43
+ const index = addColorLUT(utilities.deepClone(CORNERSTONE_COLOR_LUT));
44
44
  return index;
45
45
  }
46
46
  if (typeof colorLUTOrIndex === 'number') {
@@ -51,7 +51,7 @@ function getColorLUTIndex(config) {
51
51
  const index = addColorLUT(colorLUTOrIndex);
52
52
  return index;
53
53
  }
54
- const index = addColorLUT(JSON.parse(JSON.stringify(CORNERSTONE_COLOR_LUT)));
54
+ const index = addColorLUT(utilities.deepClone(CORNERSTONE_COLOR_LUT));
55
55
  return index;
56
56
  }
57
57
  export { internalAddSegmentationRepresentation };
@@ -0,0 +1,9 @@
1
+ export { SOURCE_REPRESENTATION_NAME, ensureLabelmapState, getPrimaryLabelmapId, getSegmentOrder, } from './normalizeLabelmapSegmentationData';
2
+ export type { LabelmapSegmentationWithState } from './normalizeLabelmapSegmentationData';
3
+ export { getConstructorNameForLabelmap, getLabelmap, getLabelmapDataById, getLabelmapForImageId, getLabelmapForVolumeId, getLabelmapIds, getLabelmaps, getOrCreateLabelmapVolume, getScalarArrayLengthFromLabelmap, registerLabelmap, removeLabelmap, } from './labelmapLayerStore';
4
+ export { getReferencedImageIdToCurrentImageIdMap, syncLegacyLabelmapData, } from './labelmapLegacyAdapter';
5
+ export { getLabelmapForSegment, getLabelValueForSegment, getSegmentBinding, getSegmentIndexForLabelValue, getSegmentsOnLabelmap, removeSegmentBinding, resolveLabelmapForSegment, setSegmentBinding, } from './labelmapSegmentBindings';
6
+ export { createPrivateLabelmap, moveSegmentToPrivateLabelmap, } from './privateLabelmap';
7
+ export { beginLabelmapEditTransaction, collectCrossLayerEraseBindings, eraseLabelmapEditTransactionOverwrites, getLabelmapLayerImageId, getProtectedSegmentIndicesForLayer, hasProtectedSegmentOverwrite, resolveLabelmapLayerEditTarget, } from './labelmapEditTransaction';
8
+ export type { BeginLabelmapEditTransactionOptions, EraseLabelmapEditTransactionOptions, LabelmapEditTransaction, LabelmapLayerEditTarget, ResolveLabelmapLayerEditTargetOptions, } from './labelmapEditTransaction';
9
+ export { default as LabelmapImageReferenceResolver } from './labelmapImageReferenceResolver';
@@ -0,0 +1,7 @@
1
+ export { SOURCE_REPRESENTATION_NAME, ensureLabelmapState, getPrimaryLabelmapId, getSegmentOrder, } from './normalizeLabelmapSegmentationData';
2
+ export { getConstructorNameForLabelmap, getLabelmap, getLabelmapDataById, getLabelmapForImageId, getLabelmapForVolumeId, getLabelmapIds, getLabelmaps, getOrCreateLabelmapVolume, getScalarArrayLengthFromLabelmap, registerLabelmap, removeLabelmap, } from './labelmapLayerStore';
3
+ export { getReferencedImageIdToCurrentImageIdMap, syncLegacyLabelmapData, } from './labelmapLegacyAdapter';
4
+ export { getLabelmapForSegment, getLabelValueForSegment, getSegmentBinding, getSegmentIndexForLabelValue, getSegmentsOnLabelmap, removeSegmentBinding, resolveLabelmapForSegment, setSegmentBinding, } from './labelmapSegmentBindings';
5
+ export { createPrivateLabelmap, moveSegmentToPrivateLabelmap, } from './privateLabelmap';
6
+ export { beginLabelmapEditTransaction, collectCrossLayerEraseBindings, eraseLabelmapEditTransactionOverwrites, getLabelmapLayerImageId, getProtectedSegmentIndicesForLayer, hasProtectedSegmentOverwrite, resolveLabelmapLayerEditTarget, } from './labelmapEditTransaction';
7
+ export { default as LabelmapImageReferenceResolver } from './labelmapImageReferenceResolver';
@@ -0,0 +1,54 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ import type vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
3
+ import type { Segmentation } from '../../../types/SegmentationStateTypes';
4
+ import type { LabelmapLayer, SegmentLabelmapBindingState } from '../../../types/LabelmapTypes';
5
+ type MoveSegmentToPrivateLabelmap = (segmentation: Segmentation, segmentIndex: number) => LabelmapLayer | undefined;
6
+ type BeginLabelmapEditTransactionOptions = {
7
+ segmentIndex: number;
8
+ overwriteSegmentIndices?: number[];
9
+ segmentationVoxelManager?: Types.IVoxelManager<number>;
10
+ segmentationImageData?: vtkImageData;
11
+ isInObject?: (point: Types.Point3) => boolean;
12
+ isInObjectBoundsIJK?: Types.BoundsIJK;
13
+ moveSegmentToPrivateLabelmap?: MoveSegmentToPrivateLabelmap;
14
+ };
15
+ type LabelmapEditTransaction = {
16
+ segmentIndex: number;
17
+ labelmapId?: string;
18
+ labelValue: number;
19
+ sourceLayer?: LabelmapLayer;
20
+ activeLayer?: LabelmapLayer;
21
+ overwriteSegmentIndices: number[];
22
+ protectedSegmentIndices: number[];
23
+ crossLayerEraseBindings: SegmentLabelmapBindingState[];
24
+ movedSegment: boolean;
25
+ };
26
+ type ResolveLabelmapLayerEditTargetOptions = {
27
+ viewport?: Types.IViewport;
28
+ imageId?: string;
29
+ sourceLayer?: LabelmapLayer;
30
+ preferVolume?: boolean;
31
+ };
32
+ type LabelmapLayerEditTarget = {
33
+ imageId?: string;
34
+ imageData?: vtkImageData;
35
+ voxelManager?: Types.IVoxelManager<number>;
36
+ volume?: Types.IImageVolume;
37
+ image?: Types.IImage;
38
+ };
39
+ type EraseLabelmapEditTransactionOptions = {
40
+ viewport: Types.IViewport;
41
+ referenceImageData: vtkImageData;
42
+ isInObject: (point: Types.Point3) => boolean;
43
+ isInObjectBoundsIJK?: Types.BoundsIJK;
44
+ imageId?: string;
45
+ };
46
+ declare function getProtectedSegmentIndicesForLayer(segmentation: Segmentation, labelmapId: string, segmentIndex: number, overwriteSegmentIndices?: number[]): number[];
47
+ declare function hasProtectedSegmentOverwrite(segmentation: Segmentation, labelmapId: string, protectedSegmentIndices: number[], voxelManager?: Types.IVoxelManager<number>, options?: Pick<BeginLabelmapEditTransactionOptions, 'segmentationImageData' | 'isInObject' | 'isInObjectBoundsIJK'>): boolean;
48
+ declare function collectCrossLayerEraseBindings(segmentation: Segmentation, labelmapId: string | undefined, overwriteSegmentIndices?: number[]): SegmentLabelmapBindingState[];
49
+ declare function beginLabelmapEditTransaction(segmentation: Segmentation, options: BeginLabelmapEditTransactionOptions): LabelmapEditTransaction;
50
+ declare function getLabelmapLayerImageId(layer: LabelmapLayer, options?: ResolveLabelmapLayerEditTargetOptions): string | undefined;
51
+ declare function resolveLabelmapLayerEditTarget(layer: LabelmapLayer, options?: ResolveLabelmapLayerEditTargetOptions): LabelmapLayerEditTarget;
52
+ declare function eraseLabelmapEditTransactionOverwrites(segmentation: Segmentation, transaction: LabelmapEditTransaction | undefined, options: EraseLabelmapEditTransactionOptions): number[];
53
+ export { beginLabelmapEditTransaction, collectCrossLayerEraseBindings, eraseLabelmapEditTransactionOverwrites, getLabelmapLayerImageId, getProtectedSegmentIndicesForLayer, hasProtectedSegmentOverwrite, resolveLabelmapLayerEditTarget, };
54
+ export type { BeginLabelmapEditTransactionOptions, EraseLabelmapEditTransactionOptions, LabelmapEditTransaction, LabelmapLayerEditTarget, ResolveLabelmapLayerEditTargetOptions, };