Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 1x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 90x 9x 9x 9x 9x | import { cache } from '@cornerstonejs/core';
import triggerSegmentationRender from '../../utilities/triggerSegmentationRender';
import SegmentationRepresentations from '../../enums/SegmentationRepresentations';
import * as SegmentationState from '../../stateManagement/segmentation/segmentationState';
import { SegmentationDataModifiedEventType } from '../../types/EventTypes';
/** A callback function that is called when the segmentation data is modified which
* often is as a result of tool interactions e.g., scissors, eraser, etc.
*/
const onSegmentationDataModified = function (
evt: SegmentationDataModifiedEventType
): void {
const { segmentationId, modifiedSlicesToUse } = evt.detail;
const { representationData, type } =
SegmentationState.getSegmentation(segmentationId);
let toolGroupIds;
Eif (type === SegmentationRepresentations.Labelmap) {
// get the volume from cache, we need the openGLTexture to be updated to GPU
const segmentationVolume = cache.getVolume(
representationData[type].volumeId
);
Iif (!segmentationVolume) {
console.warn('segmentation not found in cache');
return;
}
const { imageData, vtkOpenGLTexture } = segmentationVolume;
// Update the texture for the volume in the GPU
let slicesToUpdate;
Iif (modifiedSlicesToUse && Array.isArray(modifiedSlicesToUse)) {
slicesToUpdate = modifiedSlicesToUse;
} else {
const numSlices = imageData.getDimensions()[2];
slicesToUpdate = [...Array(numSlices).keys()];
}
slicesToUpdate.forEach((i) => {
vtkOpenGLTexture.setUpdatedFrame(i);
});
// Trigger modified on the imageData to update the image
imageData.modified();
toolGroupIds =
SegmentationState.getToolGroupsWithSegmentation(segmentationId);
} else {
throw new Error(
`onSegmentationDataModified: representationType ${type} not supported yet`
);
}
toolGroupIds.forEach((toolGroupId) => {
triggerSegmentationRender(toolGroupId);
});
};
export default onSegmentationDataModified;
|