@cornerstonejs/tools 5.11.7 → 5.12.1

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.
@@ -0,0 +1,3 @@
1
+ export declare function moveSegmentToPrivateLabelmap(segmentationId: string, segmentIndex: number, options?: {
2
+ recordHistory?: boolean;
3
+ }): string | undefined;
@@ -0,0 +1,31 @@
1
+ import { utilities } from '@cornerstonejs/core';
2
+ import { getSegmentation } from '../getSegmentation.js';
3
+ import { triggerSegmentationDataModified } from '../triggerSegmentationEvents.js';
4
+ import { moveSegmentToPrivateLabelmap as moveSegmentToPrivateLayer } from '../labelmapModel/privateLabelmap.js';
5
+ const { DefaultHistoryMemo } = utilities.HistoryMemo;
6
+ export function moveSegmentToPrivateLabelmap(segmentationId, segmentIndex, options) {
7
+ const segmentation = getSegmentation(segmentationId);
8
+ if (!segmentation?.representationData.Labelmap) {
9
+ return;
10
+ }
11
+ const layer = moveSegmentToPrivateLayer(segmentation, segmentIndex, {
12
+ moveStepCallback: (step) => {
13
+ if (!options?.recordHistory) {
14
+ return;
15
+ }
16
+ DefaultHistoryMemo.push({
17
+ restoreMemo: (undo) => {
18
+ if (undo) {
19
+ step.undo();
20
+ }
21
+ else {
22
+ step.redo();
23
+ }
24
+ triggerSegmentationDataModified(segmentationId);
25
+ },
26
+ });
27
+ },
28
+ });
29
+ triggerSegmentationDataModified(segmentationId);
30
+ return layer?.labelmapId;
31
+ }
@@ -13,7 +13,9 @@ import * as utilities from './utilities/index.js';
13
13
  import { convertStackToVolumeLabelmap } from './helpers/convertStackToVolumeLabelmap.js';
14
14
  import { computeVolumeLabelmapFromStack } from './helpers/computeVolumeLabelmapFromStack.js';
15
15
  import { clearSegmentValue } from './helpers/clearSegmentValue.js';
16
+ import { moveSegmentToPrivateLabelmap } from './helpers/moveSegmentToPrivateLabelmap.js';
16
17
  import { convertVolumeToStackLabelmap } from './helpers/computeStackLabelmapFromVolume.js';
18
+ import { getLabelToSegmentIndex, getLabelValueForSegment, getSegmentIndexForLabelValue } from './labelmapModel/index.js';
17
19
  import { removeSegment } from './removeSegment.js';
18
20
  import { getLabelmapImageIds } from './getLabelmapImageIds.js';
19
21
  import * as strategies from './../../tools/segmentation/strategies/index.js';
@@ -28,5 +30,9 @@ declare const helpers: {
28
30
  convertStackToVolumeLabelmap: typeof convertStackToVolumeLabelmap;
29
31
  computeVolumeLabelmapFromStack: typeof computeVolumeLabelmapFromStack;
30
32
  convertVolumeToStackLabelmap: typeof convertVolumeToStackLabelmap;
33
+ getLabelToSegmentIndex: typeof getLabelToSegmentIndex;
34
+ getLabelValueForSegment: typeof getLabelValueForSegment;
35
+ getSegmentIndexForLabelValue: typeof getSegmentIndexForLabelValue;
36
+ moveSegmentToPrivateLabelmap: typeof moveSegmentToPrivateLabelmap;
31
37
  };
32
38
  export { removeSegmentationRepresentation, removeContourRepresentation, removeLabelmapRepresentation, removeSurfaceRepresentation, removeAllSegmentations, removeSegmentation, removeSegmentationRepresentations, addLabelmapRepresentationToViewport, addLabelmapRepresentationToViewportMap, addSegmentationRepresentations, removeAllSegmentationRepresentations, addContourRepresentationToViewport, addContourRepresentationToViewportMap, addSurfaceRepresentationToViewport, addSurfaceRepresentationToViewportMap, addSegmentations, updateSegmentations, addSegmentationListener, addDefaultSegmentationListener, removeSegmentationListener, removeAllSegmentationListeners, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, utilities, helpers, removeSegment, getLabelmapImageIds, addRepresentationData, strategies, segmentationStyle, defaultSegmentationStateManager, getCurrentLabelmapImageIdsForViewport, getLabelmapImageIdsForImageId, getActiveSegmentation, };
