@@ -75,38 +75,6 @@ export default class SegmentationStateManager {
75
75
this . uid = uid ;
76
76
}
77
77
78
- /**
79
- * Generates a key for the _labelmapImageIdReferenceMap
80
- * @param param0.segmentationId
81
- * @param param0.imageId
82
- */
83
- generateMapKey ( { segmentationId, imageId } ) {
84
- return `${ segmentationId } -${ imageId } ` ;
85
- }
86
-
87
- /**
88
- * Updates the _labelmapImageIdReferenceMap according to the correct key and preserving old values
89
- * @param param0.segmentationId
90
- * @param param0.imageId
91
- * @param param0.labelmapImageId
92
- */
93
- _updateLabelmapImageIdReferenceMap ( {
94
- segmentationId,
95
- imageId,
96
- labelmapImageId,
97
- } ) {
98
- const key = this . generateMapKey ( { segmentationId, imageId } ) ;
99
-
100
- if ( ! this . _labelmapImageIdReferenceMap . has ( key ) ) {
101
- this . _labelmapImageIdReferenceMap . set ( key , [ labelmapImageId ] ) ;
102
- return ;
103
- }
104
-
105
- const currentValues = this . _labelmapImageIdReferenceMap . get ( key ) ;
106
- const newValues = Array . from ( new Set ( [ ...currentValues , labelmapImageId ] ) ) ;
107
- this . _labelmapImageIdReferenceMap . set ( key , newValues ) ;
108
- }
109
-
110
78
/**
111
79
* Returns a copy of the current state of the segmentation.
112
80
*/
@@ -488,7 +456,7 @@ export default class SegmentationStateManager {
488
456
labelmapImageIds ,
489
457
updateCallback
490
458
) : string | undefined {
491
- const currentImageId = viewport . getCurrentImageId ( ) ;
459
+ const referenceImageId = viewport . getCurrentImageId ( ) ;
492
460
493
461
let viewableLabelmapImageIdFound = false ;
494
462
for ( const labelmapImageId of labelmapImageIds ) {
@@ -501,10 +469,10 @@ export default class SegmentationStateManager {
501
469
viewableLabelmapImageIdFound = true ;
502
470
this . _stackLabelmapImageIdReferenceMap
503
471
. get ( segmentationId )
504
- . set ( currentImageId , labelmapImageId ) ;
472
+ . set ( referenceImageId , labelmapImageId ) ;
505
473
this . _updateLabelmapImageIdReferenceMap ( {
506
474
segmentationId,
507
- imageId : currentImageId ,
475
+ referenceImageId ,
508
476
labelmapImageId,
509
477
} ) ;
510
478
}
@@ -517,7 +485,7 @@ export default class SegmentationStateManager {
517
485
return viewableLabelmapImageIdFound
518
486
? this . _stackLabelmapImageIdReferenceMap
519
487
. get ( segmentationId )
520
- . get ( currentImageId )
488
+ . get ( referenceImageId )
521
489
: undefined ;
522
490
}
523
491
@@ -585,7 +553,7 @@ export default class SegmentationStateManager {
585
553
labelmapImageIds ,
586
554
( stackViewport , segmentationId , labelmapImageIds ) => {
587
555
const imageIds = stackViewport . getImageIds ( ) ;
588
- imageIds . forEach ( ( imageId , index ) => {
556
+ imageIds . forEach ( ( referenceImageId , index ) => {
589
557
for ( const labelmapImageId of labelmapImageIds ) {
590
558
const viewableImageId = stackViewport . isReferenceViewable (
591
559
{ referencedImageId : labelmapImageId , sliceIndex : index } ,
@@ -595,10 +563,10 @@ export default class SegmentationStateManager {
595
563
if ( viewableImageId ) {
596
564
this . _stackLabelmapImageIdReferenceMap
597
565
. get ( segmentationId )
598
- . set ( imageId , labelmapImageId ) ;
566
+ . set ( referenceImageId , labelmapImageId ) ;
599
567
this . _updateLabelmapImageIdReferenceMap ( {
600
568
segmentationId,
601
- imageId ,
569
+ referenceImageId ,
602
570
labelmapImageId,
603
571
} ) ;
604
572
}
@@ -638,13 +606,13 @@ export default class SegmentationStateManager {
638
606
}
639
607
640
608
/**
641
- * Retrieves the stack labelmap imageId associated with the current imageId
609
+ * Retrieves the stack labelmap imageIds associated with the current imageId
642
610
* that is rendered on the viewport.
643
611
* @param viewportId - The ID of the viewport.
644
612
* @param segmentationId - The UID of the segmentation representation.
645
613
* @returns A Map object containing the image ID reference map, or undefined if the enabled element is not found.
646
614
*/
647
- getCurrentLabelmapImageIdForViewportOverlapping (
615
+ getCurrentLabelmapImageIdsForViewport (
648
616
viewportId : string ,
649
617
segmentationId : string
650
618
) : string [ ] | undefined {
@@ -655,11 +623,11 @@ export default class SegmentationStateManager {
655
623
}
656
624
657
625
const stackViewport = enabledElement . viewport as Types . IStackViewport ;
658
- const currentImageId = stackViewport . getCurrentImageId ( ) ;
626
+ const referenceImageId = stackViewport . getCurrentImageId ( ) ;
659
627
660
- const key = this . generateMapKey ( {
628
+ const key = this . _generateMapKey ( {
661
629
segmentationId,
662
- imageId : currentImageId ,
630
+ referenceImageId ,
663
631
} ) ;
664
632
return this . _labelmapImageIdReferenceMap . get ( key ) ;
665
633
}
@@ -891,6 +859,29 @@ export default class SegmentationStateManager {
891
859
return removedRepresentations ;
892
860
}
893
861
862
+ /**
863
+ * Updates the _labelmapImageIdReferenceMap according to the correct key and preserving old values
864
+ * @param segmentationId
865
+ * @param referenceImageId
866
+ * @param labelmapImageId
867
+ */
868
+ _updateLabelmapImageIdReferenceMap ( {
869
+ segmentationId,
870
+ referenceImageId,
871
+ labelmapImageId,
872
+ } ) {
873
+ const key = this . _generateMapKey ( { segmentationId, referenceImageId } ) ;
874
+
875
+ if ( ! this . _labelmapImageIdReferenceMap . has ( key ) ) {
876
+ this . _labelmapImageIdReferenceMap . set ( key , [ labelmapImageId ] ) ;
877
+ return ;
878
+ }
879
+
880
+ const currentValues = this . _labelmapImageIdReferenceMap . get ( key ) ;
881
+ const newValues = Array . from ( new Set ( [ ...currentValues , labelmapImageId ] ) ) ;
882
+ this . _labelmapImageIdReferenceMap . set ( key , newValues ) ;
883
+ }
884
+
894
885
_setActiveSegmentation (
895
886
state : SegmentationState ,
896
887
viewportId : string ,
@@ -1158,6 +1149,15 @@ export default class SegmentationStateManager {
1158
1149
1159
1150
return result ;
1160
1151
}
1152
+
1153
+ /**
1154
+ * Generates a key for the _labelmapImageIdReferenceMap
1155
+ * @param segmentationId - The ID of the segmentation
1156
+ * @param referenceImageId - The reference image ID - this is the imageId that is currently being displayed in the viewport (not the derived imageId)
1157
+ */
1158
+ private _generateMapKey ( { segmentationId, referenceImageId } ) {
1159
+ return `${ segmentationId } -${ referenceImageId } ` ;
1160
+ }
1161
1161
}
1162
1162
1163
1163
async function internalComputeVolumeLabelmapFromStack ( {
0 commit comments