All files / packages/streaming-image-volume-loader/src StreamingImageVolume.ts

100% Statements 13/13
100% Branches 0/0
100% Functions 4/4
100% Lines 11/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              2x       23x 23x     1x         5x 1x   23x                         6x 6x   6x 23x    
import { Types } from '@cornerstonejs/core';
import BaseStreamingImageVolume from './BaseStreamingImageVolume';
 
/**
 * Streaming Image Volume Class that extends ImageVolume base class.
 * It implements load method to load the imageIds and insert them into the volume.
 */
export default class StreamingImageVolume extends BaseStreamingImageVolume {
  constructor(
    imageVolumeProperties: Types.IVolume,
    streamingProperties: Types.IStreamingVolumeProperties
  ) {
    super(imageVolumeProperties, streamingProperties);
  }
 
  /**
   * Return the scalar data (buffer)
   * @returns volume scalar data
   */
  public getScalarData(): Types.VolumeScalarData {
    return <Types.VolumeScalarData>this.scalarData;
  }
 
  /**
   * It returns the imageLoad requests for the streaming image volume instance.
   * It involves getting all the imageIds of the volume and creating a success callback
   * which would update the texture (when the image has loaded) and the failure callback.
   * Note that this method does not executes the requests but only returns the requests.
   * It can be used for sorting requests outside of the volume loader itself
   * e.g. loading a single slice of CT, followed by a single slice of PET (interleaved), before
   * moving to the next slice.
   *
   * @returns Array of requests including imageId of the request, its imageIdIndex,
   * options (targetBuffer and scaling parameters), and additionalDetails (volumeId)
   */
  public getImageLoadRequests = (priority: number) => {
    const { imageIds } = this;
    const scalarData = <Types.VolumeScalarData>this.scalarData;
 
    return this.getImageIdsRequests(imageIds, scalarData, priority);
  };
}