@cornerstonejs/tools 4.11.2 → 4.11.3
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/annotation/LivewireContourSegmentationTool.js +4 -0
- package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts +1 -1
- package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js +5 -1
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +0 -1
- package/dist/esm/tools/base/ContourBaseTool.d.ts +6 -0
- package/dist/esm/tools/base/ContourBaseTool.js +17 -1
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js +14 -8
- package/dist/esm/utilities/contours/AnnotationToPointData.d.ts +14 -4
- package/dist/esm/utilities/contours/AnnotationToPointData.js +8 -6
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +3 -3
|
@@ -4,6 +4,7 @@ import { LivewirePath } from '../../utilities/livewire/LiveWirePath';
|
|
|
4
4
|
import { triggerAnnotationModified } from '../../stateManagement/annotation/helpers/state';
|
|
5
5
|
import { ChangeTypes } from '../../enums';
|
|
6
6
|
import { drawPolyline as drawPolylineSvg } from '../../drawingSvg';
|
|
7
|
+
import AnnotationToPointData from '../../utilities/contours/AnnotationToPointData';
|
|
7
8
|
class LivewireContourSegmentationTool extends LivewireContourTool {
|
|
8
9
|
static { this.toolName = 'LivewireContourSegmentationTool'; }
|
|
9
10
|
updateInterpolatedAnnotation(annotation, enabledElement) {
|
|
@@ -85,5 +86,8 @@ class LivewireContourSegmentationTool extends LivewireContourTool {
|
|
|
85
86
|
isContourSegmentationTool() {
|
|
86
87
|
return true;
|
|
87
88
|
}
|
|
89
|
+
static {
|
|
90
|
+
AnnotationToPointData.register(this);
|
|
91
|
+
}
|
|
88
92
|
}
|
|
89
93
|
export default LivewireContourSegmentationTool;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AnnotationRenderContext, PublicToolProps } from '../../types';
|
|
2
2
|
import PlanarFreehandROITool from './PlanarFreehandROITool';
|
|
3
|
-
declare class PlanarFreehandContourSegmentationTool extends PlanarFreehandROITool {
|
|
3
|
+
export declare class PlanarFreehandContourSegmentationTool extends PlanarFreehandROITool {
|
|
4
4
|
static toolName: string;
|
|
5
5
|
constructor(toolProps: PublicToolProps);
|
|
6
6
|
protected isContourSegmentationTool(): boolean;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { utilities } from '@cornerstonejs/core';
|
|
2
2
|
import { triggerSegmentationDataModified } from '../../stateManagement/segmentation/triggerSegmentationEvents';
|
|
3
3
|
import PlanarFreehandROITool from './PlanarFreehandROITool';
|
|
4
|
-
|
|
4
|
+
import AnnotationToPointData from '../../utilities/contours/AnnotationToPointData';
|
|
5
|
+
export class PlanarFreehandContourSegmentationTool extends PlanarFreehandROITool {
|
|
5
6
|
static { this.toolName = 'PlanarFreehandContourSegmentationTool'; }
|
|
6
7
|
constructor(toolProps) {
|
|
7
8
|
const initialProps = utilities.deepMerge({
|
|
@@ -12,6 +13,9 @@ class PlanarFreehandContourSegmentationTool extends PlanarFreehandROITool {
|
|
|
12
13
|
}, toolProps);
|
|
13
14
|
super(initialProps);
|
|
14
15
|
}
|
|
16
|
+
static {
|
|
17
|
+
AnnotationToPointData.register(this);
|
|
18
|
+
}
|
|
15
19
|
isContourSegmentationTool() {
|
|
16
20
|
return true;
|
|
17
21
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AnnotationTool } from '../base';
|
|
2
1
|
import { CONSTANTS, getEnabledElement, VolumeViewport, utilities as csUtils, metaData, } from '@cornerstonejs/core';
|
|
3
2
|
import { vec3 } from 'gl-matrix';
|
|
4
3
|
import { getCalibratedLengthUnitsAndScale } from '../../utilities/getCalibratedUnits';
|
|
@@ -4,6 +4,12 @@ import AnnotationTool from './AnnotationTool';
|
|
|
4
4
|
import type { ContourWindingDirection } from '../../types/ContourAnnotation';
|
|
5
5
|
declare abstract class ContourBaseTool extends AnnotationTool {
|
|
6
6
|
constructor(toolProps: PublicToolProps, defaultToolProps: ToolProps);
|
|
7
|
+
static getContourSequence(toolData: any, metadataProvider: any): {
|
|
8
|
+
NumberOfContourPoints: number;
|
|
9
|
+
ContourImageSequence: any;
|
|
10
|
+
ContourGeometricType: string;
|
|
11
|
+
ContourData: any[];
|
|
12
|
+
};
|
|
7
13
|
renderAnnotation(enabledElement: Types.IEnabledElement, svgDrawingHelper: SVGDrawingHelper): boolean;
|
|
8
14
|
protected createAnnotation(evt: EventTypes.InteractionEventType): ContourAnnotation;
|
|
9
15
|
protected addAnnotation(annotation: Annotation, element: HTMLDivElement): string;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getEnabledElement } from '@cornerstonejs/core';
|
|
2
1
|
import { addAnnotation, getAnnotations, getChildAnnotations, } from '../../stateManagement/annotation/annotationState';
|
|
3
2
|
import { drawPath as drawPathSvg } from '../../drawingSvg';
|
|
4
3
|
import AnnotationTool from './AnnotationTool';
|
|
@@ -8,6 +7,23 @@ class ContourBaseTool extends AnnotationTool {
|
|
|
8
7
|
constructor(toolProps, defaultToolProps) {
|
|
9
8
|
super(toolProps, defaultToolProps);
|
|
10
9
|
}
|
|
10
|
+
static getContourSequence(toolData, metadataProvider) {
|
|
11
|
+
const { data } = toolData;
|
|
12
|
+
const ContourData = [];
|
|
13
|
+
for (const point of data.contour.polyline) {
|
|
14
|
+
for (const v of point) {
|
|
15
|
+
ContourData.push(v.toFixed(2));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const { referencedImageId } = toolData.metadata;
|
|
19
|
+
const ContourImageSequence = metadataProvider.get('ImageSopInstanceReference', referencedImageId);
|
|
20
|
+
return {
|
|
21
|
+
NumberOfContourPoints: ContourData.length / 3,
|
|
22
|
+
ContourImageSequence,
|
|
23
|
+
ContourGeometricType: 'CLOSED_PLANAR',
|
|
24
|
+
ContourData,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
11
27
|
renderAnnotation(enabledElement, svgDrawingHelper) {
|
|
12
28
|
let renderStatus = false;
|
|
13
29
|
const { viewport } = enabledElement;
|
|
@@ -108,14 +108,20 @@ function _checkContourGeometryMatchViewport(geometryIds, viewportNormal) {
|
|
|
108
108
|
return false;
|
|
109
109
|
}
|
|
110
110
|
const contours = geometryData.contours;
|
|
111
|
-
const points = contours[0]
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
const { points } = contours[0];
|
|
112
|
+
const [point] = points;
|
|
113
|
+
const delta = vec3.create();
|
|
114
|
+
const { length } = points;
|
|
115
|
+
const increment = Math.ceil(length / 25);
|
|
116
|
+
for (let i = 1; i < length; i += increment) {
|
|
117
|
+
const point2 = points[i];
|
|
118
|
+
vec3.sub(delta, point, point2);
|
|
119
|
+
vec3.normalize(delta, delta);
|
|
120
|
+
if (vec3.dot(viewportNormal, delta) > 0.1) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return true;
|
|
119
125
|
}
|
|
120
126
|
function _checkContourNormalsMatchViewport(annotationUIDsMap, viewportNormal) {
|
|
121
127
|
const annotationUIDs = Array.from(annotationUIDsMap.values())
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
+
import type { Types } from '@cornerstonejs/core';
|
|
2
|
+
type ContourSequence = {
|
|
3
|
+
NumberOfContourPoints: number;
|
|
4
|
+
ContourImageSequence: Types.NormalModule[];
|
|
5
|
+
ContourGeometricType: string;
|
|
6
|
+
ContourData: string[];
|
|
7
|
+
};
|
|
8
|
+
type ContourSequenceProvider = {
|
|
9
|
+
getContourSequence: (annotation: any, metadataProvider: any) => ContourSequence | ContourSequence[];
|
|
10
|
+
};
|
|
1
11
|
declare class AnnotationToPointData {
|
|
2
|
-
static TOOL_NAMES: Record<string,
|
|
12
|
+
static TOOL_NAMES: Record<string, ContourSequenceProvider>;
|
|
3
13
|
constructor();
|
|
4
|
-
static convert(annotation: any,
|
|
14
|
+
static convert(annotation: any, segment: any, metadataProvider: any): {
|
|
5
15
|
ReferencedROINumber: any;
|
|
6
|
-
ROIDisplayColor:
|
|
7
|
-
ContourSequence:
|
|
16
|
+
ROIDisplayColor: any;
|
|
17
|
+
ContourSequence: ContourSequence[];
|
|
8
18
|
};
|
|
9
19
|
static register(toolClass: any): void;
|
|
10
20
|
}
|
|
@@ -3,7 +3,7 @@ function validateAnnotation(annotation) {
|
|
|
3
3
|
if (!annotation?.data) {
|
|
4
4
|
throw new Error('Tool data is empty');
|
|
5
5
|
}
|
|
6
|
-
if (!annotation.metadata || annotation.metadata.referencedImageId) {
|
|
6
|
+
if (!annotation.metadata || !annotation.metadata.referencedImageId) {
|
|
7
7
|
throw new Error('Tool data is not associated with any imageId');
|
|
8
8
|
}
|
|
9
9
|
}
|
|
@@ -11,23 +11,25 @@ class AnnotationToPointData {
|
|
|
11
11
|
static { this.TOOL_NAMES = {}; }
|
|
12
12
|
constructor() {
|
|
13
13
|
}
|
|
14
|
-
static convert(annotation,
|
|
14
|
+
static convert(annotation, segment, metadataProvider) {
|
|
15
15
|
validateAnnotation(annotation);
|
|
16
16
|
const { toolName } = annotation.metadata;
|
|
17
17
|
const toolClass = AnnotationToPointData.TOOL_NAMES[toolName];
|
|
18
18
|
if (!toolClass) {
|
|
19
19
|
throw new Error(`Unknown tool type: ${toolName}, cannot convert to RTSSReport`);
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
const color = [
|
|
21
|
+
const contourSequence = toolClass.getContourSequence(annotation, metadataProvider);
|
|
22
|
+
const color = segment.color?.slice(0, 3) || [
|
|
23
23
|
Math.floor(Math.random() * 255),
|
|
24
24
|
Math.floor(Math.random() * 255),
|
|
25
25
|
Math.floor(Math.random() * 255),
|
|
26
26
|
];
|
|
27
27
|
return {
|
|
28
|
-
ReferencedROINumber:
|
|
28
|
+
ReferencedROINumber: segment.segmentIndex,
|
|
29
29
|
ROIDisplayColor: color,
|
|
30
|
-
ContourSequence
|
|
30
|
+
ContourSequence: Array.isArray(contourSequence)
|
|
31
|
+
? contourSequence
|
|
32
|
+
: [contourSequence],
|
|
31
33
|
};
|
|
32
34
|
}
|
|
33
35
|
static register(toolClass) {
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "4.11.
|
|
1
|
+
export declare const version = "4.11.3";
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '4.11.
|
|
1
|
+
export const version = '4.11.3';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "4.11.
|
|
3
|
+
"version": "4.11.3",
|
|
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.11.
|
|
111
|
+
"@cornerstonejs/core": "4.11.3",
|
|
112
112
|
"@kitware/vtk.js": "32.12.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": "e7b0cea10f4ceb71710d3f01eaead75152180b7a"
|
|
131
131
|
}
|