@cornerstonejs/tools 1.71.0 → 1.71.2

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.
Files changed (76) hide show
  1. package/dist/cjs/tools/displayTools/Contour/contourConfig.js +2 -2
  2. package/dist/cjs/tools/displayTools/Contour/contourConfig.js.map +1 -1
  3. package/dist/cjs/tools/displayTools/Contour/contourDisplay.js +8 -6
  4. package/dist/cjs/tools/displayTools/Contour/contourDisplay.js.map +1 -1
  5. package/dist/cjs/tools/displayTools/Contour/contourHandler/contourConfigCache.js.map +1 -0
  6. package/dist/cjs/tools/displayTools/Contour/contourHandler/handleContourSegmentation.d.ts +6 -0
  7. package/dist/cjs/tools/displayTools/Contour/contourHandler/handleContourSegmentation.js +124 -0
  8. package/dist/cjs/tools/displayTools/Contour/contourHandler/handleContourSegmentation.js.map +1 -0
  9. package/dist/cjs/tools/displayTools/Contour/contourHandler/utils.js.map +1 -0
  10. package/dist/cjs/tools/displayTools/Contour/removeContourFromElement.d.ts +1 -1
  11. package/dist/cjs/tools/displayTools/Contour/removeContourFromElement.js +12 -9
  12. package/dist/cjs/tools/displayTools/Contour/removeContourFromElement.js.map +1 -1
  13. package/dist/esm/tools/displayTools/Contour/contourConfig.js +2 -2
  14. package/dist/esm/tools/displayTools/Contour/contourConfig.js.map +1 -1
  15. package/dist/esm/tools/displayTools/Contour/contourDisplay.js +8 -7
  16. package/dist/esm/tools/displayTools/Contour/contourDisplay.js.map +1 -1
  17. package/dist/esm/tools/displayTools/Contour/contourHandler/contourConfigCache.js.map +1 -0
  18. package/dist/esm/tools/displayTools/Contour/contourHandler/handleContourSegmentation.js +119 -0
  19. package/dist/esm/tools/displayTools/Contour/contourHandler/handleContourSegmentation.js.map +1 -0
  20. package/dist/esm/tools/displayTools/Contour/contourHandler/utils.js.map +1 -0
  21. package/dist/esm/tools/displayTools/Contour/removeContourFromElement.js +12 -9
  22. package/dist/esm/tools/displayTools/Contour/removeContourFromElement.js.map +1 -1
  23. package/dist/types/tools/displayTools/Contour/contourDisplay.d.ts.map +1 -1
  24. package/dist/types/tools/displayTools/Contour/contourHandler/contourConfigCache.d.ts.map +1 -0
  25. package/dist/types/tools/displayTools/Contour/contourHandler/handleContourSegmentation.d.ts +7 -0
  26. package/dist/types/tools/displayTools/Contour/contourHandler/handleContourSegmentation.d.ts.map +1 -0
  27. package/dist/types/tools/displayTools/Contour/contourHandler/utils.d.ts.map +1 -0
  28. package/dist/types/tools/displayTools/Contour/removeContourFromElement.d.ts +1 -1
  29. package/dist/types/tools/displayTools/Contour/removeContourFromElement.d.ts.map +1 -1
  30. package/dist/umd/index.js +1 -1
  31. package/dist/umd/index.js.map +1 -1
  32. package/package.json +3 -3
  33. package/src/tools/displayTools/Contour/contourConfig.ts +2 -2
  34. package/src/tools/displayTools/Contour/contourDisplay.ts +14 -91
  35. package/src/tools/displayTools/Contour/contourHandler/handleContourSegmentation.ts +207 -0
  36. package/src/tools/displayTools/Contour/removeContourFromElement.ts +20 -14
  37. package/dist/cjs/tools/displayTools/Contour/vtkContour/addContourSetsToElement.d.ts +0 -3
  38. package/dist/cjs/tools/displayTools/Contour/vtkContour/addContourSetsToElement.js +0 -73
  39. package/dist/cjs/tools/displayTools/Contour/vtkContour/addContourSetsToElement.js.map +0 -1
  40. package/dist/cjs/tools/displayTools/Contour/vtkContour/addOrUpdateVTKContourSets.d.ts +0 -3
  41. package/dist/cjs/tools/displayTools/Contour/vtkContour/addOrUpdateVTKContourSets.js +0 -14
  42. package/dist/cjs/tools/displayTools/Contour/vtkContour/addOrUpdateVTKContourSets.js.map +0 -1
  43. package/dist/cjs/tools/displayTools/Contour/vtkContour/contourConfigCache.js.map +0 -1
  44. package/dist/cjs/tools/displayTools/Contour/vtkContour/updateVTKContourSets.d.ts +0 -3
  45. package/dist/cjs/tools/displayTools/Contour/vtkContour/updateVTKContourSets.js +0 -98
  46. package/dist/cjs/tools/displayTools/Contour/vtkContour/updateVTKContourSets.js.map +0 -1
  47. package/dist/cjs/tools/displayTools/Contour/vtkContour/utils.js.map +0 -1
  48. package/dist/esm/tools/displayTools/Contour/vtkContour/addContourSetsToElement.js +0 -66
  49. package/dist/esm/tools/displayTools/Contour/vtkContour/addContourSetsToElement.js.map +0 -1
  50. package/dist/esm/tools/displayTools/Contour/vtkContour/addOrUpdateVTKContourSets.js +0 -10
  51. package/dist/esm/tools/displayTools/Contour/vtkContour/addOrUpdateVTKContourSets.js.map +0 -1
  52. package/dist/esm/tools/displayTools/Contour/vtkContour/contourConfigCache.js.map +0 -1
  53. package/dist/esm/tools/displayTools/Contour/vtkContour/updateVTKContourSets.js +0 -93
  54. package/dist/esm/tools/displayTools/Contour/vtkContour/updateVTKContourSets.js.map +0 -1
  55. package/dist/esm/tools/displayTools/Contour/vtkContour/utils.js.map +0 -1
  56. package/dist/types/tools/displayTools/Contour/vtkContour/addContourSetsToElement.d.ts +0 -4
  57. package/dist/types/tools/displayTools/Contour/vtkContour/addContourSetsToElement.d.ts.map +0 -1
  58. package/dist/types/tools/displayTools/Contour/vtkContour/addOrUpdateVTKContourSets.d.ts +0 -4
  59. package/dist/types/tools/displayTools/Contour/vtkContour/addOrUpdateVTKContourSets.d.ts.map +0 -1
  60. package/dist/types/tools/displayTools/Contour/vtkContour/contourConfigCache.d.ts.map +0 -1
  61. package/dist/types/tools/displayTools/Contour/vtkContour/updateVTKContourSets.d.ts +0 -4
  62. package/dist/types/tools/displayTools/Contour/vtkContour/updateVTKContourSets.d.ts.map +0 -1
  63. package/dist/types/tools/displayTools/Contour/vtkContour/utils.d.ts.map +0 -1
  64. package/src/tools/displayTools/Contour/vtkContour/addContourSetsToElement.ts +0 -113
  65. package/src/tools/displayTools/Contour/vtkContour/addOrUpdateVTKContourSets.ts +0 -28
  66. package/src/tools/displayTools/Contour/vtkContour/updateVTKContourSets.ts +0 -155
  67. /package/dist/cjs/tools/displayTools/Contour/{vtkContour → contourHandler}/contourConfigCache.d.ts +0 -0
  68. /package/dist/cjs/tools/displayTools/Contour/{vtkContour → contourHandler}/contourConfigCache.js +0 -0
  69. /package/dist/cjs/tools/displayTools/Contour/{vtkContour → contourHandler}/utils.d.ts +0 -0
  70. /package/dist/cjs/tools/displayTools/Contour/{vtkContour → contourHandler}/utils.js +0 -0
  71. /package/dist/esm/tools/displayTools/Contour/{vtkContour → contourHandler}/contourConfigCache.js +0 -0
  72. /package/dist/esm/tools/displayTools/Contour/{vtkContour → contourHandler}/utils.js +0 -0
  73. /package/dist/types/tools/displayTools/Contour/{vtkContour → contourHandler}/contourConfigCache.d.ts +0 -0
  74. /package/dist/types/tools/displayTools/Contour/{vtkContour → contourHandler}/utils.d.ts +0 -0
  75. /package/src/tools/displayTools/Contour/{vtkContour → contourHandler}/contourConfigCache.ts +0 -0
  76. /package/src/tools/displayTools/Contour/{vtkContour → contourHandler}/utils.ts +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../src/tools/displayTools/Contour/vtkContour/utils.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAmD;AACnD,sFAAiE;AACjE,gFAA2D;AAC3D,yFAAoE;AAepE,SAAgB,wBAAwB,CACtC,qBAA6D,EAC7D,SAAiB,EACjB,KAAa;;IAEb,IAAI,qBAAqB,GACvB,MAAA,qBAAqB,CAAC,qBAAqB,0CAAG,SAAS,CAAC,CAAC;IAE3D,IAAI,CAAC,qBAAqB,EAAE;QAE1B,qBAAqB;YACnB,MAAA,qBAAqB,CAAC,qBAAqB,0CAAG,KAAK,CAAC,CAAC;KACxD;IAED,IAAI,CAAC,qBAAqB,EAAE;QAC1B,OAAO,IAAI,CAAC;KACb;IAED,OAAO,qBAAqB,CAAC,OAAO,CAAC;AACvC,CAAC;AAnBD,4DAmBC;AAOD,SAAgB,gBAAgB,CAAC,QAAyB;IACxD,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CAAC,oCAAoC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;KACpE;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AY,CAAC,CAAC,CAAC;QAExC,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC;IAC7C,CAAC,CAAC,CAAC;IAGH,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAG9B,MAAM,OAAO,GAAG,kBAAW,CAAC,WAAW,EAAE,CAAC;IAC1C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExB,OAAO,OAAO,CAAC;AACjB,CAAC;AA1CD,kCA0CC"}
