@cornerstonejs/tools 2.0.0-beta.17 → 2.0.0-beta.18

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 (103) hide show
  1. package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js +11 -14
  2. package/dist/esm/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js +26 -27
  3. package/dist/esm/eventListeners/segmentation/segmentationDataModifiedEventListener.js +1 -4
  4. package/dist/esm/eventListeners/segmentation/segmentationModifiedEventListener.js +2 -11
  5. package/dist/esm/eventListeners/segmentation/segmentationRepresentationModifiedEventListener.js +10 -2
  6. package/dist/esm/eventListeners/segmentation/segmentationRepresentationRemovedEventListener.js +2 -2
  7. package/dist/esm/index.d.ts +2 -2
  8. package/dist/esm/index.js +2 -2
  9. package/dist/esm/stateManagement/index.d.ts +3 -3
  10. package/dist/esm/stateManagement/index.js +2 -2
  11. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.d.ts +19 -18
  12. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +87 -130
  13. package/dist/esm/stateManagement/segmentation/activeSegmentation.d.ts +4 -5
  14. package/dist/esm/stateManagement/segmentation/activeSegmentation.js +6 -23
  15. package/dist/esm/stateManagement/segmentation/addRepresentation.d.ts +3 -0
  16. package/dist/esm/stateManagement/segmentation/addRepresentation.js +51 -0
  17. package/dist/esm/stateManagement/segmentation/addRepresentations.d.ts +3 -0
  18. package/dist/esm/stateManagement/segmentation/addRepresentations.js +9 -0
  19. package/dist/esm/stateManagement/segmentation/config/index.d.ts +2 -2
  20. package/dist/esm/stateManagement/segmentation/config/index.js +2 -2
  21. package/dist/esm/stateManagement/segmentation/config/segmentationColor.d.ts +4 -4
  22. package/dist/esm/stateManagement/segmentation/config/segmentationColor.js +10 -10
  23. package/dist/esm/stateManagement/segmentation/config/segmentationConfig.d.ts +8 -8
  24. package/dist/esm/stateManagement/segmentation/config/segmentationConfig.js +19 -13
  25. package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.d.ts +7 -6
  26. package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js +29 -54
  27. package/dist/esm/stateManagement/segmentation/convertStackToVolumeSegmentation.d.ts +1 -1
  28. package/dist/esm/stateManagement/segmentation/convertStackToVolumeSegmentation.js +5 -5
  29. package/dist/esm/stateManagement/segmentation/convertVolumeToStackSegmentation.d.ts +3 -3
  30. package/dist/esm/stateManagement/segmentation/convertVolumeToStackSegmentation.js +5 -5
  31. package/dist/esm/stateManagement/segmentation/helpers/getRepresentationRenderingConfig.d.ts +2 -0
  32. package/dist/esm/stateManagement/segmentation/helpers/{getRepresentationSpecificConfig.js → getRepresentationRenderingConfig.js} +1 -1
  33. package/dist/esm/stateManagement/segmentation/index.d.ts +3 -3
  34. package/dist/esm/stateManagement/segmentation/index.js +3 -3
  35. package/dist/esm/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js +2 -4
  36. package/dist/esm/stateManagement/segmentation/polySeg/Surface/createAndCacheSurfacesFromRaw.js +5 -6
  37. package/dist/esm/stateManagement/segmentation/polySeg/Surface/updateSurfaceData.js +4 -4
  38. package/dist/esm/stateManagement/segmentation/polySeg/canComputeRequestedRepresentation.js +2 -6
  39. package/dist/esm/stateManagement/segmentation/removeRepresentationsFromViewport.d.ts +2 -0
  40. package/dist/esm/stateManagement/segmentation/removeRepresentationsFromViewport.js +23 -0
  41. package/dist/esm/stateManagement/segmentation/segmentIndex.js +6 -4
  42. package/dist/esm/stateManagement/segmentation/segmentationState.d.ts +23 -20
  43. package/dist/esm/stateManagement/segmentation/segmentationState.js +68 -95
  44. package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.d.ts +2 -2
  45. package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.js +4 -18
  46. package/dist/esm/store/ToolGroupManager/destroyToolGroup.js +0 -4
  47. package/dist/esm/tools/AdvancedMagnifyViewport.js +3 -3
  48. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +0 -2
  49. package/dist/esm/tools/base/ContourSegmentationBaseTool.d.ts +0 -1
  50. package/dist/esm/tools/base/ContourSegmentationBaseTool.js +42 -33
  51. package/dist/esm/tools/displayTools/Contour/contourDisplay.d.ts +4 -4
  52. package/dist/esm/tools/displayTools/Contour/contourDisplay.js +17 -30
  53. package/dist/esm/tools/displayTools/Contour/contourHandler/handleContourSegmentation.d.ts +4 -4
  54. package/dist/esm/tools/displayTools/Contour/contourHandler/handleContourSegmentation.js +20 -11
  55. package/dist/esm/tools/displayTools/Contour/contourHandler/utils.d.ts +0 -2
  56. package/dist/esm/tools/displayTools/Contour/contourHandler/utils.js +0 -11
  57. package/dist/esm/tools/displayTools/Contour/removeContourFromElement.d.ts +1 -1
  58. package/dist/esm/tools/displayTools/Contour/removeContourFromElement.js +3 -3
  59. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.d.ts +5 -5
  60. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +51 -54
  61. package/dist/esm/tools/displayTools/SegmentationRenderingEngine.d.ts +19 -0
  62. package/dist/esm/tools/displayTools/SegmentationRenderingEngine.js +136 -0
  63. package/dist/esm/tools/displayTools/Surface/surfaceDisplay.d.ts +5 -5
  64. package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js +14 -25
  65. package/dist/esm/tools/index.d.ts +1 -2
  66. package/dist/esm/tools/index.js +1 -2
  67. package/dist/esm/tools/segmentation/BrushTool.d.ts +15 -2
  68. package/dist/esm/tools/segmentation/BrushTool.js +13 -14
  69. package/dist/esm/tools/segmentation/CircleScissorsTool.js +3 -4
  70. package/dist/esm/tools/segmentation/PaintFillTool.js +1 -2
  71. package/dist/esm/tools/segmentation/RectangleScissorsTool.js +3 -4
  72. package/dist/esm/tools/segmentation/SegmentSelectTool.d.ts +3 -2
  73. package/dist/esm/tools/segmentation/SegmentSelectTool.js +5 -5
  74. package/dist/esm/tools/segmentation/SphereScissorsTool.js +4 -5
  75. package/dist/esm/tools/segmentation/strategies/compositions/preview.js +2 -2
  76. package/dist/esm/types/EventTypes.d.ts +0 -3
  77. package/dist/esm/types/SegmentationStateTypes.d.ts +24 -23
  78. package/dist/esm/types/index.d.ts +2 -2
  79. package/dist/esm/utilities/segmentation/getSegmentIndexAtLabelmapBorder.d.ts +7 -0
  80. package/dist/esm/utilities/segmentation/{getSegmentAtLabelmapBorder.js → getSegmentIndexAtLabelmapBorder.js} +3 -3
  81. package/dist/esm/utilities/segmentation/getSegmentIndexAtWorldPoint.d.ts +11 -0
  82. package/dist/esm/utilities/segmentation/{getSegmentAtWorldPoint.js → getSegmentIndexAtWorldPoint.js} +7 -7
  83. package/dist/esm/utilities/segmentation/index.d.ts +3 -3
  84. package/dist/esm/utilities/segmentation/index.js +3 -3
  85. package/dist/esm/utilities/segmentation/triggerSegmentationRender.d.ts +2 -17
  86. package/dist/esm/utilities/segmentation/triggerSegmentationRender.js +4 -106
  87. package/dist/esm/utilities/segmentation/triggerSegmentationRenderForViewports.d.ts +3 -0
  88. package/dist/esm/utilities/segmentation/triggerSegmentationRenderForViewports.js +6 -0
  89. package/dist/esm/utilities/triggerAnnotationRenderForViewportIds.js +7 -2
  90. package/dist/umd/index.js +1 -1
  91. package/dist/umd/index.js.map +1 -1
  92. package/package.json +3 -4
  93. package/dist/esm/stateManagement/segmentation/addSegmentationRepresentation.d.ts +0 -3
  94. package/dist/esm/stateManagement/segmentation/addSegmentationRepresentation.js +0 -63
  95. package/dist/esm/stateManagement/segmentation/addSegmentationRepresentations.d.ts +0 -3
  96. package/dist/esm/stateManagement/segmentation/addSegmentationRepresentations.js +0 -14
  97. package/dist/esm/stateManagement/segmentation/helpers/getRepresentationSpecificConfig.d.ts +0 -2
  98. package/dist/esm/stateManagement/segmentation/removeSegmentationsFromToolGroup.d.ts +0 -2
  99. package/dist/esm/stateManagement/segmentation/removeSegmentationsFromToolGroup.js +0 -39
  100. package/dist/esm/tools/displayTools/SegmentationDisplayTool.d.ts +0 -13
  101. package/dist/esm/tools/displayTools/SegmentationDisplayTool.js +0 -101
  102. package/dist/esm/utilities/segmentation/getSegmentAtLabelmapBorder.d.ts +0 -7
  103. package/dist/esm/utilities/segmentation/getSegmentAtWorldPoint.d.ts +0 -11
