@cornerstonejs/tools 1.32.2 → 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/eventListeners/index.d.ts +2 -2
- package/dist/cjs/eventListeners/index.js +2 -1
- package/dist/cjs/eventListeners/index.js.map +1 -1
- package/dist/cjs/eventListeners/segmentation/imageChangeEventListener.d.ts +5 -0
- package/dist/cjs/eventListeners/segmentation/imageChangeEventListener.js +143 -0
- package/dist/cjs/eventListeners/segmentation/imageChangeEventListener.js.map +1 -0
- package/dist/cjs/eventListeners/segmentation/index.d.ts +2 -1
- package/dist/cjs/eventListeners/segmentation/index.js +3 -1
- package/dist/cjs/eventListeners/segmentation/index.js.map +1 -1
- package/dist/cjs/eventListeners/segmentation/segmentationDataModifiedEventListener.js +31 -5
- package/dist/cjs/eventListeners/segmentation/segmentationDataModifiedEventListener.js.map +1 -1
- package/dist/cjs/store/addEnabledElement.js +1 -0
- package/dist/cjs/store/addEnabledElement.js.map +1 -1
- package/dist/cjs/store/removeEnabledElement.js +2 -0
- package/dist/cjs/store/removeEnabledElement.js.map +1 -1
- package/dist/cjs/tools/StackScrollToolMouseWheelTool.d.ts +1 -0
- package/dist/cjs/tools/StackScrollToolMouseWheelTool.js +2 -0
- package/dist/cjs/tools/StackScrollToolMouseWheelTool.js.map +1 -1
- package/dist/cjs/tools/annotation/CircleROITool.js +3 -1
- package/dist/cjs/tools/annotation/CircleROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/EllipticalROITool.js +1 -1
- package/dist/cjs/tools/annotation/EllipticalROITool.js.map +1 -1
- package/dist/cjs/tools/displayTools/Labelmap/addLabelmapToElement.d.ts +2 -1
- package/dist/cjs/tools/displayTools/Labelmap/addLabelmapToElement.js +23 -10
- package/dist/cjs/tools/displayTools/Labelmap/addLabelmapToElement.js.map +1 -1
- package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.d.ts +1 -1
- package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js +36 -22
- package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
- package/dist/cjs/tools/displayTools/Labelmap/validateRepresentationData.js +6 -5
- package/dist/cjs/tools/displayTools/Labelmap/validateRepresentationData.js.map +1 -1
- package/dist/cjs/tools/segmentation/BrushTool.js +40 -45
- package/dist/cjs/tools/segmentation/BrushTool.js.map +1 -1
- package/dist/cjs/tools/segmentation/CircleScissorsTool.d.ts +4 -2
- package/dist/cjs/tools/segmentation/CircleScissorsTool.js +18 -17
- package/dist/cjs/tools/segmentation/CircleScissorsTool.js.map +1 -1
- package/dist/cjs/tools/segmentation/PaintFillTool.js +28 -5
- package/dist/cjs/tools/segmentation/PaintFillTool.js.map +1 -1
- package/dist/cjs/tools/segmentation/RectangleScissorsTool.d.ts +3 -1
- package/dist/cjs/tools/segmentation/RectangleScissorsTool.js +15 -16
- package/dist/cjs/tools/segmentation/RectangleScissorsTool.js.map +1 -1
- package/dist/cjs/tools/segmentation/SphereScissorsTool.d.ts +4 -2
- package/dist/cjs/tools/segmentation/SphereScissorsTool.js +20 -20
- package/dist/cjs/tools/segmentation/SphereScissorsTool.js.map +1 -1
- package/dist/cjs/tools/segmentation/strategies/eraseCircle.d.ts +2 -10
- package/dist/cjs/tools/segmentation/strategies/eraseCircle.js.map +1 -1
- package/dist/cjs/tools/segmentation/strategies/eraseRectangle.d.ts +4 -8
- package/dist/cjs/tools/segmentation/strategies/eraseRectangle.js +4 -20
- package/dist/cjs/tools/segmentation/strategies/eraseRectangle.js.map +1 -1
- package/dist/cjs/tools/segmentation/strategies/eraseSphere.d.ts +2 -10
- package/dist/cjs/tools/segmentation/strategies/eraseSphere.js.map +1 -1
- package/dist/cjs/tools/segmentation/strategies/fillCircle.d.ts +3 -11
- package/dist/cjs/tools/segmentation/strategies/fillCircle.js +57 -32
- package/dist/cjs/tools/segmentation/strategies/fillCircle.js.map +1 -1
- package/dist/cjs/tools/segmentation/strategies/fillRectangle.d.ts +2 -7
- package/dist/cjs/tools/segmentation/strategies/fillRectangle.js +16 -8
- package/dist/cjs/tools/segmentation/strategies/fillRectangle.js.map +1 -1
- package/dist/cjs/tools/segmentation/strategies/fillSphere.d.ts +2 -10
- package/dist/cjs/tools/segmentation/strategies/fillSphere.js +31 -17
- package/dist/cjs/tools/segmentation/strategies/fillSphere.js.map +1 -1
- package/dist/cjs/tools/segmentation/strategies/utils/getStrategyData.d.ts +9 -0
- package/dist/cjs/tools/segmentation/strategies/utils/getStrategyData.js +43 -0
- package/dist/cjs/tools/segmentation/strategies/utils/getStrategyData.js.map +1 -0
- package/dist/cjs/tools/segmentation/strategies/utils/isWithinThreshold.d.ts +2 -2
- package/dist/cjs/tools/segmentation/strategies/utils/isWithinThreshold.js +2 -2
- package/dist/cjs/tools/segmentation/strategies/utils/isWithinThreshold.js.map +1 -1
- package/dist/cjs/tools/segmentation/strategies/utils/stackVolumeCheck.d.ts +5 -0
- package/dist/cjs/tools/segmentation/strategies/utils/stackVolumeCheck.js +13 -0
- package/dist/cjs/tools/segmentation/strategies/utils/stackVolumeCheck.js.map +1 -0
- package/dist/cjs/types/LabelmapToolOperationData.d.ts +14 -0
- package/dist/cjs/types/LabelmapToolOperationData.js +3 -0
- package/dist/cjs/types/LabelmapToolOperationData.js.map +1 -0
- package/dist/cjs/types/LabelmapTypes.d.ts +5 -1
- package/dist/cjs/types/ScrollOptions.d.ts +1 -0
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/cjs/utilities/math/ellipse/pointInEllipse.d.ts +7 -9
- package/dist/cjs/utilities/math/ellipse/pointInEllipse.js +19 -11
- package/dist/cjs/utilities/math/ellipse/pointInEllipse.js.map +1 -1
- package/dist/cjs/utilities/scroll.d.ts +1 -1
- package/dist/cjs/utilities/scroll.js +5 -4
- package/dist/cjs/utilities/scroll.js.map +1 -1
- package/dist/esm/eventListeners/index.js +2 -2
- package/dist/esm/eventListeners/index.js.map +1 -1
- package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js +115 -0
- package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js.map +1 -0
- package/dist/esm/eventListeners/segmentation/index.js +2 -1
- package/dist/esm/eventListeners/segmentation/index.js.map +1 -1
- package/dist/esm/eventListeners/segmentation/segmentationDataModifiedEventListener.js +32 -6
- package/dist/esm/eventListeners/segmentation/segmentationDataModifiedEventListener.js.map +1 -1
- package/dist/esm/store/addEnabledElement.js +2 -1
- package/dist/esm/store/addEnabledElement.js.map +1 -1
- package/dist/esm/store/removeEnabledElement.js +2 -0
- package/dist/esm/store/removeEnabledElement.js.map +1 -1
- package/dist/esm/tools/StackScrollToolMouseWheelTool.js +2 -0
- package/dist/esm/tools/StackScrollToolMouseWheelTool.js.map +1 -1
- package/dist/esm/tools/annotation/CircleROITool.js +4 -2
- package/dist/esm/tools/annotation/CircleROITool.js.map +1 -1
- package/dist/esm/tools/annotation/EllipticalROITool.js +1 -1
- package/dist/esm/tools/annotation/EllipticalROITool.js.map +1 -1
- package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.js +24 -11
- package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.js.map +1 -1
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +36 -22
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
- package/dist/esm/tools/displayTools/Labelmap/validateRepresentationData.js +6 -5
- package/dist/esm/tools/displayTools/Labelmap/validateRepresentationData.js.map +1 -1
- package/dist/esm/tools/segmentation/BrushTool.js +38 -29
- package/dist/esm/tools/segmentation/BrushTool.js.map +1 -1
- package/dist/esm/tools/segmentation/CircleScissorsTool.js +27 -15
- package/dist/esm/tools/segmentation/CircleScissorsTool.js.map +1 -1
- package/dist/esm/tools/segmentation/PaintFillTool.js +28 -5
- package/dist/esm/tools/segmentation/PaintFillTool.js.map +1 -1
- package/dist/esm/tools/segmentation/RectangleScissorsTool.js +26 -17
- package/dist/esm/tools/segmentation/RectangleScissorsTool.js.map +1 -1
- package/dist/esm/tools/segmentation/SphereScissorsTool.js +28 -17
- package/dist/esm/tools/segmentation/SphereScissorsTool.js.map +1 -1
- package/dist/esm/tools/segmentation/strategies/eraseCircle.js.map +1 -1
- package/dist/esm/tools/segmentation/strategies/eraseRectangle.js +4 -20
- package/dist/esm/tools/segmentation/strategies/eraseRectangle.js.map +1 -1
- package/dist/esm/tools/segmentation/strategies/eraseSphere.js.map +1 -1
- package/dist/esm/tools/segmentation/strategies/fillCircle.js +56 -31
- package/dist/esm/tools/segmentation/strategies/fillCircle.js.map +1 -1
- package/dist/esm/tools/segmentation/strategies/fillRectangle.js +16 -8
- package/dist/esm/tools/segmentation/strategies/fillRectangle.js.map +1 -1
- package/dist/esm/tools/segmentation/strategies/fillSphere.js +32 -18
- package/dist/esm/tools/segmentation/strategies/fillSphere.js.map +1 -1
- package/dist/esm/tools/segmentation/strategies/utils/getStrategyData.js +40 -0
- package/dist/esm/tools/segmentation/strategies/utils/getStrategyData.js.map +1 -0
- package/dist/esm/tools/segmentation/strategies/utils/isWithinThreshold.js +2 -2
- package/dist/esm/tools/segmentation/strategies/utils/isWithinThreshold.js.map +1 -1
- package/dist/esm/tools/segmentation/strategies/utils/stackVolumeCheck.js +9 -0
- package/dist/esm/tools/segmentation/strategies/utils/stackVolumeCheck.js.map +1 -0
- package/dist/esm/types/LabelmapToolOperationData.js +2 -0
- package/dist/esm/types/LabelmapToolOperationData.js.map +1 -0
- package/dist/esm/utilities/math/ellipse/pointInEllipse.js +19 -11
- package/dist/esm/utilities/math/ellipse/pointInEllipse.js.map +1 -1
- package/dist/esm/utilities/scroll.js +5 -4
- package/dist/esm/utilities/scroll.js.map +1 -1
- package/dist/types/eventListeners/index.d.ts +2 -2
- package/dist/types/eventListeners/index.d.ts.map +1 -1
- package/dist/types/eventListeners/segmentation/imageChangeEventListener.d.ts +6 -0
- package/dist/types/eventListeners/segmentation/imageChangeEventListener.d.ts.map +1 -0
- package/dist/types/eventListeners/segmentation/index.d.ts +2 -1
- package/dist/types/eventListeners/segmentation/index.d.ts.map +1 -1
- package/dist/types/eventListeners/segmentation/segmentationDataModifiedEventListener.d.ts.map +1 -1
- package/dist/types/store/addEnabledElement.d.ts.map +1 -1
- package/dist/types/store/removeEnabledElement.d.ts.map +1 -1
- package/dist/types/tools/StackScrollToolMouseWheelTool.d.ts +1 -0
- package/dist/types/tools/StackScrollToolMouseWheelTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/CircleROITool.d.ts.map +1 -1
- package/dist/types/tools/displayTools/Labelmap/addLabelmapToElement.d.ts +2 -1
- package/dist/types/tools/displayTools/Labelmap/addLabelmapToElement.d.ts.map +1 -1
- package/dist/types/tools/displayTools/Labelmap/labelmapDisplay.d.ts +1 -1
- package/dist/types/tools/displayTools/Labelmap/labelmapDisplay.d.ts.map +1 -1
- package/dist/types/tools/displayTools/Labelmap/validateRepresentationData.d.ts.map +1 -1
- package/dist/types/tools/segmentation/BrushTool.d.ts.map +1 -1
- package/dist/types/tools/segmentation/CircleScissorsTool.d.ts +4 -2
- package/dist/types/tools/segmentation/CircleScissorsTool.d.ts.map +1 -1
- package/dist/types/tools/segmentation/PaintFillTool.d.ts.map +1 -1
- package/dist/types/tools/segmentation/RectangleScissorsTool.d.ts +3 -1
- package/dist/types/tools/segmentation/RectangleScissorsTool.d.ts.map +1 -1
- package/dist/types/tools/segmentation/SphereScissorsTool.d.ts +4 -2
- package/dist/types/tools/segmentation/SphereScissorsTool.d.ts.map +1 -1
- package/dist/types/tools/segmentation/strategies/eraseCircle.d.ts +2 -10
- package/dist/types/tools/segmentation/strategies/eraseCircle.d.ts.map +1 -1
- package/dist/types/tools/segmentation/strategies/eraseRectangle.d.ts +4 -8
- package/dist/types/tools/segmentation/strategies/eraseRectangle.d.ts.map +1 -1
- package/dist/types/tools/segmentation/strategies/eraseSphere.d.ts +2 -10
- package/dist/types/tools/segmentation/strategies/eraseSphere.d.ts.map +1 -1
- package/dist/types/tools/segmentation/strategies/fillCircle.d.ts +3 -11
- package/dist/types/tools/segmentation/strategies/fillCircle.d.ts.map +1 -1
- package/dist/types/tools/segmentation/strategies/fillRectangle.d.ts +2 -7
- package/dist/types/tools/segmentation/strategies/fillRectangle.d.ts.map +1 -1
- package/dist/types/tools/segmentation/strategies/fillSphere.d.ts +2 -10
- package/dist/types/tools/segmentation/strategies/fillSphere.d.ts.map +1 -1
- package/dist/types/tools/segmentation/strategies/utils/getStrategyData.d.ts +10 -0
- package/dist/types/tools/segmentation/strategies/utils/getStrategyData.d.ts.map +1 -0
- package/dist/types/tools/segmentation/strategies/utils/isWithinThreshold.d.ts +2 -2
- package/dist/types/tools/segmentation/strategies/utils/isWithinThreshold.d.ts.map +1 -1
- package/dist/types/tools/segmentation/strategies/utils/stackVolumeCheck.d.ts +6 -0
- package/dist/types/tools/segmentation/strategies/utils/stackVolumeCheck.d.ts.map +1 -0
- package/dist/types/types/LabelmapToolOperationData.d.ts +15 -0
- package/dist/types/types/LabelmapToolOperationData.d.ts.map +1 -0
- package/dist/types/types/LabelmapTypes.d.ts +5 -1
- package/dist/types/types/LabelmapTypes.d.ts.map +1 -1
- package/dist/types/types/ScrollOptions.d.ts +1 -0
- package/dist/types/types/ScrollOptions.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/utilities/math/ellipse/pointInEllipse.d.ts +7 -9
- package/dist/types/utilities/math/ellipse/pointInEllipse.d.ts.map +1 -1
- package/dist/types/utilities/scroll.d.ts +1 -1
- package/dist/types/utilities/scroll.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/eventListeners/index.ts +2 -0
- package/src/eventListeners/segmentation/imageChangeEventListener.ts +215 -0
- package/src/eventListeners/segmentation/index.ts +2 -0
- package/src/eventListeners/segmentation/segmentationDataModifiedEventListener.ts +70 -9
- package/src/store/addEnabledElement.ts +2 -0
- package/src/store/removeEnabledElement.ts +3 -0
- package/src/tools/StackScrollToolMouseWheelTool.ts +2 -0
- package/src/tools/annotation/CircleROITool.ts +5 -5
- package/src/tools/annotation/EllipticalROITool.ts +1 -1
- package/src/tools/displayTools/Labelmap/addLabelmapToElement.ts +51 -22
- package/src/tools/displayTools/Labelmap/labelmapDisplay.ts +65 -35
- package/src/tools/displayTools/Labelmap/validateRepresentationData.ts +17 -11
- package/src/tools/segmentation/BrushTool.ts +78 -39
- package/src/tools/segmentation/CircleScissorsTool.ts +46 -29
- package/src/tools/segmentation/PaintFillTool.ts +45 -8
- package/src/tools/segmentation/RectangleScissorsTool.ts +41 -31
- package/src/tools/segmentation/SphereScissorsTool.ts +46 -28
- package/src/tools/segmentation/strategies/eraseCircle.ts +3 -11
- package/src/tools/segmentation/strategies/eraseRectangle.ts +13 -42
- package/src/tools/segmentation/strategies/eraseSphere.ts +2 -10
- package/src/tools/segmentation/strategies/fillCircle.ts +93 -61
- package/src/tools/segmentation/strategies/fillRectangle.ts +31 -22
- package/src/tools/segmentation/strategies/fillSphere.ts +51 -41
- package/src/tools/segmentation/strategies/utils/getStrategyData.ts +58 -0
- package/src/tools/segmentation/strategies/utils/isWithinThreshold.ts +3 -2
- package/src/tools/segmentation/strategies/utils/stackVolumeCheck.ts +33 -0
- package/src/types/LabelmapToolOperationData.ts +27 -0
- package/src/types/LabelmapTypes.ts +16 -1
- package/src/types/ScrollOptions.ts +1 -0
- package/src/types/index.ts +8 -0
- package/src/utilities/math/ellipse/pointInEllipse.ts +43 -22
- package/src/utilities/scroll.ts +7 -4
|
@@ -15,6 +15,7 @@ import { getToolGroup } from '../../../store/ToolGroupManager';
|
|
|
15
15
|
import type {
|
|
16
16
|
LabelmapConfig,
|
|
17
17
|
LabelmapRenderingConfig,
|
|
18
|
+
LabelmapSegmentationData,
|
|
18
19
|
} from '../../../types/LabelmapTypes';
|
|
19
20
|
import {
|
|
20
21
|
RepresentationPublicInput,
|
|
@@ -25,6 +26,7 @@ import {
|
|
|
25
26
|
import addLabelmapToElement from './addLabelmapToElement';
|
|
26
27
|
|
|
27
28
|
import removeLabelmapFromElement from './removeLabelmapFromElement';
|
|
29
|
+
import { isVolumeSegmentation } from '../../segmentation/strategies/utils/stackVolumeCheck';
|
|
28
30
|
|
|
29
31
|
const MAX_NUMBER_COLORS = 255;
|
|
30
32
|
const labelMapConfigCache = new Map();
|
|
@@ -176,7 +178,7 @@ function isSameFrameOfReference(viewport, referencedVolumeId) {
|
|
|
176
178
|
* @param configuration - The configuration object for the labelmap.
|
|
177
179
|
*/
|
|
178
180
|
async function render(
|
|
179
|
-
viewport: Types.IVolumeViewport,
|
|
181
|
+
viewport: Types.IVolumeViewport | Types.IStackViewport,
|
|
180
182
|
representation: ToolGroupSpecificRepresentation,
|
|
181
183
|
toolGroupConfig: SegmentationRepresentationConfig
|
|
182
184
|
): Promise<void> {
|
|
@@ -192,29 +194,50 @@ async function render(
|
|
|
192
194
|
const segmentation = SegmentationState.getSegmentation(segmentationId);
|
|
193
195
|
const labelmapData =
|
|
194
196
|
segmentation.representationData[Representations.Labelmap];
|
|
195
|
-
const { volumeId: labelmapUID } = labelmapData;
|
|
196
197
|
|
|
197
|
-
|
|
198
|
+
let actorEntry = viewport.getActor(segmentationRepresentationUID);
|
|
199
|
+
if (isVolumeSegmentation(labelmapData)) {
|
|
200
|
+
const { volumeId: labelmapUID } = labelmapData;
|
|
198
201
|
|
|
199
|
-
|
|
200
|
-
throw new Error(`No Labelmap found for volumeId: ${labelmapUID}`);
|
|
201
|
-
}
|
|
202
|
+
const labelmap = cache.getVolume(labelmapUID);
|
|
202
203
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
let actorEntry = viewport.getActor(segmentationRepresentationUID);
|
|
204
|
+
if (!labelmap) {
|
|
205
|
+
throw new Error(`No Labelmap found for volumeId: ${labelmapUID}`);
|
|
206
|
+
}
|
|
207
207
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
208
|
+
if (!isSameFrameOfReference(viewport, labelmapData?.referencedVolumeId)) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (!actorEntry) {
|
|
213
|
+
// only add the labelmap to ToolGroup viewports if it is not already added
|
|
214
|
+
await _addLabelmapToViewport(
|
|
215
|
+
viewport,
|
|
216
|
+
labelmapData,
|
|
217
|
+
segmentationRepresentationUID
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
actorEntry = viewport.getActor(segmentationRepresentationUID);
|
|
222
|
+
} else {
|
|
223
|
+
// stack segmentation
|
|
224
|
+
const imageId = viewport.getCurrentImageId();
|
|
225
|
+
const { imageIdReferenceMap } = labelmapData;
|
|
226
|
+
|
|
227
|
+
// if the stack labelmap is not built for the current imageId that is
|
|
228
|
+
// rendered at the viewport then return
|
|
229
|
+
if (!imageIdReferenceMap.has(imageId)) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (!actorEntry) {
|
|
234
|
+
// only add the labelmap to ToolGroup viewports if it is not already added
|
|
235
|
+
await _addLabelmapToViewport(
|
|
236
|
+
viewport,
|
|
237
|
+
labelmapData,
|
|
238
|
+
segmentationRepresentationUID
|
|
239
|
+
);
|
|
240
|
+
}
|
|
218
241
|
|
|
219
242
|
actorEntry = viewport.getActor(segmentationRepresentationUID);
|
|
220
243
|
}
|
|
@@ -264,7 +287,6 @@ function _setLabelmapColorAndOpacity(
|
|
|
264
287
|
// the default color table uses RGB.
|
|
265
288
|
const colorLUT = SegmentationState.getColorLUT(colorLUTIndex);
|
|
266
289
|
const numColors = Math.min(256, colorLUT.length);
|
|
267
|
-
const volumeActor = actorEntry.actor as Types.VolumeActor;
|
|
268
290
|
const { uid: actorUID } = actorEntry;
|
|
269
291
|
|
|
270
292
|
// Note: right now outlineWidth and renderOutline are not configurable
|
|
@@ -327,24 +349,32 @@ function _setLabelmapColorAndOpacity(
|
|
|
327
349
|
}
|
|
328
350
|
}
|
|
329
351
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
ofun.setClamping(false);
|
|
333
|
-
volumeActor.getProperty().setScalarOpacity(0, ofun);
|
|
352
|
+
const actor = actorEntry.actor as Types.Actor;
|
|
334
353
|
|
|
335
|
-
|
|
354
|
+
// @ts-ignore
|
|
355
|
+
actor.getProperty().setRGBTransferFunction(0, cfun);
|
|
336
356
|
|
|
337
|
-
|
|
357
|
+
ofun.setClamping(false);
|
|
338
358
|
|
|
339
|
-
// @ts-ignore
|
|
340
|
-
|
|
341
|
-
|
|
359
|
+
// @ts-ignore
|
|
360
|
+
actor.getProperty().setScalarOpacity(0, ofun);
|
|
361
|
+
// @ts-ignore
|
|
362
|
+
actor.getProperty().setInterpolationTypeToNearest();
|
|
363
|
+
|
|
364
|
+
if (utilities.actorIsA(actorEntry, 'vtkVolume')) {
|
|
365
|
+
// @ts-ignore
|
|
366
|
+
actor.getProperty().setUseLabelOutline(renderOutline);
|
|
367
|
+
// @ts-ignore
|
|
368
|
+
actor.getProperty().setLabelOutlineOpacity(outlineOpacity);
|
|
369
|
+
// @ts-ignore
|
|
370
|
+
actor.getProperty().setLabelOutlineThickness(outlineWidth);
|
|
371
|
+
}
|
|
342
372
|
|
|
343
373
|
// Set visibility based on whether actor visibility is specifically asked
|
|
344
374
|
// to be turned on/off (on by default) AND whether is is in active but
|
|
345
375
|
// we are rendering inactive labelmap
|
|
346
376
|
const visible = isActiveLabelmap || renderInactiveSegmentations;
|
|
347
|
-
|
|
377
|
+
actor.setVisibility(visible);
|
|
348
378
|
}
|
|
349
379
|
|
|
350
380
|
function _getLabelmapConfig(
|
|
@@ -490,13 +520,13 @@ function _removeLabelmapFromToolGroupViewports(
|
|
|
490
520
|
}
|
|
491
521
|
|
|
492
522
|
async function _addLabelmapToViewport(
|
|
493
|
-
viewport: Types.IVolumeViewport,
|
|
494
|
-
|
|
495
|
-
segmentationRepresentationUID
|
|
523
|
+
viewport: Types.IVolumeViewport | Types.IStackViewport,
|
|
524
|
+
labelmapData: LabelmapSegmentationData,
|
|
525
|
+
segmentationRepresentationUID
|
|
496
526
|
): Promise<void> {
|
|
497
527
|
await addLabelmapToElement(
|
|
498
528
|
viewport.element,
|
|
499
|
-
|
|
529
|
+
labelmapData,
|
|
500
530
|
segmentationRepresentationUID
|
|
501
531
|
);
|
|
502
532
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { SegmentationPublicInput } from '../../../types/SegmentationStateTypes';
|
|
2
2
|
import { cache } from '@cornerstonejs/core';
|
|
3
|
-
import {
|
|
3
|
+
import type {
|
|
4
|
+
LabelmapSegmentationData,
|
|
5
|
+
LabelmapSegmentationDataVolume,
|
|
6
|
+
} from '../../../types/LabelmapTypes';
|
|
4
7
|
|
|
5
8
|
function validate(segmentationInput: SegmentationPublicInput): void {
|
|
6
9
|
if (!segmentationInput.representation.data) {
|
|
@@ -12,18 +15,21 @@ function validate(segmentationInput: SegmentationPublicInput): void {
|
|
|
12
15
|
const representationData = segmentationInput.representation
|
|
13
16
|
.data as LabelmapSegmentationData;
|
|
14
17
|
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
if ('volumeId' in representationData) {
|
|
19
|
+
// volumetric labelmap
|
|
20
|
+
const cachedVolume = cache.getVolume(
|
|
21
|
+
(representationData as LabelmapSegmentationDataVolume).volumeId
|
|
18
22
|
);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const cachedVolume = cache.getVolume(representationData.volumeId);
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
if (!cachedVolume) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`volumeId of ${
|
|
27
|
+
(representationData as LabelmapSegmentationDataVolume).volumeId
|
|
28
|
+
} not found in cache, you should load and cache volume before adding segmentation`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
// I don't think we need this check since there is no guarantee that the stack is cached.
|
|
27
33
|
}
|
|
28
34
|
}
|
|
29
35
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { utilities as csUtils, getEnabledElement } from '@cornerstonejs/core';
|
|
2
2
|
import { vec3 } from 'gl-matrix';
|
|
3
3
|
|
|
4
4
|
import type { Types } from '@cornerstonejs/core';
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
fillInsideCircle,
|
|
20
20
|
} from './strategies/fillCircle';
|
|
21
21
|
import { eraseInsideCircle } from './strategies/eraseCircle';
|
|
22
|
-
import { Events, ToolModes } from '../../enums';
|
|
22
|
+
import { Events, ToolModes, SegmentationRepresentations } from '../../enums';
|
|
23
23
|
import { drawCircle as drawCircleSvg } from '../../drawingSvg';
|
|
24
24
|
import {
|
|
25
25
|
resetElementCursor,
|
|
@@ -34,7 +34,11 @@ import {
|
|
|
34
34
|
state as segmentationState,
|
|
35
35
|
activeSegmentation,
|
|
36
36
|
} from '../../stateManagement/segmentation';
|
|
37
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
LabelmapSegmentationDataVolume,
|
|
39
|
+
LabelmapSegmentationDataStack,
|
|
40
|
+
} from '../../types/LabelmapTypes';
|
|
41
|
+
import { isVolumeSegmentation } from './strategies/utils/stackVolumeCheck';
|
|
38
42
|
|
|
39
43
|
/**
|
|
40
44
|
* @public
|
|
@@ -42,9 +46,11 @@ import { LabelmapSegmentationData } from '../../types/LabelmapTypes';
|
|
|
42
46
|
class BrushTool extends BaseTool {
|
|
43
47
|
static toolName;
|
|
44
48
|
private _editData: {
|
|
45
|
-
segmentation: Types.IImageVolume;
|
|
46
|
-
imageVolume: Types.IImageVolume; //
|
|
47
49
|
segmentsLocked: number[]; //
|
|
50
|
+
segmentationRepresentationUID?: string;
|
|
51
|
+
imageIdReferenceMap?: Map<string, string>;
|
|
52
|
+
volumeId?: string;
|
|
53
|
+
referencedVolumeId?: string;
|
|
48
54
|
} | null;
|
|
49
55
|
private _hoverData?: {
|
|
50
56
|
brushCursor: any;
|
|
@@ -108,10 +114,6 @@ class BrushTool extends BaseTool {
|
|
|
108
114
|
const enabledElement = getEnabledElement(element);
|
|
109
115
|
const { viewport, renderingEngine } = enabledElement;
|
|
110
116
|
|
|
111
|
-
if (viewport instanceof StackViewport) {
|
|
112
|
-
throw new Error('Not implemented yet');
|
|
113
|
-
}
|
|
114
|
-
|
|
115
117
|
const toolGroupId = this.toolGroupId;
|
|
116
118
|
|
|
117
119
|
const activeSegmentationRepresentation =
|
|
@@ -122,30 +124,78 @@ class BrushTool extends BaseTool {
|
|
|
122
124
|
);
|
|
123
125
|
}
|
|
124
126
|
|
|
125
|
-
const { segmentationId, type } =
|
|
127
|
+
const { segmentationId, type, segmentationRepresentationUID } =
|
|
128
|
+
activeSegmentationRepresentation;
|
|
129
|
+
|
|
130
|
+
if (type === SegmentationRepresentations.Contour) {
|
|
131
|
+
throw new Error('Not implemented yet');
|
|
132
|
+
}
|
|
133
|
+
|
|
126
134
|
const segmentsLocked = segmentLocking.getLockedSegments(segmentationId);
|
|
127
135
|
|
|
128
136
|
const { representationData } =
|
|
129
137
|
segmentationState.getSegmentation(segmentationId);
|
|
130
138
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const segmentation = cache.getVolume(volumeId);
|
|
139
|
+
const labelmapData =
|
|
140
|
+
representationData[SegmentationRepresentations.Labelmap];
|
|
134
141
|
|
|
135
|
-
const
|
|
142
|
+
const viewportIdsToRender = [viewport.id];
|
|
136
143
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
144
|
+
if (isVolumeSegmentation(labelmapData)) {
|
|
145
|
+
const { volumeId } = representationData[
|
|
146
|
+
type
|
|
147
|
+
] as LabelmapSegmentationDataVolume;
|
|
148
|
+
const actors = viewport.getActors();
|
|
149
|
+
|
|
150
|
+
// Note: For tools that need the source data. Assumed to use
|
|
151
|
+
// First volume actor for now.
|
|
152
|
+
const firstVolumeActorUID = actors[0].uid;
|
|
153
|
+
|
|
154
|
+
this._editData = {
|
|
155
|
+
volumeId,
|
|
156
|
+
referencedVolumeId: firstVolumeActorUID,
|
|
157
|
+
segmentsLocked,
|
|
158
|
+
segmentationRepresentationUID,
|
|
159
|
+
};
|
|
160
|
+
} else {
|
|
161
|
+
const { imageIdReferenceMap } =
|
|
162
|
+
labelmapData as LabelmapSegmentationDataStack;
|
|
163
|
+
|
|
164
|
+
const currentImageId = viewport.getCurrentImageId();
|
|
165
|
+
|
|
166
|
+
if (!imageIdReferenceMap.get(currentImageId)) {
|
|
167
|
+
// if there is no stack segmentation slice for the current image
|
|
168
|
+
// we should not allow the user to perform any operation
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
141
171
|
|
|
142
|
-
|
|
172
|
+
// here we should identify if we can perform sphere manipulation
|
|
173
|
+
// for these stack of images, if the metadata is not present
|
|
174
|
+
// to create a volume or if there are inconsistencies between
|
|
175
|
+
// the image metadata we should not allow the sphere manipulation
|
|
176
|
+
// and should throw an error or maybe simply just allow circle manipulation
|
|
177
|
+
// and not sphere manipulation
|
|
178
|
+
if (this.configuration.activeStrategy.includes('SPHERE')) {
|
|
179
|
+
console.warn(
|
|
180
|
+
'Sphere manipulation is not supported for this stack of images yet'
|
|
181
|
+
);
|
|
182
|
+
return;
|
|
183
|
+
|
|
184
|
+
// Todo: add sphere manipulation support for stacks of images
|
|
185
|
+
// we should basically check if the stack constructs a valid volume
|
|
186
|
+
// meaning all the metadata is present and consistent
|
|
187
|
+
// then we should create a volume and use it as a reference
|
|
188
|
+
// ideally a tiny volume that does not exceeds the boundary of the
|
|
189
|
+
// sphere brush size
|
|
190
|
+
// csUtils.isValidVolume(referencedImageIds
|
|
191
|
+
}
|
|
143
192
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
193
|
+
this._editData = {
|
|
194
|
+
imageIdReferenceMap,
|
|
195
|
+
segmentsLocked,
|
|
196
|
+
segmentationRepresentationUID,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
149
199
|
|
|
150
200
|
this._activateDraw(element);
|
|
151
201
|
|
|
@@ -240,8 +290,6 @@ class BrushTool extends BaseTool {
|
|
|
240
290
|
const enabledElement = getEnabledElement(element);
|
|
241
291
|
const { renderingEngine } = enabledElement;
|
|
242
292
|
|
|
243
|
-
const { imageVolume, segmentation, segmentsLocked } = this._editData;
|
|
244
|
-
|
|
245
293
|
this.updateCursor(evt);
|
|
246
294
|
|
|
247
295
|
const {
|
|
@@ -261,11 +309,9 @@ class BrushTool extends BaseTool {
|
|
|
261
309
|
);
|
|
262
310
|
|
|
263
311
|
const operationData = {
|
|
312
|
+
...this._editData,
|
|
264
313
|
points: data.handles.points,
|
|
265
|
-
volume: segmentation, // todo: just pass the segmentationId instead
|
|
266
|
-
imageVolume,
|
|
267
314
|
segmentIndex,
|
|
268
|
-
segmentsLocked,
|
|
269
315
|
viewPlaneNormal,
|
|
270
316
|
toolGroupId: this.toolGroupId,
|
|
271
317
|
segmentationId,
|
|
@@ -340,7 +386,6 @@ class BrushTool extends BaseTool {
|
|
|
340
386
|
const eventData = evt.detail;
|
|
341
387
|
const { element } = eventData;
|
|
342
388
|
|
|
343
|
-
const { imageVolume, segmentation, segmentsLocked } = this._editData;
|
|
344
389
|
const {
|
|
345
390
|
segmentIndex,
|
|
346
391
|
segmentationId,
|
|
@@ -356,21 +401,13 @@ class BrushTool extends BaseTool {
|
|
|
356
401
|
resetElementCursor(element);
|
|
357
402
|
|
|
358
403
|
const enabledElement = getEnabledElement(element);
|
|
359
|
-
const { viewport } = enabledElement;
|
|
360
404
|
|
|
361
|
-
this._editData = null;
|
|
362
405
|
this.updateCursor(evt);
|
|
363
406
|
|
|
364
|
-
if (viewport instanceof StackViewport) {
|
|
365
|
-
throw new Error('Not implemented yet');
|
|
366
|
-
}
|
|
367
|
-
|
|
368
407
|
const operationData = {
|
|
369
408
|
points: data.handles.points,
|
|
370
|
-
|
|
371
|
-
imageVolume,
|
|
409
|
+
...this._editData,
|
|
372
410
|
segmentIndex,
|
|
373
|
-
segmentsLocked,
|
|
374
411
|
viewPlaneNormal,
|
|
375
412
|
toolGroupId: this.toolGroupId,
|
|
376
413
|
segmentationId,
|
|
@@ -380,6 +417,8 @@ class BrushTool extends BaseTool {
|
|
|
380
417
|
this.configuration.strategySpecificConfiguration,
|
|
381
418
|
};
|
|
382
419
|
|
|
420
|
+
this._editData = null;
|
|
421
|
+
|
|
383
422
|
this.applyActiveStrategy(enabledElement, operationData);
|
|
384
423
|
};
|
|
385
424
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cache, getEnabledElement
|
|
1
|
+
import { cache, getEnabledElement } from '@cornerstonejs/core';
|
|
2
2
|
import type { Types } from '@cornerstonejs/core';
|
|
3
3
|
|
|
4
4
|
import { BaseTool } from '../base';
|
|
@@ -25,7 +25,12 @@ import {
|
|
|
25
25
|
config as segmentationConfig,
|
|
26
26
|
} from '../../stateManagement/segmentation';
|
|
27
27
|
import { getSegmentation } from '../../stateManagement/segmentation/segmentationState';
|
|
28
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
LabelmapSegmentationData,
|
|
30
|
+
LabelmapSegmentationDataStack,
|
|
31
|
+
LabelmapSegmentationDataVolume,
|
|
32
|
+
} from '../../types/LabelmapTypes';
|
|
33
|
+
import { isVolumeSegmentation } from './strategies/utils/stackVolumeCheck';
|
|
29
34
|
|
|
30
35
|
/**
|
|
31
36
|
* Tool for manipulating segmentation data by drawing a circle. It acts on the
|
|
@@ -38,9 +43,12 @@ class CircleScissorsTool extends BaseTool {
|
|
|
38
43
|
static toolName;
|
|
39
44
|
editData: {
|
|
40
45
|
annotation: any;
|
|
41
|
-
segmentation: any;
|
|
42
46
|
segmentIndex: number;
|
|
43
|
-
|
|
47
|
+
//
|
|
48
|
+
volumeId: string;
|
|
49
|
+
referencedVolumeId: string;
|
|
50
|
+
imageIdReferenceMap: Map<string, string>;
|
|
51
|
+
//
|
|
44
52
|
segmentsLocked: number[];
|
|
45
53
|
segmentColor: [number, number, number, number];
|
|
46
54
|
viewportIdsToRender: string[];
|
|
@@ -49,6 +57,7 @@ class CircleScissorsTool extends BaseTool {
|
|
|
49
57
|
newAnnotation?: boolean;
|
|
50
58
|
hasMoved?: boolean;
|
|
51
59
|
centerCanvas?: Array<number>;
|
|
60
|
+
segmentationRepresentationUID?: string;
|
|
52
61
|
} | null;
|
|
53
62
|
isDrawing: boolean;
|
|
54
63
|
isHandleOutsideImage: boolean;
|
|
@@ -116,8 +125,13 @@ class CircleScissorsTool extends BaseTool {
|
|
|
116
125
|
const { representationData } = getSegmentation(segmentationId);
|
|
117
126
|
|
|
118
127
|
// Todo: are we going to support contour editing with rectangle scissors?
|
|
119
|
-
const
|
|
120
|
-
|
|
128
|
+
const labelmapData = representationData[type];
|
|
129
|
+
|
|
130
|
+
if (!labelmapData) {
|
|
131
|
+
throw new Error(
|
|
132
|
+
'No labelmap data found for the active segmentation, create one before using scissors tool'
|
|
133
|
+
);
|
|
134
|
+
}
|
|
121
135
|
|
|
122
136
|
// Todo: Used for drawing the svg only, we might not need it at all
|
|
123
137
|
const annotation = {
|
|
@@ -145,7 +159,6 @@ class CircleScissorsTool extends BaseTool {
|
|
|
145
159
|
|
|
146
160
|
this.editData = {
|
|
147
161
|
annotation,
|
|
148
|
-
segmentation,
|
|
149
162
|
centerCanvas: canvasPos,
|
|
150
163
|
segmentIndex,
|
|
151
164
|
segmentationId,
|
|
@@ -156,7 +169,27 @@ class CircleScissorsTool extends BaseTool {
|
|
|
156
169
|
movingTextBox: false,
|
|
157
170
|
newAnnotation: true,
|
|
158
171
|
hasMoved: false,
|
|
159
|
-
|
|
172
|
+
segmentationRepresentationUID,
|
|
173
|
+
} as any;
|
|
174
|
+
|
|
175
|
+
if (isVolumeSegmentation(labelmapData as LabelmapSegmentationData)) {
|
|
176
|
+
const { volumeId } = labelmapData as LabelmapSegmentationDataVolume;
|
|
177
|
+
const segmentation = cache.getVolume(volumeId);
|
|
178
|
+
|
|
179
|
+
this.editData = {
|
|
180
|
+
...this.editData,
|
|
181
|
+
volumeId,
|
|
182
|
+
referencedVolumeId: segmentation.referencedVolumeId,
|
|
183
|
+
};
|
|
184
|
+
} else {
|
|
185
|
+
const { imageIdReferenceMap } =
|
|
186
|
+
labelmapData as LabelmapSegmentationDataStack;
|
|
187
|
+
|
|
188
|
+
this.editData = {
|
|
189
|
+
...this.editData,
|
|
190
|
+
imageIdReferenceMap,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
160
193
|
|
|
161
194
|
this._activateDraw(element);
|
|
162
195
|
|
|
@@ -221,15 +254,7 @@ class CircleScissorsTool extends BaseTool {
|
|
|
221
254
|
const eventDetail = evt.detail;
|
|
222
255
|
const { element } = eventDetail;
|
|
223
256
|
|
|
224
|
-
const {
|
|
225
|
-
annotation,
|
|
226
|
-
newAnnotation,
|
|
227
|
-
hasMoved,
|
|
228
|
-
segmentation,
|
|
229
|
-
segmentIndex,
|
|
230
|
-
segmentsLocked,
|
|
231
|
-
segmentationId,
|
|
232
|
-
} = this.editData;
|
|
257
|
+
const { annotation, newAnnotation, hasMoved } = this.editData;
|
|
233
258
|
const { data } = annotation;
|
|
234
259
|
const { viewPlaneNormal, viewUp } = annotation.metadata;
|
|
235
260
|
|
|
@@ -244,25 +269,17 @@ class CircleScissorsTool extends BaseTool {
|
|
|
244
269
|
resetElementCursor(element);
|
|
245
270
|
|
|
246
271
|
const enabledElement = getEnabledElement(element);
|
|
247
|
-
const { viewport } = enabledElement;
|
|
248
|
-
|
|
249
|
-
this.editData = null;
|
|
250
|
-
this.isDrawing = false;
|
|
251
|
-
|
|
252
|
-
if (viewport instanceof StackViewport) {
|
|
253
|
-
throw new Error('Not implemented yet');
|
|
254
|
-
}
|
|
255
272
|
|
|
256
273
|
const operationData = {
|
|
274
|
+
...this.editData,
|
|
257
275
|
points: data.handles.points,
|
|
258
|
-
volume: segmentation,
|
|
259
|
-
segmentIndex,
|
|
260
|
-
segmentsLocked,
|
|
261
276
|
viewPlaneNormal,
|
|
262
|
-
segmentationId,
|
|
263
277
|
viewUp,
|
|
264
278
|
};
|
|
265
279
|
|
|
280
|
+
this.editData = null;
|
|
281
|
+
this.isDrawing = false;
|
|
282
|
+
|
|
266
283
|
this.applyActiveStrategy(enabledElement, operationData);
|
|
267
284
|
};
|
|
268
285
|
|
|
@@ -7,7 +7,7 @@ import type { Types } from '@cornerstonejs/core';
|
|
|
7
7
|
|
|
8
8
|
import { BaseTool } from '../base';
|
|
9
9
|
import { PublicToolProps, ToolProps, EventTypes } from '../../types';
|
|
10
|
-
|
|
10
|
+
import { SegmentationRepresentations } from '../../enums';
|
|
11
11
|
import { triggerSegmentationDataModified } from '../../stateManagement/segmentation/triggerSegmentationEvents';
|
|
12
12
|
import {
|
|
13
13
|
segmentLocking,
|
|
@@ -17,7 +17,11 @@ import {
|
|
|
17
17
|
import floodFill from '../../utilities/segmentation/floodFill';
|
|
18
18
|
import { getSegmentation } from '../../stateManagement/segmentation/segmentationState';
|
|
19
19
|
import { FloodFillResult, FloodFillGetter } from '../../types';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
LabelmapSegmentationDataStack,
|
|
22
|
+
LabelmapSegmentationDataVolume,
|
|
23
|
+
} from '../../types/LabelmapTypes';
|
|
24
|
+
import { isVolumeSegmentation } from './strategies/utils/stackVolumeCheck';
|
|
21
25
|
|
|
22
26
|
const { transformWorldToIndex, isEqual } = csUtils;
|
|
23
27
|
|
|
@@ -83,12 +87,45 @@ class PaintFillTool extends BaseTool {
|
|
|
83
87
|
segmentLocking.getLockedSegments(segmentationId);
|
|
84
88
|
const { representationData } = getSegmentation(segmentationId);
|
|
85
89
|
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
const labelmapData =
|
|
91
|
+
representationData[SegmentationRepresentations.Labelmap];
|
|
92
|
+
|
|
93
|
+
let dimensions: Types.Point3;
|
|
94
|
+
let direction: Types.Mat3;
|
|
95
|
+
let scalarData: Types.PixelDataTypedArray;
|
|
96
|
+
let index: Types.Point3;
|
|
97
|
+
|
|
98
|
+
if (isVolumeSegmentation(labelmapData)) {
|
|
99
|
+
const { volumeId } = representationData[
|
|
100
|
+
type
|
|
101
|
+
] as LabelmapSegmentationDataVolume;
|
|
102
|
+
|
|
103
|
+
const segmentation = cache.getVolume(volumeId);
|
|
104
|
+
({ dimensions, direction } = segmentation);
|
|
105
|
+
scalarData = segmentation.getScalarData();
|
|
90
106
|
|
|
91
|
-
|
|
107
|
+
index = transformWorldToIndex(segmentation.imageData, worldPos);
|
|
108
|
+
} else {
|
|
109
|
+
const { imageIdReferenceMap } =
|
|
110
|
+
labelmapData as LabelmapSegmentationDataStack;
|
|
111
|
+
|
|
112
|
+
const currentImageId = enabledElement.viewport.getCurrentImageId();
|
|
113
|
+
const currentSegmentationImageId =
|
|
114
|
+
imageIdReferenceMap.get(currentImageId);
|
|
115
|
+
|
|
116
|
+
if (!currentSegmentationImageId) {
|
|
117
|
+
throw new Error(
|
|
118
|
+
'No active segmentation imageId detected, create one before using scissors tool'
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const segmentationImage = cache.getImage(currentSegmentationImageId);
|
|
123
|
+
scalarData = segmentationImage.getPixelData();
|
|
124
|
+
const { imageData } = viewport.getImageData();
|
|
125
|
+
dimensions = imageData.getDimensions();
|
|
126
|
+
direction = imageData.getDirection();
|
|
127
|
+
index = transformWorldToIndex(imageData, worldPos);
|
|
128
|
+
}
|
|
92
129
|
|
|
93
130
|
const fixedDimension = this.getFixedDimension(
|
|
94
131
|
viewPlaneNormal,
|
|
@@ -190,7 +227,7 @@ class PaintFillTool extends BaseTool {
|
|
|
190
227
|
};
|
|
191
228
|
|
|
192
229
|
private generateHelpers = (
|
|
193
|
-
scalarData:
|
|
230
|
+
scalarData: Types.PixelDataTypedArray,
|
|
194
231
|
dimensions: Types.Point3,
|
|
195
232
|
seedIndex3D: Types.Point3,
|
|
196
233
|
fixedDimension = 2
|