@@ -1,66 +0,0 @@
1
- import { cache } from '@cornerstonejs/core';
2
- import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
3
- import vtkAppendPolyData from '@kitware/vtk.js/Filters/General/AppendPolyData';
4
- import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
5
- import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
6
- import { getPolyData, getSegmentSpecificConfig, validateGeometry, } from './utils';
7
- import { getConfigCache, setConfigCache } from './contourConfigCache';
8
- export function addContourSetsToElement(viewport, geometryIds, contourRepresentation, contourRepresentationConfig, contourActorUID) {
9
- const { segmentationRepresentationUID, segmentsHidden } = contourRepresentation;
10
- const appendPolyData = vtkAppendPolyData.newInstance();
11
- const scalarToColorMap = new Map();
12
- const segmentSpecificMap = new Map();
13
- geometryIds.forEach((geometryId) => {
14
- const geometry = cache.getGeometry(geometryId);
15
- if (!geometry) {
16
- console.warn(`No geometry found for geometryId ${geometryId}. Skipping render.`);
17
- return;
18
- }
19
- const segmentIndex = geometry.data.getSegmentIndex();
20
- validateGeometry(geometry);
21
- const segmentSpecificConfig = getSegmentSpecificConfig(contourRepresentation, geometryId, segmentIndex);
22
- const contourSet = geometry.data;
23
- const polyData = getPolyData(contourSet);
24
- const color = contourSet.getColor();
25
- const size = polyData.getPoints().getNumberOfPoints();
26
- const scalars = vtkDataArray.newInstance({
27
- size: size * 4,
28
- numberOfComponents: 4,
29
- dataType: 'Uint8Array',
30
- });
31
- for (let i = 0; i < size; ++i) {
32
- scalars.setTuple(i, [...color, 255]);
33
- }
34
- polyData.getPointData().setScalars(scalars);
35
- if (segmentSpecificConfig) {
36
- segmentSpecificMap.set(segmentIndex, segmentSpecificConfig);
37
- }
38
- scalarToColorMap.set(segmentIndex, [
39
- ...color,
40
- segmentsHidden.has(segmentIndex) ? 0 : 255,
41
- ]);
42
- segmentIndex === 0
43
- ? appendPolyData.setInputData(polyData)
44
- : appendPolyData.addInputData(polyData);
45
- });
46
- const polyDataOutput = appendPolyData.getOutputData();
47
- const outlineWidthActive = contourRepresentationConfig.representations.CONTOUR.outlineWidthActive;
48
- const mapper = vtkMapper.newInstance();
49
- mapper.setInputData(polyDataOutput);
50
- const actor = vtkActor.newInstance();
51
- actor.setMapper(mapper);
52
- actor.getProperty().setLineWidth(outlineWidthActive);
53
- setConfigCache(segmentationRepresentationUID, Object.assign({}, getConfigCache(segmentationRepresentationUID), {
54
- segmentsHidden: new Set(segmentsHidden),
55
- segmentSpecificMap,
56
- outlineWidthActive,
57
- }));
58
- actor.setForceOpaque(true);
59
- viewport.addActor({
60
- uid: contourActorUID,
61
- actor: actor,
62
- });
63
- viewport.resetCamera();
64
- viewport.render();
65
- }
66
- //# sourceMappingURL=addContourSetsToElement.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addContourSetsToElement.js","sourceRoot":"","sources":["../../../../../../src/tools/displayTools/Contour/vtkContour/addContourSetsToElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAS,MAAM,qBAAqB,CAAC;AACnD,OAAO,YAAY,MAAM,uCAAuC,CAAC;AACjE,OAAO,iBAAiB,MAAM,gDAAgD,CAAC;AAC/E,OAAO,QAAQ,MAAM,sCAAsC,CAAC;AAC5D,OAAO,SAAS,MAAM,uCAAuC,CAAC;AAE9D,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,SA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QACvC,kBAAkB;QAClB,kBAAkB;KACnB,CAAC,CACH,CAAC;IAEF,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAE3B,QAAQ,CAAC,QAAQ,CAAC;QAChB,GAAG,EAAE,eAAe;QACpB,KAAK,EAAE,KAA+B;KACvC,CAAC,CAAC;IACH,QAAQ,CAAC,WAAW,EAAE,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,CAAC;AACpB,CAAC"}
@@ -1,10 +0,0 @@
1
- import { addContourSetsToElement } from './addContourSetsToElement';
2
- import { updateVTKContourSets } from './updateVTKContourSets';
3
- export function addOrUpdateVTKContourSets(viewport, geometryIds, contourRepresentation, contourRepresentationConfig) {
4
- const { segmentationRepresentationUID } = contourRepresentation;
5
- const actorUID = `CONTOUR_${segmentationRepresentationUID}`;
6
- const actor = viewport.getActor(actorUID);
7
- const addOrUpdateFn = actor ? updateVTKContourSets : addContourSetsToElement;
8
- addOrUpdateFn(viewport, geometryIds, contourRepresentation, contourRepresentationConfig, actorUID);
9
- }
10
- //# sourceMappingURL=addOrUpdateVTKContourSets.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addOrUpdateVTKContourSets.js","sourceRoot":"","sources":["../../../../../../src/tools/displayTools/Contour/vtkContour/addOrUpdateVTKContourSets.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,UAAU,yBAAyB,CACvC,QAA+B,EAC/B,WAAqB,EACrB,qBAA6D,EAC7D,2BAA6D;IAE7D,MAAM,EAAE,6BAA6B,EAAE,GAAG,qBAAqB,CAAC;IAChE,MAAM,QAAQ,GAAG,WAAW,6BAA6B,EAAE,CAAC;IAC5D,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAE1C,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,uBAAuB,CAAC;IAC7E,aAAa,CACX,QAAQ,EACR,WAAW,EACX,qBAAqB,EACrB,2BAA2B,EAC3B,QAAQ,CACT,CAAC;AACJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"contourConfigCache.js","sourceRoot":"","sources":["../../../../../../src/tools/displayTools/Contour/vtkContour/contourConfigCache.ts"],"names":[],"mappings":"AAYA,MAAM,2CAA2C,GAAG,IAAI,GAAG,EAAE,CAAC;AAE9D,MAAM,UAAU,cAAc,CAC5B,6BAAqC;IAErC,OAAO,2CAA2C,CAAC,GAAG,CACpD,6BAA6B,CAC9B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,6BAAqC,EACrC,MAAmB;IAEnB,2CAA2C,CAAC,GAAG,CAC7C,6BAA6B,EAC7B,MAAM,CACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,6BAAqC;IACrE,2CAA2C,CAAC,MAAM,CAChD,6BAA6B,CAC9B,CAAC;AACJ,CAAC"}
@@ -1,93 +0,0 @@
1
- import { cache } from '@cornerstonejs/core';
2
- import { getConfigCache, setConfigCache } from './contourConfigCache';
3
- import { getSegmentSpecificConfig } from './utils';
4
- export function updateVTKContourSets(viewport, geometryIds, contourRepresentation, contourRepresentationConfig, contourActorUID) {
5
- const { segmentationRepresentationUID, segmentsHidden } = contourRepresentation;
6
- const newContourConfig = contourRepresentationConfig.representations.CONTOUR;
7
- const cachedConfig = getConfigCache(segmentationRepresentationUID);
8
- const contourSetsActor = viewport.getActor(contourActorUID);
9
- if (!contourSetsActor) {
10
- console.warn(`No contour actor found for actorUID ${contourActorUID}. Skipping render.`);
11
- return;
12
- }
13
- const { actor } = contourSetsActor;
14
- const newOutlineWithActive = newContourConfig.outlineWidthActive;
15
- if (cachedConfig?.outlineWidthActive !== newOutlineWithActive) {
16
- actor
17
- .getProperty()
18
- .setLineWidth(newOutlineWithActive);
19
- setConfigCache(segmentationRepresentationUID, Object.assign({}, cachedConfig, {
20
- outlineWidthActive: newOutlineWithActive,
21
- }));
22
- }
23
- const mapper = actor.getMapper();
24
- const lut = mapper.getLookupTable();
25
- const segmentsToSetToInvisible = [];
26
- const segmentsToSetToVisible = [];
27
- for (const segmentIndex of segmentsHidden) {
28
- if (!cachedConfig.segmentsHidden.has(segmentIndex)) {
29
- segmentsToSetToInvisible.push(segmentIndex);
30
- }
31
- }
32
- for (const segmentIndex of cachedConfig.segmentsHidden) {
33
- if (!segmentsHidden.has(segmentIndex)) {
34
- segmentsToSetToVisible.push(segmentIndex);
35
- }
36
- }
37
- const mergedInvisibleSegments = Array.from(cachedConfig.segmentsHidden)
38
- .filter((segmentIndex) => !segmentsToSetToVisible.includes(segmentIndex))
39
- .concat(segmentsToSetToInvisible);
40
- const { contourSets, segmentSpecificConfigs } = geometryIds.reduce((acc, geometryId) => {
41
- const geometry = cache.getGeometry(geometryId);
42
- const { data: contourSet } = geometry;
43
- const segmentIndex = contourSet.getSegmentIndex();
44
- const segmentSpecificConfig = getSegmentSpecificConfig(contourRepresentation, geometryId, segmentIndex);
45
- acc.contourSets.push(contourSet);
46
- acc.segmentSpecificConfigs[segmentIndex] = segmentSpecificConfig ?? {};
47
- return acc;
48
- }, { contourSets: [], segmentSpecificConfigs: {} });
49
- const affectedSegments = [
50
- ...mergedInvisibleSegments,
51
- ...segmentsToSetToVisible,
52
- ];
53
- const hasCustomSegmentSpecificConfig = Object.values(segmentSpecificConfigs).some((config) => Object.keys(config).length > 0);
54
- let polyDataModified = false;
55
- if (affectedSegments.length || hasCustomSegmentSpecificConfig) {
56
- const appendPolyData = mapper.getInputData();
57
- const appendScalars = appendPolyData.getPointData().getScalars();
58
- const appendScalarsData = appendScalars.getData();
59
- let offset = 0;
60
- contourSets.forEach((contourSet) => {
61
- const segmentIndex = contourSet.getSegmentIndex();
62
- const size = contourSet.getTotalNumberOfPoints();
63
- if (affectedSegments.includes(segmentIndex) ||
64
- segmentSpecificConfigs[segmentIndex]?.fillAlpha) {
65
- const color = contourSet.getColor();
66
- let visibility = mergedInvisibleSegments.includes(segmentIndex)
67
- ? 0
68
- : 255;
69
- const segmentConfig = segmentSpecificConfigs[segmentIndex];
70
- if (segmentConfig.fillAlpha !== undefined) {
71
- visibility = segmentConfig.fillAlpha * 255;
72
- }
73
- for (let i = 0; i < size; ++i) {
74
- appendScalarsData[offset + i * 4] = color[0];
75
- appendScalarsData[offset + i * 4 + 1] = color[1];
76
- appendScalarsData[offset + i * 4 + 2] = color[2];
77
- appendScalarsData[offset + i * 4 + 3] = visibility;
78
- }
79
- polyDataModified = true;
80
- }
81
- offset = offset + size * 4;
82
- });
83
- if (polyDataModified) {
84
- appendPolyData.modified();
85
- }
86
- setConfigCache(segmentationRepresentationUID, Object.assign({}, cachedConfig, {
87
- segmentsHidden: new Set(segmentsHidden),
88
- }));
89
- mapper.setLookupTable(lut);
90
- }
91
- viewport.render();
92
- }
93
- //# sourceMappingURL=updateVTKContourSets.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"updateVTKContourSets.js","sourceRoot":"","sources":["../../../../../../src/tools/displayTools/Contour/vtkContour/updateVTKContourSets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAS,MAAM,qBAAqB,CAAC;AAOnD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,UAAU,oBAAoB,CAClC,QAA+B,EAC/B,WAAqB,EACrB,qBAA6D,EAC7D,2BAA6D,EAC7D,eAAuB;IAEvB,MAAM,EAAE,6BAA6B,EAAE,cAAc,EAAE,GACrD,qBAAqB,CAAC;IACxB,MAAM,gBAAgB,GAAG,2BAA2B,CAAC,eAAe,CAAC,OAAO,CAAC;IAC7E,MAAM,YAAY,GAAG,cAAc,CAAC,6BAA6B,CAAC,CAAC;IAEnE,MAAM,gBAAgB,GAAG,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C;IAGH,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAG9B,MAAM,OAAO,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;IAC1C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExB,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,4 +0,0 @@
1
- import { Types } from '@cornerstonejs/core';
2
- import { SegmentationRepresentationConfig, ToolGroupSpecificContourRepresentation } from '../../../../types';
3
- export declare function addContourSetsToElement(viewport: Types.IVolumeViewport, geometryIds: string[], contourRepresentation: ToolGroupSpecificContourRepresentation, contourRepresentationConfig: SegmentationRepresentationConfig, contourActorUID: string): void;
4
- //# sourceMappingURL=addContourSetsToElement.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addContourSetsToElement.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/displayTools/Contour/vtkContour/addContourSetsToElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAYnD,OAAO,EACL,gCAAgC,EAChC,sCAAsC,EACvC,MAAM,mBAAmB,CAAC;AAG3B,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,KAAK,CAAC,eAAe,EAC/B,WAAW,EAAE,MAAM,EAAE,EACrB,qBAAqB,EAAE,sCAAsC,EAC7D,2BAA2B,EAAE,gCAAgC,EAC7D,eAAe,EAAE,MAAM,QAyFxB"}
@@ -1,4 +0,0 @@
1
- import { Types } from '@cornerstonejs/core';
2
- import { SegmentationRepresentationConfig, ToolGroupSpecificContourRepresentation } from '../../../../types';
3
- export declare function addOrUpdateVTKContourSets(viewport: Types.IVolumeViewport, geometryIds: string[], contourRepresentation: ToolGroupSpecificContourRepresentation, contourRepresentationConfig: SegmentationRepresentationConfig): void;
4
- //# sourceMappingURL=addOrUpdateVTKContourSets.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addOrUpdateVTKContourSets.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/displayTools/Contour/vtkContour/addOrUpdateVTKContourSets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,OAAO,EACL,gCAAgC,EAChC,sCAAsC,EACvC,MAAM,mBAAmB,CAAC;AAI3B,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,KAAK,CAAC,eAAe,EAC/B,WAAW,EAAE,MAAM,EAAE,EACrB,qBAAqB,EAAE,sCAAsC,EAC7D,2BAA2B,EAAE,gCAAgC,QAc9D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"contourConfigCache.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/displayTools/Contour/vtkContour/contourConfigCache.ts"],"names":[],"mappings":"AAAA,aAAK,WAAW,GAAG;IACjB,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAUF,wBAAgB,cAAc,CAC5B,6BAA6B,EAAE,MAAM,GACpC,WAAW,CAIb;AAED,wBAAgB,cAAc,CAC5B,6BAA6B,EAAE,MAAM,EACrC,MAAM,EAAE,WAAW,QAMpB;AAED,wBAAgB,iBAAiB,CAAC,6BAA6B,EAAE,MAAM,QAItE"}
@@ -1,4 +0,0 @@
1
- import { Types } from '@cornerstonejs/core';
2
- import { SegmentationRepresentationConfig, ToolGroupSpecificContourRepresentation } from '../../../../types';
3
- export declare function updateVTKContourSets(viewport: Types.IVolumeViewport, geometryIds: string[], contourRepresentation: ToolGroupSpecificContourRepresentation, contourRepresentationConfig: SegmentationRepresentationConfig, contourActorUID: string): void;
4
- //# sourceMappingURL=updateVTKContourSets.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"updateVTKContourSets.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/displayTools/Contour/vtkContour/updateVTKContourSets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EACL,gCAAgC,EAChC,sCAAsC,EACvC,MAAM,mBAAmB,CAAC;AAI3B,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,KAAK,CAAC,eAAe,EAC/B,WAAW,EAAE,MAAM,EAAE,EACrB,qBAAqB,EAAE,sCAAsC,EAC7D,2BAA2B,EAAE,gCAAgC,EAC7D,eAAe,EAAE,MAAM,QA2IxB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/displayTools/Contour/vtkContour/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,WAAW,MAAM,2CAA2C,CAAC;AACpE,OAAO,EAAE,sCAAsC,EAAE,MAAM,mBAAmB,CAAC;AAc3E,wBAAgB,wBAAwB,CACtC,qBAAqB,EAAE,sCAAsC,EAC7D,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,0DAgBd;AAOD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI,CAmBhE;AAUD,wBAAgB,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC,WAAW,eA0CxD"}
@@ -1,113 +0,0 @@
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
- import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
5
- import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
6
-
7
- import {
8
- getPolyData,
9
- getSegmentSpecificConfig,
10
- validateGeometry,
11
- } from './utils';
12
-
13
- import {
14
- SegmentationRepresentationConfig,
15
- ToolGroupSpecificContourRepresentation,
16
- } from '../../../../types';
17
- import { getConfigCache, setConfigCache } from './contourConfigCache';
18
-
19
- export function addContourSetsToElement(
20
- viewport: Types.IVolumeViewport,
21
- geometryIds: string[],
22
- contourRepresentation: ToolGroupSpecificContourRepresentation,
23
- contourRepresentationConfig: SegmentationRepresentationConfig,
24
- contourActorUID: string
25
- ) {
26
- const { segmentationRepresentationUID, segmentsHidden } =
27
- contourRepresentation;
28
- const appendPolyData = vtkAppendPolyData.newInstance();
29
-
30
- const scalarToColorMap = new Map();
31
- const segmentSpecificMap = new Map();
32
-
33
- geometryIds.forEach((geometryId) => {
34
- const geometry = cache.getGeometry(geometryId);
35
-
36
- if (!geometry) {
37
- console.warn(
38
- `No geometry found for geometryId ${geometryId}. Skipping render.`
39
- );
40
- return;
41
- }
42
-
43
- const segmentIndex = (geometry.data as Types.IContourSet).getSegmentIndex();
44
-
45
- validateGeometry(geometry);
46
-
47
- const segmentSpecificConfig = getSegmentSpecificConfig(
48
- contourRepresentation,
49
- geometryId,
50
- segmentIndex
51
- );
52
-
53
- const contourSet = geometry.data;
54
- const polyData = getPolyData(contourSet as Types.IContourSet);
55
- const color = contourSet.getColor();
56
-
57
- const size = polyData.getPoints().getNumberOfPoints();
58
-
59
- const scalars = vtkDataArray.newInstance({
60
- size: size * 4,
61
- numberOfComponents: 4,
62
- dataType: 'Uint8Array',
63
- });
64
- for (let i = 0; i < size; ++i) {
65
- scalars.setTuple(i, [...color, 255]);
66
- }
67
- polyData.getPointData().setScalars(scalars);
68
-
69
- if (segmentSpecificConfig) {
70
- segmentSpecificMap.set(segmentIndex, segmentSpecificConfig);
71
- }
72
-
73
- scalarToColorMap.set(segmentIndex, [
74
- ...color,
75
- segmentsHidden.has(segmentIndex) ? 0 : 255,
76
- ]);
77
-
78
- segmentIndex === 0
79
- ? appendPolyData.setInputData(polyData)
80
- : appendPolyData.addInputData(polyData);
81
- });
82
-
83
- const polyDataOutput = appendPolyData.getOutputData();
84
-
85
- const outlineWidthActive =
86
- contourRepresentationConfig.representations.CONTOUR.outlineWidthActive;
87
-
88
- const mapper = vtkMapper.newInstance();
89
- mapper.setInputData(polyDataOutput);
90
-
91
- const actor = vtkActor.newInstance();
92
- actor.setMapper(mapper);
93
- actor.getProperty().setLineWidth(outlineWidthActive);
94
-
95
- // set the config cache for later update of the contour
96
- setConfigCache(
97
- segmentationRepresentationUID,
98
- Object.assign({}, getConfigCache(segmentationRepresentationUID), {
99
- segmentsHidden: new Set(segmentsHidden),
100
- segmentSpecificMap,
101
- outlineWidthActive,
102
- })
103
- );
104
-
105
- actor.setForceOpaque(true);
106
-
107
- viewport.addActor({
108
- uid: contourActorUID,
109
- actor: actor as unknown as Types.Actor,
110
- });
111
- viewport.resetCamera();
112
- viewport.render();
113
- }
@@ -1,28 +0,0 @@
1
- import { Types } from '@cornerstonejs/core';
2
-
3
- import {
4
- SegmentationRepresentationConfig,
5
- ToolGroupSpecificContourRepresentation,
6
- } from '../../../../types';
7
- import { addContourSetsToElement } from './addContourSetsToElement';
8
- import { updateVTKContourSets } from './updateVTKContourSets';
9
-
10
- export function addOrUpdateVTKContourSets(
11
- viewport: Types.IVolumeViewport,
12
- geometryIds: string[],
13
- contourRepresentation: ToolGroupSpecificContourRepresentation,
14
- contourRepresentationConfig: SegmentationRepresentationConfig
15
- ) {
16
- const { segmentationRepresentationUID } = contourRepresentation;
17
- const actorUID = `CONTOUR_${segmentationRepresentationUID}`;
18
- const actor = viewport.getActor(actorUID);
19
-
20
- const addOrUpdateFn = actor ? updateVTKContourSets : addContourSetsToElement;
21
- addOrUpdateFn(
22
- viewport,
23
- geometryIds,
24
- contourRepresentation,
25
- contourRepresentationConfig,
26
- actorUID
27
- );
28
- }
@@ -1,155 +0,0 @@
1
- import { cache, Types } from '@cornerstonejs/core';
2
- import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
3
-
4
- import {
5
- SegmentationRepresentationConfig,
6
- ToolGroupSpecificContourRepresentation,
7
- } from '../../../../types';
8
- import { getConfigCache, setConfigCache } from './contourConfigCache';
9
- import { getSegmentSpecificConfig } from './utils';
10
-
11
- export function updateVTKContourSets(
12
- viewport: Types.IVolumeViewport,
13
- geometryIds: string[],
14
- contourRepresentation: ToolGroupSpecificContourRepresentation,
15
- contourRepresentationConfig: SegmentationRepresentationConfig,
16
- contourActorUID: string
17
- ) {
18
- const { segmentationRepresentationUID, segmentsHidden } =
19
- contourRepresentation;
20
- const newContourConfig = contourRepresentationConfig.representations.CONTOUR;
21
- const cachedConfig = getConfigCache(segmentationRepresentationUID);
22
-
23
- const contourSetsActor = viewport.getActor(contourActorUID);
24
-
25
- if (!contourSetsActor) {
26
- console.warn(
27
- `No contour actor found for actorUID ${contourActorUID}. Skipping render.`
28
- );
29
- return;
30
- }
31
-
32
- const { actor } = contourSetsActor;
33
-
34
- const newOutlineWithActive = newContourConfig.outlineWidthActive;
35
-
36
- if (cachedConfig?.outlineWidthActive !== newOutlineWithActive) {
37
- (actor as unknown as vtkActor)
38
- .getProperty()
39
- .setLineWidth(newOutlineWithActive);
40
-
41
- setConfigCache(
42
- segmentationRepresentationUID,
43
- Object.assign({}, cachedConfig, {
44
- outlineWidthActive: newOutlineWithActive,
45
- })
46
- );
47
- }
48
-
49
- const mapper = (actor as unknown as vtkActor).getMapper();
50
- const lut = mapper.getLookupTable();
51
-
52
- const segmentsToSetToInvisible = [];
53
- const segmentsToSetToVisible = [];
54
-
55
- for (const segmentIndex of segmentsHidden) {
56
- if (!cachedConfig.segmentsHidden.has(segmentIndex)) {
57
- segmentsToSetToInvisible.push(segmentIndex);
58
- }
59
- }
60
-
61
- // the other way around
62
- for (const segmentIndex of cachedConfig.segmentsHidden) {
63
- if (!segmentsHidden.has(segmentIndex)) {
64
- segmentsToSetToVisible.push(segmentIndex);
65
- }
66
- }
67
-
68
- const mergedInvisibleSegments = Array.from(cachedConfig.segmentsHidden)
69
- .filter((segmentIndex) => !segmentsToSetToVisible.includes(segmentIndex))
70
- .concat(segmentsToSetToInvisible);
71
-
72
- const { contourSets, segmentSpecificConfigs } = geometryIds.reduce(
73
- (acc, geometryId) => {
74
- const geometry = cache.getGeometry(geometryId);
75
- const { data: contourSet } = geometry;
76
- const segmentIndex = (contourSet as Types.IContourSet).getSegmentIndex();
77
- const segmentSpecificConfig = getSegmentSpecificConfig(
78
- contourRepresentation,
79
- geometryId,
80
- segmentIndex
81
- );
82
-
83
- acc.contourSets.push(contourSet);
84
- acc.segmentSpecificConfigs[segmentIndex] = segmentSpecificConfig ?? {};
85
-
86
- return acc;
87
- },
88
- { contourSets: [], segmentSpecificConfigs: {} }
89
- );
90
-
91
- const affectedSegments = [
92
- ...mergedInvisibleSegments,
93
- ...segmentsToSetToVisible,
94
- ];
95
-
96
- const hasCustomSegmentSpecificConfig = Object.values(
97
- segmentSpecificConfigs
98
- ).some((config) => Object.keys(config).length > 0);
99
-
100
- let polyDataModified = false;
101
-
102
- if (affectedSegments.length || hasCustomSegmentSpecificConfig) {
103
- const appendPolyData = mapper.getInputData();
104
- const appendScalars = appendPolyData.getPointData().getScalars();
105
- const appendScalarsData = appendScalars.getData();
106
- // below we will only manipulate the polyData of the contourSets that are affected
107
- // by picking the correct offset in the scalarData array
108
- let offset = 0;
109
- contourSets.forEach((contourSet) => {
110
- const segmentIndex = (contourSet as Types.IContourSet).getSegmentIndex();
111
- const size = contourSet.getTotalNumberOfPoints();
112
-
113
- if (
114
- affectedSegments.includes(segmentIndex) ||
115
- segmentSpecificConfigs[segmentIndex]?.fillAlpha // Todo: add others
116
- ) {
117
- const color = contourSet.getColor();
118
- let visibility = mergedInvisibleSegments.includes(segmentIndex)
119
- ? 0
120
- : 255;
121
-
122
- const segmentConfig = segmentSpecificConfigs[segmentIndex];
123
- if (segmentConfig.fillAlpha !== undefined) {
124
- visibility = segmentConfig.fillAlpha * 255;
125
- }
126
-
127
- for (let i = 0; i < size; ++i) {
128
- appendScalarsData[offset + i * 4] = color[0];
129
- appendScalarsData[offset + i * 4 + 1] = color[1];
130
- appendScalarsData[offset + i * 4 + 2] = color[2];
131
- appendScalarsData[offset + i * 4 + 3] = visibility;
132
- }
133
-
134
- polyDataModified = true;
135
- }
136
-
137
- offset = offset + size * 4;
138
- });
139
-
140
- if (polyDataModified) {
141
- appendPolyData.modified();
142
- }
143
-
144
- setConfigCache(
145
- segmentationRepresentationUID,
146
- Object.assign({}, cachedConfig, {
147
- segmentsHidden: new Set(segmentsHidden),
148
- })
149
- );
150
-
151
- mapper.setLookupTable(lut);
152
- }
153
-
154
- viewport.render();
155
- }