diff --git a/common/reviews/api/dicom-image-loader.api.md b/common/reviews/api/dicom-image-loader.api.md index a5f05ff06d..8fa0a1d1b1 100644 --- a/common/reviews/api/dicom-image-loader.api.md +++ b/common/reviews/api/dicom-image-loader.api.md @@ -124,12 +124,16 @@ const cornerstoneDICOMImageLoader: { setOptions: setOptions; getOptions: getOptions; }; + decodeImageFrame: typeof decodeImageFrame; }; export default cornerstoneDICOMImageLoader; // @public (undocumented) export function createImage(imageId: string, pixelData: ByteArray, transferSyntax: string, options?: DICOMLoaderImageOptions): Promise; +// @public (undocumented) +export function decodeImageFrame(imageFrame: any, transferSyntax: any, pixelData: any, decodeConfig: any, options: any, callbackFn: any): Promise; + // @public (undocumented) export function decodeJPEGBaseline8BitColor(imageFrame: Types_2.IImageFrame, pixelData: ByteArray, canvas: HTMLCanvasElement): Promise; diff --git a/packages/core/src/RenderingEngine/vtkClasses/vtkStreamingOpenGLTexture.js b/packages/core/src/RenderingEngine/vtkClasses/vtkStreamingOpenGLTexture.js index f91e11d249..3c1d6eab53 100644 --- a/packages/core/src/RenderingEngine/vtkClasses/vtkStreamingOpenGLTexture.js +++ b/packages/core/src/RenderingEngine/vtkClasses/vtkStreamingOpenGLTexture.js @@ -56,6 +56,15 @@ function vtkStreamingOpenGLTexture(publicAPI, model) { ); }; + const superUpdate = publicAPI.updateVolumeInfoForGL; + + publicAPI.updateVolumeInfoForGL = (dataType, numComps) => { + const isScalingApplied = superUpdate(dataType, numComps); + model.volumeInfo.dataComputedScale = [1]; + model.volumeInfo.dataComputedOffset = [0]; + return isScalingApplied; + }; + /** * This function updates the GPU texture memory to match the current * representation of data held in RAM. diff --git a/packages/core/src/utilities/VoxelManager.ts b/packages/core/src/utilities/VoxelManager.ts index 6fe9940ccd..ce9f3498dd 100644 --- a/packages/core/src/utilities/VoxelManager.ts +++ b/packages/core/src/utilities/VoxelManager.ts @@ -796,6 +796,11 @@ export default class VoxelManager { for (const imageId of imageIds) { const image = cache.getImage(imageId); + // Skip if image not loaded yet + if (!image) { + continue; + } + // min and max pixel value is correct, //todo this is not true // for dynamically changing data such as labelmaps in segmentation if (image.minPixelValue < minValue) { @@ -805,6 +810,12 @@ export default class VoxelManager { maxValue = image.maxPixelValue; } } + + // If no images were loaded yet, return default range + if (minValue === Infinity && maxValue === -Infinity) { + return [0, 0]; + } + return [minValue, maxValue]; }; diff --git a/packages/dicomImageLoader/src/decodeImageFrameWorker.js b/packages/dicomImageLoader/src/decodeImageFrameWorker.js index c3f29ab9d6..708a8a491b 100644 --- a/packages/dicomImageLoader/src/decodeImageFrameWorker.js +++ b/packages/dicomImageLoader/src/decodeImageFrameWorker.js @@ -304,7 +304,7 @@ function scaleImageFrame(imageFrame, targetBuffer, TypedArrayConstructor) { * This is an async function return the result, or you can provide an optional * callbackFn that is called with the results. */ -async function decodeImageFrame( +export async function decodeImageFrame( imageFrame, transferSyntax, pixelData, diff --git a/packages/dicomImageLoader/src/index.ts b/packages/dicomImageLoader/src/index.ts index 6f69c81cad..ad9eb21731 100644 --- a/packages/dicomImageLoader/src/index.ts +++ b/packages/dicomImageLoader/src/index.ts @@ -20,6 +20,7 @@ import { default as getPixelData } from './imageLoader/wadors/getPixelData'; import { internal } from './imageLoader/internal/index'; import * as constants from './constants'; import type * as Types from './types'; +import { decodeImageFrame } from './decodeImageFrameWorker'; const cornerstoneDICOMImageLoader = { constants, @@ -40,6 +41,7 @@ const cornerstoneDICOMImageLoader = { isColorImage, isJPEGBaseline8BitColor, internal, + decodeImageFrame, }; export { @@ -61,6 +63,7 @@ export { isColorImage, isJPEGBaseline8BitColor, internal, + decodeImageFrame, }; export type { Types }; diff --git a/packages/tools/src/tools/TrackballRotateTool.ts b/packages/tools/src/tools/TrackballRotateTool.ts index 6f80fb7ba6..07b2bb9da3 100644 --- a/packages/tools/src/tools/TrackballRotateTool.ts +++ b/packages/tools/src/tools/TrackballRotateTool.ts @@ -103,7 +103,12 @@ class TrackballRotateTool extends BaseTool { return; } const { viewport } = element; + + const viewPresentation = viewport.getViewPresentation(); + viewport.resetCamera(); + + viewport.setViewPresentation(viewPresentation); viewport.render(); });