@cornerstonejs/core 2.0.0-beta.2 → 2.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/RenderingEngine/StackViewport.js +3 -4
- package/dist/cjs/RenderingEngine/StackViewport.js.map +1 -1
- package/dist/cjs/RenderingEngine/Viewport.js +8 -9
- package/dist/cjs/RenderingEngine/Viewport.js.map +1 -1
- package/dist/cjs/RenderingEngine/VolumeViewport.js +13 -0
- package/dist/cjs/RenderingEngine/VolumeViewport.js.map +1 -1
- package/dist/cjs/RenderingEngine/helpers/cpuFallback/rendering/correctShift.d.ts +1 -1
- package/dist/cjs/RenderingEngine/vtkClasses/vtkStreamingOpenGLVolumeMapper.js +1 -0
- package/dist/cjs/RenderingEngine/vtkClasses/vtkStreamingOpenGLVolumeMapper.js.map +1 -1
- package/dist/cjs/Settings.js +3 -1
- package/dist/cjs/Settings.js.map +1 -1
- package/dist/cjs/cache/cache.d.ts +3 -1
- package/dist/cjs/cache/cache.js +12 -7
- package/dist/cjs/cache/cache.js.map +1 -1
- package/dist/cjs/cache/classes/Contour.d.ts +1 -1
- package/dist/cjs/cache/classes/ContourSet.d.ts +1 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/loaders/geometryLoader.d.ts +1 -1
- package/dist/cjs/loaders/volumeLoader.js +2 -3
- package/dist/cjs/loaders/volumeLoader.js.map +1 -1
- package/dist/cjs/requestPool/requestPoolManager.d.ts +3 -3
- package/dist/cjs/types/ActorSliceRange.d.ts +1 -1
- package/dist/cjs/types/AffineMatrix.d.ts +1 -1
- package/dist/cjs/types/CPUFallbackColormapData.d.ts +1 -1
- package/dist/cjs/types/CPUFallbackColormapsData.d.ts +1 -1
- package/dist/cjs/types/CPUFallbackLUT.d.ts +1 -1
- package/dist/cjs/types/CPUFallbackRenderingTools.d.ts +1 -1
- package/dist/cjs/types/CPUFallbackViewport.d.ts +1 -1
- package/dist/cjs/types/CPUFallbackViewportDisplayedArea.d.ts +1 -1
- package/dist/cjs/types/CPUIImageData.d.ts +2 -2
- package/dist/cjs/types/Colormap.d.ts +3 -3
- package/dist/cjs/types/ContourData.d.ts +3 -3
- package/dist/cjs/types/Cornerstone3DConfig.d.ts +1 -1
- package/dist/cjs/types/EventTypes.d.ts +46 -46
- package/dist/cjs/types/FlipDirection.d.ts +1 -1
- package/dist/cjs/types/IActor.d.ts +4 -4
- package/dist/cjs/types/IImage.d.ts +2 -0
- package/dist/cjs/types/IViewport.d.ts +4 -4
- package/dist/cjs/types/IVolume.d.ts +1 -1
- package/dist/cjs/types/IVolumeInput.d.ts +1 -1
- package/dist/cjs/types/ImageLoaderFn.d.ts +1 -1
- package/dist/cjs/types/ImageSliceData.d.ts +1 -1
- package/dist/cjs/types/Mat3.d.ts +1 -1
- package/dist/cjs/types/Metadata.d.ts +1 -1
- package/dist/cjs/types/OrientationVectors.d.ts +1 -1
- package/dist/cjs/types/PixelDataTypedArray.d.ts +1 -1
- package/dist/cjs/types/Plane.d.ts +1 -1
- package/dist/cjs/types/Point2.d.ts +1 -1
- package/dist/cjs/types/Point3.d.ts +1 -1
- package/dist/cjs/types/Point4.d.ts +1 -1
- package/dist/cjs/types/RGB.d.ts +1 -1
- package/dist/cjs/types/ScalingParameters.d.ts +3 -3
- package/dist/cjs/types/StackViewportProperties.d.ts +1 -1
- package/dist/cjs/types/TransformMatrix2D.d.ts +1 -1
- package/dist/cjs/types/ViewportInputOptions.d.ts +1 -1
- package/dist/cjs/types/ViewportProperties.d.ts +1 -1
- package/dist/cjs/types/VolumeLoaderFn.d.ts +1 -1
- package/dist/cjs/types/VolumeViewportProperties.d.ts +1 -1
- package/dist/cjs/types/displayArea.d.ts +1 -1
- package/dist/cjs/types/voi.d.ts +2 -2
- package/dist/cjs/utilities/actorCheck.d.ts +1 -1
- package/dist/cjs/utilities/getViewportsWithImageURI.d.ts +1 -1
- package/dist/esm/RenderingEngine/StackViewport.js +3 -4
- package/dist/esm/RenderingEngine/StackViewport.js.map +1 -1
- package/dist/esm/RenderingEngine/Viewport.js +8 -9
- package/dist/esm/RenderingEngine/Viewport.js.map +1 -1
- package/dist/esm/RenderingEngine/VolumeViewport.js +15 -2
- package/dist/esm/RenderingEngine/VolumeViewport.js.map +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/correctShift.d.ts +1 -1
- package/dist/esm/RenderingEngine/vtkClasses/vtkStreamingOpenGLVolumeMapper.js +1 -0
- package/dist/esm/RenderingEngine/vtkClasses/vtkStreamingOpenGLVolumeMapper.js.map +1 -1
- package/dist/esm/Settings.js +3 -1
- package/dist/esm/Settings.js.map +1 -1
- package/dist/esm/cache/cache.d.ts +3 -1
- package/dist/esm/cache/cache.js +12 -7
- package/dist/esm/cache/cache.js.map +1 -1
- package/dist/esm/cache/classes/Contour.d.ts +1 -1
- package/dist/esm/cache/classes/ContourSet.d.ts +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loaders/geometryLoader.d.ts +1 -1
- package/dist/esm/loaders/volumeLoader.js +2 -3
- package/dist/esm/loaders/volumeLoader.js.map +1 -1
- package/dist/esm/requestPool/requestPoolManager.d.ts +3 -3
- package/dist/esm/types/ActorSliceRange.d.ts +1 -1
- package/dist/esm/types/AffineMatrix.d.ts +1 -1
- package/dist/esm/types/CPUFallbackColormapData.d.ts +1 -1
- package/dist/esm/types/CPUFallbackColormapsData.d.ts +1 -1
- package/dist/esm/types/CPUFallbackLUT.d.ts +1 -1
- package/dist/esm/types/CPUFallbackRenderingTools.d.ts +1 -1
- package/dist/esm/types/CPUFallbackViewport.d.ts +1 -1
- package/dist/esm/types/CPUFallbackViewportDisplayedArea.d.ts +1 -1
- package/dist/esm/types/CPUIImageData.d.ts +2 -2
- package/dist/esm/types/Colormap.d.ts +3 -3
- package/dist/esm/types/ContourData.d.ts +3 -3
- package/dist/esm/types/Cornerstone3DConfig.d.ts +1 -1
- package/dist/esm/types/EventTypes.d.ts +46 -46
- package/dist/esm/types/FlipDirection.d.ts +1 -1
- package/dist/esm/types/IActor.d.ts +4 -4
- package/dist/esm/types/IImage.d.ts +2 -0
- package/dist/esm/types/IViewport.d.ts +4 -4
- package/dist/esm/types/IVolume.d.ts +1 -1
- package/dist/esm/types/IVolumeInput.d.ts +1 -1
- package/dist/esm/types/ImageLoaderFn.d.ts +1 -1
- package/dist/esm/types/ImageSliceData.d.ts +1 -1
- package/dist/esm/types/Mat3.d.ts +1 -1
- package/dist/esm/types/Metadata.d.ts +1 -1
- package/dist/esm/types/OrientationVectors.d.ts +1 -1
- package/dist/esm/types/PixelDataTypedArray.d.ts +1 -1
- package/dist/esm/types/Plane.d.ts +1 -1
- package/dist/esm/types/Point2.d.ts +1 -1
- package/dist/esm/types/Point3.d.ts +1 -1
- package/dist/esm/types/Point4.d.ts +1 -1
- package/dist/esm/types/RGB.d.ts +1 -1
- package/dist/esm/types/ScalingParameters.d.ts +3 -3
- package/dist/esm/types/StackViewportProperties.d.ts +1 -1
- package/dist/esm/types/TransformMatrix2D.d.ts +1 -1
- package/dist/esm/types/ViewportInputOptions.d.ts +1 -1
- package/dist/esm/types/ViewportProperties.d.ts +1 -1
- package/dist/esm/types/VolumeLoaderFn.d.ts +1 -1
- package/dist/esm/types/VolumeViewportProperties.d.ts +1 -1
- package/dist/esm/types/displayArea.d.ts +1 -1
- package/dist/esm/types/voi.d.ts +2 -2
- package/dist/esm/utilities/actorCheck.d.ts +1 -1
- package/dist/esm/utilities/getViewportsWithImageURI.d.ts +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -4
- package/src/RenderingEngine/StackViewport.ts +3 -4
- package/src/RenderingEngine/Viewport.ts +9 -10
- package/src/RenderingEngine/VolumeViewport.ts +20 -3
- package/src/Settings.ts +3 -1
- package/src/cache/cache.ts +33 -18
- package/src/loaders/volumeLoader.ts +2 -3
- package/src/types/IImage.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/umd/index.js",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -32,8 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@kitware/vtk.js": "27.3.1",
|
|
34
34
|
"detect-gpu": "^5.0.22",
|
|
35
|
-
"gl-matrix": "^3.4.3"
|
|
36
|
-
"lodash.clonedeep": "4.5.0"
|
|
35
|
+
"gl-matrix": "^3.4.3"
|
|
37
36
|
},
|
|
38
37
|
"contributors": [
|
|
39
38
|
{
|
|
@@ -46,5 +45,5 @@
|
|
|
46
45
|
"type": "individual",
|
|
47
46
|
"url": "https://ohif.org/donate"
|
|
48
47
|
},
|
|
49
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "deefd5fb773ca3eb6fc4f2047c15a2b1a3ac82de"
|
|
50
49
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
|
|
2
2
|
import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
|
|
3
3
|
import type { vtkImageData as vtkImageDataType } from '@kitware/vtk.js/Common/DataModel/ImageData';
|
|
4
|
-
import _cloneDeep from 'lodash.clonedeep';
|
|
5
4
|
import vtkCamera from '@kitware/vtk.js/Rendering/Core/Camera';
|
|
6
5
|
import { vec2, vec3, mat4 } from 'gl-matrix';
|
|
7
6
|
import vtkImageMapper from '@kitware/vtk.js/Rendering/Core/ImageMapper';
|
|
@@ -1017,7 +1016,7 @@ class StackViewport extends Viewport implements IStackViewport {
|
|
|
1017
1016
|
? vec3.negate(vec3.create(), this.initialViewUp)
|
|
1018
1017
|
: this.initialViewUp;
|
|
1019
1018
|
|
|
1020
|
-
this.
|
|
1019
|
+
this.setCameraNoEvent({
|
|
1021
1020
|
viewUp: initialViewUp as Point3,
|
|
1022
1021
|
});
|
|
1023
1022
|
|
|
@@ -1957,7 +1956,7 @@ class StackViewport extends Viewport implements IStackViewport {
|
|
|
1957
1956
|
|
|
1958
1957
|
// Cache camera props so we can trigger one camera changed event after
|
|
1959
1958
|
// The full transition.
|
|
1960
|
-
const previousCameraProps =
|
|
1959
|
+
const previousCameraProps = structuredClone(this.getCamera());
|
|
1961
1960
|
if (sameImageData && !this.stackInvalidated) {
|
|
1962
1961
|
// 3a. If we can reuse it, replace the scalar data under the hood
|
|
1963
1962
|
this._updateVTKImageDataFromCornerstoneImage(image);
|
|
@@ -2239,7 +2238,7 @@ class StackViewport extends Viewport implements IStackViewport {
|
|
|
2239
2238
|
|
|
2240
2239
|
const targetImageId = imageIds[newTargetImageIdIndex];
|
|
2241
2240
|
|
|
2242
|
-
const imageAlreadyLoaded = cache.
|
|
2241
|
+
const imageAlreadyLoaded = cache.isLoaded(targetImageId);
|
|
2243
2242
|
|
|
2244
2243
|
// If image is already cached we want to scroll right away; however, if it is
|
|
2245
2244
|
// not cached, we can debounce the scroll event to avoid firing multiple scroll
|
|
@@ -4,7 +4,6 @@ import vtkMath from '@kitware/vtk.js/Common/Core/Math';
|
|
|
4
4
|
import vtkPlane from '@kitware/vtk.js/Common/DataModel/Plane';
|
|
5
5
|
|
|
6
6
|
import { vec2, vec3 } from 'gl-matrix';
|
|
7
|
-
import _cloneDeep from 'lodash.clonedeep';
|
|
8
7
|
|
|
9
8
|
import Events from '../enums/Events';
|
|
10
9
|
import ViewportStatus from '../enums/ViewportStatus';
|
|
@@ -103,11 +102,11 @@ class Viewport implements IViewport {
|
|
|
103
102
|
this.renderingEngineId
|
|
104
103
|
);
|
|
105
104
|
|
|
106
|
-
this.defaultOptions =
|
|
105
|
+
this.defaultOptions = structuredClone(props.defaultOptions);
|
|
107
106
|
this.suppressEvents = props.defaultOptions.suppressEvents
|
|
108
107
|
? props.defaultOptions.suppressEvents
|
|
109
108
|
: false;
|
|
110
|
-
this.options =
|
|
109
|
+
this.options = structuredClone(props.defaultOptions);
|
|
111
110
|
this.isDisabled = false;
|
|
112
111
|
}
|
|
113
112
|
|
|
@@ -126,7 +125,7 @@ class Viewport implements IViewport {
|
|
|
126
125
|
|
|
127
126
|
/**
|
|
128
127
|
* Indicate that the image has been rendered.
|
|
129
|
-
* This will set
|
|
128
|
+
* This will set the viewportStatus to RENDERED if there is image data
|
|
130
129
|
* available to actually be rendered - otherwise, the rendering simply showed
|
|
131
130
|
* the background image.
|
|
132
131
|
*/
|
|
@@ -180,7 +179,7 @@ class Viewport implements IViewport {
|
|
|
180
179
|
* @param immediate - If `true`, renders the viewport after the options are set.
|
|
181
180
|
*/
|
|
182
181
|
public setOptions(options: ViewportInputOptions, immediate = false): void {
|
|
183
|
-
this.options = <ViewportInputOptions>
|
|
182
|
+
this.options = <ViewportInputOptions>structuredClone(options);
|
|
184
183
|
|
|
185
184
|
// TODO When this is needed we need to move the camera position.
|
|
186
185
|
// We can steal some logic from the tools we build to do this.
|
|
@@ -198,7 +197,7 @@ class Viewport implements IViewport {
|
|
|
198
197
|
* @param immediate - If `true`, renders the viewport after the options are reset.
|
|
199
198
|
*/
|
|
200
199
|
public reset(immediate = false) {
|
|
201
|
-
this.options =
|
|
200
|
+
this.options = structuredClone(this.defaultOptions);
|
|
202
201
|
|
|
203
202
|
// TODO When this is needed we need to move the camera position.
|
|
204
203
|
// We can steal some logic from the tools we build to do this.
|
|
@@ -660,7 +659,7 @@ class Viewport implements IViewport {
|
|
|
660
659
|
flipVertical: false,
|
|
661
660
|
});
|
|
662
661
|
|
|
663
|
-
const previousCamera =
|
|
662
|
+
const previousCamera = structuredClone(this.getCamera());
|
|
664
663
|
const bounds = renderer.computeVisiblePropBounds();
|
|
665
664
|
const focalPoint = <Point3>[0, 0, 0];
|
|
666
665
|
const imageData = this.getDefaultImageData();
|
|
@@ -775,9 +774,9 @@ class Viewport implements IViewport {
|
|
|
775
774
|
clippingRange: clippingRangeToUse,
|
|
776
775
|
});
|
|
777
776
|
|
|
778
|
-
const modifiedCamera =
|
|
777
|
+
const modifiedCamera = structuredClone(this.getCamera());
|
|
779
778
|
|
|
780
|
-
this.setFitToCanvasCamera(
|
|
779
|
+
this.setFitToCanvasCamera(structuredClone(this.getCamera()));
|
|
781
780
|
|
|
782
781
|
if (storeAsInitialCamera) {
|
|
783
782
|
this.setInitialCamera(modifiedCamera);
|
|
@@ -1007,7 +1006,7 @@ class Viewport implements IViewport {
|
|
|
1007
1006
|
storeAsInitialCamera = false
|
|
1008
1007
|
): void {
|
|
1009
1008
|
const vtkCamera = this.getVtkActiveCamera();
|
|
1010
|
-
const previousCamera =
|
|
1009
|
+
const previousCamera = structuredClone(this.getCamera());
|
|
1011
1010
|
const updatedCamera = Object.assign({}, previousCamera, cameraInterface);
|
|
1012
1011
|
const {
|
|
1013
1012
|
viewUp,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import vtkPlane from '@kitware/vtk.js/Common/DataModel/Plane';
|
|
2
|
+
import vtkVolume from '@kitware/vtk.js/Rendering/Core/Volume';
|
|
3
|
+
|
|
2
4
|
import { vec3 } from 'gl-matrix';
|
|
3
5
|
|
|
4
6
|
import cache from '../cache';
|
|
5
7
|
import { MPR_CAMERA_VALUES, RENDERING_DEFAULTS } from '../constants';
|
|
6
|
-
import { BlendModes, OrientationAxis } from '../enums';
|
|
8
|
+
import { BlendModes, OrientationAxis, Events } from '../enums';
|
|
7
9
|
import type {
|
|
8
10
|
ActorEntry,
|
|
9
11
|
IImageVolume,
|
|
@@ -12,10 +14,9 @@ import type {
|
|
|
12
14
|
Point3,
|
|
13
15
|
} from '../types';
|
|
14
16
|
import type { ViewportInput } from '../types/IViewport';
|
|
15
|
-
import { actorIsA, getClosestImageId } from '../utilities';
|
|
17
|
+
import { actorIsA, getClosestImageId, triggerEvent } from '../utilities';
|
|
16
18
|
import BaseVolumeViewport from './BaseVolumeViewport';
|
|
17
19
|
import setDefaultVolumeVOI from './helpers/setDefaultVolumeVOI';
|
|
18
|
-
import vtkVolume from '@kitware/vtk.js/Rendering/Core/Volume';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* An object representing a VolumeViewport. VolumeViewports are used to render
|
|
@@ -383,6 +384,22 @@ class VolumeViewport extends BaseVolumeViewport {
|
|
|
383
384
|
);
|
|
384
385
|
}
|
|
385
386
|
setDefaultVolumeVOI(volumeActor.actor as vtkVolume, imageVolume, false);
|
|
387
|
+
|
|
388
|
+
const range = (volumeActor.actor as vtkVolume)
|
|
389
|
+
.getProperty()
|
|
390
|
+
.getRGBTransferFunction(0)
|
|
391
|
+
.getMappingRange();
|
|
392
|
+
|
|
393
|
+
const eventDetails = {
|
|
394
|
+
viewportId: volumeActor.uid,
|
|
395
|
+
range: {
|
|
396
|
+
lower: range[0],
|
|
397
|
+
upper: range[1],
|
|
398
|
+
},
|
|
399
|
+
volumeId: volumeActor.uid,
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
triggerEvent(this.element, Events.VOI_MODIFIED, eventDetails);
|
|
386
403
|
}
|
|
387
404
|
}
|
|
388
405
|
|
package/src/Settings.ts
CHANGED
|
@@ -13,7 +13,9 @@ const DICTIONARY = Symbol('Dictionary');
|
|
|
13
13
|
export default class Settings {
|
|
14
14
|
constructor(base?: Settings) {
|
|
15
15
|
const dictionary = Object.create(
|
|
16
|
-
base instanceof Settings && DICTIONARY in base
|
|
16
|
+
base instanceof Settings && DICTIONARY in base
|
|
17
|
+
? (base[DICTIONARY] as object)
|
|
18
|
+
: null
|
|
17
19
|
);
|
|
18
20
|
Object.seal(
|
|
19
21
|
Object.defineProperty(this, DICTIONARY, {
|
package/src/cache/cache.ts
CHANGED
|
@@ -15,34 +15,40 @@ import { triggerEvent, imageIdToURI } from '../utilities';
|
|
|
15
15
|
import eventTarget from '../eventTarget';
|
|
16
16
|
import Events from '../enums/Events';
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const ONE_GB = 1073741824;
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Stores images, volumes and geometry.
|
|
22
|
+
* There are two sizes - the max cache size, that controls the overal maximum
|
|
23
|
+
* size, and the instance size, which controls how big any single object can
|
|
24
|
+
* be. Defaults are 3 GB and 2 GB - 8 bytes (just enough to allow allocating it
|
|
25
|
+
* without crashing).
|
|
26
|
+
* The 3 gb is tuned to the chromium garbage collection cycle to allow image volumes
|
|
27
|
+
* to be used/discarded.
|
|
28
|
+
*/
|
|
20
29
|
class Cache implements ICache {
|
|
21
|
-
|
|
22
|
-
private readonly
|
|
30
|
+
// used to store image data (2d)
|
|
31
|
+
private readonly _imageCache = new Map<string, ICachedImage>(); // volatile space
|
|
32
|
+
// used to store volume data (3d)
|
|
33
|
+
private readonly _volumeCache = new Map<string, ICachedVolume>(); // non-volatile space
|
|
23
34
|
// Todo: contour for now, but will be used for surface, etc.
|
|
24
35
|
private readonly _geometryCache: Map<string, ICachedGeometry>;
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
private
|
|
36
|
+
|
|
37
|
+
private _imageCacheSize = 0;
|
|
38
|
+
private _volumeCacheSize = 0;
|
|
39
|
+
private _maxCacheSize = 3 * ONE_GB;
|
|
40
|
+
private _maxInstanceSize = 2 * ONE_GB - 8;
|
|
28
41
|
|
|
29
42
|
constructor() {
|
|
30
|
-
// used to store image data (2d)
|
|
31
|
-
this._imageCache = new Map();
|
|
32
|
-
// used to store volume data (3d)
|
|
33
|
-
this._volumeCache = new Map();
|
|
34
43
|
// used to store object data (contour, surface, etc.)
|
|
35
44
|
this._geometryCache = new Map();
|
|
36
|
-
this._imageCacheSize = 0;
|
|
37
|
-
this._volumeCacheSize = 0;
|
|
38
|
-
this._maxCacheSize = MAX_CACHE_SIZE_1GB; // Default 1GB
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
/**
|
|
42
48
|
* Set the maximum cache Size
|
|
43
49
|
*
|
|
44
|
-
* Maximum cache size should be set before adding the data
|
|
45
|
-
* will
|
|
50
|
+
* Maximum cache size should be set before adding the data. If set after,
|
|
51
|
+
* and it is smaller than the current size, will cause issues.
|
|
46
52
|
*
|
|
47
53
|
* @param newMaxCacheSize - new maximum cache size
|
|
48
54
|
*
|
|
@@ -59,7 +65,7 @@ class Cache implements ICache {
|
|
|
59
65
|
/**
|
|
60
66
|
* Checks if there is enough space in the cache for requested byte size
|
|
61
67
|
*
|
|
62
|
-
* It
|
|
68
|
+
* It returns false, if the sum of volatile (image) cache and unallocated cache
|
|
63
69
|
* is less than the requested byteLength
|
|
64
70
|
*
|
|
65
71
|
* @param byteLength - byte length of requested byte size
|
|
@@ -67,6 +73,9 @@ class Cache implements ICache {
|
|
|
67
73
|
* @returns - boolean indicating if there is enough space in the cache
|
|
68
74
|
*/
|
|
69
75
|
public isCacheable = (byteLength: number): boolean => {
|
|
76
|
+
if (byteLength > this._maxInstanceSize) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
70
79
|
const unallocatedSpace = this.getBytesAvailable();
|
|
71
80
|
const imageCacheSize = this._imageCacheSize;
|
|
72
81
|
const availableSpace = unallocatedSpace + imageCacheSize;
|
|
@@ -81,6 +90,13 @@ class Cache implements ICache {
|
|
|
81
90
|
*/
|
|
82
91
|
public getMaxCacheSize = (): number => this._maxCacheSize;
|
|
83
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Returns maximum size of a single instance (volume or single image)
|
|
95
|
+
*
|
|
96
|
+
* @returns maximum instance size
|
|
97
|
+
*/
|
|
98
|
+
public getMaxInstanceSize = (): number => this._maxInstanceSize;
|
|
99
|
+
|
|
84
100
|
/**
|
|
85
101
|
* Returns current size of the cache
|
|
86
102
|
*
|
|
@@ -384,7 +400,6 @@ class Cache implements ICache {
|
|
|
384
400
|
cachedImage.image = image;
|
|
385
401
|
cachedImage.sizeInBytes = image.sizeInBytes;
|
|
386
402
|
this._incrementImageCacheSize(cachedImage.sizeInBytes);
|
|
387
|
-
|
|
388
403
|
const eventDetails: EventTypes.ImageCacheImageAddedEventDetail = {
|
|
389
404
|
image: cachedImage,
|
|
390
405
|
};
|
|
@@ -429,7 +444,7 @@ class Cache implements ICache {
|
|
|
429
444
|
* @param imageId - image Id to check
|
|
430
445
|
* @returns boolean
|
|
431
446
|
*/
|
|
432
|
-
public
|
|
447
|
+
public isLoaded(imageId: string): boolean {
|
|
433
448
|
const cachedImage = this._imageCache.get(imageId);
|
|
434
449
|
|
|
435
450
|
if (!cachedImage) {
|
|
@@ -3,7 +3,6 @@ import '@kitware/vtk.js/Rendering/Profiles/Volume';
|
|
|
3
3
|
import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
|
|
4
4
|
import type { vtkImageData as vtkImageDataType } from '@kitware/vtk.js/Common/DataModel/ImageData';
|
|
5
5
|
import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
|
|
6
|
-
import cloneDeep from 'lodash.clonedeep';
|
|
7
6
|
|
|
8
7
|
import { ImageVolume } from '../cache/classes/ImageVolume';
|
|
9
8
|
import type * as Types from '../types';
|
|
@@ -330,7 +329,7 @@ export async function createAndCacheDerivedVolume(
|
|
|
330
329
|
|
|
331
330
|
const derivedVolume = new ImageVolume({
|
|
332
331
|
volumeId,
|
|
333
|
-
metadata:
|
|
332
|
+
metadata: structuredClone(metadata),
|
|
334
333
|
dimensions: [dimensions[0], dimensions[1], dimensions[2]],
|
|
335
334
|
spacing,
|
|
336
335
|
origin,
|
|
@@ -419,7 +418,7 @@ export function createLocalVolume(
|
|
|
419
418
|
|
|
420
419
|
const derivedVolume = new ImageVolume({
|
|
421
420
|
volumeId,
|
|
422
|
-
metadata:
|
|
421
|
+
metadata: structuredClone(metadata),
|
|
423
422
|
dimensions: [dimensions[0], dimensions[1], dimensions[2]],
|
|
424
423
|
spacing,
|
|
425
424
|
origin,
|
package/src/types/IImage.ts
CHANGED