diff --git a/extensions/cornerstone/src/utils/interleaveCenterLoader.ts b/extensions/cornerstone/src/utils/interleaveCenterLoader.ts index d8f64b5d838..16ed7eeebc7 100644 --- a/extensions/cornerstone/src/utils/interleaveCenterLoader.ts +++ b/extensions/cornerstone/src/utils/interleaveCenterLoader.ts @@ -51,18 +51,25 @@ export default function interleaveCenterLoader({ * listen to it and as the other viewports are created we can set the volumes for them * since volumes are already started loading. */ - if (matchDetails.size !== viewportIdVolumeInputArrayMap.size) { - return; - } + const uniqueViewportVolumeDisplaySetUIDs = new Set(); + viewportIdVolumeInputArrayMap.forEach((volumeInputArray, viewportId) => { + volumeInputArray.forEach(volumeInput => { + const { volumeId } = volumeInput; + uniqueViewportVolumeDisplaySetUIDs.add(volumeId); + }); + }); - // Check if all the matched volumes are loaded - for (const [_, details] of displaySetsMatchDetails.entries()) { - const { SeriesInstanceUID } = details; + const uniqueMatchedDisplaySetUIDs = new Set(); - // HangingProtocol has matched, but don't have all the volumes created yet, so return - if (!Array.from(volumeIdMapsToLoad.values()).includes(SeriesInstanceUID)) { - return; - } + matchDetails.forEach(matchDetail => { + const { displaySetsInfo } = matchDetail; + displaySetsInfo.forEach(({ displaySetInstanceUID }) => { + uniqueMatchedDisplaySetUIDs.add(displaySetInstanceUID); + }); + }); + + if (uniqueViewportVolumeDisplaySetUIDs.size !== uniqueMatchedDisplaySetUIDs.size) { + return; } const volumeIds = Array.from(volumeIdMapsToLoad.keys()).slice(); diff --git a/extensions/cornerstone/src/utils/interleaveTopToBottom.ts b/extensions/cornerstone/src/utils/interleaveTopToBottom.ts index a0d1e4fb6fd..fc5447a423b 100644 --- a/extensions/cornerstone/src/utils/interleaveTopToBottom.ts +++ b/extensions/cornerstone/src/utils/interleaveTopToBottom.ts @@ -75,21 +75,25 @@ export default function interleaveTopToBottom({ * listen to it and as the other viewports are created we can set the volumes for them * since volumes are already started loading. */ - if (filteredMatchDetails.length !== viewportIdVolumeInputArrayMap.size) { - return; - } + const uniqueViewportVolumeDisplaySetUIDs = new Set(); + viewportIdVolumeInputArrayMap.forEach((volumeInputArray, viewportId) => { + volumeInputArray.forEach(volumeInput => { + const { volumeId } = volumeInput; + uniqueViewportVolumeDisplaySetUIDs.add(volumeId); + }); + }); - // Check if all the matched volumes are loaded - for (const [_, details] of displaySetsMatchDetails.entries()) { - const { SeriesInstanceUID, displaySetInstanceUID } = details; + const uniqueMatchedDisplaySetUIDs = new Set(); - // HangingProtocol has matched, but don't have all the volumes created yet, so return - if ( - displaySetsToLoad.has(displaySetInstanceUID) && - !Array.from(volumeIdMapsToLoad.values()).includes(SeriesInstanceUID) - ) { - return; - } + matchDetails.forEach(matchDetail => { + const { displaySetsInfo } = matchDetail; + displaySetsInfo.forEach(({ displaySetInstanceUID }) => { + uniqueMatchedDisplaySetUIDs.add(displaySetInstanceUID); + }); + }); + + if (uniqueViewportVolumeDisplaySetUIDs.size !== uniqueMatchedDisplaySetUIDs.size) { + return; } const volumeIds = Array.from(volumeIdMapsToLoad.keys()).slice();