All files / core/src/utilities getViewportsWithVolumeId.ts

100% Statements 8/8
100% Branches 0/0
100% Functions 3/3
100% Lines 8/8

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                      4046x   4046x   4046x 4046x 4046x 10080x   4046x     4046x        
import type { IVolumeViewport } from '../types';
import { getRenderingEngines } from '../RenderingEngine/getRenderingEngine';
 
/**
 * Retrieves viewports containing a specific volume ID.
 *
 * @param volumeId - The ID of the volume to search for within viewports.
 * @returns An array of volume viewports that contain the specified volume ID.
 */
function getViewportsWithVolumeId(volumeId: string): IVolumeViewport[] {
  // If rendering engine is not provided, use all rendering engines
  const renderingEngines = getRenderingEngines();
 
  const targetViewports: IVolumeViewport[] = [];
 
  renderingEngines.forEach((renderingEngine) => {
    const viewports = renderingEngine.getVolumeViewports();
    const filteredViewports = viewports.filter((vp) =>
      vp.hasVolumeId(volumeId)
    );
    targetViewports.push(...filteredViewports);
  });
 
  return targetViewports;
}
 
export default getViewportsWithVolumeId;