All files / core/src/RenderingEngine/GenericViewport/Planar planarActorCompatibility.ts

0% Statements 0/11
0% Branches 0/4
0% Functions 0/2
0% Lines 0/11

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 60 61 62 63 64                                                                                                                               
import vtkImageMapper from '@kitware/vtk.js/Rendering/Core/ImageMapper';
import vtkImageSlice from '@kitware/vtk.js/Rendering/Core/ImageSlice';
import CanvasActor from '../../CanvasActor';
import { ActorRenderMode } from '../../../types';
import type { ActorEntry, IImage, IStackInput } from '../../../types';
import type { IViewport } from '../../../types/IViewport';
import uuidv4 from '../../../utilities/uuidv4';
import { createVTKImageDataFromImage } from '../../helpers/planarImageRendering';
import type { LoadedData } from '../ViewportArchitectureTypes';
import type { PlanarPayload } from './PlanarViewportTypes';
import type { PlanarRendering } from './planarRuntimeTypes';
 
export function createPlanarImageOverlayActorEntry(
  image: IImage,
  stackInput: IStackInput
): ActorEntry {
  const mapper = vtkImageMapper.newInstance();
  const actor = vtkImageSlice.newInstance();
  const imageData = createVTKImageDataFromImage(image);
 
  mapper.setInputData(imageData);
  actor.setMapper(mapper);
 
  if (typeof stackInput.visibility === 'boolean') {
    actor.setVisibility(stackInput.visibility);
  }
 
  return {
    uid: uuidv4(),
    actor,
    actorMapper: {
      actor,
      mapper,
      renderMode: ActorRenderMode.VTK_IMAGE,
    },
    referencedId: image.imageId,
    ...stackInput,
  };
}
 
export function createPlanarCpuImageOverlayActorEntry(
  viewport: IViewport,
  image: IImage,
  stackInput: IStackInput
): ActorEntry {
  const actor = new CanvasActor(viewport, image);
 
  actor.setVisibility(
    typeof stackInput.visibility === 'boolean' ? stackInput.visibility : true
  );
 
  return {
    uid: uuidv4(),
    actor,
    actorMapper: {
      actor,
      mapper: actor.getMapper(),
      renderMode: ActorRenderMode.CPU_IMAGE,
    },
    referencedId: image.imageId,
    ...stackInput,
  };
}