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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | import { IVolumeViewport } from '../types'; import { getRenderingEngines, getRenderingEngine, } from '../RenderingEngine/getRenderingEngine'; /** * Returns the viewports containing the same volume actors (all actors) the same * as the target viewport. If renderingEngineId is provided, it will only return * viewports that are associated with the renderingEngineId; otherwise, it will * return search in all rendering engines. * * This method is useful for finding viewports that are associated with the same * volume (e.g., for tools that share state between viewports). * * @param viewport - target viewport * @returns array of viewports that have the same volume actor as the target viewport */ function getVolumeViewportsContainingSameVolumes( targetViewport: IVolumeViewport, renderingEngineId?: string ): Array<IVolumeViewport> { // If rendering engine is not provided, use all rendering engines let renderingEngines; if (renderingEngineId) { renderingEngines = [getRenderingEngine(renderingEngineId)]; } else { renderingEngines = getRenderingEngines(); } const sameVolumesViewports = []; renderingEngines.forEach((renderingEngine) => { const targetActors = targetViewport.getActors(); const viewports = renderingEngine.getVolumeViewports(); for (const vp of viewports) { const vpActors = vp.getActors(); if (vpActors.length !== targetActors.length) { continue; } // every targetActors should be in the vpActors const sameVolumes = targetActors.every(({ uid }) => vpActors.find((vpActor) => uid === vpActor.uid) ); if (sameVolumes) { sameVolumesViewports.push(vp); } } }); return sameVolumesViewports; } export default getVolumeViewportsContainingSameVolumes; |