@@ -1,25 +1,8 @@
1
- import { getDefaultSegmentationStateManager, getSegmentation, } from './segmentationState';
2
- import { triggerSegmentationRepresentationModified } from './triggerSegmentationEvents';
3
- function getActiveSegmentationRepresentation(toolGroupId) {
4
- const segmentationStateManager = getDefaultSegmentationStateManager();
5
- const toolGroupSegmentationRepresentations = segmentationStateManager.getSegmentationRepresentations(toolGroupId);
6
- if (!toolGroupSegmentationRepresentations) {
7
- return;
8
- }
9
- const activeRepresentation = toolGroupSegmentationRepresentations.find((representation) => representation.active);
10
- return activeRepresentation;
1
+ import * as SegmentationState from './segmentationState';
2
+ function getActiveRepresentation(viewportId) {
3
+ return SegmentationState.getActiveRepresentation(viewportId);
11
4
  }
12
- function getActiveSegmentation(toolGroupId) {
13
- const activeRepresentation = getActiveSegmentationRepresentation(toolGroupId);
14
- if (!activeRepresentation) {
15
- return;
16
- }
17
- const activeSegmentation = getSegmentation(activeRepresentation.segmentationId);
18
- return activeSegmentation;
5
+ function setActiveRepresentation(viewportId, segmentationRepresentationUID, suppressEvent = false) {
6
+ SegmentationState.setActiveRepresentation(viewportId, segmentationRepresentationUID, suppressEvent);
19
7
  }
20
- function setActiveSegmentationRepresentation(toolGroupId, segmentationRepresentationUID) {
21
- const segmentationStateManager = getDefaultSegmentationStateManager();
22
- segmentationStateManager.setActiveSegmentationRepresentation(toolGroupId, segmentationRepresentationUID);
23
- triggerSegmentationRepresentationModified(toolGroupId, segmentationRepresentationUID);
24
- }
25
- export { getActiveSegmentationRepresentation, getActiveSegmentation, setActiveSegmentationRepresentation, };
8
+ export { getActiveRepresentation, setActiveRepresentation, };
@@ -0,0 +1,3 @@
1
+ import { SegmentationRepresentationConfig, RepresentationPublicInput } from '../../types/SegmentationStateTypes';
2
+ declare function addRepresentation(viewportId: string, representationInput: RepresentationPublicInput, initialConfig?: SegmentationRepresentationConfig): Promise<string>;
3
+ export { addRepresentation };
@@ -0,0 +1,51 @@
1
+ import { utilities } from '@cornerstonejs/core';
2
+ import * as SegmentationState from './segmentationState';
3
+ import { getRepresentationRenderingConfig } from './helpers/getRepresentationRenderingConfig';
4
+ import CORNERSTONE_COLOR_LUT from '../../constants/COLOR_LUT';
5
+ import { triggerAnnotationRenderForViewportIds } from '../../utilities';
6
+ import { SegmentationRepresentations } from '../../enums';
7
+ import { triggerSegmentationModified } from './triggerSegmentationEvents';
8
+ async function addRepresentation(viewportId, representationInput, initialConfig) {
9
+ const { segmentationId, options = {} } = representationInput;
10
+ const segmentationRepresentationUID = representationInput.options?.segmentationRepresentationUID ||
11
+ utilities.uuidv4();
12
+ const colorLUTIndexToUse = getColorLUTIndex(options);
13
+ const representation = {
14
+ segmentationId,
15
+ segmentationRepresentationUID,
16
+ type: representationInput.type,
17
+ colorLUTIndex: colorLUTIndexToUse,
18
+ rendering: getRepresentationRenderingConfig(representationInput),
19
+ polySeg: options.polySeg,
20
+ config: {
21
+ allSegments: {},
22
+ perSegment: {},
23
+ },
24
+ };
25
+ SegmentationState.addRepresentationToViewport(viewportId, representation);
26
+ if (initialConfig) {
27
+ SegmentationState.setAllSegmentsConfig(segmentationRepresentationUID, initialConfig.representations);
28
+ }
29
+ if (representationInput.type === SegmentationRepresentations.Contour) {
30
+ triggerAnnotationRenderForViewportIds([viewportId]);
31
+ }
32
+ triggerSegmentationModified(segmentationId);
33
+ return segmentationRepresentationUID;
34
+ }
35
+ function getColorLUTIndex(options = {}) {
36
+ const colorLUTOrIndexInput = options.colorLUTOrIndex;
37
+ let colorLUTIndexToUse;
38
+ if (typeof colorLUTOrIndexInput === 'number') {
39
+ colorLUTIndexToUse = colorLUTOrIndexInput;
40
+ }
41
+ else {
42
+ const nextIndex = SegmentationState.getNextColorLUTIndex();
43
+ const colorLUTToAdd = Array.isArray(colorLUTOrIndexInput)
44
+ ? colorLUTOrIndexInput
45
+ : CORNERSTONE_COLOR_LUT;
46
+ SegmentationState.addColorLUT(colorLUTToAdd, nextIndex);
47
+ colorLUTIndexToUse = nextIndex;
48
+ }
49
+ return colorLUTIndexToUse;
50
+ }
51
+ export { addRepresentation };
@@ -0,0 +1,3 @@
1
+ import { SegmentationRepresentationConfig, RepresentationPublicInput } from '../../types/SegmentationStateTypes';
2
+ declare function addRepresentations(viewportId: string, representationInputArray: RepresentationPublicInput[], segmentationRepresentationConfig?: SegmentationRepresentationConfig): Promise<string[]>;
3
+ export default addRepresentations;
@@ -0,0 +1,9 @@
1
+ import { addRepresentation } from './addRepresentation';
2
+ async function addRepresentations(viewportId, representationInputArray, segmentationRepresentationConfig) {
3
+ const promises = representationInputArray.map((representationInput) => {
4
+ return addRepresentation(viewportId, representationInput, segmentationRepresentationConfig);
5
+ });
6
+ const segmentationRepresentationUIDs = await Promise.all(promises);
7
+ return segmentationRepresentationUIDs;
8
+ }
9
+ export default addRepresentations;
@@ -1,4 +1,4 @@
1
1
  import * as color from './segmentationColor';
2
2
  import * as visibility from './segmentationVisibility';
3
- import { getGlobalConfig, getGlobalRepresentationConfig, getToolGroupSpecificConfig, setGlobalConfig, setGlobalRepresentationConfig, setToolGroupSpecificConfig, setSegmentSpecificConfig, getSegmentSpecificConfig, setSegmentationRepresentationSpecificConfig, getSegmentationRepresentationSpecificConfig } from './segmentationConfig';
4
- export { color, visibility, getGlobalConfig, getGlobalRepresentationConfig, getToolGroupSpecificConfig, setGlobalConfig, setGlobalRepresentationConfig, setToolGroupSpecificConfig, setSegmentSpecificConfig, getSegmentSpecificConfig, setSegmentationRepresentationSpecificConfig, getSegmentationRepresentationSpecificConfig, };
3
+ import { getGlobalConfig, getGlobalRepresentationConfig, setGlobalConfig, setGlobalRepresentationConfig, getAllSegmentsConfig, getPerSegmentConfig, getSegmentIndexConfig, setAllSegmentsConfig, setPerSegmentConfig, setSegmentIndexConfig } from './segmentationConfig';
4
+ export { color, visibility, getGlobalConfig, getGlobalRepresentationConfig, setGlobalConfig, setGlobalRepresentationConfig, getAllSegmentsConfig, getPerSegmentConfig, getSegmentIndexConfig, setAllSegmentsConfig, setPerSegmentConfig, setSegmentIndexConfig, };
@@ -1,4 +1,4 @@
1
1
  import * as color from './segmentationColor';
2
2
  import * as visibility from './segmentationVisibility';
3
- import { getGlobalConfig, getGlobalRepresentationConfig, getToolGroupSpecificConfig, setGlobalConfig, setGlobalRepresentationConfig, setToolGroupSpecificConfig, setSegmentSpecificConfig, getSegmentSpecificConfig, setSegmentationRepresentationSpecificConfig, getSegmentationRepresentationSpecificConfig, } from './segmentationConfig';
4
- export { color, visibility, getGlobalConfig, getGlobalRepresentationConfig, getToolGroupSpecificConfig, setGlobalConfig, setGlobalRepresentationConfig, setToolGroupSpecificConfig, setSegmentSpecificConfig, getSegmentSpecificConfig, setSegmentationRepresentationSpecificConfig, getSegmentationRepresentationSpecificConfig, };
3
+ import { getGlobalConfig, getGlobalRepresentationConfig, setGlobalConfig, setGlobalRepresentationConfig, getAllSegmentsConfig, getPerSegmentConfig, getSegmentIndexConfig, setAllSegmentsConfig, setPerSegmentConfig, setSegmentIndexConfig, } from './segmentationConfig';
4
+ export { color, visibility, getGlobalConfig, getGlobalRepresentationConfig, setGlobalConfig, setGlobalRepresentationConfig, getAllSegmentsConfig, getPerSegmentConfig, getSegmentIndexConfig, setAllSegmentsConfig, setPerSegmentConfig, setSegmentIndexConfig, };
@@ -1,6 +1,6 @@
1
1
  import type { Types } from '@cornerstonejs/core';
2
2
  declare function addColorLUT(colorLUT: Types.ColorLUT, colorLUTIndex: number): void;
3
- declare function setColorLUT(toolGroupId: string, segmentationRepresentationUID: string, colorLUTIndex: number): void;
4
- declare function getColorForSegmentIndex(toolGroupId: string, segmentationRepresentationUID: string, segmentIndex: number): Types.Color;
5
- declare function setColorForSegmentIndex(toolGroupId: string, segmentationRepresentationUID: string, segmentIndex: number, color: Types.Color): void;
6
- export { getColorForSegmentIndex, addColorLUT, setColorLUT, setColorForSegmentIndex, };
3
+ declare function setColorLUT(segmentationRepresentationUID: string, colorLUTIndex: number): void;
4
+ declare function getSegmentIndexColor(segmentationRepresentationUID: string, segmentIndex: number): Types.Color;
5
+ declare function setSegmentIndexColor(segmentationRepresentationUID: string, segmentIndex: number, color: Types.Color): void;
6
+ export { getSegmentIndexColor, addColorLUT, setColorLUT, setSegmentIndexColor };
@@ -11,8 +11,8 @@ function addColorLUT(colorLUT, colorLUTIndex) {
11
11
  }
12
12
  SegmentationState.addColorLUT(colorLUT, colorLUTIndex);
13
13
  }
14
- function setColorLUT(toolGroupId, segmentationRepresentationUID, colorLUTIndex) {
15
- const segRepresentation = SegmentationState.getSegmentationRepresentationByUID(toolGroupId, segmentationRepresentationUID);
14
+ function setColorLUT(segmentationRepresentationUID, colorLUTIndex) {
15
+ const segRepresentation = SegmentationState.getRepresentation(segmentationRepresentationUID);
16
16
  if (!segRepresentation) {
17
17
  throw new Error(`setColorLUT: could not find segmentation representation with UID ${segmentationRepresentationUID}`);
18
18
  }
@@ -20,12 +20,12 @@ function setColorLUT(toolGroupId, segmentationRepresentationUID, colorLUTIndex)
20
20
  throw new Error(`setColorLUT: could not find colorLUT with index ${colorLUTIndex}`);
21
21
  }
22
22
  segRepresentation.colorLUTIndex = colorLUTIndex;
23
- triggerSegmentationRepresentationModified(toolGroupId, segmentationRepresentationUID);
23
+ triggerSegmentationRepresentationModified(segmentationRepresentationUID);
24
24
  }
25
- function getColorForSegmentIndex(toolGroupId, segmentationRepresentationUID, segmentIndex) {
26
- const segmentationRepresentation = SegmentationState.getSegmentationRepresentationByUID(toolGroupId, segmentationRepresentationUID);
25
+ function getSegmentIndexColor(segmentationRepresentationUID, segmentIndex) {
26
+ const segmentationRepresentation = SegmentationState.getRepresentation(segmentationRepresentationUID);
27
27
  if (!segmentationRepresentation) {
28
- throw new Error(`segmentation representation with UID ${segmentationRepresentationUID} does not exist for tool group ${toolGroupId}`);
28
+ throw new Error(`segmentation representation with UID ${segmentationRepresentationUID} does not exist`);
29
29
  }
30
30
  const { colorLUTIndex } = segmentationRepresentation;
31
31
  const colorLUT = SegmentationState.getColorLUT(colorLUTIndex);
@@ -38,11 +38,11 @@ function getColorForSegmentIndex(toolGroupId, segmentationRepresentationUID, seg
38
38
  }
39
39
  return colorValue;
40
40
  }
41
- function setColorForSegmentIndex(toolGroupId, segmentationRepresentationUID, segmentIndex, color) {
42
- const colorReference = getColorForSegmentIndex(toolGroupId, segmentationRepresentationUID, segmentIndex);
41
+ function setSegmentIndexColor(segmentationRepresentationUID, segmentIndex, color) {
42
+ const colorReference = getSegmentIndexColor(segmentationRepresentationUID, segmentIndex);
43
43
  for (let i = 0; i < color.length; i++) {
44
44
  colorReference[i] = color[i];
45
45
  }
46
- triggerSegmentationRepresentationModified(toolGroupId, segmentationRepresentationUID);
46
+ triggerSegmentationRepresentationModified(segmentationRepresentationUID);
47
47
  }
48
- export { getColorForSegmentIndex, addColorLUT, setColorLUT, setColorForSegmentIndex, };
48
+ export { getSegmentIndexColor, addColorLUT, setColorLUT, setSegmentIndexColor };
@@ -1,13 +1,13 @@
1
1
  import SegmentationRepresentations from '../../../enums/SegmentationRepresentations';
2
- import { RepresentationConfig, SegmentationRepresentationConfig, SegmentSpecificRepresentationConfig } from '../../../types/SegmentationStateTypes';
2
+ import { RepresentationConfig, SegmentationRepresentationConfig, SegmentRepresentationConfig } from '../../../types/SegmentationStateTypes';
3
3
  declare function getGlobalConfig(): SegmentationRepresentationConfig;
4
4
  declare function setGlobalConfig(segmentationConfig: SegmentationRepresentationConfig): void;
5
5
  declare function getGlobalRepresentationConfig(representationType: SegmentationRepresentations): RepresentationConfig['LABELMAP'];
6
6
  declare function setGlobalRepresentationConfig(representationType: SegmentationRepresentations, config: RepresentationConfig['LABELMAP']): void;
7
- declare function getToolGroupSpecificConfig(toolGroupId: string): SegmentationRepresentationConfig;
8
- declare function setToolGroupSpecificConfig(toolGroupId: string, segmentationRepresentationConfig: SegmentationRepresentationConfig): void;
9
- declare function getSegmentationRepresentationSpecificConfig(toolGroupId: string, segmentationRepresentationUID: string): RepresentationConfig;
10
- declare function setSegmentationRepresentationSpecificConfig(toolGroupId: string, segmentationRepresentationUID: string, config: RepresentationConfig): void;
11
- declare function getSegmentSpecificConfig(toolGroupId: string, segmentationRepresentationUID: string, segmentIndex: number): RepresentationConfig;
12
- declare function setSegmentSpecificConfig(toolGroupId: string, segmentationRepresentationUID: string, config: SegmentSpecificRepresentationConfig): void;
13
- export { getGlobalConfig, setGlobalConfig, getGlobalRepresentationConfig, setGlobalRepresentationConfig, getToolGroupSpecificConfig, setToolGroupSpecificConfig, getSegmentationRepresentationSpecificConfig, setSegmentationRepresentationSpecificConfig, getSegmentSpecificConfig, setSegmentSpecificConfig, };
7
+ declare function getAllSegmentsConfig(segmentationRepresentationUID: string): RepresentationConfig;
8
+ declare function setAllSegmentsConfig(segmentationRepresentationUID: string, config: RepresentationConfig): void;
9
+ declare function setPerSegmentConfig(segmentationRepresentationUID: string, config: SegmentRepresentationConfig): void;
10
+ declare function getPerSegmentConfig(segmentationRepresentationUID: string): SegmentRepresentationConfig;
11
+ declare function setSegmentIndexConfig(segmentationRepresentationUID: string, segmentIndex: number, config: RepresentationConfig, suppressEvent?: boolean): void;
12
+ declare function getSegmentIndexConfig(segmentationRepresentationUID: string, segmentIndex: number): RepresentationConfig;
13
+ export { getGlobalConfig, setGlobalConfig, getGlobalRepresentationConfig, setGlobalRepresentationConfig, getAllSegmentsConfig, setAllSegmentsConfig, setPerSegmentConfig, getPerSegmentConfig, setSegmentIndexConfig, getSegmentIndexConfig, };
@@ -1,4 +1,5 @@
1
1
  import * as SegmentationState from '../../../stateManagement/segmentation/segmentationState';
2
+ import { triggerSegmentationRepresentationModified } from '../triggerSegmentationEvents';
2
3
  function getGlobalConfig() {
3
4
  return SegmentationState.getGlobalConfig();
4
5
  }
@@ -22,22 +23,27 @@ function setGlobalRepresentationConfig(representationType, config) {
22
23
  },
23
24
  });
24
25
  }
