@@ -11,6 +11,11 @@ import { performStackLabelmapUpdate } from './performStackLabelmapUpdate';
1111import { getSegmentation } from '../../../stateManagement/segmentation/getSegmentation' ;
1212import { getViewportIdsWithSegmentation } from '../../../stateManagement/segmentation/getViewportIdsWithSegmentation' ;
1313
14+ const getViewportByViewportId = ( viewportId : string ) => {
15+ const enabledElement = getEnabledElementByViewportId ( viewportId ) ;
16+ return enabledElement ?. viewport ?? undefined ;
17+ } ;
18+
1419/** A callback function that is called when the segmentation data is modified which
1520 * often is as a result of tool interactions e.g., scissors, eraser, etc.
1621 */
@@ -24,19 +29,19 @@ const onLabelmapSegmentationDataModified = function (
2429 const viewportIds = getViewportIdsWithSegmentation ( segmentationId ) ;
2530
2631 const hasVolumeViewport = viewportIds . some ( ( viewportId ) => {
27- const { viewport } = getEnabledElementByViewportId ( viewportId ) ;
32+ const viewport = getViewportByViewportId ( viewportId ) ;
2833 return viewport instanceof VolumeViewport ;
2934 } ) ;
3035
3136 const hasStackViewport = viewportIds . some ( ( viewportId ) => {
32- const { viewport } = getEnabledElementByViewportId ( viewportId ) ;
37+ const viewport = getViewportByViewportId ( viewportId ) ;
3338 return viewport instanceof StackViewport ;
3439 } ) ;
3540
3641 const hasBothStackAndVolume = hasVolumeViewport && hasStackViewport ;
3742
3843 viewportIds . forEach ( ( viewportId ) => {
39- const { viewport } = getEnabledElementByViewportId ( viewportId ) ;
44+ const viewport = getViewportByViewportId ( viewportId ) ;
4045
4146 if ( viewport instanceof VolumeViewport ) {
4247 // For combined stack and volume scenarios in the rendering engine, updating only affected
0 commit comments