All files / extensions/cornerstone/src/utils isAnyDisplaySetCommon.ts

100% Statements 2/2
100% Branches 0/0
100% Functions 2/2
100% Lines 1/1

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                                62x    
/**
 * Checks whether two viewports share at least one common display set.
 *
 * This method checks to see if the source and target share a display set.
 * It performs an O(n * m) comparison between the display sets of each viewport.
 * Since each viewport typically contains only a small number of display sets (≤ 5),
 * the computational cost is negligible.
 *
 * @param sourceDisplaySetUIDs - Array of displaySetInstanceUID from the source viewport.
 * @param targetDisplaySetUIDs - Array of displaySetInstanceUID from the target viewport.
 * @returns true if at least one display set is common; false otherwise.
 */
export function isAnyDisplaySetCommon(
  sourceDisplaySetUIDs: string[],
  targetDisplaySetUIDs: string[]
): boolean {
  return sourceDisplaySetUIDs.some(uid => targetDisplaySetUIDs.includes(uid));
}