@cornerstonejs/tools 0.60.2 → 0.61.1
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/removeSegmentationsFromToolGroup.js +2 -1
- package/dist/cjs/stateManagement/segmentation/removeSegmentationsFromToolGroup.js.map +1 -1
- package/dist/cjs/tools/displayTools/Contour/contourConfig.js +3 -0
- package/dist/cjs/tools/displayTools/Contour/contourConfig.js.map +1 -1
- package/dist/cjs/tools/displayTools/Contour/contourDisplay.js +2 -0
- package/dist/cjs/tools/displayTools/Contour/contourDisplay.js.map +1 -1
- package/dist/cjs/tools/displayTools/Contour/updateContourSets.js +48 -30
- package/dist/cjs/tools/displayTools/Contour/updateContourSets.js.map +1 -1
- package/dist/cjs/tools/displayTools/Contour/utils.js.map +1 -1
- package/dist/cjs/types/ContourTypes.d.ts +3 -0
- package/dist/esm/stateManagement/segmentation/removeSegmentationsFromToolGroup.js +2 -1
- package/dist/esm/stateManagement/segmentation/removeSegmentationsFromToolGroup.js.map +1 -1
- package/dist/esm/tools/displayTools/Contour/contourConfig.js +3 -0
- package/dist/esm/tools/displayTools/Contour/contourConfig.js.map +1 -1
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js +2 -0
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js.map +1 -1
- package/dist/esm/tools/displayTools/Contour/updateContourSets.js +48 -28
- package/dist/esm/tools/displayTools/Contour/updateContourSets.js.map +1 -1
- package/dist/esm/tools/displayTools/Contour/utils.js.map +1 -1
- package/dist/esm/types/ContourTypes.d.ts +3 -0
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/stateManagement/segmentation/removeSegmentationsFromToolGroup.ts +6 -1
- package/src/tools/displayTools/Contour/contourConfig.ts +3 -0
- package/src/tools/displayTools/Contour/contourDisplay.ts +3 -0
- package/src/tools/displayTools/Contour/updateContourSets.ts +70 -28
- package/src/tools/displayTools/Contour/utils.ts +0 -1
- package/src/types/ContourTypes.ts +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.61.1",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"main": "dist/umd/index.js",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@cornerstonejs/core": "^0.
|
|
29
|
+
"@cornerstonejs/core": "^0.41.1",
|
|
30
30
|
"lodash.clonedeep": "4.5.0",
|
|
31
31
|
"lodash.get": "^4.4.2"
|
|
32
32
|
},
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"type": "individual",
|
|
53
53
|
"url": "https://ohif.org/donate"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "8e8c4693642dab1c46c38381f66730b40b187e79"
|
|
56
56
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import SegmentationRepresentations from '../../enums/SegmentationRepresentations';
|
|
2
2
|
import { labelmapDisplay } from '../../tools/displayTools/Labelmap';
|
|
3
|
+
import { contourDisplay } from '../../tools/displayTools/Contour';
|
|
3
4
|
|
|
4
5
|
import {
|
|
5
6
|
getSegmentationRepresentations,
|
|
@@ -76,7 +77,11 @@ function _removeSegmentation(
|
|
|
76
77
|
immediate
|
|
77
78
|
);
|
|
78
79
|
} else if (type === SegmentationRepresentations.Contour) {
|
|
79
|
-
|
|
80
|
+
contourDisplay.removeSegmentationRepresentation(
|
|
81
|
+
toolGroupId,
|
|
82
|
+
segmentationRepresentationUID,
|
|
83
|
+
immediate
|
|
84
|
+
);
|
|
80
85
|
} else {
|
|
81
86
|
throw new Error(`The representation ${type} is not supported yet`);
|
|
82
87
|
}
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from '../../../types/SegmentationStateTypes';
|
|
16
16
|
import { addOrUpdateContourSets } from './addOrUpdateContourSets';
|
|
17
17
|
import removeContourFromElement from './removeContourFromElement';
|
|
18
|
+
import { deleteConfigCache } from './contourConfigCache';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* It adds a new segmentation representation to the segmentation state
|
|
@@ -97,6 +98,8 @@ function removeSegmentationRepresentation(
|
|
|
97
98
|
segmentationRepresentationUID
|
|
98
99
|
);
|
|
99
100
|
|
|
101
|
+
deleteConfigCache(segmentationRepresentationUID);
|
|
102
|
+
|
|
100
103
|
if (renderImmediate) {
|
|
101
104
|
const viewportsInfo = getToolGroup(toolGroupId).getViewportsInfo();
|
|
102
105
|
viewportsInfo.forEach(({ viewportId, renderingEngineId }) => {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { cache, Types } from '@cornerstonejs/core';
|
|
2
|
-
import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
|
|
3
|
-
import vtkAppendPolyData from '@kitware/vtk.js/Filters/General/AppendPolyData';
|
|
4
2
|
import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
|
|
5
3
|
|
|
6
4
|
import {
|
|
@@ -8,7 +6,7 @@ import {
|
|
|
8
6
|
ToolGroupSpecificContourRepresentation,
|
|
9
7
|
} from '../../../types';
|
|
10
8
|
import { getConfigCache, setConfigCache } from './contourConfigCache';
|
|
11
|
-
import {
|
|
9
|
+
import { getSegmentSpecificConfig } from './utils';
|
|
12
10
|
|
|
13
11
|
export function updateContourSets(
|
|
14
12
|
viewport: Types.IVolumeViewport,
|
|
@@ -53,7 +51,7 @@ export function updateContourSets(
|
|
|
53
51
|
const segmentsToSetToVisible = [];
|
|
54
52
|
|
|
55
53
|
for (const segmentIndex of segmentsHidden) {
|
|
56
|
-
if (!cachedConfig
|
|
54
|
+
if (!cachedConfig.segmentsHidden.has(segmentIndex)) {
|
|
57
55
|
segmentsToSetToInvisible.push(segmentIndex);
|
|
58
56
|
}
|
|
59
57
|
}
|
|
@@ -64,38 +62,82 @@ export function updateContourSets(
|
|
|
64
62
|
segmentsToSetToVisible.push(segmentIndex);
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
|
-
if (segmentsToSetToInvisible.length || segmentsToSetToVisible.length) {
|
|
68
|
-
const appendPolyData = vtkAppendPolyData.newInstance();
|
|
69
65
|
|
|
70
|
-
|
|
66
|
+
const mergedInvisibleSegments = Array.from(cachedConfig.segmentsHidden)
|
|
67
|
+
.filter((segmentIndex) => !segmentsToSetToVisible.includes(segmentIndex))
|
|
68
|
+
.concat(segmentsToSetToInvisible);
|
|
69
|
+
|
|
70
|
+
const { contourSets, segmentSpecificConfigs } = geometryIds.reduce(
|
|
71
|
+
(acc, geometryId) => {
|
|
71
72
|
const geometry = cache.getGeometry(geometryId);
|
|
72
73
|
const { data: contourSet } = geometry;
|
|
73
74
|
const segmentIndex = (contourSet as Types.IContourSet).getSegmentIndex();
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
75
|
+
const segmentSpecificConfig = getSegmentSpecificConfig(
|
|
76
|
+
contourRepresentation,
|
|
77
|
+
geometryId,
|
|
78
|
+
segmentIndex
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
acc.contourSets.push(contourSet);
|
|
82
|
+
acc.segmentSpecificConfigs[segmentIndex] = segmentSpecificConfig ?? {};
|
|
83
|
+
|
|
84
|
+
return acc;
|
|
85
|
+
},
|
|
86
|
+
{ contourSets: [], segmentSpecificConfigs: {} }
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const affectedSegments = [
|
|
90
|
+
...mergedInvisibleSegments,
|
|
91
|
+
...segmentsToSetToVisible,
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
const hasCustomSegmentSpecificConfig = Object.values(
|
|
95
|
+
segmentSpecificConfigs
|
|
96
|
+
).some((config) => Object.keys(config).length > 0);
|
|
97
|
+
|
|
98
|
+
let polyDataModified = false;
|
|
99
|
+
|
|
100
|
+
if (affectedSegments.length || hasCustomSegmentSpecificConfig) {
|
|
101
|
+
const appendPolyData = mapper.getInputData();
|
|
102
|
+
const appendScalars = appendPolyData.getPointData().getScalars();
|
|
103
|
+
const appendScalarsData = appendScalars.getData();
|
|
104
|
+
// below we will only manipulate the polyData of the contourSets that are affected
|
|
105
|
+
// by picking the correct offset in the scalarData array
|
|
106
|
+
let offset = 0;
|
|
107
|
+
contourSets.forEach((contourSet) => {
|
|
108
|
+
const segmentIndex = (contourSet as Types.IContourSet).getSegmentIndex();
|
|
109
|
+
const size = contourSet.getTotalNumberOfPoints();
|
|
110
|
+
|
|
111
|
+
if (
|
|
112
|
+
affectedSegments.includes(segmentIndex) ||
|
|
113
|
+
segmentSpecificConfigs[segmentIndex]?.fillAlpha // Todo: add others
|
|
114
|
+
) {
|
|
115
|
+
const color = contourSet.getColor();
|
|
116
|
+
let visibility = mergedInvisibleSegments.includes(segmentIndex)
|
|
117
|
+
? 0
|
|
118
|
+
: 255;
|
|
119
|
+
|
|
120
|
+
const segmentConfig = segmentSpecificConfigs[segmentIndex];
|
|
121
|
+
if (segmentConfig.fillAlpha !== undefined) {
|
|
122
|
+
visibility = segmentConfig.fillAlpha * 255;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
for (let i = 0; i < size; ++i) {
|
|
126
|
+
appendScalarsData[offset + i * 4] = color[0];
|
|
127
|
+
appendScalarsData[offset + i * 4 + 1] = color[1];
|
|
128
|
+
appendScalarsData[offset + i * 4 + 2] = color[2];
|
|
129
|
+
appendScalarsData[offset + i * 4 + 3] = visibility;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
polyDataModified = true;
|
|
89
133
|
}
|
|
90
|
-
polyData.getPointData().setScalars(scalars);
|
|
91
134
|
|
|
92
|
-
|
|
93
|
-
? appendPolyData.setInputData(polyData)
|
|
94
|
-
: appendPolyData.addInputData(polyData);
|
|
135
|
+
offset = offset + size * 4;
|
|
95
136
|
});
|
|
96
137
|
|
|
97
|
-
|
|
98
|
-
|
|
138
|
+
if (polyDataModified) {
|
|
139
|
+
appendPolyData.modified();
|
|
140
|
+
}
|
|
99
141
|
|
|
100
142
|
setConfigCache(
|
|
101
143
|
segmentationRepresentationUID,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Enums, Types } from '@cornerstonejs/core';
|
|
2
2
|
import vtkCellArray from '@kitware/vtk.js/Common/Core/CellArray';
|
|
3
|
-
import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
|
|
4
3
|
import vtkPoints from '@kitware/vtk.js/Common/Core/Points';
|
|
5
4
|
import vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData';
|
|
6
5
|
import { ToolGroupSpecificContourRepresentation } from '../../../types';
|
|
@@ -12,6 +12,12 @@ export type ContourConfig = {
|
|
|
12
12
|
outlineOpacityInactive?: number;
|
|
13
13
|
/** outline visibility */
|
|
14
14
|
renderOutline?: boolean;
|
|
15
|
+
/** render fill */
|
|
16
|
+
renderFill?: boolean;
|
|
17
|
+
/** fill alpha */
|
|
18
|
+
fillAlpha?: number;
|
|
19
|
+
/** fillAlphaInactive */
|
|
20
|
+
fillAlphaInactive?: number;
|
|
15
21
|
};
|
|
16
22
|
|
|
17
23
|
/**
|