@@ -13,7 +13,9 @@ import * as utilities from './utilities/index.js';
13
13
  import { convertStackToVolumeLabelmap } from './helpers/convertStackToVolumeLabelmap.js';
14
14
  import { computeVolumeLabelmapFromStack } from './helpers/computeVolumeLabelmapFromStack.js';
15
15
  import { clearSegmentValue } from './helpers/clearSegmentValue.js';
16
+ import { moveSegmentToPrivateLabelmap } from './helpers/moveSegmentToPrivateLabelmap.js';
16
17
  import { convertVolumeToStackLabelmap } from './helpers/computeStackLabelmapFromVolume.js';
18
+ import { getLabelToSegmentIndex, getLabelValueForSegment, getSegmentIndexForLabelValue, } from './labelmapModel/index.js';
17
19
  import { removeSegment } from './removeSegment.js';
18
20
  import { getLabelmapImageIds } from './getLabelmapImageIds.js';
19
21
  import * as strategies from './../../tools/segmentation/strategies/index.js';
@@ -28,5 +30,9 @@ const helpers = {
28
30
  convertStackToVolumeLabelmap,
29
31
  computeVolumeLabelmapFromStack,
30
32
  convertVolumeToStackLabelmap,
33
+ getLabelToSegmentIndex,
34
+ getLabelValueForSegment,
35
+ getSegmentIndexForLabelValue,
36
+ moveSegmentToPrivateLabelmap,
31
37
  };
32
38
  export { removeSegmentationRepresentation, removeContourRepresentation, removeLabelmapRepresentation, removeSurfaceRepresentation, removeAllSegmentations, removeSegmentation, removeSegmentationRepresentations, addLabelmapRepresentationToViewport, addLabelmapRepresentationToViewportMap, addSegmentationRepresentations, removeAllSegmentationRepresentations, addContourRepresentationToViewport, addContourRepresentationToViewportMap, addSurfaceRepresentationToViewport, addSurfaceRepresentationToViewportMap, addSegmentations, updateSegmentations, addSegmentationListener, addDefaultSegmentationListener, removeSegmentationListener, removeAllSegmentationListeners, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, utilities, helpers, removeSegment, getLabelmapImageIds, addRepresentationData, strategies, segmentationStyle, defaultSegmentationStateManager, getCurrentLabelmapImageIdsForViewport, getLabelmapImageIdsForImageId, getActiveSegmentation, };
