@cornerstonejs/tools 4.15.22 → 4.15.24
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/esm/tools/base/AnnotationTool.js +3 -18
- package/dist/esm/utilities/index.d.ts +2 -1
- package/dist/esm/utilities/index.js +2 -1
- package/dist/esm/utilities/safeStructuredClone.d.ts +1 -0
- package/dist/esm/utilities/safeStructuredClone.js +53 -0
- package/dist/esm/utilities/segmentation/getStatistics.js +3 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +3 -3
|
@@ -8,8 +8,8 @@ import { triggerAnnotationModified } from '../../stateManagement/annotation/help
|
|
|
8
8
|
import ChangeTypes from '../../enums/ChangeTypes';
|
|
9
9
|
import { setAnnotationSelected } from '../../stateManagement/annotation/annotationSelection';
|
|
10
10
|
import { addContourSegmentationAnnotation } from '../../utilities/contourSegmentation';
|
|
11
|
+
import { safeStructuredClone } from '../../utilities/safeStructuredClone';
|
|
11
12
|
const { DefaultHistoryMemo } = csUtils.HistoryMemo;
|
|
12
|
-
const { PointsManager } = csUtils;
|
|
13
13
|
class AnnotationTool extends AnnotationDisplayTool {
|
|
14
14
|
static createAnnotationForViewport(viewport, ...annotationBaseData) {
|
|
15
15
|
return this.createAnnotation({ metadata: viewport.getViewReference() }, ...annotationBaseData);
|
|
@@ -161,26 +161,11 @@ class AnnotationTool extends AnnotationDisplayTool {
|
|
|
161
161
|
}
|
|
162
162
|
static createAnnotationState(annotation, deleting) {
|
|
163
163
|
const { data, annotationUID } = annotation;
|
|
164
|
-
|
|
165
|
-
...data,
|
|
166
|
-
cachedStats: {},
|
|
167
|
-
};
|
|
168
|
-
delete cloneData.contour;
|
|
169
|
-
delete cloneData.spline;
|
|
170
|
-
const state = {
|
|
164
|
+
return {
|
|
171
165
|
annotationUID,
|
|
172
|
-
data:
|
|
166
|
+
data: safeStructuredClone(data),
|
|
173
167
|
deleting,
|
|
174
168
|
};
|
|
175
|
-
const contour = data.contour;
|
|
176
|
-
if (contour) {
|
|
177
|
-
state.data.contour = {
|
|
178
|
-
...contour,
|
|
179
|
-
polyline: null,
|
|
180
|
-
pointsManager: PointsManager.create3(contour.polyline.length, contour.polyline),
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
return state;
|
|
184
169
|
}
|
|
185
170
|
static createAnnotationMemo(element, annotation, options) {
|
|
186
171
|
if (!annotation) {
|
|
@@ -39,6 +39,7 @@ import { getPixelValueUnits, getPixelValueUnitsImageId } from './getPixelValueUn
|
|
|
39
39
|
import * as geometricSurfaceUtils from './geometricSurfaceUtils';
|
|
40
40
|
import setAnnotationLabel from './setAnnotationLabel';
|
|
41
41
|
import { moveAnnotationToViewPlane } from './moveAnnotationToViewPlane';
|
|
42
|
+
import { safeStructuredClone } from './safeStructuredClone';
|
|
42
43
|
import getOrCreateImageVolume from './segmentation/getOrCreateImageVolume';
|
|
43
44
|
import * as usFanExtraction from '../tools/annotation/UltrasoundPleuraBLineTool/utils/fanExtraction';
|
|
44
|
-
export { math, planar, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnitsAndScale, getCalibratedProbeUnitsAndValue, getCalibratedAspect, getPixelValueUnits, getPixelValueUnitsImageId, segmentation, contours, triggerAnnotationRenderForViewportIds, triggerAnnotationRenderForToolGroupIds, triggerAnnotationRender, getSphereBoundsInfo, getAnnotationNearPoint, getViewportForAnnotation, getAnnotationNearPointOnEnabledElement, viewport, cine, boundingBox, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, roundNumber, pointToString, polyDataUtils, voi, AnnotationMultiSlice, contourSegmentation, annotationHydration, getClosestImageIdForStackViewport, pointInSurroundingSphereCallback, normalizeViewportPlane, IslandRemoval, geometricSurfaceUtils, usFanExtraction, setAnnotationLabel, moveAnnotationToViewPlane, getOrCreateImageVolume, };
|
|
45
|
+
export { math, planar, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnitsAndScale, getCalibratedProbeUnitsAndValue, getCalibratedAspect, getPixelValueUnits, getPixelValueUnitsImageId, segmentation, contours, triggerAnnotationRenderForViewportIds, triggerAnnotationRenderForToolGroupIds, triggerAnnotationRender, getSphereBoundsInfo, getAnnotationNearPoint, getViewportForAnnotation, getAnnotationNearPointOnEnabledElement, viewport, cine, boundingBox, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, roundNumber, pointToString, polyDataUtils, voi, AnnotationMultiSlice, contourSegmentation, annotationHydration, getClosestImageIdForStackViewport, pointInSurroundingSphereCallback, normalizeViewportPlane, IslandRemoval, geometricSurfaceUtils, usFanExtraction, setAnnotationLabel, moveAnnotationToViewPlane, safeStructuredClone, getOrCreateImageVolume, };
|
|
@@ -39,6 +39,7 @@ import { getPixelValueUnits, getPixelValueUnitsImageId, } from './getPixelValueU
|
|
|
39
39
|
import * as geometricSurfaceUtils from './geometricSurfaceUtils';
|
|
40
40
|
import setAnnotationLabel from './setAnnotationLabel';
|
|
41
41
|
import { moveAnnotationToViewPlane } from './moveAnnotationToViewPlane';
|
|
42
|
+
import { safeStructuredClone } from './safeStructuredClone';
|
|
42
43
|
import getOrCreateImageVolume from './segmentation/getOrCreateImageVolume';
|
|
43
44
|
import * as usFanExtraction from '../tools/annotation/UltrasoundPleuraBLineTool/utils/fanExtraction';
|
|
44
|
-
export { math, planar, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnitsAndScale, getCalibratedProbeUnitsAndValue, getCalibratedAspect, getPixelValueUnits, getPixelValueUnitsImageId, segmentation, contours, triggerAnnotationRenderForViewportIds, triggerAnnotationRenderForToolGroupIds, triggerAnnotationRender, getSphereBoundsInfo, getAnnotationNearPoint, getViewportForAnnotation, getAnnotationNearPointOnEnabledElement, viewport, cine, boundingBox, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, roundNumber, pointToString, polyDataUtils, voi, AnnotationMultiSlice, contourSegmentation, annotationHydration, getClosestImageIdForStackViewport, pointInSurroundingSphereCallback, normalizeViewportPlane, IslandRemoval, geometricSurfaceUtils, usFanExtraction, setAnnotationLabel, moveAnnotationToViewPlane, getOrCreateImageVolume, };
|
|
45
|
+
export { math, planar, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnitsAndScale, getCalibratedProbeUnitsAndValue, getCalibratedAspect, getPixelValueUnits, getPixelValueUnitsImageId, segmentation, contours, triggerAnnotationRenderForViewportIds, triggerAnnotationRenderForToolGroupIds, triggerAnnotationRender, getSphereBoundsInfo, getAnnotationNearPoint, getViewportForAnnotation, getAnnotationNearPointOnEnabledElement, viewport, cine, boundingBox, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, roundNumber, pointToString, polyDataUtils, voi, AnnotationMultiSlice, contourSegmentation, annotationHydration, getClosestImageIdForStackViewport, pointInSurroundingSphereCallback, normalizeViewportPlane, IslandRemoval, geometricSurfaceUtils, usFanExtraction, setAnnotationLabel, moveAnnotationToViewPlane, safeStructuredClone, getOrCreateImageVolume, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function safeStructuredClone<T>(value: T): T;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { utilities as csUtils } from '@cornerstonejs/core';
|
|
2
|
+
const { PointsManager } = csUtils;
|
|
3
|
+
function cloneContourValue(_key, value) {
|
|
4
|
+
if (value == null || typeof value !== 'object' || !('polyline' in value)) {
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
const contour = value;
|
|
8
|
+
return {
|
|
9
|
+
...contour,
|
|
10
|
+
polyline: null,
|
|
11
|
+
pointsManager: PointsManager.create3(contour.polyline.length, contour.polyline),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const OMIT_KEYS = new Map([
|
|
15
|
+
['pointsInVolume', null],
|
|
16
|
+
['projectionPoints', null],
|
|
17
|
+
['contour', cloneContourValue],
|
|
18
|
+
['spline', null],
|
|
19
|
+
]);
|
|
20
|
+
function omitUncloneableKeys(obj) {
|
|
21
|
+
const result = {};
|
|
22
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
23
|
+
if (OMIT_KEYS.has(key)) {
|
|
24
|
+
const handler = OMIT_KEYS.get(key);
|
|
25
|
+
if (handler) {
|
|
26
|
+
result[key] = handler(key, value);
|
|
27
|
+
}
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (value === null || value === undefined || typeof value !== 'object') {
|
|
31
|
+
result[key] = value;
|
|
32
|
+
}
|
|
33
|
+
else if (Array.isArray(value)) {
|
|
34
|
+
result[key] = value.map((value) => safeStructuredClone(value));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
result[key] = omitUncloneableKeys(value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
export function safeStructuredClone(value) {
|
|
43
|
+
if (value === null || value === undefined) {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
if (typeof value !== 'object') {
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
if (Array.isArray(value)) {
|
|
50
|
+
return value.map((item) => safeStructuredClone(item));
|
|
51
|
+
}
|
|
52
|
+
return omitUncloneableKeys(value);
|
|
53
|
+
}
|
|
@@ -32,6 +32,9 @@ async function getStatistics({ segmentationId, segmentIndices, mode = 'collectiv
|
|
|
32
32
|
}
|
|
33
33
|
async function calculateVolumeStatistics({ operationData, indices, unit, mode, }) {
|
|
34
34
|
const strategyData = prepareVolumeStrategyDataForWorker(operationData);
|
|
35
|
+
if (!strategyData) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
35
38
|
const { segmentationVoxelManager, imageVoxelManager, segmentationImageData, imageData, } = strategyData;
|
|
36
39
|
if (!segmentationVoxelManager || !segmentationImageData) {
|
|
37
40
|
return;
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "4.15.
|
|
1
|
+
export declare const version = "4.15.24";
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '4.15.
|
|
1
|
+
export const version = '4.15.24';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "4.15.
|
|
3
|
+
"version": "4.15.24",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"types": "./dist/esm/index.d.ts",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"canvas": "3.2.0"
|
|
109
109
|
},
|
|
110
110
|
"peerDependencies": {
|
|
111
|
-
"@cornerstonejs/core": "4.15.
|
|
111
|
+
"@cornerstonejs/core": "4.15.24",
|
|
112
112
|
"@kitware/vtk.js": "34.15.1",
|
|
113
113
|
"@types/d3-array": "3.2.1",
|
|
114
114
|
"@types/d3-interpolate": "3.0.4",
|
|
@@ -127,5 +127,5 @@
|
|
|
127
127
|
"type": "individual",
|
|
128
128
|
"url": "https://ohif.org/donate"
|
|
129
129
|
},
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "a7da641f29b3b0eae7112a1d5516c528ec9ff0b5"
|
|
131
131
|
}
|