All files / packages/core/src/utilities getViewportsWithVolumeId.ts

90% Statements 9/10
50% Branches 1/2
100% Functions 3/3
88.88% Lines 8/9

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 29 30 31 32 33 34 35 36 37 38 39                                    7x 7x         7x   7x 7x 8x     7x     7x        
import { IVolumeViewport } from '../types';
import {
  getRenderingEngines,
  getRenderingEngine,
} from '../RenderingEngine/getRenderingEngine';
 
/**
 * Similar to {@link getVolumeViewportsContainingSameVolumes}, but uses the volumeId
 * to filter viewports that contain the same volume.
 *
 * @returns VolumeViewport viewports array
 */
function getViewportsWithVolumeId(
  volumeId: string,
  renderingEngineId?: string
): Array<IVolumeViewport> {
  // If rendering engine is not provided, use all rendering engines
  let renderingEngines;
  Eif (renderingEngineId) {
    renderingEngines = [getRenderingEngine(renderingEngineId)];
  } else {
    renderingEngines = getRenderingEngines();
  }
 
  const targetViewports = [];
 
  renderingEngines.forEach((renderingEngine) => {
    const viewports = renderingEngine.getVolumeViewports();
    const filteredViewports = viewports.filter((vp) =>
      vp.hasVolumeId(volumeId)
    );
    targetViewports.push(...filteredViewports);
  });
 
  return targetViewports;
}
 
export default getViewportsWithVolumeId;