@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,20 +1,21 @@
1
- import { cache, getEnabledElementByIds, VolumeViewport3D, } from '@cornerstonejs/core';
1
+ import { cache, getEnabledElementByViewportId, VolumeViewport3D, } from '@cornerstonejs/core';
2
2
  import * as SegmentationState from '../../../stateManagement/segmentation/segmentationState';
3
3
  import Representations from '../../../enums/SegmentationRepresentations';
4
- import { getToolGroup } from '../../../store/ToolGroupManager';
5
4
  import removeSurfaceFromElement from './removeSurfaceFromElement';
6
5
  import addOrUpdateSurfaceToElement from './addOrUpdateSurfaceToElement';
7
6
  import { polySeg } from '../../../stateManagement/segmentation';
8
- function removeSegmentationRepresentation(toolGroupId, segmentationRepresentationUID, renderImmediate = false) {
9
- _removeSurfaceFromToolGroupViewports(toolGroupId, segmentationRepresentationUID);
10
- SegmentationState.removeSegmentationRepresentation(toolGroupId, segmentationRepresentationUID);
11
- if (renderImmediate) {
12
- const viewportsInfo = getToolGroup(toolGroupId).getViewportsInfo();
13
- viewportsInfo.forEach(({ viewportId, renderingEngineId }) => {
14
- const enabledElement = getEnabledElementByIds(viewportId, renderingEngineId);
15
- enabledElement.viewport.render();
16
- });
7
+ function removeRepresentation(viewportId, segmentationRepresentationUID, renderImmediate = false) {
8
+ const enabledElement = getEnabledElementByViewportId(viewportId);
9
+ if (!enabledElement) {
10
+ return;
11
+ }
12
+ const { viewport } = enabledElement;
13
+ removeSurfaceFromElement(viewport.element, segmentationRepresentationUID);
14
+ SegmentationState.removeRepresentation(segmentationRepresentationUID);
15
+ if (!renderImmediate) {
16
+ return;
17
17
  }
18
+ viewport.render();
18
19
  }
19
20
  async function render(viewport, representation) {
20
21
  const { colorLUTIndex, segmentationId, segmentationRepresentationUID } = representation;
@@ -55,20 +56,8 @@ async function render(viewport, representation) {
55
56
  });
56
57
  viewport.render();
57
58
  }
58
- function _removeSurfaceFromToolGroupViewports(toolGroupId, segmentationRepresentationUID) {
59
- const toolGroup = getToolGroup(toolGroupId);
60
- if (toolGroup === undefined) {
61
- throw new Error(`ToolGroup with ToolGroupId ${toolGroupId} does not exist`);
62
- }
63
- const { viewportsInfo } = toolGroup;
64
- for (const viewportInfo of viewportsInfo) {
65
- const { viewportId, renderingEngineId } = viewportInfo;
66
- const enabledElement = getEnabledElementByIds(viewportId, renderingEngineId);
67
- removeSurfaceFromElement(enabledElement.viewport.element, segmentationRepresentationUID);
68
- }
69
- }
70
59
  export default {
71
60
  render,
72
- removeSegmentationRepresentation,
61
+ removeRepresentation,
73
62
  };
74
- export { render, removeSegmentationRepresentation };
63
+ export { render, removeRepresentation };
@@ -38,7 +38,6 @@ import CobbAngleTool from './annotation/CobbAngleTool';
38
38
  import UltrasoundDirectionalTool from './annotation/UltrasoundDirectionalTool';
39
39
  import KeyImageTool from './annotation/KeyImageTool';
40
40
  import AnnotationEraserTool from './AnnotationEraserTool';
41
- import SegmentationDisplayTool from './displayTools/SegmentationDisplayTool';
42
41
  import RectangleScissorsTool from './segmentation/RectangleScissorsTool';
43
42
  import CircleScissorsTool from './segmentation/CircleScissorsTool';
44
43
  import SphereScissorsTool from './segmentation/SphereScissorsTool';
@@ -49,4 +48,4 @@ import BrushTool from './segmentation/BrushTool';
49
48
  import PaintFillTool from './segmentation/PaintFillTool';
50
49
  import OrientationMarkerTool from './OrientationMarkerTool';
51
50
  import SegmentSelectTool from './segmentation/SegmentSelectTool';
52
- export { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, StackScrollMouseWheelTool, ZoomTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LengthTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, AnnotationEraserTool as EraserTool, SegmentationDisplayTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, ReferenceLines, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, SculptorTool, SegmentSelectTool, };
51
+ export { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, StackScrollMouseWheelTool, ZoomTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LengthTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, AnnotationEraserTool as EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, ReferenceLines, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, SculptorTool, SegmentSelectTool, };
@@ -38,7 +38,6 @@ import CobbAngleTool from './annotation/CobbAngleTool';
38
38
  import UltrasoundDirectionalTool from './annotation/UltrasoundDirectionalTool';
39
39
  import KeyImageTool from './annotation/KeyImageTool';
40
40
  import AnnotationEraserTool from './AnnotationEraserTool';
41
- import SegmentationDisplayTool from './displayTools/SegmentationDisplayTool';
42
41
  import RectangleScissorsTool from './segmentation/RectangleScissorsTool';
43
42
  import CircleScissorsTool from './segmentation/CircleScissorsTool';
44
43
  import SphereScissorsTool from './segmentation/SphereScissorsTool';
@@ -49,4 +48,4 @@ import BrushTool from './segmentation/BrushTool';
49
48
  import PaintFillTool from './segmentation/PaintFillTool';
50
49
  import OrientationMarkerTool from './OrientationMarkerTool';
51
50
  import SegmentSelectTool from './segmentation/SegmentSelectTool';
52
- export { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, StackScrollMouseWheelTool, ZoomTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LengthTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, AnnotationEraserTool as EraserTool, SegmentationDisplayTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, ReferenceLines, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, SculptorTool, SegmentSelectTool, };
51
+ export { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, StackScrollMouseWheelTool, ZoomTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LengthTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, AnnotationEraserTool as EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, ReferenceLines, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, SculptorTool, SegmentSelectTool, };
@@ -23,12 +23,10 @@ declare class BrushTool extends BaseTool {
23
23
  volumeId: string;
24
24
  referencedVolumeId: any;
25
25
  segmentsLocked: number[] | [];
26
- segmentationRepresentationUID: string;
27
26
  imageIdReferenceMap?: undefined;
28
27
  } | {
29
28
  imageIdReferenceMap: Map<string, string>;
30
29
  segmentsLocked: number[] | [];
31
- segmentationRepresentationUID: string;
32
30
  volumeId?: undefined;
33
31
  referencedVolumeId?: undefined;
34
32
  };
@@ -69,6 +67,21 @@ declare class BrushTool extends BaseTool {
69
67
  referencedVolumeId: any;
70
68
  segmentsLocked: number[] | [];
71
69
  imageIdReferenceMap?: undefined;
70
+ } | {
71
+ points: any;
72
+ segmentIndex: number;
73
+ previewColors: any;
74
+ viewPlaneNormal: any;
75
+ toolGroupId: string;
76
+ segmentationId: string;
77
+ segmentationRepresentationUID: string;
78
+ viewUp: any;
79
+ strategySpecificConfiguration: any;
80
+ preview: unknown;
81
+ imageIdReferenceMap: Map<string, string>;
82
+ segmentsLocked: number[] | [];
83
+ volumeId?: undefined;
84
+ referencedVolumeId?: undefined;
72
85
  };
73
86
  private _calculateCursor;
74
87
  private _endCallback;
@@ -190,12 +190,11 @@ class BrushTool extends BaseTool {
190
190
  createEditData(element) {
191
191
  const enabledElement = getEnabledElement(element);
192
192
  const { viewport } = enabledElement;
193
- const toolGroupId = this.toolGroupId;
194
- const activeSegmentationRepresentation = activeSegmentation.getActiveSegmentationRepresentation(toolGroupId);
195
- if (!activeSegmentationRepresentation) {
193
+ const activeRepresentation = activeSegmentation.getActiveRepresentation(viewport.id);
194
+ if (!activeRepresentation) {
196
195
  throw new Error('No active segmentation detected, create a segmentation representation before using the brush tool');
197
196
  }
198
- const { segmentationId, type, segmentationRepresentationUID } = activeSegmentationRepresentation;
197
+ const { segmentationId, type } = activeRepresentation;
199
198
  if (type === SegmentationRepresentations.Contour) {
200
199
  throw new Error('Not implemented yet');
201
200
  }
@@ -224,7 +223,6 @@ class BrushTool extends BaseTool {
224
223
  volumeId,
225
224
  referencedVolumeId: this.configuration.thresholdVolumeId ?? referencedVolumeIdToThreshold,
226
225
  segmentsLocked,
227
- segmentationRepresentationUID,
228
226
  };
229
227
  }
230
228
  else {
@@ -239,7 +237,6 @@ class BrushTool extends BaseTool {
239
237
  return {
240
238
  imageIdReferenceMap,
241
239
  segmentsLocked,
242
- segmentationRepresentationUID,
243
240
  };
244
241
  }
245
242
  }
@@ -249,7 +246,7 @@ class BrushTool extends BaseTool {
249
246
  const camera = viewport.getCamera();
250
247
  const { viewPlaneNormal, viewUp } = camera;
251
248
  const viewportIdsToRender = [viewport.id];
252
- const { segmentIndex, segmentationId, segmentationRepresentationUID, segmentColor, } = this.getActiveSegmentationData() || {};
249
+ const { segmentIndex, segmentationId, segmentationRepresentationUID, segmentColor, } = this.getActiveSegmentationData(viewport) || {};
253
250
  const brushCursor = {
254
251
  metadata: {
255
252
  viewPlaneNormal: [...viewPlaneNormal],
@@ -265,22 +262,23 @@ class BrushTool extends BaseTool {
265
262
  brushCursor,
266
263
  centerCanvas,
267
264
  segmentIndex,
265
+ viewport,
268
266
  segmentationId,
269
267
  segmentationRepresentationUID,
270
268
  segmentColor,
271
269
  viewportIdsToRender,
272
270
  };
273
271
  }
274
- getActiveSegmentationData() {
275
- const toolGroupId = this.toolGroupId;
276
- const activeSegmentationRepresentation = activeSegmentation.getActiveSegmentationRepresentation(toolGroupId);
277
- if (!activeSegmentationRepresentation) {
272
+ getActiveSegmentationData(viewport) {
273
+ const viewportId = viewport.id;
274
+ const activeRepresentation = activeSegmentation.getActiveRepresentation(viewportId);
275
+ if (!activeRepresentation) {
278
276
  console.warn('No active segmentation detected, create one before using the brush tool');
279
277
  return;
280
278
  }
281
- const { segmentationRepresentationUID, segmentationId } = activeSegmentationRepresentation;
279
+ const { segmentationId, segmentationRepresentationUID } = activeRepresentation;
282
280
  const segmentIndex = segmentIndexController.getActiveSegmentIndex(segmentationId);
283
- const segmentColor = segmentationConfig.color.getColorForSegmentIndex(toolGroupId, segmentationRepresentationUID, segmentIndex);
281
+ const segmentColor = segmentationConfig.color.getSegmentIndexColor(segmentationRepresentationUID, segmentIndex);
284
282
  return {
285
283
  segmentIndex,
286
284
  segmentationId,
@@ -393,8 +391,9 @@ class BrushTool extends BaseTool {
393
391
  return;
394
392
  }
395
393
  const { data } = this._hoverData.brushCursor;
394
+ const { viewport } = this._hoverData;
396
395
  data.invalidated = true;
397
- const { segmentColor } = this.getActiveSegmentationData() || {};
396
+ const { segmentColor } = this.getActiveSegmentationData(viewport) || {};
398
397
  this._hoverData.brushCursor.metadata.segmentColor = segmentColor;
399
398
  }
400
399
  renderAnnotation(enabledElement, svgDrawingHelper) {
@@ -31,19 +31,18 @@ class CircleScissorsTool extends BaseTool {
31
31
  const worldPos = currentPoints.world;
32
32
  const canvasPos = currentPoints.canvas;
33
33
  const enabledElement = getEnabledElement(element);
34
- const { viewport, renderingEngine } = enabledElement;
34
+ const { viewport } = enabledElement;
35
35
  this.isDrawing = true;
36
36
  const camera = viewport.getCamera();
37
37
  const { viewPlaneNormal, viewUp } = camera;
38
- const toolGroupId = this.toolGroupId;
39
- const activeSegmentationRepresentation = activeSegmentation.getActiveSegmentationRepresentation(toolGroupId);
38
+ const activeSegmentationRepresentation = activeSegmentation.getActiveRepresentation(viewport.id);
40
39
  if (!activeSegmentationRepresentation) {
41
40
  throw new Error('No active segmentation detected, create one before using scissors tool');
42
41
  }
43
42
  const { segmentationRepresentationUID, segmentationId, type } = activeSegmentationRepresentation;
44
43
  const segmentIndex = segmentIndexController.getActiveSegmentIndex(segmentationId);
45
44
  const segmentsLocked = segmentLocking.getLockedSegments(segmentationId);
46
- const segmentColor = segmentationConfig.color.getColorForSegmentIndex(toolGroupId, segmentationRepresentationUID, segmentIndex);
45
+ const segmentColor = segmentationConfig.color.getSegmentIndexColor(segmentationRepresentationUID, segmentIndex);
47
46
  const { representationData } = getSegmentation(segmentationId);
48
47
  const labelmapData = representationData[type];
49
48
  if (!labelmapData) {
@@ -20,8 +20,7 @@ class PaintFillTool extends BaseTool {
20
20
  const { viewport } = enabledElement;
21
21
  const camera = viewport.getCamera();
22
22
  const { viewPlaneNormal } = camera;
23
- const toolGroupId = this.toolGroupId;
24
- const activeSegmentationRepresentation = activeSegmentation.getActiveSegmentationRepresentation(toolGroupId);
23
+ const activeSegmentationRepresentation = activeSegmentation.getActiveRepresentation(viewport.id);
25
24
  if (!activeSegmentationRepresentation) {
26
25
  throw new Error('No active segmentation detected, create one before using scissors tool');
27
26
  }
@@ -31,19 +31,18 @@ class RectangleScissorsTool extends BaseTool {
31
31
  const { currentPoints, element } = eventDetail;
32
32
  const worldPos = currentPoints.world;
33
33
  const enabledElement = getEnabledElement(element);
34
- const { viewport, renderingEngine } = enabledElement;
34
+ const { viewport } = enabledElement;
35
35
  this.isDrawing = true;
36
36
  const camera = viewport.getCamera();
37
37
  const { viewPlaneNormal, viewUp } = camera;
38
- const toolGroupId = this.toolGroupId;
39
- const activeSegmentationRepresentation = activeSegmentation.getActiveSegmentationRepresentation(toolGroupId);
38
+ const activeSegmentationRepresentation = activeSegmentation.getActiveRepresentation(viewport.id);
40
39
  if (!activeSegmentationRepresentation) {
41
40
  throw new Error('No active segmentation detected, create one before using scissors tool');
42
41
  }
43
42
  const { segmentationRepresentationUID, segmentationId, type } = activeSegmentationRepresentation;
44
43
  const segmentIndex = segmentIndexController.getActiveSegmentIndex(segmentationId);
45
44
  const segmentsLocked = segmentLocking.getLockedSegments(segmentationId);
46
- const segmentColor = segmentationConfig.color.getColorForSegmentIndex(toolGroupId, segmentationRepresentationUID, segmentIndex);
45
+ const segmentColor = segmentationConfig.color.getSegmentIndexColor(segmentationRepresentationUID, segmentIndex);
47
46
  const { representationData } = getSegmentation(segmentationId);
48
47
  const labelmapData = representationData[SegmentationRepresentations.Labelmap];
49
48
  const annotation = {
@@ -1,6 +1,7 @@
1
1
  import type { Types } from '@cornerstonejs/core';
2
2
  import { BaseTool } from '../base';
3
- import { PublicToolProps, ToolProps, EventTypes, ToolGroupSpecificRepresentation } from '../../types';
3
+ import { PublicToolProps, ToolProps, EventTypes } from '../../types';
4
+ import { SegmentationRepresentation } from '../../types/SegmentationStateTypes';
4
5
  declare class SegmentSelectTool extends BaseTool {
5
6
  static toolName: any;
6
7
  private hoverTimer;
@@ -14,6 +15,6 @@ declare class SegmentSelectTool extends BaseTool {
14
15
  onSetToolActive: () => void;
15
16
  onSetToolDisabled: () => void;
16
17
  _setActiveSegment(evt?: EventTypes.InteractionEventType): void;
17
- _setActiveSegmentForType(activeSegmentationReps: ToolGroupSpecificRepresentation, worldPoint: Types.Point3, viewport: Types.IStackViewport | Types.IVolumeViewport): void;
18
+ _setActiveSegmentForType(activeSegmentationReps: SegmentationRepresentation, worldPoint: Types.Point3, viewport: Types.IStackViewport | Types.IVolumeViewport): void;
18
19
  }
19
20
  export default SegmentSelectTool;
@@ -2,10 +2,10 @@ import { getEnabledElement } from '@cornerstonejs/core';
2
2
  import { BaseTool } from '../base';
3
3
  import { triggerSegmentationModified } from '../../stateManagement/segmentation/triggerSegmentationEvents';
4
4
  import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
5
- import { getActiveSegmentationRepresentation } from '../../stateManagement/segmentation/activeSegmentation';
5
+ import { getActiveRepresentation } from '../../stateManagement/segmentation/activeSegmentation';
6
6
  import RepresentationTypes from '../../enums/SegmentationRepresentations';
7
7
  import { setActiveSegmentIndex } from '../../stateManagement/segmentation/segmentIndex';
8
- import { getHoveredContourSegmentationAnnotation, getSegmentAtLabelmapBorder, getSegmentAtWorldPoint, } from '../../utilities/segmentation';
8
+ import { getHoveredContourSegmentationAnnotation, getSegmentIndexAtLabelmapBorder, getSegmentIndexAtWorldPoint, } from '../../utilities/segmentation';
9
9
  import { state } from '../../store';
10
10
  import SegmentationRepresentations from '../../enums/SegmentationRepresentations';
11
11
  class SegmentSelectTool extends BaseTool {
@@ -54,7 +54,7 @@ class SegmentSelectTool extends BaseTool {
54
54
  return;
55
55
  }
56
56
  const { viewport } = enabledElement;
57
- const activeSegmentationReps = getActiveSegmentationRepresentation(this.toolGroupId);
57
+ const activeSegmentationReps = getActiveRepresentation(viewport.id);
58
58
  if (!activeSegmentationReps) {
59
59
  return;
60
60
  }
@@ -77,14 +77,14 @@ class SegmentSelectTool extends BaseTool {
77
77
  const { segmentationId, type } = activeSegmentationReps;
78
78
  let hoveredSegmentIndex;
79
79
  if (this.configuration.mode === SegmentSelectTool.SelectMode.Inside) {
80
- hoveredSegmentIndex = getSegmentAtWorldPoint(segmentationId, worldPoint, {
80
+ hoveredSegmentIndex = getSegmentIndexAtWorldPoint(segmentationId, worldPoint, {
81
81
  viewport,
82
82
  });
83
83
  }
84
84
  else {
85
85
  switch (type) {
86
86
  case SegmentationRepresentations.Labelmap:
87
- hoveredSegmentIndex = getSegmentAtLabelmapBorder(segmentationId, worldPoint, {
87
+ hoveredSegmentIndex = getSegmentIndexAtLabelmapBorder(segmentationId, worldPoint, {
88
88
  viewport,
89
89
  searchRadius: this.configuration.searchRadius,
90
90
  });
@@ -31,19 +31,18 @@ class SphereScissorsTool extends BaseTool {
31
31
  const worldPos = currentPoints.world;
32
32
  const canvasPos = currentPoints.canvas;
33
33
  const enabledElement = getEnabledElement(element);
34
- const { viewport, renderingEngine } = enabledElement;
34
+ const { viewport } = enabledElement;
35
35
  this.isDrawing = true;
36
36
  const camera = viewport.getCamera();
37
37
  const { viewPlaneNormal, viewUp } = camera;
38
- const toolGroupId = this.toolGroupId;
39
- const activeSegmentationRepresentation = activeSegmentation.getActiveSegmentationRepresentation(toolGroupId);
38
+ const activeSegmentationRepresentation = activeSegmentation.getActiveRepresentation(viewport.id);
40
39
  if (!activeSegmentationRepresentation) {
41
40
  throw new Error('No active segmentation detected, create one before using scissors tool');
42
41
  }
43
42
  const { segmentationRepresentationUID, segmentationId } = activeSegmentationRepresentation;
44
43
  const segmentIndex = segmentIndexController.getActiveSegmentIndex(segmentationId);
45
44
  const segmentsLocked = segmentLocking.getLockedSegments(segmentationId);
46
- const segmentColor = segmentationConfig.color.getColorForSegmentIndex(toolGroupId, segmentationRepresentationUID, segmentIndex);
45
+ const segmentColor = segmentationConfig.color.getSegmentIndexColor(segmentationRepresentationUID, segmentIndex);
47
46
  this.isDrawing = true;
48
47
  const annotation = {
49
48
  metadata: {
@@ -73,7 +72,7 @@ class SphereScissorsTool extends BaseTool {
73
72
  segmentationId,
74
73
  segmentsLocked,
75
74
  segmentColor,
76
- toolGroupId,
75
+ toolGroupId: this.toolGroupId,
77
76
  viewportIdsToRender,
78
77
  handleIndex: 3,
79
78
  movingTextBox: false,
@@ -42,12 +42,12 @@ export default {
42
42
  return;
43
43
  }
44
44
  const configColor = previewColors?.[segmentIndex];
45
- const segmentColor = segmentationConfig.color.getColorForSegmentIndex(toolGroupId, segmentationRepresentationUID, segmentIndex);
45
+ const segmentColor = segmentationConfig.color.getSegmentIndexColor(segmentationRepresentationUID, segmentIndex);
46
46
  if (!configColor && !segmentColor) {
47
47
  return;
48
48
  }
49
49
  const previewColor = configColor || lightenColor(...segmentColor);
50
- segmentationConfig.color.setColorForSegmentIndex(toolGroupId, segmentationRepresentationUID, previewSegmentIndex, previewColor);
50
+ segmentationConfig.color.setSegmentIndexColor(segmentationRepresentationUID, previewSegmentIndex, previewColor);
51
51
  },
52
52
  [StrategyCallbacks.AcceptPreview]: (operationData) => {
53
53
  const { segmentationVoxelManager: segmentationVoxelManager, previewVoxelManager: previewVoxelManager, previewSegmentIndex, preview, } = operationData || {};
@@ -111,17 +111,14 @@ type SegmentationDataModifiedEventDetail = {
111
111
  };
112
112
  type SegmentationRenderedEventDetail = {
113
113
  viewportId: string;
114
- toolGroupId: string;
115
114
  };
116
115
  type SegmentationRepresentationModifiedEventDetail = {
117
- toolGroupId: string;
118
116
  segmentationRepresentationUID: string;
119
117
  };
120
118
  type SegmentationRemovedEventDetail = {
121
119
  segmentationId: string;
122
120
  };
123
121
  type SegmentationRepresentationRemovedEventDetail = {
124
- toolGroupId: string;
125
122
  segmentationRepresentationUID: string;
126
123
  };
127
124
  type SegmentationModifiedEventDetail = {
@@ -3,7 +3,7 @@ import * as Enums from '../enums';
3
3
  import { ContourConfig, ContourRenderingConfig, ContourSegmentationData } from './ContourTypes';
4
4
  import type { LabelmapConfig, LabelmapRenderingConfig, LabelmapSegmentationData } from './LabelmapTypes';
5
5
  import { SurfaceSegmentationData, SurfaceRenderingConfig } from './SurfaceTypes';
6
- export type SegmentSpecificRepresentationConfig = {
6
+ export type SegmentRepresentationConfig = {
7
7
  [key: number | string]: RepresentationConfig;
8
8
  };
9
9
  export type RepresentationConfig = {
@@ -12,7 +12,7 @@ export type RepresentationConfig = {
12
12
  SURFACE?: any;
13
13
  };
14
14
  export type SegmentationRepresentationConfig = {
15
- renderInactiveSegmentations: boolean;
15
+ renderInactiveRepresentations: boolean;
16
16
  representations: RepresentationConfig;
17
17
  };
18
18
  export type SegmentationRepresentationData = {
@@ -34,43 +34,44 @@ export type Segmentation = {
34
34
  };
35
35
  representationData: SegmentationRepresentationData;
36
36
  };
37
- export type ToolGroupSpecificRepresentationState = {
37
+ export type BaseSegmentationRepresentation = {
38
38
  segmentationRepresentationUID: string;
39
39
  segmentationId: string;
40
40
  type: Enums.SegmentationRepresentations;
41
- active: boolean;
42
- segmentsHidden: Set<number>;
43
41
  colorLUTIndex: number;
44
42
  polySeg?: {
45
43
  enabled: boolean;
46
44
  options?: any;
47
45
  };
46
+ config: {
47
+ allSegments?: RepresentationConfig;
48
+ perSegment?: SegmentRepresentationConfig;
49
+ };
48
50
  };
49
- export type ToolGroupSpecificLabelmapRepresentation = ToolGroupSpecificRepresentationState & {
50
- config: LabelmapRenderingConfig;
51
- segmentationRepresentationSpecificConfig?: RepresentationConfig;
52
- segmentSpecificConfig?: SegmentSpecificRepresentationConfig;
51
+ export type LabelmapRepresentation = BaseSegmentationRepresentation & {
52
+ rendering: LabelmapRenderingConfig;
53
53
  };
54
- export type ToolGroupSpecificContourRepresentation = ToolGroupSpecificRepresentationState & {
55
- config: ContourRenderingConfig;
56
- segmentationRepresentationSpecificConfig?: RepresentationConfig;
57
- segmentSpecificConfig?: SegmentSpecificRepresentationConfig;
54
+ export type ContourRepresentation = BaseSegmentationRepresentation & {
55
+ rendering: ContourRenderingConfig;
58
56
  };
59
- export type ToolGroupSpecificSurfaceRepresentation = ToolGroupSpecificRepresentationState & {
60
- config: SurfaceRenderingConfig;
61
- segmentationRepresentationSpecificConfig?: RepresentationConfig;
62
- segmentSpecificConfig?: SegmentSpecificRepresentationConfig;
57
+ export type SurfaceRepresentation = BaseSegmentationRepresentation & {
58
+ rendering: SurfaceRenderingConfig;
63
59
  };
64
- export type ToolGroupSpecificRepresentation = ToolGroupSpecificLabelmapRepresentation | ToolGroupSpecificContourRepresentation;
65
- export type ToolGroupSpecificRepresentations = Array<ToolGroupSpecificRepresentation>;
60
+ export type SegmentationRepresentation = LabelmapRepresentation | ContourRepresentation | SurfaceRepresentation;
66
61
  export type SegmentationState = {
67
62
  colorLUT: Types.ColorLUT[];
68
63
  segmentations: Segmentation[];
69
64
  globalConfig: SegmentationRepresentationConfig;
70
- toolGroups: {
71
- [key: string]: {
72
- segmentationRepresentations: ToolGroupSpecificRepresentations;
73
- config: SegmentationRepresentationConfig;
65
+ representations: {
66
+ [key: string]: SegmentationRepresentation;
67
+ };
68
+ viewports: {
69
+ [viewportId: string]: {
70
+ [segRepresentationUID: string]: {
71
+ visible: boolean;
72
+ active: boolean;
73
+ segmentsHidden: Set<number>;
74
+ };
74
75
  };
75
76
  };
76
77
  };
@@ -22,7 +22,7 @@ import type ScrollOptions from './ScrollOptions';
22
22
  import type BoundsIJK from './BoundsIJK';
23
23
  import type SVGDrawingHelper from './SVGDrawingHelper';
24
24
  import type * as CINETypes from './CINETypes';
25
- import type { RepresentationConfig, SegmentationRepresentationConfig, SegmentationRepresentationData, Segmentation, ToolGroupSpecificRepresentationState, ToolGroupSpecificContourRepresentation, ToolGroupSpecificLabelmapRepresentation, ToolGroupSpecificRepresentation, SegmentationState, RepresentationPublicInput } from './SegmentationStateTypes';
25
+ import type { RepresentationConfig, SegmentationRepresentationConfig, SegmentationRepresentationData, Segmentation, SegmentationState, RepresentationPublicInput } from './SegmentationStateTypes';
26
26
  import { ISculptToolShape } from './ISculptToolShape';
27
27
  import type ISynchronizerEventHandler from './ISynchronizerEventHandler';
28
28
  import type { FloodFillGetter, FloodFillOptions, FloodFillResult } from './FloodFillTypes';
@@ -46,4 +46,4 @@ import type { SplineLineSegment } from './SplineLineSegment';
46
46
  import type { SplineProps } from './SplineProps';
47
47
  import type { BidirectionalData } from '../utilities/segmentation/createBidirectionalToolData';
48
48
  import type { PolySegConversionOptions } from './PolySeg';
49
- export type { Annotation, Annotations, ContourAnnotationData, ContourAnnotation, ContourSegmentationAnnotationData, ContourSegmentationAnnotation, BidirectionalData, CanvasCoordinates, IAnnotationManager, InterpolationViewportData, ImageInterpolationData, GroupSpecificAnnotations, AnnotationState, AnnotationStyle, ToolSpecificAnnotationTypes, JumpToSliceOptions, AnnotationGroupSelector, AnnotationRenderContext, PlanarBoundingBox, ToolProps, PublicToolProps, ToolConfiguration, EventTypes, IPoints, ITouchPoints, IDistance, IToolBinding, SetToolBindingsType, ToolOptionsType, InteractionTypes, ToolAction, IToolGroup, IToolClassReference, ISynchronizerEventHandler, ToolHandle, AnnotationHandle, TextBoxHandle, Segmentation, SegmentationState, SegmentationRepresentationData, SegmentationRepresentationConfig, RepresentationConfig, ToolGroupSpecificRepresentationState, ToolGroupSpecificContourRepresentation, ToolGroupSpecificLabelmapRepresentation, ToolGroupSpecificRepresentation, RepresentationPublicInput, LabelmapTypes, SVGCursorDescriptor, SVGPoint, ScrollOptions, CINETypes, BoundsIJK, SVGDrawingHelper, FloodFillResult, FloodFillGetter, FloodFillOptions, ContourSegmentationData, ISculptToolShape, Statistics, NamedStatistics, LabelmapToolOperationData, LabelmapToolOperationDataStack, LabelmapToolOperationDataVolume, CardinalSplineProps, ClosestControlPoint, ClosestPoint, ClosestSplinePoint, ControlPointInfo, ISpline, SplineCurveSegment, SplineLineSegment, SplineProps, PolySegConversionOptions, };
49
+ export type { Annotation, Annotations, ContourAnnotationData, ContourAnnotation, ContourSegmentationAnnotationData, ContourSegmentationAnnotation, BidirectionalData, CanvasCoordinates, IAnnotationManager, InterpolationViewportData, ImageInterpolationData, GroupSpecificAnnotations, AnnotationState, AnnotationStyle, ToolSpecificAnnotationTypes, JumpToSliceOptions, AnnotationGroupSelector, AnnotationRenderContext, PlanarBoundingBox, ToolProps, PublicToolProps, ToolConfiguration, EventTypes, IPoints, ITouchPoints, IDistance, IToolBinding, SetToolBindingsType, ToolOptionsType, InteractionTypes, ToolAction, IToolGroup, IToolClassReference, ISynchronizerEventHandler, ToolHandle, AnnotationHandle, TextBoxHandle, Segmentation, SegmentationState, SegmentationRepresentationData, SegmentationRepresentationConfig, RepresentationConfig, RepresentationPublicInput, LabelmapTypes, SVGCursorDescriptor, SVGPoint, ScrollOptions, CINETypes, BoundsIJK, SVGDrawingHelper, FloodFillResult, FloodFillGetter, FloodFillOptions, ContourSegmentationData, ISculptToolShape, Statistics, NamedStatistics, LabelmapToolOperationData, LabelmapToolOperationDataStack, LabelmapToolOperationDataVolume, CardinalSplineProps, ClosestControlPoint, ClosestPoint, ClosestSplinePoint, ControlPointInfo, ISpline, SplineCurveSegment, SplineLineSegment, SplineProps, PolySegConversionOptions, };
@@ -0,0 +1,7 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ type Options = {
3
+ viewport?: Types.IViewport;
4
+ searchRadius?: number;
5
+ };
6
+ export declare function getSegmentIndexAtLabelmapBorder(segmentationId: string, worldPoint: Types.Point3, { viewport, searchRadius }: Options): number;
7
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { cache, utilities } from '@cornerstonejs/core';
2
- import { getSegmentation, getSegmentationIdRepresentations, } from '../../stateManagement/segmentation/segmentationState';
2
+ import { getSegmentation, getRepresentationsBySegmentationId, } from '../../stateManagement/segmentation/segmentationState';
3
3
  import { isVolumeSegmentation } from '../../tools/segmentation/strategies/utils/stackVolumeCheck';
4
- export function getSegmentAtLabelmapBorder(segmentationId, worldPoint, { viewport, searchRadius }) {
4
+ export function getSegmentIndexAtLabelmapBorder(segmentationId, worldPoint, { viewport, searchRadius }) {
5
5
  const segmentation = getSegmentation(segmentationId);
6
6
  const labelmapData = segmentation.representationData.LABELMAP;
7
7
  if (isVolumeSegmentation(labelmapData)) {
@@ -23,7 +23,7 @@ export function getSegmentAtLabelmapBorder(segmentationId, worldPoint, { viewpor
23
23
  if (!image) {
24
24
  return;
25
25
  }
26
- const segmentationRepresentations = getSegmentationIdRepresentations(segmentation.segmentationId);
26
+ const segmentationRepresentations = getRepresentationsBySegmentationId(segmentation.segmentationId);
27
27
  const { segmentationRepresentationUID } = segmentationRepresentations[0];
28
28
  const segmentationActor = viewport.getActor(segmentationRepresentationUID);
29
29
  const imageData = segmentationActor?.actor.getMapper().getInputData();
@@ -0,0 +1,11 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ import { SegmentationRepresentations } from '../../enums';
3
+ import { Segmentation } from '../../types';
4
+ type Options = {
5
+ representationType?: SegmentationRepresentations;
6
+ viewport?: Types.IViewport;
7
+ };
8
+ export declare function getSegmentIndexAtWorldPoint(segmentationId: string, worldPoint: Types.Point3, options?: Options): number;
9
+ export declare function getSegmentIndexAtWorldForLabelmap(segmentation: Segmentation, worldPoint: Types.Point3, { viewport }: Options): number | undefined;
10
+ export declare function getSegmentIndexAtWorldForContour(segmentation: Segmentation, worldPoint: Types.Point3, { viewport }: Options): number;
11
+ export {};
@@ -1,10 +1,10 @@
1
1
  import { cache, utilities } from '@cornerstonejs/core';
2
2
  import { SegmentationRepresentations } from '../../enums';
3
- import { getSegmentation, getSegmentationIdRepresentations, } from '../../stateManagement/segmentation/segmentationState';
3
+ import { getSegmentation, getRepresentationsBySegmentationId, } from '../../stateManagement/segmentation/segmentationState';
4
4
  import { isVolumeSegmentation } from '../../tools/segmentation/strategies/utils/stackVolumeCheck';
5
5
  import { getAnnotation } from '../../stateManagement';
6
6
  import { isPointInsidePolyline3D } from '../math/polyline';
7
- export function getSegmentAtWorldPoint(segmentationId, worldPoint, options = {}) {
7
+ export function getSegmentIndexAtWorldPoint(segmentationId, worldPoint, options = {}) {
8
8
  const segmentation = getSegmentation(segmentationId);
9
9
  const representationData = segmentation.representationData;
10
10
  const desiredRepresentation = options?.representationType ?? Object.keys(representationData)[0];
@@ -13,14 +13,14 @@ export function getSegmentAtWorldPoint(segmentationId, worldPoint, options = {})
13
13
  }
14
14
  switch (desiredRepresentation) {
15
15
  case SegmentationRepresentations.Labelmap:
16
- return getSegmentAtWorldForLabelmap(segmentation, worldPoint, options);
16
+ return getSegmentIndexAtWorldForLabelmap(segmentation, worldPoint, options);
17
17
  case SegmentationRepresentations.Contour:
18
- return getSegmentAtWorldForContour(segmentation, worldPoint, options);
18
+ return getSegmentIndexAtWorldForContour(segmentation, worldPoint, options);
19
19
  default:
20
20
  return;
21
21
  }
22
22
  }
23
- export function getSegmentAtWorldForLabelmap(segmentation, worldPoint, { viewport }) {
23
+ export function getSegmentIndexAtWorldForLabelmap(segmentation, worldPoint, { viewport }) {
24
24
  const labelmapData = segmentation.representationData.LABELMAP;
25
25
  if (isVolumeSegmentation(labelmapData)) {
26
26
  const { volumeId } = labelmapData;
@@ -38,7 +38,7 @@ export function getSegmentAtWorldForLabelmap(segmentation, worldPoint, { viewpor
38
38
  if (!image) {
39
39
  return;
40
40
  }
41
- const segmentationRepresentations = getSegmentationIdRepresentations(segmentation.segmentationId);
41
+ const segmentationRepresentations = getRepresentationsBySegmentationId(segmentation.segmentationId);
42
42
  const { segmentationRepresentationUID } = segmentationRepresentations[0];
43
43
  const segmentationActor = viewport.getActor(segmentationRepresentationUID);
44
44
  const imageData = segmentationActor?.actor.getMapper().getInputData();
@@ -49,7 +49,7 @@ export function getSegmentAtWorldForLabelmap(segmentation, worldPoint, { viewpor
49
49
  const segmentIndex = voxelManager.getAtIJKPoint(indexIJK);
50
50
  return segmentIndex;
51
51
  }
52
- export function getSegmentAtWorldForContour(segmentation, worldPoint, { viewport }) {
52
+ export function getSegmentIndexAtWorldForContour(segmentation, worldPoint, { viewport }) {
53
53
  const contourData = segmentation.representationData.CONTOUR;
54
54
  const segmentIndices = Array.from(contourData.annotationUIDsMap.keys());
55
55
  const { viewPlaneNormal } = viewport.getCamera();
@@ -15,8 +15,8 @@ import createBidirectionalToolData from './createBidirectionalToolData';
15
15
  import segmentContourAction from './segmentContourAction';
16
16
  import { invalidateBrushCursor } from './invalidateBrushCursor';
17
17
  import { getUniqueSegmentIndices } from './getUniqueSegmentIndices';
18
- import { getSegmentAtWorldPoint } from './getSegmentAtWorldPoint';
19
- import { getSegmentAtLabelmapBorder } from './getSegmentAtLabelmapBorder';
18
+ import { getSegmentIndexAtWorldPoint } from './getSegmentIndexAtWorldPoint';
19
+ import { getSegmentIndexAtLabelmapBorder } from './getSegmentIndexAtLabelmapBorder';
20
20
  import { getHoveredContourSegmentationAnnotation } from './getHoveredContourSegmentationAnnotation';
21
21
  import { getBrushToolInstances } from './utilities';
22
- export { thresholdVolumeByRange, createMergedLabelmapForIndex, isValidRepresentationConfig, getDefaultRepresentationConfig, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, thresholdSegmentationByRange, createImageIdReferenceMap, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentAtWorldPoint, getSegmentAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, };
22
+ export { thresholdVolumeByRange, createMergedLabelmapForIndex, isValidRepresentationConfig, getDefaultRepresentationConfig, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, thresholdSegmentationByRange, createImageIdReferenceMap, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, };
@@ -15,8 +15,8 @@ import createBidirectionalToolData from './createBidirectionalToolData';
15
15
  import segmentContourAction from './segmentContourAction';
16
16
  import { invalidateBrushCursor } from './invalidateBrushCursor';
17
17
  import { getUniqueSegmentIndices } from './getUniqueSegmentIndices';
18
- import { getSegmentAtWorldPoint } from './getSegmentAtWorldPoint';
19
- import { getSegmentAtLabelmapBorder } from './getSegmentAtLabelmapBorder';
18
+ import { getSegmentIndexAtWorldPoint } from './getSegmentIndexAtWorldPoint';
19
+ import { getSegmentIndexAtLabelmapBorder } from './getSegmentIndexAtLabelmapBorder';
20
20
  import { getHoveredContourSegmentationAnnotation } from './getHoveredContourSegmentationAnnotation';
21
21
  import { getBrushToolInstances } from './utilities';
22
- export { thresholdVolumeByRange, createMergedLabelmapForIndex, isValidRepresentationConfig, getDefaultRepresentationConfig, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, thresholdSegmentationByRange, createImageIdReferenceMap, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentAtWorldPoint, getSegmentAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, };
22
+ export { thresholdVolumeByRange, createMergedLabelmapForIndex, isValidRepresentationConfig, getDefaultRepresentationConfig, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, thresholdSegmentationByRange, createImageIdReferenceMap, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, };