@cornerstonejs/tools 1.78.3 → 1.80.0
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/cursors/SVGCursorDescriptor.js +7 -0
- package/dist/cjs/cursors/SVGCursorDescriptor.js.map +1 -1
- package/dist/cjs/drawingSvg/drawHeight.d.ts +3 -0
- package/dist/cjs/drawingSvg/drawHeight.js +49 -0
- package/dist/cjs/drawingSvg/drawHeight.js.map +1 -0
- package/dist/cjs/drawingSvg/index.d.ts +2 -1
- package/dist/cjs/drawingSvg/index.js +3 -1
- package/dist/cjs/drawingSvg/index.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/tools/annotation/HeightTool.d.ts +40 -0
- package/dist/cjs/tools/annotation/HeightTool.js +463 -0
- package/dist/cjs/tools/annotation/HeightTool.js.map +1 -0
- package/dist/cjs/tools/index.d.ts +2 -1
- package/dist/cjs/tools/index.js +4 -2
- package/dist/cjs/tools/index.js.map +1 -1
- package/dist/cjs/tools/segmentation/CircleROIStartEndThresholdTool.d.ts +15 -8
- package/dist/cjs/tools/segmentation/CircleROIStartEndThresholdTool.js +189 -62
- package/dist/cjs/tools/segmentation/CircleROIStartEndThresholdTool.js.map +1 -1
- package/dist/cjs/tools/segmentation/RectangleROIStartEndThresholdTool.d.ts +17 -7
- package/dist/cjs/tools/segmentation/RectangleROIStartEndThresholdTool.js +167 -52
- package/dist/cjs/tools/segmentation/RectangleROIStartEndThresholdTool.js.map +1 -1
- package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +26 -4
- package/dist/cjs/utilities/planar/filterAnnotationsWithinPlane.d.ts +3 -0
- package/dist/cjs/utilities/planar/filterAnnotationsWithinPlane.js +31 -0
- package/dist/cjs/utilities/planar/filterAnnotationsWithinPlane.js.map +1 -0
- package/dist/cjs/utilities/planar/index.d.ts +3 -1
- package/dist/cjs/utilities/planar/index.js +4 -1
- package/dist/cjs/utilities/planar/index.js.map +1 -1
- package/dist/cjs/utilities/viewport/isViewportPreScaled.js +1 -4
- package/dist/cjs/utilities/viewport/isViewportPreScaled.js.map +1 -1
- package/dist/esm/cursors/SVGCursorDescriptor.js +7 -0
- package/dist/esm/cursors/SVGCursorDescriptor.js.map +1 -1
- package/dist/esm/drawingSvg/drawHeight.js +43 -0
- package/dist/esm/drawingSvg/drawHeight.js.map +1 -0
- package/dist/esm/drawingSvg/index.js +2 -1
- package/dist/esm/drawingSvg/index.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tools/annotation/HeightTool.js +439 -0
- package/dist/esm/tools/annotation/HeightTool.js.map +1 -0
- package/dist/esm/tools/index.js +2 -1
- package/dist/esm/tools/index.js.map +1 -1
- package/dist/esm/tools/segmentation/CircleROIStartEndThresholdTool.js +192 -66
- package/dist/esm/tools/segmentation/CircleROIStartEndThresholdTool.js.map +1 -1
- package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +168 -54
- package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js.map +1 -1
- package/dist/esm/utilities/planar/filterAnnotationsWithinPlane.js +27 -0
- package/dist/esm/utilities/planar/filterAnnotationsWithinPlane.js.map +1 -0
- package/dist/esm/utilities/planar/index.js +3 -1
- package/dist/esm/utilities/planar/index.js.map +1 -1
- package/dist/esm/utilities/viewport/isViewportPreScaled.js +2 -5
- package/dist/esm/utilities/viewport/isViewportPreScaled.js.map +1 -1
- package/dist/types/cursors/SVGCursorDescriptor.d.ts.map +1 -1
- package/dist/types/drawingSvg/drawHeight.d.ts +4 -0
- package/dist/types/drawingSvg/drawHeight.d.ts.map +1 -0
- package/dist/types/drawingSvg/index.d.ts +2 -1
- package/dist/types/drawingSvg/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/tools/annotation/HeightTool.d.ts +41 -0
- package/dist/types/tools/annotation/HeightTool.d.ts.map +1 -0
- package/dist/types/tools/index.d.ts +2 -1
- package/dist/types/tools/index.d.ts.map +1 -1
- package/dist/types/tools/segmentation/CircleROIStartEndThresholdTool.d.ts +15 -8
- package/dist/types/tools/segmentation/CircleROIStartEndThresholdTool.d.ts.map +1 -1
- package/dist/types/tools/segmentation/RectangleROIStartEndThresholdTool.d.ts +17 -7
- package/dist/types/tools/segmentation/RectangleROIStartEndThresholdTool.d.ts.map +1 -1
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts +26 -4
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts.map +1 -1
- package/dist/types/utilities/planar/filterAnnotationsWithinPlane.d.ts +4 -0
- package/dist/types/utilities/planar/filterAnnotationsWithinPlane.d.ts.map +1 -0
- package/dist/types/utilities/planar/index.d.ts +3 -1
- package/dist/types/utilities/planar/index.d.ts.map +1 -1
- package/dist/types/utilities/viewport/isViewportPreScaled.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/cursors/SVGCursorDescriptor.ts +7 -0
- package/src/drawingSvg/drawHeight.ts +90 -0
- package/src/drawingSvg/index.ts +2 -0
- package/src/index.ts +2 -0
- package/src/tools/annotation/HeightTool.ts +882 -0
- package/src/tools/index.ts +2 -0
- package/src/tools/segmentation/CircleROIStartEndThresholdTool.ts +310 -102
- package/src/tools/segmentation/RectangleROIStartEndThresholdTool.ts +287 -77
- package/src/types/ToolSpecificAnnotationTypes.ts +26 -4
- package/src/utilities/planar/filterAnnotationsWithinPlane.ts +76 -0
- package/src/utilities/planar/index.ts +3 -0
- package/src/utilities/viewport/isViewportPreScaled.ts +2 -5
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { vec3 } from 'gl-matrix';
|
|
2
|
+
import { CONSTANTS, metaData } from '@cornerstonejs/core';
|
|
3
|
+
import type { Types } from '@cornerstonejs/core';
|
|
4
|
+
import { Annotations, Annotation } from '../../types';
|
|
5
|
+
|
|
6
|
+
const { EPSILON } = CONSTANTS;
|
|
7
|
+
|
|
8
|
+
const PARALLEL_THRESHOLD = 1 - EPSILON;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* given some `Annotations`, and the slice defined by the camera's normal
|
|
12
|
+
* direction and the spacing in the normal, filter the `Annotations` which
|
|
13
|
+
* is within the slice.
|
|
14
|
+
*
|
|
15
|
+
* @param annotations - Annotations
|
|
16
|
+
* @param camera - The camera
|
|
17
|
+
* @param spacingInNormalDirection - The spacing in the normal direction
|
|
18
|
+
* @returns The filtered `Annotations`.
|
|
19
|
+
*/
|
|
20
|
+
export function filterAnnotationsWithinSamePlane(
|
|
21
|
+
annotations: Annotations,
|
|
22
|
+
camera: Types.ICamera
|
|
23
|
+
): Annotations {
|
|
24
|
+
const { viewPlaneNormal } = camera;
|
|
25
|
+
|
|
26
|
+
// The reason we use parallel normals instead of actual orientation is that
|
|
27
|
+
// flipped action is done through camera API, so we can't rely on the
|
|
28
|
+
// orientation (viewplaneNormal and viewUp) since even the same image and
|
|
29
|
+
// same slice if flipped will have different orientation, but still rendering
|
|
30
|
+
// the same slice. Instead, we choose to use the parallel normals to filter
|
|
31
|
+
// the annotations and later we fine tune it with the annotation within slice
|
|
32
|
+
// logic down below.
|
|
33
|
+
const annotationsWithParallelNormals = annotations.filter(
|
|
34
|
+
(td: Annotation) => {
|
|
35
|
+
let annotationViewPlaneNormal = td.metadata.viewPlaneNormal;
|
|
36
|
+
|
|
37
|
+
if (!annotationViewPlaneNormal) {
|
|
38
|
+
// This code is run to set the annotation view plane normal
|
|
39
|
+
// for historical data which was saved without the normal.
|
|
40
|
+
const { referencedImageId } = td.metadata;
|
|
41
|
+
const { imageOrientationPatient } = metaData.get(
|
|
42
|
+
'imagePlaneModule',
|
|
43
|
+
referencedImageId
|
|
44
|
+
);
|
|
45
|
+
const rowCosineVec = vec3.fromValues(
|
|
46
|
+
imageOrientationPatient[0],
|
|
47
|
+
imageOrientationPatient[1],
|
|
48
|
+
imageOrientationPatient[2]
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const colCosineVec = vec3.fromValues(
|
|
52
|
+
imageOrientationPatient[3],
|
|
53
|
+
imageOrientationPatient[4],
|
|
54
|
+
imageOrientationPatient[5]
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
annotationViewPlaneNormal = vec3.create() as Types.Point3;
|
|
58
|
+
|
|
59
|
+
vec3.cross(annotationViewPlaneNormal, rowCosineVec, colCosineVec);
|
|
60
|
+
td.metadata.viewPlaneNormal = annotationViewPlaneNormal;
|
|
61
|
+
}
|
|
62
|
+
const isParallel =
|
|
63
|
+
Math.abs(vec3.dot(viewPlaneNormal, annotationViewPlaneNormal)) >
|
|
64
|
+
PARALLEL_THRESHOLD;
|
|
65
|
+
|
|
66
|
+
return annotationViewPlaneNormal && isParallel;
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
// No in plane annotations.
|
|
71
|
+
if (!annotationsWithParallelNormals.length) {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return annotationsWithParallelNormals;
|
|
76
|
+
}
|
|
@@ -3,6 +3,7 @@ import getWorldWidthAndHeightFromCorners from './getWorldWidthAndHeightFromCorne
|
|
|
3
3
|
import filterAnnotationsForDisplay from './filterAnnotationsForDisplay';
|
|
4
4
|
import getPointInLineOfSightWithCriteria from './getPointInLineOfSightWithCriteria';
|
|
5
5
|
import { isPlaneIntersectingAABB } from './isPlaneIntersectingAABB';
|
|
6
|
+
import { filterAnnotationsWithinSamePlane } from './filterAnnotationsWithinPlane';
|
|
6
7
|
|
|
7
8
|
export default {
|
|
8
9
|
filterAnnotationsWithinSlice,
|
|
@@ -10,6 +11,7 @@ export default {
|
|
|
10
11
|
filterAnnotationsForDisplay,
|
|
11
12
|
getPointInLineOfSightWithCriteria,
|
|
12
13
|
isPlaneIntersectingAABB,
|
|
14
|
+
filterAnnotationsWithinSamePlane,
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
export {
|
|
@@ -18,4 +20,5 @@ export {
|
|
|
18
20
|
filterAnnotationsForDisplay,
|
|
19
21
|
getPointInLineOfSightWithCriteria,
|
|
20
22
|
isPlaneIntersectingAABB,
|
|
23
|
+
filterAnnotationsWithinSamePlane,
|
|
21
24
|
};
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
StackViewport,
|
|
4
4
|
Types,
|
|
5
5
|
BaseVolumeViewport,
|
|
6
|
+
utilities,
|
|
6
7
|
} from '@cornerstonejs/core';
|
|
7
8
|
|
|
8
9
|
function isViewportPreScaled(
|
|
@@ -10,11 +11,7 @@ function isViewportPreScaled(
|
|
|
10
11
|
targetId: string
|
|
11
12
|
): boolean {
|
|
12
13
|
if (viewport instanceof BaseVolumeViewport) {
|
|
13
|
-
const
|
|
14
|
-
const volumeId =
|
|
15
|
-
targetIdTokens.length > 1
|
|
16
|
-
? targetIdTokens[1].split('?')[0]
|
|
17
|
-
: targetIdTokens[0];
|
|
14
|
+
const volumeId = utilities.getVolumeId(targetId);
|
|
18
15
|
const volume = cache.getVolume(volumeId);
|
|
19
16
|
return !!volume?.scaling && Object.keys(volume.scaling).length > 0;
|
|
20
17
|
} else if (viewport instanceof StackViewport) {
|