@cornerstonejs/tools 0.56.6 → 0.57.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/stateManagement/segmentation/SegmentationStateManager.d.ts +1 -1
- package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.js +5 -2
- package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/config/segmentationColor.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/config/segmentationVisibility.js +23 -5
- package/dist/cjs/stateManagement/segmentation/config/segmentationVisibility.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/segmentationState.js +0 -10
- package/dist/cjs/stateManagement/segmentation/segmentationState.js.map +1 -1
- package/dist/cjs/tools/displayTools/Contour/addContourSetsToElement.d.ts +3 -0
- package/dist/cjs/tools/displayTools/Contour/addContourSetsToElement.js +70 -0
- package/dist/cjs/tools/displayTools/Contour/addContourSetsToElement.js.map +1 -0
- package/dist/cjs/tools/displayTools/Contour/addOrUpdateContourSets.d.ts +3 -0
- package/dist/cjs/tools/displayTools/Contour/addOrUpdateContourSets.js +14 -0
- package/dist/cjs/tools/displayTools/Contour/addOrUpdateContourSets.js.map +1 -0
- package/dist/cjs/tools/displayTools/Contour/contourConfig.d.ts +3 -0
- package/dist/cjs/tools/displayTools/Contour/contourConfig.js +14 -0
- package/dist/cjs/tools/displayTools/Contour/contourConfig.js.map +1 -0
- package/dist/cjs/tools/displayTools/Contour/contourConfigCache.d.ts +9 -0
- package/dist/cjs/tools/displayTools/Contour/contourConfigCache.js +17 -0
- package/dist/cjs/tools/displayTools/Contour/contourConfigCache.js.map +1 -0
- package/dist/cjs/tools/displayTools/Contour/contourDisplay.d.ts +1 -1
- package/dist/cjs/tools/displayTools/Contour/contourDisplay.js +4 -52
- package/dist/cjs/tools/displayTools/Contour/contourDisplay.js.map +1 -1
- package/dist/cjs/tools/displayTools/Contour/updateContourSets.d.ts +3 -0
- package/dist/cjs/tools/displayTools/Contour/updateContourSets.js +78 -0
- package/dist/cjs/tools/displayTools/Contour/updateContourSets.js.map +1 -0
- package/dist/cjs/tools/displayTools/Contour/utils.d.ts +6 -0
- package/dist/cjs/tools/displayTools/Contour/utils.js +63 -0
- package/dist/cjs/tools/displayTools/Contour/utils.js.map +1 -0
- package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
- package/dist/cjs/types/ContourTypes.d.ts +1 -0
- package/dist/cjs/types/SegmentationStateTypes.d.ts +4 -4
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.d.ts +1 -1
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +5 -2
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/config/segmentationColor.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js +19 -5
- package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/segmentationState.js +1 -11
- package/dist/esm/stateManagement/segmentation/segmentationState.js.map +1 -1
- package/dist/esm/tools/displayTools/Contour/addContourSetsToElement.d.ts +3 -0
- package/dist/esm/tools/displayTools/Contour/addContourSetsToElement.js +63 -0
- package/dist/esm/tools/displayTools/Contour/addContourSetsToElement.js.map +1 -0
- package/dist/esm/tools/displayTools/Contour/addOrUpdateContourSets.d.ts +3 -0
- package/dist/esm/tools/displayTools/Contour/addOrUpdateContourSets.js +10 -0
- package/dist/esm/tools/displayTools/Contour/addOrUpdateContourSets.js.map +1 -0
- package/dist/esm/tools/displayTools/Contour/contourConfig.d.ts +3 -0
- package/dist/esm/tools/displayTools/Contour/contourConfig.js +12 -0
- package/dist/esm/tools/displayTools/Contour/contourConfig.js.map +1 -0
- package/dist/esm/tools/displayTools/Contour/contourConfigCache.d.ts +9 -0
- package/dist/esm/tools/displayTools/Contour/contourConfigCache.js +11 -0
- package/dist/esm/tools/displayTools/Contour/contourConfigCache.js.map +1 -0
- package/dist/esm/tools/displayTools/Contour/contourDisplay.d.ts +1 -1
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js +6 -54
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js.map +1 -1
- package/dist/esm/tools/displayTools/Contour/updateContourSets.d.ts +3 -0
- package/dist/esm/tools/displayTools/Contour/updateContourSets.js +71 -0
- package/dist/esm/tools/displayTools/Contour/updateContourSets.js.map +1 -0
- package/dist/esm/tools/displayTools/Contour/utils.d.ts +6 -0
- package/dist/esm/tools/displayTools/Contour/utils.js +53 -0
- package/dist/esm/tools/displayTools/Contour/utils.js.map +1 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
- package/dist/esm/types/ContourTypes.d.ts +1 -0
- package/dist/esm/types/SegmentationStateTypes.d.ts +4 -4
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/stateManagement/segmentation/SegmentationStateManager.ts +10 -7
- package/src/stateManagement/segmentation/config/segmentationColor.ts +1 -0
- package/src/stateManagement/segmentation/config/segmentationVisibility.ts +25 -7
- package/src/stateManagement/segmentation/segmentationState.ts +7 -23
- package/src/tools/displayTools/Contour/addContourSetsToElement.ts +110 -0
- package/src/tools/displayTools/Contour/addOrUpdateContourSets.ts +28 -0
- package/src/tools/displayTools/Contour/contourConfig.ts +15 -0
- package/src/tools/displayTools/Contour/contourConfigCache.ts +37 -0
- package/src/tools/displayTools/Contour/contourDisplay.ts +11 -91
- package/src/tools/displayTools/Contour/updateContourSets.ts +111 -0
- package/src/tools/displayTools/Contour/utils.ts +117 -0
- package/src/tools/displayTools/Labelmap/labelmapDisplay.ts +5 -2
- package/src/types/ContourTypes.ts +2 -0
- package/src/types/SegmentationStateTypes.ts +22 -8
- package/src/types/index.ts +2 -0
- package/dist/cjs/tools/displayTools/Contour/addContourToElement.d.ts +0 -4
- package/dist/cjs/tools/displayTools/Contour/addContourToElement.js +0 -87
- package/dist/cjs/tools/displayTools/Contour/addContourToElement.js.map +0 -1
- package/dist/esm/tools/displayTools/Contour/addContourToElement.d.ts +0 -4
- package/dist/esm/tools/displayTools/Contour/addContourToElement.js +0 -80
- package/dist/esm/tools/displayTools/Contour/addContourToElement.js.map +0 -1
- package/src/tools/displayTools/Contour/addContourToElement.ts +0 -135
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Enums, Types } from '@cornerstonejs/core';
|
|
2
|
+
import vtkCellArray from '@kitware/vtk.js/Common/Core/CellArray';
|
|
3
|
+
import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
|
|
4
|
+
import vtkPoints from '@kitware/vtk.js/Common/Core/Points';
|
|
5
|
+
import vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData';
|
|
6
|
+
import { ToolGroupSpecificContourRepresentation } from '../../../types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* If the segment specific config exists for the given segment id, it returns
|
|
10
|
+
* the segment specific config. Otherwise, it looks for the segment specific
|
|
11
|
+
* config for the given index. If it doesn't exist, it returns null.
|
|
12
|
+
*
|
|
13
|
+
* @param contourRepresentation - The representation object that is passed
|
|
14
|
+
* to the tool.
|
|
15
|
+
* @param segmentId - The id of the segment.
|
|
16
|
+
* @param index - The index of the segment in the list of segments.
|
|
17
|
+
* @returns the segment specific config for the given segment id.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
export function getSegmentSpecificConfig(
|
|
21
|
+
contourRepresentation: ToolGroupSpecificContourRepresentation,
|
|
22
|
+
segmentId: string,
|
|
23
|
+
index: number
|
|
24
|
+
) {
|
|
25
|
+
let segmentSpecificConfig =
|
|
26
|
+
contourRepresentation.segmentSpecificConfig?.[segmentId];
|
|
27
|
+
|
|
28
|
+
if (!segmentSpecificConfig) {
|
|
29
|
+
// try the index
|
|
30
|
+
segmentSpecificConfig =
|
|
31
|
+
contourRepresentation.segmentSpecificConfig?.[index];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!segmentSpecificConfig) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return segmentSpecificConfig.CONTOUR;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* takes a geometry object as an argument
|
|
43
|
+
* and throws an error if the geometry object is not a contour
|
|
44
|
+
* @param geometry - The geometry object to be rendered.
|
|
45
|
+
*/
|
|
46
|
+
export function validateGeometry(geometry: Types.IGeometry): void {
|
|
47
|
+
if (!geometry) {
|
|
48
|
+
throw new Error(`No contours found for geometryId ${geometry.id}`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const geometryId = geometry.id;
|
|
52
|
+
|
|
53
|
+
if (geometry.type !== Enums.GeometryType.CONTOUR) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`Geometry type ${geometry.type} not supported for rendering.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!geometry.data) {
|
|
60
|
+
console.warn(
|
|
61
|
+
`No contours found for geometryId ${geometryId}. Skipping render.`
|
|
62
|
+
);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* It takes a contourSet and returns a vtkPolyData for that contourSet. A contour set
|
|
69
|
+
* is a collection of contours. Each contour is a collection of points. Each point
|
|
70
|
+
* is x,y,z in the world coordinate system.
|
|
71
|
+
*
|
|
72
|
+
* @param contourSet - the contour set that you want to convert to polyData
|
|
73
|
+
* @returns A vtkPolyData object
|
|
74
|
+
*/
|
|
75
|
+
export function getPolyData(contourSet: Types.IContourSet) {
|
|
76
|
+
const pointArray = [];
|
|
77
|
+
|
|
78
|
+
const points = vtkPoints.newInstance();
|
|
79
|
+
const lines = vtkCellArray.newInstance();
|
|
80
|
+
|
|
81
|
+
// this variable will indicate the index of the first point in the current line
|
|
82
|
+
// so we can correctly generate the point index list to add in the cellArray
|
|
83
|
+
let pointIndex = 0;
|
|
84
|
+
contourSet.getContours().forEach((contour: Types.IContour) => {
|
|
85
|
+
const pointList = contour.getPoints();
|
|
86
|
+
const flatPoints = contour.getFlatPointsArray();
|
|
87
|
+
const type = contour.getType();
|
|
88
|
+
|
|
89
|
+
// creating a point index list that defines a line
|
|
90
|
+
const pointIndexes = pointList.map(
|
|
91
|
+
(_, pointListIndex) => pointListIndex + pointIndex
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
// if close planar, add the first point index to the list
|
|
95
|
+
if (type === Enums.ContourType.CLOSED_PLANAR) {
|
|
96
|
+
pointIndexes.push(pointIndexes[0]);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const linePoints = Float32Array.from(flatPoints);
|
|
100
|
+
// add the current points into the point list
|
|
101
|
+
pointArray.push(...linePoints);
|
|
102
|
+
// add the point indexes into the cell array
|
|
103
|
+
lines.insertNextCell([...pointIndexes]);
|
|
104
|
+
// update the first point index
|
|
105
|
+
pointIndex = pointIndex + pointList.length;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// converts the pointArray into vtkPoints
|
|
109
|
+
points.setData(pointArray, 3);
|
|
110
|
+
|
|
111
|
+
// creates the polyData
|
|
112
|
+
const polygon = vtkPolyData.newInstance();
|
|
113
|
+
polygon.setPoints(points);
|
|
114
|
+
polygon.setLines(lines);
|
|
115
|
+
|
|
116
|
+
return polygon;
|
|
117
|
+
}
|
|
@@ -12,7 +12,10 @@ import Representations from '../../../enums/SegmentationRepresentations';
|
|
|
12
12
|
import * as SegmentationConfig from '../../../stateManagement/segmentation/config/segmentationConfig';
|
|
13
13
|
import * as SegmentationState from '../../../stateManagement/segmentation/segmentationState';
|
|
14
14
|
import { getToolGroup } from '../../../store/ToolGroupManager';
|
|
15
|
-
import type {
|
|
15
|
+
import type {
|
|
16
|
+
LabelmapConfig,
|
|
17
|
+
LabelmapRenderingConfig,
|
|
18
|
+
} from '../../../types/LabelmapTypes';
|
|
16
19
|
import {
|
|
17
20
|
RepresentationPublicInput,
|
|
18
21
|
SegmentationRepresentationConfig,
|
|
@@ -179,7 +182,7 @@ async function render(
|
|
|
179
182
|
actorEntry = viewport.getActor(segmentationRepresentationUID);
|
|
180
183
|
}
|
|
181
184
|
|
|
182
|
-
const { cfun, ofun } = renderingConfig;
|
|
185
|
+
const { cfun, ofun } = renderingConfig as LabelmapRenderingConfig;
|
|
183
186
|
|
|
184
187
|
const renderInactiveSegmentations =
|
|
185
188
|
toolGroupConfig.renderInactiveSegmentations;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as Enums from '../enums';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ContourConfig,
|
|
4
|
+
ContourRenderingConfig,
|
|
5
|
+
ContourSegmentationData,
|
|
6
|
+
} from './ContourTypes';
|
|
3
7
|
import type {
|
|
4
8
|
LabelmapConfig,
|
|
5
9
|
LabelmapRenderingConfig,
|
|
@@ -18,11 +22,8 @@ export type Color = [number, number, number, number];
|
|
|
18
22
|
export type ColorLUT = Array<Color>;
|
|
19
23
|
|
|
20
24
|
export type SegmentSpecificRepresentationConfig = {
|
|
21
|
-
[key: number]: RepresentationConfig;
|
|
25
|
+
[key: number | string]: RepresentationConfig;
|
|
22
26
|
};
|
|
23
|
-
/**
|
|
24
|
-
* Segmentation Config
|
|
25
|
-
*/
|
|
26
27
|
|
|
27
28
|
export type RepresentationConfig = {
|
|
28
29
|
/** labelmap configuration */
|
|
@@ -126,13 +127,14 @@ export type ToolGroupSpecificLabelmapRepresentation =
|
|
|
126
127
|
|
|
127
128
|
export type ToolGroupSpecificContourRepresentation =
|
|
128
129
|
ToolGroupSpecificRepresentationState & {
|
|
129
|
-
config:
|
|
130
|
+
config: ContourRenderingConfig;
|
|
130
131
|
segmentationRepresentationSpecificConfig?: RepresentationConfig;
|
|
131
132
|
segmentSpecificConfig?: SegmentSpecificRepresentationConfig;
|
|
132
133
|
};
|
|
133
134
|
|
|
134
135
|
export type ToolGroupSpecificRepresentation =
|
|
135
|
-
|
|
136
|
+
| ToolGroupSpecificLabelmapRepresentation
|
|
137
|
+
| ToolGroupSpecificContourRepresentation;
|
|
136
138
|
|
|
137
139
|
export type ToolGroupSpecificRepresentations =
|
|
138
140
|
Array<ToolGroupSpecificRepresentation>;
|
|
@@ -194,11 +196,23 @@ export type ToolGroupSpecificRepresentations =
|
|
|
194
196
|
* colorLUTIndex: 0,
|
|
195
197
|
* visibility: true,
|
|
196
198
|
* segmentsHidden: Set(),
|
|
197
|
-
* //
|
|
199
|
+
* // rendering config
|
|
198
200
|
* config: {
|
|
199
201
|
* "cfun",
|
|
200
202
|
* "ofun",
|
|
201
203
|
* },
|
|
204
|
+
* // segmentation representation specific config, has priority over the one in the outer scope
|
|
205
|
+
* segmentationRepresentationSpecificConfig: {
|
|
206
|
+
* LABELMAP: {
|
|
207
|
+
* renderFill: true,
|
|
208
|
+
* }
|
|
209
|
+
* }
|
|
210
|
+
* // segment specific config
|
|
211
|
+
* segmentSpecificConfig: {
|
|
212
|
+
* 1: {
|
|
213
|
+
* renderFill: false,
|
|
214
|
+
* }
|
|
215
|
+
* },
|
|
202
216
|
* },
|
|
203
217
|
* ],
|
|
204
218
|
* config: {
|
package/src/types/index.ts
CHANGED
|
@@ -36,6 +36,7 @@ import type {
|
|
|
36
36
|
SegmentationRepresentationData,
|
|
37
37
|
Segmentation,
|
|
38
38
|
ToolGroupSpecificRepresentationState,
|
|
39
|
+
ToolGroupSpecificContourRepresentation,
|
|
39
40
|
ToolGroupSpecificLabelmapRepresentation,
|
|
40
41
|
ToolGroupSpecificRepresentation,
|
|
41
42
|
SegmentationState,
|
|
@@ -91,6 +92,7 @@ export type {
|
|
|
91
92
|
SegmentationRepresentationConfig,
|
|
92
93
|
RepresentationConfig,
|
|
93
94
|
ToolGroupSpecificRepresentationState,
|
|
95
|
+
ToolGroupSpecificContourRepresentation,
|
|
94
96
|
ToolGroupSpecificLabelmapRepresentation,
|
|
95
97
|
ToolGroupSpecificRepresentation,
|
|
96
98
|
RepresentationPublicInput,
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Types } from '@cornerstonejs/core';
|
|
2
|
-
declare function addContourToElement(element: HTMLDivElement, contour: Types.IContour, actorUID: string): void;
|
|
3
|
-
declare function addContourSetToElement(element: HTMLDivElement, contourSet: Types.IContourSet, actorUID: string): void;
|
|
4
|
-
export { addContourToElement, addContourSetToElement };
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.addContourSetToElement = exports.addContourToElement = void 0;
|
|
7
|
-
const core_1 = require("@cornerstonejs/core");
|
|
8
|
-
const PolyData_1 = __importDefault(require("@kitware/vtk.js/Common/DataModel/PolyData"));
|
|
9
|
-
const CellArray_1 = __importDefault(require("@kitware/vtk.js/Common/Core/CellArray"));
|
|
10
|
-
const Points_1 = __importDefault(require("@kitware/vtk.js/Common/Core/Points"));
|
|
11
|
-
const Mapper_1 = __importDefault(require("@kitware/vtk.js/Rendering/Core/Mapper"));
|
|
12
|
-
const Actor_1 = __importDefault(require("@kitware/vtk.js/Rendering/Core/Actor"));
|
|
13
|
-
function addContourToElement(element, contour, actorUID) {
|
|
14
|
-
const enabledElement = (0, core_1.getEnabledElement)(element);
|
|
15
|
-
const { renderingEngine, viewport } = enabledElement;
|
|
16
|
-
const { id: viewportId } = viewport;
|
|
17
|
-
const visibility = true;
|
|
18
|
-
const immediateRender = false;
|
|
19
|
-
const suppressEvents = true;
|
|
20
|
-
const pointList = contour.getPoints();
|
|
21
|
-
const flatPoints = contour.getFlatPointsArray();
|
|
22
|
-
const color = contour.getColor();
|
|
23
|
-
const type = contour.getType();
|
|
24
|
-
const p = pointList.map((_, i) => i);
|
|
25
|
-
if (type === core_1.Enums.ContourType.CLOSED_PLANAR) {
|
|
26
|
-
p.push(0);
|
|
27
|
-
}
|
|
28
|
-
const var1 = Float32Array.from(flatPoints);
|
|
29
|
-
const var2 = Uint32Array.from([p.length, ...p]);
|
|
30
|
-
const colorToUse = color.map((c) => c / 255);
|
|
31
|
-
const points = Points_1.default.newInstance();
|
|
32
|
-
points.setData(var1, 3);
|
|
33
|
-
const lines = CellArray_1.default.newInstance();
|
|
34
|
-
lines.setData(var2, 3);
|
|
35
|
-
const polygon = PolyData_1.default.newInstance();
|
|
36
|
-
polygon.setPoints(points);
|
|
37
|
-
polygon.setLines(lines);
|
|
38
|
-
const mapper1 = Mapper_1.default.newInstance();
|
|
39
|
-
mapper1.setInputData(polygon);
|
|
40
|
-
const actor1 = Actor_1.default.newInstance();
|
|
41
|
-
actor1.setMapper(mapper1);
|
|
42
|
-
actor1.getProperty().setLineWidth(4);
|
|
43
|
-
actor1.getProperty().setColor(colorToUse[0], colorToUse[1], colorToUse[2]);
|
|
44
|
-
viewport.addActor({ actor: actor1, uid: actorUID });
|
|
45
|
-
}
|
|
46
|
-
exports.addContourToElement = addContourToElement;
|
|
47
|
-
function addContourSetToElement(element, contourSet, actorUID) {
|
|
48
|
-
const enabledElement = (0, core_1.getEnabledElement)(element);
|
|
49
|
-
const { renderingEngine, viewport } = enabledElement;
|
|
50
|
-
const { id: viewportId } = viewport;
|
|
51
|
-
const visibility = true;
|
|
52
|
-
const immediateRender = false;
|
|
53
|
-
const suppressEvents = true;
|
|
54
|
-
const actor1 = Actor_1.default.newInstance();
|
|
55
|
-
let color;
|
|
56
|
-
const pointArray = [];
|
|
57
|
-
const points = Points_1.default.newInstance();
|
|
58
|
-
const lines = CellArray_1.default.newInstance();
|
|
59
|
-
let pointIndex = 0;
|
|
60
|
-
contourSet.getContours().forEach((contour) => {
|
|
61
|
-
const pointList = contour.getPoints();
|
|
62
|
-
const flatPoints = contour.getFlatPointsArray();
|
|
63
|
-
color = contour.getColor();
|
|
64
|
-
const type = contour.getType();
|
|
65
|
-
const pointIndexes = pointList.map((_, i) => i + pointIndex);
|
|
66
|
-
if (type === core_1.Enums.ContourType.CLOSED_PLANAR) {
|
|
67
|
-
pointIndexes.push(pointIndexes[0]);
|
|
68
|
-
}
|
|
69
|
-
const linePoints = Float32Array.from(flatPoints);
|
|
70
|
-
pointArray.push(...linePoints);
|
|
71
|
-
lines.insertNextCell([...pointIndexes]);
|
|
72
|
-
pointIndex = pointIndex + pointList.length;
|
|
73
|
-
});
|
|
74
|
-
points.setData(pointArray, 3);
|
|
75
|
-
const polygon = PolyData_1.default.newInstance();
|
|
76
|
-
polygon.setPoints(points);
|
|
77
|
-
polygon.setLines(lines);
|
|
78
|
-
const mapper1 = Mapper_1.default.newInstance();
|
|
79
|
-
mapper1.setInputData(polygon);
|
|
80
|
-
actor1.setMapper(mapper1);
|
|
81
|
-
actor1.getProperty().setLineWidth(4);
|
|
82
|
-
const colorToUse = color.map((c) => c / 255);
|
|
83
|
-
actor1.getProperty().setColor(colorToUse[0], colorToUse[1], colorToUse[2]);
|
|
84
|
-
viewport.addActor({ actor: actor1, uid: actorUID });
|
|
85
|
-
}
|
|
86
|
-
exports.addContourSetToElement = addContourSetToElement;
|
|
87
|
-
//# sourceMappingURL=addContourToElement.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addContourToElement.js","sourceRoot":"","sources":["../../../../../src/tools/displayTools/Contour/addContourToElement.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsE;AACtE,yFAAoE;AACpE,sFAAiE;AACjE,gFAA2D;AAC3D,mFAA8D;AAC9D,iFAA4D;AAK5D,SAAS,mBAAmB,CAC1B,OAAuB,EACvB,OAAuB,EACvB,QAAgB;IAEhB,MAAM,cAAc,GAAG,IAAA,wBAAiB,EAAC,OAAO,CAAC,CAAC;IAClD,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,GAAG,cAAc,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YAAY,CAAC,CAAC,CAAC,CAAC;IAIrC,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IAC7C,MAAM,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3E,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;AACtD,CAAC;AAE6B,wDAAsB"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Types } from '@cornerstonejs/core';
|
|
2
|
-
declare function addContourToElement(element: HTMLDivElement, contour: Types.IContour, actorUID: string): void;
|
|
3
|
-
declare function addContourSetToElement(element: HTMLDivElement, contourSet: Types.IContourSet, actorUID: string): void;
|
|
4
|
-
export { addContourToElement, addContourSetToElement };
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { getEnabledElement, Enums } from '@cornerstonejs/core';
|
|
2
|
-
import vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData';
|
|
3
|
-
import vtkCellArray from '@kitware/vtk.js/Common/Core/CellArray';
|
|
4
|
-
import vtkPoints from '@kitware/vtk.js/Common/Core/Points';
|
|
5
|
-
import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
|
|
6
|
-
import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
|
|
7
|
-
function addContourToElement(element, contour, actorUID) {
|
|
8
|
-
const enabledElement = getEnabledElement(element);
|
|
9
|
-
const { renderingEngine, viewport } = enabledElement;
|
|
10
|
-
const { id: viewportId } = viewport;
|
|
11
|
-
const visibility = true;
|
|
12
|
-
const immediateRender = false;
|
|
13
|
-
const suppressEvents = true;
|
|
14
|
-
const pointList = contour.getPoints();
|
|
15
|
-
const flatPoints = contour.getFlatPointsArray();
|
|
16
|
-
const color = contour.getColor();
|
|
17
|
-
const type = contour.getType();
|
|
18
|
-
const p = pointList.map((_, i) => i);
|
|
19
|
-
if (type === Enums.ContourType.CLOSED_PLANAR) {
|
|
20
|
-
p.push(0);
|
|
21
|
-
}
|
|
22
|
-
const var1 = Float32Array.from(flatPoints);
|
|
23
|
-
const var2 = Uint32Array.from([p.length, ...p]);
|
|
24
|
-
const colorToUse = color.map((c) => c / 255);
|
|
25
|
-
const points = vtkPoints.newInstance();
|
|
26
|
-
points.setData(var1, 3);
|
|
27
|
-
const lines = vtkCellArray.newInstance();
|
|
28
|
-
lines.setData(var2, 3);
|
|
29
|
-
const polygon = vtkPolyData.newInstance();
|
|
30
|
-
polygon.setPoints(points);
|
|
31
|
-
polygon.setLines(lines);
|
|
32
|
-
const mapper1 = vtkMapper.newInstance();
|
|
33
|
-
mapper1.setInputData(polygon);
|
|
34
|
-
const actor1 = vtkActor.newInstance();
|
|
35
|
-
actor1.setMapper(mapper1);
|
|
36
|
-
actor1.getProperty().setLineWidth(4);
|
|
37
|
-
actor1.getProperty().setColor(colorToUse[0], colorToUse[1], colorToUse[2]);
|
|
38
|
-
viewport.addActor({ actor: actor1, uid: actorUID });
|
|
39
|
-
}
|
|
40
|
-
function addContourSetToElement(element, contourSet, actorUID) {
|
|
41
|
-
const enabledElement = getEnabledElement(element);
|
|
42
|
-
const { renderingEngine, viewport } = enabledElement;
|
|
43
|
-
const { id: viewportId } = viewport;
|
|
44
|
-
const visibility = true;
|
|
45
|
-
const immediateRender = false;
|
|
46
|
-
const suppressEvents = true;
|
|
47
|
-
const actor1 = vtkActor.newInstance();
|
|
48
|
-
let color;
|
|
49
|
-
const pointArray = [];
|
|
50
|
-
const points = vtkPoints.newInstance();
|
|
51
|
-
const lines = vtkCellArray.newInstance();
|
|
52
|
-
let pointIndex = 0;
|
|
53
|
-
contourSet.getContours().forEach((contour) => {
|
|
54
|
-
const pointList = contour.getPoints();
|
|
55
|
-
const flatPoints = contour.getFlatPointsArray();
|
|
56
|
-
color = contour.getColor();
|
|
57
|
-
const type = contour.getType();
|
|
58
|
-
const pointIndexes = pointList.map((_, i) => i + pointIndex);
|
|
59
|
-
if (type === Enums.ContourType.CLOSED_PLANAR) {
|
|
60
|
-
pointIndexes.push(pointIndexes[0]);
|
|
61
|
-
}
|
|
62
|
-
const linePoints = Float32Array.from(flatPoints);
|
|
63
|
-
pointArray.push(...linePoints);
|
|
64
|
-
lines.insertNextCell([...pointIndexes]);
|
|
65
|
-
pointIndex = pointIndex + pointList.length;
|
|
66
|
-
});
|
|
67
|
-
points.setData(pointArray, 3);
|
|
68
|
-
const polygon = vtkPolyData.newInstance();
|
|
69
|
-
polygon.setPoints(points);
|
|
70
|
-
polygon.setLines(lines);
|
|
71
|
-
const mapper1 = vtkMapper.newInstance();
|
|
72
|
-
mapper1.setInputData(polygon);
|
|
73
|
-
actor1.setMapper(mapper1);
|
|
74
|
-
actor1.getProperty().setLineWidth(4);
|
|
75
|
-
const colorToUse = color.map((c) => c / 255);
|
|
76
|
-
actor1.getProperty().setColor(colorToUse[0], colorToUse[1], colorToUse[2]);
|
|
77
|
-
viewport.addActor({ actor: actor1, uid: actorUID });
|
|
78
|
-
}
|
|
79
|
-
export { addContourToElement, addContourSetToElement };
|
|
80
|
-
//# sourceMappingURL=addContourToElement.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addContourToElement.js","sourceRoot":"","sources":["../../../../../src/tools/displayTools/Contour/addContourToElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAS,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,WAAW,MAAM,2CAA2C,CAAC;AACpE,OAAO,YAAY,MAAM,uCAAuC,CAAC;AACjE,OAAO,SAAS,MAAM,oCAAoC,CAAC;AAC3D,OAAO,SAAS,MAAM,uCAAuC,CAAC;AAC9D,OAAO,QAAQ,MAAM,sCAAsC,CAAC;AAK5D,SAA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OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC9B,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC1B,MAAM,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAIrC,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IAC7C,MAAM,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3E,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;AACtD,CAAC;AAED,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { getEnabledElement, Types, Enums } from '@cornerstonejs/core';
|
|
2
|
-
import vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData';
|
|
3
|
-
import vtkCellArray from '@kitware/vtk.js/Common/Core/CellArray';
|
|
4
|
-
import vtkPoints from '@kitware/vtk.js/Common/Core/Points';
|
|
5
|
-
import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
|
|
6
|
-
import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
|
|
7
|
-
|
|
8
|
-
// Todo: this seems to have performance issues when there are many contours
|
|
9
|
-
// Maybe we should not create one actor per contour, but rather one actor per
|
|
10
|
-
// contourSet?
|
|
11
|
-
function addContourToElement(
|
|
12
|
-
element: HTMLDivElement,
|
|
13
|
-
contour: Types.IContour,
|
|
14
|
-
actorUID: string
|
|
15
|
-
): void {
|
|
16
|
-
const enabledElement = getEnabledElement(element);
|
|
17
|
-
const { renderingEngine, viewport } = enabledElement;
|
|
18
|
-
const { id: viewportId } = viewport;
|
|
19
|
-
|
|
20
|
-
// Default to true since we are setting a new segmentation, however,
|
|
21
|
-
// in the event listener, we will make other segmentations visible/invisible
|
|
22
|
-
// based on the config
|
|
23
|
-
const visibility = true;
|
|
24
|
-
const immediateRender = false;
|
|
25
|
-
const suppressEvents = true;
|
|
26
|
-
|
|
27
|
-
const pointList = contour.getPoints();
|
|
28
|
-
const flatPoints = contour.getFlatPointsArray();
|
|
29
|
-
const color = contour.getColor();
|
|
30
|
-
const type = contour.getType();
|
|
31
|
-
|
|
32
|
-
const p = pointList.map((_, i) => i);
|
|
33
|
-
|
|
34
|
-
if (type === Enums.ContourType.CLOSED_PLANAR) {
|
|
35
|
-
p.push(0);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const var1 = Float32Array.from(flatPoints);
|
|
39
|
-
const var2 = Uint32Array.from([p.length, ...p]);
|
|
40
|
-
|
|
41
|
-
const colorToUse = color.map((c) => c / 255);
|
|
42
|
-
|
|
43
|
-
const points = vtkPoints.newInstance();
|
|
44
|
-
points.setData(var1, 3);
|
|
45
|
-
|
|
46
|
-
const lines = vtkCellArray.newInstance();
|
|
47
|
-
// @ts-ignore
|
|
48
|
-
lines.setData(var2, 3);
|
|
49
|
-
|
|
50
|
-
const polygon = vtkPolyData.newInstance();
|
|
51
|
-
polygon.setPoints(points);
|
|
52
|
-
polygon.setLines(lines);
|
|
53
|
-
|
|
54
|
-
const mapper1 = vtkMapper.newInstance();
|
|
55
|
-
mapper1.setInputData(polygon);
|
|
56
|
-
const actor1 = vtkActor.newInstance();
|
|
57
|
-
actor1.setMapper(mapper1);
|
|
58
|
-
actor1.getProperty().setLineWidth(4);
|
|
59
|
-
actor1.getProperty().setColor(colorToUse[0], colorToUse[1], colorToUse[2]);
|
|
60
|
-
|
|
61
|
-
viewport.addActor({ actor: actor1, uid: actorUID });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function addContourSetToElement(
|
|
65
|
-
element: HTMLDivElement,
|
|
66
|
-
contourSet: Types.IContourSet,
|
|
67
|
-
actorUID: string
|
|
68
|
-
): void {
|
|
69
|
-
const enabledElement = getEnabledElement(element);
|
|
70
|
-
const { renderingEngine, viewport } = enabledElement;
|
|
71
|
-
const { id: viewportId } = viewport;
|
|
72
|
-
|
|
73
|
-
// Default to true since we are setting a new segmentation, however,
|
|
74
|
-
// in the event listener, we will make other segmentations visible/invisible
|
|
75
|
-
// based on the config
|
|
76
|
-
const visibility = true;
|
|
77
|
-
const immediateRender = false;
|
|
78
|
-
const suppressEvents = true;
|
|
79
|
-
|
|
80
|
-
const actor1 = vtkActor.newInstance();
|
|
81
|
-
let color;
|
|
82
|
-
|
|
83
|
-
const pointArray = [];
|
|
84
|
-
|
|
85
|
-
const points = vtkPoints.newInstance();
|
|
86
|
-
const lines = vtkCellArray.newInstance();
|
|
87
|
-
|
|
88
|
-
// this variable will indicate the index of the first point in the current line
|
|
89
|
-
// so we can correctly generate the point index list to add in the cellArray
|
|
90
|
-
let pointIndex = 0;
|
|
91
|
-
contourSet.getContours().forEach((contour: Types.IContour) => {
|
|
92
|
-
const pointList = contour.getPoints();
|
|
93
|
-
const flatPoints = contour.getFlatPointsArray();
|
|
94
|
-
color = contour.getColor();
|
|
95
|
-
const type = contour.getType();
|
|
96
|
-
|
|
97
|
-
// creating a point index list that defines a line
|
|
98
|
-
const pointIndexes = pointList.map((_, i) => i + pointIndex);
|
|
99
|
-
|
|
100
|
-
// if close planar, add the first point index to the list
|
|
101
|
-
if (type === Enums.ContourType.CLOSED_PLANAR) {
|
|
102
|
-
pointIndexes.push(pointIndexes[0]);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const linePoints = Float32Array.from(flatPoints);
|
|
106
|
-
// add the curent points into the point list
|
|
107
|
-
pointArray.push(...linePoints);
|
|
108
|
-
// add the point indexes into the cell array
|
|
109
|
-
lines.insertNextCell([...pointIndexes]);
|
|
110
|
-
// update the first point index
|
|
111
|
-
pointIndex = pointIndex + pointList.length;
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
// converts the pointArray into vtkPoints
|
|
115
|
-
points.setData(pointArray, 3);
|
|
116
|
-
|
|
117
|
-
// creates the polydata
|
|
118
|
-
const polygon = vtkPolyData.newInstance();
|
|
119
|
-
polygon.setPoints(points);
|
|
120
|
-
polygon.setLines(lines);
|
|
121
|
-
|
|
122
|
-
const mapper1 = vtkMapper.newInstance();
|
|
123
|
-
mapper1.setInputData(polygon);
|
|
124
|
-
actor1.setMapper(mapper1);
|
|
125
|
-
actor1.getProperty().setLineWidth(4);
|
|
126
|
-
|
|
127
|
-
// despite each contour can have its own color, we assign the last color to
|
|
128
|
-
// all contours
|
|
129
|
-
const colorToUse = color.map((c) => c / 255);
|
|
130
|
-
actor1.getProperty().setColor(colorToUse[0], colorToUse[1], colorToUse[2]);
|
|
131
|
-
|
|
132
|
-
viewport.addActor({ actor: actor1, uid: actorUID });
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export { addContourToElement, addContourSetToElement };
|