@@ -2,8 +2,8 @@ export { SOURCE_REPRESENTATION_NAME, ensureLabelmapState, getPrimaryLabelmapId,
2
2
  export type { LabelmapSegmentationWithState } from './normalizeLabelmapSegmentationData.js';
3
3
  export { getConstructorNameForLabelmap, getLabelmap, getLabelmapDataById, getLabelmapForImageId, getLabelmapForVolumeId, getLabelmapIds, getLabelmaps, getOrCreateLabelmapVolume, getScalarArrayLengthFromLabelmap, registerLabelmap, removeLabelmap, } from './labelmapLayerStore.js';
4
4
  export { getReferencedImageIdToCurrentImageIdMap, syncLegacyLabelmapData, } from './labelmapLegacyAdapter.js';
5
- export { getLabelmapForSegment, getLabelValueForSegment, getSegmentBinding, getSegmentIndexForLabelValue, getSegmentsOnLabelmap, removeSegmentBinding, resolveLabelmapForSegment, setSegmentBinding, } from './labelmapSegmentBindings.js';
5
+ export { getLabelmapForSegment, getLabelToSegmentIndex, getLabelValueForSegment, getSegmentBinding, getSegmentIndexForLabelValue, getSegmentsOnLabelmap, removeSegmentBinding, resolveLabelmapForSegment, setSegmentBinding, } from './labelmapSegmentBindings.js';
6
6
  export { createPrivateLabelmap, moveSegmentToPrivateLabelmap, } from './privateLabelmap.js';
7
- export { beginLabelmapEditTransaction, collectCrossLayerEraseBindings, eraseLabelmapEditTransactionOverwrites, getLabelmapLayerImageId, getProtectedSegmentIndicesForLayer, hasProtectedSegmentOverwrite, resolveLabelmapLayerEditTarget, } from './labelmapEditTransaction.js';
8
- export type { BeginLabelmapEditTransactionOptions, EraseLabelmapEditTransactionOptions, LabelmapEditTransaction, LabelmapLayerEditTarget, ResolveLabelmapLayerEditTargetOptions, } from './labelmapEditTransaction.js';
7
+ export { beginLabelmapEditTransaction, collectCrossLayerEraseBindings, eraseLabelmapEditTransactionOverwrites, getLabelmapLayerImageId, getLockedVoxelsOnOtherLayers, getProtectedSegmentIndicesForLayer, resolveLabelmapLayerEditTarget, } from './labelmapEditTransaction.js';
8
+ export type { BeginLabelmapEditTransactionOptions, EraseLabelmapEditTransactionOptions, LabelmapEditTransaction, LabelmapLayerEditTarget, LockedLabelmapVoxels, ResolveLabelmapLayerEditTargetOptions, } from './labelmapEditTransaction.js';
9
9
  export { default as LabelmapImageReferenceResolver } from './labelmapImageReferenceResolver.js';
@@ -1,7 +1,7 @@
1
1
  export { SOURCE_REPRESENTATION_NAME, ensureLabelmapState, getPrimaryLabelmapId, getSegmentOrder, } from './normalizeLabelmapSegmentationData.js';
2
2
  export { getConstructorNameForLabelmap, getLabelmap, getLabelmapDataById, getLabelmapForImageId, getLabelmapForVolumeId, getLabelmapIds, getLabelmaps, getOrCreateLabelmapVolume, getScalarArrayLengthFromLabelmap, registerLabelmap, removeLabelmap, } from './labelmapLayerStore.js';
3
3
  export { getReferencedImageIdToCurrentImageIdMap, syncLegacyLabelmapData, } from './labelmapLegacyAdapter.js';
4
- export { getLabelmapForSegment, getLabelValueForSegment, getSegmentBinding, getSegmentIndexForLabelValue, getSegmentsOnLabelmap, removeSegmentBinding, resolveLabelmapForSegment, setSegmentBinding, } from './labelmapSegmentBindings.js';
4
+ export { getLabelmapForSegment, getLabelToSegmentIndex, getLabelValueForSegment, getSegmentBinding, getSegmentIndexForLabelValue, getSegmentsOnLabelmap, removeSegmentBinding, resolveLabelmapForSegment, setSegmentBinding, } from './labelmapSegmentBindings.js';
5
5
  export { createPrivateLabelmap, moveSegmentToPrivateLabelmap, } from './privateLabelmap.js';
6
- export { beginLabelmapEditTransaction, collectCrossLayerEraseBindings, eraseLabelmapEditTransactionOverwrites, getLabelmapLayerImageId, getProtectedSegmentIndicesForLayer, hasProtectedSegmentOverwrite, resolveLabelmapLayerEditTarget, } from './labelmapEditTransaction.js';
6
+ export { beginLabelmapEditTransaction, collectCrossLayerEraseBindings, eraseLabelmapEditTransactionOverwrites, getLabelmapLayerImageId, getLockedVoxelsOnOtherLayers, getProtectedSegmentIndicesForLayer, resolveLabelmapLayerEditTarget, } from './labelmapEditTransaction.js';
7
7
  export { default as LabelmapImageReferenceResolver } from './labelmapImageReferenceResolver.js';
@@ -14,6 +14,7 @@ type MoveSegmentToPrivateLabelmap = (segmentation: Segmentation, segmentIndex: n
14
14
  type BeginLabelmapEditTransactionOptions = {
15
15
  segmentIndex: number;
16
16
  overwriteSegmentIndices?: number[];
17
+ segmentsLocked?: number[];
17
18
  segmentationVoxelManager?: Types.IVoxelManager<number>;
18
19
  segmentationImageData?: vtkImageData;
19
20
  isInObject?: (point: Types.Point3) => boolean;
@@ -31,6 +32,11 @@ type LabelmapEditTransaction = {
31
32
  crossLayerEraseBindings: SegmentLabelmapBindingState[];
32
33
  movedSegment: boolean;
33
34
  moveStep?: LabelmapRestoreStep;
35
+ lockedVoxelsOnOtherLayers?: LockedLabelmapVoxels[];
36
+ };
37
+ type LockedLabelmapVoxels = {
38
+ voxelManager: Types.IVoxelManager<number>;
39
+ labelValues: Set<number>;
34
40
  };
35
41
  type ResolveLabelmapLayerEditTargetOptions = {
36
42
  viewport?: Types.IViewport;
@@ -57,8 +63,9 @@ declare function getProtectedSegmentIndicesForLayer(segmentation: Segmentation,
57
63
  declare function hasProtectedSegmentOverwrite(segmentation: Segmentation, labelmapId: string, protectedSegmentIndices: number[], voxelManager?: Types.IVoxelManager<number>, options?: Pick<BeginLabelmapEditTransactionOptions, 'segmentationImageData' | 'isInObject' | 'isInObjectBoundsIJK'>): boolean;
58
64
  declare function collectCrossLayerEraseBindings(segmentation: Segmentation, labelmapId: string | undefined, overwriteSegmentIndices?: number[]): SegmentLabelmapBindingState[];
59
65
  declare function beginLabelmapEditTransaction(segmentation: Segmentation, options: BeginLabelmapEditTransactionOptions): LabelmapEditTransaction;
66
+ declare function getLockedVoxelsOnOtherLayers(segmentation: Segmentation, labelmapId: string | undefined, segmentsLocked?: number[], targetOptions?: ResolveLabelmapLayerEditTargetOptions): LockedLabelmapVoxels[];
60
67
  declare function getLabelmapLayerImageId(layer: LabelmapLayer, options?: ResolveLabelmapLayerEditTargetOptions): string | undefined;
61
68
  declare function resolveLabelmapLayerEditTarget(layer: LabelmapLayer, options?: ResolveLabelmapLayerEditTargetOptions): LabelmapLayerEditTarget;
62
69
  declare function eraseLabelmapEditTransactionOverwrites(segmentation: Segmentation, transaction: LabelmapEditTransaction | undefined, options: EraseLabelmapEditTransactionOptions): number[];
63
- export { beginLabelmapEditTransaction, collectCrossLayerEraseBindings, eraseLabelmapEditTransactionOverwrites, getLabelmapLayerImageId, getProtectedSegmentIndicesForLayer, hasProtectedSegmentOverwrite, resolveLabelmapLayerEditTarget, };
64
- export type { BeginLabelmapEditTransactionOptions, CrossLayerEraseRecord, EraseLabelmapEditTransactionOptions, LabelmapEditTransaction, LabelmapLayerEditTarget, ResolveLabelmapLayerEditTargetOptions, };
70
+ export { beginLabelmapEditTransaction, collectCrossLayerEraseBindings, eraseLabelmapEditTransactionOverwrites, getLabelmapLayerImageId, getLockedVoxelsOnOtherLayers, getProtectedSegmentIndicesForLayer, hasProtectedSegmentOverwrite, resolveLabelmapLayerEditTarget, };
71
+ export type { BeginLabelmapEditTransactionOptions, CrossLayerEraseRecord, EraseLabelmapEditTransactionOptions, LabelmapEditTransaction, LabelmapLayerEditTarget, LockedLabelmapVoxels, ResolveLabelmapLayerEditTargetOptions, };
@@ -1,5 +1,6 @@
1
1
  import { BaseVolumeViewport, cache } from '@cornerstonejs/core';
2
2
  import { getLabelmap, getOrCreateLabelmapVolume } from './labelmapLayerStore.js';
3
+ import { getLabelmapImageIdsForReferencedImageId, getReferencedImageIdForImageIndex, } from './labelmapImageIdMapping.js';
3
4
  import { getSegmentBinding, getSegmentIndexForLabelValue, getSegmentsOnLabelmap, } from './labelmapSegmentBindings.js';
4
5
  import { moveSegmentToPrivateLabelmap as defaultMoveSegmentToPrivateLabelmap } from './privateLabelmap.js';
5
6
  function getProtectedSegmentIndicesForLayer(segmentation, labelmapId, segmentIndex, overwriteSegmentIndices = []) {
@@ -67,7 +68,8 @@ function beginLabelmapEditTransaction(segmentation, options) {
67
68
  let labelValue = binding.labelValue;
68
69
  let movedSegment = false;
69
70
  const protectedSegmentIndices = getProtectedSegmentIndicesForLayer(segmentation, labelmapId, segmentIndex, overwriteSegmentIndices);
70
- const shouldMoveSegment = hasProtectedSegmentOverwrite(segmentation, labelmapId, protectedSegmentIndices, options.segmentationVoxelManager, {
71
+ const segmentsLocked = options.segmentsLocked ?? [];
72
+ const shouldMoveSegment = hasProtectedSegmentOverwrite(segmentation, labelmapId, protectedSegmentIndices.filter((protectedSegmentIndex) => !segmentsLocked.includes(protectedSegmentIndex)), options.segmentationVoxelManager, {
71
73
  segmentationImageData: options.segmentationImageData,
72
74
  isInObject: options.isInObject,
73
75
  isInObjectBoundsIJK: options.isInObjectBoundsIJK,
@@ -104,6 +106,53 @@ function beginLabelmapEditTransaction(segmentation, options) {
104
106
  moveStep,
105
107
  };
106
108
  }
109
+ function getLockedVoxelsOnOtherLayers(segmentation, labelmapId, segmentsLocked = [], targetOptions = {}) {
110
+ const labelValuesByLayer = new Map();
111
+ for (const lockedSegmentIndex of segmentsLocked) {
112
+ const binding = getSegmentBinding(segmentation, lockedSegmentIndex);
113
+ if (!binding || binding.labelmapId === labelmapId) {
114
+ continue;
115
+ }
116
+ if (!labelValuesByLayer.has(binding.labelmapId)) {
117
+ labelValuesByLayer.set(binding.labelmapId, new Set());
118
+ }
119
+ labelValuesByLayer.get(binding.labelmapId).add(binding.labelValue);
120
+ }
121
+ const { sourceLayer: editedLayer, imageId: editedImageId } = targetOptions;
122
+ const editedImageIndex = editedLayer?.imageIds?.indexOf(editedImageId) ?? -1;
123
+ const referencedImageId = editedLayer?.referencedImageIds && editedImageIndex >= 0
124
+ ? getReferencedImageIdForImageIndex(editedLayer, editedImageIndex)
125
+ : undefined;
126
+ const isVolumeEdit = targetOptions.preferVolume ||
127
+ targetOptions.viewport instanceof BaseVolumeViewport;
128
+ const lockedVoxels = [];
129
+ labelValuesByLayer.forEach((labelValues, lockedLabelmapId) => {
130
+ const layer = getLabelmap(segmentation, lockedLabelmapId);
131
+ if (!layer) {
132
+ return;
133
+ }
134
+ let layerTargetOptions = targetOptions;
135
+ if (!isVolumeEdit &&
136
+ !layer.volumeId &&
137
+ referencedImageId &&
138
+ layer.referencedImageIds) {
139
+ const [lockedImageId] = getLabelmapImageIdsForReferencedImageId(layer, referencedImageId);
140
+ if (!lockedImageId) {
141
+ return;
142
+ }
143
+ layerTargetOptions = {
144
+ ...targetOptions,
145
+ imageId: lockedImageId,
146
+ sourceLayer: layer,
147
+ };
148
+ }
149
+ const { voxelManager } = resolveLabelmapLayerEditTarget(layer, layerTargetOptions);
150
+ if (voxelManager) {
151
+ lockedVoxels.push({ voxelManager, labelValues });
152
+ }
153
+ });
154
+ return lockedVoxels;
155
+ }
107
156
  function getViewportImageIds(viewport) {
108
157
  const stackViewport = viewport;
109
158
  return typeof stackViewport?.getImageIds === 'function'
@@ -241,4 +290,4 @@ function eraseLabelmapEditTransactionOverwrites(segmentation, transaction, optio
241
290
  });
242
291
  return Array.from(modifiedSlices);
243
292
  }
244
- export { beginLabelmapEditTransaction, collectCrossLayerEraseBindings, eraseLabelmapEditTransactionOverwrites, getLabelmapLayerImageId, getProtectedSegmentIndicesForLayer, hasProtectedSegmentOverwrite, resolveLabelmapLayerEditTarget, };
293
+ export { beginLabelmapEditTransaction, collectCrossLayerEraseBindings, eraseLabelmapEditTransactionOverwrites, getLabelmapLayerImageId, getLockedVoxelsOnOtherLayers, getProtectedSegmentIndicesForLayer, hasProtectedSegmentOverwrite, resolveLabelmapLayerEditTarget, };
@@ -4,8 +4,9 @@ declare function getSegmentBinding(segmentation: Segmentation, segmentIndex: num
4
4
  declare function setSegmentBinding(segmentation: Segmentation, segmentIndex: number, binding: SegmentLabelmapBindingState): void;
5
5
  declare function getSegmentsOnLabelmap(segmentation: Segmentation, labelmapId: string): number[];
6
6
  declare function getSegmentIndexForLabelValue(segmentation: Segmentation, labelmapId: string, labelValue: number): number | undefined;
7
+ declare function getLabelToSegmentIndex(segmentation: Segmentation, labelmapId: string): Record<number, number>;
7
8
  declare function getLabelValueForSegment(segmentation: Segmentation, segmentIndex: number): number;
8
9
  declare function getLabelmapForSegment(segmentation: Segmentation, segmentIndex: number): LabelmapLayer | undefined;
9
10
  declare function resolveLabelmapForSegment(segmentation: Segmentation, segmentIndex: number): LabelmapLayer | undefined;
10
11
  declare function removeSegmentBinding(segmentation: Segmentation, segmentIndex: number): void;
11
- export { getLabelmapForSegment, getLabelValueForSegment, getSegmentBinding, getSegmentIndexForLabelValue, getSegmentsOnLabelmap, removeSegmentBinding, resolveLabelmapForSegment, setSegmentBinding, };
12
+ export { getLabelmapForSegment, getLabelToSegmentIndex, getLabelValueForSegment, getSegmentBinding, getSegmentIndexForLabelValue, getSegmentsOnLabelmap, removeSegmentBinding, resolveLabelmapForSegment, setSegmentBinding, };
@@ -40,6 +40,11 @@ function getSegmentIndexForLabelValue(segmentation, labelmapId, labelValue) {
40
40
  }
41
41
  return layer.labelToSegmentIndex?.[labelValue] ?? labelValue;
42
42
  }
43
+ function getLabelToSegmentIndex(segmentation, labelmapId) {
44
+ return {
45
+ ...(getLabelmap(segmentation, labelmapId)?.labelToSegmentIndex ?? {}),
46
+ };
47
+ }
43
48
  function getLabelValueForSegment(segmentation, segmentIndex) {
44
49
  return (getSegmentBinding(segmentation, segmentIndex)?.labelValue ?? segmentIndex);
45
50
  }
@@ -70,4 +75,4 @@ function removeSegmentBinding(segmentation, segmentIndex) {
70
75
  }
71
76
  syncLegacyLabelmapData(segmentation);
72
77
  }
73
- export { getLabelmapForSegment, getLabelValueForSegment, getSegmentBinding, getSegmentIndexForLabelValue, getSegmentsOnLabelmap, removeSegmentBinding, resolveLabelmapForSegment, setSegmentBinding, };
78
+ export { getLabelmapForSegment, getLabelToSegmentIndex, getLabelValueForSegment, getSegmentBinding, getSegmentIndexForLabelValue, getSegmentsOnLabelmap, removeSegmentBinding, resolveLabelmapForSegment, setSegmentBinding, };
@@ -2,13 +2,12 @@ import StrategyCallbacks from '../../../../enums/StrategyCallbacks.js';
2
2
  import { forEachBrushFillVoxel } from '../utils/brushVoxelSlab.js';
3
3
  export default {
4
4
  [StrategyCallbacks.Fill]: (operationData) => {
5
- const { segmentsLocked, segmentationImageData, segmentationVoxelManager, brushStrategy, centerIJK, brushVoxelSlabFill, } = operationData;
5
+ const { segmentationImageData, segmentationVoxelManager, brushStrategy, centerIJK, brushVoxelSlabFill, } = operationData;
6
6
  const isWithinThreshold = brushStrategy.createIsInThreshold?.(operationData);
7
7
  const { setValue } = brushStrategy;
8
8
  const callback = isWithinThreshold
9
9
  ? (data) => {
10
- const { value, index } = data;
11
- if (segmentsLocked.includes(value) || !isWithinThreshold(index)) {
10
+ if (!isWithinThreshold(data.index)) {
12
11
  return;
13
12
  }
14
13
  setValue(operationData, data);
@@ -4,7 +4,7 @@ import { getSegmentation } from '../../../../stateManagement/segmentation/getSeg
4
4
  import { getSegmentIndexForLabelValue } from '../../../../stateManagement/segmentation/helpers/labelmapSegmentationState.js';
5
5
  export default {
6
6
  [StrategyCallbacks.INTERNAL_setValue]: (operationData, { value, index }) => {
7
- const { segmentsLocked, previewSegmentIndex, memo, segmentationVoxelManager, centerSegmentIndexInfo, segmentIndex, labelValue, labelmapId, segmentationId, } = operationData;
7
+ const { segmentsLocked, previewSegmentIndex, memo, segmentationVoxelManager, centerSegmentIndexInfo, segmentIndex, labelValue, labelmapId, segmentationId, labelmapEditTransaction, } = operationData;
8
8
  const existingValue = segmentationVoxelManager.getAtIndex(index);
9
9
  const segmentation = getSegmentation(segmentationId);
10
10
  const existingSegmentIndex = segmentation && labelmapId
@@ -14,6 +14,10 @@ export default {
14
14
  if (segmentsLocked.includes(existingSegmentIndex)) {
15
15
  return;
16
16
  }
17
+ if (writeValue &&
18
+ labelmapEditTransaction?.lockedVoxelsOnOtherLayers?.some(({ voxelManager, labelValues }) => labelValues.has(voxelManager.getAtIndex(index)))) {
19
+ return;
20
+ }
17
21
  if (!centerSegmentIndexInfo &&
18
22
  existingValue === (labelValue ?? segmentIndex)) {
19
23
  return;
@@ -1,5 +1,5 @@
1
1
  import { getSegmentation } from '../../../../stateManagement/segmentation/getSegmentation.js';
2
- import { beginLabelmapEditTransaction, resolveLabelmapLayerEditTarget, } from '../../../../stateManagement/segmentation/helpers/labelmapSegmentationState.js';
2
+ import { beginLabelmapEditTransaction, getLockedVoxelsOnOtherLayers, resolveLabelmapLayerEditTarget, } from '../../../../stateManagement/segmentation/helpers/labelmapSegmentationState.js';
3
3
  import { eraseCrossLayerOverwrites } from './crossLayerErase.js';
4
4
  import { resolveOverwriteSegmentIndices } from './overwritePolicy.js';
5
5
  function prepareOverlapOperationData(operationData) {
@@ -12,6 +12,7 @@ function prepareOverlapOperationData(operationData) {
12
12
  const transaction = beginLabelmapEditTransaction(segmentation, {
13
13
  segmentIndex: operationData.segmentIndex,
14
14
  overwriteSegmentIndices: operationData.overwriteSegmentIndices,
15
+ segmentsLocked: operationData.segmentsLocked,
15
16
  segmentationVoxelManager: operationData.segmentationVoxelManager,
16
17
  segmentationImageData: operationData.segmentationImageData,
17
18
  isInObject: operationData.isInObject,
@@ -37,5 +38,10 @@ function prepareOverlapOperationData(operationData) {
37
38
  operationData.segmentationVoxelManager = target.voxelManager;
38
39
  }
39
40
  }
41
+ transaction.lockedVoxelsOnOtherLayers = getLockedVoxelsOnOtherLayers(segmentation, transaction.labelmapId, operationData.segmentsLocked, {
42
+ viewport: operationData.viewport,
43
+ imageId: operationData.imageId,
44
+ sourceLayer: transaction.activeLayer,
45
+ });
40
46
  }
41
47
  export { eraseCrossLayerOverwrites, prepareOverlapOperationData };
@@ -1 +1 @@
1
- export declare const version = "5.11.7";
1
+ export declare const version = "5.12.1";
@@ -1 +1 @@
1
- export const version = '5.11.7';
1
+ export const version = '5.12.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "5.11.7",
3
+ "version": "5.12.1",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -126,11 +126,11 @@
126
126
  "lodash.get": "4.4.2"
127
127
  },
128
128
  "devDependencies": {
129
- "@cornerstonejs/core": "5.11.7",
129
+ "@cornerstonejs/core": "5.12.1",
130
130
  "canvas": "3.2.0"
131
131
  },
132
132
  "peerDependencies": {
133
- "@cornerstonejs/core": "5.11.7",
133
+ "@cornerstonejs/core": "5.12.1",
134
134
  "@kitware/vtk.js": "36.4.1",
135
135
  "@types/d3-array": "3.2.1",
136
136
  "@types/d3-interpolate": "3.0.4",
@@ -1,3 +0,0 @@
1
- import type { InitializedOperationData } from '../BrushStrategy.js';
2
- declare function separateSegmentIfNeeded(operationData: InitializedOperationData): void;
3
- export { separateSegmentIfNeeded };
@@ -1,38 +0,0 @@
1
- import { getSegmentation } from '../../../../stateManagement/segmentation/getSegmentation.js';
2
- import { beginLabelmapEditTransaction, resolveLabelmapLayerEditTarget, } from '../../../../stateManagement/segmentation/helpers/labelmapSegmentationState.js';
3
- function separateSegmentIfNeeded(operationData) {
4
- const segmentation = getSegmentation(operationData.segmentationId);
5
- if (!segmentation || !operationData.segmentIndex) {
6
- return;
7
- }
8
- const transaction = beginLabelmapEditTransaction(segmentation, {
9
- segmentIndex: operationData.segmentIndex,
10
- overwriteSegmentIndices: operationData.overwriteSegmentIndices,
11
- segmentationVoxelManager: operationData.segmentationVoxelManager,
12
- segmentationImageData: operationData.segmentationImageData,
13
- isInObject: operationData.isInObject,
14
- isInObjectBoundsIJK: operationData.isInObjectBoundsIJK,
15
- });
16
- operationData.labelmapEditTransaction = transaction;
17
- operationData.labelmapId = transaction.labelmapId;
18
- operationData.labelValue = transaction.labelValue;
19
- operationData.crossLayerEraseBindings = transaction.crossLayerEraseBindings;
20
- if (!transaction.movedSegment || !transaction.activeLayer) {
21
- return;
22
- }
23
- const target = resolveLabelmapLayerEditTarget(transaction.activeLayer, {
24
- viewport: operationData.viewport,
25
- imageId: operationData.imageId,
26
- sourceLayer: transaction.sourceLayer,
27
- });
28
- if (target.imageId) {
29
- operationData.imageId = target.imageId;
30
- }
31
- if (target.imageData) {
32
- operationData.segmentationImageData = target.imageData;
33
- }
34
- if (target.voxelManager) {
35
- operationData.segmentationVoxelManager = target.voxelManager;
36
- }
37
- }
38
- export { separateSegmentIfNeeded };