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

100% Statements 10/10
100% Branches 2/2
100% Functions 4/4
100% Lines 10/10

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                            23x 22x   23x               17x                               6x   6x     23x 6x 6x 6x      
import { Types } from '@cornerstonejs/core';
import BaseStreamingImageVolume from './BaseStreamingImageVolume';
import ImageLoadRequests from './types/ImageLoadRequests';
 
/**
 * 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.ImageVolumeProps,
    streamingProperties: Types.IStreamingVolumeProperties
  ) {
    // Just for fallback to the old API
    if (!imageVolumeProperties.imageIds) {
      imageVolumeProperties.imageIds = streamingProperties.imageIds;
    }
    super(imageVolumeProperties, streamingProperties);
  }
 
  /**
   * Return the scalar data (buffer)
   * @returns volume scalar data
   */
  public getScalarData(): Types.PixelDataTypedArray {
    return <Types.PixelDataTypedArray>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): ImageLoadRequests[] {
    const { imageIds } = this;
 
    return this.getImageIdsRequests(imageIds, priority);
  }
 
  public getImageIdsToLoad = () => {
    const { imageIds } = this;
    this.numFrames = imageIds.length;
    return imageIds;
  };
}