25
- function getToolGroupSpecificConfig(toolGroupId) {
26
- return SegmentationState.getToolGroupSpecificConfig(toolGroupId);
26
+ function getAllSegmentsConfig(segmentationRepresentationUID) {
27
+ return SegmentationState.getAllSegmentsConfig(segmentationRepresentationUID);
27
28
  }
28
- function setToolGroupSpecificConfig(toolGroupId, segmentationRepresentationConfig) {
29
- SegmentationState.setToolGroupSpecificConfig(toolGroupId, segmentationRepresentationConfig);
29
+ function setAllSegmentsConfig(segmentationRepresentationUID, config) {
30
+ SegmentationState.setAllSegmentsConfig(segmentationRepresentationUID, config);
30
31
  }
31
- function getSegmentationRepresentationSpecificConfig(toolGroupId, segmentationRepresentationUID) {
32
- return SegmentationState.getSegmentationRepresentationSpecificConfig(toolGroupId, segmentationRepresentationUID);
32
+ function setPerSegmentConfig(segmentationRepresentationUID, config) {
33
+ SegmentationState.setPerSegmentConfig(segmentationRepresentationUID, config);
33
34
  }
34
- function setSegmentationRepresentationSpecificConfig(toolGroupId, segmentationRepresentationUID, config) {
35
- SegmentationState.setSegmentationRepresentationSpecificConfig(toolGroupId, segmentationRepresentationUID, config);
35
+ function getPerSegmentConfig(segmentationRepresentationUID) {
36
+ return SegmentationState.getPerSegmentConfig(segmentationRepresentationUID);
36
37
  }
37
- function getSegmentSpecificConfig(toolGroupId, segmentationRepresentationUID, segmentIndex) {
38
- return SegmentationState.getSegmentSpecificRepresentationConfig(toolGroupId, segmentationRepresentationUID, segmentIndex);
38
+ function setSegmentIndexConfig(segmentationRepresentationUID, segmentIndex, config, suppressEvent = false) {
39
+ const perSegment = SegmentationState.getPerSegmentConfig(segmentationRepresentationUID);
40
+ perSegment[segmentIndex] = config;
41
+ if (!suppressEvent) {
42
+ triggerSegmentationRepresentationModified(segmentationRepresentationUID);
43
+ }
39
44
  }
40
- function setSegmentSpecificConfig(toolGroupId, segmentationRepresentationUID, config) {
41
- SegmentationState.setSegmentSpecificRepresentationConfig(toolGroupId, segmentationRepresentationUID, config);
45
+ function getSegmentIndexConfig(segmentationRepresentationUID, segmentIndex) {
46
+ const perSegment = SegmentationState.getPerSegmentConfig(segmentationRepresentationUID);
47
+ return perSegment?.[segmentIndex];
42
48
  }
43
- export { getGlobalConfig, setGlobalConfig, getGlobalRepresentationConfig, setGlobalRepresentationConfig, getToolGroupSpecificConfig, setToolGroupSpecificConfig, getSegmentationRepresentationSpecificConfig, setSegmentationRepresentationSpecificConfig, getSegmentSpecificConfig, setSegmentSpecificConfig, };
49
+ export { getGlobalConfig, setGlobalConfig, getGlobalRepresentationConfig, setGlobalRepresentationConfig, getAllSegmentsConfig, setAllSegmentsConfig, setPerSegmentConfig, getPerSegmentConfig, setSegmentIndexConfig, getSegmentIndexConfig, };
@@ -1,6 +1,7 @@
1
- declare function setSegmentationVisibility(toolGroupId: string, segmentationRepresentationUID: string, visibility: boolean): void;
2
- declare function getSegmentationVisibility(toolGroupId: string, segmentationRepresentationUID: string): boolean | undefined;
3
- declare function setSegmentsVisibility(toolGroupId: string, segmentationRepresentationUID: string, segmentIndices: number[], visibility: boolean): void;
4
- declare function setSegmentVisibility(toolGroupId: string, segmentationRepresentationUID: string, segmentIndex: number, visibility: boolean): void;
5
- declare function getSegmentVisibility(toolGroupId: string, segmentationRepresentationUID: string, segmentIndex: number): boolean;
6
- export { setSegmentationVisibility, getSegmentationVisibility, setSegmentVisibility, setSegmentsVisibility, getSegmentVisibility, };
1
+ declare function setRepresentationVisibility(viewportId: string, segmentationRepresentationUID: string, visibility: boolean): void;
2
+ declare function getRepresentationVisibility(viewportId: string, segmentationRepresentationUID: string): boolean | undefined;
3
+ declare function setSegmentsVisibility(viewport: string, segmentationRepresentationUID: string, segmentIndices: number[], visibility: boolean): void;
4
+ declare function setSegmentIndexVisibility(viewportId: string, segmentationRepresentationUID: string, segmentIndex: number, visibility: boolean): void;
5
+ declare function getSegmentIndexVisibility(viewportId: string, segmentationRepresentationUID: string, segmentIndex: number): boolean;
6
+ declare function getSegmentsHidden(viewportId: string, segmentationRepresentationUID: string): Set<number>;
7
+ export { setRepresentationVisibility, getRepresentationVisibility, setSegmentsVisibility, setSegmentIndexVisibility, getSegmentIndexVisibility, getSegmentsHidden, };
@@ -1,69 +1,44 @@
1
1
  import * as SegmentationState from '../../../stateManagement/segmentation/segmentationState';
2
- import { getSegmentationRepresentations } from '../../../stateManagement/segmentation/segmentationState';
3
- import { getUniqueSegmentIndices } from '../../../utilities/segmentation';
4
2
  import { triggerSegmentationRepresentationModified } from '../triggerSegmentationEvents';
5
- function setSegmentationVisibility(toolGroupId, segmentationRepresentationUID, visibility) {
6
- const toolGroupSegmentationRepresentations = getSegmentationRepresentations(toolGroupId);
7
- if (!toolGroupSegmentationRepresentations) {
8
- return;
9
- }
10
- const representation = toolGroupSegmentationRepresentations.find((representation) => representation.segmentationRepresentationUID ===
11
- segmentationRepresentationUID);
3
+ function setRepresentationVisibility(viewportId, segmentationRepresentationUID, visibility) {
4
+ const representation = SegmentationState.getRepresentation(segmentationRepresentationUID);
5
+ debugger;
12
6
  if (!representation) {
13
7
  return;
14
8
  }
15
- const { segmentsHidden, segmentationId } = representation;
16
- const indices = getUniqueSegmentIndices(segmentationId);
17
- if (visibility) {
18
- segmentsHidden.clear();
19
- }
20
- else {
21
- indices.forEach((index) => {
22
- segmentsHidden.add(index);
23
- });
24
- }
25
- triggerSegmentationRepresentationModified(toolGroupId, representation.segmentationRepresentationUID);
9
+ SegmentationState.setRepresentationVisibility(viewportId, segmentationRepresentationUID, visibility);
10
+ triggerSegmentationRepresentationModified(segmentationRepresentationUID);
26
11
  }
27
- function getSegmentationVisibility(toolGroupId, segmentationRepresentationUID) {
28
- const toolGroupSegmentationRepresentations = getSegmentationRepresentations(toolGroupId);
29
- const representation = toolGroupSegmentationRepresentations.find((representation) => representation.segmentationRepresentationUID ===
30
- segmentationRepresentationUID);
31
- if (!representation) {
32
- return;
33
- }
34
- const { segmentsHidden, segmentationId } = representation;
35
- const indices = getUniqueSegmentIndices(segmentationId);
36
- const indicesSet = new Set(indices);
37
- segmentsHidden.forEach((segmentIndex) => indicesSet.delete(segmentIndex));
38
- return !!indicesSet.size;
12
+ function getRepresentationVisibility(viewportId, segmentationRepresentationUID) {
13
+ return SegmentationState.getRepresentationVisibility(viewportId, segmentationRepresentationUID);
39
14
  }
40
- function setSegmentsVisibility(toolGroupId, segmentationRepresentationUID, segmentIndices, visibility) {
41
- const segRepresentation = SegmentationState.getSegmentationRepresentationByUID(toolGroupId, segmentationRepresentationUID);
42
- if (!segRepresentation) {
43
- return;
44
- }
15
+ function setSegmentsVisibility(viewport, segmentationRepresentationUID, segmentIndices, visibility) {
16
+ const hiddenSegments = getSegmentsHidden(viewport, segmentationRepresentationUID);
45
17
  segmentIndices.forEach((segmentIndex) => {
46
18
  visibility
47
- ? segRepresentation.segmentsHidden.delete(segmentIndex)
48
- : segRepresentation.segmentsHidden.add(segmentIndex);
19
+ ? hiddenSegments.delete(segmentIndex)
20
+ : hiddenSegments.add(segmentIndex);
49
21
  });
50
- triggerSegmentationRepresentationModified(toolGroupId, segmentationRepresentationUID);
22
+ triggerSegmentationRepresentationModified(segmentationRepresentationUID);
51
23
  }
52
- function setSegmentVisibility(toolGroupId, segmentationRepresentationUID, segmentIndex, visibility) {
53
- const segRepresentation = SegmentationState.getSegmentationRepresentationByUID(toolGroupId, segmentationRepresentationUID);
54
- if (!segRepresentation) {
55
- return;
56
- }
24
+ function setSegmentIndexVisibility(viewportId, segmentationRepresentationUID, segmentIndex, visibility) {
25
+ const hiddenSegments = getSegmentsHidden(viewportId, segmentationRepresentationUID);
26
+ debugger;
57
27
  visibility
58
- ? segRepresentation.segmentsHidden.delete(segmentIndex)
59
- : segRepresentation.segmentsHidden.add(segmentIndex);
60
- triggerSegmentationRepresentationModified(toolGroupId, segmentationRepresentationUID);
28
+ ? hiddenSegments.delete(segmentIndex)
29
+ : hiddenSegments.add(segmentIndex);
30
+ triggerSegmentationRepresentationModified(segmentationRepresentationUID);
31
+ }
32
+ function getSegmentIndexVisibility(viewportId, segmentationRepresentationUID, segmentIndex) {
33
+ const hiddenSegments = getSegmentsHidden(viewportId, segmentationRepresentationUID);
34
+ return !hiddenSegments.has(segmentIndex);
61
35
  }
62
- function getSegmentVisibility(toolGroupId, segmentationRepresentationUID, segmentIndex) {
63
- const segRepresentation = SegmentationState.getSegmentationRepresentationByUID(toolGroupId, segmentationRepresentationUID);
64
- if (!segRepresentation) {
65
- return false;
36
+ function getSegmentsHidden(viewportId, segmentationRepresentationUID) {
37
+ const viewportRenderingState = SegmentationState.getRepresentationsRenderingStateForViewport(viewportId);
38
+ if (!viewportRenderingState) {
39
+ return new Set();
66
40
  }
67
- return !segRepresentation.segmentsHidden.has(segmentIndex);
41
+ return (viewportRenderingState[segmentationRepresentationUID]?.segmentsHidden ??
42
+ new Set());
68
43
  }
69
- export { setSegmentationVisibility, getSegmentationVisibility, setSegmentVisibility, setSegmentsVisibility, getSegmentVisibility, };
44
+ export { setRepresentationVisibility, getRepresentationVisibility, setSegmentsVisibility, setSegmentIndexVisibility, getSegmentIndexVisibility, getSegmentsHidden, };
@@ -9,7 +9,7 @@ declare function computeVolumeSegmentationFromStack({ imageIdReferenceMap, optio
9
9
  declare function convertStackToVolumeSegmentation({ segmentationId, options, }: {
10
10
  segmentationId: string;
11
11
  options?: {
12
- toolGroupId: string;
12
+ viewportId: string;
13
13
  volumeId?: string;
14
14
  removeOriginal?: boolean;
15
15
  };
@@ -1,6 +1,6 @@
1
1
  import { volumeLoader, utilities as csUtils, eventTarget, cache, } from '@cornerstonejs/core';
2
2
  import { Events, SegmentationRepresentations } from '../../enums';
3
- import addSegmentationRepresentations from './addSegmentationRepresentations';
3
+ import addRepresentations from './addRepresentations';
4
4
  import { triggerSegmentationRender } from '../../utilities/segmentation';
5
5
  import { getSegmentation } from './segmentationState';
6
6
  import { triggerSegmentationDataModified } from './triggerSegmentationEvents';
@@ -25,12 +25,12 @@ async function convertStackToVolumeSegmentation({ segmentationId, options, }) {
25
25
  });
26
26
  await updateSegmentationState({
27
27
  segmentationId,
28
- toolGroupId: options.toolGroupId,
28
+ viewportId: options.viewportId,
29
29
  options,
30
30
  volumeId,
31
31
  });
32
32
  }
33
- async function updateSegmentationState({ segmentationId, toolGroupId, volumeId, options, }) {
33
+ async function updateSegmentationState({ segmentationId, viewportId, volumeId, options, }) {
34
34
  const segmentation = getSegmentation(segmentationId);
35
35
  if (options?.removeOriginal) {
36
36
  const data = segmentation.representationData
@@ -49,13 +49,13 @@ async function updateSegmentationState({ segmentationId, toolGroupId, volumeId,
49
49
  volumeId,
50
50
  };
51
51
  }
52
- await addSegmentationRepresentations(toolGroupId, [
52
+ await addRepresentations(viewportId, [
53
53
  {
54
54
  segmentationId,
55
55
  type: SegmentationRepresentations.Labelmap,
56
56
  },
57
57
  ]);
58
- triggerSegmentationRender(toolGroupId);
58
+ triggerSegmentationRender(viewportId);
59
59
  eventTarget.addEventListenerOnce(Events.SEGMENTATION_RENDERED, () => triggerSegmentationDataModified(segmentationId));
60
60
  }
61
61
  export { convertStackToVolumeSegmentation, computeVolumeSegmentationFromStack };
@@ -6,14 +6,14 @@ export declare function computeStackSegmentationFromVolume({ volumeId, }: {
6
6
  export declare function convertVolumeToStackSegmentation({ segmentationId, options, }: {
7
7
  segmentationId: string;
8
8
  options?: {
9
- toolGroupId: string;
9
+ viewportId: string;
10
10
  newSegmentationId?: string;
11
11
  removeOriginal?: boolean;
12
12
  };
13
13
  }): Promise<void>;
14
- export declare function updateStackSegmentationState({ segmentationId, toolGroupId, imageIdReferenceMap, options, }: {
14
+ export declare function updateStackSegmentationState({ segmentationId, viewportId, imageIdReferenceMap, options, }: {
15
15
  segmentationId: string;
16
- toolGroupId: string;
16
+ viewportId: string;
17
17
  imageIdReferenceMap: Map<any, any>;
18
18
  options?: {
19
19
  removeOriginal?: boolean;
@@ -1,6 +1,6 @@
1
1
  import { cache, eventTarget, getRenderingEngines, } from '@cornerstonejs/core';
2
2
  import { Events, SegmentationRepresentations } from '../../enums';
3
- import addSegmentationRepresentations from './addSegmentationRepresentations';
3
+ import addRepresentations from './addRepresentations';
4
4
  import { triggerSegmentationRender, createImageIdReferenceMap, } from '../../utilities/segmentation';
5
5
  import { getSegmentation } from './segmentationState';
6
6
  import { triggerSegmentationDataModified } from './triggerSegmentationEvents';
@@ -28,12 +28,12 @@ export async function convertVolumeToStackSegmentation({ segmentationId, options
28
28
  });
29
29
  await updateStackSegmentationState({
30
30
  segmentationId,
31
- toolGroupId: options.toolGroupId,
31
+ viewportId: options.viewportId,
32
32
  imageIdReferenceMap,
33
33
  options,
34
34
  });
35
35
  }
36
- export async function updateStackSegmentationState({ segmentationId, toolGroupId, imageIdReferenceMap, options, }) {
36
+ export async function updateStackSegmentationState({ segmentationId, viewportId, imageIdReferenceMap, options, }) {
37
37
  const segmentation = getSegmentation(segmentationId);
38
38
  if (options?.removeOriginal) {
39
39
  const data = segmentation.representationData
@@ -51,13 +51,13 @@ export async function updateStackSegmentationState({ segmentationId, toolGroupId
51
51
  imageIdReferenceMap,
52
52
  };
53
53
  }
54
- await addSegmentationRepresentations(toolGroupId, [
54
+ await addRepresentations(viewportId, [
55
55
  {
56
56
  segmentationId,
57
57
  type: SegmentationRepresentations.Labelmap,
58
58
  },
59
59
  ]);
60
- triggerSegmentationRender(toolGroupId);
60
+ triggerSegmentationRender();
61
61
  eventTarget.addEventListenerOnce(Events.SEGMENTATION_RENDERED, () => triggerSegmentationDataModified(segmentationId));
62
62
  }
63
63
  function _getImageIdReferenceMapForStackSegmentation(segmentationVolume) {
@@ -0,0 +1,2 @@
1
+ import { RepresentationPublicInput } from '../../../types';
2
+ export declare function getRepresentationRenderingConfig(representationInput: RepresentationPublicInput): {};
@@ -1,6 +1,6 @@
1
1
  import SegmentationRepresentations from '../../../enums/SegmentationRepresentations';
2
2
  import { getRepresentationRenderingConfig as getLabelmapRenderingConfig } from '../../../tools/displayTools/Labelmap/labelmapDisplay';
3
- export function getRepresentationSpecificConfig(representationInput) {
3
+ export function getRepresentationRenderingConfig(representationInput) {
4
4
  const { type } = representationInput;
5
5
  if (type === SegmentationRepresentations.Labelmap) {
6
6
  return getLabelmapRenderingConfig();
@@ -1,6 +1,6 @@
1
- import removeSegmentationsFromToolGroup from './removeSegmentationsFromToolGroup';
1
+ import removeRepresentationsFromViewport from './removeRepresentationsFromViewport';
2
2
  import addSegmentations from './addSegmentations';
3
- import addSegmentationRepresentations from './addSegmentationRepresentations';
3
+ import addRepresentations from './addRepresentations';
4
4
  import addRepresentationData from './addRepresentationData';
5
5
  import { convertStackToVolumeSegmentation } from './convertStackToVolumeSegmentation';
6
6
  import { convertVolumeToStackSegmentation } from './convertVolumeToStackSegmentation';
@@ -11,4 +11,4 @@ import * as config from './config';
11
11
  import * as segmentIndex from './segmentIndex';
12
12
  import * as triggerSegmentationEvents from './triggerSegmentationEvents';
13
13
  import * as polySegManager from './polySeg';
14
- export { addSegmentations, addSegmentationRepresentations, removeSegmentationsFromToolGroup, addRepresentationData, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, convertStackToVolumeSegmentation, convertVolumeToStackSegmentation, polySegManager as polySeg, };
14
+ export { addSegmentations, addRepresentations, removeRepresentationsFromViewport, addRepresentationData, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, convertStackToVolumeSegmentation, convertVolumeToStackSegmentation, polySegManager as polySeg, };
@@ -1,6 +1,6 @@
1
- import removeSegmentationsFromToolGroup from './removeSegmentationsFromToolGroup';
1
+ import removeRepresentationsFromViewport from './removeRepresentationsFromViewport';
2
2
  import addSegmentations from './addSegmentations';
3
- import addSegmentationRepresentations from './addSegmentationRepresentations';
3
+ import addRepresentations from './addRepresentations';
4
4
  import addRepresentationData from './addRepresentationData';
5
5
  import { convertStackToVolumeSegmentation } from './convertStackToVolumeSegmentation';
6
6
  import { convertVolumeToStackSegmentation } from './convertVolumeToStackSegmentation';
@@ -11,4 +11,4 @@ import * as config from './config';
11
11
  import * as segmentIndex from './segmentIndex';
12
12
  import * as triggerSegmentationEvents from './triggerSegmentationEvents';
13
13
  import * as polySegManager from './polySeg';
14
- export { addSegmentations, addSegmentationRepresentations, removeSegmentationsFromToolGroup, addRepresentationData, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, convertStackToVolumeSegmentation, convertVolumeToStackSegmentation, polySegManager as polySeg, };
14
+ export { addSegmentations, addRepresentations, removeRepresentationsFromViewport, addRepresentationData, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, convertStackToVolumeSegmentation, convertVolumeToStackSegmentation, polySegManager as polySeg, };
@@ -1,11 +1,10 @@
1
1
  import { cache } from '@cornerstonejs/core';
2
2
  import { getUniqueSegmentIndices } from '../../../../utilities/segmentation';
3
- import { getSegmentation, setSegmentationRepresentationSpecificConfig, } from '../../segmentationState';
3
+ import { getSegmentation, setAllSegmentsConfig } from '../../segmentationState';
4
4
  import { computeSurfaceFromLabelmapSegmentation } from '../Surface/surfaceComputationStrategies';
5
5
  import { clipAndCacheSurfacesForViewport, } from '../../helpers/clipAndCacheSurfacesForViewport';
6
6
  import { extractContourData } from './utils/extractContourData';
7
7
  import { createAndAddContourSegmentationsFromClippedSurfaces } from './utils/createAndAddContourSegmentationsFromClippedSurfaces';
8
- import { getToolGroupForViewport } from '../../../../store/ToolGroupManager';
9
8
  export async function computeContourData(segmentationId, options = {}) {
10
9
  const segmentIndices = options.segmentIndices?.length
11
10
  ? options.segmentIndices
@@ -36,8 +35,7 @@ export async function computeContourData(segmentationId, options = {}) {
36
35
  }
37
36
  const { viewport, segmentationRepresentationUID } = options;
38
37
  const annotationUIDsMap = createAndAddContourSegmentationsFromClippedSurfaces(rawContourData, viewport, segmentationId);
39
- const toolGroupId = getToolGroupForViewport(viewport.id)?.id;
40
- setSegmentationRepresentationSpecificConfig(toolGroupId, segmentationRepresentationUID, {
38
+ setAllSegmentsConfig(segmentationRepresentationUID, {
41
39
  CONTOUR: {
42
40
  fillAlpha: 0,
43
41
  },
@@ -1,11 +1,10 @@
1
1
  import { Enums, geometryLoader } from '@cornerstonejs/core';
2
- import { getColorForSegmentIndex } from '../../config/segmentationColor';
3
- import { findSegmentationRepresentationByUID, getSegmentation, } from '../../segmentationState';
2
+ import { getSegmentIndexColor } from '../../config/segmentationColor';
3
+ import { getRepresentation, getSegmentation } from '../../segmentationState';
4
4
  export async function createAndCacheSurfacesFromRaw(segmentationId, rawSurfacesData, options = {}) {
5
- let segmentationRepresentation, toolGroupId;
5
+ let segmentationRepresentation;
6
6
  if (options.segmentationRepresentationUID) {
7
- ({ segmentationRepresentation, toolGroupId } =
8
- findSegmentationRepresentationByUID(options.segmentationRepresentationUID));
7
+ segmentationRepresentation = getRepresentation(options.segmentationRepresentationUID);
9
8
  }
10
9
  const segmentation = getSegmentation(segmentationId);
11
10
  const geometryIds = new Map();
@@ -13,7 +12,7 @@ export async function createAndCacheSurfacesFromRaw(segmentationId, rawSurfacesD
13
12
  const rawSurfaceData = rawSurfacesData[index];
14
13
  const segmentIndex = rawSurfaceData.segmentIndex;
15
14
  const color = segmentationRepresentation;
16
- getColorForSegmentIndex(toolGroupId, segmentationRepresentation.segmentationRepresentationUID, segmentIndex).slice(0, 3);
15
+ getSegmentIndexColor(segmentationRepresentation.segmentationRepresentationUID, segmentIndex).slice(0, 3);
17
16
  if (!color) {
18
17
  throw new Error('No color found for segment index, unable to create surface');
19
18
  }
@@ -1,6 +1,6 @@
1
1
  import { cache } from '@cornerstonejs/core';
2
2
  import { getUniqueSegmentIndices } from '../../../../utilities/segmentation';
3
- import { getSegmentation, getSegmentationRepresentations, getToolGroupIdsWithSegmentation, } from '../../segmentationState';
3
+ import { getSegmentation, getRepresentationsForViewport, getViewportIdsWithSegmentationId, } from '../../segmentationState';
4
4
  import { triggerSegmentationModified } from '../../triggerSegmentationEvents';
5
5
  import { SegmentationRepresentations } from '../../../../enums';
6
6
  import { computeSurfaceFromLabelmapSegmentation } from './surfaceComputationStrategies';
@@ -27,9 +27,9 @@ export async function updateSurfaceData(segmentationId) {
27
27
  const geometryId = `segmentation_${segmentationId}_surface_${segmentIndex}`;
28
28
  const geometry = cache.getGeometry(geometryId);
29
29
  if (!geometry) {
30
- const toolGroupIds = getToolGroupIdsWithSegmentation(segmentationId);
31
- return toolGroupIds.map((toolGroupId) => {
32
- const segmentationRepresentations = getSegmentationRepresentations(toolGroupId);
30
+ const viewportIds = getViewportIdsWithSegmentationId(segmentationId);
31
+ return viewportIds.map((viewportId) => {
32
+ const segmentationRepresentations = getRepresentationsForViewport(viewportId);
33
33
  return segmentationRepresentations.map((segmentationRepresentation) => {
34
34
  if (segmentationRepresentation.type !==
35
35
  SegmentationRepresentations.Surface) {