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 | 126x 8x 8x 8x 118x 118x 118x 118x 118x 120x 120x 120x | import {
StackViewport,
VolumeViewport,
Types,
utilities as csUtils,
} from '@cornerstonejs/core';
import filterAnnotationsWithinSlice from './filterAnnotationsWithinSlice';
import type { Annotations } from '../../types';
/**
* Given the viewport and the annotations, it filters the annotations array and only
* return those annotation that should be displayed on the viewport
* @param annotations - Annotations
* @returns A filtered version of the annotations.
*/
export default function filterAnnotationsForDisplay(
viewport: Types.IViewport,
annotations: Annotations,
filterOptions: Types.ReferenceCompatibleOptions = {}
): Annotations {
if (viewport instanceof VolumeViewport) {
const camera = viewport.getCamera();
const { spacingInNormalDirection } =
csUtils.getTargetVolumeAndSpacingInNormalDir(viewport, camera);
// Get data with same normal and within the same slice
return filterAnnotationsWithinSlice(
annotations,
camera,
spacingInNormalDirection
);
}
Eif (viewport instanceof StackViewport) {
// 1. Get the currently displayed imageId from the StackViewport
const imageId = viewport.getCurrentImageId();
// 2. remove the dataLoader scheme since it might be an annotation that was
// created on the volumeViewport initially and has the volumeLoader scheme
// but shares the same imageId
const colonIndex = imageId.indexOf(':');
filterOptions.imageURI = imageId.substring(colonIndex + 1);
}
return annotations.filter((annotation) => {
Iif (!annotation.isVisible) {
return false;
}
Iif (annotation.data.isCanvasAnnotation) {
return true;
}
return viewport.isReferenceViewable(annotation.metadata, filterOptions);
});
}
|